# How do I insert a 'floating' page number for the location of a Figure that may change as I continue to edit my book?

I have three Figures in the back of my book that I want to refer to by page number. "Figure 1.2, which is located on page number 142" or something like that. However, as the book is currently being edited, and will go through multiple iterations before formal publishing, I'd like to write a little code that refers to the page number where the Figure is located. Is this possible?

This question was asked without prior knowledge of /ref.

• Duplicate of 2193 – vonbrand Oct 30 '15 at 19:23
• @vonbrand Not really a duplicate: in the referenced question the notion of \ref is already assumed. – egreg Oct 30 '15 at 21:47

Certainly it's possible; this is one of the things that LaTeX excels at. First, inside your figure, include a label by which you can refer to it:

\label{fig:coolfigure}


Then you can refer to it by figure number with \ref or by page number with \pageref. For example:

\documentclass{article}
\begin{document}
\section{Figures}
\begin{figure}
This is a figure
\label{fig:coolfig}
\end{figure}
Please look at Figure~\ref{fig:coolfig} on page~\pageref{fig:coolfig}.
\end{document}


This will get you the following:

Remember that the first time you run LaTeX on this, the references and their targets are being written out to the aux file; they won't be read in correctly until you run LaTeX a second time, and it can read those references back in from the aux file. Whenever your page numbers or references change, you'll need to run LaTeX twice to get the references to resolve correctly. Fortunately, LaTeX will tell you when this needs to happen.

• It's a good idea to put a non-breaking space between Figure and \ref: Please look at Figure~\ref{fig:coolfig}... – musarithmia Oct 30 '15 at 19:50
• Indeed it is; so edited. – dgoodmaniii Oct 30 '15 at 19:57