What is the best way to produce the following: (Image shows a typo)

What is the best way to produce the following: (Image shows a typo)

Although using a tabular environment can solve some of the alignment issues easily, I would rather opt for using the align environment from the amsmath package, as it would require less typing in the end.
Some manual manipulation of the last three lines would be necessary,
in order to get the single digit numbers 9,8 and 7 to line up properly with the double digit numbers on the top three lines. To achieve this you need to use a phantom to push them to the right.
A \phantom is a macro that does not display its contents but produces
an infinitely thin horizontal line just as wide
as the original material. This can be used to push these numbers to the right in order to get them aligned with the double digit ones on top.
We define this as a macro called \Z:
\def\Z{\hphantom{1}}
and the full code:
\documentclass[12pt]{article}
\usepackage{amsmath,array}
\def\Z{\hphantom{1}}
\begin{document}
\begin{align*}
1 + 12 &= 13\\
2 + 11 &= 13\\
3 + 10 &= 13\\
4 + \Z9 &= 13\\
5 + \Z8 &= 13\\
6 + \Z7 &= 13
\end{align*}
\end{document}
Some options are amsmath's align(or align*, without numbering):
\usepackage{amsmath}
...
\begin{align*}
1 &+& 20 &= 13
2 &+& 11 &= 13
...
\end{align*}
(I've edited the example, thanks Martin Tapankov).
or a simple tabular environment. @ expressions automatically insert what's given between the appropriate columns.
\begin{tabular}{r@{+}r@{=}r}
1 & 20 & 13 \\
2 & 11 & 13 \\
...
\end{tabular}
You might also want to include extra spacing in @ arguments (like \;, \: or \,).
Following Martin Scharrer's advice, you could also use array package for ensuring mathmode. >{$}r<{$} means: Prepend a $ sign before a right aligned column, and then append a $ sign after that. @{+} means that a + gets inserted between columns defined left and right of the @{+}.
\usepackage{array}
\begin{tabular}{>{$}r<{$}@{+}>{$}r<{$}@{=}>{$}r<{$}}
1 & 20 & 13 \\
2 & 11 & 13 \\
...
\end{tabular}
align* environment, the second column will be left-justified instead of right-justified. You'll need to add extra alignment sign after the plus sign.
– Martin Tapankov
Mar 04 '11 at 12:25
tabular answer. But you did it better than I would have! Could you explain a little more about the @ mechanism? That sounds really useful!
– Seamus
Mar 04 '11 at 12:25
array environment should be used instead of tabular. Both are using the some code internally, but array uses math-mode. In this example with only positive number it doesn't make a difference but as soon as negative sign appear it does.
– Martin Scharrer
Mar 04 '11 at 12:28
tabular to array then the >{$} <{$} are already implied. You need to put array in math-mode, e.g. put $ around it.
– Martin Scharrer
Mar 04 '11 at 13:57
Okay, let me start by saying that I do not recommend this solution! But I've just been learning a bit about catcodes and felt like trying them out. So here's a solution that allows you to type the equations as they are and typesets them as you want. The only extra typing is the \\ at the end of the lines (I tried to make the newlines into \\s but that got nasty ...)
Code (the extra equation is to show that the alignments are correct):
\documentclass{minimal}
\newenvironment{alignedeqns}{\catcode`\+4\catcode`\=4\array{r@{{}+{}}r@{{}={}}l}}{\endarray}
\begin{document}
\[
1 + 100 = 101
\]
\[
\begin{alignedeqns}
1 + 100 = 101 \\
1 + 20 = 21 \\
2 + 11 = 13 \\
3 + 10 = 13 \\
4 + 9 = 13 \\
5 + 8 = 13 \\
6 + 7 = 13
\end{alignedeqns}
\]
\end{document}
Result:

l which occurs at the end of the argument to the \array command to an r. (I agree that it should be right-aligned. I'm not sure why I chose left; maybe I felt that the equals sign would be lonely without all the 13s next to it).
– Andrew Stacey
Mar 04 '11 at 13:39
1 + 20 \neq 13... – Seamus Mar 04 '11 at 12:27