Aligned Equations
Keep your multi-line derivations perfectly aligned at the equals sign.
When doing algebraic derivations, you often need to write equations that span multiple lines. If you use standard display math \[ ... \], the equations will just be centered individually, resulting in a messy, jagged look.
The align environment (provided by the amsmath package) is the solution. It aligns multiple lines of math exactly where you want them—usually at the equals sign.
The Align Environment
Inside the align environment:
- Use an ampersand
&to mark the exact point of alignment (put it directly before the=sign). - Use a double backslash
\\to break the line.
\begin{align}
f(x) &= (x+1)^2 - 3 \\
&= (x^2 + 2x + 1) - 3 \\
&= x^2 + 2x - 2
\end{align}Notice that the align environment automatically places an equation number on the right side of every single line.
If you DO NOT want equation numbers, use the starred version: \begin{align*}. This is highly recommended for standard derivations where numbering every single step is excessive.
Multiple Alignments per Line
You can actually align multiple equations on the exact same line. You do this by alternating & symbols. The odd & symbols are used for alignment, and the even & symbols are used to create horizontal space between the equation columns.
\begin{align*}
x &= 2 & y &= 3 & z &= 4 \\
a &= 10 & b &= 20 & c &= 30
\end{align*}Mixing Text and Math
If you need to interject a word like "and" or "implies" between aligned equations, DO NOT just type it. Math mode will squish the letters together and italicize them.
Instead, use the \text{} command to briefly escape back to normal text formatting:
\begin{align*}
A &= \pi r^2 \\
\text{where } r &= 5
\end{align*}