Overbrace in amsmath align environment

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


Can't believe this is missing a tikz solution. Here I have adapted the solution from Curly brace to insert something into an equation? Like an inverted underbrace.

This uses \tikzmark{} to mark the start and end points of the brace:

... &\tikzmark{StartBrace}R_L^2 + &\cdots + &b_1 &R_S^{m-1} &c_1 &R_L^{n-1}\tikzmark{EndBrace}

The names used here StartBrace and EndBrace for the endpoints are arbitrary so you can chose different names if you have multiple braces that are required. Then, after the array is completed, you pass these two names, along with any optional style changes you desire, and the text to be placed under the brace with:

 \InsertUnderBrace[draw=red,text=blue]{StartBrace}{EndBrace}{Explanation}

This yields:

enter image description here

Notes:

  • This does require two runs. First one to determine the locations, and the second to do the drawing.
  • The math spacing around the binary operators was incorrect in the code snippet that was provided. I have adjusted those as well, while maintaining your desired alignment.

References:

  • The brace is adapted from adding a large brace next to a body of text

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\newcommand*{\BraceAmplitude}{0.5em}%  Can be tweaked if
\newcommand*{\VerticalOffset}{0.5ex}%  necessary.
\newcommand*{\InsertUnderBrace}[4][]{%
    \begin{tikzpicture}[overlay,remember picture]
\draw [decoration={brace,amplitude=\BraceAmplitude},decorate, thick,draw=blue,text=black,#1]
        ($(#3)+(0,-\VerticalOffset)$) -- 
        ($(#2)+(0,-\VerticalOffset)$)
        node [below=\VerticalOffset, midway] {#4};
    \end{tikzpicture}%
}%

\begin{document}
\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} &\tikzmark{StartBrace}R_L^2 + \cdots + b_1 &&R_S^{m-1} &&c_1 &R_L^{n-1}\tikzmark{EndBrace}
\end{alignat*}
\InsertUnderBrace[draw=red,text=blue]{StartBrace}{EndBrace}{Explanation}
\end{document}

Richard: The following code has three groups of equations. The first is basically your set of expressions using the alignat structure, but with {}+{} terms instead of simple + terms to help TeX find better horizontal spacing (by treating the plus as a rel-operator). The second structure replicates the first structure but using an align* environment; note the use of \phantoms (defined in the preamble) to enforce proper columnar alignment. The third structure then demonstrates the use of \overbrace commands to add comments to the $n$ groups in the align group.

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}

\newcommand{\pa}{\phantom{{}-1}}
\newcommand{\pb}{\phantom{R_S^{1-1}}}
\newcommand{\pc}{\phantom{.-1}}
\newcommand{\pp}{\phantom{{}+{}}}
\newcommand{\pq}{\phantom{{}+}}
\begin{document}

\begin{alignat*}{16}
1 =& &&b_m     &&          &c_n {}+{} &b_m     &&          &c_{n-1} &&R_L {}+{} &b_m     &&          &c_{n-2} &R_L^2 {}+{} &\dots {}+{} &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 {}+{} &\dots {}+{} &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 {}+{} &\dots {}+{} &b_{m-2} &&R_S^2     &&c_1 &R_L^{n-1} \\
  & \phantom{c}\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 {}+{} &\dots {}+{} &b_1     &&R_S^{m-1} &&c_1 &R_L^{n-1}
\end{alignat*}

\begin{align*}
1 =  &\pp b_{m\pc}\pb     c_n +  b_{m\pc}\pb       c_{n-1} R_L  +  b_{m\pc}\pb        c_{n-2} R_L^2 + \dots + b_{m\pc}\pb        c_1 R_L^{n-1} \\
       &+ b_{m-1} R_S^{1\pc}c_n +  b_{m-1} R_S^{1\pc}c_{n-1} R_L  +  b_{m-1} R_S^{1\pc} c_{n-2} R_L^2 + \dots + b_{m-1} R_S^{1\pc} c_1 R_L^{n-1} \\
       &+ b_{m-2} R_S^{2\pc}c_n +  b_{m-2} R_S^{2\pc}c_{n-1} R_L  +  b_{m-2} R_S^{2\pc} c_{n-2} R_L^2 + \dots + b_{m-2} R_S^{2\pc} c_1 R_L^{n-1} \\
       &\pp\vdots \\
       &+ b_{1\pc}R_S^{m-1} c_n +  b_{1\pc}R_S^{m-1\phantom{.}} c_{n-1} R_L  +  b_{1\pc}R_S^{m-1}  c_{n-2} R_L^2 + \dots + b_{1\pc}R_S^{m-1}  c_1 R_L^{n-1}
\end{align*}

\begin{align*}
1 =  &\pq \overbrace{b_{m\pc}\pb     c_n}^{\text{First Group}} {}+ \overbrace{b_{m\pc}\pb       c_{n-1} R_L}^{\text{Second Group}} {}+ \overbrace{b_{m\pc}\pb c_{n-2} R_L^2}^{\text{Third Group}} {}+ \dots + \overbrace{b_{m\pc}\pb        c_1 R_L^{n-1}}^{\text{$n$-th Group}} \\[1ex]
       &+ b_{m-1} R_S^{1\pc}c_n +  b_{m-1} R_S^{1\pc}c_{n-1} R_L  +    b_{m-1} R_S^{1\pc} c_{n-2} R_L^2 + \dots + b_{m-1} R_S^{1\pc} c_1 R_L^{n-1} \\[2ex]
       &+ b_{m-2} R_S^{2\pc}c_n +  b_{m-2} R_S^{2\pc}c_{n-1} R_L  + b_{m-2} R_S^{2\pc} c_{n-2} R_L^2 + \dots + b_{m-2} R_S^{2\pc} c_1 R_L^{n-1} \\
       &\pp\vdots \\[2ex]
       &+ b_{1\pc}R_S^{m-1} c_n +  b_{1\pc}R_S^{m-1\phantom{.}} c_{n-1} R_L  +  b_{1\pc}R_S^{m-1}  c_{n-2} R_L^2 + \dots + b_{1\pc}R_S^{m-1}  c_1 R_L^{n-1}
\end{align*}
\end{document}

Different equation styles

Tags:

Align

Amsmath