Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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)?

share|improve this question

2 Answers 2

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.

share|improve this answer
    
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}
    \FPadd\pointoffset{\p}{350}
  \hypersetup{%
    pdfstartpage=\zref@extractdefault{startpoint}{abspage}{1},%
    pdfstartview={XYZ 0 \pointoffset 1}
  }%
}
\makeatother

works fine. I'm aware that there are a number of technical difficulties which I'm working on (particularly that "here" might not be defined, and the need for two different labels) for a future update.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.