# [texhax] \thepage issues, seems like a bug, but how could it be??

Micha Hofri hofri at cs.wpi.edu
Sat Feb 18 17:49:20 CET 2006

Dear texhackers,

Thank you for the help in solving my problem, especially those who
answered, but cruising many postings of others provided a better
understanding of my options.

I ended up using the package perpage, written by David Kastup and
suggested by Uwe Lück (below), and reference formatting suggestions of
Matthew Leingang

The alternative, using varioref was considered as well; it is neat, but
the proposed usage seemed heavier than I wished.

The only niggling remaining problem with the current implementation: if I
refer to an equation on the same page it appears, I would like to omit
the page number.  Maybe this little hack is about my size and I shall
attempt it.
----------------------------------------

So is it a bug? Now I think of it as a curious design decision.
If I understood right, the ExTeX project aims at reimplementing the TeX
kernel as well; hopefully they will avoid such a decision.

--Micha Hofri

At 20:24 on 02/13/06 Uwe Lück sent:

: What you are missing is -- briefly said -- David Kastup's
:
:     CTAN/macros/latex/contib/mics/perpage.sty
:
:     \usepackage{perpage}
:     \MakePerPage{equation}
:
: Is it a bug? It is a problem due to the way TeX works;
: are such problems bugs? (Rather not.) Pagewise
: numbering requires that, at a certain appearance of
: the counter, it is known (or provisionally guessed)
: on which page the corresponding counter things happen.
: The page number is typically decided _after_ the counter
: code has been processed, because (essentially) _first_
: the code is processed, _then_ lines are broken into
: paragraphs, _then_ another page break is chosen.
: The typical, easy enough way to solve this is problem
: is a \label; perpage is an internal, more elegant, safer variant.
:
: Another issue: what you write on having something like
:     \renewcommand{\theequation}{\thechapter.\arabic{equation}}
: -- what if a chapter spans pages n, n+1, n+2, and you
: happen to have to refer to the first equation on page n+1
: as well as that on page n+2? I wonder whether it is good
: to number equations by pages instead of by chapters at all.
: -- You might as well drop referring to chapter numbers
: at all and rather use the varioref package.
:
: -- Uwe Lueck.
:
: At 02:03 13.02.06, Micha Hofri wrote:
:
: >I am writing a largish book, using the book class.  It has many times a
: >phrase like "from Eq(x.yz) we see.." where x is chapter number and yz is
: >equation number in the chapter, and it is often not easy to find. In _my_ text
: >I go back and forth a lot to find it.
: >
: >The solution I want:  equation numbers restart on each page.
: > Reference to an equation will now be "from Eq(ppp.x) we see..." where ppp is
: > page number, and x the equation number.  But only the x's get typeset as
: > equation numbers!
: >
: >Current state of my knowledge:  easy to tell latex to restart numbering on a
: >page, using \numberwithin{equation}{page} but this has two problems
: >
: >(1)  It sets \theequation which is used both in .aux and to print the
: >equation number.  I need that value in the .aux file, to generate references,
: >but I want to print only the second part of the string, following the period,
: >so I need to get into the macro(?) that prints the equation number.
: >
: >Here is the odd part:
: >
: >(2) When latex gets to an equation which causes it to clear page and start
: >another, its \theequation has already been set as belonging to the previous
: >page, while the .aux file reflects the correct page where it was included.
: >There seems to be fuzziness about the value of \thepage.
: >Which seems odd at this stage of developmment
: >
: >What am I missing?
: >
: >
: >
: >--Micha Hofri
: >
: >_______________________________________________
: >TeX FAQ: http://www.tex.ac.uk/faq
: >Mailing list archives: http://tug.org/pipermail/texhax/