# Why and since when does \mathrm render ligatures?

As explained in answer to this question and several others as well as in various other ressources, \mathrm is for setting upright math symbols (and may thus cause problems when used for text). So if, for whatever reason, I denote something with an upright f and something else with an upright i and want to multiply the two, \mathrm{fi} or \mathrm{f}\mathrm{i} should do the job and especially not employ any ligatures.

While I am rather sure that the above statement was correct not too long ago, my current distribution (TeX Live 2012) as well as this tool renders a ligature:

(Note that I am not looking for a way to avoid this.)

Minimal example:

\documentclass{article}
\begin{document}
$\mathrm{f}\mathrm{i}$
\end{document}

• I don't think the behavior has ever been of splitting the ligature. Since the font used has a nonzero interword space, ligatures are applied when two characters in that font are next to each other. – egreg Jan 17 '14 at 13:35
• It is like this from the beginning of TeX. – egreg Jan 18 '14 at 10:05
• While you may not be looking for a way to avoid it, others may. So here it is: \mathrm{f}\,\!\mathrm{i} – Steven B. Segletes Mar 31 '14 at 0:59
• @SeanAllred -- no, we have potentially not yet reached the point where "all bugs become features". knuth, on his c&t web page, under "errata", announces that "I intend to check on purported bugs again in the years 2020, 2028, 2037, etc." of course, this depends on his continuing good health, but don't assume it won't continue, please. – barbara beeton Apr 1 '14 at 15:04
• @SeanAllred -- actually, two "major" bugs were reported and corrected in the most recent cycle; knuth's report of the "tuneup" will appear in the issue of tugboat now in preparation. as for where this ligaturing mechanism is located, it is in tex itself (not in plain.tex) since it is a function of the font properties, which are handled in the core, not as macros. (david's answer has given the reasons why this particular report would not be considered a bug. but that doesn't mean that there are no bugs left; they just get more and more obscure.) – barbara beeton Apr 1 '14 at 16:03

This is by design (mostly:-).

\mathrm \mathit and friends are designed to allow multi-letter identifiers so use the same kerning and ligatures as the text fonts (in fact, in most font setups they are the text fonts) . This is in contrast to the math italic font which is not the same as the italic font used in text and does not have ligatures and has much wider sidebearings.

Well that explains why \mathrm{fi} has ligatures.

The justification for \mathrm{f}\mathrm{i} not losing ligatures is a bit harder. It's just the way it is, even if you do {\mathrm{f}}{\mathrm{i}} by the time TeX constructs a horizontal list from the math list, the f and i are adjacent and the font-specified ligature kicks in. The brace groups already implicit in the definition of \mathrm don't form ligature boundaries.

Example 3 below uses a {} empty math atom to break the ligature and the \rmsym command used in 4 makes its argument a single mathord atom but using {} internally to make sure that ligatures do not combine mathords in-appropriately.

\documentclass{article}
\newcommand\rmsym[1]{{{}\mathrm{#1}{}}}
\begin{document}
\showoutput
$1 \mathrm{f}\mathrm{i}$
$2 \mathrm{fi}$
$3 \mathrm{f}{}\mathrm{i}$
$4 \rmsym{f}\rmsym{i}$
\end{document}