# How do I control italicization of text in axes and frame labels?

How do I prevent my text from being italicized when I annotate it with additional glyphs?

For example if I add a "hat" to a variable, z as in $\widehat z$, but want z to not be italicized to match its use elsewhere:

Remove[z];
Plot[x^2, {x,-5,5},
AxesLabel->{"P("<>ToString@StringForm["",z]<>")",
"Q("<>ToString@StringForm["Overscript[, ^]",z]<>")"},
PlotTheme->"Classic"]


Conversely, how do I force z to be italic when it lacks an annotation (ToString@Style[z,Italic] doesn't do the trick)?

Note: This answer has some more details for the first part of your question (i.e. how to prevent italic letters)

To get everything italic, simply specify everything as expression instead of as string:

Plot[x^2, {x, -5, 5}, AxesLabel -> {P[z], Q[OverHat[z]]}, PlotTheme -> "Classic"]


To prevent italic letters, use SingleLetterItalics: (from the linked answer)

Plot[x^2, {x, -5, 5},
AxesLabel -> Thread@Style[{P[z], Q[OverHat[z]]}, SingleLetterItalics -> False],
PlotTheme -> "Classic"
]


• That doesn't generalize well beyond the simple example. The expression I need is more along the lines of P[b|X,Overscript[\[CapitalTheta], ^]\p]/P[Overscript[b, ^]| ...], which I have to build with a mess like ToString[p],"P("<>ToString[p]<>"|X,Overscript[\[CapitalTheta], ^]\\" <> ToString[p]<> ") / P( "<>ToString@StringForm["Overscript[, ^]",p]<>"|...)", which would be made yet worse if I wanted to fixe the italicized $\widehat b$. – orome Sep 10 '17 at 21:26
• I think I still don't fully understand your issue - for me, something like P[b | X, OverHat@p]/P[OverHat@b | \[Ellipsis]] // TraditionalForm looks like it should. And what do you want to achieve with your mix of StringForm and ToString? Does p have a value assigned? If so, what value? – Lukas Lang Sep 10 '17 at 22:04
• Let me see if I can work up a more useful MWE (though the process may lead me back to Python; why are strings, and output in general, such a mess in MMA?). – orome Sep 10 '17 at 22:16
• OK, I think (after messing with this for too long) I see and just want to conform. Basically, to get anything interesting done, the idiom for each idem in AxesLabel or FrameLabel needs to be of the form Style[Row@{...},options...]. If that's about right then I think I got it. – orome Sep 11 '17 at 13:18