2

This very helpful answer

https://tex.stackexchange.com/a/582444/239563

describes a way to avoid a double superscript error by including an empty group:

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

My question is: is there any danger in always including an empty group whenever some "accent" like \dot or \bar is used? Are there cases where this has undesirable consequences in a different situation?

(I'm asking because in my case, the LaTeX code is automatically generated, and either my code does it, or the user has to take care of it by using a special instruction of my program.)

Thanks a lot for your help!

David Carlisle
  • 757,742
Ralf
  • 185
  • could you define "always" eg in $\dot{y}+\dot{x}$ where would you add empty groups? (in the example you add the {} within a group holding a superscript) – David Carlisle Oct 08 '21 at 06:58

1 Answers1

2

The group is essentially forcing an extra math node wrapper which is acting like a box and will affect positioning in various ways, arguably not for the better. For example it avoids a double superscript error by moving the superscript to the outer node but it also does the same for a subscript which would have been placed (and kerned) on the inner character node.

enter image description here

\documentclass{article}

\begin{document}

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

${\dot{y}^a}_1$ \end{document}

Maintaining the tightly kerned subscript is presumably why TeX unwinds the mathaccent construct to expose the character node in the first place.

Although it depends slightly on where you are proposing to "always" add the {} this form with {} does produce the close subscript.

enter image description here

\documentclass{article}

\begin{document}

${{}\dot{y}^a_1}$ \end{document}

David Carlisle
  • 757,742
  • Very helpful answer, thanks a lot. I turns out the placement of the {} is really the problem in my code, which makes a solution more complex. – Ralf Oct 08 '21 at 07:30