Overlays with Code Listings

You cannot include a lstlisting (package listings) in a only or visible command in LaTeX beamer. BUT you can define the listing beforehand and then include that inside the only or visible!

Example (from slides about recursion in Java):

public int fakultaet(int n) {
   if ( n == 1 ) {
      return 1;
   } else {
      return n * fakultaet( n-1 ) ;

\frametitle{Aufgabe: Fakult├Ąt von $n$}

   \item \lstinline{fakultaet( 1 ) = 1}
   \item \lstinline{fakultaet( n ) = n * fakultaet( n-1 ) }


Java Code: 

This entry was posted in LaTeX and tagged , , by swk. Bookmark the permalink.

About swk

I am a computational linguist, teacher of computer science and above all a huge fan of LaTeX. I use LaTeX for everything, including things you never wanted to do with LaTeX. My latest love is lilypond, aka LaTeX for music. I'll post at irregular intervals about cool stuff, stupid hacks and annoying settings I want to remember for the future.