Alignment

Recall that the $equation$ environment can be used to display and automatically number a single- line equation[*]. The eqnarray environment is used for displaying and automatically numbering either a single expression that spreads over several lines or multiple expressions, while taking care of alignment for us. The syntax is similar to that of the tabular and array environments, except that no argument is necessary to declare the number and justification of columns. The eqnarray* environment does this without numbering any equations.

0.1

\begin{eqnarray}
(a+b)(a+b) & = & a^2 + 2ab + b^2\\
(a+b)(a-b) & = & a^2 - b^2
\end{eqnarray}
will give


(a + b)(a + b) = a2 +2ab + b2 (1)
(a + b)(a - b) = a2 - b2 (2)

See how we identify the columns so as to line the = signs up. We can also leave entries empty, to obtain effect like the following:

\begin{eqnarray*}
\frac{d}{dx} \sin x & = & \lim_{h\rightarrow0}\frac{\sin(x+h)-\sin x}{h}\\
 & = & \lim_{h\rightarrow0}\frac{\sin x\cos h + \cos x\sinh - \sin x}{h}\\ 
 & = & \lim_{h\rightarrow0}\frac{\sin x(\cos h-1)}{h} + \cos x\frac{\sin h}{h}\\
 & = & \cos x
\end{eqnarray*}
which produces


$\displaystyle {\frac{{d}}{{dx}}}$sin x = $\displaystyle \lim_{{h \rightarrow 0}}^{}$$\displaystyle {\frac{{\sin(x+h)-\sin x}}{{h}}}$  
  = $\displaystyle \lim_{{h \rightarrow 0}}^{}$$\displaystyle {\frac{{\sin x\cos h + \cos x\sinh - \sin x}}{{h}}}$  
  = $\displaystyle \lim_{{h \rightarrow 0}}^{}$$\displaystyle \left\{\vphantom{\frac{\sin x(\cos h-1)}{h} + \cos x\frac{\sin h}{h}}\right.$$\displaystyle {\frac{{\sin x(\cos h-1)}}{{h}}}$ + cos x$\displaystyle {\frac{{\sin h}}{{h}}}$$\displaystyle \left.\vphantom{\frac{\sin x(\cos h-1)}{h} + \cos x\frac{\sin h}{h}}\right\}$  
  = cos x