# The distance between the caption and the table

I use the following table in Latex. And I want to decrease the distance between the caption and the table. And also I want to adjust the distance between the table and the above text; the distance between the caption and the following text.

So I search on google. I find \captionsetup[table]{belowskip=0pt} or \setlength{\abovetopsep}{10pt} and so on. But they do not work. I do not see the difference.

\begin{tabularx}{\textwidth}{XXXXX}
\toprule
F          &   G       &    E  \\\midrule
convex     & convex    &-      \\\midrule
$C^{1,1}$  & convex    &-      \\\midrule
-          &  -        & convex\\\midrule
convex     &convex     &-      \\\bottomrule
\end{tabularx}\captionof{table}{Comparison of solvers}
• \captionof will use the class specified setting of captions but you have given no indication of what class (or caption package) settings you are using so it is hard to say how to change them. Please always provide a complete document that shows the problem. – David Carlisle Apr 24 '14 at 11:40
• But do you want the caption to be above (as is usually) or below your table? – Bernard Apr 24 '14 at 12:30
• @Bernard, it should below my table. – Vivian Apr 24 '14 at 12:45
• @DavidCarlisle, thank you for your comment. It is a paper for submitting. It does not have a class. – Vivian Apr 24 '14 at 12:45
• every latex document has a class, specified on the first line \documentclass{???} – David Carlisle Apr 24 '14 at 13:05

Instead of captionof you can put tabularx in a table float environment and use the normal caption. Then you should be able to adjust spacing using \vspace{} directive.

For instance,

\begin{table}
\vspace{-1cm} % reduce distance above table
\begin{tabularx}{\textwidth}{XXXXX}
\toprule
F          &   G       &    E  \\\midrule
convex     & convex    &-      \\\midrule
$C^{1,1}$  & convex    &-      \\\midrule
-          &  -        & convex\\\midrule
convex     &convex     &-      \\\bottomrule
\end{tabularx}
\vspace{-2cm} % Reduce distance between caption and table
\caption{Comparison of solvers}
\vspace{-2cm} % Reduce distance after caption to text
\end{table}

and change the vspace arguments to what you want. Negative value will make texts come closer and positive values will increase space.

• \captionof just calls \caption internally so any spacing you apply here could have been applied to the original form. – David Carlisle Apr 24 '14 at 12:26
• A disadvantage of this approach is that you have to apply the \vspace instructions for each and every table (and figure) instance. It may be more convenient to modify the length parameter \abovecaptionskip. – Mico Apr 24 '14 at 13:04
• That is true and is depending on the use-case of course. I'll bookmark your post anyway, because defaults are sometimes nicer :) – Trefex Apr 24 '14 at 14:33

Assuming the caption is set below the tabular material -- as is the case in your example -- the vertical space above the caption is governed by the length parameter \abovecaptionskip. Its default value is the nominal font size of the document, e.g., 10pt. To change this parameter, use \setlength\abovecaptionskip{<some length>}.

\documentclass{article}
\usepackage{tabularx,caption}
\setlength\parindent{0pt} % just for this example
\begin{document}
\verb+\abovecaptionskip+ at default value:

\begin{tabularx}{\textwidth}{X}
\hline
\end{tabularx}
\captionof{table}{First dummy table}

\vspace{2cm}
\setlength\abovecaptionskip{2\baselineskip}

\verb+\abovecaptionskip+ set to \verb+2\baselineskip+:

\begin{tabularx}{\textwidth}{X}
\hline
\end{tabularx}
\captionof{table}{Second dummy table}
\end{document}