tags:

views:

220

answers:

3

In LaTeX you can easily reference a section by using \label{} next to a section and then \ref{} to create the reference. However, the reference only includes the number of the section, or the page with \pageref{}. I would like to insert a reference containing the text of the section.

Example:

\section{My Section}
\label{section:my}

This is a reference to Section~\ref{section:my}.

The output is the following:

1. My Section

This is a reference to Section 1.

I would like to have:

This is a reference to 1. My Section.
+4  A: 

I think you can do this with the hyperref package, although I've not tried it myself. From the relevant LaTeX Wikibook section:

The hyperref package introduces another useful command; \autoref{}. This command creates a reference with additional text corresponding to the targets type, all of which will be a hyperlink. For example, the command \autoref{sec:intro} would create a hyperlink to the \label{sec:intro} command, wherever it is. Assuming that this label is pointing to a section, the hyperlink would contain the text "section 3.4", or similar (capitalization rules will be followed, which makes this very convenient). You can customize the prefixed text by redefining \typeautorefname to the prefix you want, as in:

\def\subsectionautorefname{section}

ire_and_curses
Or consult the `hyperref` manual here: http://www.tex.ac.uk/tex-archive/macros/latex/contrib/hyperref/nameref.pdf
Paul Lammertsma
+7  A: 

Have a look to this wiki: LaTeX/Labels and Cross-referencing:

The hyperref package automatically includes the nameref package, and a similarly named command. It inserts text corresponding to the section name, for example:

\section{MyFirstSection}

\label{marker}

\section{MySecondSection} In section \nameref{marker} we defined...

enguerran
+2  A: 

Duplicate. See my answer to 522838.

Will Robertson
Yes, the question can be considered a duplicate (didn't found it initially). However, the accepted answer in this post is much simpler and clean.
ssn