2

I am preparing a presentation in beamer including some sections and subsections. However, I want the section numbers and subsection numbers appear in the PDF Bookmarks. I used the following code but in the TOC, the section number appears twice.

\section[First Section]{\S~{\protect\ref{s1}} First Section}\label{s1}

How can I have the following output for the PDF Bookmarks and the TOC? Desired

  • Maybe you can define a \mysection combining \addcontentsline and \pdfbookmark – Symbol 1 Oct 19 '14 at 3:09
3

Alright, I found my answer here Adjust Bookmarks numbering in Beamer, thanks to cyberSingularity. I am giving the codes too.

\documentclass{beamer}

\usepackage{etoolbox}
\usepackage{bookmark}

\hypersetup{bookmarksdepth=4,bookmarksnumbered=true,bookmarksopen=true}

\usetheme{Warsaw}
\usecolortheme{seahorse}

\makeatletter
\newcounter{realsection}
\newif\ifrealsection
\long\def\beamer@@ssection*#1{\realsectionfalse\beamer@section[{#1}]{}}
\long\def\beamer@@@section#1{\realsectiontrue\beamer@section[{#1}]{#1}}

\patchcmd{\beamer@section}%
    {\refstepcounter{section}}%
    {\ifrealsection\refstepcounter{realsection}\fi\refstepcounter{section}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@section}%
    {\Hy@writebookmark{\the\c@section}{\secname}}%
    {\Hy@writebookmark{\the\c@section}{\S~\numberline{\therealsection}\secname}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsection}%
   {\Hy@writebookmark{\the\c@subsection}{#2}}%
    {\Hy@writebookmark{\the\c@subsection}{\S~\numberline{\therealsection.\thesubsection}#2}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsubsection}%
    {\Hy@writebookmark{\the\c@subsubsection}{#2}}%
    {\Hy@writebookmark{\the\c@subsubsection}{\S~\numberline{\therealsection.\thesubsection.\thesubsubsection}#2}}%
    {}{\errmessage{failed to patch}}
\makeatother

\begin{document}

\begin{frame}{}
\tableofcontents
\end{frame}

\section*{Cover}
\pdfbookmark[2]{Cover}{Cover}

\section*{Table of Contents}
\pdfbookmark[2]{Table of Contents}{ToC}

\section{First Section}
\begin{frame}{}
\end{frame}

\end{document} 

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.