101

In my document I am referencing a section, e.g.

\section{My Section}\label{test}
Also see section\ref{test}

This gives me, e.g.

Also see section 1

but what I want is:

Also see section My Section

How can I do that?

[Edit: comment moved to question body]

Of course it makes more sense to have something like "chapter 1 My Section", therefore mentioning chapter number and title. Anyways, this is just an example and you can easily combine both.

gebruiker
  • 1,491
me.at.coding
  • 1,653

1 Answers1

105

The nameref package does what you want (and cooperates well with hyperref).

\documentclass{article}

\usepackage{nameref}% Only if hyperref isn't loaded
% \usepackage{hyperref}

\begin{document}

\section{foo}\label{test}

Some text.

\section{bar}

Some text. Also see section \nameref{test}.

\end{document}

enter image description here

lockstep
  • 250,273