Displaying listings in LaTeX beamer slides
If you are using LaTeX for presentations, you usually use the Beamer package. If you are serious about listing, you probably use the Listings package – but what if you want nice code listings in a presentation?
Actually, it’s quite easy, all you need is:
\begin{frame}[fragile]
\frametitle{Your title}
\begin{lstlisting}
code
\end{lstlisting}
\end{frame}
That’s it, and you can use all fancy formatting options inside your slides (boxes, shadows, line-numbers, etc.). Just make sure you don’t use the short-hand \frame{ ... }
and that you add the [fragile]
to each slide that contains a listing.