## Thursday, August 6, 2009

### Aligning Equations in Latex

Let's say that you have an equation like this:

And want to align it in a pretty way, say:

or:

as opposite to the sloppy:

Then, you can use the environment split within the package amsmath, just as in the example in the box below. By the way, the sloppy way is the last bit of code in the example.

 \documentclass{article} \usepackage{amsmath}\begin{document} \begin{split} x = a + b + c \end{split} \begin{split} x = {} & a \\ + & b \\ + & c \\ \end{split} \begin{split} x = {} & a + b \\ + & c \\ \end{split} \begin{array}{l} x = a+ b \\ + c \\ \end{array}\end{document}

1. It's just a matter of personal preference or personal style, but I would probably use this code:

\begin{eqnarray}
x &=& a + b \\ \nonumber
& & + c
\end{eqnarray}

or:

\begin{eqnarray*}
x &=& a + b \\
& & + c
\end{eqnarray*}

2. You may then find useful the article about eqnarray in the Practex journal:

3. My question then Nelson is the following... things are not really ligned up nicely in your version. Is this something that is fixable? for example, the spacing is not the same on the first line and the next lines.

4. I have no idea. Gustav may know.

5. Here is something I found if you want to make it look nice. (Courtesy of: ftp://ftp.ams.org/pub/tex/doc/amsmath/short-math-guide.pdf)

\label{xx}
\begin{split}
a& =b+c-d\\