The default format for Graphics
is TraditionalForm
:
Options[GraphicsBox, FormatType]
{FormatType -> TraditionalForm}
TraditionalForm
uses SingleLetterItalics
:
CurrentValue[{StyleDefinitions, "TraditionalForm", SingleLetterItalics}]
True
SingleLetterItalics
displays single letter variables in italics. Note that single letter strings are not variables, and so they do not get italicized. So, in the following, the first output is in italics, while the second output is not:
y //TraditionalForm
"y" //TraditionalForm
y
y
So, three simple approaches to avoid italics are:
- Use
StandardForm
(which has SingleLetterItalics->False
)
- Use strings instead of variables
- Put your labels inside of a
Style
wrapper (e.g., Style[y, Plain]
or Style[y, SingleLetterItalics->False]
)
Now, for the question about why your example had a mixture of italic and plain variables. Mathematica typesetting converts expressions into boxes in order to show them in two-dimensional form. For example:
MakeBoxes[x/π, TraditionalForm] //InputForm
FractionBox["x", "π"]
Notice the presence of the box form FractionBox
and that the variable x
and constant π
have been converted to their symbol names "x"
and "π"
. One can use DisplayForm
to print boxes inside an expression in explicit two-dimensional form (I prefer RawBoxes
to DisplayForm
, because DisplayForm
encourages the mixing of expressions and boxes, and I think they should never be mixed). Your first label:
DisplayForm[FractionBox["x", "π"]]
is thus equivalent to the typeset form of x/π
, and so naturally in TraditionalForm
the x
is displayed in italics. Your second label:
Superscript["y", "0"]
is just an expression, and so the "y" is not displayed in italics. If you had used:
DisplayForm[SuperscriptBox["y", "0"]]
instead, then since SuperscriptBox
is a box form, "y"
would be the box representation of the variable y
and it would have been displayed in italics.
Here then are a few examples of a FrameLabel
option that would not typeset anything in italics:
FrameLabel -> {"x"/π, "y"^"0"}
FrameLabel -> {"x"/π, HoldForm["y"^0]}
FrameLabel -> {
Style[x/π, SingleLetterItalics->False],
Style[Superscript[y,0], Plain]
}
Superscript["y", "0"]
withSuperscript["y", "z"]
and you will see that exponents are set in italics in general. $\endgroup$y
is also not in italics in your example. That's weird; it is typeset correctly in MMA 11.0.1 for macos. Maybe applying theStyle
to both framelabels by hand would help. $\endgroup$SingleLetterItalics
is switchingTrue
andFalse
$\endgroup$