5

Possible Duplicate:
Unknown error using tikz matrix of nodes in beamer

I have the following tikzpicture environment from my TeX document but I cannot make it work in Beamer. I get the error:

! Package pgf Error: No shape named m-1-3 is known. 
! Package pgf Error: No shape named m-1-4 is known.

Here is the code

\begin{frame}[fragile] 
\frametitle{Data set-up}
\begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
\matrix (m) [matrix of math nodes, row sep=3em,
column sep=2.5em, text height=1.5ex, text depth=0.25ex] 
{\&\&Z_{1}\&Z_{2}\&\& \\
R \& \& \& \& \& Y  \\ };
\path[->,font=\scriptsize]
(m-1-3) edge node[description]{$ \alpha_{1} $} (m-2-1)
(m-1-4) edge node[description] {$ \alpha_{2} $}(m-2-1)
(m-1-3) edge node[description]{$ \beta_{1} $} (m-2-6)
(m-1-4) edge node[description] {$ \beta_{2} $}(m-2-6);
\path[->,loosely dashed, font=\scriptsize]
(m-2-1) edge node[auto, swap] {$(MAR)$}(m-2-6);
\end{tikzpicture}
\end{frame}
5

The problem is due to the fact that your code uses \& as column separator, but the default is &. To use \& you should add the option ampersand replacement=\&.

This code works properly:

\documentclass{beamer}
\usepackage{tikz,amsmath}
\usetikzlibrary{matrix}

\begin{document}

\begin{frame}[fragile] 
\frametitle{Data set-up}
\begin{tikzpicture}[description/.style={fill=white,inner sep=2pt}]
\matrix (m) [matrix of math nodes, row sep=3em,
 column sep=2.5em, text height=1.5ex, text depth=0.25ex,
 ampersand replacement=\&] % <= notice the missing option
{\&\&Z_{1}\&Z_{2}\&\& \\
R \& \& \& \& \& Y  \\ };
\path[->,font=\scriptsize]
(m-1-3) edge node[description]{$ \alpha_{1} $} (m-2-1)
(m-1-4) edge node[description] {$ \alpha_{2} $}(m-2-1)
(m-1-3) edge node[description]{$ \beta_{1} $} (m-2-6)
(m-1-4) edge node[description] {$ \beta_{2} $}(m-2-6);
\path[->,loosely dashed, font=\scriptsize]
(m-2-1) edge node[auto, swap] {$(MAR)$}(m-2-6);
\end{tikzpicture}
\end{frame}    

\end{document}

Graphical result:

enter image description here

  • I saw the previous discussion and changed & to \&, but didn't realize how the option was inserted. Many thanks! – Duru Alanya Jul 5 '12 at 8:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.