# Beamer - Customizing PDF Bookmark

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?

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

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}