Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've been trying to get the bookmark package to work with my thesis, and for the most part I'm happy with the results; however, I'm having some problems with the links for the Table of Figures and Bibliography. Below is a rather extensive MWE of my code for the various sections and chapters etc. I've included all the packages I'm using in my thesis (thus far) in case there's anything that might be causing some conflicts.

Having compiled the TeX file and opened the pdf all the various bookmarks are present, however when I click on the bookmark for Table of Figures it takes me to the Contents page. Similarly, when I click on the bookmark for the bibliography it takes me to 6.1.1, the subsection in Chapter 6.

Can anyone shed any light on what's going wrong here?

Many thanks!

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage[round,colon]{natbib}
\usepackage{caption}
\usepackage{array,booktabs,threeparttable}
\usepackage{chemformula}
\usepackage{url}
\usepackage[intoc]{nomencl}
\usepackage{bookmark}
\usepackage{lipsum}
\bookmarksetup{bold=false}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
  @book{Knu86,
    author = {Knuth, Donald E.},
    year = {1986},
    title = {The \TeX book},
  }
\end{filecontents}

\begin{document}

\begin{titlepage}
\begin{center}
\vspace*{1in}
{\LARGE Quantifying rates of landscape evolution in carbonate terrains using U-Pb dating of speleothems}
\par
\vspace{1.5in}
{\large Christopher James Martin Smith}
\par
\vfill
A dissertation submitted to the University of Bristol in accordance with the requirements for award of the degree of Doctor of Philosophy in the Faculty of Science.
\par
\vspace{0.5in}
School of Geographical Sciences
\par
\vspace{0.5in}
University of Bristol
\par
\vspace{0.5in}
September 2014
\end{center}
\end{titlepage}

\pagenumbering{roman}
\chapter*{Declaration}
\addcontentsline{toc}{chapter}{Declaration}
\lipsum[1]

\chapter*{Acknowledgements}
\addcontentsline{toc}{chapter}{Acknowledgements}
\lipsum[1]

\chapter*{Abstract}
\addcontentsline{toc}{chapter}{Abstract}
\lipsum[1]

\label{Table of Contents}
\cleardoublepage
\pdfbookmark{\contentsname}{Contents}
\tableofcontents
\newpage

\label{List of Figures}
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\newpage

\label{Lits of Tables}
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
\newpage

\label{Nomenclature}
\printnomenclature
\newpage

\pagenumbering{arabic}
\chapter{Introduction}
\section{Section}
\lipsum[1]\citep{Knu86}
\subsection{Subsection}
\lipsum[1]

\chapter{Literature Review}
\section{Section}
\lipsum[1]
\subsection{Subsection}
\lipsum[1]

\chapter{Methodology}
\section{Section}
\lipsum[1]
\subsection{Subsection}
\lipsum[1]

\chapter{Results}
\section{Section}
\lipsum[1]
\subsection{Subsection}
\lipsum[1]

\chapter{Discussion}
\section{Section}
\lipsum[1]
\subsection{Subsection}
\lipsum[1]

\chapter{Conclusion}
\section{Section}
\lipsum[1]
\subsection{Subsection}
\lipsum[1]

\addcontentsline{toc}{chapter}{Bibliography} 
\bibliographystyle{plainnat}
\bibliography{\jobname}

\end{document}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

The bookmark links to the anchor that \addcontentsline uses. Since it comes before the table of figures or the bibliography, it links to some event before (the table of contents/the last subsection). \phantomsection can be used to create a new anchor:

\cleardoublepage
\pdfbookmark{\contentsname}{Contents}
\label{Table of Contents}
\tableofcontents
\newpage

\phantomsection
\label{List of Figures}
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\newpage

\phantomsection
\label{List of Tables}
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
\newpage
...

\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{Bibliography} 
\bibliographystyle{plainnat}
\bibliography{\jobname}

Alternative for the standard lists

\addcontentsline should go to the very first beginning of the lists. \addtocontents allows such placement:

In the preamble (or right after `\begin{document}`:

\AtBeginDocument{%
  \addtocontents{toc}{\protect\label{Table of Contents}}%
  \addtocontents{lof}{%
    \protect\addcontentsline{toc}{chapter}{\protect\listfigurename}%
    \protect\label{List of Figures}%
  }%
  \addtocontents{lot}{%
    \protect\addcontentsline{toc}{chapter}{\protect\listtablename}%
    \protect\label{List of Tables}%
  }%
}

Then \addcontentsline and \label refer to the chapter title of the list. And the code in the document simplifies to

\cleardoublepage
\pdfbookmark{\contentsname}{Contents}
\tableofcontents
\newpage

\listoffigures
\newpage

\listoftables
\newpage

Disadvantage: It takes some runs, because in the first run \addcontentsline goes into the .toc file, in the second run, it goes on to the .lof or .lot file and in the third run the entry is set in the list of figures/tables.

share|improve this answer
    
That's brilliant. Thank you very much. If I were to add a section for a nomenclature, would I need to add a \phantomsection for that as well? –  cjms85 Feb 20 at 17:39
    
@cjms85: Yes, \addcontentsline should go to the first page of the nomenclature. Therefore it goes before \nomenclature. Then \addcontentsline needs an anchor that is set by \phantomsection. –  Heiko Oberdiek Feb 20 at 17:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.