Inconsistent behaviour using string with superscript as label

This might be a silly question, but actually I lost a bit of time to figure out what I was doing wrong and now I want to understand better. Moreover, I'm not sure if the behaviour I see is a bug or not.

I was experimenting with the "new" PlotLabels functionality and I created a label which is a string with a superscript, i.e. I naively employed the usual superscript notation (ctrl+6) inside quotation marks. This is what I usually do for labels, copy-pasting the code it reads:

Plot[x^2, {x, -3, 3},PlotLabels -> "\!$$\*SuperscriptBox[\(x$$, $$2$$]\)"]


The result is a weirdly placed label that looks broken (Mathematica 11.3 on macOS). I lost some times to figure out what was the problem and it turns out it was the superscript: by writing the input "by hand" as "\!$$x\^2$$" everything works nicely. See this picture to understand what I mean.
Now, my question is: have I always done something fundamentally wrong by using superscript notation inside quotation marks for my labels? Is this a bug of PlotLabels?

Note that PlotLegends works as expected in both cases:

This might be a bug. However, I think linear syntax is evil, and would recommend that you avoid it like the plague. Instead, just use an expression:

Plot[x^2, {x, -3, 3}, PlotLabels -> x^2]


Question: What is linear syntax?

Answer: It is something like "!(x\^2)". This is what happens to a string when you perform 2D formatting inside of a string.

Question: Why do you think this is evil?

Answer: These are the main reasons:

1. It creates unintelligible code when displayed outside of the Front End (which happens all the time here on MSE).
2. It is extremely difficult to convert into a readable form that can be usefully displayed outside the Front End.
3. It mixes expressions and strings in a hidden way.

Something like:

"\!$$x\^2$$ vs x"


is basically equivalent to:

StringForm[" vs x", HoldForm[x^2]]


(It's a bit more complicated, but this gives the gist). The x^2 part is an expression, while the x part is a string. Now, Mathematica has the option SingleLetterItalics, which controls the font slant of single letter "symbols". So, in the following, notice that the x in x^2 gets italicized, while the string x does not:

Style["\!$$x\^2$$ vs x", SingleLetterItalics->True]


This hidden difference between symbols and strings causes endless confusion for people who use linear syntax in plots, where labels are by default displayed in TraditionalForm, which has the option SingleLetterItalics set to True.

• Thank you for your answer! What do you mean by "linear syntax is evil"? Anyways, now I notice that even my second plot has a weird spacing between the leader and the text! Do you think I should file a bug report? Commented Aug 31, 2018 at 6:59
• @justmyfault See update Commented Aug 31, 2018 at 18:07
• Thanks a lot, I will probably resort to using HoldForm as much as possible! Commented Sep 1, 2018 at 15:07