1. ## underbraces inside array

Hi,

I have the following expression:

$
\begin{array}{cclclclclcl}
= & & 2^{k-2} \\
& + & 2^{k-3} & + & 2^{k-3} \\
& + & 2^{k-4} & + & 2^{k-4} & + & 2^{k-4} \\
& \vdots \\
& + & 2^1 & + & 2^1 & + & \dots & + & 2^1 \\
& + & 2^0 & + & 2^0 & + & \dots & + & 2^0 & + & 2^0 \\
\end{array}
$

It is set inside an array because of the + alignment. I would like to add underbraces under the two bottom rows, such as this:

$
$

$
$

However, I would still like to retain the vertical alignment of all the + signs in all rows, so I need to somehow put these underbraces inside the array. (Or use array inside an array, but I can't figure exactly how.)

Do you know any way to do this? Thanks!

2. Hello,

maybe this reply http://www.mathhelpforum.com/math-help/94284-post2.html helps a little bit further.

3. Originally Posted by earboth
Hello,

maybe this reply http://www.mathhelpforum.com/math-help/94284-post2.html helps a little bit further.
It doesn't

I could do the bottom brace that way, but there would still be a problem with the inner one.

Also, I could put all the stuff above the inner brace into an array and then put the brace under this array, and the whole thing would be in a bigger array with the second brace under itself, but one problem still remains - the +'s in the bottom line (which is outside the inner array, but inside the outer one) would not be aligned with the +'s in the inner array (which they are out of).

$\begin{split}
&= 2^{k-2} \\
& \quad + 2^{k-3} + 2^{k-3} \\
& \quad+ 2^{k-4} + 2^{k-4} + 2^{k-4} \\
& \quad + \underbrace{2^1 + 2^1 + \cdots + 2^1}_{k-2} \\
& \quad + \underbrace{2^0 + 2^0 + \cdots + 2^0 + 2^0}_{k-1}.
\end{split}$

¿?

5. $\begin{array}{ccl}
= & {} & 2^{k-2}\\
{} & + & 2^{k-3}\ +\ 2^{k-3}\\
{} & + & 2^{k-4}\ +\ 2^{k-4}\ +\ 2^{k-4}\\
{} & {} & \vdots\\
\end{array}$

6. Originally Posted by Krizalid

$\begin{split}
&= 2^{k-2} \\
& \quad + 2^{k-3} + 2^{k-3} \\
& \quad+ 2^{k-4} + 2^{k-4} + 2^{k-4} \\
& \quad + \underbrace{2^1 + 2^1 + \cdots + 2^1}_{k-2} \\
& \quad + \underbrace{2^0 + 2^0 + \cdots + 2^0 + 2^0}_{k-1}.
\end{split}$

¿?
Thanks, but it doesn't keep the vertical alignment of +'s, so not exactly what I needed.

Originally Posted by JaneBennet
$\begin{array}{ccl}
= & {} & 2^{k-2}\\
{} & + & 2^{k-3}\ +\ 2^{k-3}\\
{} & + & 2^{k-4}\ +\ 2^{k-4}\ +\ 2^{k-4}\\
{} & {} & \vdots\\
\end{array}$
Thanks, this looks pretty much like what I needed - but as I understand it, you just approximated the spaces to keep the alignment, so if I add/change something, I would have to approximate and change the spaces in all rows, so it is kind of unpractical if I want to use it more often. Also, I think the alignment is not 100% precise.

7. Originally Posted by johny
Thanks, this looks pretty much like what I needed - but as I understand it, you just approximated the spaces to keep the alignment, so if I add/change something, I would have to approximate and change the spaces in all rows, so it is kind of unpractical if I want to use it more often. Also, I think the alignment is not 100% precise.
If you really want 100% precise alignment then you can use TeX's \rlap and \hphantom routines to write a superscript 1 that takes up exactly the same amount of space as k–4. The input looks like this:

Code:
\begin{array}{cl}
= & \hphantom{{}+{}}  2^{k-2}\\
&{}  +  2^{k-3} + 2^{k-3}\\
&{} +  2^{k-4} + 2^{k-4} + 2^{k-4}\\
& \hphantom{{}+{}} \vdots\\
&{} +  \underbrace{2^{\rlap{$\scriptstyle1$}\hphantom{k-4}} + 2^{\rlap{$\scriptstyle1$}\hphantom{k-4}} + \ldots + 2^1}_{k-2}\vspace{.5ex}\\
&{} +  \underbrace{2^{\rlap{$\scriptstyle0$}\hphantom{k-4}} + 2^{\rlap{$\scriptstyle0$}\hphantom{k-4}} + \ldots + 2^0 + 2^0}_{k-1}
\end{array}
I can't show the complete output here, because the LaTeX string is too long for the MathHelpForum's compiler to accept. But it works nicely with the TeX program on my computer. If I leave out a couple of lines to bring it down to MathHelpForum's 400-character limit then it looks like this:

$\begin{array}{cl}
= & \hphantom{{}+{}} 2^{k-2}\\
&{} + 2^{k-4} + 2^{k-4} + 2^{k-4}\\
&{} + \underbrace{2^{\rlap{\scriptstyle1}\hphantom{k-4}} + 2^{\rlap{\scriptstyle1}\hphantom{k-4}} + \ldots + 2^1}_{k-2}\vspace{.5ex}\\
&{} + \underbrace{2^{\rlap{\scriptstyle0}\hphantom{k-4}} + 2^{\rlap{\scriptstyle0}\hphantom{k-4}} + \ldots + 2^0 + 2^0}_{k-1}
\end{array}$