6

I have use the \ref function to make an internal reference to another section with \label and \ref{} but my reference is invisible but click able.

Someone has the same problem?

EDIT BY LOCKSTEP: Strange indeed. Here's a MWE (and yes, there's a click able link):

\documentclass{moderncv}

\firstname{John}
\familyname{Doe}

\begin{document}

\maketitle

\section{Master thesis}\label{sec:th}
\cvline{title}{\emph{Title}}

\section{Experience}
\cventry{year--year}{Job title}{Employer}{City}{}{See section \ref{sec:th}}

\end{document}
Peter Grill
  • 223,288

1 Answers1

3

The moderncv document class defines a section without a counter. Here's the \section command extracted from moderncv.cls:

% usage: \section{<title>}
\newcommand*{\section}[1]{%
  \vspace*{2.5ex}%
  \parbox[m]{\hintscolumnwidth}{\raggedleft\hintfont{\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{1ex}}}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{part}{#1}%
  \hspace{\separatorcolumnwidth}%
  \parbox[m]{\maincolumnwidth}{\sectionstyle{#1}}%
  \par\nobreak\vskip 1ex\@afterheading}% to avoid a pagebreak after the heading

Correct referencing is obtained via hyperref's \phantomsection. Hence, \ref returns nothing other than a correct internal hyperlink. This is also evident from the fact that the sections in moderncv is not typeset with a numbered counter.

As such, if you want to have a description associated with the link, you need to use \hyperref[<lab>]{<text>} where <lab> is your label, and <text> is what you want to be clickable. For example, using the posted MWE, you could use

\cventry{year--year}{Job title}{Employer}{City}{}{See section \hyperref[sec:th]{Master thesis}}

enter image description here

Werner
  • 603,163