Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have to underbrace multiple lines in an align-environment with one brace. Meaning something like

\begin{align*}
 A ={}& B + \underbracemultiline{C + D + E \\
      & + F + G \\
      & + H + I \\
      & + J + K}_{=:M} + L
\end{align*}

results in (a nice version of)
http://www.phoenixes.de/Bsp.png
Another possible syntax would be

\begin{align*}
 A ={}& B + \under{brace}{line}{dots}{C + D + E} \\
      & \under{dots}{brace}{dots}{+ F + G}_{=:M} \\
      & \under{dots}{line}{dots}{+ H + I} \\
      & \under{dots}{line}{brace}{+ J + K} + L
\end{align*}

where the macro

\under{begin}{middle}{end}{What to under"line"}

is as needed for the example. How can I do this?

Thx

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

\underbrace is constructed from bits so you just need to copy its definition using different bits each time:

enter image description here

\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*}
 A ={}& B + \underbracea{C + D + E} \\
      &\underbraceb{{} + F + G}_{=:M} \\
      &\underbracec{{}+ H + I} \\
      &\underbraced{{} + J + K} + L
\end{align*}

\end{document}
share|improve this answer
    
Perfect thanks! –  Elgrimm Mar 26 '13 at 16:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.