LaTeX examples - reference a figure or table

LaTeX table/figure FAQ - How do I reference a table or figure in a LaTeX document?

Being able to automatically reference a figure within a LaTeX document is a very cool thing. This referencing capability lets you easily give readers the exact number of a figure, or tell them what page number a figure is located on with the use of a few simple commands (\label, \ref, and \pageref). The same technique works for referencing other objects within a LaTeX document, including tables and equations.

Here’s the simple two-step process to use and reference figures in LaTeX documents.

1) Define your LaTeX figure

To begin with, assume that you have a figure defined somewhere in a LaTeX document like this:

\caption{A prototype of the Job Information dialog}

(As you’ll see from the many comments below, the order of these lines is very important. Please read the comments for more details.)

Let’s further assume that as it turns out, in the current version of your document, this is Figure 11-1 in the document, and it appears on page 69.

2) Reference your LaTeX figure

Now, somewhere else in my document I want to make a reference to this figure. If I just want to refer to the figure number, I can get it to appear by writing LaTeX text like this:

Please see Figure ~\ref{fig:JobInformationDialog} for a prototype yada yada yada

When I create my output document, such as when I create a PDF with pdflatex, this results in the following output:

Please see Figure 11-1 for a prototype blah blah blah

Now, if I further want to refer to the page number that the image resides on, I can make a reference like this:

Please see Figure ~\ref{fig:JobInformationDialog} on page ~\pageref{fig:JobInformationDialog} for a prototype blah blah blah

If I now compile this statement with pdflatex I’ll end up with a PDF that has this output:

Please see Figure 11-1 on page 69 for a prototype blah blah blah

The \ref and \pageref commands make it very easy to refer to figures that contain labels. As you’ve seen, the text referenced by the \ref and \pageref commands must match the text used within the label command. (It seems to be a convention to begin this text with the string “fig:”. This isn’t really necessary, but because these labels must be unique within a document, it helps to organize your labels, and separate your labels for figures from your labels for tables and equations.

This way of referencing things is very powerful, because you can use the same technique to makes reference to other objects, like tables and equations.


I've used a command \ref{fig:} to reference my figures, but I don't receive the same numbers in the text as they are in the images.
In my text I have sections and subsections. The image gets the section number (2 digits) while in the text it appears as a 3 digit number.
What should I change?

Thank you!

Hi Alvin,
Thank you very much for your reply, but I still didn't solve my problem.
I'll try to explain it better:
For example, I have 3 figures in Chapter 5. The figures will have reference numbers: 5.1, 5.2, and 5.3. But, if I refer to the first image in a subsection 5.1.3, in the text I will get the reference number 5.1.3 not 5.1. If I refer to the same figure but in a subsection 5.2.2 the text will contain the figure number 5.2.2.

Hope this will look more clear to you.

Thank you.


I have the exact problem. The label for the table seems to cause the reference to refer to the section the table is in instead of the table number itself. I am actually trying to find a way of correcting the problem when i came upon this thread. Hope somebody can help



i came here for the same reason as you claudine, and yes you're right, that does fix it!
thx a lot


I have the same problem with my figures, and moving the label around doesn't seem to change anything. It's quite problematic when four figures give the same reference, which is just the name of the subsection they are placed in.


Hi everyone,

I have the same problem with tables. I only have one table at the moment and its caption calls it 2.1 as it is in chapter 2. However when i refer to in in the text with \ref{table:mism} the result is table 2.2 (which is the chapter and section number - coincidence???)

This happens weather i put the text reference before or after the actual table.

I'm running
pdfTeX 3.1415926-1.40.9-2.2 (Web2C 7.5.7)
kpathsea version 3.5.7

i.e the most recent binary of TexShop for mac





\definecolor{purp}{rgb}{0.9, 0.1, 0.9}

%40 left 30 top




\title{test doc}




here is some text, no tables.

Table \ref{table:mism} computes lattice mismatch for various films (horizontal) grown on different substrates and electrodes (vertical). The highlighted fields indicate trials to be undertaken.

\begin{center}\begin{tabular}{lcccccccc} \hline & \textbf{STO} & \textbf{MAO} & \textbf{MgO} & \textbf{Fe$_3$0$_4$} & \textbf{LSMO} & \textbf{SRO} & \textbf{BFO} & \textbf{PZT} \\ \hline \textbf{STO} & -- & -3.465 & -7.841 & -7.501 & \color{green}{0.896} & \color{green}{-0.896} & -1.216 & 0 \\ \textbf{MAO} & 3.349 & -- & -4.230 & \color{green}{-3.901} & 4.215 & 2.482 & 2.173 & 0 \\ \textbf{MgO} & 7.271 & 4.058 & -- & \color{green}{0.316} & 8.102 & 6.440 & 6.143 & 0 \\ \textbf{Fe$_3$0$_4$} & 6.977 & 3.754 & -0.317 & -- & 7.811 & 6.144 & \color{blue}{5.846} & 0 \\ \textbf{LSMO} & -0.904 & -4.400 & -8.816 & -8.473 & -- & -1.809 & \color{blue}{-2.132} & 0 \\ \textbf{SRO} & 0.888 & -2.546 & -6.883 & -6.546 & 1.777 & -- & \color{blue}{-0.317} & 0 \\ \textbf{BFO} & 1.202 & -2.163 & -6.545 & -6.209 & \color{purp}{2.087} & \color{purp}{0.316} & -- & 0 \\ \textbf{PZT} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{tabular} \caption{Lattice mismatch calculations}




Hi Alvin,

Thank you so very much.

I have no idea why it works, but placing the label directly after the caption has solved the problem.




I had the same problem with the figure being referenced by the section instead of just the number I wanted. And hooray, Alvin's solution of putting the label directly after the caption also worked for me.


Thanks, the Post of Claudine helped me get the References straight, I also had the order of caption/label "wrong".


I can't believe changing the order to caption-label worked! I'm so happy! Thank you Claudine!!!


Thanks to Claudine and to Alvin. Add me to the list of "me too".

Must be one of the fragile commands ... finicky about the order and
contiguousness. As it says, it is because it will actually allow
several caption-label pairs within the same table or figure environment.
That is also a feature of great utility so the fragility has to be


...for the posts! I also switched the occurence of caption and label at some point in my doc and this thread helped me quickly.

Having spent half an hour trying everything I could think of without much luck, I can't say how delighted I was to see you figured a way out of the problem.



Hi Alvin,

Thank you so very much. Your suggestion indeed solved my problem



I struggled with the same figure numbering issue for a couple hours until I found this post. Thanks!


Thank you, I'm glad I found this post! Saved me some hours of debugging!


Thanks for the help!

The form \caption{blah blah}\label{fig:num} works for me, too. I really had no idea how to get it right! Thank you once again! :)


I just ran into the same problem with the figure references. I guess I used to blindly use the correct sequence and couldn't figure out what I was doing wrong today. Thanks for the solution.

Hi Alvin,

thanks a lot for this help. I had been struggling with incorrect numbering of a single table in my thesis and wasn't able to solve it. Today I decided to be patient and solve it. I stumbled upon your post here and to my relief it is working. thanks again,


Add new comment

The content of this field is kept private and will not be shown publicly.

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.