Skip to main content
2 of 2
deleted 16 characters in body
Sjoerd C. de Vries
  • 66.2k
  • 15
  • 189
  • 327

If you evaluate or print the following string you get what you want:

"\!\(\*StyleBox[\"text\",FontColor->RGBColor[1, 0, 0]]\) \!\(\*StyleBox[\"text\",FontColor->RGBColor[0, 0, 1]]\)"

Mathematica graphics

This is a single string and it contains color information for different substrings.

Do[Print@"\!\(\*StyleBox[\"text\",FontColor->RGBColor[1, 0, 0]]\) \!\(\*StyleBox[\"text\",FontColor->RGBColor[0, 0, 1]]\)", {5}]

Mathematica graphics

Sjoerd C. de Vries
  • 66.2k
  • 15
  • 189
  • 327