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.


You can use the alignat environment from the amsmath package.

  X&={}& A&AA  &{}+{}& B&B&B &{}+{}& C&C&C \\
   &={}&  &a   &{}+{}&  &b&  &{}+{}&  &c&

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


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$}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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