\documentclass{beamer}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\begin{frame}[fragile, t]{My slides}
\only<1>{
\begin{equation*}
\begin{tikzcd}
a
\end{tikzcd}
\end{equation*}}
\only<2>{
\begin{equation*}
\begin{tikzcd}
a \arrow{r} & b
\end{tikzcd}
\end{equation*}}
\end{frame}
\end{document}
All I want is to show 'a' first, then a point to b, like this 'a->b' (and it has to use Tikz-cd!). But Tikzcd is making it impossible because I get the following error:
Package pgf Error: Single ampersand used with wrong catcode.
See the pgf package documentation for explanation. Type H for immediate help. ...
l.13 \end{equation*}} This error message was generated by an \errmessage command, so I can't give any explicit help. Pretend that you're Hercule Poirot: Examine all clues, and deduce the truth by order and method.
Is there any way to solve this issue? The & works fine when it is on its own frame. But when I put it into a \only block things go bonkers.
I thought [fragile] was supposed to prevent these things!