LaTeX align stacked summation
I am writing an elementary summation proof and would like to write that
1 + 2 + 3 + ... + n-2 + n-1 + n
+ n + n-1 + n-2 + ... + 3 + 2 + 1
= n+1 + n+1 + n+1 + ...
and so on. I want the symbols to line up so that it's easy to see the vertical addition. How do I do this in LaTeX? The align
environme开发者_如何学Cnt doesn't do so well with multiple things to align on, and creating a tabular
environment is annoying because it's not in math mode.
The array
environment is the way to go here. This solution is better in some ways than Jack Kelly's, and worse in other ways:
\begin{array}{c *{6}{c@{\hspace{6pt} + \hspace{6pt}}} c}
& 1 & 2 & 3 & \ldots & n-2 & n-1 & n \\
+ & n & n-1 & n-2 & \ldots & 3 & 2 & 1 \\
= & n+1 & n+1 & n+1 & \ldots & n+1 & n+1 & n+1
\end{array}
Two things to notice in the column specification: we use *{6}{spec}
to get six copies of a column with specification spec
. We also use @
to specify that each column separator should look like a six-point gap, a plus sign, and another gap.
More on the @
trick here.
My LaTeX is a little rusty, but here goes:
\[
\begin{array}{l r c r c r c c c r c r c r}
& 1 & + & 2 & + & 3 & + & \ldots & + & n-2 & + & n-1 & + & n \\
+ & n & + & n-1 & + & n-2 & + & \ldots & + & 3 & + & 2 & + & 1 \\
= & n+1 & + & n+1 & + & n+1 & + & \ldots & + & n+1 & + & n+1 & + & n+1\\
\end{array}
\]
精彩评论