# MathJax for integer summation proof

I have this

$$\begin{array}{r} sum &= 1 + 2 + \ldots + (n - 1) + n \\[1ex] + \; sum &= n + (n-1) + \ldots + 2 + 1 \\ \hline 2\,sum &= (n +1) + (n+1) + \ldots + (n+1) + (n+1) \end{array}$$

for displaying the Gauss trick for summing integers proof, but the alignment is not great. Any suggestions on how to improve this?

• You have not aligned the right-hand column. If you align it to the left then it will align to the equals sign. Use \begin{array}{rl}. If you also want to align the plus signs then you can use the array to do this manually, by putting each plus sign and each number in its own cell. – user1729 Feb 11 at 17:49
• (incidentally, I would have used the align environment for what you wrote, rather than array: \begin{align*}sum&=1+2+\ldots+(n-1)+n\\...\\ \hline 2sum&=...\end{align*}. I would use array to align the plus signs, but that may not be good LaTeX practice...) – user1729 Feb 11 at 17:54

$$\begin{array}{rrcccccccccc} &\text{sum}&=&1&+&2&+&\dots&+&(n-1)&+&n\\ +&\text{sum}&=&n&+&(n-1)&+&\dots&+&2&+&1\\ \hline &2\;\text{sum}&=&(n+1)&+&(n+1)&+&\dots&+&(n+1)&+&(n+1) \end{array}$$
$$\begin{array}{rrcccccccccc} &\text{sum}&=&1&+&2&+&\dots&+&(n-1)&+&n\\ +&\text{sum}&=&n&+&(n-1)&+&\dots&+&2&+&1\\ \hline &2\;\text{sum}&=&(n+1)&+&(n+1)&+&\dots&+&(n+1)&+&(n+1) \end{array}$$