GeneralCross Reference for a Section by Name

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
dagoss
Posts: 2
Joined: Fri Jul 15, 2011 7:40 pm

Cross Reference for a Section by Name

Post by dagoss »

Hello,

I feel like this should be a simply (and common) operation but I haven't figured out how to do it. It may simply be that I don't understand this documenation.

I want to cross references sections of my document such that I can have this:

Code: Select all

\section{Building Framing}
\label{frame}

[...]

Please refer to \autoref{frame} for more information.
Which would output:

"Please refer to 3.2 Building Framing for more information."

By default, autoref gives "Section 3.2", but I want it to pull the name of the chapter/section/subsection that the label is in, along with the number. How can I do that?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Cross Reference for a Section by Name

Post by meho_r »

Here's one way:

Code: Select all

\documentclass{article}

\usepackage{hyperref}

\newcommand{\myref}[1]{\ref{#1} -- \nameref{#1}}

\begin{document}

\section{A section}\label{test}

``Plain'' ref:~\ref{test},\\ 
Autoref:~\autoref{test},\\
Nameref:~\nameref{test},\\
Custom ref:~\myref{test}.

\end{document}
Post Reply