# 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"]

• 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