beamer 文档中 hyperref 的书签编号选项

beamer 文档中 hyperref 的书签编号选项

我想在 Beamer 文档的 PDF 书签中添加章节编号。但是章节编号没有显示。问题是什么?

\documentclass{beamer}

\hypersetup{
  bookmarksnumbered=true
}

\begin{document}

\section{Hello}

\begin{frame}Test\end{frame}

\section{Beamer}

\begin{frame}Test\end{frame}

\section{World}

\begin{frame}Test\end{frame}

\end{document}

我正在使用 MikTeX 2.9。

答案1

我认为这是一个错误,beamer因为它不遵循通常的hyperref挂钩接口。以下补丁允许该bookmarksnumbered选项产生效果:

\documentclass{beamer}

\hypersetup{
  bookmarksnumbered=true
}
% get numbering in section bookmarks
\usepackage{etoolbox}
\makeatletter
\patchcmd{\beamer@section}%
    {\Hy@writebookmark{\the\c@section}{\secname}}%
    {\Hy@writebookmark{\the\c@section}{\numberline{\thesection}\secname}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsection}%
    {\Hy@writebookmark{\the\c@subsection}{#2}}%
    {\Hy@writebookmark{\the\c@subsection}{\numberline{\thesection.\thesubsection}#2}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsubsection}%
    {\Hy@writebookmark{\the\c@subsubsection}{#2}}%
    {\Hy@writebookmark{\the\c@subsubsection}{\numberline{\thesection.\thesubsection.\thesubsubsection}#2}}%
    {}{\errmessage{failed to patch}}
\makeatother

\begin{document}

\section{Hello}

\begin{frame}Test\end{frame}

\subsection{Goodybe}

\begin{frame}Test\end{frame}

\section{Beamer}

\begin{frame}Test\end{frame}

\section{World}

\begin{frame}Test\end{frame}

\end{document}

结果

结果

相关内容