# Overbrace and superscripts

Using pdflatex, the command

$e^{a\overbrace{+b+c}}$


results in a bigger size font of the part +b+c under the brace. If I do:

$e^{a\overbrace{\scriptstyle +b+c}}$


the size of +b+c is fixed but the size of the brace is still wrong: the brace has the same size than before but, since the interior font is now smaller, white spaces appear.

Can we fix this?

NOTE: This question can be considered a duplicated of Underbrace and Subscripts. However, the solutions in that question do not tackle the brace size problem. I don't have enough repuation to add this as a comment there and I don't think it is a good idea to add an answer that is rather a question.

NOTE2: Using mathtools does not change the problem.

• I wonder why you need an overbrace in a superscript in the first place. I would certainly look for other ways how to express yourself. I'm 111% sure they will be better.
– yo'
Oct 22 '15 at 17:21
• @yo' I think that I needed this from the moment that I couldn't do it, of course. Anyway, I'm pretty sure that users can always surprise with their needs and developers should avoid to underestimate them. Oct 22 '15 at 18:10
• I don't speak about the "developers" side, this can be done, as egreg shows. I just mean, that a reader of a piece of text that uses this notation to make things clear will only be confused by this. You said it's for a beamer talk -- why don't you use colours, and bubbles or arrows or something like this to show what you need to show? It's much easier to say "and now you see that the blue guys cancel and only 12345 is left" than to make talk listeners try to understand what the overbrace means.
– yo'
Oct 22 '15 at 18:38
• OK, I understand what you mean and I appreciate the advice. Oct 22 '15 at 19:46

\documentclass{article}
\usepackage{amsmath}

\newcommand{\supsuboverbrace}[2][]{%
{\everymath{\scriptstyle}%
\overbrace{\scriptstyle#2}^{#1}}%
}

\begin{document}

$e^{a{\overbrace{\scriptstyle+b+c}^{d}}} \qquad e^{a\supsuboverbrace[d]{+b+c}}$

\end{document}


• Thank you. I realice that the space problem is worse in my current beamer presentation than in your article example. Anyway, with this solution it improves a lot, and is enough for me. Oct 22 '15 at 18:07

Here I introduce \Obrace[overset]{quantity}. It automatically takes the overset to the next lower math size. Also, one can specify the brace "size" with \bracesize, defaulting to \scriptsize, and temporarily set to \tiny for the last two examples.

\documentclass{article}
\usepackage{amsmath,stackengine,scalerel}
\def\bracesize{\scriptsize}
\newcommand\Obrace[2][]{\ThisStyle{\setbox0=\hbox{$\SavedStyle#2$}%
\stackon[3\LMpt]{\stackon[2pt]{$\SavedStyle#2$}{\makebox[%
\dimexpr\wd0-1\LMpt]%
{\bracesize\downbracefill}}}{$\SavedStyle_{#1}$}}%
}
\begin{document}
$a\Obrace{{}+b+c}$

$a\Obrace[x]{{}+b+c}$

{\def\bracesize{\tiny}
$e^{a\Obrace{+b+c}}$

$e^{a\Obrace[x]{+b+c}}$}
\end{document}