2

I would like to pass specific options to a moderncv document.

The problem is options are already loaded by the moderncv class (file /usr/share/texlive/texmf-dist/tex/latex/moderncv/moderncv.cls on debian).

This moderncv.cls file contains an hyperref setup section:

% hyper links (hyperref is loaded at the end of the preamble to pass options required by loaded packages such as CJK)
\newcommand*\pdfpagemode{UseNone}% do not show thumbnails or bookmarks on opening (on supporting browsers); set \pdfpagemode to "UseOutlines" to show bookmarks
\RequirePackage{url}
\urlstyle{tt}
\AtEndPreamble{
  \pagenumbering{arabic}% has to be issued before loading hyperref, as to set \thepage and hence to avoid hyperref issuing a warning and setting pdfpagelabels=false
  \RequirePackage[unicode]{hyperref}% unicode is required for unicode pdf metadata
  \hypersetup{
    breaklinks,
    baseurl       = http://,
    pdfborder     = 0 0 0,
    pdfpagemode   = \pdfpagemode,
    pdfstartpage  = 1,
    pdfcreator    = {\LaTeX{} with 'moderncv' package},
%    pdfproducer   = {\LaTeX{}},% will/should be set automatically to the correct TeX engine used
    bookmarksopen = true,
    bookmarksdepth= 2,% to show sections and subsections
    pdfauthor     = {\@firstname{}~\@lastname{}},
    pdftitle      = {\@firstname{}~\@lastname{}\notblank{\@title}{ -- \@title}{}},
    pdfsubject    = {Resum\'{e} of \@firstname{}~\@lastname{}},
    pdfkeywords   = {\@firstname{}~\@lastname{}, curriculum vit\ae{}, resum\'{e}}}}

I do not want to modify this file because it will be erased by updates.

I would rather enter hypersetup options in my .tex document and want them to override the default options described in the .cls file.

In my .tex document, \hypersetup{} is not recognized. And if I add \usepackage{hyperref} I have LaTeX Error: Option clash for package hyperref. because hyperref is called twice (in .cls and in .tex). Here is the complete log:

The package hyperref has already been loaded with options:
  []
There has now been an attempt to load it with options
  [unicode]
Adding the global options:
  ,unicode
to your \documentclass declaration may fix this.

I added "unicode" to \documentclass[11pt,a4paper,roman,unicode]{moderncv} but I still have the same error.

2
  • the code you show is loading hyperref \AtEndPreamble{ so you can load it before then (include unicode option to avoid a clash) or use \hypersetup inside \AtEndPreamble so it is executed later, after hyperref is loaded Jun 19, 2018 at 9:10
  • Ok I was passing "unicode" to documentclass instead of hyperref. Change your comment to an answer and I will accept it. Thanks
    – ppr
    Jun 19, 2018 at 9:14

1 Answer 1

4

The code you show is loading hyperref \AtEndPreamble{ so you can load it before then (include unicode option to avoid a clash) or use \hypersetup inside \AtEndPreamble so it is executed later, after hyperref is loaded

2
  • Simply adding "unicode" option to the hyperref call seems also to work. Of course it is better to use \AtEndPreamble to avoid possible clash.
    – ppr
    Jun 19, 2018 at 9:43
  • \AtEndPreamble{\hypersetup{ draft=true }} does disable links from moderncv for me. Be aware though that some PDF viewers still show the hand cursor when hovering links, for example Preview on OS X.
    – mknaf
    Jan 25, 2020 at 19:38

You must log in to answer this question.

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