[Tex/LaTex] labels with tabular

labelstables

The code is:

\documentclass{article}
\begin{document}
Critical temperature for different Type I superconductors is given in Table \ref{Tab:Tcr}:
\begin{center}
  \begin{tabular}{l l}
    material  & T [K]\\
    \hline
    Sn                     & 3,7 \\
    Pb                     & 7,2 \\
    Al                     & 1,2\\
  \end{tabular}
  \label{Tab:Tcr}
 \end{center}
\end{document}

The output is enter image description here

The table reference is missing in the text. How to display the table reference?

Best Answer

You can't \label a tabular, because a tabular does not receive an intrinsic ordering scheme (aka a number) that can be referenced. But if you place the tabular inside of a table, you can \label that.

\documentclass{article}
\begin{document}
Critical temperature for different Type I superconductors is given in Table~\ref{Tab:Tcr}
\begin{table}[ht]
\caption{My Table}
\centering
  \begin{tabular}{l l}
    material  & T [K]\\
    \hline
    Sn                     & 3,7 \\
    Pb                     & 7,2 \\
    Al                     & 1,2\\
  \end{tabular}
  \label{Tab:Tcr}
\end{table}
\end{document}

enter image description here

Now I will add an version that defies my earlier assertion. With the caption package, the \captionof macro is provided to emulate a table without the use of the floating table environment. And \captionof can take a label. So, technically, you still are not \labeling the tabular, but only the \captionof.

\documentclass{article}
\usepackage{caption}
\begin{document}
Critical temperature for different Type I superconductors is given in Table~\ref{Tab:Tcr}
\begin{center}
  \captionof{table}{My Table\label{Tab:Tcr}}
  \begin{tabular}{l l}
    material  & T [K]\\
    \hline
    Sn                     & 3,7 \\
    Pb                     & 7,2 \\
    Al                     & 1,2\\
  \end{tabular}
\end{center}
\end{document}