# [pdftex] Getting write page number in hyperindex

Joe Riel joe.riel at incep.com
Mon Mar 11 19:43:31 CET 2002

I'm using the hyperref package to create a hyperlinked index
and have had to write my own index macros.  Some of the
hyperlinks point to the page before the page where the
indexed item winds up.  I assume that this is due
to the TeX's page breaking technique, that is, the page number
isn't known at the time the page number is written to the idx file.

Is there a standard method for fixing this?
The code that writes the page number to the index file
looks like

\def\codeline at wrindex#1{%
\if at filesw\protected at write\@indexfile{}{%
\string\indexentry{#1{\number\value{page}}}{\number\c at CodelineNo}}%
\fi}

Thanks,

Joe Riel