Displaying listings in LaTeX beamer slides
If you are using LaTeX for presentations, you usually use the Beamer [1] package. If you are serious about listing, you probably use the Listings [2] 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.