3

I have written in my work $X^{+},\,\rm{e}^{X},\,|X|^{p}$. Why is the second and third term not in italics?

lockstep
  • 250,273
Laura
  • 6,403
  • 2
    Because you used \rm instead of \mathrm. – JLDiaz Jul 18 '12 at 11:06
  • 1
    The command \rm is a switch, i.e., all subsequent material (until either the math environment ends or a different font-related switch is encountered) is affected by the command. To limit its scope, you should type {\rm e} instead of \rm{e}. Much better, though: Use \mathrm{e}. The command \rm is a holdover from "Plain TeX" and is not supported fully in LaTeX! – Mico Jul 18 '12 at 11:58
  • JLDiaz/@Mico: Please compose an answer so this can be marked as answered. – Peter Grill Jul 21 '12 at 22:12

2 Answers2

7

Because you used \rm instead of \mathrm.

\rm is not a macro which accepts an argument, as you apparently thought. The macro which does that is \textrm{text} for text mode and \mathrm{text} for math mode. Instead, macro \rm changes the current font to roman, from the point in which the macro appears until the end of the current scope (which is the end of the math mode in your case, but more generally the end of the group in which \rm appears).

Macros \it, \bf and \tt, work in the same line than \rm, and they have also a version which accepts one parameter, which are \textit{} (but more frequently \emph{}), \textbf{} and \textt{}.

Those two-letter macros which change fonts and styles are deprecated and should not be used. They are maintained for backwards compatibility.

JLDiaz
  • 55,732
2

Summing up what JLDiaz and Mico have said in the comments:

The correct thing to use here is \mathrm. So you should have:

$X^{+},\,\mathrm{e}^{X},\,|X|^{p}$

\rm is a font selection macro from Plain TeX and does a toggle, so that all subsequent material in the current scope will be affected. It would be possible to do {\rm e}, but actually \rm is deprecated in current LaTeX.

If you need something similar for text-mode you can use \textrm{some text} there.

In the case that you want to define math symbols similar to \sin you can use e.g. \DeclareMathOperator{\gr}{gr} from amsmath package, which adjusts the font too, but also takes care of spacing. You use it as \gr.

bodo
  • 6,228