1

I want to number the each section, subsection and subsubsecton in bookmarks of beamer using texlive 2018 version. This problem seems to have been solved many years ago according to the solutions provided by cybersingularity in question Adjust Bookmarks numbering in Beamer.

I followed it and solved it in texlive 2017 last year, however, I can not compile the code in texlive 2018 on Windows OS:

enter image description here

the bookmark is:

enter image description here

The code is as follows:

\documentclass{beamer}
\documentclass{beamer}
\hypersetup{
  bookmarksnumbered=true
}

\setcounter{tocdepth}{4}

% get numbering in section bookmarks
\usepackage{etoolbox}
\usepackage{bookmark}
\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}{\numberline{\therealsection}\secname}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsection}%
   {\Hy@writebookmark{\the\c@subsection}{#2}}%
    {\Hy@writebookmark{\the\c@subsection}{\numberline{\therealsection.\thesubsection}#2}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsubsection}%
    {\Hy@writebookmark{\the\c@subsubsection}{#2}}%
    {\Hy@writebookmark{\the\c@subsubsection}{\numberline{\therealsection.\thesubsection.\thesubsubsection}#2}}%
    {}{\errmessage{failed to patch}}
\makeatother


\begin{document}

\section*{Intro}

\section{section}

\begin{frame}
\end{frame}

\subsection{subsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}

\section{section}
\begin{frame}
\end{frame}

\subsection{subsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}
\end{document}

So, how do i modify the code above and number the subsection and subsusection?

Many thanks for your help.

2

beamer now uses also for subsection and subsubsection commands \subsecname and \subsubsecname:

\documentclass{beamer}
\hypersetup{
  bookmarksnumbered=true
}

\setcounter{tocdepth}{4}

% get numbering in section bookmarks
\usepackage{etoolbox}
\usepackage{bookmark}
\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}{\numberline{\therealsection}\secname}}%
    {}{\errmessage{failed to patch}}
\patchcmd{\beamer@subsection}%
   {\Hy@writebookmark{\the\c@subsection}{\subsecname}}%
    {\Hy@writebookmark{\the\c@subsection}{\numberline{\therealsection.\thesubsection}\subsecname}}%
    {}{\errmessage{failed to patch}}


\patchcmd{\beamer@subsubsection}%
    {\Hy@writebookmark{\the\c@subsubsection}{\subsubsecname}}%
    {\Hy@writebookmark{\the\c@subsubsection}{\numberline{\therealsection.\thesubsection.\thesubsubsection}\subsubsecname}}%
    {}{\errmessage{failed to patch}}
\makeatother


\begin{document}

\section*{Intro}

\section{section}

\begin{frame}
\end{frame}

\subsection{subsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}

\section{section}
\begin{frame}
\end{frame}

\subsection{subsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}

\subsubsection{subsubsection}
\begin{frame}
\end{frame}
\end{document}
  • Many thanks for your helpful advice. It works well. – learnTeX Mar 11 at 10:16

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.