Overbrace Inside Underbrace

I would like to have an overbrace inside an underbrace (not overlapping braces). Here is an equation I have been trying:

    $$\max_{a \in A} \left\{\underbrace{ \left(v_a + v_y y \right) a - C(a)}_{\text{blabla}} \mathrlap{\overbrace{\phantom{v_y y ) a - C(a)}}^{\text{blablabla}}} + \mu_a \mathbb{E}(v_a | a, y) - \mu_y \mathbb{E}(v_y|a,y)\right\}.$$


So far, I am obtaining an overbrace shifted far to the right:

• As always on this site, please provide a full minimal example. Not everyone know that \mathclap comes from mathtools Oct 7 '15 at 10:38
• And what exactly is the overbrace suppose to cover? a-C(a)? Oct 7 '15 at 10:41
• then just use \underbrace{ ... \overbrace{...}^{A}}_{B} just tested, works just fine. Oct 7 '15 at 10:54

Here's a solution that gets by without \mathrlap. Note also the declaration of \E as a "math operator", the use of \mid instead of | (in order to obtain some whitespace on both sides of the vertical bars), and the use of \biggl\{ and \biggr\} instead of \left\{ and \right\} (to avoid getting unnecessarily large curly braces).

\documentclass{beamer}
\usepackage{amsmath,amsfonts}
\DeclareMathOperator{\E}{\mathbb{E}}

\begin{document}
\begin{frame}

$\max_{a \in A} \biggl\{ \underbrace{ ( v_a + \overbrace{v_y y ) a - C(a)}^{ \text{blabla}}}_{\text{blabla}} {} + \mu_a \E(v_a \mid a, y) - \mu_y \E(v_y\mid a,y) \biggr\}$

\end{frame}
\end{document}

• Is is just me, or is the spacing around the + after the \underbrace wrong/missing? Oct 7 '15 at 11:21
• @daleif - Good catch! I'll modify the code to insert {} before + in order to change its type from unary to binary operator.
– Mico
Oct 7 '15 at 11:29
• Egreg recommends adding a brace around the whole thing instead. \underbrace is an Op atom. Oct 7 '15 at 11:55
• @daleif - egreg's recommendation is certainly sound in general. In the present case, though, the term immediately before the + symbol is rather dominant visually, as it ends with an overbrace, a parenthesis, and and an underbrace. Using the {}-before+ approach provides just a teeny bit more whitespace ahead of the + symbol, letting the entire equation look a bit more balanced. :-)
– Mico
Oct 7 '15 at 12:52

After a while, I got it:

    $$\max_{a \in A} \left\{ \underbrace{ (v_a + \mathrlap{\overbrace{\phantom{v_y y ) a - C(a)}}^{\text{blablabla}}} v_y y ) a - C(a)}_{\text{blabla}} + \mu_a \mathbb{E}(v_a | a, y) - \mu_y \mathbb{E}(v_y|a,y)\right\}.$$