tikz breaks pagenumbers

Bug #1307948 reported by Torsten Scheck
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
moderncv
New
Undecided
Unassigned

Bug Description

The examples don't produce page numbers using pdflatex from Debian unstable, texlive texlive-latex-extra 2013.20140408-1.

Steps to reproduce:
cd moderncv
cp examples/template.tex examples/picture.* .
pdflatex template.tex && pdflatex template.tex
grep lastpage template.aux
# grep returns nothing

I expect something like:
\newlabel{lastpage}{{}{2}{}{section*.1}{}}

moderncv 1.40 works.
The new command \RequirePackage{tikz} in moderncviconsmarvosym.sty breaks the pagenumbers.

grep "Package: tikz" template.log
Package: tikz 2013/12/13 v3.0.0 (rcs-revision 1.142)

Workarounds:
1) In template.tex: Add \label{lastpage} before \end{document}.
or
2) In moderncv.cls: Move \AtEndDocument{\label{lastpage}} out of \AtBeginDocument
(I have no clue about the consequences, though.)

--- moderncv-1.51/moderncv.cls 2014-04-14 22:59:21.000000000 +0200
+++ moderncv-1.51_local/moderncv.cls 2014-04-15 11:11:44.000000000 +0200
@@ -153,8 +153,8 @@
           \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}}%
+\AtEndDocument{\label{lastpage}}
 \pagestyle{plain}

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

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.