I am trying to type math exercises by using XeLaTeX, the tikz-cd package for commutative diagrams, the babel package for German, and the exsheets package for formatting and organizing the questions and answers.
Here is a minimal example:
\documentclass{article}
\usepackage{xltxtra}
\usepackage{exsheets}
\usepackage[ngerman]{babel}
\usepackage{tikz-cd}
\usetikzlibrary{babel}
\begin{document}
\begin{question}
\[
\begin{tikzcd}[ampersand replacement=\&]
A \arrow[r, "f"]
\& B
\end{tikzcd}
\]
\end{question}
\end{document}
I use \usetikzlibrary{babel} because otherwise the ngerman module for babel and the " character in the tikzcd environment result in a problem similar to this one.
I use ampersand replacement=\& for the tikzcd enviroment, because the question environment otherwise results in a problem similar to this one.
The given code results in the following error:
Argument of \language@active@arg" has an extra }
This is the same error one gets when not using \usetikzlibrary{babel}, and any of these three make the code work:
- Not using the
babelpackage. - Not using the
questionenvironment. - Removing the label
"f"from the arrow.
So it seems to me that the question environment is somehow preventing \usetikzlibrary{babel} from working.
I don’t know how the fix this, and the only other mention of this problem I found has a workaround specific to the Spanish language.
questionenvironment (actually a subenvironment, but it's not important) absorbs the contents as a macro to an argument; this is the reason whyampersand replacementis needed. This unfortunately also has the consequence that the trick used by thebabelTikZ library doesn't work. However, you can use the alternate input\arrow{r}{f}. – egreg Jun 23 '16 at 22:45