Beamer:兼容性问题 natbib

Beamer:兼容性问题 natbib

我正在尝试创建一个 beamer 演示文稿,在每个新部分的开头显示一张带有目录的幻灯片,并突出显示当前部分。我知道如何做到这一点(下面 MWE 中的第 4-8 行)。但是,这似乎与软件包不兼容natbib

如果我尝试排版下面的 MWE,我收到以下错误:./mwe.vrb:2: Extra },或忘记 \endgroup。\endframe ->\egroup \begingroup \def @currenvir {frame} l.2 \begin{thebibliography}{1}

注释掉 natbib 包可以消除错误,注释掉 MWE 的第 4-8 行也可以消除错误。

\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

问题在于您的参考书目试图开始新的章节。由于这种情况发生在框架内,因此章节页面的框架将嵌套在另一个框架中,这是不允许的。

您可以使用 来避免此问题\AtBeginSection[]{...}。空白[]将关闭未编号章节的章节页面,从而避免参考书目问题。

\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}

相关内容