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?
[Tex/LaTex] What’s the difference between \mathrm and \operatorname
amsmathmath-modemath-operators
Best Answer
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 illustrationwhere 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 exampleand 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.