Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code listing in LaTeX beamer presentation frames

Tags:

latex

beamer

I'm trying to create a LaTeX beamer presentation that has several Java code listings. However, I encountered a very bizarre problem - my listing snippet causes a compilation failure when in the presentation, but works just fine in some other document.

\begin{frame}[Fragile]
  \frametitle{Test}
 \begin{lstlisting}
    public class SimpleClass {
      public static void main(String[] args) {
        System.out.println("Hello!");
      }
    }
  \end{lstlisting}
\end{frame}

If I remove this code from my presentation it will work just fine, but with it I get the error message:

===

ERROR: Paragraph ended before \lst@next was complete.

--- TeX said --- \par l.129

--- HELP --- A blank line occurred in a command argument that shouldn't contain one. You probably forgot the right brace at the end of an argument.

====

I'm totally at a loss here, because this exact listing works just fine in some regular report. I've searched around and found out that I should have the fragile attribute set for frames with listings in them, but this didn't change anything.

Thanks in advance for your help.

like image 202
Bozhidar Batsov Avatar asked Oct 08 '10 16:10

Bozhidar Batsov


1 Answers

I believe that the option fragile is meant to be entirely lowercase.

like image 177
Svante Avatar answered Sep 23 '22 13:09

Svante