The backref
option and its variants in the hyperref
package allow to include back-references in the bibliography to the page(s) or section(s) in which a given reference was cited.
The target of the back-reference is the beginning of the page (or of the section, depending on the option) in which the citation occurs (see backref manual).
How can I get the back-reference links to point precisely at the line in which the citation key occurs in the text?
Apparently, someone had a related issue with "runners" on the side of the page, but the solution hinges on the definition of the runners themselves.
I am looking to obtain, in the back-reference, the same behavior of the link from in-text citation to reference (i.e., point to the line of the reference in question), just backwards.
Any suggestion will be appreciated.
Edit
Below is a minimal working example: the in-text citations are evenly spaced in the page and the back-reference commands in the bibliography should point to them, instead to the top of page.
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[pagebackref]{hyperref}
\begin{document}
Top of page
\vfill
\cite{Cleveland2007}
\vfill
\cite{Spence1999}
\newpage
\begin{thebibliography}{2}
\providecommand{\natexlab}[1]{#1}
\providecommand{\url}[1]{\texttt{#1}}
\expandafter\ifx\csname urlstyle\endcsname\relax
\providecommand{\doi}[1]{doi: #1}\else
\providecommand{\doi}{doi: \begingroup \urlstyle{rm}\Url}\fi
\bibitem[Cleveland(1984)]{Cleveland2007}
WS~Cleveland.
\newblock {Graphical perception: Theory, experimentation, and application to
the development of graphical methods}.
\newblock \emph{Journal of the American Statistical Association}, 79\penalty0
(387):\penalty0 531--554, 1984.
\bibitem[Spence et~al.(1999)Spence, Kutlesa, and Rose]{Spence1999}
I.~Spence, N.~Kutlesa, and D.L. Rose.
\newblock {Using color to code quantity in spatial analysis}.
\newblock \emph{Journal of Experimental Psychology: Applied}, 5:\penalty0 393,
1999.
\end{thebibliography}
\end{document}
I compile with Pdflatex, twice.
Best Answer
There are essentially three parts to the patch.
\phantomsection
before every\cite
does most of the work. These phantom sections are what the hyperrefs point back to.backref
to point the hyperlinks back to the phantom sections even if using page numbers as the labels.backref
over-rule our hyper-target (and use the start of the document instead) if it thinks there's no section to point back to.The patch has now been updated to hopefully work as expected in all situations, either when using
natbib
or not. See the post history if not interested innatbib
support. Note thatbiblatex
provides its ownbackref
mode, but does not provide direct links, and this patch does not work there (and should not be used!)Patch code (use in document preamble after loading the
hyperref
package with abackref
option; note this will fail ungracefully withouthyperref
!):And all together in the context of an MWE (based on the provided one, but extended), and now using the
biblio.bib
example file which should hopefully get found automatically (otherwise use the link to get it from CTAN):Note that this example uses
\citet
and\citep
fromnatbib
just to check that they work as expected.