# Wrong total number of pages in page numbering

My document is 39 pages long. However, the total page number (after numerous processing) is 36. I thus have page 1/36, 2/36, ... 36/36, as well as 37/36, 38/36, and 39/36.

Page 36 matches with the end of my text: the end of page 36 and pages 37 to 39 are filled with (floating) tables only.
If I add enough content in order to have regular text displayed after all floating tables, the numbering becomes right, i.e., the total page number equals 39.

I have tried to add \null after the last floating table, but it has no effect.

The total number of pages is computed via the \@totpages variable that is defined as following in the .cls file I use. (This class is the template of the journal I want to publish in, based on the article class.)

\def\@totpages{0}
\AtEndDocument{\immediate\write\@auxout{\string\gdef\string\@totpages{\thepage}}}


Question: How to force the total of page number to be compute after the last float being printed?

• If needed, I can provide a MWE, but I use an exotic class pimped by the journal I want to publish in. So maybe the solution is so obvious, I do not have to create such example ! N.B.: The exotic class is based on article, and loads morefloats, as well as stfloats floats packages. – ebosi Jun 10 '16 at 8:37
• Do you use the lastpage package to get the label? – Ulrike Fischer Jun 10 '16 at 9:16
• Your comment made me browse class definition - what is indeed a good idea to understand how is totalpage generated! Anyway, the footer is defined as \thepage/\@totpages where \@totpages is computed as following: first \def\@totpages{0} and then \AtEndDocument{\immediate\write\@auxout{\string\gdef\string\@totpages{\thepage}}} (all these commands are in class definition) – ebosi Jun 10 '16 at 9:23
• load lastpage and then redefine the footer to use \pageref{LastPage}. – Ulrike Fischer Jun 10 '16 at 9:27
• @UlrikeFischer: \RequirePackage{lastpage} + \def\@totpages{\pageref{LastPage}} does the job! Would you mind writing an answer I could accept? (My next issue is to let my modifications be accepted by journal editor!) – ebosi Jun 10 '16 at 9:39

Load the lastpage package and then redefine the footer or \@totpages to use \pageref{LastPage}.