Cross-Referencing – Clicking Link Does Not Jump to Exact Label Location

cross-referencinglinkslyxpositioning

When I label an equation and later have a reference to it, then by clicking the corresponding link the pdf I jump to that equation, with the equation being exactly at the top of the page. Same goes for footnotes.

But when I just insert a label in the text (for example near a theorem for the purpose to have a link to that theorem in my text) and later in the text have a reference to it and then click on the corresponding link in the pdf, I don't jump exactly to the place where the label was (meaning it isn't at the top of the page like equations ans footnotes anymore), just to right page – with the place where the label was being somewhere around the middle.

What can I do so that the link will send me to the place where the label was, with it being at the top of the page (like for equations) ?

P.S. I use LxY 2.

Best Answer

Links jump to the last anchor. Normally hyperref inserts such anchors at sensible places, but if you want a specific location you must do it yourself.

\documentclass{article}
\usepackage{hyperref,lipsum}

\begin{document}
\section{ABC}
\lipsum[1]

ANCHOR\label{A}\phantomsection\label{B}

\lipsum[2]
\newpage
A: \ref{A} to section title

B: \ref{B} to ANCHOR
\end{document}
Related Question