This refers to the following sophisticated solution by @David Carlisle for applying \underbrace
to multiline expressions:
- How can I still use
\underbrace
on a single-line expression? All I get from the common use of\underbrace
with the proposed solution is
- How can I get the brace under an expression that spans only two lines with the tip of the brace below the second line's part of the brace? All I get is
- What is the most flexible approach to multiline '\underbrace' apart from obviously avoiding such notation when possible?
Here is (for convenience) David Carlisle's code with the problematic equations added:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\def\underbracex#1#2{\mathop{\vtop{\m@th\ialign{##\crcr
$\hfil\displaystyle{#2}\hfil$\crcr
\noalign{\kern3\p@\nointerlineskip}%
#1\crcr\noalign{\kern3\p@}}}}\limits}
\def\underbracea{\underbracex\upbracefilla}
\def\upbracefilla{$\m@th \setbox\z@\hbox{$\braceld$}%
\bracelu\leaders\vrule \@height\ht\z@ \@depth\z@\hfill
\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@
$}
\def\underbraceb{\underbracex\upbracefillb}
\def\upbracefillb{$\m@th \setbox\z@\hbox{$\braceld$}%
\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@
\leaders\vrule \@height\ht\z@ \@depth\z@\hfill\bracerd
\braceld\leaders\vrule \@height\ht\z@ \@depth\z@\hfill
\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@
$}
\def\underbracec{\underbracex\upbracefillc}
\def\upbracefillc{$\m@th \setbox\z@\hbox{$\braceld$}%
\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@
\leaders\vrule \@height\ht\z@ \@depth\z@\hfill
\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@
$}
\def\underbraced{\underbracex\upbracefill}
\def\upbracefill{$\m@th \setbox\z@\hbox{$\braceld$}%
\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@\vrule \@width\p@\kern\p@
\leaders\vrule \@height\ht\z@ \@depth\z@\hfill\braceru$}
\makeatother
\begin{document}
\begin{align}
\underbrace{a+b}_{=c} \\
\underbracea{d + e} \\
\underbraced{f+g}_{=h}
\end{align}
\begin{align*}
A ={}& B + \underbracea{C + D + E} \\
&\underbraceb{{} + F + G}_{=:M} \\
&\underbracec{{}+ H + I} \\
&\underbraced{{} + J + K} + L
\end{align*}
\end{document}