3

I have a problem with a specific \documentclass[]{report}: in the ToC, both the bookmark and the page number for the Bibliography chapter are incorrect, as they point to the previous section (chapter 9.x) instead of the Bibliography.

Here is the code:

\documentclass[11pt,a4paper,twoside,openright]{report}

\usepackage[hyphens]{url}
\usepackage[hidelinks]{hyperref}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{subfigure}
\usepackage{afterpage}
\usepackage{amsmath,amssymb}            
\usepackage{rotating}  
\usepackage{fancyhdr}  
\usepackage{bbding}  
\usepackage{framed}  
\usepackage[scriptsize]{caption} 
\usepackage[italian,english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{listings}
\usepackage{soul}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage{float}
\usepackage{placeins}
\usepackage{endnotes}
\usepackage{color}
\usepackage{dirtree}
\usepackage{enumitem}
\usepackage{pgfplots}


\addtolength{\oddsidemargin}{+1.3 cm}
\addtolength{\evensidemargin}{-1.3 cm}

\linespread{1.1}


\renewcommand{\captionfont}{\normalfont \sffamily \itshape \small}

\newcommand{\checklist}[1]{\vspace{1cm}\begin{framed}
\noindent \textbf{Checklist} #1\end{framed}}

\newcommand{\note}[2]{\begin{framed}\sffamily\small
\noindent \textbf{#1} \\ #2\end{framed}}

\pagestyle{empty}


\begin{document}
\pgfplotsset{compat=1.15}

\include{cover_page}
\thispagestyle{empty} \normalfont 

\clearpage
\include{dedication}

\thispagestyle{empty}  \cleardoublepage
\pagenumbering{Roman}
\include{abstract}

\thispagestyle{empty} \vspace*{.75truecm} \cleardoublepage
\include{acknowledgements}

\thispagestyle{empty} \vspace*{.75truecm} \normalfont \cleardoublepage
\pagestyle{plain}\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}} 
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}         
\fancyhead[LE,RO]{\bfseries\thepage}    

\fancyhead[RE]{\bfseries\leftmark}    
\fancyhead[LO]{\bfseries\rightmark}     
\renewcommand{\headrulewidth}{0.3pt} 

\tableofcontents
\listoffigures
\listoftables

\cleardoublepage

\pagenumbering{arabic}
\setcounter{page}{1}


\include{chapter1/chapter}
\include{chapter2/chapter}
\include{chapter3/chapter}
\include{chapter4/chapter}
\include{chapter5/chapter}
\include{chapter6/chapter}
\include{chapter7/chapter}
\include{chapter8/chapter}
\include{chapter9/chapter}

\cleardoublepage


\addcontentsline{toc}{chapter}{Bibliography}
\bibliography{mendeley_v2}
\bibliographystyle{plain}


\cleardoublepage

\appendix

\include{appendixA/appendix}
\include{appendixB/appendix}
\include{appendixC/appendix}

\end{document}

Any suggestion would be really appreciated!

2
  • 1
    (1) welcome, (2) in report \bibliography (though the thebibliography environment) issues a \chapter* which includes a \clearpage, thus your \addcontentsline is executed on the wrong page. Consider using the tocbibind package instead, it is specifically made to solve this problem. BTW: it is recommened to load hyperref last as it has to alter a lot of macros.
    – daleif
    Commented Sep 5, 2018 at 10:13
  • I'll add it as an answer
    – daleif
    Commented Sep 5, 2018 at 13:24

1 Answer 1

2

In report \bibliography (through its use of the thebibliography environment) issues a \chapter*{\bibname}. But first it it runs \clearpage or \cleardouble page.

Therefore

\addcontentsline{toc}{chapter}{Bibliography}
\bibliography{mendeley_v2}

may end up giving the wrong page numbers/bookmark target.

Often this can be fixed by issuing a \clearpage before \addcontentsline but this might not work, especially if hyperref is involved.

There is a better solution: use the tocbibind package as (as in tableofcontents, bibliography, index) it will add these to the TOC and contains various tools to control this.

Therefore use the tocbibind package and remove the \addcontentsline line to get a much less cluttered code.

You must log in to answer this question.

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