1

In beamer, I want to insert a bookmark level (or depth?) between part and section. In the example I called it chapter just like it is in the report class. My code put the part and chapter at the right level, but the sections are at the same level than chapter.

I have played around with commands from the bookmark package and some other things like \toclevel@section but clearly, I don’t know what I’m doing and I can’t get the section level to change (except when I put \bookmarksetupnext{rellevel=1} at the end of the chapter command, it works for the very next section only). How can I set the level of the section and subsection bookmarks to one level higher?

\documentclass{beamer}
\usepackage{bookmark}

\AtBeginPart{%
\frame{\partpage}
}%
\AtBeginSection[]{%
\frame{\sectionpage}
}%
\AtBeginSubsection[]{%
\frame{\subsectionpage}
}%

\newcounter{chapter}%
\setcounter{chapter}{0}%

\newcommand{\chapter}[1]{%
\hypertarget{chap\thechapter}{}
\bookmark[level=2, dest=chap\thechapter]{#1}{}
    \refstepcounter{chapter}% 
    \begin{frame}
    \begin{center}
    {\large \textcolor{red}{Chapitre \thechapter \\ \ \\ #1}}%
    \end{center}
    \end{frame}
}%

\begin{document}

\part{First part}
    \chapter{First chapter}
        \section{First section}
            \subsection{First subsection}
        \section{Second section}
    \chapter{Second chapter}
        \section{Thrid section}
\part{Second part}
    \chapter{Third chapter}
        \section{Fourth section}
        \section{Fifth section}

\end{document}
1

beamer hard codes the levels. You can patch e.g. the \part command and set its level to zero:

\documentclass{beamer}
\usepackage{bookmark}

\AtBeginPart{%
\frame{\partpage}
}%
\AtBeginSection[]{%
\frame{\sectionpage}
}%
\AtBeginSubsection[]{%
\frame{\subsectionpage}
}%

\newcounter{chapter}%
\setcounter{chapter}{0}%

\newcommand{\chapter}[1]{%
\refstepcounter{chapter}%
\hypertarget{chap\thechapter}{}
\bookmark[level=1, dest=chap\thechapter]{#1}{}%
    \begin{frame}
    \begin{center}
    {\large \textcolor{red}{Chapitre \thechapter \\ \ \\ #1}}%
    \end{center}
    \end{frame}
}%

\makeatletter
\usepackage{etoolbox}
\patchcmd\beamer@part{{1}{toc}}{{0}{toc}}{}{\fail}
\makeatother
\begin{document}

\part{First part}
    \chapter{First chapter}
        \section{First section}
            \subsection{First subsection}
        \section{Second section}
    \chapter{Second chapter}
        \section{Thrid section}
\part{Second part}
    \chapter{Third chapter}
        \section{Fourth section}
        \section{Fifth section}

\end{document}
  • Unfortunately reseting the section counter (with \beamer@tocsectionnumber=0 and \setcounter{section}{0}) at the beginning of every chapter makes some sections bookmarks non-functional. – sipaq11 Nov 14 '19 at 16:50

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.