Search code examples
latex

References with text in LaTeX


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.

Solution

  • 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...