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


Groups > comp.soft-sys.math.mathematica > #9205

Re: Different Color in ToString

From Scott Colwell <scolwell@uoguelph.ca>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Different Color in ToString
Date 2012-03-23 06:32 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jkh5dn$jrp$1@smc.vnet.net> (permalink)

Show all headers | View raw


That is perfect, thanks Alexei.

SC

----- Original Message -----
From: "Alexei Boulbitch" <Alexei.Boulbitch@iee.lu>
Cc: scolwell@uoguelph.ca
Sent: Thursday, 22 March, 2012 5:28:43 AM
Subject: Different Color in ToString

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=C2 :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu




--
Scott R. Colwell, Ph.D.
Associate Professor, Dept. of Mkt/Cons Studies
Adjunct Professor, Dept. of Psychology
MINS Building 201a
University of Guelph
Guelph, Ontario, Canada, N1G 2W1

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Different Color in ToString Scott Colwell <scolwell@uoguelph.ca> - 2012-03-23 06:32 +0000

csiph-web