This question led to a new package:
underoverlap
I've been using the \overunderbrace macro provided in this answer. It works fine for simple examples, but since the original definition uses \vcenter, vertical alignment is not correct when the axis of the 'content' is not aligned to its vertical center. For example, to get proper alignment in the following formula, I had to do some manual tweaking with \raisebox. Not ideal.

I'm trying to perfect the macro; perhaps write a small package. (There are several extensions possible, e.g., \underoverbrace, custom vertical spacing, custom brace-command (\underoverline), etc.)
Question: Rather than 'naively' using \vcenter, is there a way to raise/lower the whole structure the exact amount needed to align its axis with the axis of the 'content' (which is a row in a \halign)?
Several possible solutions come to mind:
- The simplest (for me) would be to add two optional arguments to the macro for the content before and after the bracing. I could then put them in the 'content row'. But I'd rather not have to.
- If I have to, I can probably measure the segments and calculate the correct amount to raise/lower.
I'm just hoping there's a simpler solution I'm not yet aware of.
Edit: Here's a simple MWE of the misalignment, based on the example of the original answer:
\documentclass{article}
\makeatletter
\def\overunderbrace#1#2#3{%
\begingroup
\let\overunderbrace@sup\empty
\let\overunderbrace@sub\empty
\@ifnextchar^%
{\@overunderbracesup{#1}{#2}{#3}}%
{\@ifnextchar_%
{\@overunderbracesub{#1}{#2}{#3}}%
{\@overunderbrace{#1}{#2}{#3}}%
}%
}
\def\@overunderbracesup#1#2#3^#4{%
\def\overunderbrace@sup{#4}%
\@ifnextchar_%
{\@overunderbracesub{#1}{#2}{#3}}%
{\@overunderbrace{#1}{#2}{#3}}%
}
\def\@overunderbracesub#1#2#3_#4{%
\def\overunderbrace@sub{#4}%
\@ifnextchar^%
{\@overunderbracesup{#1}{#2}{#3}}%
{\@overunderbrace{#1}{#2}{#3}}%
}
\def\@overunderbrace#1#2#3{%
\mathop {\vcenter {\m@th \ialign {##&##&##\crcr
\noalign {\kern 3\p@}%
\span\omit\hfil\hbox{\vbox to 0pt{\vss\hbox{\vbox{\hbox{$\m@th\scriptstyle\overunderbrace@sup$}\vspace{0pt}}}}}\hfil
&%
\crcr \noalign {\kern 5\p@\nointerlineskip}%
\span\omit\downbracefill&%
\crcr \noalign {\kern 3\p@\nointerlineskip}%
$\hfil \displaystyle {#1}\hfil $&%
$\hfil \displaystyle {#2}\hfil $&%
$\hfil \displaystyle {#3}\hfil $%
\crcr \noalign {\kern 3\p@\nointerlineskip}%
& \span\omit \upbracefill
\crcr \noalign {\kern 5\p@\nointerlineskip}%
&\span\omit\hfil\hbox{\vbox to 0pt{\hbox{\vbox{\vspace{0pt}\hbox{$\m@th\scriptstyle\overunderbrace@sub$}}}\vss}}\hfil
\crcr \noalign {\kern 3\p@ }%
}}}%
\endgroup
}
\makeatother
\begin{document}
$$
a+b+
\overunderbrace
{c+\mathord{\mathop{\Sigma}_d} + \mathord{}}
{e+f+g}
{\mathord{}+h+i}^{x}_{y}
= e^2
$$
\end{document}



\Sigmasubscript sticking out, which is the cause of the misalignment. – mhelvens Jan 29 '13 at 00:34