# How to properly align an equation [duplicate]

Possible Duplicate:
Multiline equation with LHS alone on first line?

I want to put down an equation of the form A=B. Both expressions A and B are long. What I'd like is for A to be aligned at the left, drop down a line and have =B a little right of left aligned. Bonus points if you can have it so an expression A is left aligned, drop down a line and have =B a little right of left aligned, drop down a line and have =C, but have =B and =C line up.

Here is an option to get you started using a regular array environment:

\documentclass{article}
\begin{document}
$\begin{array}​​​​​​{l@{}l@{}r} ax^2 + bx + c \\ {}+ dx^{-1} + ex^{-2} + fx^{-3} & {}= gy + hy^2 & {}= iz^{-1} + jz^{-2} + kz^{-3} \\ & & {}+ lz^{-4} + mz^{-5} \end{array}$
\end{document}​​​​​


The use of {}+ and {}= is to ensure that the relations/operators are considered "binary"; that is, with an operand on either side (otherwise the spacing would be off). Also, @{} removes any inter-column spacing, allowing for managing the spacing of the operators much more easily.

Here are two solutions with amsmath (for the align and flalign environments) and mathtools (for the \mathrlap command):

\documentclass[a5paper]{article}
\usepackage{amsmath,mathtools}

\begin{document}

\begin{align}
\mathrlap{\text{a long expression}}
&= \text{another long expression} \\
&= \text{yet another one}
\end{align}

\begin{flalign}
\mathrlap{\text{a long expression}} \\
&& &= \text{another long expression} \\
&& &= \text{yet another one}
\end{flalign}

\end{document}


In the first block, with \hphantom you can indent the 2nd and 3rd lines as much as you like, and the whole thing is roughly centered.

In the second block, the first line is flush left, the others are flush right (and the = signs are aligned). In this sample the \mathrlap is not needed, but it will when the expressions are longer.

Using @Werner's example code as my starting point, here's a version that uses the multline environment of the amsmath package:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{multline*}
ax^2 + bx + c \\
{}+ dx^{-1} + ex^{-2} + fx^{-3} = gy + hy^2 = iz^{-1} + jz^{-2} + kz^{-3} \\
{}+ lz^{-4} + mz^{-5}
\end{multline*}
\end{document}​​​​​