How to make outer (following closing parenthesis) exponent same height level as inner (inside parentheses) exponent?

I need outer exponent n to start at same height level as inner exponent m.

\documentclass[border=1mm]{standalone}
\usepackage[alignedleftspaceno]{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path node[draw]
{%
$% \begin{gathered} \left(a^{m}\right)^{n} \end{gathered}$
};
\end{tikzpicture}
\end{document}


• This clearly shows why always using \left and \right is bad. Not the only reason. Dec 2, 2017 at 11:23

The vertical postion of a superscript depends on the height of the nucleus.

You can use \vphantom{a} to create an invisible math atom with a nucleus of the desired height but no width.

That gives the desired vertical alignment, but also introduces an undesired horizontal space between the closing bracket and the superscript. As \showlists (see The TeXbook page 158) shows, \left(a^{m}\right) is an inner atom and the vphantom is an ordinary atom. The space inserted between an inner atom and an ordinary atom (in non-script styles) is according to the table on page 170 in The TeXbook a thin space. Therefore we can neutralize this space with one negative thin space \! (see page 167).

\documentclass[border=1mm]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path node[draw]
{%
$% \begin{gathered} \left( a^{m} \right) \!{\vphantom{a}} ^{n} \end{gathered}$
};
\end{tikzpicture}
\end{document}


EDIT: Please note the braces around the \vphantom. Without them the \vphantom seems to have no effect.

• My tests show that just the negative thin space is enough - no need for vphantom. As I'm relatively new to Latex I may be missing some subtlety (maybe of a more general case than the example) and I'd appreciate understanding what that may be. Nov 30, 2017 at 14:20
• @StephenG you are right. Even when I replace the lower case a with an upper case A it still seems to be on the same vertical position. Maybe my claim that the position of the superscript depends on the height of the nucleus was wrong. I'll try to find the time to read that up in The TeXbook. Thank you for pointing that out. Dec 1, 2017 at 7:25
• @bp2017 sorry, I did not have the time to look at the question up to now, but it seems there are enough answers by now. Dec 2, 2017 at 7:22
• @StephenG it seems that TeX's parameters are set up in a way that the superscript is on the same vertical position for most "normal" symbols used in the nucleus. If the height of the nucleus was bigger (for example because it contained a \sum) a superscript directly following the \! would be too low. The exact rules how TeX typesets math lists are explained in Appendix G of The TeXbook, see rules 18a and 18c on page 445. Dec 2, 2017 at 11:23

for your simple math expression it is sufficient:

\documentclass[border=1mm]{standalone}
\usepackage[alignedleftspaceno]{amsmath}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path node[draw]{$(a^{m})^{n}$};
\end{tikzpicture}
\end{document}


the position of exponents are adopted to height of variable or math operators. with \right) you made closing parenthesis higher, consequently exponent m is accordingly move higher as at simple ).