MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Constructing a Label

  • To: mathgroup at
  • Subject: [mg93444] Re: Constructing a Label
  • From: magma <maderri2 at>
  • Date: Sat, 8 Nov 2008 03:59:45 -0500 (EST)
  • References: <gepb15$sfr$> <24955424.1225964460341.JavaMail.root@m02>

On Nov 7, 12:01 pm, "David Park" <djmp... at> wrote:
> f[x_] := 2/3 Sin[x^2];
> I would consider the first method to be the best:
> Row[{"f[x] = ", f[x]}]
> This is because it is the most direct and intuitive. The second method
> involves descending in to box structure programming, which the new featur=
> of Version circumvent.
> The third method with HoldForm is also ok, but if f is define within a
> Module with f being a Module variable, then you won't like the result
> because it won't be a simple 'f'.
> The StringForm method is a nice trick, but it is not as versatile or
> intuitive as the Row method.
> The last method is too arcane and too old fashioned. ToString, by default=
> formats to the old OutputForm, which uses multiple lines for the 3D form =
> expressions. That's why you have to specify TraditionalForm or StandardFo=
> If you look at the FullForm of the ToString expression you will see that
> Mathematica uses the lower level specification for boxed structures:
> ToString[TraditionalForm[f[x]]] // FullForm
> "\!\(TraditionalForm\`\(2\\ \(\(sin(\(\(x\^2\)\))\)\)\)\/3\)"
> Using Column and Row to build up displays is a nice new method in Version=
> and it's worthwhile getting to know how to use them.
> David Park
> djmp... at comcast.net
> From: Nikolaus Rath [mailto:Nikol... at]
> Nikolaus Rath <Nikol... at> writes:
> > Hello,
> > I want to automatically construct labels of the form
> > "A = <value of A>" for a number of plots.
> > However, I cannot quite figure out how to generate the above
> > expression.
> I have now received quite a number of different solutions for this
> problem (now for some general function f[x]):
> f[x_] := 2/3 Sin[x^2];
> Row[{"f[x] = ", f[x]}]
> DisplayForm[RowBox[{"f[x] = ", f[x]}]]
> HoldForm[f[x]] == f[x]
> StringForm["f[x] = ``", f[x]]
> "f[x] = " <> ToString[TraditionalForm[f[x]]]
> While they all seem to work equally well for my problem, I do not
> quite understand how the last two expressions can actually work out. I
> thought that a String is just a sequence of unicode characters, so how
> is it possible that it renders as true fraction?
> Moreover, this really made me curious in which way the above
> expressions differ. The only difference that I found when evaluating
> them is that the last one (obviously) only renders in traditional form
> and that HoldForm only works if I use == instead of =. But are ther=
> other differences? An should I prefer some variant over the others?
> Personally, the variant with HoldForms seems most natural to me,
> because it directly expresses what I want to do ("print f[x] in
If you are not interested in Traditional form, then either the
Holdform or the Row example are good, but if you like to use
Traditional form, I would suggest

Row[{HoldForm[f[x]], " = ", f[x]}] // TraditionalForm

which is simple enough and replicates as much as possible standard
high quality printouts.


> evaluated and unevaluated form").
> I'd be interested  in hearing other opinions about this.
> Best,
>    -Nikolaus
> --
>  =C2=BBIt is not worth an intelligent man's time to be in the major=
>   By definition, there are already enough people to do that.=C2=AB
>                                     =
                     -J.H. Hardy
>   PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6  02CF A9AD B7F8 AE4E 425C

  • Prev by Date: Re: NIntegrate[UnitStep[...]PDF[...],{x,...}] hard to integrate
  • Next by Date: Re: From reactions to differential equations
  • Previous by thread: Re: Re: Constructing a Label
  • Next by thread: Re: Constructing a Label