9.4 Using fonts in math
Unlike the situation in text, automatic changes in font shapes are generally not desired in math formulas. For mathematicians, individual shapes convey specific information. For example, bold upright letters may represent vectors. If the characters in a formula were to change because of surrounding conditions, the result would be incorrect. For this reason, handling of fonts in mathematical formulas is different than that in text.
Characters in a formula can be loosely put into two classes: symbols and alphabetic characters (including digits). Internally, TEX distinguishes between eight types of math characters (to account for appropriate spacing), but for the discussion of fonts the division into two classes is generally adequate.
Some symbols, such as =, can be entered directly from the keyboard. The bulk of them, however, must be entered via a control sequence— for example, stands for ≤. The other main group of characters in a formula, the alphabetic characters (at least the Latin ones), are entered directly from the keyboard.
More than 200 symbols are predefined in a standard LaTEX system, allowing the user to typeset almost any desired formula. These symbols are scattered over several fonts, but they are accessed in such a way that the user does not have to be aware of their internal representations. If necessary, additional symbol fonts can be made accessible in a similar way; see Section 9.8.5.
The most important difference between symbols and alphabet characters is that symbols always have the same graphical representation within one formula, while it is possible for the user to change the appearance of the alphabet characters. We call the commands that change the appearance of alphabet characters in a formula “math alphabet identifiers” and the fonts associated with these commands “math alphabets”. The alphabet identifiers are independent of surrounding font commands outside the formula, so a formula does not change if it is placed (for example) inside a theorem environment whose text is, by default, typeset in italics. This behavior is very important, because character shapes in a mathematical formula carry meanings that must not change because the formula is typeset in a different place in a document.
Text font declarations such as
9.4.1 Special math alphabet identifiers
One alphabet and a huge number of symbols are not sufficient for scientists to express their thoughts. They tend to use every available typeface to denote special concepts. Besides the use of foreign alphabets such as Greek letters, which usually are accessed as symbols— , , and so on— we find sans serif letters for matrices, bold serif letters for vectors, and Fraktur fonts for groups, ideals, or fields. Others use calligraphic shapes to denote sets. The conventions are endless, and — even more importantly — they differ from one discipline to another. For this reason LaTEX makes it possible to declare new math alphabet identifiers and associate them with any desired font shape group instead of relying only on a predefined set that cannot be extended. These identifiers are special commands for use in a formula that typeset any alphabet character in their argument in a specific typeface. (Symbols cannot be changed in this way.) These identifiers may use different typefaces in different formulas, as we will see in Section 9.4.3, but within one formula they always select the same typeface regardless of the surrounding conditions.
Predefined alphabet identifiers
New math alphabet identifiers can be defined according to the user’s needs, but LaTEX already has a few built in. These identifiers are shown in Table 9.4 on the following page. As the last lines in the table show, the letters used in formulas are taken by default from the math alphabet . In contrast, the letters produced by have different spacing; thus, this alphabet could be used to provide full-word variable names, which are common in some disciplines.
In LaTEX math alphabet identifiers are commands with one argument, usually a single letter or a single word to be typeset in a special font.
The command names for the math alphabet identifiers are chosen to be descriptive rather than simple to type— they all start with . However, it is better to stick to the names rather than inventing random abbreviations, because this helps others (co-workers or journal editors) to easily understand your source text. Possible exceptions are cases where you invent special notations that are relevant for your current paper and you want to give them descriptive names. In that case, defining your own command can be helpful, especially if there is a chance that you may want to alter the notation later, e.g.,
9.4.2 Text font commands in math
As mentioned previously, text font declarations like cannot be used in math. However, the font-changing commands with arguments— for example, can be used in both text and math. You can use these commands to temporarily exit the math context and typeset some text in the midst of your formula that logically belongs to the text outside of the formula. Note that the font used to typeset this text therefore depends on surrounding conditions — that is, the command picks up the current values of encoding, family, series, and shape, and then changes one of the attributes as requested.
9.4.3 Mathematical formula versions
Besides allowing parts of a formula to be changed by using math alphabet identifiers, LaTEX lets you change the appearance of a formula as a whole. Formulas are typeset in a certain “math version”, and you can switch between math versions outside of math mode by using the command , thereby changing the overall layout of the following formulas.
LaTEX knows about two math versions that are called “normal” and “bold”. Additional ones are sometimes provided in special packages. As the name indicates, is the default. In contrast, the bold version produces bolder alphabet characters and symbols, though by default big operators, like , are not changed. The following example shows the same formula first in the normal and then in the bold math version: