Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9180 > unrolled thread

Different Color in ToString

Started byScott Colwell <scolwell@uoguelph.ca>
First post2012-03-21 10:45 +0000
Last post2012-03-22 10:49 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Different Color in ToString Scott Colwell <scolwell@uoguelph.ca> - 2012-03-21 10:45 +0000
    Re: Different Color in ToString David Reiss <dbreiss@gmail.com> - 2012-03-22 10:48 +0000
    Re: Different Color in ToString Helen Read <readhpr@gmail.com> - 2012-03-22 10:49 +0000

#9180 — Different Color in ToString

FromScott Colwell <scolwell@uoguelph.ca>
Date2012-03-21 10:45 +0000
SubjectDifferent Color in ToString
Message-ID<jkcbgl$qed$1@smc.vnet.net>
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]]

Thank you,

[toc] | [next] | [standalone]


#9190

FromDavid Reiss <dbreiss@gmail.com>
Date2012-03-22 10:48 +0000
Message-ID<jkf01n$8h2$1@smc.vnet.net>
In reply to#9180
Text[Row[{Style["There is ", Blue], Style[ToString[n], Red],
   Style[" numbers here", Blue]}]]

--David

On Mar 21, 6:45 am, Scott Colwell <scolw...@uoguelph.ca> 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]]
>
> Thank you,

[toc] | [prev] | [next] | [standalone]


#9191

FromHelen Read <readhpr@gmail.com>
Date2012-03-22 10:49 +0000
Message-ID<jkf03l$8i4$1@smc.vnet.net>
In reply to#9180
On 3/21/2012 6:45 AM, 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]]
>
> Thank you,
>

Use Row.

n = 3;
Row[{Style["There is ", Blue], Style[n, Red, Bold],
   Style[" numbers here", Blue]}]

Row can mix strings with expressions, with no need for ToString.

-- 
Helen Read
University of Vermont

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web