Re: Different Color in ToString
- To: mathgroup at smc.vnet.net
- Subject: [mg125625] Re: Different Color in ToString
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Thu, 22 Mar 2012 05:51:50 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
On 3/21/12 at 5:44 AM, scolwell at uoguelph.ca (Scott Colwell) wrote: >Does anyone know how to change the color of the font in a ToString >command. >For example, in the following, the text should be blue, but the >number 3 should be red. >n = 3; >Text[Style["There is "<> ToString[Style[n, Red]] <> " numbers here", Blue]] This cannot do what you want for two reasons. First, the command ToString outputs black strings and undoes the effect of Style[n,Red]. And even if this did what you wanted you compose a string by string joining all the pieces then set the style of this new string to blue. So the result will be a blue string. Look at the output of this which I think does what you want Grid[{{Style["There are ", Blue], Style[n, Red], Style[" numbers here", Blue]}}, Spacings -> 0]