3

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

3
  • 2
    Because you used \rm instead of \mathrm.
    – JLDiaz
    Jul 18, 2012 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, 2012 at 11:58
  • JLDiaz/@Mico: Please compose an answer so this can be marked as answered. Jul 21, 2012 at 22:12

2 Answers 2

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.

1
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.

3
  • Oops... We collided, I was redacting my answer at the same time than you. Sorry
    – JLDiaz
    Jul 23, 2012 at 19:02
  • @JLDiaz: what is normally done in such cases?
    – bodo
    Jul 23, 2012 at 19:06
  • No idea... I guess we can leave both answers until a moderator gives us advice.
    – JLDiaz
    Jul 23, 2012 at 19:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.