[Tex/LaTex] Matrix derivation

arraysmath-modematrices

I would like to display a matrix with a dot (derivative) on top of it. The entry of this matrix shall consist of arbitrary symbols.

When I write

 \begin{align}
   \dot{\begin{pmatrix} x \\ y \end{pmatrix}}
 \end{align}

everything works fine. However,

 \begin{align}
   \dot{\begin{pmatrix} \hat{x} \\ \hat{y} \end{pmatrix}}
 \end{align}

results in a weird series of errors (Illegal units of measure etc.).

How can I display a matrix derivation with hats (or other ornaments) on my x and y variables? Neither changing from pmatrix to array nor setting brackets did bring any improvements.

A complete example of the problem reads:

 \documentclass{report}
 \usepackage[utf8x]{inputenc}
 \usepackage{amsmath,amsfonts,mathrsfs,amssymb,dsfont}
 \begin{document}
   \begin{align}
     \dot{\begin{pmatrix} \hat{x} \\ \hat{y} \end{pmatrix}} % Problem!
   \end{align}
 \end{document}

Best Answer

amsmath has some fancy code for double accents and having \hat inside \dot triggers bits of that in unintended ways. Easiest is to pre-set the inner expression in a box.

enter image description here

\documentclass{report}
 \usepackage[utf8x]{inputenc}
 \usepackage{amsmath,amsfonts,mathrsfs,amssymb,dsfont}
\begin{document}

 \begin{align}
 \sbox0{$\begin{pmatrix}\hat{x} \\ \hat{y} \end{pmatrix}$}\dot{\usebox{0}}
 \end{align}
\end{document}
Related Question