Thanks in advance,
Dmitry Pechyony
the above does of course not work because of the line breaks.
Here is a proof of concept showing that it could be done
\documentclass{article}
\usepackage{mathtools} % auto loads amsmath
\begin{document}
\begin{equation}
\begin{split}
a &= b +c +g +r_q \\
&\quad \underbrace{
\mathmakebox[\widthof{$\displaystyle b +c +g +r_q$}][l]{
+ x+y}}_{xxx}
\end{split}
\end{equation}
\end{document}
It not optimized at all, just showing that it can be done
--
/daleif (remove RTFSIGNATURE from email address)
LaTeX FAQ: http://www.tex.ac.uk/faq
Superb Class: http://www.ctan.org/tex-archive/help/Catalogue/entries/memoir.html
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal working examples.
I don't understand. One can define \underbraceleft, \underbraceright
(even \underbracemiddle) macros. But where put your _{xxx} (first
line, second one, split, other)?
Jean-Côme Charpentier
Such a design would seem to be confusing at best and misleading at
worst (and probably hideous to look at). I wouldn't even try to
implement it, but rather would find some other way to label/describe
that group of items.
Can you point to an existing book or article that uses something like
that?
Dan
I'm agree with you but the challenge was funny (even the result is
horrible) :-)
\documentclass{article}
\makeatletter
\newcommand*\Lupbracefill{%
$\m@th
\setbox\z@ \hbox{$\braceld$}%
\bracelu
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
$%
}
\newcommand*\LMupbracefill{%
$\m@th
\setbox\z@ \hbox{$\braceld$}%
\bracelu
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
\bracerd
\braceld
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
$%
}
\newcommand*\Mupbracefill{%
$\m@th
\setbox\z@ \hbox{$\braceld$}%
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
\bracerd
\braceld
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
$%
}
\newcommand*\MRupbracefill{%
$\m@th
\setbox\z@ \hbox{$\braceld$}%
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
\bracerd
\braceld
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
\braceru
$%
}
\newcommand*\Rupbracefill{%
$\m@th
\setbox\z@ \hbox{$\braceld$}%
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
\braceru
$%
}
\newcommand*\Eupbracefill{%
$\m@th
\setbox\z@ \hbox{$\braceld$}%
\leaders \vrule \@height \ht\z@ \@depth \z@ \hfill
$%
}
\newcommand*\Allunderbrace[2]{%
\mathop{%
\vtop {%
\m@th
\ialign{%
##\crcr $\hfil \displaystyle {#2}\hfil$\crcr
\noalign{\kern 3\p@ \nointerlineskip}%
#1 \crcr
\noalign{\kern 3\p@}%
}%
}%
}\limits
}
\newcommand*\Lunderbrace{%
\Allunderbrace\Lupbracefill
}
\newcommand*\LMunderbrace{%
\Allunderbrace\LMupbracefill
}
\newcommand*\Munderbrace{%
\Allunderbrace\Mupbracefill
}
\newcommand*\MRunderbrace{%
\Allunderbrace\MRupbracefill
}
\newcommand*\Runderbrace{%
\Allunderbrace\Rupbracefill
}
\newcommand*\Eunderbrace{%
\Allunderbrace\Eupbracefill
}
\newcommand*\splitunderbrace[1]{%
\def\splitformula{#1}%
\@ifnextchar_{\split@underbrace}{\split@@underbrace}
}
\newif\ifsub
\def\split@underbrace_#1{%
\def\splitsub{#1}%
\subtrue
\split@@@underbrace
}
\def\split@@underbrace{%
\subfalse
\split@@@underbrace
}
\newcommand\split@@@underbrace{%
\count@=0
%% count@ = nb lines
\expandafter\SU@countbs\splitformula \\\@nil
\ifcase\count@
% impossible
\or
\ifsub
\underbrace{\splitformula}_{\splitsub}%
\else
\underbrace{\splitformula}%
\fi
\or
% 2
\setbox0=\hbox{$\displaystyle\@nameuse{SF@0}\phantom{\braceld}$}%
\setbox1=\hbox{$\displaystyle\@nameuse{SF@1}\phantom{\braceld}$}%
\ifdim\wd0>\wd1
\ifsub
\LMunderbrace{\box0}_{\splitsub}\\
\Runderbrace{\box1}%
\else
\Lunderbrace{\box0}\\
\MRunderbrace{\box1}%
\fi
\else
\ifsub
\else
\fi
\fi
\else
% >=3
\@tempcnta=\count@
\divide\@tempcnta \tw@
\ifodd\count@
% nb line is odd (one middle)
\advance\count@ \m@ne
% very left part
\setbox0=\hbox{$\displaystyle\@nameuse{SF@0}\phantom{\braceld}$}%
\Lunderbrace{\box0}\\
\@tempcntb=\@ne
% left parts
\loop
\ifnum\@tempcntb<\@tempcnta
\setbox0=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\advance\@tempcntb \@ne
\Eunderbrace{\box0}\\
\repeat
\setbox0=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\advance\@tempcntb \@ne
\ifsub
\Munderbrace{\box0}_{\splitsub}\\
\else
\Munderbrace{\box0}\\
\fi
\loop
\ifnum\@tempcntb<\count@
\setbox0=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\advance\@tempcntb \@ne
\Eunderbrace{\box0}\\
\repeat
\setbox0=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\Runderbrace{\box0}\\
\else
%nb line is even (two middles)
\advance\count@ \m@ne
\advance\@tempcnta \m@ne
% very left part
\setbox0=\hbox{$\displaystyle\@nameuse{SF@0}\phantom{\braceld}$}%
\Lunderbrace{\box0}\\
\@tempcntb=\@ne
% left parts
\loop
\ifnum\@tempcntb<\@tempcnta
\setbox0=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\advance\@tempcntb \@ne
\Eunderbrace{\box0}\\
\repeat
\setbox0=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\advance\@tempcntb \@ne
\setbox1=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\advance\@tempcntb \@ne
\ifdim\wd0>\wd1
\ifsub
\Munderbrace{\box0}_{\splitsub}\\
\else
\Munderbrace{\box0}\\
\fi
\Eunderbrace{\box1}\\
\else
\Eunderbrace{\box0}\\
\ifsub
\Munderbrace{\box1}_{\splitsub}\\
\else
\Munderbrace{\box1}\\
\fi
\fi
\loop
\ifnum\@tempcntb<\count@
\setbox0=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\advance\@tempcntb \@ne
\Eunderbrace{\box0}\\
\repeat
\setbox0=\hbox{%
$\displaystyle\@nameuse{SF@\the\@tempcntb}\phantom{\braceld}$%
}%
\Runderbrace{\box0}\\
\fi
\fi
}
\def\SU@countbs#1\\#2\@nil{%
\@namedef{SF@\the\count@}{$#1$}%
\def\SU@arg{#2}%
\advance\count@ \@ne
\ifx\empty\SU@arg
\let\next\@gobble
\else
\let\next\SU@countbs
\fi
\expandafter\next\SU@arg\@nil
}
\makeatother
\begin{document}
\parindent=0pt
$\splitunderbrace{a+b+c+d}_{xxx}$\par\bigskip
$\splitunderbrace{a+b+c+d+\\e+f+g+h}_{xxx}$\par\bigskip
$\splitunderbrace{a+b+c+d+\\e+f+g+h+\\i+j+k+l}_{xxx}$\par\bigskip
$\splitunderbrace{a+b+c+d+\\e+f+\\g+h+i+j+k+l+
\\m+n+o+p}_{xxx}$\par\bigskip
$\splitunderbrace{a+b+c+d+\\e+f+g+h+i+j+\\k+l+
\\m+n+o+p}_{xxx}$\par\bigskip
$\splitunderbrace{a+b+c+d+\\e+f+g+h+\\i+j+k+l+
\\m+n+o+p+\\q+r+s+t}_{xxx}$\par\bigskip
$\splitunderbrace{a+b+c+d+\\e+f+g+h+\\i+j+k+l+
\\m+n+o+p+\\q+r+s+t+\\u+v+w+x}_{xxx}$\par\bigskip
\end{document}