# How to refer a figure?

I am trying to add some results (images). I want to refer these images in other chapter(s) of the PDF so that the reader can just click the reference and go to the image directly. How I can do that?

• Put your images in a figure environment, with \label and load the hyperref package. It should be loaded after all other packages, with some exceptions. – Bernard Apr 26 '16 at 18:52
• Or drop the figure environment and use the \captionof{figure}{...}\label{...} and hyperref – user31729 Apr 26 '16 at 18:55

Here's the short way of doing it:

• Use figure environment, a \caption and a \label
• Or just use \captionof{figure}{...} and the label

But in both cases: No \label, no reference possibility.

\documentclass{article}

\usepackage{caption}

\usepackage{graphicx}

\usepackage{hyperref}

\usepackage{cleveref}

\begin{document}
\listoffigures

In \cref{fig:nonfloat} you see a non-floating image and in \cref{fig:float} it's floating around and causes troubles (most times)

\begingroup
\includegraphics[scale=0.5]{ente}
\captionof{figure}[No float duck]{I hate float environments and that's why I don't use and recommend them } \label{fig:nonfloat}
\endgroup

\begin{figure}
\includegraphics[scale=0.5]{ente}
\caption[And the dreadful floating one]{I hate float environments and that's why I don't use and recommend them but just to demonstrate their usage }
\label{fig:float}
\end{figure}

\end{document}


• Using \captionof outside of a group is not advised, and you'll receive a warning to that effect. – Werner Apr 26 '16 at 19:13
• @Werner: True, I added a \begingroup...\endgroup` pair around it – user31729 Apr 26 '16 at 19:16