I did a commutative diagram with tikz in the article class and everything works.
The next code is the MWE in article class.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{center}
\begin{tikzpicture}
\matrix(m)[matrix of math nodes,row sep=2em,column sep=4em,minimum width=2em]
{ A & B \\
C & D \\};
\path[-stealth]
(m-1-1) edge node [above] {e} (m-1-2) edge node [left] {f} (m-2-1)
(m-1-2) edge node [right] {g} (m-2-2)
(m-2-1) edge node [below] {h} (m-2-2);
\end{tikzpicture}
\end{center}
\end{document}
But, when I copy the code in a Beamer document, something is wrong, as the following code.
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}
\matrix(m)[matrix of math nodes,row sep=2em,column sep=4em,minimum width=2em]
{ A & B \\
C & D \\};
\path[-stealth]
(m-1-1) edge node [above] {e} (m-1-2) edge node [left] {f} (m-2-1)
(m-1-2) edge node [right] {g} (m-2-2)
(m-2-1) edge node [below] {h} (m-2-2);
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
Any idea? Am I doing something wrong?

