4

The figure
enter image description here

is generated by the following code

\documentclass{amsart}
\usepackage{tikz-cd}


\begin{document}
\begin{tikzcd}
A\ar[rr, shift left=.4ex, "f"]
  &&
  B\ar[ll, shift left=.4ex, "g"],
\end{tikzcd}

\end{document}

However, the same code does not work with Beamer:

\documentclass{beamer}

\usepackage{tikz-cd}

\begin{document}

\begin{frame}

\begin{tikzcd}
A\ar[rr, shift left=.4ex, "f"]
  &&
  B\ar[ll, shift left=.4ex, "g"];
\end{tikzcd}

\end{frame}

\end{document}

The error messages are

! Undefined control sequence.
<argument> \pgf@matrix@last@nextcell@options 
?
! Package pgf Error: Single ampersand used with wrong catcode.
...
l.56 I think the culprit is a tikzcd arrow in cell 1-1.
\errmessage ...currentrow -\tikzcd@currentcolumn }

I am not sure how to make this work with beamer.

Thanks in advance!

0

1 Answer 1

3

You just add [fragile] after \begin{frame}to prevent unexpected effect from & in the tikz-cd package.

Also, plain TikZ is a plain way, no [fragile] thing is needed.

enter image description here

\documentclass{beamer}
\usepackage{tikz,tikz-cd}
\begin{document}
\begin{frame}[fragile]
\begin{tikzcd}
A\ar[rr, shift left=.4ex, "f"]
&&
B\ar[ll, shift left=.4ex, "g"]
\end{tikzcd}

\begin{tikzpicture}
\path (0,0) node (A) {$A$} (2.5,0) node (B) {$B$};
\draw[->] (A.15) to node[above,scale=.75]{$f$} (B.165);
\draw[<-] (A.-15) to node[below,scale=.75]{$g$} (B.-165);
\end{tikzpicture}
\end{frame}
\end{document}
0

Not the answer you're looking for? Browse other questions tagged .