Message Boards Message Boards

0
|
5810 Views
|
2 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Combine Styled Characters?

Posted 6 years ago

End result will be the PNG below, but when I use StringJoin to join Styled Characters, error pop up StringJoin::string: String expected at position 1 in StringJoin[M]. Possible issue is StringJoin works only with explicit strings, while TreeForm[Style["M",Red]] shows it is not a String and thus cannot use StringJoin, how could I make it?

StringJoin@Style[#, RandomColor[]] & /@ Characters["Mathematica"]

enter image description here

POSTED BY: freemanwangyl
2 Replies
Posted 6 years ago

Use StringForm instead of StringJoin.

Style[StringForm["`1``2``3``4``5``6``7``8``9``10``11`",
  Sequence @@ (Style[#, RandomColor[]] & /@ Characters["Mathematica"])],
 56, Italic, FontFamily -> "Times New Roman"]

enter image description here

POSTED BY: Mark Greenberg
(* Assumption->None, Method->"Spa****"; *)
Style[#, RandomColor[]] & /@ Characters["Mathematica"] // Row

or credit to Mark

StringForm[
 "`1``2``3``4``5``6``7``8``9``10``11`"
 , Sequence @@
   (Style[#, RandomColor[], 56, Italic, FontFamily -> "Times New Roman"] &
     /@ Characters["Mathematica"]
   )
]
POSTED BY: Raspi Rascal
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract