1

As suggested here, I use symbols drawn with tikz to indicate hyperlinks in my cv. However when used in the cventry command of the modern cv package, this caused an error. Here is the minimal non-working example

\documentclass[11pt,a4paper,color,final]{moderncv}
\usepackage{tikz}
\newcommand{\ExternalLink}{%
  \tikz[x=1.2ex, y=1.2ex, baseline=-0.05ex]{% 
    \begin{scope}[x=1ex, y=1ex]
      \clip (-0.1,-0.1) 
      --++ (-0, 1.2) 
      --++ (0.6, 0) 
      --++ (0, -0.6) 
      --++ (0.6, 0) 
      --++ (0, -1);
      \path[draw, 
        line width = 0.5, 
      rounded corners=0.5] 
      (0,0) rectangle (1,1);
    \end{scope}
    \path[draw, line width = 0.5] (0.5, 0.5) 
    -- (1, 1);
    \path[draw, line width = 0.5] (0.6, 1) 
    -- (1, 1) -- (1, 0.6);
  }
}

\moderncvtheme[black]{classic}

\firstname{FirstName}
\familyname{Name}

\begin{document}

\maketitle

\section{Section}
\cventry{2014}{\href{http://example.com/ \ExternalLink}{My great position}}{My great company}{My great city}{}{}

\end{document}

Edit following Salim Bou's answer. The following works

\cventry{2014}{\href{http://example.com/}{My great position \ExternalLink}}{My great company}{My great city}{}{}

(The symbol shoulb be placed in the string not in the url).

However this still produces an error

\cventry{2014}{My great position}{\href{http://example.com/}{My great company \ExternalLink}}{My great city}{}{}

Looking at the log the error looks quite similar. Latex is complaining about some error message being undefined.

Ronan
  • 113
  • You can use \cventry{2014}{My great position}{\href{http://example.com/}{My great company \protect\ExternalLink}}{My great city}{}{} – Salim Bou Dec 27 '16 at 15:25

2 Answers2

5

You need to include your symbol like this

\cventry{2014}{\href{http://example.com/}{\ExternalLink My great position}}
{My great company}{My great city}{}{}
Salim Bou
  • 17,021
  • 2
  • 31
  • 76
  • Ok this solves the initial problem but there is still a bug. I edited my question in regard of your answer. – Ronan Dec 27 '16 at 14:45
0

This is an old question, but since it's the first result that appears when searching for "moderncv tikz error", here's my take.

Use \DeclareRobustCommand instead of \newcommand to define the TikZ macro. That's it. See this other question if you are interested in understanding why.

Piolie
  • 133