1

When I adjust the page countering the hyperreference under the hyperref package shows the correct page, but when the hyperlink is clicked it takes me to the page which had been indicated without the adjustment of the page counting.

Can this be rectified?

Here is a MWE:

\documentclass{article}    
\usepackage{hyperref}

\begin{document}    
\setcounter{page}{-1}    
\newpage

empty 

\newpage

test\label{test}

\newpage

test at page \pageref{test}    
\end{document}
1

1 Answer 1

5

In the point where your \label is, no counter has been incremented, so the hyperlink points to the beginning of the document.

In fact, if you take a look at your .aux file, you will see a line

\newlabel{test}{{}{0}{}{Doc-Start}{}}

One way to circumvent this is to add a \phantomsection before your label.

\documentclass{article}
\usepackage{hyperref}

\begin{document}
\setcounter{page}{-1}
\newpage

empty

\newpage

test\phantomsection\label{test}

\newpage

test at page \pageref{test}
\end{document}

The corresponding line in the .aux file is now

\newlabel{test}{{}{0}{}{section*.1}{}}

and the hyperlink points to the right place.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .