# Align numbers with each other

In using the align* environment, how can I get specific numbers to align with each other?

In the following example, I want each term of the top sum and the bottom sum to be aligned with each other:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
2S &= 1 &+ 2 &+ 3 &+ \ldots &+ (N-2) &+ (N-1) &+ N \\
&= N &+ (N-1) &+ (N-2) &+ \ldots &+ 3 &+ 2 &+ 1
\end{align*}
\end{document}


Currently, this looks ugly:

-
An array should be better. –  egreg Dec 25 '13 at 17:42

A simple array with some tweaks:

\documentclass{article}
\usepackage{amsmath,array}
\begin{document}
$\begin{array}{@{}r<{{}}@{}c*{6}{@{}>{{}}c<{{}}@{}c}@{}} 2S = & 1 & + & 2 & + & 3 & + & \cdots & + & (N-2) & + & (N-1) & + & N \\ {} + & N & + & (N-1) & + & (N-2) & + & \cdots & + & 3 & + & 2 & + & 1 \end{array}$
\end{document}


If you want to align the numbers to the minus signs, add new columns.

\documentclass{article}
\usepackage{amsmath,array}
\begin{document}
$\begin{array}{@{}r<{{}}*{21}{@{}>{{}}c<{{}}}@{}} 2S = & 1 &+& & 2 & &+& & 3 & &+& \cdots &+& (N & - & 2) &+& (N & - & 1) &+& N \\ {} + & N &+& (N & - & 1) &+& (N & - & 2) &+& \cdots &+& & 3 & &+& & 2 & &+& 1 \end{array}$
\end{document}


I also fixed the math.

-

Using the under-development tabstackengine, introduced at Writing a table with equally spaced columns, based on the widest column (sty file found at Measuring align), the process is straightforward:

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\renewcommand\stackalignment{l}
\begin{document}
\tabbedLongstack{%
2S &= 1 &+ 2 &+ 3 &+ \ldots &+ (N-2) &+ (N-1) &+ N \\
&= N &+ (N-1) &+ (N-2) &+ \ldots &+ 3 &+ 2 &+ 1}
\end{document}


OR, as the OP requests, a slightly different look:

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\begin{document}
\tabbedLongstack{%
2S &=& 1 &+& 2 &+& 3 &+& \ldots &+& (N-2) &+& (N-1) &+& N \\
&=& N &+& (N-1) &+& (N-2) &+& \ldots &+& 3 &+& 2 &+& 1}
\end{document}


-
Might this look better of the 2s were centered relative to the (N-1)s, and similarly for the 3s and the (N_2)s? –  jamaicanworm Dec 25 '13 at 17:59
@jamaicanworm Please see revision. –  Steven B. Segletes Dec 25 '13 at 18:02