It is very easy and convenient to write textual labels as Strings in the WYSIWYG mode. For example, I define a short form describing a linear model: "2D3O", which means "two descriptors of type D and tree descriptors of type O". Everything is good so far. Now I wish to add superscripts and use standard palette to add them. I get

Looks nice. But at some point I have a lot of such labels and wish to apply some formatting to all of them at once. For example, I wish to make all the digits Bold and all the letters Gray. FullForm shows internal structure and I see the string representation of boxes:

This is not a format easy to deal with. The tutorial explains how to convert ordinary boxes to its string representation using ToString. But what is the general way to convert string representation of boxes into explicit boxes?



MakeBoxes@@ToHeldExpression@stringhelp? – Simon Woods May 03 '14 at 10:16"3\!\(\*SuperscriptBox[\(R\), \(2\)]\)2O".MakeBoxesreturns a box structure with redundant space character (representing multiplication produced byToHeldExpression). – Alexey Popkov May 03 '14 at 10:27ToExpressionis very fragile way to convert string representation of boxes because it requires syntactically correct expression inside of the string. – Alexey Popkov May 03 '14 at 10:33FEis interpreting such expression. I don't know how to fight this without decomposing everythig. Take a look atStringForm["\!\(\*SuperscriptBox[\(````\), \(``\)]\)", Style["R", Gray], Style[3, Bold], Style[1, Bold]]– Kuba May 03 '14 at 13:24ResourceFunction["StringToBoxes"]. The docs provide some good example usage. – Tanner Legvold Jan 04 '21 at 03:56