# Where are the math font parameters?

I've been studying the algorithms used to render formulas in math mode. I was hoping to be able to replicate some of this functionality, so I started looking for the different parameters needed from the font. These extra math font parameters are discussed on page 477 in The TEXbook.

Running tftopl cmbsy10.tfm for instance, I Was able to extract the extra parameters for this particular font:

(FONTDIMEN
(SLANT R 0.25)
(SPACE R 0.0)
(STRETCH R 0.0)
(SHRINK R 0.0)
(XHEIGHT R 0.430555)
(EXTRASPACE R 0.0)
(NUM1 R 0.676508)
(NUM2 R 0.393732)
(NUM3 R 0.443731)
(DENOM1 R 0.685951)
(DENOM2 R 0.344841)
(SUP1 R 0.412892)
(SUP2 R 0.362892)
(SUP3 R 0.288889)
(SUB1 R 0.15)
(SUB2 R 0.247217)
(SUPDROP R 0.386108)
(SUBDROP R 0.05)
(DELIM1 R 2.389999)
(DELIM2 R 1.01)
(AXISHEIGHT R 0.25)
)


However, I can't find these parameters in any of the STIX font tfms, or any of the AMS fonts. Is everyone using these same parameters (perhaps having scaling by the designsize)? Could some fonts be storing these parameters somewhere else, or perhaps modifying them in LaTeX? I wasn't able to find answers to any of these questions.

• It’s not clear what you are trying to achieve and what you are asking for. Not all fonts used in math typesetting have “extra” parameters, but only those in families 2 and 3 (in core TeX parlance), or in the symbols and largesymbols fonts (in LaTeX 2e’s NFSS parlance), and the sets of extra parameters differ between the two. You can always define additional parameters for any font you load “by hand”, but only immediately after loading it. – GuM Jul 8 '16 at 5:01
• When you say that the sets of extra parameters differ between the two, you mean that there are different types of parameters? Where would I learn about these? My confusion is that when I was looking at the STIX tfm files, they all looked like family 1 fonts where only the first 7 parameters were shown. Ultimately, I would like to be able to rederive the calculations used for rendering various formulas, like where to place which symbols given the font and a simple command like \frac{1}{2}. But I need these parameters for the given font. – breeden Jul 8 '16 at 5:37
• " I need these parameters for the given font. " no that is a misunderstanding, a construct like \frac does not use the font parameters for the fonts used in that construct, it uses the parameters that are set for the entire math expression, based on the values in the fonts used for fam2 and fam3 – David Carlisle Jul 8 '16 at 6:41
• Thank you that does clarify it a little bit. Maybe I was looking at the wrong Tfm files. So I guess I need to find which fonts are loaded in to fam2 and fam3 (say for instance in STIX) and then find the corresponding Tfm files to find the extra parameters. Perhaps this would be easier to do with \fontdimen but I was hoping to find a programmatic way. I wrote a parser to parse Tfm files for that purpose – breeden Jul 8 '16 at 6:48

The parameters described in Appendix G of the TeXbook are taken from the fonts in math families 2 and 3. If a (sub)formula is typeset in display or text style, the values are taken from \textfont2 and \textfont3; script and scriptscript styles use \scriptfont2, \scriptfont3,\scriptscriptfont2and\scriptscriptfont3.

The fonts current at the end of a formula will be used.

You can see which ones are used by stix with an input such as

\documentclass{article}
\usepackage{stix}

\begin{document}

$a$ \expandafter\show\the\textfont2 \expandafter\show\the\textfont3

\stop


that will display on the terminal (hit return twice)

> \LS1/stixscr/m/n/10=select font stix-mathscr.
<inserted text> \LS1/stixscr/m/n/10

l.6 $a$ \expandafter\show\the\textfont2
\expandafter\show\the\textfont3
?
> \LS2/stixex/m/n/10=select font stix-mathex.
<inserted text> \LS2/stixex/m/n/10

l.6 ...e\textfont2 \expandafter\show\the\textfont3

?


We need to typeset a formula, because in LaTeX math font families are set only at the last moment, in order to allow different sizes in the same document.

If we do tftopl stix-mathscr, we get

(FAMILY STIXMATHSCRIPT)
(FACE F MRR)
(CODINGSCHEME STIXMATHSCR)
(DESIGNSIZE R 10.0)
(COMMENT DESIGNSIZE IS IN POINTS)
(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)
(CHECKSUM O 7425717650)
(SEVENBITSAFEFLAG TRUE)
(FONTDIMEN
(SLANT R 0.0)
(SPACE R 0.0)
(STRETCH R 0.0)
(SHRINK R 0.0)
(XHEIGHT R 0.45)
(EXTRASPACE R 0.0)
(PARAMETER D 8 R 0.58)
(PARAMETER D 9 R 0.48)
(PARAMETER D 10 R 0.48)
(PARAMETER D 11 R 0.7)
(PARAMETER D 12 R 0.48)
(PARAMETER D 13 R 0.4)
(PARAMETER D 14 R 0.35)
(PARAMETER D 15 R 0.275)
(PARAMETER D 16 R 0.25)
(PARAMETER D 17 R 0.35)
(PARAMETER D 18 R 0.375)
(PARAMETER D 19 R 0.05)
(PARAMETER D 20 R 2.4)
(PARAMETER D 21 R 1.0)
(PARAMETER D 22 R 0.25)
)


whereas tftopl stix-mathex gives

(FAMILY STIXMATHEXTENSIONS)
(FACE F MRR)
(CODINGSCHEME STIXMATHEX)
(DESIGNSIZE R 10.0)
(COMMENT DESIGNSIZE IS IN POINTS)
(COMMENT OTHER SIZES ARE MULTIPLES OF DESIGNSIZE)
(CHECKSUM O 7636115355)
(SEVENBITSAFEFLAG TRUE)
(FONTDIMEN
(SLANT R 0.0)
(SPACE R 0.0)
(STRETCH R 0.0)
(SHRINK R 0.0)
(XHEIGHT R 0.45)
(EXTRASPACE R 0.0)
(PARAMETER D 8 R 0.066)
(PARAMETER D 9 R 0.15)
(PARAMETER D 10 R 0.15)
(PARAMETER D 11 R 0.3)
(PARAMETER D 12 R 0.6)
(PARAMETER D 13 R 0.1)
)


These fonts are scalable, so for script and scriptscript styles you just scale the values.

• With $a$ \typeout{\fontname\the\textfont2} \typeout{\fontname\the\textfont3} you don’t even need to hit return… (;-) – GuM Jul 8 '16 at 19:23
• @GustavoMezzetti I like some interaction better. ;-) – egreg Jul 8 '16 at 19:24

I must post an answer because 600 characters are not enough. As D.C. has already pointed out (see comments), you are probably misunderstanding how math typesetting works: I’ll try to give you a brief (and oversimplified!) explanation of it.

There is no concept of “the font in which a formula is typeset”: indeed, each formula can, and in general will, make use of several fonts at the same time. By convention (more or less) at least four fonts are always available in every formula, each at three different sizes: a size for the “main level” symbols, one for subscripts, and the third one to be used at all subscript levels below the first one. In The TeXbook, this four fonts are referred to as “families”, numbered from 0 to 3: in the setting of plain TeX, and in the default setting for LaTeX, family 0 corresponds to cmr, family 1 to cmmi, family 2 to cmsy, and family 3 to cmex. In LaTeX, which uses the NFSS (New Font Selection Scheme), the terminology is different and more abstract, but the concept is exactly the same:

• family 0 corresponds to the operators math group, that supplies, among other things, the characters for the ten digits and for operator names like “log”, “sin”, “lim”…;

• family 1 corresponds to the letters math group, used for variables like “x”, “y”, “z”…;

• family 2 corresponds to the symbols math group, from which characters like “∩”, “∪”, or “∈” are taken;

• family 3 corresponds to the largesymbols math group, that comprises characters like “∑” (in two sizes) and the various growing delimiters.

Below, however, we’ll stick to the terminolgy used in The TeXbook. The three sizes, on the other hand, are distinguished by the three prefixes \textfont, \scripfont, and \scriptscriptfont; so, for example, \textfont1 is the font used for variables (letters) in the main size, \scriptfont0 is the font used for digits and operator names that appear in first-level subscripts, and \scriptscriptfont2 is the font used for symbols like “∩” that happen to occur at the second, or higher, subscript level. Let’s make a typical example: given the source code

$x_{A_{0}\cup B_{i}}$


the “x” will be in \textfont1, the “A” and the “B” will be in \scriptfont1, the “0” will be in \scripscriptfont0, the “∩” will be in \scriptfont2, and the “i” will be in \scriptscriptfont1. To make another example, the (in-line) formula

$\lim_{x\to0} \frac{\sin x}{x}$


will be typeset as follows (recall that the numerator and denominator of the fraction are set in \scriptstyle):

• the word “lim” is in \textfont0;

• all occurences of the variable “x” are in \scriptfont1;

• “0” and the word “sin” are in \scriptfont0;

• the arrow (\to) is in \scriptfont2.

The normal setting, if the formula is typeset at 10 points, is \textfont0 = cmr10, \scriptfont0 = cmr7, \scripscriptfont0 = cmr5, \textfont1 = cmmi10, and so on (exception: family 3 could exist only at 10 points, that is, as cmex10, but there are packages that give access to other sizes).

Additional fonts may be used in a formula: for example, you might want to use calligraphic letters. This is achieved by defining additional font families. Up to sixteen different families (each one in three sizes) can be used in a single formula. Different formulas can have different groups of 48.

You will now understand that the parameters that govern the placement of subscripts, the height of the math axis, and so on, cannot be bound to each single font, but are a property of the formula as a whole: indeed, in the formula $\frac{1}{x^{\bullet}}$, for example, the numerator, the denominator, and the superscript of the latter come from three different fonts (normally, cmr7, cmmi7, and cmsy5). The TeX engine assumes that certain parameters must be given as \fontdimen parameters of the font associated to family 2, and others as \fontdimen parameters of the font associated to family 3 (the values 2 and 3 are “hard-wired” into TeX itself); the current style of the (sub-)formula being typeset determines whether their \textfont, \scriptfont, or \scripscriptfont` variants will be used. You find the details about which parameters are taken from which font in the table on p. 447 of The TeXbook that you mention in your question: all parameters denoted by a “σ” are looked for in the font associated to family 2, while those indicated with a “ξ” are assumed to be found in the font associated with family 3.

For further information, see The TeXbook, Chapter 17 and Appendix G.

• Thank you for this. In hind sight it should've been clear to me that I shouldn't have made such a generalization when I said "the font", and it was indeed an oversight of mine. I'll take another look at Chapter 17. – breeden Jul 8 '16 at 19:56