exsheets and tikz matrix

What is the problem with this file?

\documentclass{article}
\usepackage{exsheets}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

\begin{question}
\begin{tikzpicture}
\matrix (magic) [matrix of nodes]
{
8 & 1 & 6 \\
3 & 5 & 7 \\
4 & 9 & 2 \\
};
\end{tikzpicture}
\end{question}

\end{document}


The compiler says

./mini.tex:16: Undefined control sequence.
<argument> \pgf@matrix@last@nextcell@options

-
Workaround: use the ampersand replacement=\& and change all & into \&. –  Claudio Fiandrino May 8 at 13:55

exsheets reads the body of the question environment as argument, hence you can't use &, but you can use ampersand replacement=\&.

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{exsheets}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{question}
\begin{tikzpicture}
\matrix (magic) [ampersand replacement=\&,matrix of nodes]
{
8 \& 1 \& 6 \\
3 \& 5 \& 7 \\
4 \& 9 \& 2 \\
};
\end{tikzpicture}
\end{question}
\end{document}


-
+1: try to investigate if exsheet makes use of & for special purposes: it may indicate the cause of the problem. –  Claudio Fiandrino May 8 at 14:09
exsheets doesn't use & for anything specific. What it does, though, is reading the environment body as macro argument. Maybe that's the cause... –  cgnieder May 8 at 14:36