11.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. Many of them are provided by the amsmath package, but in some cases further packages need to be loaded.
11.4.1 amsmath, mathtools, extarrows — Decorated arrows
The amsmath commands and produce horizontal relation arrows similar to those used for the commutative diagrams in Section 11.3.5; 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.
Further extensible arrows with the same syntax for superscript and subscript material are provided by the mathtools package. This includes three double line arrows, two hook arrows, and various harpoons as shown in the next example. In the case of the double line arrows, you may have to add some extra spacing inside the arguments to avoid the material bumping into the arrowhead (as we did with ␣ in the example); for the harpoons this is usually not necessary.
11.4.2 Fractions and their generalizations
In addition to the command from standard LaTEX, the amsmath package provides and as convenient abbreviations for {…} and {…} (mathematical styles are discussed in more detail in Section 11.7.1 on page 195).
11.4.3 Continued fractions
The 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].
11.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:
11.4.5 Stacking in subscripts and superscripts
The standard LaTEX 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 provided by the amsmath package, which allows you to specify that the lines should be left aligned instead of centered (no right alignment). Note that both structures need to be surrounded by braces when they appear as a subscript or superscript.
11.4.6 amsmath, esint, wasysym — Multiple integral signs
Using amsmath, the commands , , and give multiple integral signs with well-adjusted spaces between them, in both running text and displays. The command gives two integral signs with ellipsis dots between them. These commands are all built up from single integrals placed side by side (with somewhat reduced spacing), whereas the esint package (described below) uses a separate symbol font with individual glyphs for each integral.
The following example also shows the use of to override the default for integral constructions and place the limit V underneath the symbol; as an alternative, we could have used the package option intlimits.
Do not try to apply superscripts to these integrals when setting them with ; they come out in fairly strange places as the next example shows. This time we used intlimits so that all integrals have limits by default.
If you think that the amsmath versions of the multiple integral signs are too much spaced apart or if you need other integral signs that are not in that set, you can load the esint package by Eddie Saudrais. Like amsmath it supports the options intlimits and nointlimits (default). If both packages are used, amsmath has to be loaded first; otherwise, it reinstalls its version of the integrals, and only the new ones are available.
If you compare the first line of the next example with the previous one, you can see that the individual integrals are much closer together and that with the esint package version the upper limits, though not perfect, come out more or less right. The second and third rows show the additionally defined integrals by the package, in case you have a need for one or the other in that set. Again, we use the option intlimits and override it a few times with an explicit command.
As the package uses its own symbol font, it should be used only if you use the default Computer Modern Math fonts or a set of math fonts that are visually compatible with these integrals.
Some people prefer upright integral symbols instead of the default slanted ones. This can be achieved using the package wasysym with the option integrals. If amsmath is loaded too (order is irrelevant), then and are also changed; otherwise, these two amsmath commands are not available. The other special integrals provided by the esint package are not available in this style. See Section 10.13.2 on page 116 for further information on the wasysym package.
11.4.7 diffcoeff — Handling derivatives of arbitrary order
If you often need ordinary, partial, and other derivatives, then take a look at the diffcoeff package by Andrew Parsloe, because it helps you to produce them in a consistent manner with the ability to adjust their style in various ways. By default, it implements the ISO 80000-2 recommendation, and with the help of a def-file option you can specify a file to hold your own conventions and adjustments for reuse in several documents.
The command produces an ordinary derivative, while is responsible for partial derivatives — the argument structure is the same for both commands. The differentiand is normally set as a numerator; the starred form appends it instead, and a second star also swaps the mandatory arguments — i.e., variable first, to retain the reading order. If you prefer a slashed style use or , and for a very compact representation, use or instead. The order of differentiation (default 1) is specified in the first optional argument, and a point of evaluation can be set in the second optional argument. Below we show a few examples:
If you prefer to have fewer braces in your formula, you can leave them out around the mandatory arguments— but, of course, only if they are single tokens! We have done this in the next example, which uses slashed and compact style, because this usually works better in text. Otherwise, this repeats the previous example to allow for easy comparison.
Notations like dx or dx (ISO style) also appear in other places than derivatives, e.g., in integrals. If you switch between different styles (because the publishing journal has requirements to use or not use ISO style), you would want to see the expressions change throughout without the need to manually alter the source. To accomodate this, the package offers the small command , which changes appearance based on the overall style you have selected. By default, the d’s are written upright:
The package offers many customization possibilities. You can, for example, produce derivatives with symbols such as D, δ, or ∆; adjust the spacing; define new variants; and much more. For reuse in different documents, the necessary declarations can be stored in a file with the extension .def and loaded with the option def-file =⟨file⟩. See the extensive package documentation for further details.
11.4.8 Modular relations
Standard LaTEX already provides the commands and . The amsmath package augments this set with and to deal with special spacing conventions of the “mod” notation for equivalence classes of integers. These extra commands are variants of that are preferred by some authors; omits the parentheses, whereas omits the “mod” and retains the parentheses. Furthermore, with amsmath the spacing of is decreased within an inline formula.
11.4.9 mathtools, interval — Properly spaced intervals
Specifying intervals is usually done by using brackets as fences, e.g., “[a, b]”. This is simple for closed intervals, but the natural input for open or half-open intervals fails rather miserably with respect to spacing as seen in the next example:
The reason for this spacing result is that “[” is considered by TEX as an opening and “]” as a closing symbol. However, if used as fences for half or fully open intervals, their interpretation should be reversed— something TEX cannot determine by itself. So it sees an opening symbol “ ” ollowed by an “=” (relation), and that does not get any space added. With the help of explicit and commands (see Section 11.8.1 on page 209), this can be corrected; however, the resulting input becomes rather noncomprehensible at the same time:
To avoid such source code monsters, mathtools offers the possibility of defining new commands that automatically supply opening and closing delimiters around their argument.
This declaration defines a new command cmd with one mandatory argument that is typeset surrounded by the left-delimiter and right-delimiter. Also defined is a starred form that sets the delimiters using and , which is why you can use only real delimiters that are allowed after those commands, e.g., those from Table 11.5 on page 190 or Table 11.30 on page 224. Instead of the star, you can use an optional argument to specify the size explicitly using , , , or .
11.4.10 braket — Dirac bra–ket and set notation
The bra–ket notation, also known as Dirac notation, was established by Paul Dirac around 1940. In quantum mechanics it is a common notation for describing quantum states. Donald Arseneau produced a small package, bracket, that offers a handful of commands to enter the notation consistently.
Commands starting with an uppercase letter grow vertically to enclose their content (using internally and ), while the lowercase commands do not change sizes. You can use | in the argument to generate extensible vertical lines as needed, and with || or | you get doubled lines. As sets have a similar structure involving vertical lines, they are also provided via and .
11.4.11 amsmath, mathtools, empheq — Boxed formulas
The amsmath command puts a box around its argument; it works just like , except that the contents are in math mode.
11.4.12 amsmath, accents, mathdots — Various accents
TEX distinguishes sharply between accented characters in text and in math. To obtain “à” in text, you can use the Unicode character “à” or the command “’a”, both of which fail in math mode. Depending on the engine you might get a warning or error message, but the character may also be silently ignored with only an entry in the transcript file saying something like
Thus, to typeset accents over mathematical symbols you should always use special math accent commands, i.e., in this case. The full set of math accents provided by standard LaTEX is shown in the next example.
Note that most accents change with the math alphabet currently in use; e.g., all but , , and become bold when we place them inside . This means you have a choice: if you use or any other varying math accent within a math alphabet command, you get accents in the “style” of the alphabet; if you use them outside, you get ordinary ones. This is shown on the third line.
11.4.13 mattens — Commands to typeset tensors
There exist quite a number of different notations for denoting vectors and tensors, and not surprisingly, there are a number of packages that implement an input syntax for them. For the book we selected the mattens package by Danie Els, because it offers a simple and very flexible interface, but if this does not appeal to you, then there are a handful of other packages on CTAN and probably in your distribution.
The commands offered by the package all follow the naming scheme, where the placeholder □ stands for either a (arrow), b (bar), or nothing (no embellishment), which gives you a total of eight commands as shown in Table 11.3. All follow the same argument structure: mandatory symbol and an optional (math) accent. The starred forms typeset the symbol as an ordinary symbol, i.e., not boldened.
There are also two cross-product tensors: and . The example below exhibits some of the different combinations:
As you can deduce from the previous example (because gather is available), the package implicitly loads amsmath. What you also see is that with Computer Modern fonts the arrows (being very large) touch the x— with Lucida Math (as shown in the table) this is not an issue. One way to solve that is to use the package option mathstrut, which adds a into each tensor thereby forcing upper and lower arrows and bars farther apart. You can alternatively define your own struts using, for example, as explained in the package documentation.
Some people prefer to show tensors and vectors in a different font instead of boldening the symbols. The next example shows how to do this with the help of . Note that this acts only on symbols that are affected by math alphabets; e.g., the Greek letter is not altered. For the same reason you still see the ordinary x when the starred form is used, because that suppresses special formatting.
The Computer Modern fonts do not have a bold sans serif font shape, but the Latin Modern do, so we define a math alphabet for it and use that.
If you find yourself always using the starred forms, because you want to supply your own formatting, you can instead load the package with the option noformat, which suppresses the boldening or other automatic formatting of the symbols.
11.4.14 Extra decorations for symbols
Standard LaTEX provides for placing a superscript above a Relation symbol. A set of possibly more useful commands is provided by the amsmath package with the commands , , and . They can be used to place material above and/or below any Ordinary symbol or Binary operator symbol,
in addition to Relation symbols, and automatically determine the correct math type for the resulting compound symbol.
The command 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 P or Q. These are placed in the subscript and superscript positions, on both the left and right of the Operator.