[texhax] Am I on the lastpage?

Ulrike Fischer news3 at nililand.de
Mon May 20 11:13:59 CEST 2013


Am Sun, 19 May 2013 16:39:26 +0000 schrieb Schwartz, Steven J:

> (I tried to send this a week ago but haven't seen it, so perhaps it got lost)
 
> Dear All,
 
> I have a class file that uses fancyhdr and latex's leftmarks to
> set footers depending on the context. It's for exams, so it sets
> footers to "Turn to next page" or "This question continues ..."
> or whatever, and on the last page it's supposed to write "End of
> Examination". To accomplish this last task, I borrowed the logic
> from the lastpage package. That is, AtEndDocument I write out a
> label called lastpage, and in my header-building code I use an
> ifthenelse construction to compare \thepage with
> \pageref{lastpage}.
 
> This works most of the time, but fails when there is only a small
> paragraph on the last page. This is due to the well-known TeX
> behaviour which results (see the TeX FAQ) in \thepage being
> "almost always wrong in the first paragraph of a page". 

\thepage can be wrong in the first paragraph in the text *body* of a
page but it is always correct when header and footers are added to
the page (as the headers and always footers has to (and do) show the
correct page number). So if you are really using fancyhdr and do the
comparison in the footer it should work -- which means that your
code is probably faulty. 


-- 
Ulrike Fischer 
http://www.troubleshooting-tex.de/



More information about the texhax mailing list