From: Doran, H. <HD...@ai...> - 2009-01-26 15:17:31
|
I am having some trouble properly referencing tables when I introduce subsections. A minimal example is below that illustrates the problem. I think the issue is setting the counter, but I am having some difficulties understanding how it might work in this instance. \documentclass{article} \begin{document} \section{First Section} Table~\ref{tab:1} is properly referenced below \begin{table}[htb!] \label{tab:1} \begin{center} \begin{tabular}{cccc} \hline Grade & M1 & M2 & M3 \\ \hline 3 & -5457242.1 (48) & -5403792.1 (96) & -5384273.8 (144) \\ 4 & -5329033.6 (48) & -5291898.8 (96) & -5273390.8 (144) \\ 5 & -6839010.4 (73) & -6785206.2 (124)& -6763920.8 (175) \\ \hline \end{tabular} \caption{log-likelihoods} \end{center} \end{table} \subsection{Problem is here} Table~\ref{tab:2} is not properly referenced below, but the table is numbered properly \begin{table}[htb!] \label{tab:2} \begin{center} \begin{tabular}{cccc} \hline Grade & M1 & M2 & M3 \\ \hline 3 & -5457242.1 (48) & -5403792.1 (96) & -5384273.8 (144) \\ 4 & -5329033.6 (48) & -5291898.8 (96) & -5273390.8 (144) \\ 5 & -6839010.4 (73) & -6785206.2 (124)& -6763920.8 (175) \\ \hline \end{tabular} \caption{log-likelihoods} \end{center} \end{table} \section{And the problem propogates} The table number is correct, but the reference is not Table~\ref{tab:3} \begin{table}[htb!] \label{tab:3} \begin{center} \begin{tabular}{cccc} \hline Grade & M1 & M2 & M3 \\ \hline 3 & -5457242.1 (48) & -5403792.1 (96) & -5384273.8 (144) \\ 4 & -5329033.6 (48) & -5291898.8 (96) & -5273390.8 (144) \\ 5 & -6839010.4 (73) & -6785206.2 (124)& -6763920.8 (175) \\ \hline \end{tabular} \caption{log-likelihoods} \end{center} \end{table} \end{document} |
From: José C. S. <jcs...@fc...> - 2009-01-26 15:56:02
|
On 26-01-2009 14:52, Doran, Harold wrote: > I am having some trouble properly referencing tables when I introduce > subsections. A minimal example is below that illustrates the problem. I > think the issue is setting the counter, but I am having some > difficulties understanding how it might work in this instance. The \caption command should always be put *before* the \label command. Best regards, Jose Carlos Santos |
From: Lothar B. <lb...@un...> - 2009-01-26 16:09:11
|
Dear Harold, as a general rule place \label commands immediately AFTER the \caption command. If I am not mistaken, the numbering is created with the \caption command. Thus if you add the \label command before the \caption it will refer to the current set object which in your case is the \subsection. Best regards, Lothar On Mon, 2009-01-26 at 08:52 -0600, Doran, Harold wrote: > \documentclass{article} > \begin{document} > > \section{First Section} > > Table~\ref{tab:1} is properly referenced below > > \begin{table}[htb!] > \label{tab:1} > \begin{center} > \begin{tabular}{cccc} > \hline > Grade & M1 & M2 & M3 \\ \hline > 3 & -5457242.1 (48) & -5403792.1 (96) & -5384273.8 (144) \\ > 4 & -5329033.6 (48) & -5291898.8 (96) & -5273390.8 (144) \\ > 5 & -6839010.4 (73) & -6785206.2 (124)& -6763920.8 (175) \\ > \hline > \end{tabular} > \caption{log-likelihoods} > \end{center} > \end{table} > > \subsection{Problem is here} > > Table~\ref{tab:2} is not properly referenced below, but the table is > numbered properly > > \begin{table}[htb!] > \label{tab:2} > \begin{center} > \begin{tabular}{cccc} > \hline > Grade & M1 & M2 & M3 \\ \hline > 3 & -5457242.1 (48) & -5403792.1 (96) & -5384273.8 (144) \\ > 4 & -5329033.6 (48) & -5291898.8 (96) & -5273390.8 (144) \\ > 5 & -6839010.4 (73) & -6785206.2 (124)& -6763920.8 (175) \\ > \hline > \end{tabular} > \caption{log-likelihoods} > \end{center} > \end{table} > > \section{And the problem propogates} > > The table number is correct, but the reference is not Table~ > \ref{tab:3} > > \begin{table}[htb!] > \label{tab:3} > \begin{center} > \begin{tabular}{cccc} > \hline > Grade & M1 & M2 & M3 \\ \hline > 3 & -5457242.1 (48) & -5403792.1 (96) & -5384273.8 (144) \\ > 4 & -5329033.6 (48) & -5291898.8 (96) & -5273390.8 (144) \\ > 5 & -6839010.4 (73) & -6785206.2 (124)& -6763920.8 (175) \\ > \hline > \end{tabular} > \caption{log-likelihoods} > \end{center} > \end{table} > > > > \end{document} > -- -- Lothar Birk -------------------------------------------------------- School of Naval Architecture and Marine Engineering University of New Orleans, 2000 Lakeshore Drive, New Orleans, LA 70148 Phone +1 504 280 6183, Fax +1 504 280 5542 |
From: Philip G. R. <phi...@fa...> - 2009-01-26 15:31:50
|
> I am having some trouble properly referencing tables when I > introduce subsections. A minimal example is below that > illustrates the problem. I think the issue is setting the > counter, but I am having some difficulties understanding how > it might work in this instance. You need to place the \label command AFTER the \caption command, but inside the environment of course. Cheers, Phil |