1

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

7
  • 1
    \caption{} ? Oct 22, 2015 at 16:09
  • @DavidCarlisle. Yes. I don't want to add any comment for the table. But I need it be numbered and referenced. Oct 22, 2015 at 16:11
  • oh you don't even want the number printed? just be able to reference it with \ref ? No you say you do want the number printed. \caption{} will produce something like Table 3 Oct 22, 2015 at 16:12
  • @DavidCarlisle That would take me quite a long time to find.
    – Johannes_B
    Oct 22, 2015 at 16:13
  • @Johannes_B the power of hyperref.... Oct 22, 2015 at 16:14

2 Answers 2

3

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}
1
  • For reference: One can also perform the caption setup locally; within the table environment, if need be.
    – Werner
    Oct 22, 2015 at 17:06
2

How about a \fakecaption that increments the table counter and sets \tablename\ \thetable: ? This way the label and references work.

\documentclass{book}

\newcommand{\fakecaption}{%
  \vskip0.5\baselineskip
  \refstepcounter{table}%
  \tablename\ \thetable%
}

\usepackage{blindtext}



\begin{document}

\blindtext[5]

In Table \ref{lab} we see important stuff!

\blindtext[5]


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

\blindtext[5]

\end{document}

You must log in to answer this question.

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