1

I'm trying to create a beamer presentation that shows, at the start of each new section, a slide with the table of contents, with the current section highlighted. I know how to do that (lines 4-8 in the MWE below). However, this seems to be incompatible with the natbib package.

If I try to typeset the MWE below, I get the following error: ./mwe.vrb:2: Extra }, or forgotten \endgroup. \endframe ->\egroup \begingroup \def @currenvir {frame} l.2 \begin{thebibliography}{1}

Commenting out the natbib package removes the error, as does commenting out lines 4-8 of the MWE.

\documentclass{beamer} 
\usepackage[authoryear]{natbib}

\AtBeginSection{%
\begin{frame}[c]{Outline}
\tableofcontents[currentsection, subsectionstyle=show/hide/hide]
\end{frame}
}

\title{Title}
\author{Author}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\begin{frame}[c]{Outline}
\tableofcontents[hideallsubsections]
\end{frame}

\section{Section 1}
\begin{frame}
\frametitle{\insertsectionhead}
Some text.
\end{frame}

\section{Section 2}
\begin{frame}{\insertsectionhead}
Some more text; see in particular \cite{Chomsky1965}.
\end{frame}


\begin{frame}[fragile]{References}
\begin{thebibliography}{1}
\providecommand{\natexlab}[1]{#1}
\providecommand{\url}[1]{\texttt{#1}}
\providecommand{\urlprefix}{}
\expandafter\ifx\csname urlstyle\endcsname\relax
  \providecommand{\doi}[1]{doi:\discretionary{}{}{}#1}\else
  \providecommand{\doi}{doi:\discretionary{}{}{}\begingroup
  \urlstyle{rm}\Url}\fi

\bibitem[{Chomsky(1965)}]{Chomsky1965}
Chomsky, Noam. 1965.
\newblock \emph{Aspects of the theory of syntax}.
\newblock Cambridge, MA: MIT Press.
\end{thebibliography}
\end{frame}
       
\end{document}

1 Answer 1

0

The problem is that your bibliography tries to start a new section. As this happens inside a frame, the frame from the section page would be nested into another frame, which is not allowed.

You can avoid the problem by using \AtBeginSection[]{...}. The empty [] will switch off the section pages for unnumbered sections and this avoid the problem with the bibliography.

\documentclass{beamer} 
\usepackage[authoryear]{natbib}

\AtBeginSection[]{%
\begin{frame}[c]{Outline}
\tableofcontents[currentsection, subsectionstyle=show/hide/hide]
\end{frame}
}

\title{Title}
\author{Author}

\begin{document}

\begin{frame}
\titlepage
\end{frame}

\begin{frame}[c]{Outline}
\tableofcontents[hideallsubsections]
\end{frame}

\section{Section 1}
\begin{frame}
\frametitle{\insertsectionhead}
Some text.
\end{frame}

\section{Section 2}
\begin{frame}{\insertsectionhead}
Some more text; see in particular \cite{Chomsky1965}.
\end{frame}


\begin{frame}[fragile]{References}
\begin{thebibliography}{1}
\providecommand{\natexlab}[1]{#1}
\providecommand{\url}[1]{\texttt{#1}}
\providecommand{\urlprefix}{}
\expandafter\ifx\csname urlstyle\endcsname\relax
  \providecommand{\doi}[1]{doi:\discretionary{}{}{}#1}\else
  \providecommand{\doi}{doi:\discretionary{}{}{}\begingroup
  \urlstyle{rm}\Url}\fi
\bibitem[{Chomsky(1965)}]{Chomsky1965}
Chomsky, Noam. 1965.
\newblock \emph{Aspects of the theory of syntax}.
\newblock Cambridge, MA: MIT Press.
\end{thebibliography}
\end{frame}
       
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .