# TeX double script error even though all brackets are perfectly placed

Whenever I write,

${{\dot y}^a}^\top$


I will receive a double superscript error.

But {{\dot y}^a}^\top is perfectly parsed. I don't understand why there would be an error at all. Please help!

• To get around it, use ${\dot{y}}^a{}^\top$. – Werner Feb 8 at 5:49

From the TeXbook, Chapter 26: Summary of Math Mode, page 291 (emphasis mine on the last sentence)

{<math mode material>}.  A character token of category 1, or a control sequence like \bgroup that has been \let equal to such a character token, causes TeX to start a new level of grouping and also to begin work on a new math list. When such a group ends—with }'—TeX uses the resulting math list as the nucleus of a new Ord atom that is appended to the current list. If the resulting math list is a single Acc atom, however (i.e., an accented quantity), that atom itself is appended.

The last sentence means that if the content of the braces is a single Acc atom (including sub/superscripts), then the outer braces are effectively removed.

The corresponding routine is described in §1186 of TeX (again: emphasis mine)

Therefore with {{\dot y}^a} the content of the math list is {\dot y}^a, which is an Acc atom (with superscript). The braces are thus stripped, and it's like you had written {\dot y}^a^\top, causing the double superscript error. Note that this check and possible brace stripping is performed every time a closing brace is encountered, so no nesting can help: even something like

{{{\dot{y}^a}}}^\top


with three sets of braces won't help.

The solution is to add something to the math list such that it does not contain only the Acc atom, like an empty group or a zero kern:

${{}\dot{y}^a}^\top$


Alternatively you could add the empty group just before the second superscript, as Werner pointed out in his comment. This will cause a different placing of the superscript, which might be desired or not; take your pick.

\documentclass{article}
\begin{document}
${{}\dot{y}^a}^\top$
${\dot{y}^a}{}^\top$
\end{document}
`