12

As the title says, how can you reference a chapter or section title when using cref? To be more clear: I do not want the label "section" or "chapter", I want the actual title of the chapter or section..

\documentclass{article}
\usepackage[norsk]{babel} 
\usepackage{tabularx}
\usepackage{apacite}
\usepackage{hyperref}
\usepackage{enumerate}
\usepackage[norsk,nameinlink]{cleveref}
\begin{document}

\section{Title}


\section{another title}
%I want to reference the first section here, with its name


\end{document}

2 Answers2

15

This:

\documentclass{article}
\usepackage[norsk]{babel} 
\usepackage{tabularx}
\usepackage{apacite}
\usepackage{hyperref}
\usepackage{enumerate}
\usepackage[norsk,nameinlink]{cleveref}
\begin{document}

\section{Title}


\section{another title}
\label{sss}
%I want to reference the first section here, with its name

nameref: \nameref{sss}\\
cref: \cref{sss}\\
ref: \ref{sss}

\end{document}

Gives this after 2 or 3 compilations:

enter image description here

yo'
  • 51,322
4

So, if I understand the comments and suggestions correctly:

Cleveref actually don't have a function equal to nameref, so the solution is to use normal \nameref

  • 2
    Yes, exactly. Why in the world would it double something that is (1) painful to implement and (2) perfectly done by hyperref?! – yo' Mar 12 '15 at 10:13
  • I just thought the best "approach" would be to use one of them through the whole document. Guess I got blinded by that. – miniHessel Mar 12 '15 at 10:17
  • Just FYI, cleveref does have namecref and many variants, but those similarly-named operations don't do what you want: the actual name of the labeled element. As you noticed, they instead give you the name of the "class" of element (e.g. section, chapter). – Jason Hemann Oct 01 '19 at 20:38