BibLaTeX backref links to wrong page using hyperref
The template/class you are using is loading hyperref
. But hyperref should be, with some exceptions, loaded last. The documentation of biblatex
clearly says, that backreferencing will only work, when hyperref is loaded after biblatex.
You have to either delete everything related to hyperref in the .cls
and input it in your own preamble.
You should never modify a class or package file, since every change will be lost when updating. In your template, modifying is not only encouraged, but needed to get everything right. This can't be a quality mark. I would drop this template entirely.
Concerning the whitespace in your references:
You need to be careful when (re-)defining own command, since LaTeX treats the end of line as a single space. You can cover those with a comment character (%
). Read more about it at What is the use of percent signs (%) at the end of lines?
For example, the first space after the opening bracket (_
is covered/removed here:
\AtEveryCitekey{%<- This % is needed
\ifciteseen{}{\defcounter{maxnames}{6}\clearfield{namehash}}}
You can easily find things like that on your own by using the methods to prepare a minimal working example.
After numerous months of battling with this and trying all manners of suggested solutions, I finally found a method that works for me. My thesis class uses "report" (as opposed to "book" or "article") and my frontmatter has no page numbers. There are 8 pages of frontmatter (this was important for diagnosing). My table of contents and list of figures have roman page numbers, and the rest of the thesis has arabic page numbers. Just like the OP, biblatex backrefs to pages 1-8 would link to the corresponding frontmatter page instead of the correct one. Backrefs to page 9 and beyond would link correctly.
My solution relies on resetting the page counter. I know this is frowned upon, but let me illustrate, as I reset the page counter for the roman pages, not the arabic ones:
\singlespacing{\maketitle}
%start counting pages in roman, but they won't show since dedication et c. are empty pagestyle
\cleardoublepage
\pagenumbering{roman}
\include{dedication} % include a dedication.tex file
\include{acknowledgements} % include an acknowledgements.tex file
\include{abstract} % include the abstract.tex file
\cleardoublepage
\setcounter{page}{1} % resets the ROMAN page counter to 1 for the TOC
\tableofcontents % generate and include a tbl of contents
\listoffigures % generate and include a list of figures
\cleardoublepage
\pagenumbering{arabic} %change to arabic counting. Resets to 1 automatically
\doublespacing %works right through thesis
%now include the latex source files for each of the chapters
\include{chapter1-intro}
\include{nextchapter}
...
\cleardoublepage
...
\printbibliography[heading=bibintoc] % ensure the bib is linked in TOC
\end{document}
The key was to start the page numbering right after the title page. The dedication, acknowledgements, abstract et c. were all of empty pagestyle, so the page numbers did not show. I then reset the page number at the TOC, which is the first time the roman page numbers display. I then set the page numbering style to arabic before including the actual content.
For reference, my biblatex import looks like this:
\usepackage[natbib=true,
style=authoryear-comp,
hyperref=true,
backend=biber,
maxbibnames=99,
firstinits=true,
uniquename=false,
uniquelist=false,
useprefix=true, %for `van', `von' et c.
maxcitenames=1,
parentracker=true,
url=false,
doi=false,
isbn=false,
eprint=false,
backref=true,
bibencoding=auto,
sortcites=false,
sorting=anyt, %sort the citations by increasing year (oldest first)
]{biblatex}
Hope this helps!