3

Here is a MWE:

\documentclass{moderncv}
\usepackage{hyperref}    

\begin{document}
\cvitem {some text}{\href{url}}{text}
\end{document}

The problem I get is:

Option clash for package hyperref

and also a second error:

Paragraph ended before \\cvitem was complete.

What have I made wrong?

3
  • moderncvalready loads hyperref package with certain options. Hence this error.. If you want to make some changes, please use \hypersetup. No need of loading hyperref again.
    – user11232
    Sep 2, 2015 at 9:26
  • I corrected doument to document as it was clearly a typo. But your code remains uncompilable. AFAIK the command \cvitem has just two arguments. You use three here. Please have a look on some other examples in order to learn the right syntax and do not load hyperref a second time.
    – LaRiFaRi
    Sep 2, 2015 at 9:29
  • 2
    @LaRiFaRi And \href has two arguments missing one. Thus, moving the second curly closing brace to the end after {text} is probably the solution: \cvitem{some text}{\href{url}{text}}. Sep 2, 2015 at 9:36

1 Answer 1

5

moderncv loads hyperref package by itself with the option unicode. These are the lines from moderncv.cls.

\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}}}}

Hence, if you load the package again, the error

Option clash for package hyperref

is generated. Hence remove the line \usepackage{hyperref} from your file. On the other hand, if you want to change some settings for hyperref, use \hypersetup at appropriate place in your file.

Similarly the \cvitem is defined as (in moderncv.cls)

\newcommand*{\cvitem}[3][.25em]{}

which means, \cvitem takes three arguments and the first argument is optional. The first argument is actually the space between the \cvitems with default being 0.25em. But you are using three arguments with all three being mandatory (enclosed in braces {}). Remove one argument.

You must log in to answer this question.

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