13

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}
8
  • 2
    Add a \label so you have something to refer to. Then use \cref{label name} and \nameref{label name} for the title.
    – daleif
    Commented Mar 12, 2015 at 10:01
  • so cleveref dont have a command similar to nameref? I would want the name clickable..
    – miniHessel
    Commented Mar 12, 2015 at 10:06
  • @miniHessel related: 1, 2, 3 Commented Mar 12, 2015 at 10:08
  • @egwenesedai no, not at all. I am talking about cleveref.
    – miniHessel
    Commented Mar 12, 2015 at 10:10
  • @miniHessel, did you test it. The name is clickable.
    – daleif
    Commented Mar 12, 2015 at 10:10

2 Answers 2

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

3
  • 1
    Where does the avsnitt come from?
    – Trylks
    Commented Apr 14, 2015 at 17:16
  • 1
    @Trylks From the Norsk language?
    – yo'
    Commented Apr 14, 2015 at 17:19
  • I see, so it means "section" I guess. I was asking because I have a related problem but it seems to be different. Thank you.
    – Trylks
    Commented Apr 14, 2015 at 18:12
5

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

3
  • 2
    Yes, exactly. Why in the world would it double something that is (1) painful to implement and (2) perfectly done by hyperref?!
    – yo'
    Commented Mar 12, 2015 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
    Commented Mar 12, 2015 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). Commented Oct 1, 2019 at 20:38

You must log in to answer this question.

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