Currently I am trying to create a presentation with tikzcd
using the TeXWorks Editor. Apparently, my computer does not recognize the command \arrow
in the way I would need it to work with tikzcd
(only a theory). Frankly speaking, it looks like my computer has problems with the tikzcd
package at all.
This is working (well, if you want to call this working…)
\documentclass{beamer}
\usetheme[width=2.18cm]{PaloAlto}
\usefonttheme{serif}
\usepackage{tikz, tikz-cd}
\usetikzlibrary{arrows,shapes,cd}
\begin{document}
\begin{frame}{Not important}
\framesubtitle{Neither important}
$\begin{tikzcd}
\end{tikzcd}$
\end{frame}
\end{document}
But as soon as I insert something marginal useful (e.g. A&B
, while a single A
is working…), I get an undefined control sequence referring to \end{frame}
. I want to include something like this
I feel like I missing an important point, even though I copied the code given above straight from here. What could be wrong and more importantly: how do I fix this?
Thanks in advance!
Best Answer
Questions of this type have been asked here before, but I could not find any answer with an explanation (which is most likely my fault). Anyway, here we go. In section 8 Creating Frames of the
beamer
manual version 3.56 it is stated that (I highlighted the important part)It also says on p. 61
In any case, since
tikz-cd
does change some character codes, we need to addfragile
. (As a rule of thumb, whenever something does not work inbeamer
which works fine elsewhere, it is worthwhile adding thefragile
key and check whether or not this solves the problem. Some of the drawbacks of usingfragile
are discussed in this thread.)I also used the opportunity to typeset the diagram, in which the
execute at end picture
key is used to connect the two edge labels, which attained names with thealias
key.ADDENDUM: It has been suggested that the ampersand is the problem. I disagree with that statement. E.g.
does work. It is the line
\catcode\
\&=13that can be found in
tikz.code.tex. It is true, though, that ampersand replacement is another way to solve the problem. I also want to add that I was using
execute at end picturefor a reason. Even though there are seemingly simpler ways, they do not allow you to control the order in which the arrows are placed because
tikz-cd` collects them internally and draws them in an order that we cannot control. Here it does not matter, but you can find here an example where it does.