22

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?

0

1 Answer 1

39

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}
3
  • If I may, loading caption would be useful here.
    – Bernard
    Commented Jun 21, 2017 at 15:38
  • 1
    @Bernard Would that be because it provides \captionof or did you have another reason in mind? I modified to make use of the \captionof approach. Commented Jun 21, 2017 at 16:44
  • 1
    No, it's only because basic LaTeX forgets to swap the values of \abovecaptionskip (10pt by default, if I remember well) and \belowcaptionskip (0pt by default) when the caption is above table, whereas caption does.
    – Bernard
    Commented Jun 21, 2017 at 16:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .