My book
class-based document normally has structure Chapter -> Section -> Subsection -> Subsubsection. And usually, PDF bookmarks in a PDF viewer (e.g. Adobe Reader) reflect just that. Here is one MWE with expected behaviour:
\documentclass{book}
%\usepackage[estonian]{babel}
%\usepackage{mathtools}
%\usepackage{tocloft}
%\usepackage{titlesec}
\usepackage[hypertexnames=false]{hyperref}
%\usepackage{bookmark}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\begin{document}
\tableofcontents
\chapter{Test C}
A
\section{Test C1}
B
\subsection{Test C11}
C
\subsubsection{Test C111}
D
\include{Testing bookmarks}
\end{document}
where Testing bookmarks.tex
is
\appendix
%\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\chapter{Test A}
A
\section{Test A1}
B
The bookmarks are as expected:
However, when \addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
is added/uncommented under Testing bookmarks.tex
, two of the deeper level bookmarks have disappeared.
How can I fix this?
- Please make sure to compile the document a suitable number of times when making changes (here, sometimes three).
- (The MWE is indeed very minimal when compared to the original document.)