I can get latex to do most of what I want, but not everything.
I am trying to write multiple equations where each term in each equation is aligned. On the last equation line, I'd like to put an \underbrace under the entire right-hand side of the equation. I can't seem to figure out how to do both at the same time.
\begin{array}{rlrrrrrrrrrrr}
S &=& 1 &+& 2 &+& 3 &+& \cdots &+& 99 &+& 100 \\
S &=& 100 &+& 99 &+& 98 &+& \cdots &+& 2 &+& 1 \\
\hline
S + S &=& 101 &+& 101 &+& 101 &+& \cdots &+& 101 &+& 101
\end{array}
$$
\begin{alignat*}{0}
S &= 1 + 2 + 3 + \cdots + 99 + 100 \\
S &= 100 + 99 + 98 + \cdots + 2 + 1 \\
\cline{2-1}
S + S &= \underbrace{101 + 101 + 101 + \cdots + 101 + 101}_{\text{100 groups}} \\
\end{alignat*}
The top version aligns the terms in the sum to the right of the =, but if I try to use \underbrace underneath more than one array element in the last line, the compiler complains. If I wrap the whole array in an \underbrace, the brace spans the entire equation line, not just the right-hand side.
The bottom version puts the underbrace in the correct place, but I can't get the terms in each equation to line up the way I want.
Is there any way to convince LaTeX to let me do both at the same time? I've attached a picture to show what's going on, but Stack Overflow won't let me embed yet.
