I apparently can't see the difference in a compilation (pdflatex) between \mathrm and \operatorname. So, as in the title the question is: is there a difference? Which one is preferable in what occasions?

  • 1
    "\mathrm is used to make variables and units appear in roman (non-italic) text." - You can use it for units for example.
    – Avatar
    Commented Oct 21, 2020 at 6:50

3 Answers 3


There are many differences. The main one is in the fact that \mathrm{xyz} behaves like an ordinary letter, while \operatorname{xyz} behaves like function names such as \sin. Here's an illustration

$\sin x + \sin(x+y) + a\sin z$

$\mathrm{sin} x + \mathrm{sin}(x+y) + a\mathrm{sin}z$

enter image description here

where it's clear that the second line is typeset wrong. Even if your "operator" requires parentheses after it, it should be \operatorname, as the third summand shows, where a thin space separates the coefficient from the operator.

Another subtle difference is in how some characters are interpreted in \mathrm and in \operatorname. Suppose you have an operator to be called "pre-norm", with a hyphen. Here's the example



enter image description here

and now it's clear what is to be used. Indeed \operatorname (and the same holds for macros defined with \DeclareMathOperator) treats punctuation symbols in a special way; \mathrm, instead, treats them as math symbols.

  • 11
    Can you please tell the full form of the rm in mathrm? Thank you! Commented Feb 14, 2018 at 5:12
  • 23
    @GaurangTandon rm stands for “roman”, that conventionally denotes the upright type used in the document.
    – egreg
    Commented Feb 14, 2018 at 8:59
  • 2
    Wrapping \mathrm with \mathop addresses the first point (spacing). Replacing \mathrm with \textrm addresses the second point (characters interpreted as math inside \mathrm{...}). So the next question is: what’s the difference between \mathop{\textrm{...}} and \operatorname{...}?
    – Maëlan
    Commented May 11, 2022 at 22:03
  • 2
    @Maëlan Try $\mathop{\textrm{xyz}}$ inside a theorem statement typeset in italics.
    – egreg
    Commented May 11, 2022 at 22:19


The argument is written in upright mode but with some additional space before and behind.


It is like math mode (no spaces), but in upright mode. The font size isn't changed.

The following example shows the differences:


enter image description here


In other LaTeX environments \mathrm{xyz} is useful. In MathJax v 2.0

$ i \\, \mathrm{sinh} \; $

gave the equivalent output as $ i \sinh x $. MathJax did not recognize \operatorname.

  • 15
    \operatorname is now supported with the ASMmath.js TeX extension.
    – ChrisR
    Commented Dec 4, 2013 at 16:10
  • 8
    Typo in the comment by @ChrisR (important if you're searching): it's AMSmath.js, (not ASMmath.js). Commented Feb 14, 2020 at 20:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .