I'm trying to use the tickz package in beamer, but the bug is appearing
Missing \endcsname inserted
The code of the diagram I'm drawing is
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{utopia}
\usepackage{tikz}
\usetikzlibrary{shadows}
\usetikzlibrary{arrows,shapes}
\usetheme{Madrid}
\usecolortheme{default}
\begin{document}
\begin{frame}
\begin{equation*}
\begin{tikzpicture}
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
{
K_0(I) & K_0(A) & K_0(B) \\
K_1(B) & K_1(A) & K_1(I) \\};
\path[-stealth]
(m-2-1) edge node [left] {$\delta_1$} (m-1-1)
(m-1-1) edge node [above] {$K_0(\varphi)$} (m-1-2)
(m-1-2) edge node [above] {$K_0(\psi)$} (m-1-3)
(m-2-3) edge node [below] {$K_1(\varphi)$} (m-2-2)
(m-2-2) edge node [below] {$K_1(\psi)$} (m-2-1);
\end{tikzpicture}
\end{equation*}
\end{frame}
\end{document}
If I try this same code into a normal document (without the beamer) it works normally

ampersand replacementand to load thematrixlibrary.\matrix (m) [ampersand replacement =\&,matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em] { K_0(I) \& K_0(A) \& K_0(B) \\ K_1(B) \& K_1(A) \& K_1(I) \\};and\usetikzlibrary{matrix}in the preamble. – Apr 17 '19 at 18:37