[Tex/LaTex] Table with number but without caption

tables

Is there a way to add a table with a table-number shown below it, but without any caption?

I also need to add a label for referencing the table.

When I use \caption{}:

\documentclass{book}

\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|c|c|}
\hline
1
&
2
\\\hline
\end{tabular}
\caption{}\label{lab}
\end{table}

\end{document}

The tabled is numbered but it has : after the number as if there is some caption after it.

enter image description here

Best Answer

Adding \caption{} to a table adds an unwanted table separator to the caption. For example, you might end up with a caption:

Table 1:

You can control this, for example, with the package caption. For example:

\documentclass{article}

\usepackage{booktabs}
\usepackage[labelsep=none]{caption}

\begin{document}

\begin{table}
  \centering
  \begin{tabular}{cc}
    \toprule
    left number & right number \\
    \midrule
     5.6 &  3.8 \\
     1.3 & 20.4 \\
    10.4 &  5.2 \\
     1.3 &  0.8 \\
     7.2 &  3.9 \\
     2.5 & 16.2 \\
     \bottomrule
  \end{tabular}
  \caption{}
  \label{tab:tab}
\end{table}

Let's refer to Table~\ref{tab:tab}.

\end{document}

The caption now reads:

Table 1

If there are other tables that need an ordinary caption, you can use \captionsetup to temporarily change options. See the documentation for more details.

The package also contains further options to control the caption. For example, if you really want only the number (without "Table" in front) under the table, you can use:

\documentclass{article}

\usepackage{booktabs}
\usepackage[labelsep=none,labelformat=empty]{caption}

\begin{document}

\begin{table}
  \centering
  \begin{tabular}{cc}
    \toprule
    left number & right number \\
    \midrule
     5.6 &  3.8 \\
     1.3 & 20.4 \\
    10.4 &  5.2 \\
     1.3 &  0.8 \\
     7.2 &  3.9 \\
     2.5 & 16.2 \\
     \bottomrule
  \end{tabular}
  \caption{\ref{tab:tab}}
  \label{tab:tab}
\end{table}

Let's refer to table~\ref{tab:tab}.

\end{document}
Related Question