Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a package that automatically inserts the ToC level of the reference I inserted?

Section 1.1
\label{a}
Subsection 1.1.1
\label{b}
Subsection 1.1.2 
\label{c}

So that the text:

Blah \superref{a} and \superref{b} and \superref{c}

becomes:

Blah Section 1.1 and Subsection 1.1.1 and Subsection 1.1.2

So that it automatically adapts if I change the level of a label?

share|improve this question

2 Answers 2

up vote 23 down vote accepted

Use the cleveref package and its \cref macro. Note that sectioning levels below \section are referred to as "section" by default, but this can be customized.

EDIT: In case you want the first letter of the reference name capitalized, use \Cref.

\documentclass{book}

\usepackage{cleveref}
\crefname{subsection}{subsection}{subsections}

\begin{document}

\chapter{First}

\section{First-first}\label{a}

\subsection{First-first-first}\label{b}

\subsection{First-first-second}\label{c}

See \cref{a} and \cref{b} and \cref{c}~\dots

\end{document}

enter image description here

share|improve this answer
1  
\Cref is for starting a sentence, akin to \Citet. For consistent capitalization, use the capitalize package option. Use noabbrev to fully spell out the reference names. (See Section 6 of the manual.) –  krlmlr Jun 15 '13 at 13:44

The hyperref package provides \autoref{<label>} which inserts the name of the reference type as well. These names can also be changed e.g. redefine \sectionautorefname to change the name for sections.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.