[pdftex] ambiguous \pdfpageref

Heiko Oberdiek oberdiek at uni-freiburg.de
Tue Dec 7 19:22:28 CET 2004


On Tue, Dec 07, 2004 at 10:30:34AM +0100, Alexander Grahn wrote:

> within a latex macro package I need access to the PDF page object
> number. It can be accessed using the command
>     \pdfpageref\value{page}\space 0 R
> But I run into problems if a roman numbered page `i' is followed by
> an arabic numbered page `1'.
> 
> In both cases `\value{page}' yields `1' and consequently `\pdfpageref'
> yields the same PDF page object number, although there are two physically
> distinct pages.
> 
> How can I solve this problem?
> 
> Example:
> 
> \documentclass{article}
> \begin{document}
> \pagenumbering{roman}
> Page object number: \pdfpageref\value{page}\\
> \newpage
> \pagenumbering{arabic}
> Page object number: \pdfpageref\value{page}\\
> \end{document}

\documentclass{article}
\usepackage{count1to}
\newcommand*{\CurrentPageObject}{%
  \pdfpageref\numexpr\count 1 + 1\relax
  \space 0 R%
}
\begin{document}
\pagenumbering{roman}
Page object number: \CurrentPageObject\\
\newpage
\pagenumbering{arabic}
Page object number: \CurrentPageObject\\
\end{document}

Yours sincerely
  Heiko <oberdiek at uni-freiburg.de>
-- 



More information about the pdftex mailing list