11

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.

Bozhidar Batsov
  • 55,802
  • 13
  • 100
  • 117

2 Answers2

12

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

Svante
  • 50,694
  • 11
  • 78
  • 122
-1

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.

Linfeng Mu
  • 171
  • 1
  • 11