2

I'm trying to write a presentation in beamer about something I've previously written in book documentclass. When it comes to the string:

\documentclass{beamer}
\begin{center}
\begin{tikzpicture}
    \matrix(m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
    {C & B \\
     C^*(E) & \\};
    \draw[->]
    (m-1-1) edge node [above] {$\rho_{T,Q}$} (m-1-2)
     (m-2-1)  edge node [left] {$\exists \phi$} (m-1-1)
     edge node [right] {$\pi_{T,Q}$} (m-1-2);
\end{tikzpicture}
\end{center}

which perfectly compiles in book documentclass, doesn't compile in beamer documentclass. The packages and libraries I use in the beamer, and are then already uploaded are the following:

\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\usetikzlibrary{automata}

Hope some of you guys can help me, thanks.

Teo
  • 31
  • 2
    Please make this into a proper example that others can copy and test as is. We cannot do much with these sniplets. See https://tex.meta.stackexchange.com/q/228 – daleif Jul 07 '20 at 13:28
  • 3
    Hi, welcome. You're missing a frame environment, but beyond that my first guess is that you're facing the same problem as https://tex.stackexchange.com/questions/15093/single-ampersand-used-with-wrong-catcode-error-using-tikz-matrix-in-beamer – Torbjørn T. Jul 07 '20 at 13:28

1 Answers1

1

Okay thanks to Torbjørn T. for the comment. The answer to this problem is just alike "Single ampersand used with wrong catcode" error using tikz matrix in beamer

i.e. Tikz and beamer sometimes don't agree on & being a column separator, so you just have to rename it with some other symbol, like \&

ampersand replacement=\&

then my code should have been:

\begin{center}
\begin{tikzpicture}
    \matrix(m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em,ampersand replacement=\&]
    {C & B \\
     C^*(E) & \\};
    \draw[->]
    (m-1-1) edge node [above] {$\rho_{T,Q}$} (m-1-2)
     (m-2-1)  edge node [left] {$\exists \phi$} (m-1-1)
     edge node [right] {$\pi_{T,Q}$} (m-1-2);
\end{tikzpicture}
\end{center}
Teo
  • 31