[Tex/LaTex] Differences of fonts in math and text mode

fonts

The following question raised by the discussion of the question Reduce number of fonts used (from default settings)

Question

I have not yet found an explanation why we have different font types in math and in text mode. It seems reasonable to ask for the differences between the default math and text font. Is the answer that in the math environment no ligatures are desired?

Remark

In the end I want to make the decision whether it is reasonable to have a different font between both of them or not.

Best Answer

If I understand your question correctly, you're asking why TeX uses different fonts for (Latin-alphabet) letters and numbers depending on whether they are set in text or math mode. Put differently, if a well-designed math font happens to contain all letters, digits, and punctuation marks that can possibly occur in text mode settings, why not use this math font for text mode too? Why use two different fonts in such cases? (Of course, math frequently also requires symbols -- e.g., summation and integral symbols, fraction bars, and primes -- which don't occur in text mode at all. I take it that symbol fonts are not a part of your question.)

  • You already mention one reason for having different fonts: Text fonts frequently provide ligatures for character pairs and triples such as ff, fi, fl, ffi, ffl, possibly also for ft, fft, fj, fh, ct, st, sp, etc. In math mode, replacing these character pairs and triples with ligatures is almost certainly undesirable.

  • A second, and probably more important, reason, for having separate fonts is that the side bearings around letters can (and should!) differ considerably depending on whether they occur in text or math mode. Consider the character strings fly and office; in the following example they're first set in text italic mode, with ligatures suppressed via \kern0pt instructions, and then in math italic mode. (The vertical bar is provided to indicate the left-hand edge of the text block.)

enter image description here

  • (Point two, continued.) Observe that in text-italic mode, the letter f actually has a negative left-hand side bearing, so that its descender can "encroach" into the space occupied by the preceding character or interword space; its right-hand side-bearing seems to be pretty much zero, so that it touches subsequent characters such as l. In contrast, in math-italic mode the left-hand side bearing of f is zero and its right-hand side bearing is positive. I suppose this is done so that if and when the character combinations ff and fl occur in math mode, it'll be abundantly clear that we're dealing with the products of one-letter variables named f and l, respectively, rather than with two-letter variables named ff and fl. To be extra-super clear, some people may resort to writing f\cdot f and f\cdot l. If the math font is designed correctly, it shouldn't be necessary to do so.

    Observe that the spaces between "l" and "y", "f" and "i", "i" and "c", and "c" and "e" are also greater in math mode than they are in text mode. This is true not only for the font family used in the example above (newtx) but for all well-designed font families that have both text and math modes.

    The issue of setting the side bearings differently in text and math mode contexts extends to punctuation marks: Characters such as , (comma), : (colon), ; (semi-colon), and ! (exclamation mark/factorial) generally have different meanings in text and math mode; the spacing around them reflect the context in which they occur. (Note that I'm not talking about symbols such as + and = which usually occur only in math mode. The appearance of the latter two symbols in text mode is generally a signal of poor typography.)

  • Third, using different fonts for text and math provides an important degree of freedom from the point of view of document design: Even though you, personally, may be content using the same font family (e.g., Computer Modern, Latin Modern, newtx, or newpx) for both text and math material, others may not. E.g., somebody might prefer to use newpxtext (a Palatino clone) with nexpxmath, whereas someone else might prefer to combine it with eulervm. To provide this degree of design freedom, it's almost certainly necessary to store math and text fonts in separate files.

Finally, here's the code used to generate the example shown above.

\documentclass{article}
\usepackage[showframe]{geometry} % draw vertical lines around text block
\setlength\parindent{0pt}        % just for this example
\usepackage{newtxtext,newtxmath}
\begin{document}
\emph{f\kern0pt ly} % text italic mode

$fly$               % math (italic) mode

\emph{o\kern0pt f\kern0pt f\kern0pt ice}

$office$
\end{document}
Related Question