# Display the title of a section (or subsection) in a reference [duplicate]

I understood how to use \ label {} and \ ref} to get the number of a section or subsection. I would like to know if it was possible to also obtain the title of a section or sub-section. For example (see VI.1 Test) where Test the title of the subsection

• Take a look at the nameref package. – leandriis Jan 6 at 11:27

Use hyperref or cleveref packages.

\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\section{Test}\label{sec:test}
\ref{sec:test}
\nameref{sec:test}

\autoref{sec:test}

\cref{sec:test}

\end{document}


You can define a \newcommand to fit your need:

\newcommand{\myref}[1]{(see \autoref{#1}~\nameref{#1}, p.~\pageref{#1})}

• thanks for your response. can I remove the frame that surrounds the reference in the final document, – Nicolas Jan 6 at 14:46
• Sure! Use \hypersetup{colorlinks=true}. See hyperref documentation. – NBur Jan 6 at 14:52