I'm making a custom document without any chapters, sections, etc. But I also want a table of contents in my document, with entries that I define. So far, I have used

\phantomsection


and this creates an entry within my table of contents (\tableofcontents). But when I click one of these entries, the jump takes me to the exact location in the document where this phantom section was defined. Instead I want jumps that takes me to the top of that page. Ideally, the page should be jumped to and fit to screen (zoom out, typically) when I click the entry.

How can I add entries to the table of contents that jumps to the top of the page I want an entry for?

This will take you to the page anchor.

\documentclass{article}
\usepackage{hyperref}

\makeatletter
\newcommand{\phantompageref}{\def\@currentHref{page.\@the@H@page}}
\makeatother

\begin{document}
\tableofcontents
\newpage
\rule{1pt}{.4\textheight}

\phantompageref

\rule{2pt}{.4\textheight}
\end{document}


This links to the very top of the page.

\documentclass{article}
\usepackage{everypage}
\usepackage{hyperref}

\makeatletter
\newcommand{\phantompageref}{\def\@currentHref{pagetop.\thepage}}
\makeatother

\begin{document}
\tableofcontents

\newpage
\rule{1pt}{.4\textheight}

\phantompageref

• This takes me to a top of my document, not on the page I have \phantompageref together with \addcontentsline. And it will not jump to the page border of my document, instead it jumps to the top of my header on this page (refer to the line which 5 points to in this figure: en.wikibooks.org/wiki/LaTeX/Page_Layout#Page_dimensions). The example above will not jump at all. – telephone Jan 28 '17 at 11:46
• Thanks! But it will not compile because of "Undefined control sequence": pagetop.\@the@H@page. Looks like we are closer, though :) – telephone Jan 28 '17 at 14:51