The space between the table and its caption is very small
You could try
\usepackage{caption}
\captionsetup[table]{skip=10pt}
in your preamble. On another note, have a look at Why should a table caption be placed above the table?
My attention was drawn to this question by another one that had been posted on TeX-LaTeX Meta. In spite of having been asked almost six years ago, not only—IMHO, of course!—is this question still attracting poor answers, it also lacks a satisfactory answer among all those that have been posted so far, including the previous version of this one. This claim might sound as harsh criticism and obviously needs adequate justification, which I’ll try to provide below; but I want to make it clear at the outset that, since the spacing around captions can depend on many interrelated factors (the choice of the document class, in the first place), a comprehensive analysis of the problem would lead us too far. In this answer, I’ve chosen to concentrate on how the caption
package can help to control that spacing, also overriding, if necessary, the decisions made by the document class.
As I said, this answer is an extensive modification of a previous, clearly unsatisfactory version, which corresponded, more or less, to what is now the section covering the use of the caption
package with the article
class.
Spacing Around Captions: The Rôle of the Document Class
As David Carlisle remarked a few minutes after the question was posted, the behavior described therein is not what the standard classes (article
, report
, books
) do; shortly after, Barbara Beeton added that the AMS classes (amsart
, amsbook
, amsproc
) do produce a similar output when the caption of a table is placed below the table itself, since they assume that only in figure
s the caption occurs at the bottom, while in table
s (and in all other other types of floating objects) it is placed at the top. (See, for instance, amsart.cls
, lines 1401–1408.) Other document classes make a similar assumption, so you will incur in a similar problem, when using those classes, if you insist on captioning tables at the bottom, as the standard classes expect you to do. The llncs
class is one of them (see llncs.cls
, l. 789–799 and l. 811–820). We choose to demonstrate only the behavior of amsart
and of article
.
The “native” behavior of the amsart
class
The following source
\documentclass[a4paper]{amsart}
\usepackage[T1]{fontenc} % I’m accustomed to always loading it...
\usepackage{booktabs}
\usepackage{mwe}
\begin{document}
In figure~\ref{fig:sample} the caption is below
and in table~\ref{tab:sample} it is above:
with the \textsf{amsart} class, they both look right.
\begin{figure}[tbp]
\centering
\includegraphics[scale=0.5]{image}
\caption{A sample image}
\label{fig:sample}
\end{figure}
\begin{table}[tbp]
\centering
\caption{A sample table}
\label{tab:sample}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\end{table}
Table~\ref{tab:inverted} has the caption below:
with the \textsf{amsart} class, the spacing is wrong.
\begin{table}[tbp]
\centering
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\caption{A table with a caption below}
\label{tab:inverted}
\end{table}
Random text follows, just to fill the page up.
\lipsum[1-2]
\end{document}
yields the following output:
When the caption is below the table, the spacing is wrong. This is similar to the OP’s case.
The “native” behavior of the article
class
Source code:
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} % I’m accustomed to always loading it...
\usepackage{booktabs}
\usepackage{mwe}
\begin{document}
In figure~\ref{fig:sample} the caption is below
and in table~\ref{tab:sample} it is above:
with the \textsf{article} class, the former looks right,
but the latter does not.
\begin{figure}[tbp]
\centering
\includegraphics[scale=0.5]{image}
\caption{A sample image}
\label{fig:sample}
\end{figure}
\begin{table}[tbp]
\centering
\caption{A sample table}
\label{tab:sample}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\end{table}
On the other hand, table~\ref{tab:inverted}, which has the caption below,
looks right with the \textsf{article} class.
\begin{table}[tbp]
\centering
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\caption{A table with a caption below}
\label{tab:inverted}
\end{table}
Random text follows, just to fill the page up.
\lipsum[1-2]
\end{document}
Output:
Although even the standard classes allow you to customize, by changing the values of the two style parameters \abovecaptionskip
and \belowcaptionskip
, the vertical space above and below the captions, they make the unfortunate assumption that all types of caption are placed in the same position (either all above, or all below) with respect to the object they refer to.
Remedies
We already hinted at the fact that several remedies are possible, but that we’ll stick to a few simple ones, based on the caption
package. But first, let’s see why I deem the already existing answers unsatisfactory.
Drawbacks of the other answers
The accepted answer (which has got, as of this writing, 44 votes!) is simply wrong, in general, as you can readily verify, for example in the case of the amsart
class, if you apply it to the sample source code given above:
\documentclass[a4paper]{amsart}
%\documentclass[a4paper]{llncs}
\usepackage[T1]{fontenc} % I’m accustomed to always loading it...
\usepackage{caption}
\usepackage{booktabs}
\usepackage{mwe}
\captionsetup[table]{skip=10pt plus 0.01pt}
%\captionsetup{tableposition=above}
\makeatletter
%\renewenvironment{table}
% {\@float{table}}
% {\end@float}
%\renewenvironment{table*}
% {\@dblfloat{table}}
% {\end@dblfloat}
\newcommand*\DrawHoriLine{%
\par
\dimen@ \prevdepth
\kern -.1\p@
\hrule \@height .1\p@ \@depth .1\p@
\kern -.1\p@
\prevdepth \z@
\null
\vskip -\baselineskip
\prevdepth \dimen@
}
\newcommand*\PrintSkips[1]{%
\typeout{In #1:}%
\typeout{\@spaces above: \the\abovecaptionskip}%
\typeout{\@spaces below: \the\belowcaptionskip}%
}
\makeatother
\begin{document}
In figure~\ref{fig:sample} the caption is below
and in table~\ref{tab:sample} it is above:
with the \textsf{amsart} class, they both look right.
\begin{figure}[tbp]
\DrawHoriLine
\centering
\PrintSkips{figure}
\includegraphics[scale=0.5]{image}
\caption{A sample image}
\label{fig:sample}
\DrawHoriLine
\end{figure}
\begin{table}[tbp]
\DrawHoriLine
\centering
\PrintSkips{table}
\caption{A sample table}
\label{tab:sample}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\DrawHoriLine
\end{table}
Table~\ref{tab:inverted} has the caption below:
with the \textsf{amsart} class, even if we apply @cmhughes' answer,
the spacing is wrong.
\begin{table}[tbp]
\DrawHoriLine
\centering
\PrintSkips{inverted table}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\caption{A table with a caption below}
\label{tab:inverted}
\DrawHoriLine
\end{table}
Random text follows, just to fill the page up.
\lipsum[1-2]
\end{document}
This code issues some diagnostic messages that helps you verify the claims we are going to make; for the same reason, it also draws thin horizontal lines that mark the exact boundaries of the floats, to make unwanted vertical spaces between the caption and the edges of the float clearly visible. Note that we have made the vertical space introduced by the solution clearly recognizable in diagnostic messages by adding to it a bit of stretchability. Moreover, you can try by yourself different alternatives (e.g., try the efficacy of the solution with the llncs
class) by suitably uncommenting certain lines of code (while commenting out other ones).
It is evident that the accepted answer does not work with the amsart
class; it might nonetheless give the impression of being adequate in the case of the llncs
class, but it isn’t either; indeed:
it introduces spurious spaces between the caption and the edge of the float;
in spite of what the
caption
package claims in a warning issued during the compilation, the look of the captions is changed and differs from that specified by the document class.
Note that the second point does not apply to the amsart
class (because it is one of the classes the package is aware of). With the llncs
class, however, the fact that the look of captions is not preserved can be a problem, and one might prefer, for this reason, to avoid the caption
package altogether. Actually, in this case the simplest thing to do, if one insists on captioning tables “from below”, is probably to restore the original definition of the two environments table
and table*
, as given in the article
class (on which llncs
is based). This is achieved uncommenting the lines
%\renewenvironment{table}
% {\@float{table}}
% {\end@float}
%\renewenvironment{table*}
% {\@dblfloat{table}}
% {\end@dblfloat}
in the code shown above. Since I’m struggling (once more!) with the 30000 character limit, I’ll leave to you to check that what I’ve just said is true, as well as to try other possible alternatives, by suitably commenting/uncommenting parts of that code. After all, the llncs
class is not a part of the standard distributions, and I want this answer to focus on solutions that work with the standard classes. Let me draw attention, however, to an additional drawback of the accepted answer: it sets the skip between the caption and the table to a value that ignores the setting made by the document class. For example, the amsart
class uses 12pt, not 10pt.
I find @isk27’s answer and @agold’s defective in similar ways: besides suggesting a patch that needs to be applied to each float individually, they ignore the style parameters preset by the class. The center
environment, in particular, yields too much space.
Using the caption
package
Actually, simply loading the caption
package should solve the issue: see section 2.6 of its manual, beginning on page 13. Note that the command
\captionsetup[table]{skip=10pt}
specifies the value of the skip between the caption and the captioned object, and should be used only if you want to alter the value preset by the document class, which, as already remarked, is not always a good idea. One should say, rather,
\captionsetup[table]{position=above}
but this is not needed in simple circumstances, because the default setting position=auto
is usually capable of guessing automatically where the captions occurs (above or below the floating object). Should this fail, besides the declaration shown above, you can also use the following shortcut, which also works, when you load the package:
\usepackage[tableposition=above]{caption}
See section 5 of the manual of the caption
package for information on how the package interacts with some known document classes. Complete, compilable examples, which illustrate its behavior with the article
and the amsart
classes, and also show how you can override the general settings for a particular table, follow in the next sections.
The strategy that the caption
table uses to adjust the vertical space around captions sometimes swaps the meaning of the style parameters \abovecaptionskip
and \belowcaptionskip
; all the examples in the next sections print the values of those parameters, to help you understand what the package is doing.
article
Document Class
Recall that, with article
, you need to change the default behavior if you want to caption tables “from above”.
article
+ caption
, default settings
In this case, usually, the caption
package is smart enough to insert the correct spaces in all cases, even if you include an exceptional table that is captioned differently from the others; however, this is not guaranteed to work in all situations.
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} % I’m accustomed to always loading it...
%
% The following should generally suffice...
\usepackage{caption}
%
% ... but if it doesn't, use, for example, the "tableposition" option:
% \usepackage[tableposition=above]{caption}
%
% Other packages follow:
\usepackage{booktabs}
\usepackage{mwe}
\makeatletter
\newcommand*\PrintSkips[1]{%
\typeout{In #1:}%
\typeout{\@spaces above: \the\abovecaptionskip}%
\typeout{\@spaces below: \the\belowcaptionskip}%
}
\makeatother
\begin{document}
Now figure~\ref{fig:sample} (with the caption below)
and table~\ref{tab:sample} (with the caption above)
both look correct. Remember that we are using the
\textsf{article} class.
\begin{figure}[tbp]
\centering
\PrintSkips{figure}
\includegraphics[scale=0.5]{image}
\caption{A sample image}
\label{fig:sample}
\end{figure}
\begin{table}[tbp]
\centering
\PrintSkips{table}
\caption{A sample table}
\label{tab:sample}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\end{table}
An exceptional table that, like table~\ref{tab:inverted},
has the caption below, is still handled correctly, if we
we do \emph{not} specify to the \textsf{caption} package
any positioning option for captions (the default
\texttt{position=auto} remains in force).
However, this is not guaranteed to work in all situations.
\begin{table}[tbp]
\centering
\PrintSkips{inverted table}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\caption{A table with a caption below}
\label{tab:inverted}
\end{table}
Random text follows, just to fill the page up.
\lipsum[1-2]
\end{document}
Output:
article
+ caption
+ tableposition=above
If you explicitly specify tableposition=above
, however, an exceptional table with the caption below will not be handled correctly.
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} % I’m accustomed to always loading it...
%
% The following should generally suffice...
% \usepackage{caption}
%
% ... but if it doesn't, use, for example, the "tableposition" option:
\usepackage[tableposition=above]{caption}
%
% Other packages follow:
\usepackage{booktabs}
\usepackage{mwe}
\makeatletter
\newcommand*\PrintSkips[1]{%
\typeout{In #1:}%
\typeout{\@spaces above: \the\abovecaptionskip}%
\typeout{\@spaces below: \the\belowcaptionskip}%
}
\makeatother
\begin{document}
Now figure~\ref{fig:sample} (with the caption below)
and table~\ref{tab:sample} (with the caption above)
both look correct. Remember that we are always using
the \textsf{article} class.
\begin{figure}[tbp]
\centering
\PrintSkips{figure}
\includegraphics[scale=0.5]{image}
\caption{A sample image}
\label{fig:sample}
\end{figure}
\begin{table}[tbp]
\centering
\PrintSkips{table}
\caption{A sample table}
\label{tab:sample}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\end{table}
If the \textsf{caption} package is explicitly loaded
specifyig \texttt{tableposition=above}, though,
an exceptional table that, like table~\ref{tab:inverted},
has the caption below, will \emph{not} be handled correctly.
\begin{table}[tbp]
\centering
\PrintSkips{inverted table}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\caption{A table with a caption below}
\label{tab:inverted}
\end{table}
Random text follows, just to fill the page up.
\lipsum[1-2]
\end{document}
Output:
Such an exceptional table can still be coped with by means of a \captionsetup
command issued in the body of the floating environment.
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc} % I’m accustomed to always loading it...
%
% The following should generally suffice...
% \usepackage{caption}
%
% ... but if it doesn't, use, for example, the "tableposition" option:
\usepackage[tableposition=above]{caption}
%
% Other packages follow:
\usepackage{booktabs}
\usepackage{mwe}
\makeatletter
\newcommand*\PrintSkips[1]{%
\typeout{In #1:}%
\typeout{\@spaces above: \the\abovecaptionskip}%
\typeout{\@spaces below: \the\belowcaptionskip}%
}
\makeatother
\begin{document}
Now figure~\ref{fig:sample} (with the caption below)
and table~\ref{tab:sample} (with the caption above)
both look correct. We are always using the \textsf{article} class.
\begin{figure}[tbp]
\centering
\PrintSkips{figure}
\includegraphics[scale=0.5]{image}
\caption{A sample image}
\label{fig:sample}
\end{figure}
\begin{table}[tbp]
\centering
\PrintSkips{table}
\caption{A sample table}
\label{tab:sample}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\end{table}
Even when \texttt{tableposition=above} has been specified,
an exceptional table that, like table~\ref{tab:inverted},
has the caption below, can still be dealt with by means
of a \verb|\captionsetup| command issued in the body of
the floating environment. This is guaranteed to work.
\begin{table}[tbp]
\centering
\captionsetup{position=below}
\PrintSkips{inverted table}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\caption{A table with a caption below}
\label{tab:inverted}
\end{table}
Random text follows, just to fill the page up.
\lipsum[1-2]
\end{document}
Output:
amsart
Document Class
Recall that, with amsart
, you need to change the default behavior if you want to caption tables “from below”.
amsart
+ caption
, default settings
With amsart
, the default setting imply that all floats except figure
s (in particular, all table
s) should be captioned above. Unfortunately, with amsart
the caption
package does not handle correctly an exceptional table that is captioned the other way round.
\documentclass[a4paper]{amsart}
\usepackage[T1]{fontenc} % I’m accustomed to always loading it...
%
% The following should generally suffice...
\usepackage{caption}
%
% ... but if it doesn't, use, for example, the "tableposition" option:
% \usepackage[tableposition=above]{caption}
%
% Other packages follow:
\usepackage{booktabs}
\usepackage{mwe}
\makeatletter
\newcommand*\PrintSkips[1]{%
\typeout{In #1:}%
\typeout{\@spaces above: \the\abovecaptionskip}%
\typeout{\@spaces below: \the\belowcaptionskip}%
}
\makeatother
\begin{document}
Remember? With the \textsf{amsart} class,
figure~\ref{fig:sample} (with the caption below)
and table~\ref{tab:sample} (with the caption above)
both looked correct; the same happens if we load the
\textsf{caption} package, as we are doing now.
So, loading the package seems useless in this case,
but it does not harm.
\begin{figure}[tbp]
\centering
\PrintSkips{figure}
\includegraphics[scale=0.5]{image}
\caption{A sample image}
\label{fig:sample}
\end{figure}
\begin{table}[tbp]
\centering
\PrintSkips{table}
\caption{A sample table}
\label{tab:sample}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\end{table}
Unfortunately, with the \textsf{amsart} class,
an exceptional table that, like table~\ref{tab:inverted},
has the caption below, will \emph{not} be handled correctly,
if we load the \textsf{caption} package without specifying
any positioning option for captions (thereby leaving
the default \texttt{position=auto} in force).
\begin{table}[tbp]
\centering
\PrintSkips{inverted table}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\caption{A table with a caption below}
\label{tab:inverted}
\end{table}
Random text follows, just to fill the page up.
\lipsum[1-2]
\end{document}
Output:
amsart
+ caption
+ tableposition=above
This is the same as the case of the previous subsection. Of course, you can still cope with an exceptional table with the caption below by means of a \captionsetup
command issued in the body of the floating environment.
\documentclass[a4paper]{amsart}
\usepackage[T1]{fontenc} % I’m accustomed to always loading it...
%
% The following should generally suffice...
% \usepackage{caption}
%
% ... but if it doesn't, use, for example, the "tableposition" option:
\usepackage[tableposition=above]{caption}
%
% Other packages follow:
\usepackage{booktabs}
\usepackage{mwe}
\makeatletter
\newcommand*\PrintSkips[1]{%
\typeout{In #1:}%
\typeout{\@spaces above: \the\abovecaptionskip}%
\typeout{\@spaces below: \the\belowcaptionskip}%
}
\makeatother
\begin{document}
Remember? With the \textsf{amsart} class,
figure~\ref{fig:sample} (with the caption below)
and table~\ref{tab:sample} (with the caption above)
both looked correct; the same happens if we load the
\textsf{caption} package, as we are doing now.
So, loading the package seems useless in this case,
but it does not harm.
\begin{figure}[tbp]
\centering
\PrintSkips{figure}
\includegraphics[scale=0.5]{image}
\caption{A sample image}
\label{fig:sample}
\end{figure}
\begin{table}[tbp]
\centering
\PrintSkips{table}
\caption{A sample table}
\label{tab:sample}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\end{table}
However, the \textsf{caption} package is still useful in that
an exceptional table that, like table~\ref{tab:inverted},
has the caption below, can correctly be dealt with,
even when the package is loaded with \texttt{tableposition=above},
by means of a \verb|\captionsetup| command issued in the body
of the floating environment.
\begin{table}[tbp]
\centering
\captionsetup{position=below}
\PrintSkips{inverted table}
\begin{tabular}{lcc}
\toprule
Titles & Data 1 & Data 2 \\
\midrule
This is the first row & 12 & 34 \\
This is the second row & 56 & 78 \\
This is---guess what?---the third row & 90 & ?? \\
\bottomrule
\end{tabular}
\caption{A table with a caption below}
\label{tab:inverted}
\end{table}
Random text follows, just to fill the page up.
\lipsum[1-2]
\end{document}
Output:
Note that the same workaround should be applied also if the caption
package is loaded with default setting (try it).
I had the same problem and I have found that using \begin{center}
and \end{center}
instead of \centering
does add more space between the caption and the table:
\begin{table}
\begin{center}
\begin{tabular}{|l||c|c|}
\hline&Column 1&Column 2\\
\hline\hline
cell1 & cell2 & cell3 \\\hline
cell1 & cell2 & cell3 \\\hline
\end{tabular}
\end{center}
\caption{A test caption 2.}
\label{tab:attempt2}
\end{table}
This results in:
However, as commented before, when no special packages/settings are used the normal output already has sufficient space:
\begin{table}
\centering
\begin{tabular}{|l||c|c|}
\hline&Column 1&Column 2\\
\hline\hline
cell1 & cell2 & cell3 \\\hline
cell1 & cell2 & cell3 \\\hline
\end{tabular}
\caption{A test caption.}
\label{tab:attempt1}
\end{table}