Graphics, Figures & TablesProblem with \ref{figure:#}

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Problem with \ref{figure:#}

Post by QwareeqMathematics »

Now, here is a mini-example of my file :
Short Premable :

Code: Select all

\documentclass[12pt,a4paper,dvipdfm]{report}
\usepackage[left=3.5cm,right=2.5cm,top=2.5cm]{geometry}
\setlength{\textheight}{780pt}
\usepackage[dvipdfm]{hyperref}
\usepackage{amssymb,latexsym,amsmath,mathrsfs,array,epsfig,tikz}
\usepackage{color,amstext,amsbsy,amsopn,amsthm,amscd,amsxtra,amsfonts,setspace}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\contentsname}{List of Contents}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\chead{\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\numberwithin{figure}{section}
In chapter one , I have something like this :

Code: Select all

\chapter{TEXT}
:
:
:

\section{Text}
:
:
\subsection{text}
:
:
\subsection{text}
:
:
\subsection{text}
:
:
\subsection{text}
:
:

\section{ HERE IS THE SECTION I HAVE PROBLEM WITH FIGURES}

\subsection{ In this subsection I add figures like this}


\noindent{These definitions illustrated by figure \ref{figure:1}, figure \ref{figure:2}, and figure \ref{figure:3}.}\newpage

\begin{figure}[!ht]
\centering
\begin{minipage}[b]{0.4\textwidth}
\label{figure:1}
\centering
\includegraphics {fi1.eps}
\caption{Non-simple graph}
\end{minipage}
\begin{minipage}[b]{0.4\textwidth}
\label{figure:2}
\centering
\includegraphics {fi2.eps}
\caption{Simple Graph}
\end{minipage}
\end{figure}

\begin{figure}[!ht]
\label{figure:3}
\centering
\includegraphics {fi3.eps}
\caption{Infinite Graph}
\end{figure}
For the strange results :
figure.PNG
figure.PNG (7.68 KiB) Viewed 2237 times
WHY it gave me the same number of ref{figure number }

THanks

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Problem with \ref{figure:#}

Post by gmedina »

Because you are using \label before \caption in your figure environments. In the floating environments (figure, table, others defined by the user) the \label command must be used after the corresponding \caption command to prevent the problem that you already experienced.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Re: Problem with \ref{figure:#}

Post by QwareeqMathematics »

Thank you .... new information ;)
Post Reply