Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
I make a guess: Different types of symbols that would occupy the same glyph number in the font. Think of the huge variety of mathematical symbols compared to a standard font with latin letters? –  Christian Hupfer May 17 at 19:16
    
Yes seems reasonable but then I could just change the global font type to the math's one... You know what I mean? –  strpeter May 17 at 19:22
    
Originally, TeX was limited to 128 glyphs per font. Today, it supports 256 glyphs. That means that in order to typeset mathematics and text symbols, you need additional fonts. If you look at the Computer Modern or Latin Modern families, for example, you can see how these are arranged. Even if your type1 font has all the glyphs you need, you have to create several fonts as far as TeX is concerned unless you can make do with no more than 256 glyphs. That is not many... –  cfr May 17 at 19:28
    
Note that by default maths mode does partly rely on symbols from the same fonts as text because some maths alphabets are defined in terms of the OT1 encoding which is the default for text. You can use T1 encoded fonts in place of these if you use T1 for text. However, you are still going to need everything else from dedicated maths fonts (e.g. encoded OML etc.) and maybe dedicated text symbol fonts (TS1). –  cfr May 17 at 19:34
    
Note that as asked, your question can't be directly answered. If you want to be able to typeset mathematics and text, you have to have a certain number of fonts and you cannot use e.g. an OML encoded font to typeset text or a T1 encoded font (alone) to typeset maths. So from the end-user perspective, it is reasonable because it is the only way. From the designer perspective, it is reasonable because that was the only way to set the system up given the constraints which applied at the time TeX was written. –  cfr May 17 at 19:41
show 1 more comment

2 Answers 2

up vote 10 down vote accepted

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}
share|improve this answer
    
“The appearance of the latter two symbols in text mode is generally a signal of poor typography” – Do you know if the same holds for \pm? For example, 0.10±0.02\% or $0.10\pm 0.02$\%? –  morbusg May 18 at 8:34
1  
@morbusg - Most likely the term ± is part of a "formula", such as the ones you show. In order to get the spacing around the term to be consistent with the spacing in use for other binary operators (such as +), I'd say it's highly advisable to typeset the formula in math mode. –  Mico May 18 at 9:04
add comment

It's hard to answer as traditionally using the same font wouldn't have been an option at all, you simply need too many symbols. Consider the small document

enter image description here

\tracingonline2
\showboxdepth100
\showboxbreadth100
\scrollmode
\setbox0\vbox{

one {\it two}
$$\alpha + \sum_0^\infty x^2$$

}

\showbox0

\expandafter\show\the\tenrm 
\expandafter\show\the\tenit
\expandafter\show\the\teni
\expandafter\show\the\sevensy
\expandafter\show\the\tenex 

\box0
\bye

That uses 5 fonts as the output shows:

> \tenrm=select font cmr10.
> \tenit=select font cmti10.
> \teni=select font cmmi10.
> \sevensy=select font cmsy7.
> \tenex=select font cmex10.

the upright roman text font, the italic font, the math italic font a 7pt symbol font and the 10pt large symbol extension font.

Classic TeX simply uses too many characters to fit in one 8bit font.

Perhaps you were mainly just asking why the math italic font is different to the text italic? There mainly the difference relates to teh fact that in text adjacent letters form a word so the letters have small sidebearings so they are close together and some combinations are merged with ligatures or brought closer with kerns. Math italic conversely adjacent letters are typically an implied product of separate variables and the design tries to make them not look like a word: wide sidebearings and typically no ligatures.

With a modern Unicode font there are of course possibilities to put many glyphs into the same font but that is just an implementation issue, you would still want different glyphs, perhaps using an italic font with U+0061 for an a and U+1D44E for a math italic a, so even though they are two a in the same font, they are different glyphs, just packaged into one big font rather than lots of small ones.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.