TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get certain parts in the second line of an equation to line up with certain parts in the first line. For example,


 = a + b + c

where here I am wanting the lower-case letter to line up in the middle of its three upper-case counterparts and all of the operators to align. I have tried using align in the following way:


  X&=A&AA &+ B&BB &+ C&CC \\

  &= &a &+ &b &+ &c


This results in horrible spacing. I have also tried using tabular, but the spacing is bad there also. I would like the first line to be written as it would be normally and then the second line to line up as desired.

share|improve this question
up vote 6 down vote accepted

You can use the alignat environment from the amsmath package.

  X&={}& A&AA  &{}+{}& B&B&B &{}+{}& C&C&C \\
   &={}&  &a   &{}+{}&  &b&  &{}+{}&  &c&
share|improve this answer
Beautiful, thank you very much! – clh Feb 23 '12 at 22:45

Note that the align environment uses a rcl alignment for each of the components. That's why your output seems to be bunched together in "mini-equations".

Here are a couple of options, using amsmath or not:

enter image description here

\usepackage{amsmath}% http://ctan.org/pkg/amsmath
Original using \verb|align*|:
  X&=A&AA &+ B&BB &+ C&CC \\
  &= &a &+ &b &+ &c

Using \verb|alignat*|:
  X&=AAA &&+ BBB &&+ CCC \\
  &=\cmathbox[AAA]{a} &&+ \cmathbox[BBB]{b} &&+ \cmathbox[CCC]{c}

Using \verb|array|:
    X & AAA & BBB & CCC \\[\jot]
      &  a  &  b  &  c

My alignat solution differs slightly from @IanThompson's. His would be more general if you don't want to horizontally centre the expression components. The array solution mimics the behaviour via correct spacing around the operators (relational and binary), as well as vertically between expressions (using \jot which is 3pt).

share|improve this answer
Very nice to know, thank you! – clh Feb 23 '12 at 22:46

I often resort to using \makebox[<size>]{<new text>} which uses a box as wide as <size} to place the <new text>.

To compute the <size> I use \withdof{<old text>} form the calc package. By default this will center the <new text>, but you can also specify the alignment with [l] for left, [r] for right, or [c] for center. In the second example below I left aligned the a and b, and right aligned the c for illustrative purposes (not suggesting that that looks good).

enter image description here

  X &= AAA + BBB + CCC \\
    &= \makebox[\widthof{$AAA$}]{$a$}   
     + \makebox[\widthof{$BBB$}]{$b$}   
     + \makebox[\widthof{$CCC$}]{$c$}

  X &= AAA + BBB + CCC \\
    &= \makebox[\widthof{$AAA$}][l]{$a$}   
     + \makebox[\widthof{$BBB$}][l]{$b$}   
     + \makebox[\widthof{$CCC$}][r]{$c$}
share|improve this answer
Cool, thanks a lot! – clh Feb 23 '12 at 22:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.