MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Different Color in ToString

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125627] Different Color in ToString
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Fri, 23 Mar 2012 01:30:58 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

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


I would do as follows:

myNr[x_Numeric] := Text@Style[ToString[x], Red];
myText[x_String] := Text@Style[x, Blue];

n = 3;
Row[{myText["There is "], myNr[n], myText[" numbers here"]}]

Try it.

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at iee.lu






  • Prev by Date: Type-Ahead Searches in a Manipulate or Dynamic Module
  • Next by Date: GConf errors when running from cron
  • Previous by thread: Re: Different Color in ToString
  • Next by thread: Re: Different Color in ToString