## LaTeX forum ⇒ Math & Science ⇒ To align items in several equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

### To align items in several equations

I need to align several items in many equations, and there's something I don't understand. Here's a very simple example :
\begin{align}    & a &&= x \\    & b + c &&= x + y\end{align}

I want to left-align the left members ("a" and "b + c"), while still aligning the "=". The code above is working well, but there's a large ugly space at the left of the "=" sign. How can I modify that code just to remove that large gap ?

The following code looks nicer once compiled, but the left members aren't aligned :
\begin{align}    a &= x \\    b + c &= x + y
Last edited by Cham on Wed May 11, 2011 6:03 pm, edited 1 time in total.

Stefan Kottwitz
Posts: 9601
Joined: Mon Mar 10, 2008 9:44 pm
Hi Cham,

you could use an alignat environment:
\begin{alignat}{2}...

Use & for alignment and for separating the two columns.

Your second code example looks good to me. Right aligning the part left of the equal sign is very common, so it's the standard behavior of amsmath's align.

Stefan

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm
Thanks for the fast reply. This solves my problem.

Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm
Maybe there's a better way to do my stuff (?) : I'm actually writing several tensor components, each one on a separate line. The code looks like this :
	\begin{alignat}{2}		& T_{j\,=\,2}^{m\,=\,0} &&= blablabla, \\ \nonumber \\		& T_{j\,=\,2}^{m\,=\,\pm 1} &&= blablabla, \\ \nonumber \\		& T_{j\,=\,2}^{m\,=\,\pm 2} &&= blablabla,	\end{alignat}

Do you think there's a better way to do this ?

EDIT : by the way, is there a way to compile the TeX code on this forum, so we can have a compiled view of the code ? We can do this on lots of standard forums on the net. Why not here too ?