0

The ToC is not linking to the correct page, the page numbering is correct in the ToC but when I click on the hyperref it takes me the wrong section

\documentclass[11pt]{report} % Default font size is 12pt, it can be changed here
\usepackage{geometry} % Required to change the page size to A4
\geometry{a4paper} % Set the page size to be A4 as opposed to the default US Letter
\usepackage{graphicx} % Required for including pictures
\usepackage{float} % Allows putting an [H] in \begin{figure} to specify the exact location of the figure
\usepackage{wrapfig} % Allows in-line images
\graphicspath{{../figures/}}  % Specifies the directory where pictures are stored
\usepackage[utf8]{inputenc}
\linespread{1.2} % Line spacing
%\setlength\parindent{0pt} % Uncomment to remove all indentation from paragraphs
\usepackage[colorlinks=true,urlcolor=blue,citecolor=red,linkcolor=black,bookmarks=true]{hyperref} % makes color citations
\usepackage{indentfirst} %indent all the first lines of an sentance
\usepackage[sort&compress,round,semicolon,authoryear]{natbib}
\usepackage{siunitx}
\usepackage{gensymb}
\usepackage{pdfpages}
\usepackage{tabularx}
\usepackage{glossaries}
\usepackage{bookmark}
\setcounter{secnumdepth}{0} % only number chapters 
\usepackage{forest} % to create pretty diagrams
\usepackage[nottoc,numbib]{tocbibind}

\usetikzlibrary{arrows.meta}
\tikzset{
  my rounded corners/.append style={rounded corners=2pt},
}
\colorlet{linecol}{black!75}
\setcounter{tocdepth}{1}

\bookmarksetup{
  numbered,
  open
}

%used to center the chapter headings and decrease the space before and after the heading which is unreasonable in the normal setting
\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\centering}
  {\chaptertitlename\ \thechapter}{10pt}{\Huge}
  \titlespacing*{\chapter}{0pt}{-50pt}{20pt} 

%\renewcommand*{\thesection}{\arabic{section}}

% document begin
\begin{document}

Please feel free to comment on the general code to, I just started using latex.

  • Maybe one more compilation will help ? – DRi Nov 7 '16 at 9:57
  • (1) welcome, (2) how are we suppose to test this when the MWE depends in files we do not have access to? – daleif Nov 7 '16 at 9:57
  • I tired compiling more than once a couple of times. I'm a noob - what would be appropriate as a MWE? I thought the order of the packages or the use of \addcontentsline might be the problem (although I uncommented it and it was still not correct), hence the reason I only posted that. – Padawan Nov 7 '16 at 10:01
  • A MWE should be compilable by itself and should show the problem. Referring to files that you don't provide (except those that come with standard TeX distributions) is not helpful: either remove the reference if the problems still remains after removal, or include the file if its contents is essential. – gernot Nov 7 '16 at 11:47
  • Thanks for the advice, I'll make sure I add a adequate MWE next time. – Padawan Nov 7 '16 at 12:30
1

It turns out it was the order of the packages that mixed things up. I think the latex document still compiled with the defult layout and spacing. I moved my layout setup:

  \usepackage{titlesec}
     \titleformat{\chapter}[display]
     {\normalfont\huge\bfseries\centering}
     {\chaptertitlename\ \thechapter}{10pt}{\Huge}
     \titlespacing*{\chapter}{0pt}{-50pt}{20pt}

higher up in my package list and it's fine now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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