[Tex/LaTex] Overbrace in amsmath align environment

alignamsmath

I have the following rather large equation.

\begin{alignat*}{16}
1 &= &&b_m     &&          &c_n + &b_m     &&          &c_{n-1} &&R_L + &b_m     &&          &c_{n-2} &R_L^2 + &\cdots + &b_m     &&          &&c_1 &R_L^{n-1} \\
  &+ &&b_{m-1} &&R_S^1     &c_n + &b_{m-1} &&R_S^1     &c_{n-1} &&R_L + &b_{m-1} &&R_S^1     &c_{n-2} &R_L^2 + &\cdots + &b_{m-1} &&R_S^1     &&c_1 &R_L^{n-1} \\
  &+ &&b_{m-2} &&R_S^2     &c_n + &b_{m-2} &&R_S^2     &c_{n-1} &&R_L + &b_{m-2} &&R_S^2     &c_{n-2} &R_L^2 + &\cdots + &b_{m-2} &&R_S^2     &&c_1 &R_L^{n-1} \\
  &  &&        &&          &      &        &&          &        &&      & \vdots \\
  &+ &&b_1     &&R_S^{m-1} &c_n + &b_1     &&R_S^{m-1} &c_{n-1} &&R_L + &b_1     &&R_S^{m-1} &c_{n-2} &R_L^2 + &\cdots + &b_1     &&R_S^{m-1} &&c_1 &R_L^{n-1}
\end{alignat*}

I would like to use overbraces and underbraces to break things down, such as by using:

&+ &&b_1     &&R_S^{m-1} &c_n + &b_1     &&R_S^{m-1} &c_{n-1} &&R_L + &b_1     &&R_S^{m-1} &c_{n-2} &R_L^2 + &\cdots + \underbrace{&b_1     &&R_S^{m-1} &&c_1 &R_L^{n-1}}_{Explanation}

However, the align environment doesn't seem to like this; perhaps because alignment symbols get tucked inside of the underbrace call.

Is it possible to both align and over/underbrace my equation?

Best Answer

Here is a solution using the array package. It is not ideal as you have to specify the width that the brace is supposed to span. There is a method to span columns using \extracolsep{\fill}, but I was not able to figure out where to place that so that the \hphantom span the entire column. But hopefully, this gets you going:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\newcolumntype{L}{l@{}}%

\begin{document}
\newcommand*{\WidthToSpan}{{R_L^2}{+}{\cdots +}b_{m-2} R_S^{m-1} c_1 R_L^{n-1}}%
\[
\begin{array}{LLLLLLLLLLLLLLLLLL}
1 &= &b_m     &          &c_n + &b_m     &          &c_{n-1} &R_L + &b_m     &          &c_{n-2} &R_L^2 + &\cdots + &b_m     &          &c_1 &R_L^{n-1} \\
  &+ &b_{m-1} &R_S^1     &c_n + &b_{m-1} &R_S^1     &c_{n-1} &R_L + &b_{m-1} &R_S^1     &c_{n-2} &R_L^2 + &\cdots + &b_{m-1} &R_S^1     &c_1 &R_L^{n-1} \\
  &+ &b_{m-2} &R_S^2     &c_n + &b_{m-2} &R_S^2     &c_{n-1} &R_L + &b_{m-2} &R_S^2     &c_{n-2} &R_L^2 + &\cdots + &b_{m-2} &R_S^2     &c_1 &R_L^{n-1} \\
  &  &        &          &      &        &          &        &      & \vdots \\
  &+ &b_1     &R_S^{m-1} &c_n + &b_1     &R_S^{m-1} &c_{n-1} &R_L + &b_1     &R_S^{m-1} &c_{n-2} &R_L^2 + &\cdots + &b_1     &R_S^{m-1} &c_1 &R_L^{n-1}\\
  &  &     & & & & & & & &  &  & \multicolumn{6}{@{}c}{\underbrace{\hphantom{\WidthToSpan}}_{\text{Explanation}}}
\end{array}
\]
\end{document}

enter image description here

Related Question