Graphics, Figures & TablesReferencing Figures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
betbetbet
Posts: 14
Joined: Thu Jan 22, 2009 10:15 am

Referencing Figures

Post by betbetbet »

Hi,

Whenever I type:

Code: Select all

\documentclass[12pt]{book}
\usepackage{setspace}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{amsfonts}
\usepackage{epsfig}
\usepackage{appendix}
%\usepackage{amsart}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{amsmath}
%\usepackage{amscls}
\usepackage{fontenc}
\usepackage{amssymb}
\usepackage{dsfont}
%\usepackage{floats}
%\usepackage{figlatex}
%\usepackage{dvips}
%\usepackage{latex}
%\usepackage{epsf}
\usepackage{epsf}

\begin{document}

\chapter{First chapter}

\section{First section}

\begin{figure}[H]
\centering
\includegraphics{notP5.pdf}
\label{P5free}
\caption{A $P_5$-free graph}
\end{figure}

\begin{figure}[H]
\centering
\includegraphics{countries.pdf}
\label{europe}
\caption{An illustration to describe adjacent countries}
\end{figure}

\section{Second section}

In Figure \ref{europe} we have countries

\end{document} 
I get the output below:

Code: Select all

Chapter 1
First chapter
1.1 First section

Figure 1.1: A P5-free graph (the figure)

Figure 1.2: An illustration to describe adjacent countries (the 2nd figure)

1.2 Second section

In Figure 1.1 we have countries
Instead of "In Figure 1.1 we have countries", I want "In Figure 1.2 we have countries" because I am referencing figure 1.2.

Referencing is done by section and not the actual figure for some reason.

Can anyone help?

Thanks in advance,

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Bozack
Posts: 117
Joined: Wed Feb 06, 2008 4:21 pm

Re: Referencing Figures

Post by Bozack »

It looks like something I've had trouble with before. Try placing the label after the caption in your figures - it should do the trick.
OS, LaTeX-system, editor: Arch Linux 64bit, TeXlive, Kile | Windows 10 Professional 64bit, MikTeX 4.9, TeXnicCenter 2.02 64bit
betbetbet
Posts: 14
Joined: Thu Jan 22, 2009 10:15 am

Re: Referencing Figures

Post by betbetbet »

It worked!

Thanks again,
Post Reply