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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can you explain me what is the difference between \textrm{} and \mathrm{} when they are used in math mode. In what context one is preferred over the other?

share|improve this question
There's a similar question here, relating to \text vs. \mathrm. Is there a preference of when to use \text and \mathrm?. – Alan Munn Jul 5 '11 at 5:37
@Alan Munn: Thanks for the link! – Marco Jul 5 '11 at 5:56
The one is using text fonts and the other one math fonts which can be quite different, right? – Martin Scharrer Jul 5 '11 at 7:10
up vote 33 down vote accepted

\textrm (and the corresponding switch \rmfamily) changes an aspect of the font – in this case the family. If possible other aspects – like the series (bold or not) or the shape (italic) – are preserved. \text...-commands can be nested and their "aspect changes" are combined:


\sffamily\bfseries\itshape abc

\mathrm and the other math alphabets don't change only an aspect of a font. They switch to specific fonts. They make it possible to print symbols in special fonts. It is quite possible to setup things so that e.g. \mathrm use times, \mathbf is a bold palatino, \mathit a slanted Arial etc. You can also confuse everyone by defining \mathbf to be light itshape palatino and \mathit a bold Arial. You can define your own special math fonts e.g. \mathvector or \mathmatrix or \mathfancy. As all these commands switch to dedicated font they can't be nested. The last command (the inner one) always wins:




share|improve this answer

Your Answer


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.