verbatim, etc. in beamer

      14 Comments on verbatim, etc. in beamer

I have been unsuccessful at creating a verbatim environment in a beamer frame. The manual says that it is fully supported, and all you have to do is set the [fragile] argument for that slide. So the following is supposed to work. (Note the weird indenting, since verbatim has to be at the beginning of the line.)

  begin{frame}[fragile]
    frametitle{Euclid says ``hello''}
    begin{verbatim}
blah...
and blah...
end{verbatim}
  end{frame}

Well, I tried compiling it, and it doesn’t. LaTeX exits with the following error.

Runaway argument?
! File ended while scanning use of next.

It took some time to get to the bottom of this. The problem is that a fragile frame must end at the start of a new line! I am an indentation-freak … I indent LaTeX files even when Emacs doesn’t. So I ended up with the end{frame} indented by a couple of spaces. That’s what choked LaTeX. So the above example works when changed as follows:

  begin{frame}[fragile]
    frametitle{Euclid says ``hello''}
    begin{verbatim}
blah...
and blah...
end{verbatim}
end{frame}

Posting this here for the record, with the hope that it will show up in the search results when some other poor sod is bugged by the same problem!

14 thoughts on “verbatim, etc. in beamer

  1. Anonymous

    Thanks for the tip
    I encountered another similar issue. Adding a comment at the end of the line for vim to do folding properly led to the same error, like this:
    frametitle{…} %{{{

    Reply
    1. J.R. Omahen

      I also lost loads of hours to this problem… fortunately this eventually came up in Google. Amazing!

      Reply
  2. Mariusz

    I have following problem. Everything is ok, when I write:
    begin{frame}[fragile]

    A

    end{frame}
    but whe I use my environment:
    newenvironment{myFrameFragile}{

    begin{frame}[fragile]

    }{

    end{frame}

    }

    begin{myFrameFragile}

    A

    end{myFrameFragile}
    I got the eror:
    ! File ended while scanning use of next.

    Thanks for help.

    Reply
  3. Charo Nuguid

    Wow. That was it? It’s all because of the indentation? Jeez! I’ve been banging my head over this for a few weeks now! 😛

    Thanks so much for the post! Now I can continue with what I was doing.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *