Chapter 8. Higher Mathematics

Basic LaTeX offers excellent mathematical typesetting capabilities for straightforward documents. However, when complex displayed equations or more advanced mathematical constructs are heavily used, something more is needed. Although it is possible to define new commands or environments to ease the burden of typing in formulas, this is not the best solution. The American Mathematical Society (AMS) provides a major package, amsmath, which makes the preparation of mathematical documents much less time-consuming and more consistent.1 It forms the core of a collection of packages known as AMS-LaTeX [8] and is the major subject of this chapter. A useful book by George Grätzer [60] also covers these packages in detail.

1 This package has its foundations in the macro-level extensions to TeX known as AMS-TeX.

This chapter describes briefly, and provides examples of, a substantial number of the many features of these packages as well as a few closely related packages; it also gives a few pointers to other relevant packages. In addition, it provides some essential background on mathematical typesetting with TeX. Thus, it covers some of standard LaTeX’s features for mathematical typesetting and layout and contains some general hints on how to typeset mathematical formulas, though these are not the main aims of this chapter.

It is also definitely not a comprehensive manual of good practice for typesetting mathematics with LaTeX. Indeed, many of the examples are offered up purely for illustration purposes and, therefore, present neither good design, nor good mathematics, nor necessarily good LaTeX coding.

Advice on how to typeset mathematics according to late 20th-century U.S. practice can be found in Ellen Swanson’s Math into Type [156]. Many details concerning how to implement this advice using TeX or, equally, standard LaTeX appear in Chapters 16–18 of Donald Knuth’s The TeXbook [82].

To use the majority of the material described in this chapter, you need to load at least the amsmath package in the preamble of your document. If other packages are needed, they are clearly marked in the examples. Detailed installation and usage documentation is included with the individual packages.

8.1. Introduction to AMS-LaTeX

The AMS-LaTeX project commenced in 1987 and three years later AMS-LaTeX version 1.0 was released. This was the original conversion to LaTeX of the mathematical capabilities in Michael Spivak’s AMS-TeX by Frank Mittelbach and Rainer Schöpf, working as consultants to the American Mathematical Society, with assistance from Michael Downes of the AMS technical staff. In 1994, further work was done with David Jones. This work was coordinated by Michael Downes and the packages have throughout been supported and much enhanced under his direction and the patronage of the AMS.1

1 Some material in this chapter is reprinted from the documentation distributed with AMS-LaTeX (with permission from the American Mathematical Society).

Thanks to a great guy!

Michael would have been the author of this chapter had he not died in spring 2003. Much of the chapter is based on the documentation he prepared for AMS-LaTeX; thus, what you are reading is a particular and heartfelt tribute by its current authors to the life and work of our dearest friend and colleague with whom we shared many coding adventures in the uncharted backwaters of TeX.

Available package options

A few options are recognized by the amsmath package. Most of these affect only detailed positioning of the “limits” on various types of mathematical operators (Section 8.4.4) or that of equation tags (Section 8.2.4).

The following three options are often supplied as global document options, set on the documentclass command. They are, however, also recognized when the amsmath package is loaded with the usepackage command.2

2 When using the AMS-LaTeX document classes, the default is leqno.

Image

Available sub-packages

The AMS-LaTeX distribution also contains components that can be loaded in dependently by the usepackage command. In particular, some features of the amsmath package are also available in these smaller packages:

amsopn Provides DeclareMathOperator for defining new operator names such as Ker and esssup.

amstext Provides the ext command for typesetting a fragment of text in the correct type size.

Extension packages

The following packages, providing functionality additional to that in amsmath, must be loaded explicitly; they are listed here for completeness.

Image

The principal documentation for these packages is the User’s Guide for the amsmath Package (Version 2.0) [8].

The AMS-LaTeX document classes

The current AMS-LaTeX collection includes three document classes: amsart, amsproc, and amsbook, corresponding to LaTeX’s article, proc, and book, respectively. They are designed to be used in the preparation of manuscripts for submission to the AMS [6], but nothing prohibits their use for other purposes. With these class files the amsmath package is automatically loaded, so that you can start your document simply with documentclass{amsart}. These classes are not covered in this book as they provide an interface similar to that provided by the LaTeX standard classes; refer to [6] for details of their use.

The AMSfonts collection

Some of the material in this chapter refers to another collection of packages from the American Mathematical Society, namely the AMSfonts distribution. These packages, listed below, set up various fonts and commands for use in mathematical formulas.

amsfonts Defines the mathfrak and mathbb commands and sets up the fonts msam (extra math symbols A), msbm (extra math symbols B and blackboard bold), eufm (Euler Fraktur), extra sizes of cmmib (bold math italic and bold lowercase Greek), and cmbsy (bold math symbols and bold script).

amssymb Defines the names of the mathematical symbols available with the AMSfonts collection. These commands are discussed in Section 8.9. The package automatically loads the amsfonts package.

eufrak Sets up the fonts for the Euler Fraktur letters (mathfrak), as discussed in Section 7.7.10. This alphabet is also available from the amsfonts package.

eucal Makes mathcal use the Euler script instead of the usual Computer Modern script letters, see Section 7.7.10 for details.

All of these packages recognize the psamsfonts option, which will set up LaTeX to use the Y&Y/Blue Sky Research version of these fonts in the AMSfonts collection. This will be useful only if you have this version of the fonts installed on your system; they are available on CTAN and are often available as the default in modern distributions of LaTeX. The principal piece of documentation for these packages is the User’s Guide to AMSFonts Version 2.2d [9].

A few important warnings

Image Watch out for fragile commands

Many of the commands described in this chapter are fragile and need to be protected in moving arguments (see Appendix B.1 on page 892). Thus, when strange error messages appear, a missing protect is a likely cause.

Image Do not abbreviate environments

It is never a good idea to use shortcut codes for LaTeX environments. With the amsmath display environments described in this chapter, such shortcuts are always disastrous—don’t do it! For closely related reasons, you will also find that verbatim material cannot be used within these environments. Here are some examples of declarations for disaster:

Image

Both will produce errors of the form “egin{...} ended by ...”. However, you can define synonyms and variant forms of these environments as follows:

Image

Note that these must have the command form of an existing environment as the last command in the “begin-code”, and the corresponding end... command as the first thing in the “end-code”. See also Section A.1.3, for more details.

8.2. Display and alignment structures for equations

The amsmath package defines several environments for creating displayed mathematics. These cover single- and multiple-line displays with single or multiple alignment points and various options for numbering equations within displays.

Throughout this section the term “equation” will be used in a very particular way: to refer to a logical distinct part of a mathematical display that is frequently numbered for reference purposes and is also labeled (commonly by its number in parentheses). Such labels are often called tags.

The complete list of all the display environments you will need for mathematical typesetting is given in Table 8.1 on the next page; the majority of these environments are covered in this section, along with examples of their use. Where appropriate they have starred forms in which there is no numbering or tagging of the equations.

Image

Table 8.1. Display environments in the amsmath package

In these examples of alignment environments, other commands from the amsmath package are also used. A detailed understanding of how these work is not necessary at this stage; an interested reader can turn to later sections for more information. The display width is the measure that defines the right and left margins (or extents) of a display; in the examples these extents are indicated by thin blue vertical rules at the right and left margins of the display.

Except where noted, all examples in this chapter are typeset with the mathematical material centered and the equation numbers, or tags, on the right (the default settings for the amsmath package). When the option leqno is specified for the amsmath package or the document class, the equation number tags will be printed at the left side of the equation.

8-2-1
Image

To position the mathematics at a fixed indent from the left margin, rather than centered in the text column, you use the option fleqn. You will then normally need to set the size of the indent in the preamble. It is the value of the rubber length mathindent, which gets its default value from the indentation of a first-level list—which is probably not the value you want! Observe the differences between the next example and the previous example. In this particular case, use of the reqno option is redundant (as it is the default), but it forces the equation number to the right side regardless of what the document class specifies.

8-2-2
Image

As later examples will show, as in standard LaTeX, & and \ are used for column and line separation within displayed alignments. The details of their usage change in the amsmath environments, however (see the next section).

8.2.1. Comparison with standard LaTeX

Some of the multiple-line display environments allow you to align parts of the formula. In contrast to the original LaTeX environments eqnarray and eqnarray*, the structures implemented by the amsmath package use a slightly different and more straightforward method for marking the alignment points. Standard LaTeX’s eqnarray* is similar to an array environment with {rcl} as the preamble and, therefore, requires two ampersand characters indicating the two alignment points. In the equivalent amsmath structures there is only a single alignment point (similar to a {rl} preamble), so only a single ampersand character should be used, placed to the left of the symbol (usually a relation) that should be aligned.

The amsmath structures give fixed spacing at the alignment points, whereas the eqnarray environment produces extra space depending on the parameter settings for array. The difference can be seen clearly in the next example, where the same equation is typeset using the equation, align, and eqnarray environments; the spaces in the eqnarray environment come out too wide for conventional standards of mathematical typesetting.

8-2-3
Image

As in standard LaTeX, lines in an amsmath display are marked with \ (or the end of the environment). Because line breaking in a mathematical display usually requires a thorough understanding of the structure of the formula, it is commonly considered to be beyond today’s software capabilities. However, one of the last bigger projects undertaken by Michael Downes precisely tackled this problem; it resulted in the breqn package (see [42] for details).

Unlike eqnarray, the amsmath environments do not, by default, allow page breaks between lines (see Section 8.2.10).

Space after \ not ignored

Another difference concerns the use of \[dimension] or \* within mathematical display environments. With amsmath, there must be no space between the \ and the [ or the *; otherwise, the optional argument or star will not be recognized. The reason is that brackets and stars are very common in mathematical formulas, so this restriction avoids the annoyance of having a genuine bracket belonging to the formula be mistaken for the start of the optional argument.

Finally, there is one less obvious change that is very unlikely to cause any problems for users: in standard LaTeX the parameter mathindent is a non-rubber length, whereas in amsmath it becomes a rubber length. The reasons for, and consequences of, this change are discussed in amsmath.dtx, the documented source of the amsmath package.

8.2.2. A single equation on one line

The equation environment produces a single equation with an automatically generated number or tag placed on the extreme left or right according to the option in use (see Section 8.2.11); equation* does the same but omits a tag.1

1 Standard LaTeX also has equation, but not equation*, as the latter is similar to the standard displayed math environment.

Note that the presence of the tag does not affect the positioning of the contents. If there is not enough room for it on the one line, the tag will be shifted up or down: to the previous line when equation numbers are on the left, and to the next line when numbers are on the right.

8-2-4
Image

8.2.3. A single equation on several lines: no alignment

The multline environment is a variation of the equation environment used only for equations that do not fit on a single line. In this environment \ must be used to mark the line breaks, as they are not found automatically.

The first line of a multline will be aligned on an indentation from the left margin and the last line on the same indentation from the right margin.2 The size of this indentation is the value of the length multlinegap; thus, it can be changed using LaTeX’s setlength and addtolength commands.

2 Never use multline for a single-line equation because the effect is unpredictable.

If a multline contains more than two lines, each line other than the first and last is centered individually within the display width (unless the option fleqn is used). It is, however, possible to force a single line to the left or the right by adding either shoveleft or shoveright within that line.

A multline environment is a single (logical) equation and thus has only a single tag, the multline* having none; thus, none of the individual lines can be changed by the use of ag or otag. The tag, if present, is placed flush right on the last line with the default reqno option or flush left on the first line when the leqno option is used.

8-2-5
Image

The next example shows the effect of multlinegap. In the first setting, the “dy”s line up and make it appear that a tag is missing from the first line of the equation. When the parameter is set to zero, the space on the left of the second line does not change because of the tag, while the first line is pushed over to the left margin, thus making it clear that this is only one equation.

8-2-6
Image

8.2.4. A single equation on several lines: with alignment

When a simple alignment is needed within a single multiple-line equation, the split environment is almost always the best choice. It uses a single ampersand (&) on each line to mark the alignment point.

8-2-7
Image

Because it is always used as the content of a single (logical) equation, a split does not itself produce any numbering tag and hence there is no starred variant. If needed, the outer display environment will provide any needed tags.

Apart from commands such as label or otag that produce no visible material, a split structure should normally constitute the entire body of the equation being split. It can consist of either a whole equation or equation* environment or one whole line of a gather or gather* environment; see Section 8.2.5.

When the centertags option is in effect (the default), the tag (and any other material in the equation outside the split) is centered vertically on the total height of the material from the split environment. When the tbtags option is specified, the tag is aligned with the last line of the split when the tag is on the right, and with the first line of the split when the tag is on the left.

8-2-8
Image

In the next example the command phantom is used to adjust the horizontal positioning. It is first used in the preamble to define an “invisible relation symbol” of width equal to that of its argument (in this case, =). Within the example it is used to align certain lines by starting them with a “phantom, or invisible, sub-formula” (see Section 8.7.2 on page 503). The empty pair of braces {} is equivalent to mathord{} and provides an invisible zero-width “letter” that is needed to achieve the correct spacing of + h (without the {} it would look like this: +h).

Image

Note that the equation number tag has been moved to the line below the displayed material. Although this does not seem to be a very wise decision, it is as far as the automated expertise built into the system at this stage can take us.

8-2-9
Image

8.2.5. Equation groups without alignment

The gather environment is used to put two or more equations into a single display without alignment between the equations. Each equation is separately centered within the display width and has its individual number tag, if needed. Each line of a gather is a single (logical) equation.

8-2-10
Image

Use otag within the logical line to suppress the equation number for that line; or use gather* to suppress all equation numbers.

8-2-11
Image

8.2.6. Equation groups with simple alignment

The align environment should be used for two or more equations in a single display with vertical alignment. The simplest form uses a single ampersand (&) on each line to mark the alignment point (usually just before a Relation symbol).

8-2-12
Image

8.2.7. Multiple alignments: align and flalign

An align environment can include more than one alignment point. The layout contains as many column-pairs as necessary and is similar to an array with preamble of the form {rlrl...}. If it consists of n such rl column-pairs, then the number of ampersands per line will be 2n – 1: one ampersand for alignment within each column-pair giving n; and n – 1 ampersands to separate the column-pairs.

Within the align environment, the material is spread out evenly across the display width. All extra (or white) space within the line is distributed equally “between consecutive rl column-pairs” and the two display margins.

8-2-13
Image

In the variant flalign the layout is similar except that there is no space at the margins. As a result, in the next example, Equation (3) now fits on a single line (while in Equation (2) this was still not possible).

8-2-14
Image

In both cases the minimum space between column-pairs can be set by changing minalignsep. Its default value is 10pt but, misleadingly, it is not a length parameter. Thus, it must be changed by using enewcommand. If we set it to zero for the first part of the example, Equation (2) gets squeezed onto a single line; if we set it to 15pt later, the label (3) gets forced onto a line by itself.

Unfortunately, there is no such simple parametric method for controlling the spacing at the margins.

8-2-15
Image

The next example illustrates a very common use for align. Note the use of ext to produce normal text within the mathematical material.

8-2-16
Image

8.2.8. Display environments as mini-pages

All the environments described so far produce material set to the full display width. A few of these environments have also been adapted to provide self-contained alignment structures, as if they were set as the only content of a minipage environment whose size, in both directions, is determined by its contents. The environment names are changed only slightly: to aligned and gathered. Note that an aligned environment avoids unnecessary space on the left and right; thus, it mostly resembles the flalign environment.

Like minipage, these environments take an optional argument that specifies the vertical positioning with respect to the material on either side. The default alignment of the box is centered ([c]). Of course, like split they are used only within equations and they never produce tags.

8-2-17
Image

The same mathematics can also be typeset, albeit not very beautifully, using different vertical alignments for the environments.

8-2-18
Image

They may be used in many ways—for example, to do some creative and useful grouping of famous equations. Incidentally, these mini-page display environments are among the very few from amsmath that are robust enough to be used inside other definitions, as in the following example.

8-2-19
Image

You can also use the minalignsep command to control the space between pairs of columns in an aligned environment, as shown in the next example.

8-2-20
Image

8.2.9. Interrupting displays: intertext

The intertext command is used for a short passage of text (typically at most a few lines) that appears between the lines of a display alignment. Its importance stems from the fact that all the alignment properties are unaffected by the text, which itself is typeset as a normal paragraph set to the display width; this alignment would not be possible if you simply ended the display and then started a new display after the text. This command may appear only immediately after a \ or \* command.

Here the words “and finally” are outside the alignment, at the left margin, but all three equations are aligned.

8-2-21
Image

8.2.10. Vertical space and page breaks in and around displays

Space within the display...

... and around the display

As is usual in LaTeX, the optional argument \[dimension] gives extra vertical space between two lines in all amsmath display environments (there must be no space between the \ and the [ character delimiting the optional argument). The vertical spaces before and after each display environment are controlled by the following rubber lengths, where the values in parentheses are those for ormalsize with the (default) 10pt option in the standard LaTeX classes:1

1 These defaults are very much improved by the AMS-LaTeX document classes.

abovedisplayskip, elowdisplayskip The normal vertical space added above and below a mathematical display (default 10pt plus 2pt minus 5pt).

abovedisplayshortskip, elowdisplayshortskip The (usually smaller) vertical space added above and below a “short display” (0pt plus 3pt and 6pt plus 3pt minus 3pt, respectively). A short display is one that starts to the right of where the preceding text line ends.

If you look closely, you can observe the results of these space parameters in the following example. The second equation is surrounded by less space because the text in front of it does not overlap with the formula.

8-2-22
Image

Since the four parameters abovedisplay.. and elowdisplay.. depend on the current font size, they cannot be modified in the preamble of the document using setlength. Instead, they must be changed by modifying ormalsize, small, and similar commands—a job usually done in a document class.

Page breaks around the display...

Automatic page breaking before and after each display environment is controlled by the penalty parameters predisplaypenalty (for breaking before a display; default 10000, i.e., no break allowed) and postdisplaypenalty (for breaking after a display, default 0; i.e., breaks allowed). The defaults are already set in standard LaTeX and are not changed by amsmath.

... and within the display

Unlike standard LaTeX, the amsmath display environments do not, by default, allow page breaks between lines of the display. The reason for this behavior is that correct page breaks in such locations depend heavily on the structure of the display, so they often require individual attention from the author.

With amsmath such individual control of page breaks is best achieved via the displaybreak command, but it should be used only when absolutely necessary to allow a page break within a display. The command must go before the \ at which a break may be taken, and it applies only to that line and can be used only within an environment that produces a complete display. Somewhat like standard LaTeX’s pagebreak (see Section 6.2.2 in [104]), displaybreak takes an optional integer as its argument, with a value ranging from zero to four, denoting the desirability of the page break: displaybreak[0] means “it is permissible to break here” without encouraging a break; displaybreak with no optional argument is the same as displaybreak[4] and forces a break. This command cannot be used to discourage or prevent page breaks. Note that it makes no sense to break within a “mini-page display”, as those environments will never be split over two pages.

This kind of adjustment is fine-tuning, like the insertion of line breaks and page breaks in text. It should therefore be left until your document is nearly finalized. Otherwise, you may end up redoing the fine-tuning several times to keep up with changing document content.

The command allowdisplaybreaks, which obeys the usual LaTeX scoping rules, is equivalent to putting displaybreak before every line end in any display environment within its scope; it takes the same optional argument as displaybreak. Within the scope of an allowdisplaybreaks command, the \* command can be used to prohibit a page break.

The effect of a displaybreak command overrides both the default and the effect of an allowdisplaybreaks.

Image Be wary of empty lines around displays

Many authors wisely use empty lines between major structures in the document source to make it more readable. In most cases, such as before and after a heading, these empty lines do no harm. This is not universally true, however. Especially around and within mathematical display environments, one has to be quite careful: a blank line in front of such an environment will produce unexpected formatting because the empty line is in effect converted into a paragraph containing no text (and so containing just the invisible paragraph indentation box). The following display is consequently surrounded by spaces of size ..displayshortskip. Thus, the combined result is quite a lot of (possibly too much) space before the display (a whole empty line plus the abovedisplayshortskip) and a very small amount of space after the display, as this example shows.

8-2-23
Image

With the amsmath package loaded, this behavior is exhibited by all the display math environments. Strangely enough, with standard LaTeX the [ case comes out looking more or less right.

8-2-24
Image

To summarize, do not use empty lines around display environments!

8.2.11. Equation numbering and tags

In LaTeX the tags for equations are typically generated automatically and contain a printed representation of the LaTeX counter equation. This involves three processes: setting (normally by incrementing) the value of the equation counter; formatting the tag; and printing it in the correct position.

In practice, the first two processes are nearly always linked. Thus, the value of the equation counter is increased only when a tag containing its representation is automatically printed. For example, when a mathematical display environment has both starred and unstarred forms, the unstarred form automatically tags each logical equation while the starred form does not. Only in the unstarred form is the value of the equation counter changed.

Within the unstarred forms the setting of a tag (and the incrementing of the counter value) for any particular logical equation can be suppressed by putting otag (or onumber1) before the \. You can override the default automatic tag with one of your own design (or provide a new one) by using the command ag before the \. The argument of this command can be arbitrary normal text that is typeset (within the normal parentheses) as the tag for that equation.

1 The command otag is interchangeable with onumber.

Note that the use of ag suppresses the incrementing of the counter value. Thus, the default tag setting is only visually the same as ag{ heequation}; they are not equivalent forms. The starred form, ag*, causes the text in its argument to be typeset without the parentheses (and without any other material that might otherwise be added with a particular document class).

8-2-25
Image

Notice this example’s use of the label and ef commands to provide some kinds of “relative numbering” of equations.

Referencing equations

To facilitate the creation of cross-references to equations, the eqref command (used in Example 8-2-29 on page 485), automatically adds the parentheses around the equation number, adding an italic correction if necessary. See also Section 2.4 on page 66 for more general solutions to managing references.

8.2.12. Fine-tuning tag placement

Optimal placement of equation number tags can be a rather complex problem in multiple-line displays. These display environments try hard to avoid overprinting an equation number on the equation contents; if necessary, the number tag is moved down or up, onto a separate line. The difficulty of accurately determining the layout of a display can occasionally result in a tag placement that needs further adjustment. Here is an example of the kind of thing that can happen, and a strategy for fixing it. The automatic tag placement is clearly not very good.

Image
8-2-26
Image

A fairly easy way to improve the appearance of such an equation is to use an align environment with a otag on the first equation line:

Image

This produces a good result but note that it misuses logical markup—it assumes the equation numbers to be on the right!

8-2-27
Image

A aisetag command is available that will further adjust the vertical position of the current equation number but only when it has been automatically moved from its “normal position”. For example, to move such a tag upward1 by 6pt, you could write aisetag{6pt}. You can try adjusting the above equation with aisetag but the correct value is not easy to divine: a value of 1.2aselineskip looks about right!

1 The description in the file amsmath.dtx seems to indicate that a positive value should always move the tag toward the “normal position”—that is, downward for tags on the left, but the current implementation does not work in this way.

A more sensible use is shown in the next example, where aisetag with a negative argument is used to move the tag on the left down into the display.

8-2-28
Image

Here we used a gather environment with a single line because the equation environment is (the only) one within which aisetag unfortunately has no effect (it is coded using low-level TeX).

These kinds of adjustment constitute “fine-tuning”, like line breaks and page breaks in text. They should therefore be left until your document is nearly finalized. Otherwise, you may end up redoing the fine-tuning several times to keep up with changing document content.

8.2.13. Subordinate numbering sequences

The amsmath package provides a subequations environment to support “equation sub-numbering” with tags of the form (2a), (2b), (2c), and so on. All the tagged equations within it use this sub-numbering scheme based on two normal LaTeX counters: parentequation and equation.

The next example demonstrates that the tag can be redefined to some extent, but note that the redefinition for heequation must appear within the subequations environment! (Appendix A.1.4 discusses counter manipulations.)

8-2-29
Image

The subequations environment must appear outside the displays that it affects. Also, it should not be nested within itself. Each use of this environment advances the “main” equation counter by one. A label command within the subequations environment but outside any individual (logical) equation will produce a ef to the parent number (e.g., to 2 rather than 2i).

8.2.14. Resetting the equation counter

It is fairly common practice to have equations numbered within sections or chapters, using tags such as (1.1), (1.2), ..., (2.1), (2.2), .... With amsmath this can easily be set up by using the declaration umberwithin.1

1 As the name implies, umberwithin can be applied to any pair of counters, but the results may not be satisfactory in all cases because of potential complications. See the discussion of the @addtoreset command in Appendix A.1.4.

For example, to get compound equation tags including the section number, with the equation counter being automatically reset for each section, put this declaration in the preamble: umberwithin{equation}{section}.

8.3. Matrix-like environments

The amsmath package offers a number of matrix-like environments, all of which are similar to array in syntax and layout. Thinking of complex mathematical layouts in this way is a useful exercise, as quite a wide variety of two-dimensional mathematical structures and table-like layouts can be so described.

Old commands disabled

Three of these environments replace old commands that are kept well hidden in standard LaTeX; cases (discussed in the next section) and matrix and pmatrix (discussed in the section after that). Because these old command forms use a totally different notation, they are not truly part of LaTeX and they cannot be mixed with the environment forms described here. Indeed, amsmath will produce an explanatory error message if one of the old commands is used (see page 907). If, contrariwise, you make the mistake of using the amsmath environment forms without loading that package, then you will most probably get this error message: “Misplaced alignment tab character &”.

8.3.1. The cases environment

Constructions like the following, where a single equation has a few variants, are very common in mathematics. To handle these constructions, amsmath provides the cases environment. It produces a decorated array with two columns, both left aligned.

8-3-1
Image

Notice the use of ext and the “embedded math mode” in the text strings. With the help of the aligned environment, other environments similar to cases can be defined, as in Example 8-2-19 on page 478.

8.3.2. The matrix environments

The matrix environments are similar to LaTeX’s array, except that they do not have an argument specifying the formats of the columns. Instead, a default format is provided: up to 10 centered columns. Also, the spacing differs slightly from the default in array. The example below illustrates the matrix environments matrix, pmatrix, bmatrix, Bmatrix, vmatrix, and Vmatrix.1

1 Note the warning above about possible problems when using matrix and pmatrix.

8-3-2
Image

The maximum number of columns in a matrix environment is determined by the counter MaxMatrixCols, which you can change using LaTeX’s standard counter commands. As in standard arrays, the amount of space between the columns is given by the value of arraycolsep, but no space is added on either side of the array. With more columns LaTeX has to work a little harder and needs slightly more resources. However, with today’s typical TeX implementations such limits are less important, so setting it to 20 or even higher is possible without a noticeable change in processing speed.

8-3-3
Image

This example also demonstrates use of the command hdotsfor to produce a row of dots in a matrix, spanning a given number of columns (here 5). The spacing of the dots can be varied by using the optional parameter (here 2) to specify a multiplier for the default space between the dots; the default space between dots is 3 math units (see Appendix A.1.5). The thin space and the brace group ,{} at the end of each row simply make the layout look better; together they produce two thin spaces, about 6mu or 1/3em. (Spacing in formulas is discussed in more detail in Section 8.7.6 on page 507.)

To produce a small matrix suitable for use in text, use the smallmatrix environment. Note that the text lines are not spread apart even though the line before the small matrix contains words with descenders.

8-3-4
Image

8.3.3. Stacking in subscripts and superscripts

The substack command is most commonly used to typeset several lines within a subscript or superscript, using \ as the row delimiter.

A slightly more general structure is the subarray environment, which allows you to specify that the lines should be left or right aligned instead of centered. Note that both structures need to be surrounded by braces when they appear as a subscript or superscript.

8-3-5
Image

8.3.4. Commutative diagrams

Some commands for producing simple commutative diagrams based on arrays are available in a separate package, amscd. It provides some useful shorthand forms for specifying the decorated arrows and other connectors. However, it is very limited—for example, these connectors can be only horizontal and vertical.

The picture environment could be used for more complex commutative diagrams but for most serious work in this area you will need one of the more comprehensive packages. These include Kristoffer Rose’s XY-pic system (see [57, chapter 5]) and its extension [11] by Michael Barr; the diagram system [22, 23] by Francis Borceux; and the kuvio package [155] by Anders Svensson.

In the CD environment the notations @>>>, @<<<, @VVV, and @AAA give right, left, down, and up arrows, respectively.1 The following examples also show the use of the command DeclareMathOperator (see Section 8.6.2).

1 For keyboards lacking the characters < and >, the notations @))) and @((( are alternatives.

8-3-6
Image

Decorations on the arrows are specified as follows. For the horizontal arrows, material between the first and second > or < symbols will be typeset as a superscript, and material between the second and third will be typeset as a subscript. Similarly, material between the first and second, or second and third, As or Vs of vertical arrows will be typeset as left or right “side-scripts”; this format is used in the next example to place the operator End P to the right of the arrow.

The notations @= and @| give horizontal and vertical double lines.

A “null arrow” (produced by @.) can be used instead of a visible arrow to fill out an array where needed.

8-3-7
Image

A similar layout, which does not look nearly as good, can be produced in standard LaTeX:

8-3-8
Image

This example shows clearly how much better the results are with the amscd package: the notation is enormously easier and, for example, the package produces longer horizontal arrows and much improved spacing between elements of the diagram. The more specialized packages will enable you to get even more beautiful results.

8.3.5. delarray—Delimiters surrounding an array

This section describes a useful general extension to the array package (see Section 5.2 on page 243) that allows the user to specify opening and closing extensible delimiters (see Section 8.5.3) to surround a mathematical array environment. The delarray package was written by David Carlisle, and its use is illustrated in the next, rather odd-looking, example (note that the delarray package is independent of amsmath but it automatically loads the array package if necessary).

8-3-9
Image

The delimiters are placed on either side of the “preamble declaration” (here {cc}). They must be delimiters from Table 8.3 on page 498.

The most useful feature of this package is also illustrated in the preceding example: the use of the [t] and [b] optional arguments, which are not available with amsmath’s matrix environments. These show that use of the delarray syntax is not equivalent to surrounding the array environment with left and ight, since the delimiters are raised as well as the array itself.

8.4. Compound structures and decorations

This section presents some commands that produce a variety of medium-sized mathematical structures including decorated symbols and fraction-like objects.

8.4.1. Decorated arrows

The commands xleftarrow and xrightarrow produce horizontal relation arrows similar to those used for the commutative diagrams in Section 8.3.4; they are intended to have textual decorations above and/or below the arrow and the length of the arrow is chosen automatically to accommodate the text. These arrows are normally available in only one size. Thus, they will probably not be suited for use in fractions, subscripts, or superscripts, for example.

The textual decorations below and above the arrows are specified in an optional and a mandatory argument to the command.

8-4-1
Image

8.4.2. Continued fractions

The cfrac command produces fraction arrays known as “continued fractions”. By default, each numerator formula is centered; left or right alignment of a numerator is achieved by adding the optional argument [l] or [r].

8-4-2
Image

8.4.3. Boxed formulas

The command oxed puts a box around its argument; it works just like fbox, except that the contents are in math mode. See also the commands described in Section 10.1.

8-4-3
Image

8.4.4. Limiting positions

Subscripts and superscripts on integrals, sums, or other operators can be placed either above and below the mathematical operator or in the normal sub/super positions on the right of the operator. They are said to “take limits” if the superscript and subscript material is placed (in the “limit positions”) above and below the symbol or operator name. Typically, no limits are used in text (to avoid spreading lines apart); in a display, the placement depends on the operator used. The default placements in LaTeX are illustrated in the following example.

8-4-4
Image

The placement of subscripts and superscripts on integrals, sums, and other operators is often dictated by the house-style of a journal. Recognizing this fact, amsmath offers a long list of options for controlling the positioning. In the following summary, default indicates what happens when the amsmath package is used with a standard LaTeX class but without any of these options.1

1 But not necessarily when using the AMS-LaTeX document classes.

intlimits, nointlimits In displayed equations only, place superscripts and subscripts of integration-type symbols above and below or at the side (default), respectively.

sumlimits, nosumlimits In displayed equations only, place superscripts and subscripts of summation-type symbols (also called “large operators”) above and below (default) or at the side, respectively. This option also affects other big operators—∏, , ⊗, ⊕, and so forth—but not integrals.

namelimits, nonamelimits Like sumlimits or nosumlimits but for certain “operator names”, such as det, inf, lim, and max, min, that traditionally have subscripts placed underneath, at least when they occur in a displayed equation.

The positioning on individual symbols/names can be controlled directly by placing one of the following TeX primitive commands immediately after the symbol or operator name: limits, olimits, or displaylimits. This last command, which specifies that the operator “takes limits” only when the mathematical style is a display style, is the default whenever a symbol of class Operator1 appears or a mathop construction is used. If an operator is to “take limits” outside a display, then this must be declared individually using the limits command. Compare the next example to Example 8-4-4, noting that some commands show no effect as they merely reinforce the default.

1 See Section 8.9.1 on page 524 for a discussion of the various mathematical classes of symbols.

8-4-5
Image

8.4.5. Multiple integral signs

The commands iint, iiint, and iiiint give multiple integral signs with well-adjusted spaces between them, in both running text and displays. The command idotsint gives two integral signs with ellipsis dots between them. The following example also shows the use of limits to override the default for integral constructions and place the limit V underneath the symbol.

8-4-6
Image

8.4.6. Modular relations

The commands mod, mod, pmod, and pod are provided by the amsmath package to deal with the special spacing conventions of the “mod” notation for equivalence classes of integers. Two of these commands, mod and pod, are variants of pmod that are preferred by some authors; mod omits the parentheses, whereas pod omits the “mod” and retains the parentheses. With amsmath the spacing of pmod is decreased within a non-display formula.

8-4-7
Image

8.4.7. Fractions and generalizations

In addition to the common frac, the amsmath package provides dfrac and frac as convenient abbreviations for {displaystylefrac ...} and { extstylefrac ...} (mathematical styles are discussed in more detail in Section 8.7.1 on page 502).

8-4-8
Image

For binomial coefficients such as (Image), use the similar commands inom, dbinom, and binom.

8-4-9
Image

All of these inom and frac commands are special cases of the generalized fraction command genfrac, which has six parameters.

Image

The first two parameters, ldelim and rdelim, are the left and right delimiters, respectively. They must be either both empty or both non-empty; to place a single delimiter, use a period “.” on the “empty” side. The third parameter, thick, is used to override the default thickness of the fraction rule; for instance, inom uses 0pt for this argument so that the line is invisible. If it is left empty, the line thickness has the default value specified by the font set-up in use for mathematical typesetting. The examples in this chapter use the defaults listed in Table 8.2 in the various styles (see also Section 8.7.1).

Image

Table 8.2. Default rule thickness in different math styles

The fourth parameter, style, provides a “mathematical style override” for the layout and font sizes used. It can take integer values in the range 0–3 denoting displaystyle, extstyle, scriptstyle, and scriptscriptstyle, respectively. If this argument is left empty, then the style is selected according to the normal rules for fractions (described in Table 8.5 on page 502). The last two arguments are simply the numerator (num) and denominator (denom).

To illustrate, here is how frac, frac, and inom might be defined:

Image

Of course, if you want to use a particular complex notation (such as one implemented with genfrac) repeatedly throughout your document, then you will do yourself (and your editor) a favor if you define a meaningful command name with ewcommand as an abbreviation for that notation, as in the examples above.

The old generalized fraction commands over, overwithdelims, atop, atopwithdelims, above, and abovewithdelims (inherited in standard LaTeX from primitive TeX) produce warning messages if they are used with the amsmath package.

8.4.8. Dottier accents

The dot and ddot mathematical accents are supplemented by dddot and ddddot, giving triple and quadruple dot accents, respectively.

8-4-10
Image

If you want to set up your own mathematical accents, then you should probably use the accents package developed by Javier Bezos. It provides methods of defining “faked” accents (see accentset in the example) and general under-accents (underaccent, undertilde), along with other features. It can be used together with amsmath. For further details see [20].

8-4-11
Image

8.4.9. amsxtra—Accents as superscripts

One feature available with this package is a collection of simple commands for placing accents as superscripts to a sub-formula:

8-4-12
Image

8.4.10. Extra decorations

Standard LaTeX provides stackrel for placing a superscript above a Relation symbol. The amsmath package makes the commands overset and underset available as well. They can be used to place material above or below any Ordinary symbol or Binary operator symbol, in addition to Relation symbols; they are typeset just like the limits above and below a summation sign.

The command sideset serves a special purpose, complementary to the others: it adds decorations additional to the “normal” limits (which are set above and below) to any Operator symbol such as Σ or ∏. These are placed in the subscript and superscript positions, on both the left and right of the Operator.

8-4-13
Image

This more complex example shows how to fully decorate a product symbol.

8-4-14
Image

8.5. Variable symbol commands

Many LaTeX commands are often thought of as producing a particular symbol when, in fact, the exact form is not fixed (even when the font and size are fixed). Certain features of TeX’s mathematical typesetting can even be used to produce structures that can, in principle, grow to whatever size is required.

Such context-dependent variability is very important in mathematical typesetting, and this section discusses some aspects of it. With a few clearly noted exceptions, the commands covered in this section are available in standard LaTeX.

A well-known, but not very exciting, example of such variability entails the mathematical operator symbols, such as sum and prod, which typically come in just two sizes: a smaller size that is used in running text and a larger size that is used in displayed formulas. Such symbols appear in Table 8.25 on page 536.

8.5.1. Ellipsis ...

Standard LaTeX provides several types of mathematical ellipsis dots: ldots, cdots, and so on. When using amsmath, however, such ellipsis dots within math mode should almost always be marked up using simply dots.1

1 The commands dots and ldots can also be used in text mode, where both always produce a normal text ellipsis.

The vertical position (on the baseline or centered) of the ellipsis, together with the space around it, are both automatically selected according to what kind of symbol follows dots. For example, if the next symbol is a plus sign, the dots will be centered; if it is a comma, they will be on the baseline. In all cases, three dots are used but the spacing varies. These defaults from the amsmath package can be changed in a class file when different conventions are in use.

8-5-1
Image

If the dots fall at the end of a mathematical formula, the next object will be something like end or ) or $, which does not give any information about how to place the dots. In such a case, you must help by using dotsc for “dots with commas”, dotsb for “dots with Binary operator/Relation symbols”, dotsm for “multiplication dots”, dotsi for “dots with integrals”, or even dotso for “none of the above”. These commands should be used only in such special positions: otherwise you should just use dots.

In this example, low dots are produced in the first instance and centered dots in the other cases, with the space around the dots being nicely adjusted.

8-5-2
Image

You can customize the symbols and spacing produced by the dots command in various contexts by redefining the commands dotsc, dotsb, dotsm, and dotsi; this would normally be done in a class file. Thus, for example, you could decide to use only two dots in some cases.

8.5.2. Horizontal extensions

In principle, any mathematical accent command can be set up to produce the appropriate glyph from a range of widths whenever these are provided by the available fonts. However, in standard LaTeX there are only two such commands: widehat and widetilde.

This section describes a few commands that produce constructions similar to these extensible accents. They all produce compound symbols of mathematical class Ordinary (see Section 8.9.1 on page 524) and are illustrated in this example.

8-5-3
Image

Further details of the availability and properties of these commands are unfortunately somewhat complex but they are summarized in the example. Here, “change style” means that the symbol employed is affected by the mathematical style in use so that they will look right when used, for example, in fractions or subscripts/superscripts (see Section 8.7.1 on page 502). Those that do not change style are suitable for use only at the top level of displayed mathematics.

Another horizontally extensible feature of LaTeX is the bar in a radical sign; it is described at the end of the next subsection.

8.5.3. Vertical extensions

There is a much larger range available with vertical extensions. All of the symbols depicted in Table 8.26 on page 537 are potentially extensible, as are a few others. The full list is given in Table 8.3. These symbols become extensible only in certain usages; they must all be based on a construction of the following form:1

Image

1 If LaTeX is using the eTeX program, then you can also use these extensible symbols with middle.

Image

Table 8.3. Vertically extensible symbols

Here ext-Open and ext-Close can be any of the symbols (except sqrtsign) listed in Table 8.3, or possibly others if additional packages are loaded. They must be symbols that have been set up to be extensible using the methods described in [109], which is part of every LaTeX distribution; thus, a symbol must be available to represent the absence of an actual glyph. This symbol, which is sometimes called the null delimiter, was chosen to be the period (.). The sizes of the actual glyphs used to typeset the extensible symbols are chosen to fit with the vertical size (height and depth) of the typeset sub-formula that lies in between them; the exact details of how this is done, and of the parameters that affect the process, can be found in Chapter 17 and Appendix G (Rule 19) of The TeXbook [82]. One can also request specific sizes for such symbols (see Section 8.7.3 on page 504).

The radical sign sqrtsign is even more amazing—it grows both vertically and horizontally to fit the size of its argument. In LaTeX it is typically accessed via the sqrt command, which is discussed further in Section 8.7.4 on page 504.

8-5-4
Image

8.6. Words in mathematics

8.6.1. The ext command

Math font-changing commands such as mathrm are not intended for putting normal text inside mathematics; even for single words this task is often best carried out with the ext command, which is similar to the LaTeX command mbox but is much better, ensuring that the text is set using the correct font size. The font will be the text font in use outside the current mathematical material.

8-6-1
Image

8.6.2. Operator and function names

The names of many well-known mathematical functions (such as log and sin) and operators (such as max and lim) are traditionally typeset as words (or abbreviations) in Roman type so as to visually distinguish them from shorter variable names that are set in “math italic”. The most common function names have predefined commands to produce the correct typographical treatment; see Table 8.4. Most functions are available in standard LaTeX; those listed in blue in the table require loading amsmath. The functions marked with (l) may “take limits” in display formulas (see Section 8.4.4).

Image

Table 8.4. Predefined operators and functions

8-6-2
Image

New functions of this type are needed frequently in mathematics, so the amsmath package provides a general mechanism for defining new “operator names”.

Image

The DeclareMathOperator defines cmd to produce text in the appropriate font for “textual operators”. If the new function being named is an operator that should, when used in displays, “take limits” (so that any subscripts and superscripts are placed in the “limits” positions, above and below, as with, for example, lim, sup, or min), then use the starred form DeclareMathOperator*. In addition to using the proper font, DeclareMathOperator sets up good spacing on either side of the function name when necessary. For example, it gives A meas B instead of AmeasB. The text argument is processed using a “pseudo-text mode” in which

• The hyphen character - will print as a text hyphen (not as a minus sign); see supminus in the next example.

• The asterisk character * will print as a raised text asterisk (not centered).

• Otherwise, the text is processed in math mode so that spaces are ignored and you can use subscripts, superscripts, and other elements.

The related command operatorname (and its *-form) simply turns its argument into a function name, as in Example 8-2-11 on page 475. It is useful for “one-off” operators.

The next example shows how to provide the command meas for the new function name “meas” (short for measure) and the operator functions esssup and supminus, both of which take limits.

8-6-3
Image

Unfortunately, such declarations must appear in the preamble so it is not possible to change a declaration temporarily. In fact, DeclareMathOperator works only for command names that have not been used previously, so it is not possible to overwrite an existing command directly. To do so, you must first remove the previous definition (in this case, of csc) before redeclaring it; this removal is accomplished by using low-level TeX coding, as LaTeX provides no method for completing this task.

8-6-4
Image

8.7. Fine-tuning the mathematical layout

Although LaTeX generally does a good job of laying out the elements of a formula, it is sometimes necessary to fine-tune the positioning. This section describes how to achieve some of the many detailed adjustments to the layout that are used to produce mathematical typography that is just a little bit better. Most of this section applies to all LaTeX mathematical material, but a few features are available only with the amsmath package; these will be clearly labeled.

8.7.1. Controlling the automatic sizing and spacing

Letters and mathematical symbols normally get smaller, and are more tightly spaced, when they appear in fractions, superscripts, or subscripts. In total, TeX has eight different styles in which it can lay out formulas:

Image

The prime versions (D′, T′, etc.) represent the so-called cramped styles, which are similar to the normal styles except that superscripts are not raised so much.

TeX uses only three type sizes for mathematics in these styles: text size (also used in displaystyle), script size, and scriptscript size. The size of each part of a formula can be determined according to the following scheme.

Image

In LaTeX, the top-level part of a formula set in running text (within a $ pair or between (...)) is typeset using text style (style T). A displayed formula (e.g., one between [...]) will be typeset in display style (style D). The kind of style used in a sub-formula can then be determined from Table 8.5 on the facing page, where the last two columns describe the styles used in the numerator and the denominator of a fraction.

Image

Table 8.5. Mathematical styles in sub-formulas

The various styles can be seen in this example:

8-7-1
Image

You can change the layout of this example by explicitly specifying the style to be used in each part. For example, if you remove the comment character in front of displaystyle, then some of the styles will change to those shown in brackets. The result looks like this:

8-7-2
Image

Section 3.1.4 describes other ways to change the style of an individual symbol.

8.7.2. Sub-formulas

Whereas in text a pair of braces can simply indicate a group to which the effects of some declaration should be confined, within mathematics they do more than this. They delimit a sub-formula, which is always typeset as a separate entity that is added to the outer formula. As a side effect, sub-formulas are always typeset at their natural width and will not stretch or shrink horizontally when TeX tries to fit a formula in a paragraph line during line-breaking. As shown earlier, the sub-formula from a simple brace group is treated as if it was just a single symbol (of class Ordinary). An empty brace group, therefore, generates an invisible symbol that can affect the spacing. The exact details can be found in Chapters 17 and 18 and Appendix G of The TeXbook [82].

The contents of subscripts/superscripts and the arguments of many (but not all) commands, such as frac and mathrel, are also sub-formulas and get this same special treatment. Important examples of arguments that are not necessarily set as sub-formulas include those of m (see Section 8.8.2). If a group is needed only to limit the scope of a declaration (i.e., where a separately typeset sub-formula would be wrong), then egingroup and endgroup should be used. Note that specialized mathematical declarations such as style changes apply until the end of the current sub-formula, irrespective the presence of any other groups.

8.7.3. Big-g delimiters

To provide direct control of the sizes of extensible delimiters, LaTeX offers four commands: ig, Big, igg, and Bigg. These take a single parameter, which must be an extensible delimiter, and they produce ever-larger versions of the delimiter, from 1.2 to 3 times as big as the base size.

Three extra variants exist for each of the four commands, giving four sizes of Opening symbol (e.g., igl); four sizes of Relation symbol (e.g., Bigm); and four sizes of Closing symbol (e.g., Biggr).1 All 16 of these commands can (and must) be used with any symbol that can come after either left, ight, or (with eTeX) middle (see Table 8.3 on page 498).

1 See Section 8.9.1 on page 524 for the various mathematical classes of symbols.

In standard LaTeX the sizes of these delimiters are fixed. With the amsmath package, however, the sizes adapt to the size of the surrounding material, according to the type size and mathematical style in use, as shown in the next example. The same is true when you load the exscale package (see Section 7.5.5), or when you use a font package that implements the exscale functionality as an option (e.g., most of the packages discussed in Sections 7.6 and 7.7).

8-7-3
Image

8.7.4. Radical movements

In standard LaTeX, the placement of the index on a radical sign is sometimes not good. With amsmath, the commands leftroot and uproot can be used within the optional argument of the sqrt command to adjust the positioning of this index. Positive integer arguments to these commands move the root index to the left and up, respectively, while negative arguments move it right and down. These arguments are given in terms of math units (see Section 8.7.6), which are quite small, so these commands are useful for fine adjustments.

8-7-4
Image

8.7.5. Ghostbusters™

To get math spacing and alignment “just right”, it is often best to make creative use of some of primitive TeX’s unique and sophisticated typesetting abilities. These features are accessed by a collection of commands related to phantom and smash; and they can be used in both mathematical and other text.

For instance, the large alignment example (Example 8-2-9 on page 474) uses lots of phantoms to get the alignment just right. Each of these phantoms produces an invisible “white box” whose size (width and total height plus depth) is determined by typesetting the text in its argument and measuring its size.

Conversely, the command smash typesets its contents (in an LR-box) but then ignores both their height and depth, behaving as if they were both zero. The standard LaTeX command hphantom is a combination of these, producing the equivalent of smash{phantom{a truly busted ghost!}}: an invisible box with zero height and depth but the width of the phantom contents.

The vphantom command makes the width of the phantom zero but preserves its total height plus depth. An example is the command mathstrut, which is defined as “vphantom(” so that it produces a zero-width box of height and depth equal to that of a parenthesis.

The amsmath package provides an optional argument for smash, used as follows: smash[t]{...} ignores the height of the box’s contents, but retains the depth, while smash[b]{...} ignores the depth and keeps the height. Compare these four lines, in which only the handling of Image varies:

8-7-5
Image

To get the three radical signs looking pleasantly similar, it seems that the thing to do may be to give the y some extra height with a strut—but that only makes things worse! The best solution turns out to be to smash the bottom of the y (but not the whole of it!).

In the next example, the top of the large fraction in the second line appears correctly at its normal height, while neither this height nor the depth of the p in the denominator on the first line affects the vertical space between the two lines. This, of course, would bring the two lines in this example confusingly close together. For this reason, another strut was added. Nevertheless, more moderate use of smashing is often of benefit to such unbalanced displays.

8-7-6
Image

Another collection of examples illustrates a very common application of smashing: using a partial smash to give fine control over the height of surrounding delimiters. It also shows that smashing can lead to problems because the real height of the line needs to be known; this is restored by vphantom. In the following code, Hmjd is the compound symbol defined by

Image

To show the resulting vertical space we added some rules:

Image

Image Smashes being ignored by TeX

A word of warning: in a few places, deficiencies in the very low-level TeX processing may cause errors in the fine details of typesetting. These possibilities are of particular concern in mathematical layouts where (1) a sub-formula (such as the numerator/denominator of a fraction or subscripts/superscripts) consists of exactly one LR-box, or a similarly constructed mathematical box, and also (2) that box does not have its natural size, as with the more complex forms of makebox, smashes, and some phantoms. As an example look at the following:

8-7-7
Image

To shorten the depth of the radical, a smash was added in the second radical, but without any effect. With an empty brace group (third radical), it suddenly worked. On the other hand, no workaround was needed for the forth radical.1 For the same reason the strut or an empty brace group was actually necessary in Example 8-7-6 on the facing page to see any effects from the smash commands there. In summary, whenever you find that a smash does not work, try adding an empty math sub-formula (from {}) before the lonely box, to keep it from being mistreated.

1 Technically this is due to the denominator being wider than the numerator in this case, so that it was not reboxed by TeX.

8.7.6. Horizontal spaces

Even finer, and more difficult, tuning requires the explicit spacing commands shown in Table 8.6 on the next page. Both the full and short forms of these commands are robust, and they can also be used outside math mode in normal text. They are related to the thin, medium, and thick spaces available on the machines used to typeset mathematics in the mid-20th century.

Image

Table 8.6. Mathematical spacing commands

Image Do not change the parameter values

The amounts of space added by these ..space commands are, in fact, defined by the current values of the three parameters hinmuskip, medmuskip, and hickmuskip; the table lists their default values with amsmath. These very low-level TeX parameters require values in “mu” (math units). They must therefore be set only via low-level TeX assignments (as shown in Example 8-9-2 on page 525) and not by setlength or similar commands. Moreover, in normal circumstances their values should not be modified because they are used internally by TeX’s mathematical typesetting (see Table 8.7 on page 525).

Image

Table 8.7. Space between symbols

One math unit (1mu) is 1/18 of an em in the current mathematical font size (see also Table A.1 on page 855). Thus, the absolute value of a math unit varies with the mathematical style, giving consistent spacing whatever the style.

These math units can be used more generally to achieve even better control over space within mathematics. This is done via the amsmath command mspace, which is like hspace except that it can be used only within mathematics and its length argument must be given in math units (e.g., mspace{0.5mu}). Thus, to get a negative quad within a mathematical formula, you could write mspace{-18.0mu}; this will, for example, normally give about half the space in a double subscript size as it does in the basic mathematical size. In contrast, hspace{-1em} will produce the same amount of space whatever the mathematical font size (but ext{hspace{-1em}} will produce variable-sized space).

8.8. Fonts in formulas

For most symbols in a formula, the font used for a glyph cannot be changed by a font declaration as it can be in text. Indeed, there is no concept of, for example, an italic plus sign or a small caps less than sign.

One exception involves the letters of the Latin alphabet, whose appearance can be altered by the use of math alphabet identifier commands such as mathcal. The commands provided by standard LaTeX for this purpose are discussed in Section 7.4; this section introduces a few more. Another exception relates to the use of bold versions of arbitrary symbols to produce distinct symbols with new meanings. This potentially doubles the number of symbols available, as boldness can be a recognizable attribute of a glyph for nearly every shape: depending on the font family, even “<” is noticeably different from “<”. Although there is a mathbf command, the concept of a math alphabet identifier cannot be extended to cover bold symbols; a better solution is discussed in Section 8.8.2.

To change the overall appearance of the mathematics in a document, the best approach is to replace all the fonts used to typeset formulas. This is usually done in the preamble of a document by loading a (set of) suitable packages, such as those discussed in Sections 7.6 and 7.7.

At the end of this section we showcase the effects of such extensive changes, made with but a few keystrokes, on a sample page of mathematics. Section 8.8.3 contains the same material typeset with both Computer Modern Math fonts (the default in LaTeX) and 15 other font families for text and mathematics. All of the fonts used are readily available and about half of them are provided free of charge.

8.8.1. Additional math font commands

By loading the amsfonts (or amssymb) package, the Euler Fraktur alphabet (mathfrak) and a Blackboard Bold alphabet (mathbb) become available.

8-8-1
Image

As an example of small-scale changes to the mathematical typesetting, those who prefer a visually distinct Blackboard Bold alphabet can load one from the Math Pazo fonts. See Section 7.6.3 for more information on the Math Pazo fonts and Section 7.4.1 for details on DeclareMathAlphabet. In this example we first load the amsfonts package and then overwrite its definition of mathbb.

8-8-2
Image

This example shows how to include arbitrary alphabets from your LaTeX distribution as math alphabets, with the crucial part being the arguments of DeclareMathAlphabet. Although getting these right may appear to be a tricky matter, it is not so difficult once you know where to look. Fonts suitable for inclusion need to have an .fd file; that is, given a font family name in the Berry naming convention (see Section 7.10.2), there should be a file enc name .fd. For example,

Image

has the family name hlcw. It is available in several encodings, including T1, so one possible file to look at is t1hlcw.fd. In that file you will find the remaining arguments for the declaration. The font is available only in series m and shape it. All other font shapes contain substitutions (see Section 7.10.6 for details on the file format for .fd files). Putting all this together enables us to provide a mathscr command. Another possibility is to use this alphabet as a replacement for the standard mathcal command.

8-8-3
Image

Of course, the presence of the file t1hlcw.fd (and other support files) on your system does not mean that the previous example will run there. To achieve this goal, you must also install the corresponding commercial font. Most modern LaTeX installations contain such support files for various commercial font sets, so that you can use these fonts the moment you have bought them and added them to your system. In this case you would need a file called hlcriw8a.pfb.

In truth, you probably do not need to buy any fonts, because the freely available fonts already include a huge choice. The nfssfont.tex program can provide valuable help in choosing a font, by producing samples and character tables for the fonts available to your installation (see Section 7.5.7).

8.8.2. bm—Making bold

For bold Latin letters only, you can use the command mathbf; for everything else, there is the bm package. Although amsmath provides oldsymbol and pmb, the rules about when to use which command, and many of the restrictions on when they work, can now be avoided: just load the bm package and use m to make any formula as bold and beautiful as the available fonts allow.

The example below shows many ways to use the m and mathbf commands and a strategy for defining shorthand names for frequently occurring bold symbols, using both standard LaTeX’s ewcommand and mdefine, which is provided by bm. Note that mathbf{xy} is not identical to m{xy}: the former produces bold Roman “xy” and the latter produces “xy” (i.e., bold math italic).

8-8-4
Image

In the above example bm tries its best to fulfill the requests for bold versions of individual symbols and letters, but if you look closely you will see that the results are not always optimal. For example, Σ, ∏, and Image are all made bold by use of a technique known as poor man’s bold, in which the symbol is overprinted three times with slight offsets. Also, the { is not made bold in any way. Such deficiencies are unavoidable because for some symbols there is simply no bold variant available when using the Computer Modern math fonts.

The situation changes when the txfonts are loaded by changing the first line of the previous example to usepackage{amsmath,amssymb,txfonts,bm}. This family of fonts contains bold variants for all symbols from standard LaTeX and amssymb. It produces the following output:

8-8-5
Image

Image Load the bm package after packages that change the existing math font set-up!

What are the precise rules used by m to produce bold forms of the symbols in its argument? In a nutshell, it makes use of the fact that LaTeX includes a bold math version (accessible via oldmath) for typesetting a whole formula in bold (provided suitable bold fonts are available and set up). For each symbol, the m command looks at this math version to see what would be done in that version. If bm the font selected for the symbol is different from the one selected in the normal math version, it then typesets the symbol in this bold font, obtaining a perfect result (assuming that the bold math version was set up properly). If the fonts in both versions are identical, it assumes that there is no bold variant available and applies poor man’s bold (see above).

With delimiters, such as iggllbrace in the example, the situation is even more complex: a delimiter in TeX is typically typeset by a glyph chosen to match a requested height from a sequence of different sizes (see Section 8.5.3 on page 498). Moreover, these glyphs can live in different fonts and a particular size may or may not have bold variants, making it impossible for m to reliably work out whether it needs to apply poor man’s bold. It therefore essentially typesets the delimiter using whatever fonts the bold math version offers. With the Computer Modern math fonts, only the smallest delimiter size is available in bold; all other sizes come from fonts that have no bold variants.

8-8-6
Image

This situation can be improved by use of the txfonts (as in Example 8-8-5) or use of another font set with full bold variants, such as the pxfonts shown here:

8-8-7
Image

Normally, m requires that if a command that itself takes arguments is within its argument, then that command must be fully included (i.e., both the command and its arguments must appear) in the argument of m; as a result, all parts of the typeset material will be in bold. If you really need the output of a command with arguments to be only partially bold, then you have to work harder. You should place the symbol(s) that should not be bold in an mbox and explicitly reset the math version within the box contents using unboldmath. TeX considers an mbox to be a symbol of class Ordinary (see Section 8.9.1); hence, to get the spacing right, you may have to surround it by a mathbin, mathrel, or mathop.

8-8-8
Image

Fortunately, such gymnastics are seldom needed. In most cases involving commands with arguments, only parts of the arguments need to be made bold, which can be achieved by using m inside those arguments. As with sqrtsign in the example above, for the common case of bold accents m is specially programmed to allow the accent’s argument to be outside its own argument. However, if you need such accents regularly, it is wise to define your own abbreviation using mdefine, as in the next example.

Speeding up the processing

Although mdefinepi{pi} appears to be simply shorthand for ewcommandpi{m{pi}}, in fact almost the opposite is true: m defines a new hidden temporary command using mdefine and then immediately uses this temporary command to produce the bold symbol. In other words, mdefine does all the hard work! If you frequently use, for example, something that is defined via m{alpha}, then a new mdefine is executed at every use. If you set things up by doing mdefinealpha{alpha}, then mdefine does its time-consuming work only once, however many times alpha is used.

8-8-9
Image

This example also shows that the variable-width accents (e.g., widehat) share a deficiency with the delimiters: in the Computer Modern math set-up they come from a font for which no bold variant is available.

Dealing with strange errors

The bm package tries very hard to produce the correct spacing between symbols (both inside and outside the argument of m). For this effort to work, m has to “investigate” the definitions of the commands in its argument to determine the correct mathematical class to which each of the resulting symbols belongs (see Section 8.9.1 on page 524). It is possible that some strange constructions could confuse this investigation. If this happens then LaTeX will almost certainly stop with a strange error. Ideally, this problem should not arise with constructs from standard LaTeX or the AMS-LaTeX distributions, but proper parsing in TeX is extremely difficult and the odd overlooked case might still be present. For instance, the author got trapped when writing this section by the fact that m was trying to process the argument of hspace instead of producing the desired space (this problem is fixed in version 1.1a).

If some command does produce an error when used inside m, you can always surround it and all its arguments with an extra level of braces—for example, writing m{..{cmd..}..} rather than simply m{..cmd..}. The m command will not attempt to parse material surrounded by braces but will use the oldmath version to typeset the whole of the formula within the braces. The resulting bold sub-formula is then inserted as if it were a “symbol” of class Ordinary. Thus, to obtain the right spacing around it, you may have to explicitly set its class; for instance, for a relation you would use m{..mathrel{cmd..}..} (see Section 8.9.1 on page 524).

8.8.3. A collection of math font set-ups

In this section we show a sample text typeset with different font set-ups for math and text. Figure 8.1 shows the sample text typeset in Computer Modern text and math fonts—the default font set-up in LaTeX. Figures 8.2 to 8.16 on pages 514–523 (with blue captions to visually separate caption and sample) have also been generated by typesetting this sample text, each time loading different support packages for text and math fonts. These packages do all the work required to modify LaTeX’s internal tables. For other set-ups and additional information see [24].

8-8-10
Image

Figure 8.1. Sample page typeset with Computer Modern fonts

8-8-11
Image

Figure 8.2. Sample page typeset with Concrete fonts

The Concrete Roman text fonts were designed by Donald Knuth, matching math fonts were designed by Ulrik Vieth; see Section 7.7.2. They are shown in Figure 8.2, which was produced by adding usepackage[boldsans]{ccfonts} to the preamble of the sample document. Note that Concrete fonts have no boldface, so that the ∂Q subscript on the integral comes out in poor man’s bold.

Figure 8.3 combines Concrete Roman with Euler Math (designed by Hermann Zapf). This combination was produced with

Image
8-8-12
Image

Figure 8.3. Sample page typeset with Concrete and Euler fonts

and shows no deficiencies with bold symbols in math; see also Section 7.7.10. You will probably want to design different headings, as the default (Computer Modern boldface extended) does not blend very well with Concrete Roman.

In Figure 8.4 we see Utopia combined with Fourier Math fonts (designed by Michel Bovani). This combination has been discussed in Section 7.7.7 and was produced by adding usepackage{fourier} to the preamble. Again, the boldface subscript shows deficiencies, but these are expected to be addressed in a future release of the fonts.

8-8-13
Image

Figure 8.4. Sample page typeset with Fourier fonts

The versions of Concrete, both Roman and Math, are freely available. Scalable outlines can be purchased from MicroPress.1 The Fourier set-up is freely available in Type 1 format.

1 http://www.micropress-inc.com

This page spread shows three math font set-ups for use with Times Roman as a body font. With Times Roman being one of the predominant fonts in use today, several solutions have been developed to provide support for it.

Figure 8.5 shows a free solution devised by Alan Jeffrey and others (discussed in Section 7.6.2), which was produced by adding usepackage{mathptmx} to the preamble. It deploys Adobe’s Symbol font for most mathematical symbols and due to a missing set of bold symbols for math, shows the typical deficiencies in this respect. In contrast to other font solutions it does not offer its own shapes for the extended AMS symbol set but uses the standard Computer Modern shapes.

8-8-14
Image

Figure 8.5. Sample page typeset with Times and Symbol

Figure 8.6 also shows a freely available implementation deploying the TX fonts (designed by Young Ryu). It offers the full range of mathematical symbols including boldface variants, but uses exceptionally tight spacing so that sometimes symbols in formulas touch each other; see Section 7.7.5 for details. It can be activated by adding usepackage{txfonts} in the preamble.

8-8-15
Image

Figure 8.6. Sample page typeset with Times and TX fonts

In Figure 8.7 we see the commercially available TM Math solution by Micro-Press,1 which uses considerably wider spacing in formulas. It comprises bold symbols and offers its own shapes for the AMS extended symbol set. It can be activated through usepackage{tmmath,tmams} in the preamble.

1 http://www.micropress-inc.com

8-8-16
Image

Figure 8.7. Sample page typeset with Times and TM Math fonts

Other commercial Math fonts in Type 1 format for use with Times Roman are MathTime and MathTime Professional (designed by Michael Spivak), available through Y&Y2 and PCTeX,3 respectively.

2 http://www.tug.org/yandy

3 http://www.pctex.com

The typeface Palatino was designed by Hermann Zapf for the Stempel foundry in 1948 based on lettering from the Italian Renaissance. Since then it has become one of the most widely used typefaces, and probably the most popular Old Style revival in existence. A number of math font set-ups are available for use with Palatino as the text font.

Figure 8.8 shows the freely available Math Pazo fonts (designed by Diego Puga), which can be activated with usepackage{mathpazo}. It offers boldface symbols and a matching blackboard bold alphabet, but does not contain specially designed shapes for the AMS symbol set; see also Section 7.6.3.

8-8-17
Image

Figure 8.8. Sample page typeset with Palatino and Math Pazo

In contrast, the free PX fonts (designed by Young Ryu) comprise the complete symbol set. They are shown in Figure 8.9. Just like the TX fonts, they are very tightly spaced; see Section 7.7.6 for details. This set-up can be activated with usepackage{pxfonts}.

8-8-18
Image

Figure 8.9. Sample page typeset with Palatino and PX fonts

Figure 8.10 shows the commercial solution offered by MicroPress.1 It provides a similar range of symbols as the Math Pazo solution with roughly the same running length, though with noticeably different shapes. This set-up can be activated with usepackage{pamath}.

1 http://www.micropress-inc.com

8-8-19
Image

Figure 8.10. Sample page typeset with Palatino and PA Math fonts

Figure 8.11 deploys the Baskerville typeface as a text font. This “transitional” typeface was originally designed by John Baskerville (1706–1775) and can be obtained from many font vendors. The math fonts are BA Math from MicroPress1—their distribution also contains a variant of the Baskerville text fonts used here. The BA Math fonts include bold weights but do not contain shapes for the AMS symbol set. Note that although the individual symbols do not look very large, the display formulas take more vertical space than in other examples. The font set-up is activated with usepackage{ba}.

1 http://www.micropress-inc.com

8-8-20
Image

Figure 8.11. Sample page typeset with Baskerville fonts

Figure 8.12 shows the use of the commercial CH Math fonts (also from MicroPress1). Their distribution has been designed to work with the freely available Charter fonts; see Section 7.6.1. The CH Math fonts comprise the full set of mathematical symbols including the AMS additions and are activated by adding the preamble line usepackage{chmath,chams}.

8-8-21
Image

Figure 8.12. Sample page typeset with Charter fonts

The Lucida Bright and Lucida New Math fonts are displayed in Figure 8.13. This set of commercial text and math fonts has been designed by Charles Bigelow and Kris Holmes and can be obtained from Y&Y.2 The font set-up covers all standard mathematical symbols including AMS additions and is activated by loading the lucidabr package. As you will notice, the formulas run very wide, which enhances legibility at the cost of space. The body font in this book is Lucida Bright. However, for the examples, we usually used Computer Modern to make them come out as in standard LaTeX.

2 http://www.tug.org/yandy

8-8-22
Image

Figure 8.13. Sample page typeset with Lucida Bright

This page spread shows two sans serif set-ups and an “informal” math font set-up. The solutions involving sans serif fonts can be usefully deployed in many circumstances, such as conventional articles, presentations (e.g., slides, reports), online documentation, or magazines. On the other hand, the Informal Math solution should probably be confined to announcements, fliers, and similar material.

Figure 8.14 shows the Computer Modern Bright set of fonts (designed by Walter Schmidt), which are based on the Computer Modern font design. The solution offers the full range of math symbols in normal and bold weights and is activated by loading the cmbright package; see Section 7.7.3. The fonts are freely available in format, and the Type 1 versions are commercially available from MicroPress.1

1 http://www.micropress-inc.com

8-8-23
Image

Figure 8.14. Sample page typeset with CM Bright fonts

Figure 8.15 shows a math font set-up for use with Helvetica (originally designed by Max Miedinger). The HV math fonts have been designed at MicroPress1 and comprise the full set of mathematical symbols. The set-up is activated by loading the packages hvmath and hvams (for the AMS symbol set). While the Type 1 fonts are only commercially available, you can obtain 300dpi bitmapped fonts free of charge from MicroPress.

8-8-24
Image

Figure 8.15. Sample page typeset with Helvetica Math fonts

Finally, Figure 8.16 shows the Informal Math solution also offered by Micro-Press.1 The font design is loosely based on Adobe’s Tekton family of fonts. The set-up is activated by loading the infomath package. Note that the text fonts are only available in OT1 and that the AMS symbol set is not supported.

8-8-25
Image

Figure 8.16. Sample page typeset with Informal Math fonts

8.9. Symbols in formulas

The tables at the end of this section advertise the large range of mathematical symbols provided by the Image fonts packages, including the command to use for each symbol. They also include the supplementary symbols from the St Mary Road Font, which was designed by Alan Jeffrey and Jeremy Gibbons. This font extends the Computer Modern and Image symbol font collections; the corresponding stmaryrd package should normally be loaded in addition to amssymb, but always after it. It provides extra symbols for fields such as functional programming, process algebra, domain theory, linear logic, and many more. For a wealth of information about an even wider variety of symbols, see the Comprehensive LaTeX Symbol List by Scott Pakin [134].

The tables indicate which extra packages need to be loaded to use each symbol command. They are organized as follows: symbols with command names in black are available in standard LaTeX without loading further packages; symbols in blue require loading either amsmath, amssymb, or stmaryrd, as explained in the table notes. If necessary, further classification is given by markings: (StM) signals a symbol from stmaryrd when the table also contains symbols from other packages; (kernel) identifies symbols that are available in standard LaTeX but only by combining two or more glyphs, whereas a single glyph exists in the indicated package; and (var) marks “Alphabetic characters/symbols” (of type mathalpha; see Table 7.30 on page 435) that change appearance when used within the scope of a math alphabet identifier (see Section 7.4).

8.9.1. Mathematical symbol classes

The symbols are classified primarily by their “mathematical class”, occasionally called their “math symbol type”. This classification is related to their “meaning” in standard technical usage, but its importance for mathematical typography is that it influences the layout of a formula. For example, TeX’s mathematical formatter adjusts the horizontal space on either side of each symbol according to its mathematical class. There are also some finer distinctions made, for example, between accents and simple symbols and in breaking up the enormous list of Relation symbols into several tables.

The set-up for mathematics puts each symbol into one of these classes: Ordinary (Ord), Operator (Op), Binary (Bin), Relation (Rel), Opening (Open), Closing (Close), or Punctuation (Punct). This classification can be explicitly changed by using the commands mathord, mathop, mathbin, mathrel, mathopen, mathclose, and mathpunct, thereby altering the surrounding spacing. In this example, # and op (both Ord by default) are changed into a Rel and an Op.

8-9-1
Image

A symbol can be declared to belong to one of the above classes using the mechanism described in Section 7.10.7. In addition, certain sub-formulas—most importantly fractions, and those produced by left and ight—form a class called Inner; it is explicitly available through the mathinner command.

In TeX, spacing within formulas is done simply by identifying the class of each object in a formula and then adding space between each pair of adjacent objects as defined in Table 8.7; this table is unfortunately hard-wired into TeX’s mathematical typesetting routines and so cannot be changed by macro packages.1 In this table 0, 1, 2, and 3 stand for no space, a thin space (,), a medium space (:), and a thick space (;), respectively. The exact amounts of space used are listed in Section 8.7.6 on page 507.

1 Although a few of the entries in the table are questionable, on the whole it gives pleasing results.

A Binary symbol is turned into an Ordinary symbol whenever it is not preceded and followed by symbols of a nature compatible with a binary operation; for this reason, some entries in the table are marked with a star to indicate that they are not possible. For example, $+x$ gives +x (a “unary plus”) and not + x; the latter can be produced by ${}+x$.

Finally, an entry in (blue) in Table 8.7 indicates that the corresponding space is not inserted when the style is script or scriptscript.

As an example of applying these rules, consider the following formula (the default values are deliberately changed to show the added spaces more clearly):

8-9-2
Image

TeX identifies the objects as Ord, Bin, Ord, and so on, and then inserts spaces as follows:

Image

The minus in front of max is turned into an Ordinary because a Binary cannot follow a Relation.

Table 8.7 reveals a difference1 between a “left... ight” construction, in which the entire sub-formula delimited by the construction becomes a single object of class Inner (see Section 8.5.3 on page 498), and commands like Bigl and Bigr that produce individual symbols of the classes Opening and Closing, respectively. Although they may result in typesetting delimiters of equal vertical size, spacing differences can arise depending on adjacent objects in the formula. For example, Ordinary followed by Opening gets no space, whereas Ordinary followed by Inner is separated by a thin space. The spaces inside the sub-formula within a “left... ight” construction are as expected, beginning with an Opening symbol and ending with a Closing symbol. In this example we again use larger spaces to highlight the difference.

1 Another important distinction is that the material within a “left... ight” construction is processed separately as a sub-formula (see Section 8.7.2 on page 503).

8-9-3
Image

In summary, it is not enough to look up a symbol in the tables that follow; rather, it is also advisable to check that the symbol has the desired mathematical class to ensure that it is properly spaced when used. Example 8-9-4 on page 528 shows how to define new symbols that differ only in their mathematical class from existing symbols.

8.9.2. Letters, numerals, and other Ordinary symbols

The unaccented ASCII Latin letters and Arabic numeral digits (see Table 8.8) are referred to as “Alphabetic symbols”. The font used for them can vary: in mathematical formulas, the default font for Latin letters is italic whereas for the Arabic digits it is upright/Roman. Alphabetical symbols are all of class Ordinary.

Image

Table 8.8. Latin letters and Arabic numerals

Unlike the Latin letters, the mathematical Greek letters are no longer closely related to the glyphs used for typesetting normal Greek text. Due to an interesting 18th-century happenstance, in the major European tradition of mathematical typography the default font for lowercase Greek letters in mathematical formulas is italic whereas for uppercase Greek letters it is upright/Roman. (In other fields, such as physics and chemistry, the typographical traditions are slightly different.)

The capital Greek letters in the first rows of Table 8.9 are also Alphabetic symbols whose font varies, with the default being upright/Roman. Those capital Greek letters not present in this table are the letters that have the same appearance as some Latin letter (e.g., A and Alpha, B and Beta, K and Kappa, O and Omicron). Similarly, the list of lowercase Greek letters contains no omicron because it would be identical in appearance to the Latin o. Thus, in practice, the Greek letters that have Latin look-alikes are not used in mathematical formulas.

Image

Table 8.9. Symbols of class mathord (Greek)

Table 8.10 lists other letter-shaped symbols of class Ordinary. The first four are Hebrew letters. Table 8.11 lists the remaining symbols in the Ordinary class, including some common punctuation. These behave like letters and digits, so they never get any extra space around them.

Image

Table 8.10. Symbols of class mathord (letter-shaped)

Image

Table 8.11. Symbols of class mathord (miscellaneous)

A common mistake is to use the symbols from Table 8.11 directly as Binary operator or Relation symbols, without using a properly defined math symbol command for that type. Thus, if you use commands such as #, square, or &, check carefully that you get the correct inter-symbol spaces or, even better, define your own symbol command.

8-9-4
Image

The DeclareMathSymbol declaration is explained in Section 7.10.7. The correct values for its arguments are most easily found by looking at the definitions in the file amssymb.sty or fontmath.ltx (for the core symbols). For example, we looked up eg and square, replaced the mathord in each case, and finally gave the resulting symbol a new name.

8.9.3. Mathematical accents

The accent commands available for use in formulas are listed in Table 8.12. Most of them are already defined in standard LaTeX. See Section 8.4.8 for ways to define additional accent commands and Section 8.5.2 for information about extensible accents. Adding a mathematical accent to a symbol always produces a symbol of class Ordinary. Thus, without additional help, one cannot use the accents to produce new Binary or Relation symbols.

Image

Table 8.12. Mathematical accents, giving sub-formulas of class mathord

8-9-5
Image

Other ways to place symbols over Relation symbols are shown in Section 8.4.10. When adding an accent to an i or j in mathematics, it is best to use the dotless variants imath and jmath; for example, use hat{jmath} to get Ĵ.

8.9.4. Binary operator symbols

There are more than 100 symbols of class Binary operators from which to choose. Most of these Binary symbols are shown in Table 8.13 on the next page. Some of them are also available, under different names, as Relation symbols.

Image

Table 8.13. Symbols of class mathbin (miscellaneous)

The amssymb package offers a few box symbols for use as Binary operators; many more are added by stmaryrd. These are shown in Table 8.14.

Image

Table 8.14. Symbols of class mathbin (boxes)

The stmaryrd package can be loaded with the option heavycircles. It causes each circle symbol command in Table 8.15 on page 531 that starts with var to swap its definition with the corresponding command without the “var”; for example, the symbol varodot becomes odot, and vice versa.

Image

Table 8.15. Symbols of class mathbin (circles)

8.9.5. Relation symbols

The class of binary Relation symbols forms a collection even larger than that of the Binary operators. The lists start with symbols for equality and order (Table 8.16 on the next page). You can put a slash through any Relation symbol by preceding it with the ot command; this negated symbol represents the complement (or negation) of the relation.

Image

Table 8.16. Symbols of class mathrel (equality and order)

8-9-6
Image

Especially with larger symbols, this generic method of negating a Relation symbol does not always give good results because the slash will always be of the same size, position, and slope. Therefore, some specially designed “negated symbols” are also available (see Table 8.17 on the following page). If a choice is available, the designed glyphs are usually preferable. To see why, compare the symbols in this example.

Image

Table 8.17. Symbols of class mathrel (equality and order—negated)

8-9-7
Image

Next come the Relation symbols for sets and inclusions, and their negations (see Tables 8.18 and 8.19).

Image

Table 8.18. Symbols of class mathrel (sets and inclusion)

Image

Table 8.19. Symbols of class mathrel (sets and inclusion—negated)

They are followed by Relation symbols that are arrow-shaped (see Tables 8.20 and 8.21). Some extensible arrow constructions that produce compound Relation symbols are described in Section 8.5.2 on page 497.

Image
Image

Table 8.20. Symbols of class mathrel (arrows)

Image

Table 8.21. Symbols of class mathrel (arrows—negated)

In addition to ot, used to negate general Relation symbols, other building blocks have been especially designed to negate or extend arrow-like symbols; these are collected in Table 8.22.

Image

Table 8.22. Symbols of class mathrel (negation and arrow extensions)

8-9-8
Image

Finally, in Table 8.23 on page 535 you will find a miscellaneous collection of Relation symbols.

Image

Table 8.23. Symbols of class mathrel (miscellaneous)

8.9.6. Punctuation

The symbols of class Punctuation appear in Table 8.24, together with some other punctuation-like symbols. Note that some of the typical punctuation characters (i.e., “. ! ?”) are not set up as mathematical punctuation but rather as symbols of class Ordinary. This can cause unexpected results for common uses of these symbols, especially in the cases of ! and ?. Some of the dots symbols listed here are of class Inner; Section 8.5.1 on page 496 provides information about using dots for mathematical ellipsis.

Image

Table 8.24. Symbols of class mathpunct, mathord, mathinner (punctuation)

The : character produces a colon with class Relation—not a Punctuation symbol. As an alternative, standard LaTeX offers the command colon as the Punctuation symbol. However, the amsmath package makes unfortunate major changes to the spacing produced by the command colon, so that it is useful only for a particular layout in constructions such as fcolon A o B where it produces f : A B. It is therefore wise to always use mathpunct{:} for the simple punctuation colon in mathematics.

8.9.7. Operator symbols

The Operator symbols typically come in two sizes, for text and display uses; most of them are related to similar Binary operator symbols. Whether an Operator symbol takes limits in displays depends on a variety of factors (see Section 8.4.4). The available collection is shown in Table 8.25.

Image

Table 8.25. Symbols of class mathop

8.9.8. Opening and Closing symbols

The paired extensible delimiters, when used on their own (i.e., without a preceding left, ight, or middle), produce symbols of class Opening or Closing; these pairs are listed in Table 8.26. See Section 8.5.3 on page 498 for further information about the extensible symbols.

Image

Table 8.26. Symbol pairs of class mathopen and mathclose (extensible)

To improve the flexibility of the vertical bar notation, amsmath defines some new pairs of paired extensible delimiter commands: lvert, vert, lVert, and Vert. These commands are comparable to standard LaTeX’s langle and angle commands.

The stmaryrd package adds a collection of non-extensible paired symbols of class Opening and Closing, which are listed in Table 8.27.

Image

Table 8.27. Symbol pairs of class mathopen and mathclose (non-extensible)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.24.118