2

When using beamer, I found that my subsubsections are not shown in the PDF bookmarks.

I can use \setcounter{tocdepth}{4} or \hypersetup{bookmarksdepth=4} to fix it. And I wonder why.

In this answer, it’s said that:

Since subsubsections are on level 4, the tocdepth must be set to 4.

But we know subsubsections are of level 3, this image is from latex2e.pdf, page 38:

enter image description here

Furthermore, I found that the PDF bookmarks seem to be always “one-level-less” than the counter tocdepth, because if you use \setcounter{tocdepth}{2} to change tocdepth to 2, even the bookmarks for subsections disappear.

You can use this MWE to test the behavior of the PDF bookmarks and the TOC.
(I’m using TeX Live 2022, I use latexmk -xelatex ... to compile.)

\documentclass{beamer}


\hypersetup{bookmarksdepth=4} % this let PDF bookmarks show subsubsections
%\setcounter{tocdepth}{2} % this let TOC frame don't show subsubsections, but also cause subsections not shown in PDF bookmarks
% (try comment both, or comment the former and uncomment the latter)



\usetheme{Berlin}

\begin{document}

\begin{frame} % TOC frame here!
  \tableofcontents
\end{frame}

\section{a}
\subsection{aaa}
\subsubsection{aaaaa}
\begin{frame}a\end{frame}
\subsubsection{aaabb}
\begin{frame}a\end{frame}
\subsection{abb}
\subsubsection{abbaa}
\begin{frame}a\end{frame}
\subsubsection{abbbb}
\begin{frame}a\end{frame}
\section{b}
\subsection{baa}
\subsubsection{baaaa}
\begin{frame}a\end{frame}

\end{document}

1 Answer 1

2

beamer changes the numbers. It assigns 1 to part, 2 to section. You can find the relevant code in beamerbasesection.sty, e.g:

% in the \part definition
 \Hy@writebookmark{\the\c@part}{#1}{Outline\the\c@part}{1}{toc}%

% in \beamer@@section
 \Hy@writebookmark{\the\c@section}{\secname}{Outline\the\c@part.\the\c@section}{2}{toc}%
1
  • Thank you very much. I want to ask further that is \hypersetup{bookmarksdepth=4} a good solution to the question? Also, is this change mentioned in beamer’s user guide? How were the codes implemented so that I can use \setcounter{tocdepth}{...} as usual, i.e., maps subsections to level 2 but not level 3? Is there a reasonable answer to explain why didn’t beamer also change hyperref’s bookmarksdepth? I appreciate your answer.
    – PinkRabbit
    Commented Jul 18, 2022 at 17:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .