# diagrams in beamer

I want to put this diagram in the latex when I make a frame it does not work but without frame it works right. Is there any idea?

\begin{equation*}
\begin{tikzcd}[column sep=0.50em]
\cdots\arrow[r]
&D^{\oplus n_{i+1}}
\arrow[rr,"d_{i+1}"]
\arrow[dr,"g_{i+1}"]
&&D^{\oplus n_i}
\arrow[dr,"g_i"]
\arrow[rr,"d_i"]
&&D^{\oplus n_{i-1}}
\arrow[r]
\arrow[dr]
&\cdots\\
M_{i+1}\arrow[ur]
&&M_i
\arrow[ur,"f_{i}"]
\arrow[dashed,ll]
&&M_{i-1}
\arrow[dashed,ll]
\arrow[ur,"f_{i-1}"]
&&M_{i-2}
\arrow[dashed,ll]
\end{tikzcd}
\end{equation*}

• \begin{frame}[fragile]? – Torbjørn T. Nov 13 '16 at 18:48
• It worked with this [fragile] thanks. Is there any way that I make it smaller than now in the frame? – tarl Nov 13 '16 at 18:54

frames in beamer have problem with some things, such as the & in TikZ matrices. To get around that either add the [fragile] option to the frame, or use ampersand replacement as in the second example below.

In the code are indicated a few things that can help you reduce the size of the diagram, if you really need that.

\documentclass{beamer}
\usepackage{tikz-cd}
\begin{document}
\begin{frame}[fragile]
\begin{equation*}
\begin{tikzcd}[
column sep=0.50em,
%   row sep=small, % reduces space between rows
%   cramped, % reduces whitespace around cells
%   cells={font=\tiny} % reduces font size (try \footnotesize, \scriptsize, \small
]
\cdots\arrow[r]
&D^{\oplus n_{i+1}}
\arrow[rr,"d_{i+1}"]
\arrow[dr,"g_{i+1}"]
&&D^{\oplus n_i}
\arrow[dr,"g_i"]
\arrow[rr,"d_i"]
&&D^{\oplus n_{i-1}}
\arrow[r]
\arrow[dr]
&\cdots\\
M_{i+1}\arrow[ur]
&&M_i
\arrow[ur,"f_{i}"]
\arrow[dashed,ll]
&&M_{i-1}
\arrow[dashed,ll]
\arrow[ur,"f_{i-1}"]
&&M_{i-2}
\arrow[dashed,ll]
\end{tikzcd}
\end{equation*}
\end{frame}

\begin{frame}
\begin{equation*}
\begin{tikzcd}[
ampersand replacement=\&,
column sep=0.50em,
%   row sep=small, % reduces space between rows
%   cramped, % reduces whitespace around cells
%   cells={font=\tiny} % reduces font size (try \footnotesize, \scriptsize, \small
]
\cdots\arrow[r]
\&D^{\oplus n_{i+1}}
\arrow[rr,"d_{i+1}"]
\arrow[dr,"g_{i+1}"]
\&\&D^{\oplus n_i}
\arrow[dr,"g_i"]
\arrow[rr,"d_i"]
\&\&D^{\oplus n_{i-1}}
\arrow[r]
\arrow[dr]
\&\cdots\\
M_{i+1}\arrow[ur]
\&\&M_i
\arrow[ur,"f_{i}"]
\arrow[dashed,ll]
\&\&M_{i-1}
\arrow[dashed,ll]
\arrow[ur,"f_{i-1}"]
\&\&M_{i-2}
\arrow[dashed,ll]
\end{tikzcd}
\end{equation*}
\end{frame}
\end{document}