5

I'm getting "Missing } inserted" error, when compiling with pdflatex and I really don't understand why. This is occurring in a beamer frame. Maybe someone comes up with something useful.

\documentclass{beamer}
...
\usepackage[utf8x]{inputenc}
\usepackage{default}
\usepackage{times}
\usepackage{graphics}
...
\begin{frame}\frametitle{3\textonehalf. Generace}

    \begin{block}{3\textonehalf. Generace}
        \begin{itemize}
            \item OOP
        \end{itemize}
    \end{block}

    \begin{exampleblock}{Jazyky 3\textonehalf. generace}
        \begin{itemize}
            \item první Smalltalk
            \item C{}\verb!++!, Objective-C, Object Pascal, Java
            \item statické / dynamické
        \end{itemize}
    \end{exampleblock}

\end{frame}
...

I get the error on the last line.

  • 2
    Use \begin{frame}[fragile] when the frame contains verbatim bits. – egreg May 13 '13 at 22:32
  • that's it, thanx :-) – Michal Artazov May 13 '13 at 22:37
  • 3
    Although there is no need to use verb there ++ or if you want, \texttt{++} would work – David Carlisle May 13 '13 at 22:40
  • Assuming egreg is right, you could avoid the problem by using this method for typsetting C++. – Ryan Reich May 13 '13 at 23:00
  • I couldn't find a reference to the use of fragile frames in beamer when dealing with verbatim. Perhaps we should write an answer, @egreg? – Werner May 14 '13 at 01:20
  • @Werner There is http://tex.stackexchange.com/questions/36776/latex-error-when-inserting-code-listing-in-lyx, for example – egreg May 14 '13 at 07:31
  • @egreg -- your cited question does mention fragile but the question is tagged with lyx so on the surface, one might think it not relevant. a pointer to section 3.13, "verbatim text", in the beamer manual might be more helpful. – barbara beeton May 14 '13 at 13:03
  • 1
    @Werner -- the first example in section 3.13, "verbatim text" of the beamer manual starts with \begin{frame}[fragile]. i didn't know about this either, so think an answer might be helpful here. reopen? (might benefit from restating the question a bit.) – barbara beeton May 14 '13 at 13:06
  • 1
    @barbarabeeton: I've voted... – Werner May 14 '13 at 14:30

1 Answers1

8

the problem, as pointed out by egreg, is that you need to specify

\begin{frame}[fragile]

when including verbatim material in the frame.

this is documented in the beamer manual (texdoc beamer) in section 3.1.3, "verbatim text". (it almost never hurts to check the manual, and the beamer manual is a good one.)