Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

marked as duplicate by Alain Matthes, egreg, Ignasi, Marco Daniel, Claudio Fiandrino Jul 9 '12 at 6:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Can you please provide us your preamble, especially all your loaded packages? –  Eric Jul 4 '12 at 10:37
    
and tex.stackexchange.com/questions/61851/… [closed] ampersand replacement=\& and fragile are the two methods. –  Alain Matthes Jul 4 '12 at 11:00

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
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.