Is there a standard in mathematics for typesetting the textual (not symbolic) identifiers of mathematical objects other than variables?
Textual identifiers of mathematical objects other than variables are typically
- function names (
\sin
,\log
); - constant names (
\textnormal{e}
,\textnormal{i}
); - variable specifiers (
n_\textnormal{water}
,\rho_\textnormal{air}
).
For constant names and variable specifiers, I use \textnormal
, according to egreg's great post which seems to me the most logical choice.
However function names are already defined by the American Mathematical Society in their amsopn
package and they use \mathrm
instead of \textnormal
(in \operatorname
and \DeclareMathOperator
). Because my question is not about the font style, let us assume that we are comparing \mathrm
and \textrm
(rather than \textnormal
).
Why does the American Mathematical Society use \mathrm
instead of \textrm
for function names?
According to egreg (in the comments of his own answer):
Because that […] wouldn't obey to \boldmath, for one thing
In classic LaTeX (not Unicode LaTeX) both use the same text font (so kerning and ligatures are activated), and indeed, the only difference is that
\mathrm
stays in math mode, so is affected by\boldmath
;\textrm
switches to text mode, so is not affected by\boldmath
.
But is there other reasons not to use \textrm
in function names? Because \textrm
has some serious advantages over \mathrm
:
- it doesn't need the mathcode modifications of
\operatorname
and\DeclareMathOperator
to prevent hyphens and stars from being converted to binary operators, and apostrophes from being converted to primes; - spaces are not gobbled.
Best Answer
There are in fact very few standards for such things. There is
ISO 80000-2
which is an ISO standard "Quantities and units — Part 2: Mathematical signs and symbols to be used in the natural sciences and technology" this is the standard referenced by the rather unfortunately namedisomath
package andmathstyle=iso
option tounicode-math
. (I say unfortunate as there is no generic ISO view on math styling, just that one particular style guide has been promoted through the ISO process does not imply other styles are wrong, or should not also go through ISO, just as ODF being standardised as an Office format as ISO/IEC 26300:2006 did not prevent a separate standard being defined for Open (Micorosoft) Office formats ISO/IEC 29500:2008 (although it does complicate the process slightly). The ISO 80000-2 style guides are fairly universally not followed by journals of mathematics.The choice of using Roman or italic or bold letters for such things as the differential
d
or vectors etc, is not something set by global standards but just part of the style choice set by a particular publication.However mostly your question seems not to be asking about the output (which is what is addressed by ISO 8000-2 and publishing style guides, but by the technical details of the TeX construct used to obtain that style, and there are no standards for that at all, other than the general LaTeX2e documentation on the font mechanism.
The question that you reference in your question, and egreg's answer, are not (mostly) comparing
\textrm
and\mathrm
but comparing using a text font designed for multi-letter identifiers with using the math italic font designed with large sidebearings separating individual letters used as the default math font.It is clear that multi-letter identifiers should always be set in a "font" that does not have the wide side-bearings and lack of ligatures that is typically used for single letter variables in traditional math settings. I say "font" as traditional TeX necessarily needs different fonts for these different uses, but with large opentype fonts, the different usage may be accommodated by different ranges within the same physical font.
So it is perfectly natural (and consistent with the quoted text) to use
\mathrm
for\log
and friends. Generally I would use\mathxx
settings for any identifier that is naming a mathematical object (in its widest sense, such as computer language identifiers if using math setting for pseudocode) and would use\textxx
settings for fragments of natural language that for reasons related to technicalities of the markup end up inside a math region. Examples includeif
andotherwise
clauses inside multi-line displays.Unicode 3.1 introduced the mathematical alphabets in the range starting from U+1D400, but the use of these is still evolving, and especially their mapping to typesetting requirements. Unicode does not distinguish a text italic style (using ligatures) from a math italic style, but just provides a range that distinguishes italic text in mathematics, exactly how that is typeset is out of scope for Unicode and left up to the designers of the font and typesetting systems. Currently with unicode-math the
\mathxx
commands do not change fonts but just translate the characters into the1d400
range, however currently OpenType math fonts do not style the characters in those ranges in a way suitable for multi-letter identifiers so it doesn't really work.In classic TeX where you are restricted to 16 families in a single math expression the choice between using the
\mathrm
or\textrm
mechanism is complicated by the extra consideration that using\text...
(ie, a hidden\mathchoice
construct around a text font\hbox
setting) allows you to add additional fonts without eating into the 16 math font limit, thus often it makes sense to use that mechanism for additional, rarely used fonts even if a\mathxx
mechanism would be logically more natural. This is less of an issue in Unicode TeX extensions where there are more families available and vastly more characters in each family.With a Unicode TeX there are three mechanisms for getting a different visual style for letters in math mode,
Translating the character to the math alphabet range, eg replace
A
byU+1D400
to get a bold Aallocating a roman font to a new math family and selecting
a
in that family (the traditional definition of\mathrm
not so easily available in unicode-math currently, although indirectly available by specifying a different font for the\mathup
range with\setmathfont
)using
\hbox{...}
and selecting a font using the text font mechanisms,\textbf{A}
to get a bold A.All of these mechanisms have a place, although it isn't clear yet how best to map them to TeX markup, and default styling behaviour.