![beamer 文档中 hyperref 的书签编号选项](https://linux22.com/image/278233/beamer%20%E6%96%87%E6%A1%A3%E4%B8%AD%20hyperref%20%E7%9A%84%E4%B9%A6%E7%AD%BE%E7%BC%96%E5%8F%B7%E9%80%89%E9%A1%B9.png)
我想在 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}