I'm unsure of when it is preferable to use \text
versus \mathrm
, is there some unwritten rule about the use of these?
For example, I saw the following code in a math post:
\frac{\mathrm{lcm}(m,n)}{\mathrm{gcd}(m,n)}\quad\text{divides}\quad
\frac{\mathrm{lcm}(m,n)}{|\langle x\rangle\cap\langle y\rangle|}\quad
\text{divides}\quad \mathrm{ord}(ab)\quad\text{divides}\quad
\mathrm{lcm}(m,n).
and there is a mix of both. Is there a general reason why the author would choose to do so?
Best Answer
Caution: the following discussion assumes that the package amsmath has been loaded.
In general
\mathrm
should be used for "symbols" and\text
for, yes, text. :)However, it's best to use operators for clusters of Roman letters that represent functions: the commands
\lcm
and\gcd
are predefined; for "ord" there's not a predefined command, but it suffices to put in the preamble(the command's name can be what one wants). The input before would become
In this case
\text{divides}
and\mathrm{divides}
might give the same result, but they are conceptually different (and can actually be printed in different ways, depending on the math fonts used). Spaces in the argument of\mathrm
are ignored, for example. Moreover,\text
honors the font of the surrounding environment: it will print in italics in the statement of a theorem.Particular attention should be paid to units such as "m/s"; it's best not to do them "by hand", but employ a package like siunitx that takes care of all the subtleties, while being very flexible.