# When referencing a figure, make text and figure name clickable

When referecnging a figure, you write something like:

\begin{figure}[here]
\includegraphics[width=0.9\textwidth]{images/example.jpg}
\caption{A figure}
\label{figureExample}
\end{figure}


and to reference this figure you can just write "an example is figure \ref{figureExample}", and then you will get a text like

an example is figure 2.1

where 2.1 will be clickable. Now to my question; if I want both the text "figure" and the "2.1" to be clickable, how can I achieve this?

I can think of two possibilities:

• Load the hyperref package and use the \autoref macro of that package;

• in addition to loading hyperref, load the cleveref package with the option nameinlink, and use the \cref macro to generate the cross-references.

One of the nifty aspects of \cref is that you can call several objects all in one go; the package will take care of any sorting and compressing needs.

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\section{In the beginning} \label{sec:begin}
\begin{figure}[h]
\includegraphics[width=0.9\textwidth]{images/example.jpg}
\caption{A figure} \label{fig:example}
\end{figure}

$$\label{eq:pyth} a^2+b^2=c^2$$

\section{Next}

As was discussed in \autoref{sec:begin} and shown in \autoref{fig:example}, \dots

\bigskip\noindent
As argued in \cref{sec:begin,fig:example,eq:pyth}, \dots
\end{document}

• Thanks! As said in the comment above:The only problem with auto ref is that it automatically use the labels in english. Any way to get it to use another language? – – miniHessel Mar 1 '15 at 20:21
• @miniHeessel - Is there any language in particular you're interested in? – Mico Mar 1 '15 at 20:22
• Norwegian, so for example instead of figure : figur. Instead of Table :tabell – miniHessel Mar 1 '15 at 20:23
• @miniHeessel - You're in luck if you use \cref: just load cleveref with the option norsk, and the sentence in the example above will come out as "... avsnitt 1, figur 1 og likning (1) ...". (I'm afraid cleveref doesn't recognize the option nynorsk...) – Mico Mar 1 '15 at 20:28