MathGroup Archive 2008

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

Search the Archive

Re: Constructing a Label

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93399] Re: Constructing a Label
  • From: Nikolaus Rath <Nikolaus at rath.org>
  • Date: Thu, 6 Nov 2008 04:05:46 -0500 (EST)
  • References: <gepb15$sfr$1@smc.vnet.net>

Nikolaus Rath <Nikolaus at rath.org> 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 there
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
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 majority.
  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: Re: Eliminating common factors?
  • Next by Date: Re: Re: Eliminating common factors?
  • Previous by thread: Re: Constructing a Label
  • Next by thread: RE: Re: Constructing a Label