Differences among \mathrm, \text, and \operatorname in LaTeX
📂WritingDifferences among \mathrm, \text, and \operatorname in LaTeX
\mathrm, \text
code1
sin(mathrm)sin(text)basic font: abcdefghijklmnopqrstuvwxyz
When you look at the default setting, there seems to be no difference in rendering between \mathrm and \text. That is because the default font itself is exactly the same as \mathrm. \mathrm is precisely rendered in Roman type, while \text follows the font that has been set. Therefore, changing the font would result in the following rendering.
sin(mathrm)sin(text)basic font: abcdefghijklmnopqrstuvwxyz
\operatorname
Both \mathrm and \text render 'characters', whereas \operatorname, as the name suggests, renders it in a way that it can appear as an operator. For instance, the sine function rendered in four ways looks as follows.
code2
asinx(mathrm)asinx(text)asinx(operatorname)asinx(sin)
In the case of \mathrm and \text, it’s not clear whether it’s asinx or a sin x, but with \operatorname, it’s easy to see that the sin part signifies an operator.
\operatorname*
Adding ∗ behind, there’s no difference in inline mode, but in display mode, the subscript moves above and below.
code3
ProjabProjab( inline mode)
ProjabaProjb( display mode)