[Tex/LaTex] \href{} problem on moderncv document class

hyperrefmoderncv

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?

Best Answer

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.