8

I cannot set up correct PDF bookmark for Bibliography chapter in the backmatter.

The page number in TOC is correct, however the PDF bookmark consistently points to the last section in the mainmatter.

\documentclass{book}

\usepackage{bookmark}

\begin{document}
\pdfbookmark{\contentsname}{Contents}
\tableofcontents\cleardoublepage
\pagenumbering{arabic}

\begin{mainmatter}
    \chapter{Chapter A}
    \section{Section a}
\end{mainmatter}

\begin{backmatter}
    \addcontentsline{toc}{chapter}{Bibliography}
    \begin{thebibliography}{9}
    \end{thebibliography}
\end{backmatter}

\end{document}
Robert
  • 113
  • Change the order of \addcontentsline and \begin{thebibliography}` –  Jul 03 '14 at 13:12
  • And it is sufficient to write \mainmatter and \backmatter, not \begin{mainmatter} etc. Those constructs are true commands and not environments –  Jul 03 '14 at 13:14
  • Changing the order of \addcontentsline and \begin{thebibliography} produces good PDF bookmark but wrong page number in TOC (last page of Bibliography). – Robert Jul 04 '14 at 09:58
  • I used portions of your MWE and added another solution, however with \printbibliography instead of \begin{thebibliography}. At least in that short file the bookmarks and page numbers are correct –  Jul 04 '14 at 16:19

2 Answers2

4

Package tocbibind can be used to include the chapter titles of the table of contents and the bibliography to the table of contents and the bookmarks:

\documentclass{book}
\usepackage{tocbibind}
\usepackage{bookmark}

\begin{document}

\frontmatter
\tableofcontents

\mainmatter
\chapter{Chapter A}
\section{Section a}

\backmatter
\begin{thebibliography}{9}
\end{thebibliography}

\end{document}

Remarks:

  • \mainmatter, \backmatter are commands rather than environments in class book.
Heiko Oberdiek
  • 271,626
  • @Robert: That are different questions, e.g. see this answer. Also there are counter tocdepth and option depth of package bookmark (= option bookmarkdepth of hyperref). – Heiko Oberdiek Jul 04 '14 at 12:22
2

There is already a good answer by Heiko Oberdiek, I just wanted to react on the comment by the OP about the wrong page number. However, I use the biblatex package.

\documentclass{book}%

\usepackage[backend=biber]{biblatex}
\usepackage{bookmark}

% Normally biblio.bib is available on every TeXLive System in 
% the sub-directory bibtex/msc
\bibliography{biblio} 

\begin{document}
\pdfbookmark{\contentsname}{Contents}
\tableofcontents\cleardoublepage
\pagenumbering{arabic}

\mainmatter
    \chapter{Chapter A}
    \cite{Lam94} % Cite Leslie Lamport
    \section{Section a}

\backmatter
    \phantomsection
    \printbibliography%
    \addcontentsline{toc}{chapter}{\bibname}%  
\end{document}

enter image description here

  • You can just pass [heading=bibintoc] to \printbibliography. See: https://tex.stackexchange.com/a/67155 – Rufflewind Dec 19 '17 at 06:40
  • @Rufflewind: Yes. I posted this answer more than 3 years ago, when my knowledge of biblatex was limited. Forgot about this answer. Thanks –  Dec 19 '17 at 09:41