Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
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 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer

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.

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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