Alignment of formulas

Richard Kaye School of Mathematics and Statistics The University of Birmingham Birmingham B15 2TT U.K.

12th August 1998

1 Introduction

One of the most difficult aspects of typesetting mathematics is splitting long formulas across several lines and aligning a group of formulas. Many of these aspects cannot be done automatically, and it is up to you to control how this is to done. In all cases, your judgement should be based on making the formula as readable as possible.

Some control is available using L^{A}TEX’s eqnarray and eqnarray* environments. However, this command is rather limited for many applications and if you are creating a new document in which you envisage a large number of long formulas or equations I strongly recommend you use the AMS packages that are available.

2 Using the package

Unless you are using one of the AMS’s own class files, you load the package by the command \usepackage{amsmath}. This loads lots of useful new commands, including the alignment environments referred to earlier. These are:

1. equation essentially as usual

2. multline for single equations or formulas going over two or more lines

3. split as for multline, but with extra control over alignment

4. gather for several equations grouped together

5. align for several equations grouped together, with alignment

6. alignat similar to align but with some extra alignment features

In most cases, there are starred and unstarred versions of these—the starred versions do not produce any numbering automatically. There are a few other related commands, such as: the \intertext command which interpolates text without messing up the alignment; the subequations environment which numbers a groups of equations as 5a, 5b, 5c, etc.; the cases environment for definitions by cases, and a few other useful things. I’m not going to describe in detail how these commands ae used—you can get that from the documentation. Instead, the next section contains some examples and you can quickly get started by comparing the output with the L^{A}TEX source, which is called align.tex and can be obtained from the usual directory.

3 Examples

Many of these examples are directly taken from the documentation of AMSL^{A}TEX, which is recommended reading if further details are required.

   Use of equation*:

a = b

Use of equation:

a = b  (1)

Use of split and equation:

\begin{aligned}a & = b + c − d \\ & + e − f \\ & = g + h \\ & = i \end{aligned}  (2)

Use of multline:

a + b + c + d + e + f + b + c + d + e + f + b + c + d + e + f + b + c + d + e + f + b + c + d + e + f + i + j + k + l + m + n (3)

Use of gather:

a_{1} = b_{1} + c_{1}  (4)
a_{2} = b_{2} + c_{2} − d_{2} + e_{2}  (5)

Use of align:

a_{1} = b_{1} + c_{1}  (6)
a_{2} = b_{2} + c_{2} − d_{2} + e_{2}  (7)

Other uses for align:

a_{11} = b_{11}  a_{12} = b_{12}  (8)
a_{21} = b_{21}  a_{22} = b_{22} + c_{22}  (9)

Use of flalign*:

a_{11} = b_{11}  a_{12} = b_{12}
a_{21} = b_{21}  a_{22} = b_{22} + c_{22}

Use of \equation and \split:

\begin{aligned}H_{c} & = \frac{1}{2n} ∑_{l=0}^{n}(−1)^{l}(n − l)^{p−2} ∑_{l_{1}+···+l_{p}=l} ∏_{i=1}^{p} \binom{n_{i}}{l_{i}} \\ & · [(n − l) − (n_{i} − l_{i})]^{n_{i}−l_{i}} · [(n − l)^{2} − ∑_{j=1}^{p}(n_{i} − l_{i})^{2}]. \end{aligned}  (10)

Use of \align to align textual annotations:

x = y_{1} − y_{2} + y_{3} − y_{5} + y_{8} − …  by (14)  (11)
= y′ ∘ y^{∗}  by (5)  (12)
= y(0)y′  by Axiom 1.  (13)

Use of \aligned to control placement of inner alignments:

\begin{aligned}α & = αα \\ β & = βββββ \\ γ & = γ \end{aligned}  versus  \begin{aligned}δ & = δδ \\ η & = ηηηηηη \\ φ & = φ \end{aligned}

“Cases” constructions:

P_{r−j} = \begin{cases}0 & if r − j is odd, \\ r! (−1)^{(r−j)/2} & if r − j is even. \end{cases}  (14)

Use of \smash and \vphantom to control vertical size:

⟨u ∑_{i=1}^{n} F (e_{i}, v)e_{i}⟩ = ∑_{i=1}^{n} F (e_{i}, v)⟨u|e_{i}⟩

= ∑_{i=1}^{n}⟨u|e_{i}⟩F (e_{i}, v)

= ∑_{i=1}^{n} \overline{⟨e_{i}|u⟩}F (e_{i}, v)

= F (∑_{i=1}^{n}⟨e_{i}|u⟩e_{i}, v) = F (u, v),

(Note that without \phantom and \smash the brackets would be too big because of the limits on the summations.) \phantom is also useful if you are splitting a long equation over two lines and you want a large left bracket on one line to match a large right bracket on the next:

x = \frac{1}{2} (∑_{i=1}^{n} F (e_{i}, v)e_{i} + ∑_{i=1}^{n} G(e_{i}, v)e_{i} + ∑_{i=1}^{n} H(e_{i}, v)e_{i}+

∑_{i=1}^{n} I(e_{i}, v)e_{i} + ∑_{i=1}^{n} K(e_{i}, v)e_{i} + ∑_{i=1}^{n} J(e_{i}, v)e_{i})

(Note also the adjustment to the vertical spacing in this example.)

   Use of \intertext:

Proof. (a) Given v, we have

1 v = (−1)(−1)v

= (−1)(−1)v + 0 = (−1)(−1)v + (v + (−1)v) = (−1)(−1)v + ((−1)v + v) = ((−1)(−1)v + (−1)v) + v = 0 + v = v.

(b) Again,

0 v = (1 + (−1))v

= 1v + (−1)v = v + (−1)v = 0.

For (c),

λ0 = λ(0 + (−1)0)

= λ0 + λ((−1)0) = λ0 + (−1)(λ0) = 0

as required.