% !TEX root = ../manual.tex
% !TEX program = xelatexmk
% !TEX spellcheck = en_GB

\section{Labels and references}
\label{sec:this one}
One thing that is very useful when making reports is \LaTeX’s way of handling references. Let’s refer to the figure and table:
\begin{multicols}{2}
\begin{lstlisting}
figure~\ref{fig:logo} \\
table on page~\pageref{tab:table} \\
\autoref{fig:logo} \\
\nameref{tab:table}
\end{lstlisting}
\columnbreak
figure~\ref{fig:logo} \\
table on page~\pageref{tab:table} \\
\autoref{fig:logo} \\
\nameref{tab:table}
\end{multicols}

It’s also possible to link to sections:
\begin{multicols}{2}
\begin{lstlisting}
\label{sec:this one}
\autoref{sec:this one}
on page~\pageref{sec:this one}
\end{lstlisting}
\columnbreak
%\label{sec:this one}
\autoref{sec:this one}
on page~\pageref{sec:this one}
\end{multicols}

The first lines are \LaTeX’s native way of using references. Both |\autoref| and |\nameref|  are provided by the |hyperref| package, which also turns the references into hyperlinks.

There is one caveat: often references will not resolve after one compilation of your document, so you should always run it twice. In chapter 2 the |latexmk| command is discussed, which solves this problem.
