views:

139

answers:

2

Hi,

I wrote a long table with a label in a tex file and \input it into my main tex file. The reference in the main tex file to the table, however, does not show the numbering of the table but the one of the next table that are written directly in the main tex file. All long tables that are written directly in the main tex file have correct references. How to fix my problem? Must the label be defined in the same tex file as its reference?

Thanks and regards!


The label is \label{tab:yy}, and the reference is \ref{tab:yy}, and every table has a distinct label.

+2  A: 

Could it be that you need to rerun (La)TeX in order to imbed the new .aux file with the updated references?


OK, not that.

Could you post a minimal example that fails?


Sorry, don't know why @Will's answer works. Neither of my two bibles (the memoir manual and the Guide to LaTeX2e) says anything. The examples from there show \label{} coming right after \caption{}, not inside it.

???

Brent.Longborough
Thanks! But no matter how many times latex command is run, the numbering is still wrong.
Tim
See the answer of Will. Do you know why?
Tim
+2  A: 

This may or may not help, but I've had similar problems with figure references where the figure number inserted into the text in place of the \ref command was wrong. I managed to solve it by putting the \label inside the figure's \caption, viz:

\begin{figure}
\caption{Some caption.\label{fig:some-figure}}
\includegraphics{some-figure.eps}
\end{figure}

It's difficult to say more without a more extensive example of what's going wrong, though!

Will Vousden
Thanks! It works. I put \label just before \end when it did not work. Why is this?
Tim
@Tim: I'm not entirely sure! If anyone else could answer this I'd be interested to hear.
Will Vousden