I tend to use the memoir
class together with the hyperref
package, in order to have my table of contents, the lists of tables and figures, and the bibliography be hyperlinked. While all links to chapters, sections, and the like link to the correct positions in the document, the links to the table of contents, the lists of tables and figures, and the bibliography appear too low, approximately where the first item in these respective listings would be placed, but not just to the above-left of these lists' headings. Here is a minimal working example:
\documentclass{memoir}
% using the memoir class here is necessary
% for all the desired hyperlinks to be created
\usepackage{hyperref}
\begin{document}
\tableofcontents
\section{A section}
This is the only section.
\listoftables
\listoffigures
\begin{thebibliography}{9}
\end{thebibliography}
\end{document}
(It might be necessary to enlarge the display in your pdf-reader to notice this effect.)
Is it possible to correct the hyperlink targets so that they point directly to the respective headings (here, "Contents", "List of Tables", "List of Figures", and "Bibliography")? (Note: I am aware of the hypcap
package but not sure whether/how it can be used to address this.)
Best Answer
The following patch uses
etoolbox
. Add it to your document preamble after loadinghyperref
, and it will correct the hyper-links:The reason behind the faulty linking stems from the placement of
\phantomsection
inside the patched macros. It is placed after the respective headings have been created, causing the "low hyper target."The
thebibliography
environment sets a\chapter*
, which I've left as is in terms of its hyper-linking. As such, it inserts\phantomsection
before setting the chapter space and header. However, as this is the default for all chapters, it seemed suitable.