6

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:

<code>\mathrm{f}\mathrm{i}</code>

Why? And when did this change? Or am I mistaken about this?

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


Minimal example:

\documentclass{article}
\begin{document}
\[ \mathrm{f}\mathrm{i} \]
\end{document}
Wrzlprmft
  • 759
  • 1
    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
  • @egreg: So the ligature here is a bug? – Wrzlprmft Jan 18 '14 at 08:20
  • 1
    It is like this from the beginning of TeX. – egreg Jan 18 '14 at 10:05
  • @egreg: Perhaps, but it should not be like that, right? So it’s a bug. (We haven’t reached that magical point yet, where all bugs in TeX are declared features, have we?) – Wrzlprmft Jan 18 '14 at 11:58
  • 1
    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 00:59
  • We have in fact reached that magical point. – Sean Allred Apr 01 '14 at 13:39
  • 1
    @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 01 '14 at 15:04
  • @barbarabeeton I admit I said the above a bit tongue-in-cheek; while bugs may theoretically still exist, the possibility seems to be impossibly slim. I recall reading (somewhere) something that Knuth wrote that went along the lines of 'there will come a point where all bugs will become features, as I cannot assume some clever person has not utilized the 'bug' to their advantage'; if I must be exact, this is the magical point I was referring to. (As an aside and upon thinking on it a little longer, a purported bug such as this would rather be in plain.tex and not tex, right?) – Sean Allred Apr 01 '14 at 15:44
  • 1
    @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 01 '14 at 16:03

1 Answers1

12

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.

enter image description here

\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}
David Carlisle
  • 757,742