5

I wanted to put section numbers in pdf bookmarks of a beamer document. But section numbers didn't show up. What is the problem?

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

I'm using MikTeX 2.9.

4

I would suggest that this is a bug in beamer because it does not follow the usual interface that hyperref hooks into. The following patch allows the bookmarksnumbered option to have an effect:

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

Result

Result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.