10
votes

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.

2

2 Answers

11
votes

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

-1
votes

I have also also met such a problem. My codes are different from yours but we get the same error message. In my case, it is because the \lstset{} is sensitive to blank line. which means:

\lstset{
   a1 = b1,
   a2 = b2,
 }

can work; whereas

\lstset{
   a1 = b1,

   a2 = b2,
 }

can't. I hope this could help you or whoever encountered the same problem as me.