![Beamer:如何使每个框架出现在 PDF ToC 中并添加参考书目](https://linux22.com/image/290723/Beamer%EF%BC%9A%E5%A6%82%E4%BD%95%E4%BD%BF%E6%AF%8F%E4%B8%AA%E6%A1%86%E6%9E%B6%E5%87%BA%E7%8E%B0%E5%9C%A8%20PDF%20ToC%20%E4%B8%AD%E5%B9%B6%E6%B7%BB%E5%8A%A0%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%20.png)
我想基于以下解决方案这个答案通过在最后一张幻灯片中添加参考书目来为 PDF 创建目录。然而,参考书目似乎干扰了目录,TeX 输出错误
ERROR: Missing } inserted.
--- TeX said ---
<inserted text>
}
l.5 ...er@sectionintoc {1}{First Section}{1}{0}{1}
请考虑以下 MWE
\documentclass{beamer}
\AtBeginSection{\frame{\tableofcontents[currentsection]}}
\usepackage{bookmark}
\usepackage{etoolbox}
\makeatletter
% save the current definition of \beamer@@frametitle
\let\nobookmarkbeamer@@frametitle\beamer@@frametitle
% then patch it to do the bookmarks and/or TOC entries
\apptocmd{\beamer@@frametitle}{%
% keep this to add the frame title to the TOC at the "subsection level"
\addtocontents{toc}{\protect\beamer@subsectionintoc{\the\c@section}{0}{#1}{\the\c@page}{\the\c@part}%
{\the\beamer@tocsectionnumber}}%
% keep this line to add a bookmark that shows up in the PDF TOC at the subsection level
\bookmark[page=\the\c@page,level=3]{#1}%
}%
{\message{** patching of \string\beamer@@frametitle succeeded **}}%
{\errmessage{** patching of \string\beamer@@frametitle failed **}}%
\pretocmd{\beamer@checknoslide}{%
% ensure the bookmark is not created if the slide is filtered out
\let\beamer@@frametitle\nobookmarkbeamer@@frametitle
}%
{\message{** patching of \string\beamer@checknoslide succeeded **}}%
{\errmessage{** patching of \string\beamer@checknoslide failed **}}%
\makeatother
% Set the values for the bibliography
\usepackage[
backend=biber
]{biblatex}
\RequirePackage{filecontents}
\begin{filecontents*}{mybib.bib}
@book{test1,
address = {London},
url = {www.jstor.com/somearticle.html},
urldate = {2013-10-29},
title = {Cyberprotest: {New} media, citizens, and social movements},
publisher = {Routledge},
editor = {van de Donk, Wim B. H. J.},
year = {2004}
}
@misc{test2,
title = {This is the title of the webpage},
url = {www.blog.com},
urldate = {2013-08-29},
journal = {This is the title of the website},
month = feb,
year = {2009}
}
}
\end{filecontents*}
\addbibresource{mybib.bib}
\begin{document}
\section{First Section}
\begin{frame}{First frame}
\begin{itemize}
\item item2
\item item1
\end{itemize}
\end{frame}
\begin{frame}{Second frame}Text\end{frame}
\section{Second Section}
\begin{frame}{Third frame}Text\end{frame}
\begin{frame}
\autocite{test1, test2}
% \printbibliography % <- when uncommenting this line TeX return an error
\end{frame}
\end{document}