Uniconizing "\!\(\*SubscriptBox[\(a\), \(b\)]\)" // Iconize
creates an ungrammatical box structure.
I see something different than what is being discussed in the comments ("14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)"
, in case it matters). And it seems to be a bug. The OP's remarks sometimes seem centered on a different issue. A clear use-case (example) is not given, beyond the one that led me to the issue below. The non-issue, which others focus on in the comments, is the string representation "\!\(\*SubscriptBox[\(a\), \(b\)]\)"
of subscripts. The buggy issue is what happens to this when you iconize it and then uniconize it. The longer the discussion in the comments goes on, the more it seems likely that the OP is interested in the ameliorating the inconvenience of the non-issue in plot labels and has not noticed the issue below which addresses the code that was explicitly asked about. An XY Problem, perhaps.
The bug
One of the outputs in Out[301]
below is the output of uniconizing and one is the output of FullForm
— can you guess which?
But wait! The inputs in In[301]
look the same! However their internal box structure is different. Here are the output cells generated by uniconizing Iconize
and by FullForm
:
$I.$
The syntax errors come from the individual "\""
and "\\!"
. When these are replaced by "Q"
and "ESC"
, which strings represent symbols, the expression is parsed without errors.
$\;{I}{I}.$
For some reason the strings "\\("
, "\\)
and "\\*"
are ignored. RowBox[{"\\(", "a", "\\)"}]
is interpreted as the String
expression "a"
(same for "b"
).
$\;{I}{I}{I}.$
The nested RowBox
-es are interpreted as nested Times[]
or function expressions. For instance, RowBox[{"f", "[", RowBox[{"x", ",", "y"}], "]"}]
is f[x, y]
. This construction appears once above with SubscriptBox
for f
. Note it is (i) RowBox[{"SubscriptBox", "[", ..., "]"}]
, not (ii) SubscriptBox["a", "b"]
, which is the box form for (iii) Subscript[a, b]
. Box expression (i) is in effect the box form of the box form of (iii), but with nonstandard expressions for argument strings "a"
, and "b"
.
Here is what MakeExpression
makes of the boxes from the uniconized string with the ungrammatical tokens "\""
and "\\!"
replaced by "Q"
and "ESC"
.
MakeExpression[
RowBox[{"Q",
RowBox[{"ESC",
RowBox[{"\\(",
RowBox[{"\\*",
RowBox[{"SubscriptBox"
, "["
, RowBox[{
RowBox[{"\\(", "a", "\\)"}], ",", " ",
RowBox[{"\\(", "b", "\\)"}]}]
, "]"}]}],
"\\)"}]}], "Q"}]
, StandardForm] // FullForm
(* HoldComplete[Times[Q, Times[ESC, SubscriptBox["a", "b"]], Q]] *)
ToString[<<your string here>>, InputForm]
to see what it really looks like. $\endgroup$MakeBoxes
are different. So I don't think it's aMakeBoxes
problem. Maybe. $\endgroup$"\"\\!\\(\\*SubscriptBox[\\(a\\), \\(b\\)]\\)\"" // ToExpression
will evaluate the expression. $\endgroup$