# [texhax] Incrementing a counter on a page boundary?

Robin Fairbairns Robin.Fairbairns at cl.cam.ac.uk
Wed Aug 18 17:43:27 CEST 2004

```william adams wrote:

> On Wednesday, August 18, 2004, at 10:28  AM, Adrian F. Clark wrote:
>
> > I'm preparing a LaTeX document which involves per-page numbering.  In
> > other words, I need "1a" "1b" etc on p1, "2a" "2b" etc on p2, and so
> > on.
> >
> > Thanks to David Kastrup's excellent perpage.sty, I am able to handle
> > what I thought was the difficult part, the "a", "b" part of the
> > numbering scheme.  However, I'm struggling to get the page number to
> > come out right: in particular, \thepage can give a value that is one
> > too
> > small at the top of a page -- presumably because of the way TeX "cuts
> > the scroll".  Does anyone have a solution to this, perhaps a variation
> > on perpage.sty that increments rather than resets a counter?  I'm
> > afraid
> > the wizardry in perpage.sty is beyond me these days...

you needn't feel embarrassed about that...

> If you can switch to using the memoir class, its
> ``\strictpagechecktrue'' command will sort out most such instances ---
> in some places though one must add a ``\parnopar'' to force a paragraph
> to break (without changing its appearance) at a page boundary.
>
> Alternately, one can write out the page number and read it back in
> after a second run.

or use a label, as someone else has suggested.  they'll multiply
themselves, of course.

> Or, perhaps you should look at adapting the ``footmisc'' code which has
> a per-page option for numbering footnotes....

footmisc's code is pretty simple-minded, by comparison with
perpage.sty; it certainly deals explicitly in page numbers as well as
things running per page, so it might be practicable to hack it...

```