2

Possible Duplicate:
Why does an environment's label have to appear after the caption?

I have a problem using \ref{} to reference table floating object. In my document, I have a table area like this:

\begin{table}
\label{tab:gstexp}
\begin{tabular}{l l p{7.5cm}}
\hline
\hline
\textbf{Nr.}    & \textbf{Name}                     & \textbf{Comment} \\
\hline
   %Contents
\hline
\hline
\end{tabular}
\caption{just a table}
\end{table}

In my text, I reference it using Table~\ref{tab:gstexp} The ref is before the label in my text but this should be indifferent. But if I compile my code in the PDF it renders "Table ??" instead of "Table 1".

I am using MacTeX and texmaker to compile my documents.

David Carlisle
  • 757,742
john84
  • 1,205
  • 8
    The \label has always to be placed after the \caption command. – Thorsten Donig Jul 01 '12 at 09:54
  • 1
    Also it will always show as ?? the first run, you need to run latex a second time to resolve all the references. – David Carlisle Jul 01 '12 at 10:00
  • @ThorstenDonig well, but I got the same problem if place it after the '\caption' and if I place it before the caption sometimes it works as well. ??? – john84 Jul 01 '12 at 10:19
  • @DavidCarlisle Yes, I tried also three or four run's. – john84 Jul 01 '12 at 10:20
  • As usually requested on this site you will need to make a full document that people can run. But \label has to be after \caption and latex will need to run twice. Also make sure the pdf you are viewing is being refreshed, some pdf viewers block the file from being updated so you have to close the pdf view before running latex. – David Carlisle Jul 01 '12 at 10:24
  • OK, right there has been two problems, I have really to place the \label after the \caption. But in addition, after using the "clean" option in texmaker the problems occurs (even if \label is after \caption). I have to run "Tools" -> "Asymptote" now I changed the Quick Build Option (in "Preferences"->"Quick Build") from "PdfLaTeX + View PDF" to "PdfLaTeX + Asymptote + PdfLaTeX + View PDF" now it seems to work fine. – john84 Jul 01 '12 at 10:38
  • On this basis, the question is 'too localized'. – Joseph Wright Jul 01 '12 at 10:50

0 Answers0