Mathematical work

Mathematical typesetting with NFSS2 works in a very different way to text, as the fonts do not vary according to the current font attributes in the main body of the document. There are some incompatibilities with old <LaTeX>, and some new facilities. The principal difference is that that font declarations like \bf no longer work, but we must rely on two different concepts, maths versions and maths alphabets. The mathversion changes the appearance of the whole formula (all the fonts change), while the alphabet is used to set a particular set of of characters in a chosen font. The normal text commands like \em, \sf or \bf are now completely illegal in maths, and a new set of commands is provided:
Example Effect
$$mathcal calligraphic style
$$mathrm upright text
$$mathbf bold text
$$mathsf sans-serif
$$mathit italic text
These are commands with an argument, not declarations. So to get a calligraphic ABC, we say $\mathcal{ABC}$, and not $\mathcal ABC$. The effect of the latter will be to set just the A in calligraphic, since just the first token after \mathcal is taken as the argument.

You can define new math alphabets for yourself easily, with the \DeclareMathAlphabet command, which associates a particular font family, encoding, shape, and series with the command you want to use. So if we want to declare a typewriter math alphabet, we could say (in the document preamble):

  \DeclareMathAlphabet{\mathtt}{OT1}{cmtt}{m}{n}
(OT1 is the name of the original <TeX> font layout).

What about new math symbol fonts? To illustrate some of the commands available here, let us look at how a style file looks which sets up the AMS symbol fonts. Assuming that the relevant fd files exist on our system for the fonts (named msa and msb in Table [*] above), we can declare the existence of them as symbol fonts:

\DeclareSymbolFont{AMSa}{U}{msa}{m}{n}
\DeclareSymbolFont{AMSb}{U}{msb}{m}{n}
where we define the names (AMSa and AMSb) by which we are going refer to them in future, the encoding (U is for `undefined', where there is no standard layout), family (msa and msb), series (m) and shape (n). We can use the new fonts in two ways:
  1. By declaring named math symbols. E.g. DeclareMathSymbol\lozenge{\mathord}{AMSa}{"06} which looks more fearsome than it really is. We are defining a new maths macro \lozenge, and saying it comes from the AMSa font we have defined earlier, at position "06 (this hexademical numbering notation is described in [4, p. 116]). The tricky bit is \mathord, which says what type of symbol it is. The possibilities are listed in Table [*], but the serious user is advised to consult [3, p. 158].[*]
  2. By saying that we want to use a symbol font also as a math alphabet:
    \DeclareSymbolFontAlphabet{\bbold}{AMSb}
    
    This defines a new math alphabet command \bbold, which picks up characters from the AMSb fonts (where the AMS has placed `blackboard bold' letters).

The use of the three math alphabet and symbol commands here is used to construct most of the standard maths interface; the supplied style file euler.sty, which redefines maths to use the Euler fonts, is a good example of its use.

I have not dealt much here with maths versions; suffice it to say that each of the commands described above has a corresponding command which allows the user select a specific symbol or alphabet font for each different maths version.

Table: Maths symbol types
Type Meaning Type Meaning
$$mathord ordinary $$mathop large operator
$$mathbin binary operator $$mathrel relation
$$mathopen opening $$mathclose closing
$$mathpunct punctuation $$mathalpha alphabetic