3

I have not found this question asked previously.

I am fine with math using italics for variables when the math appears in a normal context. But our figure captions are in italics, and when math is used in a caption, we need to flip all math italics to Roman and vice versa.

I know how to do this by using \mathrm{} and \mathit{}, but if we have a caption like, say,

\begin{figure}  
\caption{As $|\Psi(x_0,t)|^2$ represents yadayada and $x_0$ blah at time $t$, it is clear that foobazz.}  
\end{figure}

that's something like eight mathematical elements that have to be manually defined to Roman or italics. Get a dozen or so figure captions like this and things are error-prone, never mind being a PITA.

So: is there a way to get amsmath to invert it's normal italics/Roman behavior when inside a caption?

16
  • 4
    in your question you refer to \mathit (which is a text italic font, used in math) but your examples just have $x$ which is the math italic font (which isn't the same thing at all). The usual model is that math alphabets carry semantic meaning and latex goes to some effort to ensure they do not change with the surrounding text style, so what you ask is of course possible (it's open source anything can be changed) it isn't really how it is designed to work. Commented Jul 31, 2014 at 13:21
  • 3
    You could define a new mathversion which uses other fonts, but you really should do it as David already pointed out. Math fonts carry meaning. I also wouldn't write captions in italics: italics emphasize and so are not a good choice for "side" information. Commented Jul 31, 2014 at 14:31
  • 1
    I naturally meant "you really should not do it ...". Commented Jul 31, 2014 at 15:21
  • Part of the point of using italics in math is to emphasize the difference between the math and the surrounding text. If the surrounding text is italics, the italics generated by $x$ doesn't emphasize anything at all. Commented Jul 31, 2014 at 15:56
  • 1
    Just seen this. "to get help with LaTeX problems": not only LaTeX problems, but also with style problems. We're not arrogant here, although we have strong opinions, and many of us are inclined to ask "why so ugly when it can be really beautiful with LaTeX". You're not the first, and you won't be the last. Commented Aug 31, 2014 at 6:06

1 Answer 1

4

Do not do this!

You can use the deprecated macros \rm and \it to switch between families.

This is one of the ugliest things I've ever seen.

\documentclass{article}
\usepackage{caption,etoolbox}
\captionsetup{font=it}
\everymath{\it}
\preto\caption{\everymath{\rm}}
\begin{document}
As $|\Psi(x_0,t)|^2$ represents yadayada and $x_0$ blah at time $t$, it is clear that foobazz.

\begin{figure}
  \caption{As $|\Psi(x_0,t)|^2$ represents yadayada and $x_0$ blah at time $t$, it is clear that foobazz.}
\end{figure}

\begin{center}
  \captionof{figure}{As $|\Psi(x_0,t)|^2$ represents yadayada and $x_0$ blah at time $t$, it is clear that foobazz.}
\end{center}

As $|\Psi(x_0,t)|^2$ represents yadayada and $x_0$ blah at time $t$, it is clear that foobazz.
\end{document}

enter image description here

2
  • Step in the right direction, thanks. But numbers (and anything else that is Roman in a Roman context) need to be italicized in the italics context. Commented Jul 31, 2014 at 16:33
  • 1
    @PeterCastine See my updated answer. Please don't do this! Commented Jul 31, 2014 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .