16

The following code is in the preamble of my LaTeX document:

\documentclass{llncs}
\usepackage{amsmath,amssymb}
\usepackage{url}
\usepackage[algoruled,vlined]{algorithm2e}
\usepackage{graphicx,subfigure}


\usepackage{hyperref} 
\hypersetup{colorlinks=true,citecolor=blue}


\numberwithin{equation}{section} % numbering according to the section
\bibliographystyle{plain}  %Choose a bibliograhpic style
\begin{document}

\title{The Title}
\maketitle
\section{A}
\label{sect:A}
\subsection{a}
\subsection{b}
% ...
\section{B}
\label{sect:B}
\subsection{a}
\subsection{b}
% ...
\section{C}
\label{sect:C}
\subsection{a}
\subsection{b}
% ...
\end{document}

Note that the text is organized into sections and subsection. However, after compiling the code, the Adobe PDF preview does not show the "tree" branching on the left. Instead, it just shows "The Title", and that option has no branching with the "+/-" sings. How could I achieve this?

Martin Scharrer
  • 262,582
boy
  • 1,525

1 Answers1

19

The llncs class sets tocdepth to 0. This setting controls which sectioning commands end up in the Table-Of-Contents (TOC), which is also used by hyperref for the PDF bookmarks depth by default. You need to set the bookmarksdepth manually to a higher value (higher means more deeper sectioning commands are included). An alternative is to raise tocdepth again, but this also affects the \tableofcontents command, which might be unwanted.

Here are correctly working example:

\documentclass{llncs}
\usepackage[bookmarks,bookmarksopen,bookmarksdepth=2]{hyperref}
\title{The Title}
\author{the author}
%\setcounter{tocdepth}{2}%  alternative (2 or higher)
\begin{document}
\maketitle
\section{A}
\label{sect:A}
\subsection{a}
\subsection{b}
% ...
\section{B}
\label{sect:B}
\subsection{a}
\subsection{b}
% ...
\section{C}
\label{sect:C}
\subsection{a}
\subsection{b}
% ...
\end{document}

A list of all depth numbers for the sectioning commands can be found in How to show subsections and subsubsections in TOC?

Martin Scharrer
  • 262,582
  • Works, thanks. It was the \setcounter{tocdepth}{3} command. – boy Apr 18 '12 at 11:39
  • @boy: Note that I updated the answer. Using bookmarksdepth=2 (or higher) does it also and might be better. – Martin Scharrer Apr 18 '12 at 11:40
  • thanks. I found that \subsubsection{a} doesn't show when setting bookmarksdepth=3. Is that just me? – Tim May 16 '15 at 06:04
  • @Tim: Are you using the llncs class like above or another one? The sectioning depth depends on the class. book style classes start to count at \chapter while article like classes start at \section. – Martin Scharrer May 18 '15 at 21:01
  • Thanks you very much ! :D Helped me generate bookmarks for a lot of Arxiv papers which weren't working – programmer Jul 19 '23 at 20:09