TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an article with the following figure (there are 2 small charts near each other, horizontally):

\begin{figure}[h]
  \centering
  \includegraphics{left-graph}
  \includegraphics{right-graph}
  \caption{My caption}\label{mylabel}
\end{figure}

I reference the figure with:

Figure~\ref{fig:result} shows bla-bla-bla.

The rendered PDF shows ?? instead of the figure number. I tried with the reference occurring both before and after the figure (in the LaTeX source), but it didn't make a difference.

The relevant packages I'm using are below (those removed are for titling).

\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[letterpaper]{geometry}
\geometry{top=1.0in, bottom=1.0in, left=1.5in, right=1.0in}
\usepackage{flafter} % make sure figures do not appear before their text
\usepackage{sidecap} % use side captions for floats
\usepackage{subfig} % subfloats

I'm not sure what's wrong here, advice is appreciated. I'm using MiKTeX 2.8.

Thank you!

share|improve this question
3  
Allowing only [h] is not much. I would add some options resulting in [htp] for instance. See texblog.net/help/latex/figure.html for reference. – Stefan Kottwitz Aug 17 '10 at 14:18
up vote 15 down vote accepted

Your labels don't match. Change the reference to \ref{mylabel} or the label to label{fig:result}

share|improve this answer
    
Thanks, I had misinterpreted the meaning of the reference expression (I thought it was "show the current figure counter result"). – wishihadabettername Aug 17 '10 at 14:32

Besides the mistake noted by Lev Bishop (assuming that you just did some incomplete editing for this post, and in reality the labels match), it is possible that you did not run latex enough times. For the labels to work out you need to run it at least twice.

share|improve this answer
    
The labels were not matching (see my comment to Lev's answer), but you get a vote for reminding me about running twice. – wishihadabettername Aug 17 '10 at 19:11

this is how I did at my work ..

\begin{figure}[b!]
\centering
\includegraphics[width=0.3\textwidth]{sampleFig.jpg}
\caption{sampleFig \cite{sample}}
\label{sampleFig}
\end{figure}

and in the paragrahp I put like :

\figurename{\ref(sampleFig)}
share|improve this answer
1  
Welcome, do you know about \autoref{sampleFig} from package hyperref? It is much much better than your current way of doing stuff. – Johannes_B Jun 4 at 14:53
    
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Martin Schröder Jun 4 at 15:05

I also had similar issue where pdflatex didn't update the Figure reference. I later found out that it is because of {\caption{.....}}\label{} incorrect usage. The \caption and \label commands have to be together like \caption{.....}\label{}. The caption command and its contents should not be enclosed with braces.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.