[Tex/LaTex] The distance between the caption and the table

captionsspacingtables

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}

Best Answer

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.

Related Question