# How to set pdf start page to a given label?

I'm working on a longish document and am often working on sections in the middle, so that after compiling I have to do a fair bit of digging to find the bit I was working on. After a while this can get quite tiresome, particularly with tricky bits that require multiple compilations to chase up details.

I am using the hyperref package and I know that I can set the starting page using a sequence like

\usepackage[pdfstartpage=7]{hyperref}.


While that works, I would like a method where I can leave the preamble alone and then just move around some label, say

\label{startviewinghere}.


Is this possible? As a secondary question: is it possible to control where in the starting view this anchor appears (i.e. at the top vs at the bottom)?

-

Example:

\documentclass{book}

\usepackage{zref-abspage,zref-user}
\makeatletter
\AtBeginDocument{%
\zref@refused{chap:intro}%
\hypersetup{%
pdfstartpage=\zref@extractdefault{chap:intro}{abspage}{1}%
}%
}
\makeatother

\usepackage{hyperref}
\usepackage{bookmark}

\begin{document}
\frontmatter
\tableofcontents
\chapter{Preface}

\mainmatter
\chapter{Introduction}
\zlabel{chap:intro}
\end{document}


The order does matter. hyperref sets the start page in \AtBeginDocument, therefore setting pdfstartpage must be done before. But it cannot be done in the preamble, because the .aux file is not yet read.

-
Thanks! is there a way to put the \zlabel at the bottom of the starting view? –  episanty Sep 6 '12 at 18:43
The \zlabel is only used to get the absolute page number. There is option pdfstartview to configure the view. –  Heiko Oberdiek Sep 6 '12 at 19:13

Here is a version with which will place the screen conveniently above the reference, which should be given as

\zlabel{startpoint}
\zsavepos{here}


Then, changing the corresponding code in Heiko's answer to

\usepackage{fp}
\usepackage[abspage,user,savepos]{zref}
\makeatletter
\AtBeginDocument{%
\zref@refused{startpoint}%
\FPmul\p{\zposy{here}}{1}
\FPdiv\p{\p}{65536}