Code listing in LaTeX beamer presentation frames
Asked Answered
P

2

10

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.

Packsaddle answered 8/10, 2010 at 16:54 Comment(0)
N
12

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

Nance answered 8/10, 2010 at 17:6 Comment(2)
OMG, you're absolutely right. I cannot believe I missed that. Thanks a lot.Packsaddle
A life saver answer. Thanks.Stamey
A
-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.

Arbiter answered 12/5, 2019 at 7:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.