7

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.
2
  • 1
    I think the problem here is the fact that euler is not a typical font, it has its singularities (so the choice for text font in \log would be just because of euler font). In a more general sense: \sin is maths, e is maths, air is not maths. So, it's okey to have \log with \mathrm, it's acceptable (depending on the choice if you prefer upright math constants) to have \mathrm{e}, but air is not maths (altough I write it usually with \mathrm{air} may be \textnormal is the most correct way).
    – Manuel
    May 23, 2015 at 12:54
  • 1
    Besides the purely logical reasons, there is also a reason of efficiency: \textnormal makes use of \mathchoice and therefore typesets its argument four times (one for each of the four math styles), whereas \mathrm simply stores the characters that appear inside its argument directly in the math list, as characters of the appropriate family (whose size will be decided only when the math list is dismantled and converted to an horizontal list).
    – GuM
    May 23, 2015 at 15:24

1 Answer 1

11

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 named isomath package and mathstyle=iso option to unicode-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 include if and otherwise 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 the 1d400 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 by U+1D400 to get a bold A

  • allocating 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.

1
  • 1
    Thank you for this great answer! I think my question was too vague so I improved it.
    – Géry Ogam
    May 24, 2015 at 18:11

You must log in to answer this question.

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