Use Style for symbol with a value?
- To: mathgroup at smc.vnet.net
- Subject: [mg84734] Use Style for symbol with a value?
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Fri, 11 Jan 2008 22:08:27 -0500 (EST)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- Reply-to: murray at math.umass.edu
I have some symbols that already have values, e.g.: x = Sqrt[2]; f[t_]:=t^2; y = Pi; I want to display the raw expression f[x] in a TraditionalForm and with a Styled treatment. Of course this is easy to do with a HoldForm, e.g.: Style[TraditionalForm[HoldForm[f[x]]], Large, Bold] But I have multiple instances of this situation within a single large expression, so I want to modularize this by defining a function to do the formatting -- something like: myStyled[txt_] := Style[TraditionalForm[HoldForm[txt]], Large, Bold] Now of course this will NOT work, since in myStyled[f[x]] the expression f[x] will be evaluated first, and instead of seeing the TraditionalForm equivalent of f[x] I'll see just the value 2. Now that is easily remedied by using, instead: myStyled[HoldForm[f[x]]] So far so good. But I have several expressions to which I want to apply the styling -- something like {myStyled[HoldForm[x]],myStyled[HoldForm[f[x]]],myStyled[HoldForm[y]]} -- and I would like to be able to avoid wrapping each of the individual items in HoldForm so as to reduce the length and complexity of the code there. Is there some way of defining myStyled and using some appropriate form of Hold that will accomplish this. Ultimately I'd even like to do something like myStyled /@ whatGoesHere[{x,f[x],y}] where whatGoesHere holds things in the list so it all works. (Hope I'm clear in what I'm trying to do.) -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305