Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 
share|improve this question
    
Workaround: use the ampersand replacement=\& and change all & into \&. –  Claudio Fiandrino May 8 at 13:55

1 Answer 1

up vote 6 down vote accepted

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}

enter image description here

share|improve this answer
    
+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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.