cleveref
Cross-references that prepend the right label (Figure, Section, …) automatically and merge ranges.
- Example
- Preamble
\Cref{fig:ex:cref} shows a simple fact, although \cref{fig:ex:cref} could also show something else.
\Cref{tab:ex:cref} shows a simple fact, although \cref{tab:ex:cref} could also show something else.
\Cref{sec:ex:cref} shows a simple fact, although \cref{sec:ex:cref} could also show something else.
% Extensions for references inside the document (\cref{fig:sample}, ...)
% Enable usage \cref{...} and \Cref{...} instead of \ref: Type of reference included in the link
% That means, "Figure 5" is a full link instead of just "5".
\usepackage[capitalise,nameinlink,noabbrev]{cleveref}
\crefname{listing}{Listing}{Listings}
\Crefname{listing}{Listing}{Listings}
% Intermediate solution for hyperlinked refs. See https://tex.stackexchange.com/q/132420/9075 for more information.
\newcommand{\llabel}[1]{\label[line]{#1}\hypertarget{#1}{}}
\newcommand{\lref}[1]{\hyperlink{#1}{\FancyVerbLineautorefname~\ref*{#1}}}