[texhax] Am I on the lastpage?
Schwartz, Steven J
s.schwartz at imperial.ac.uk
Sun May 19 18:39:26 CEST 2013
(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".
I have looked briefly at the most recent lastpage package and also the documentation for pageslts, but I think both are more concerned with accessing information via labels.
There is a manual workaround by inserting a \pagebreak should this happen, but since I distribute this .cls to colleagues who are not all TeXies, I'm looking for an automated self-contained approach. And one which doesn't rely on too many external packages and such (which is why my .cls borrowed ideas from lastpage, with proper credit, rather then used the ctan package).
Anyone have any suggestions?
Thanks
Steve
--------------------------------------------------------------------
Professor Steven J Schwartz Phone: +44 (0)207 594 7660
Head, Space & Atmospheric Physics Fax: +44 (0)207 594 7772
The Blackett Laboratory Email: s.schwartz at imperial.ac.uk
Imperial College London Office: Huxley 6M67A
London SW7 2AZ, UK Web: www.sp.ph.ic.ac.uk/~sjs
--------------------------------------------------------------------
More information about the texhax
mailing list