1

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.

Serge Garcia
  • 113
  • 8

1 Answers1

6

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:

References at work.

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.

dgoodmaniii
  • 4,270
  • 1
  • 19
  • 36