Graphics, Figures & TablesPreceeding References to following Figures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jomike
Posts: 5
Joined: Wed Nov 14, 2012 10:42 pm

Preceeding References to following Figures

Post by jomike »

Hello!

Just recently, I started using LaTeX. I have the following referencing problem.

If I place a reference for a figure (for the below example: \ref{fig: a figure}) or a table before this figure or table, then Latex only gives me the output "??".

This doesn't occur when I place the reference behind the figure/table. Here is a example code:

Code: Select all

\begin{figure}
\caption{a figure}
\label{a figure}
\includegraphics[scale=0.94]{figure.pdf}
\end{figure}
I'd be so glad if someone could help me out (I'm going mad with this problem)!


Greetings,
jomike

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Preceeding References to following Figures

Post by nlct »

Just make sure you run latex twice to ensure the references are up-to-date.

Code: Select all

\documentclass{article}

\usepackage{graphicx}

\begin{document}

Figure~\ref{fig:sample} is an example.

\begin{figure}
 \centering
 \includegraphics{test-image}
 \caption{Sample Figure}
 \label{fig:sample}
\end{figure}

\end{document}
Regards
Nicola Talbot
jomike
Posts: 5
Joined: Wed Nov 14, 2012 10:42 pm

Re: Preceeding References to following Figures

Post by jomike »

A little late, but: thanks Nicola, after applying your advice, it worked well!
Post Reply