Is there a way to get the number of pages shipped out so far? To be clear, I want to count "physical" output; I'm not interested in logical page numbers we typically find in the footer or header.
My current implementation simply hacks into \shipout
, as shown below, but this will not work if some package ships out via \primitive\shipout
(as, ahem, my package does). So to rephrase the question once more, I need to count the number of times the \shipout
primitive was called.
\def\shipout{%
\global\advance\mmz@realpage1
\mmz@orig@shipout
}%
I'm aware of the everyshi
package and I plan to use it if my question ends up with a negative answer — so that the half-working hack is at least performed in an "official" way — but as I only need to count the number of output pages rather than modify them in any way, I thought to ask if there's a less invasive and more precise way to do this.
At the end of the day, I'm looking for a solution that would work across engines and formats, but at this point, I welcome hints for a partial solution just as much.
Background: I'm developing an externalization package memoize
, currently available at GitHub. The package externalizes all graphics in a single compilation, and it achieves that by dumping the externalized pages into the document itself. In the next stage, these pages are separated from the regular output, and to do that, I need to know which pages these are, in terms of a real, physical page number.
\shipout
. So either you cooperate with packages that change it or you're doomed.