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


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

Re: Different Color in ToString

Started byBill Rowe <readnews@sbcglobal.net>
First post2012-03-22 10:54 +0000
Last post2012-03-22 10:54 +0000
Articles 1 — 1 participant

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


Contents

  Re: Different Color in ToString Bill Rowe <readnews@sbcglobal.net> - 2012-03-22 10:54 +0000

#9201 — Re: Different Color in ToString

FromBill Rowe <readnews@sbcglobal.net>
Date2012-03-22 10:54 +0000
SubjectRe: Different Color in ToString
Message-ID<jkf0d8$8lk$1@smc.vnet.net>
On 3/21/12 at 5:44 AM, scolwell@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]

[toc] | [standalone]


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


csiph-web