MathGroup Archive 2012

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

Search the Archive

Re: Different Color in ToString

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125638] Re: Different Color in ToString
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Sat, 24 Mar 2012 02:01:55 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201203230631.BAA20312@smc.vnet.net>

The solution shown does not work. The LHS of the definition of myNr
should read myNr[x_?NumericQ]

Unlike String, Numeric is not a Head so you need a PatternTest ( ? )
followed by a test (e.g., NumericQ).


Bob Hanlon

On Fri, Mar 23, 2012 at 2:31 AM, Scott Colwell <scolwell at uoguelph.ca> wrote:
> That is perfect, thanks Alexei.
>
> SC
>
> ----- Original Message -----
> From: "Alexei Boulbitch" <Alexei.Boulbitch at iee.lu>
> To: mathgroup at smc.vnet.net
> Cc: scolwell at 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 at 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
>



  • Prev by Date: Re: Type-Ahead Searches in a Manipulate or Dynamic Module
  • Next by Date: Re: new functional operator
  • Previous by thread: Re: Different Color in ToString
  • Next by thread: How to change the inline cell style in the StyleSheet