[texhax] Am I on the lastpage?
Schwartz, Steven J
s.schwartz at imperial.ac.uk
Mon May 20 01:05:06 CEST 2013
Reinhard,
Thanks for the reply. I think it's a very good reply, but perhaps not to the question I posed. See below:
Reinhard Kotucha wrote on 2013-05-19:
----------------
> On 2013-05-19 at 16:39:26 +0000, Schwartz, Steven J wrote:
>
>> (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?
>
> texdoc atveryend
I spent some time getting my code to talk to this package, only to realise (I think) that it doesn't solve my problem. It DOES provide a robust way to find out what the number of the last page of the document is, by writing it, e.g., as a \newlabel, to the aux file. But what I need to be able to do somehow is to compare that last page number with the number of the page on which the currently-being-processed text will appear. As \thepage is unreliable, I'm stuck, or perhaps missing something obvious.
In short, the title of this thread expresses my problem. I don't want to know what the number of the lastpage is (although I appreciate that atveryend does a better job than lastpage); I want to know if I'm on it.
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