[Tex/LaTex] Overbrace Inside Underbrace

bracketsmath-mode

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

    \begin{equation}
    \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\}.
    \end{equation}

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

enter image description here

Best Answer

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).

enter image description here

\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}