Long underbrace with exponent following

The following code results in the following output.

\documentclass{standalone}
\usepackage{amsmath}
\begin{document}
${\underbrace{\left(a^k\right)}_{\text{very long text}}}^{s}$
\end{document}


How can I get the exponent s close to the bracket?

• use mathtools and wrap the \text{...} in \mathclap – daleif Jan 6 '15 at 10:26

You can use \mathrlap from mathtools to make the exponent zero width:

\documentclass{standalone}
\usepackage{amsmath,mathtools}
\begin{document}

$\underbrace{(a^k)^{\mathrlap{s}}}_{\text{very long text}}$

\end{document}


Avoid \left( and \right) in that context. If you've read that you should always use them, then forget it: it's not true. If your editor adds them automatically, change this setting as soon as possible.

As hawk eye barbara beeton remarks, there is a small asymmetry, which may or may not be desirable.

In order to get perfect symmetry in the underbrace, we need to remove the additional space that TeX inserts when a sub/superscript is added. I'll show both version one above the other, so you can decide what'e better.

\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}

$\underbrace{(a^k)^{\mathrlap{s}}\kern-\scriptspace}_{\text{very long text}}$

$\underbrace{(a^k)^{\mathrlap{s}}}_{\text{very long text}}$

\end{document}


The \scriptspace parameter is 0.5pt, which is small but noticeable indeed.

• it's probably an illusion, but the brace appears to be positioned just a little to the right, not quite centered. – barbara beeton Jan 6 '15 at 15:22
• @barbarabeeton You always surprise me. ;-) There's \scriptspace, of course! – egreg Jan 6 '15 at 15:46