latexpage-numbering

Set the last page number to a fixed value in moderncv


How do I set/define the last page of a moderncv documentclass?

I know, that I can change the starting page count by \setcounter{page}{13} which let the document start with 13. However, moderncv displays the pages in the footer in a style like 13/17 for a five page document. Assuming, the CV is part of a larger project, how can I set the "last page" to a fix number like: 13/42?

Minimal example:

\documentclass[11pt,a4paper,sans]{moderncv}

\moderncvstyle{casual}
\usepackage[utf8]{inputenc}

\firstname{}
\familyname{}
\title{Curriculum Vitae}

\begin{document}
  \makecvtitle
  \setcounter{page}{13}

  Should be 13/42 not 13/17!
  \newpage
  Should be 14/42 not 14/17!
  \newpage
  Should be 15/42 not 15/17!
  \newpage
  Should be 16/42 not 16/17!
  \newpage
  Should be 17/42 not 17/17!
\end{document}

Solution

  • You could replace \pageref{lastpage} with 42 in the definition of the footer:

    \documentclass[11pt,a4paper,sans]{moderncv}
    
    \moderncvstyle{casual}
    \usepackage[utf8]{inputenc}
    
    \firstname{}
    \familyname{}
    \title{Curriculum Vitae}
    
    
    \begin{document}
    
    \fancyfoot[r]{\parbox[b]{\pagenumberwidth}{\color{color2}\pagenumberfont\strut\thepage/42}}% the
    
      \makecvtitle
      \setcounter{page}{13}
    
      Should be 13/42 not 13/17!
      \newpage
      Should be 14/42 not 14/17!
      \newpage
      Should be 15/42 not 15/17!
      \newpage
      Should be 16/42 not 16/17!
      \newpage
      Should be 17/42 not 17/17!
    \end{document}