Hyperref link placement: alignment to left page border and top of page

user14996 wrote:

(a) Is is possible to have certain hyperref-hyperlinks [...] point to the very left border of the page, not to the interior?

and

(b) If, in addition, one could make hyperlinks point not only to the left page border but also to the top left corner of the respective page, that would be a useful option. [...]

First I agree with the remark of canaaerus:

Just imagine the user has chosen a high zoom level and you force a jump to the top-left of the page. That point might be very far from the referenced position and the user wont be able to see it.

An alternative answer to the questions: The PDF format also supports other "view" settings for destinations. The default in hyperref is XYZ, X and Y means the anchor position and Z the zoom level (with default null meaning unchanged zoom level). If you want to get the left page border and do not mind also getting the right page border, then you can use

\hyperref{pdfview=FitH}% or FitBH that removes some white space

(Drivers hpdftex and other calculate the Y position from the current position of the anchor.)

You get the whole page with

\hyperref{pdfview=Fit}

But be aware that the user might be annoyed by having to switch the zoom level, if he cannot read the text because of a small window/screen.


In my, admittedly simplistic, world view, something like you request should not be necessary. The document should point its links to the actual target position and the viewer application can then make a sensible choice of where to jump. That choice will also depend on the current view mode and zoom level.
Just imagine the user has chosen a high zoom level and you force a jump to the top-left of the page. That point might be very far from the referenced position and the user wont be able to see it.

Now the idea to do it anyway, is to put the label mark at the top left. I got until this point:

\documentclass{memoir}

\usepackage[colorlinks]{hyperref}

\usepackage{lipsum}

\usepackage[absolute]{textpos}
\setlength\TPHorizModule{1cm}
\setlength\TPVertModule{1cm}
\textblockorigin{0mm}{0mm}

\newcounter{lbl}
\def\plabel#1{\begin{textblock}{0}(0,0)\refstepcounter{lbl}\label{#1}\end{textblock}}

\begin{document}
\chapter{The first chapter}
\lipsum[1-3]
\section{A section}
Here a label is set!\plabel{lbl1}

\chapter{The second chapter}
Here is a link up.{\Huge(\ref{lbl1})}
\end{document}

First problem is, that the textblock is always at the top left corner of the first page. So there you need to use some other method of absolute positioning. (I bet there are a dozen ways to do that)

Second thing that still needs fixing, is that now the label references the lbl counter. (I think this is similar to the hypcap packages approach.) So you need to fix the reference.

\def\thelbl{\thesection}

would for example help. But maybe you don't only want to reference sections.