Comment 1 for bug 1307948

Revision history for this message
stehpan (stehpan) wrote :

I'm not sure if \RequirePackage{tikz} is the culprit in moderncv-1.51:
I have moderncv-1.51 installed with TexLive 2013 on Windows 7, compiling with:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (TeX Live 2013/W32TeX) (format=pdflatex 2014.2.25) 23 JUL 2015 18:28
This gives me (correctly) the pagenumber.
Compiling the same document also with moderncv-1.51 using TexLive 2014:
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014/W32TeX) (preloaded format=pdflatex 2015.7.23) 23 JUL 2015 16:09
Does not print the pagenumbers.
Compiling the same document also with moderncv-1.51 using TexLive 2015:
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/W32TeX) (preloaded format=pdflatex 2015.7.23) 23 JUL 2015 19:49

I could figure out that the label is not added if the
\AtEndDocument{\label{lastpage}}
is within the \begin{document}. So moving it inside the Preamble fixes the problem for TexLive 2014 and 2015. As you described it in your patch. I enhanced your patch a bit so that the label is only set when the pagenumber is wanted.

--- moderncv.cls 2015-07-23 19:23:42.487668400 +0200
+++ moderncv-1.5.1-patched.cls 2015-07-23 20:14:06.344643700 +0200
@@ -145,16 +145,17 @@
 \newif\if@displaypagenumbers\@displaypagenumberstrue
 \newcommand*{\nopagenumbers}{\@displaypagenumbersfalse}
 \AtEndPreamble{%
- \AtBeginDocument{%
- \if@displaypagenumbers%
- \@ifundefined{r@lastpage}{}{%
+ \if@displaypagenumbers%
+ \AtEndDocument{\label{lastpage}}
+ \AtBeginDocument{%
+ \@ifundefined{r@lastpage}{\ClassWarning{moderncv}{LaTeX Warning: r@lastpage is undefined. Label:lastpage on last page is missing?}}{%
         \ifthenelse{\pageref{lastpage}>1}{%
           \newlength{\pagenumberwidth}%
           \settowidth{\pagenumberwidth}{\color{color2}\addressfont\itshape\strut\thepage/\pageref{lastpage}}%
           \fancypagestyle{plain}{%
             \fancyfoot[r]{\parbox[b]{\pagenumberwidth}{\color{color2}\pagenumberfont\strut\thepage/\pageref{lastpage}}}}% the parbox is required to ensure alignment with a possible center footer (e.g., as in the casual style)
- \pagestyle{plain}}{}}%
- \AtEndDocument{\label{lastpage}}\else\fi}}
+ \pagestyle{plain}}{}}}%
+ \else\fi}
 \pagestyle{plain}

 % reduced list spacing