# Aligning an equation [duplicate]

I have an equation like this:

$$\begin{split} |a+bi|=\sqrt{a^2+b^2}\\ |a+bi|^2=a^2+b^2\\ |a+bi|^2=(a+bi)(a+bi)\\ =(a+bi)(a-bi)\\ =a^2+b^2i^2\\ =a^2+b^2 \end{split}$$


the resualt looks like this:

How can I align this equation, that all of = symbols to be under each other

## marked as duplicate by Mico, Jesse, Bernard, jub0bs, MasroorJun 14 '14 at 11:45

• You need a & before each =. – Torbjørn T. Jun 8 '14 at 13:23

It is preferable to use the mathtools package for this task; you should use an \lvert/\rvert construction for the delimiters. With \DeclarePairedDelimiter, you can automatically scale the delimiters by using the starred version (\abs*). Also, I have created a macro for the imaginary symbol; then you can change it all the way through just by changing the definition of the marco.

\documentclass{article}

\usepackage{mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\newcommand*\imag{i} % change 'i' to '\mathrm{i}' if you want an upright 'i'

\begin{document}

\noindent No equation number:
\begin{align*}
\abs{a + b\imag}
&= \sqrt{a^{2} + b^{2}},\\
\abs{a + b\imag}^{2}
&= a^{2} + b^{2},\\
\abs{a + b\imag}^{2}
&= (a + b\imag)(a + b\imag)\\
&= (a + b\imag)(a - b\imag)\\
&= a^{2} + b^{2}\imag^{2}\\
&= a^{2} + b^{2}.
\end{align*}
A vertically centered equation number:
$$\begin{split} \abs{a + b\imag} &= \sqrt{a^{2} + b^{2}},\\ \abs{a + b\imag}^{2} &= a^{2} + b^{2},\\ \abs{a + b\imag}^{2} &= (a + b\imag)(a + b\imag)\\ &= (a + b\imag)(a - b\imag)\\ &= a^{2} + b^{2}\imag^{2}\\ &= a^{2} + b^{2}. \end{split}$$

\end{document}


Note: The fifth = is wrong; it should be a^{2} - b^{2}\imag^{2}.

• The OP has an italic “i” and I find it arbitrary using a different notation. An italic “i” for the imaginary unit is common and correct in most fields of mathematics. Using \mathit in the definition is incorrect either. – egreg Jun 10 '14 at 10:44
• @egreg Okay. How would you define \img? I'll change it according to your suggestion. – Svend Tveskæg Jun 10 '14 at 10:52
• It's either \mathrm{i} (which I totally dislike) or simply i. So \newcommand{\img}{i} or \newcommand{\img}{\mathrm{i}} – egreg Jun 10 '14 at 10:53
• Okay. I'll change it to i. – Svend Tveskæg Jun 10 '14 at 10:54
\begin{equation*}
\begin{split}
|a+bi|  &=\sqrt{a^2+b^2}\\
|a+bi|^2&=a^2+b^2\\
|a+bi|^2&=(a+bi)(a+bi)\\
&=(a+bi)(a-bi)\\
&=a^2+b^2i^2\\
&=a^2+b^2
\end{split}
\end{equation*}