Re: Use Style for symbol with a value?
- To: mathgroup at smc.vnet.net
- Subject: [mg84771] Re: Use Style for symbol with a value?
- From: Albert Retey <awnl at arcor.net>
- Date: Sun, 13 Jan 2008 05:49:16 -0500 (EST)
- References: <fm9b8a$j1a$1@smc.vnet.net>
Murray Eisenberg wrote: > 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.) > I would do: SetAttributes[myStyled,HoldAll] ReleaseHold[ myStyled/@ Hold[x,f[x],y] ] does that fit your needs? I haven't tried this with your code but think it should work... hth, albert