8

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.

lockstep
  • 250,273
PetterTB
  • 81
  • 2
  • 1
    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 02 '13 at 08:00
  • 1
    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 02 '13 at 08: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 02 '13 at 08:19
  • I'll post the packages used. – PetterTB Aug 02 '13 at 08:20
  • 4
    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 02 '13 at 10:13

1 Answers1

15

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.

Heiko Oberdiek
  • 271,626