The class stores the last page number as a reference using LastPage
, written as part of \end{document}
(comment added):
\renewcommand*\enddocument{%
\let\AtEndDocument\@firstofone
\@enddocumenthook
\clearpage
\advance\c@page \m@ne
\immediate\write\@auxout{\string\newlabel{LastPage}{{\thepage}{\thepage}{}{}{}}}
% ^^^^ This writes the (last) page number as a \label to the .aux
\@checkend{document}%
\clearpage
\begingroup
\if@filesw
\immediate\closeout\@mainaux
\let\@setckpt\@gobbletwo
\let\@newl@bel\@testdef
\@tempswafalse
\makeatletter \input\jobname.aux
\fi
\@dofilelist
\ifdim \font@submax >\fontsubfuzz\relax
\@font@warning{Size substitutions with differences\MessageBreak
up to \font@submax\space have occurred.\@gobbletwo}%
\fi
\@defaultsubs
\@refundefined
\if@filesw
\ifx \@multiplelabels \relax
\if@tempswa
\@latex@warning@no@line{Label(s) may have changed.
Rerun to get cross-references right}%
\fi
\else
\@multiplelabels
\fi
\fi
\endgroup
\deadcycles\z@\@@end}
Note that the \newlabel
is written with 5 arguments. However, arguments 3, 4 and 5 are empty. This is to accommodate regular, non-hyperref
\label
s which only require two arguments, as well as when hyperref
is loaded (which writes \label
s with 5 arguments).
This LastPage
reference is used in the footer throughout the document via this macro (line 425):
\newcommand*\aa@pageof{, page \thepage{} of \pageref{LastPage}}
While this works in general, hyperref
uses the additional arguments (empty in this case) to identify markers for the last page as a hyperlink/jump. Since they're empty, hyperref
ignores the hyperlink and merely prints the (page) reference (together with a warning).
You can avoid this warning by changing the \pageref
to \pageref*
; add the following to your preamble:
\makeatletter
\renewcommand*\aa@pageof{, page \thepage{} of \pageref*{LastPage}}
\makeatother
Alternately, make all \pageref
s default to hyperlink-less references:
\let\oldpageref\pageref
\renewcommand{\pageref}{\oldpageref*}