# Referencing nodes in matrix of nodes does not work in beamer [duplicate]

When using node coordinates in a matrix of nodes in the article document class, the following code works well and soes exactly what it is supopsed to:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix (m) [matrix of nodes]
{
A & B & C\\
D & E & F\\
};
\draw (m-1-1)--(m-2-3);
\end{tikzpicture}
\end{document}


If I try to get the same result in beamer by doing

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\matrix (m) [matrix of nodes]
{
A \& B \& C\\
D \& E \& F\\
};
\draw (m-1-1)--(m-2-3);
\end{tikzpicture}
\end{frame}
\end{document}


compilation fails with

Package pgf Error: No shape named m-2-3 is known.


Using a fragile frame makes no difference. Is there a way to make the node names in a matrix of nodes work in beamer?

• You forgot ampersand replacement=\&. – Qrrbrbirlbel Mar 7 '13 at 5:24
• @Qrrbrbirlbel OK, that was really dumb of me. Thanks, that solves the problem. Could you make it into an answer so I can accept it? – Jan Hlavacek Mar 7 '13 at 5:36
• – Claudio Fiandrino Mar 7 '13 at 8:45
• Your first code with fragile frame option will work. Your second code without fragile but with ampersand replacement=\& will work. – Ignasi Mar 7 '13 at 8:46