I'm using the pagesel package to output only selected parts of a large document. The page numbers in that document are not absolute page numbers, but pagesel (quite rightly) uses absolute page numbers. So what I'd like to do is, within my document, put a command to list the absolute page number on my TeX log. The pagesel package uses the counter ps@count to keep track of the absolute page number, so I've tried the following two ideas, but neither works:

\typeout{Absolute Page \value{ps@count}} 

\typeout{Absolute Page \theps@count} 

Could someone fix one of these? (I see from another answer How to find absolute page number as an integer? that I could use the zref package, but that seems a lot of work when pagesel already has the counter that I want.)


If you load the pagesel package without specifying any selection options (that's the main purpose of the package), then it virtually "unloads" itself. From the pagesel documentation (section 1 Usage, p 2):

Depending on the options the package works in two modes:

  1. If no page selecting option is present, so the package ignores the other options and finishes itself. So no page will be suppressed by the package and auxiliary files will be written.
  2. With at least one page selecting option the specified pages are selected and the other are suppressed. The default for this mode is that auxiliary will not be overwritten. (This can be changed by an option.)

You can load pagesel and specify that all pages should be written out using the - option as a page range. Just as an example:

\usepackage[-]{pagesel}% http://ctan.org/pkg/pagesel
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\EveryShipout{\typeout{Absolute page \theps@count.}}

will output in your .log (somewhere):

ABD: EveryShipout initializing macros
Absolute page 1.

Absolute page 2.
[2] ) 

Note that pagesel uses everyshi to determine the page count at shipout time. That is the only reliable time that you can use the page counter, so you should too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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