17

Why doesn't the following code align the two equations in the middle? It does only if I remove the alignment on the left.

\begin{align*}
    &ABC  &= ABC - AB\\
    &ABCD &= ABC - ABCDEFG
\end{align*}

enter image description here

2
  • Welcome to TeX.SX! An align environment is basically a sequence of rl column pairs, with a wide space between pairs.
    – egreg
    Sep 10, 2014 at 15:16
  • here's another question that addresses this problem: Multiple alignments in align environment. there are probably others. Sep 10, 2014 at 15:31

1 Answer 1

20

An align or align* environment is a set of rl column pairs, with a wide space between each pair.

You want to use alignat, which does the same, but adds no space between pairs of columns.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
&ABC  &&= ABC - AB\\
&ABCD &&= ABC - ABCDEFG
\end{alignat*}

\end{document}

enter image description here

With \begin{alignat*}{2} you allocate four columns, in the form rlrl, so you want & to get into the l column and && to get in the next l column; note that cells in l columns have an automatic {} inserted so as to give correct spacing for the relation or operation symbols.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .