I have written in my work $X^{+},\,\rm{e}^{X},\,|X|^{p}$. Why is the second and third term not in italics?
2 Answers
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.
- 55,732
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.
- 6,228
-
Oops... We collided, I was redacting my answer at the same time than you. Sorry – JLDiaz Jul 23 '12 at 19:02
-
-
No idea... I guess we can leave both answers until a moderator gives us advice. – JLDiaz Jul 23 '12 at 19:21
\rminstead of\mathrm. – JLDiaz Jul 18 '12 at 11:06\rmis 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\rmis a holdover from "Plain TeX" and is not supported fully in LaTeX! – Mico Jul 18 '12 at 11:58