12

So, I was doing something like this:

\cfoot{\color{color2}\itshape John~~Doe}

to get my name centered on bottom of each page. Now I'd like to have it in one line with page number. Now it looks like that:

                 PAGE/PAGE
John Doe

And I'd like to look it like this:

John Doe         PAGE/PAGE

My name, and numbered page in one line. With \lfoot or \cfoot I can't achieve that.

Also, how to start page numbering from page 2? \setcounter{page}{2} does not works. Thanks in advance.

Minimal working example (\newpage's were added ONLY to force page numbers - I don't use them in original document!):

\documentclass[11pt,a4paper]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{orange}
\usepackage[scale=0.75]{geometry}
\usepackage{fontspec}

\firstname{John}
\familyname{Doe}
%\title{}
\address{street}{postcode city}
\mobile{+4~(11)~311~111}
%\phone{+2~(345)~678~901}
%\fax{+3~(456)~789~012}
\email{[email protected]}
%\homepage{www.johndoe.com}
\extrainfo{additional info}
\photo[64pt][0.4pt]{picture.png}
%\quote{}

\cfoot{\color{color2}\itshape John~~Doe}

\begin{document}

\section{Expirience}

\subsection{My work}
\cvcomputer{One}{Bla, Bla, Bla}{Two}{Bla,Bla,Bla}

\newpage

\section{Foreign Languages}
\cvitemwithcomment{English}{Fluent}{Some description here}

\newpage

\section{Other Skills}
\cvitemwithcomment{Computers}{Very good}{Some description here}

\end{document}
0

1 Answer 1

11

It seems to be a bug of moderncv. moderncv puts the page number in a \parbox but doesn't justify them vertical. So you can use the following redefinition:

\makeatletter
\renewcommand*{\nopagenumbers}{\@displaypagenumbersfalse}
\AtEndPreamble{%
  \AtBeginDocument{%
    \if@displaypagenumbers%
      \@ifundefined{r@lastpage}{}{%
        \ifthenelse{\pageref{lastpage}>1}{%
          \settowidth{\pagenumberwidth}{\color{color2}\addressfont\itshape\strut\thepage/\pageref{lastpage}}%
          \fancypagestyle{plain}{%
            \fancyfoot[r]{\parbox[t]{\pagenumberwidth}{\color{color2}\addressfont\itshape\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}}
\makeatother

enter image description here

5
  • Thanks. This worked like a charm. And how to force moderncv to start counting pages from page 2? I think I could e-mail author of moderncv to fix this bug, of course by pointing him to your message.
    – Teddy
    Commented Apr 20, 2012 at 21:30
  • 1
    @Teddy: Try at the first page \thispagestyle{empty}. It removes all headers and footers. If you want to suppress only the page numbering you have to set \fancyfoot. Commented Apr 20, 2012 at 21:41
  • Bingo! Perfect. :) \thispagestyle{empty} was what I needed.
    – Teddy
    Commented Apr 20, 2012 at 21:47
  • I've e-mailed autor of moderncv about this. It seems that we still have no official fix for this. I'd be very happy if I could remove above code suggested by Marco from my .tex document.
    – Teddy
    Commented Jul 20, 2012 at 22:06
  • I added this to my preamble and produced no effect. Still get the regular page numbering without "John Doe". Anything that needs deactivating on the regular moderncv template?
    – lomper
    Commented Oct 31, 2023 at 11:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .