Math-accent symbol over parentheses enclosing accented symbol (amsmath)
The following redefines an internal of amsmath
. After that the output of your example looks good. I don't know whether this has any possibility of breaking other stuff. I've added every test case egreg used in his answer and the output looks good. It doesn't work with the accents
package, though.
\documentclass[]{article}
\usepackage[]{amsmath}
\makeatletter
\protected\def\mathaccentV#1#2#3#4#5%
{%
\ifmmode
\mathaccentV@do{#2}{#3}{#4}{#5}%
\else
\@xp\nonmatherr@\csname #1\endcsname
\fi
}
\def\mathaccentV@do#1#2#3#4%
{%
\global\let\macc@nucleus\@empty
\mathaccent"\accentclass@#1#2#3{#4}\macc@nucleus
}
\makeatother
\begin{document}
\begin{gather*}
\vec{(\dot{x})}
\\
\dot{\begin{bmatrix} x \\ \dot{x} \end{bmatrix}}
\\
\vec{(\exp \dot{x})}
\end{gather*}
\end{document}
This has to do with a long-standing amsmath
issue, see Why do arguments to nested \tilde or \breve commands reappear when amsmath is used?
I can offer a workaround.
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\dblacc}[2]{\mathpalette\dblacc@{{#1}{#2}}}
\newcommand{\dblacc@}[2]{\dblacc@@#1#2}
\newcommand{\dblacc@@}[3]{%
\begingroup
\sbox\z@{$\m@th#1#3$}%
#2{\box\z@}%
\endgroup
}
\makeatother
\begin{document}
\begin{gather*}
\dblacc\vec{(\dot{x})}
\\
\dblacc\dot{\begin{bmatrix} x \\ \dot{x} \end{bmatrix}}
\\
\dblacc\vec{(\exp \dot{x})}
\end{gather*}
\end{document}
A version that works also with accents
:
\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}
\makeatletter
\newsavebox{\dblacc@boxa}
\newsavebox{\dblacc@boxb}
\DeclareRobustCommand{\dblacc}[2]{\mathpalette\dblacc@{{#1}{#2}}}
\newcommand{\dblacc@}[2]{\dblacc@@#1#2}
\newcommand{\dblacc@@}[3]{%
\begingroup
\sbox\dblacc@boxa{$\m@th#1#3$}%
\sbox\dblacc@boxb{$\m@th#1#2{\copy\dblacc@boxa}$}%
\box\dblacc@boxb
\endgroup
}
\makeatother
\begin{document}
\begin{gather*}
\dblacc\vec{(\dot{x})}\quad\scriptscriptstyle\dblacc\vec{(\dot{x})}
\\
\dblacc\dot{\begin{bmatrix} x \\ \dot{x} \end{bmatrix}}
\\
\dblacc\vec{(\exp \dot{x})}
\end{gather*}
\end{document}