# [texhax] \index command to use my page numbers.

Uwe Lueck uwe.lueck at web.de
Mon Oct 18 11:12:42 CEST 2010

"Ted Rolle Jr." <stercor at gmail.com>, 18.10.2010 01:54:12:
> I've scanned in some books and have marked their pages with a counter called Page'.

What does this mean? Do you have each book page as an image on a TeX page, with \includegraphi..., together with \refstepcounter{Page}? Or what does "marked with a counter" mean?

Or are you working with OCR extracts from the book pages?

> TeX keeps this counter separate from page'.
> I'd like for the \index command to pick up Page' instead of 'page'.
>
> \index seems to be in the depths of TeX.

No, it's LaTeX code.

If you are stepping Page' by \stepcounter or \refstepcounter, you could try

\makeatletter
\def\@wrindex#1{%
\protected at write\@indexfile{}%
{\string\indexentry{#1}{\thePage}}%
\endgroup
\@esphack}
\makeatother

This would replace page' by Page' in an underlying LaTeX command.

This may fail when you use a third-party index package.

Another idea would to have your own \Index command, about as follows:

\newcommand*{\Index}[1]{{\let\thepage\thePage\index{#1}}}

Or if you have a package redefining \index so it has an optional argument ... the usual hacking ... may depend on that package ...

Or can't you use page' in place of Page' by some proper \setcounter{page}{...} for each book or even each page?

Curious:

Uwe