LaTeX forum ⇒ Math & ScienceTo align items in several equations

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

To align items in several equations

Postby Cham » Wed May 11, 2011 5:20 pm

I need to align several items in many equations, and there's something I don't understand. Here's a very simple example :
  1. \begin{align}
  2. & a &&= x \\
  3. & b + c &&= x + y
  4. \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 :
  1. \begin{align}
  2. a &= x \\
  3. b + c &= x + y
Last edited by Cham on Wed May 11, 2011 6:03 pm, edited 1 time in total.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9601
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Wed May 11, 2011 5:31 pm

Hi Cham,

you could use an alignat environment:
  1. \begin{alignat}{2}
  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
LaTeX.org admin

User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Wed May 11, 2011 6:02 pm

Thanks for the fast reply. This solves my problem. :)

User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Wed May 11, 2011 6:08 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 :
  1. \begin{alignat}{2}
  2. & T_{j\,=\,2}^{m\,=\,0} &&= blablabla, \\ \nonumber \\
  3. & T_{j\,=\,2}^{m\,=\,\pm 1} &&= blablabla, \\ \nonumber \\
  4. & T_{j\,=\,2}^{m\,=\,\pm 2} &&= blablabla,
  5. \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 ?


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 4 guests