# \dot over \vec over : amsmath bug/feature?

I was trying to typeset the time derivative of \vec{r}_\alpha, and naively, I put it as an argument to \dot. This does not work: the arrow is not on r anymore. Here is a minimal example:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\dot{\vec{r}_\alpha}$
\end{document}


Note that there is a better way to typeset it (and it works): \dot{\vec{r}}_\alpha. I am asking out of curiosity.

-
I'd use all sorts of "beautifiers" (\dot, \hat, etc.) only on the main symbol (in your case, "r") and not on the whole object (r_\alpha). Unless the \dot is e.g. absolute time derivative, or a similar operator that is to be applied on the whole term. –  Martin Tapankov Jan 25 '11 at 13:14
from physical view it is wrong to have the dot over r and alpha. It should only be over the r, the reason why your own solution is the only correct one. –  Herbert Jan 25 '11 at 13:44
@Herbert, I of course agree that the correct thing to do is \dot{\vec{r}}_\alpha. I was mostly asking because amsmath changes the output unexpectedly. –  Bruno Le Floch Jan 25 '11 at 13:56
you are absolutely right, it should work ... –  Herbert Jan 25 '11 at 15:03

Have a look at the mattens package. I have written it to "overcome" these problems

\documentclass{article}
\usepackage{mattens} % use [noformat] for non-bold symbols
\usepackage{bm}
\begin{document}
$\aS[\Dot]{r}_\alpha$

or some other examples where \TeX\ makes a real mess on its own

$\bS[\Dot]{f}^i_j$
\end{document}

-
Hmm, again: Can you explain what you mean, please? If I replace amsmath with mattens, I get the same problems. –  Hendrik Vogt Jan 25 '11 at 15:20
@Hendrik: See the example in updated post –  Danie Els Jan 25 '11 at 15:44
sorry, which updated post? –  Bruno Le Floch Jan 25 '11 at 16:17
@Bruno: He refers to the code in this answer. –  Hendrik Vogt Jan 25 '11 at 17:14
@Hendrik: for some reason the edited post had not appeared yet when I posted my comment. @Danie. Thanks: although your answer does not solve my question of putting a dot on \vec{r}_\alpha, it is probably the most useful for future users. –  Bruno Le Floch Jan 25 '11 at 17:29

To me it looks like a bug: It works as expected if you omit \usepackage{amsmath}. However, it's somewhat strange what you're trying to do. You should not expect \dot{\vec{r}_\alpha} and \dot{\vec{r}}_\alpha to produce the same output; in the first case, the \dot should be centered over \vec{r}_\alpha, and over \vec{r} in the second case:

And I have no idea why you'd want to achieve the first version: If you want the \dot over everything, then maybe you should also put the \vec over everything, as in \dot{\vec{r_\alpha}}. This again works with amsmath.

As to why amsmath changes things (see comment below): amsmath contains a fix for producing nice double accents, and this seems to go wrong here. (Incidentally, you get almost the same unexpected behaviour if you use accents instead of amsmath.)

-
I agree with the various comments on the fact that no one should do that, but I was wondering why amsmath changes things. And yes, the outputs should be slightly different, but only moving the dot slightly. –  Bruno Le Floch Jan 25 '11 at 13:58
@Bruno: See my update. –  Hendrik Vogt Jan 25 '11 at 14:10