How to include a code snippet in a beamer presentation?

mik01aj picture mik01aj · Nov 6, 2009 · Viewed 22.6k times · Source

What's the best way to include some code snippets in a beamer presentation?

I've already tried verbatim, and lstlisting environments - both destroyed my presentation.

Answer

mkluwe picture mkluwe · Nov 6, 2009

Use the [fragile] option:

\begin{frame}[fragile]
\begin{verbatim}
...
\end{verbatim}
\end{frame}