19

Whenever I compile a CV with moderncv, I get four warnings by hyperref. There don't seem to be any serious problems connected to them, yet they bug me. I like my documents to compile without warnings. How can I avoid these warnings? (Preferably without patching moderncv.cls itself, I'd rather add a few lines in each of my CVs.)

MWE:

\documentclass{moderncv}

\firstname{John}
\familyname{Doe}

\begin{document} 
\maketitle

\cvline{always}{King of the World}

\end{document}

The warnings:

Package hyperref Warning: Option `pdfpagelabels' is turned off
(hyperref)                because \thepage is undefined.

Package hyperref Warning: Option `baseurl' has already been used,
(hyperref)                setting the option has no effect on input line 6.

Package hyperref Warning: Option `pdfpagemode' has already been used,
(hyperref)                setting the option has no effect on input line 6.

Package hyperref Warning: Option `pdfstartpage' has already been used,
(hyperref)                setting the option has no effect on input line 6.

UPDATE:

Version 0.19 (2012/02/06) of moderncv only produces these warnings, the latter of which appears to be new:

Package hyperref Warning: Option `pdfpagelabels' is turned off
(hyperref)                because \thepage is undefined.

Package hyperref Warning: Option `pdfpagelabels' has already been used,
(hyperref)                setting the option has no effect on input line 6.
4
  • 2
    <rant>I find it easier to not to use moderncv than fix all its bugs.</rant> Nov 15, 2011 at 12:50
  • 1
    @AndreyVihrov: Well, but not every LaTeX user has the level of expertise and the typesetting skills you have ;)
    – doncherry
    Nov 15, 2011 at 12:52
  • 1
    I put together a smashing custom CV, and I'm hardly an expert. You should give it a go!
    – qubyte
    Nov 15, 2011 at 12:57
  • I'm voting to close this question as too localized because it doesn't apply to current systems anymore (cf. my answer). It makes my heart bleed to have a question of mine closed for the first time on tex.sx, but alas ...
    – doncherry
    Oct 16, 2012 at 2:44

4 Answers 4

17

You can avoid the first warning by setting the option before \documentclass:

\PassOptionsToPackage{pdfpagelabels=false}{hyperref} 

You can't avoid the other three without patching moderncv. moderncv sets some hyperref options incorrectly in a \AtBeginDocument.

4
  • Do you have any idea why these incorrect options aren't patched? The latest version of moderncv was deployed not even a week ago.
    – doncherry
    Nov 16, 2011 at 11:40
  • Probably nobody told the author about the problem. Did you write him? Nov 16, 2011 at 12:55
  • I just e-mailed him. Let's see what happens.
    – doncherry
    Nov 16, 2011 at 15:07
  • @UlrikeFischer Can you please enumerate the incorrect hyperref options set by moderncv. This will be helpful to fix them by passing the correct arguments using the PassOptionsToPackage trick that you propose here. Feb 14, 2019 at 20:56
5

You may deactivate all warnings of package hyperref before loading the class:

\RequirePackage{etoolbox}
\pretocmd\PackageWarning{%
  \edef\pkgname{#1}\edef\hyperrefname{hyperref}%
  \ifx\pkgname\hyperrefname
    \expandafter\gobblethree
  \fi
}{}{\undefined}
\newcommand*{\gobblethree}[3]{}

\documentclass{moderncv}

\firstname{John}
\familyname{Doe}

\begin{document} 
\maketitle

\cvline{always}{King of the World}

\end{document}

Nevertheless moderncv does some strange things (e.g. forcing option pdftex).

2
  • While this works, I'd still like to get actual warnings by hyperref, I guess I should've specified that; i.e. I'm looking for a way to rule out the reasons for the warnings.
    – doncherry
    Nov 16, 2011 at 11:38
  • In this case best would be to fix the buggy class, e.g., write a bug report to the author. Nov 16, 2011 at 14:56
4

With the advent of moderncv version 1.1.3, all of these warnings have disappeared. If you still get them, update your moderncv!

Changelog:

version 1.1.3 (10 Aug 2012) - corrected a longstanding issue causing hyperref to issue two warnings regarding its "pdfpagelabels" option, as pointed out and solved by P. Leifeld (launchpad bug #1035466).

The minimal code requirements seem to have changed as well, you now need to declare a \moderncvstyle; \maketitle now is called \makecvtitle, which isn't necessary for an MWE however (I don't recall if it was earlier or if I had put it there for looks).

\documentclass{moderncv}

\moderncvstyle{casual}

\firstname{John}
\familyname{Doe}

\begin{document} 

%\makecvtitle

\cvline{always}{King of the World}

\end{document}
3

(A bit late, but it might still be helpful for someone...)

Using the latest version (1.0, released in March 2012) of moderncv from CTAN removed all but the first warning.

For some reason, setting the pdfpagelabels option with \PassOptionsToPackage did not work for me. I finally decided to use the silence package to silence all warnings from the hyperref package, by placing the following code before \documentclass:

\RequirePackage[]{silence}

\WarningsOff[hyperref]

It is not perfect, but I consider it acceptable until moderncv gets better at playing nice with others...

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