Math & ScienceTo align items in several equations

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

To align items in several equations

Post by Cham »

I need to align several items in many equations, and there's something I don't understand. Here's a very simple example :

Code: Select all

\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 :

Code: Select all

\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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

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

To align items in several equations

Post by Stefan Kottwitz »

Hi Cham,

you could use an alignat environment:

Code: Select all

\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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: To align items in several equations

Post by Cham »

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

To align items in several equations

Post by Cham »

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 :

Code: Select all

	\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 ?
Post Reply