TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a large latex document, compiled with pdflatex. When it compiles (I compile twice, I have tried compiling thrice) the page numbers come out as: 1/141 2/141 ... 142/141 143/141

On the bottom.It seems to be two numbers short. In the rest of the document the page numbers rise in order and all is fine.

What are the typical reasons for such a problem? Normally I know where to start trouble shooting, when it comes to this I am pretty lost.

share|improve this question
Yes! Start by editing your question and adding an example code that reproduces the problem. Without this it will be difficult for anyone to help you. – Ian Thompson Aug 2 '13 at 8:00
Welcome to TeX.SE! I'm afraid the information you've provided so far is quite inadequate for the task of diagnosing what's going on. Do you have any commands that reset or otherwise affect the page counters? You mention "in the rest of the document" -- does this mean that 143/141 is shown on the final page and 142/143 on the penultimate page? – Mico Aug 2 '13 at 8:09
Yes, 142/143 in the penultimate page. No page counter commands. I don't really know how to include more info. I have a 143+ page long document and no idea where the error may be. I only wonder who the likely suspects are ;) – PetterTB Aug 2 '13 at 8:19
I'll post the packages used. – PetterTB Aug 2 '13 at 8:20
The second number apparently comes from a faulty "lastpage" label - probably there are floats flushed out after the label. Do you use the lastpage package? – Ulrike Fischer Aug 2 '13 at 10:13

Package lastpage puts the label LastPage via \AtEndDocument at the end of the document. However, at the very end, LaTeX issues \clearpage that might cause float pages to be output after the label, see Ulrike's comment.

In this case, you can try package zref-totpages and use \ztotpages instead of \pageref{LastPage}. It uses the label LastPage of zref-lastpage. Instead of \AtEndDocument it uses the hook \AfterLastShipout of package atveryend that is called after the final \clearpage and before the .aux file is closed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.