allied ones. Thus all discussion below is under the assumption that the package amsmath

has been loaded with the command \usepackage{amsmath}.

Single equations

VIII.3.1.

In addition to the LTEX commands for displaying math as discussed earlier, the ams-

A

math also provides the \begin{equation*} ... \end{equation*} construct. Thus with

this package loaded, the output

The equation representing a straight line in the Cartesian plane is of the form

ax + by + c = 0

where a, b, c are constants.

can also be produced by

83

MORE

VIII.3. ON MATHEMATICS

The equation representing a straight line in the Cartesian plane is

of the form

\begin{equation*}

ax+by+c=0

\end{equation*}

where $a$, $b$, $c$ are constants.

Why the * after equation? Suppose we try it without the * as

The equation representing a straight line in the Cartesian plane is

of the form

\begin{equation}

ax+by+c=0

\end{equation}

where $a$, $b$, $c$ are constants.

we get

The equation representing a straight line in the Cartesian plane is of the form

ax + by + c = 0

(VIII.1)

where a, b, c are constants.

This provides the equation with a number. We will discuss equation numbering in some

more detail later on. For the time being, we just note that for any environment name

with a star we discuss here, the unstarred version provides the output with numbers.

Ordinary text can be inserted inside an equation using the \text command. Thus

we can get

Thus for all real numbers x we have

x ¤ |x| and x ≥ |x|

and so

x ¤ |x| for all x in R.

from

Thus for all real numbers $x$ we have

\begin{equation*}

x\le|x|\quad\text{and}\quad x\ge|x|

\end{equation*}

and so

\begin{equation*}

x\le|x|\quad\text{for all $x$ in $R$}.

\end{equation*}

Note the use of dollar signs in the second \text above to produce mathematical

symbols within \text.

Sometimes a single equation maybe too long to ¬t into one line (or sometimes even

two lines). Look at the one below:

(a + b + c + d + e)2 = a2 + b2 + c2 + d2 + e2

+ 2ab + 2ac + 2ad + 2ae + 2bc + 2bd + 2be + 2cd + 2ce + 2de

84 TYPESETTING MATHEMATICS

VIII.

This is produced by the environment multline* (note the spelling carefully”it is not

mult i line), as shown below.

\begin{multline*}

(a+b+c+d+e)ˆ2=aˆ2+bˆ2+cˆ2+dˆ2+eˆ2\\

+2ab+2ac+2ad+2ae+2bc+2bd+2be+2cd+2ce+2de

\end{multline*}

can be used for equations requiring more than two lines, but without tweaking,

multline

the results are not very satisfactory. For example, the input

\begin{multline*}

(a+b+c+d+e+f)ˆ2=aˆ2+bˆ2+cˆ2+dˆ2+eˆ2+fˆ2\\

+2ab+2ac+2ad+2ae+2af\\

+2bc+2bd+2be+2bf\\

+2cd+2ce+2cf\\

+2de+2df\\

+2ef

\end{multline*}

produces

(a + b + c + d + e + f )2 = a2 + b2 + c2 + d2 + e2 + f 2

+ 2ab + 2ac + 2ad + 2ae + 2a f

+ 2bc + 2bd + 2be + 2b f

+ 2cd + 2ce + 2c f

+ 2de + 2d f

+ 2e f

By default, the multline environment places the ¬rst line ¬‚ush left, the last line ¬‚ush right

(except for some indentation) and the lines in between, centered within the display.

A better way to typeset the above multiline (not multline) equation is as follows.

(a + b + c + d + e + f )2 = a2 + b2 + c2 + d2 + e2 + f 2

+ 2ab + 2ac + 2ad + 2ae + 2a f

+ 2bc + 2bd + 2be + 2b f

+ 2cd + 2ce + 2c f

+ 2de + 2d f

+ 2e f

This is done using the split environment as shown below.

\begin{equation*}

\begin{split}

(a+b+c+d+e+f)ˆ2 & = aˆ2+bˆ2+cˆ2+dˆ2+eˆ2+fˆ2\\

&\quad +2ab+2ac+2ad+2ae+2af\\

&\quad +2bc+2bd+2be+2bf\\

&\quad +2cd+2ce+2cf\\

&\quad +2de+2df\\

&\quad +2ef

\end{split}

\end{equation*}

85

MORE

VIII.3. ON MATHEMATICS

Some comments seems to be in order. First note that the split environment cannot

be used independently, but only inside some equation structure such as equation (and

others we will soon see). Unlike multline, the split environment provides for alignment

among the “split” lines (using the & character, as in tabular). Thus in the above example,

all the + signs are aligned and these in turn are aligned with a point a \quad to the right

of the = sign. It is also useful when the equation contains multiple equalities as in

(a + b)2 = (a + b)(a + b)

= a2 + ab + ba + b2

= a2 + 2ab + b2

which is produced by

\begin{equation*}

\begin{split}

(a+b)ˆ2 & = (a+b)(a+b)\\

& = aˆ2+ab+ba+bˆ2\\

& = aˆ2+2ab+bˆ2

\end{split}

\end{equation*}

Groups of equations

VIII.3.2.

A group of displayed equations can be typeset in a single go using the gather environ-

ment. For example,

(a, b) + (c, d) = (a + c, b + d)

(a, b)(c, d) = (ac ’ bd, ad + bc)

can be produced by

\begin{gather*}

(a,b)+(c,d)=(a+c,b+d)\\

(a,b)(c,d)=(ac-bd,ad+bc)

\end{gather*}

Now when several equations are to be considered one unit, the logically correct way

of typesetting them is with some alignment (and it is perhaps easier on the eye too). For

example,

Thus x, y and z satisfy the equations

x+y’z=1

x’y+z=1

This is obtained by using the align* environment as shown below

Thus $x$, $y$ and $z$ satisfy the equations

\begin{align*}

x+y-z & = 1\\

x-y+z & = 1

\end{align*}

86 TYPESETTING MATHEMATICS

VIII.

We can add a short piece of text between the equations, without disturbing the alignment,

using the \intertext command. For example, the output

Thus x, y and z satisfy the equations

x+y’z=1

x’y+z=1

and by hypothesis

x+y+z=1

is produced by

Thus $x$, $y$ and $z$ satisfy the equations

\begin{align*}

x+y-z & = 1\\

x-y+z & = 1\\

\intertext{and by hypothesis}

x+y+z & =1

\end{align*}

We can also set multiple ˜columns™ of aligned equations side by side as in

Compare the following sets of equations

cos2 x + sin2 x = 1 cosh2 x ’ sinh2 x = 1

cos2 x ’ sin2 x = cos 2x cosh2 x + sinh2 x = cosh 2x

All that it needs are extra &™s to separate the columns as can be sen from the input

Compare the following sets of equations

\begin{align*}

\cosˆ2x+\sinˆ2x & = 1 & \coshˆ2x-\sinhˆ2x & = 1\\

\cosˆ2x-\sinˆ2x & = \cos 2x & \coshˆ2x+\sinhˆ2x & = \cosh 2x

\end{align*}

We can also adjust the horizontal space between the equation columns. For example,

Compare the sets of equations

\begin{align*}

\cosˆ2x+\sinˆ2x & = 1 &\qquad \coshˆ2x-\sinhˆ2x & = 1\\

\cosˆ2x-\sinˆ2x & = \cos 2x &\qquad \coshˆ2x+\sinhˆ2x & = \cosh 2x

\end{align*}

gives

Compare the sets of equations

cos2 x + sin2 x = 1 cosh2 x ’ sinh2 x = 1

cos2 x ’ sin2 x = cos 2x cosh2 x + sinh2 x = cosh 2x

Perhaps a nicer way of typesetting the above is

87

MORE

VIII.3. ON MATHEMATICS

Compare the following sets of equations

cos2 x + sin2 x = 1 cosh2 x ’ sinh2 x = 1

and

cos2 x ’ sin2 x = cos 2x cosh2 x + sinh2 x = cosh 2x

This cannot be produced by the equation structures discussed so far, because any of these

environments takes up the entire width of the text for its display, so that we cannot put

anything else on the same line. So amsmath provides variants gathered, aligned and

alignedat which take up only the actual width of the contents for their display. Thus the

above example is produced by the input

Compare the following sets of equations

\begin{equation*}

\begin{aligned}

\cosˆ2x+sinˆ2x & = 1\\

\cosˆ2x-\sinˆ2x & = \cos 2x

\end{aligned}

\qquad\text{and}\qquad

\begin{aligned}

\coshˆ2x-\sinhˆ2x & = 1\\

\coshˆ2x+\sinhˆ2x & = \cosh 2x

\end{aligned}

\end{equation*}

Another often recurring structure in mathematics is a display like this

±

if x ≥ 0

x

|x| =

’x if x ¤ 0

There is a special environment cases in amsmath to take care of these. The above exam-

ple is in fact produced by

\begin{equation*}

|x| =

\begin{cases}

x & \text{if $x\ge 0$}\\

-x & \text{if $x\le 0$}

\end{cases}

\end{equation*}

Numbered equations

VIII.3.3.

We have mentioned that each of the the ˜starred™ equation environments has a corre-

sponding unstarred version, which also produces numbers for their displays. Thus our

very ¬rst example of displayed equations with equation instead of equation* as in

The equation representing a straight line in the Cartesian plane is

of the form

\begin{equation}

ax+by+c=0

\end{equation}

where $a$, $b$, $c$ are constants.

88 TYPESETTING MATHEMATICS

VIII.

produces

The equation representing a straight line in the Cartesian plane is of the form

ax + by + c = 0

(VIII.2)

where a, b, c are constants.

Why VIII.2 for the equation number? Well, this is Equation number 2 of Chap-

ter VIII, isn™t it? If you want the section number also in the equation number, just give

the command

\numberwithin{equation}{section}

We can also override the number LTEX produces with one of our own design with the

A

\tag command as in

The equation representing a straight line in the Cartesian plane is

of the form

\begin{equation}

ax+by+c=0\tag{L}

\end{equation}

where $a$, $b$, $c$ are constants.

which gives

The equation representing a straight line in the Cartesian plane is of the form

ax + by + c = 0

(L)

where a, b, c are constants.

There is also a \tag* command which typesets the equation label without parentheses.

What about numbering alignment structures? Except for split and aligned, all

other alignment structures have unstarred forms which attach numbers to each aligned

equation. For example,

\begin{align}

x+y-z & = 1\\

x-y+z & = 1

\end{align}

gives

x+y’z=1

(VIII.3)

x’y+z=1

(VIII.4)

Here is also, you can give a label of your own to any of the equations with the \tag

command. Be careful to give the \tag before the end of line character \\ though. (See

what happens if you give a \tag command after a \\.) You can also suppress the label for

any equation with the \notag command. These are illustrated in the sample input below:

Thus $x$, $y$ and $z$ satisfy the equations

\begin{align*}

89

MATHEMATICS

VIII.4. MISCELLANY

x+y-z & = 1\ntag\\

x-y+z & = 1\notag\\

\intertext{and by hypothesis}

x+y+z & =1\tag{H}

\end{align*}

which gives the following output

Thus x, y and z satisfy the equations

x+y’z=1

x’y+z=1

and by hypothesis

x+y+z=1

(H)

What about split and aligned? As we have seen, these can be used only within

some other equation structure. The numbering or the lack of it is determined by this

parent structure. Thus

\begin{equation}

\begin{split}