# How to remove space between table and caption? [duplicate]

Possible Duplicate:
How to reduce space between image and its caption?

I am working on one example in which i need to draw one table and its caption. How can i control the space between Title, Table and caption. I want to minimize the spacing.

 \usepackage{transparent}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{hyphenat}
\usepackage{xstring}
\usepackage{forloop}
\usepackage{collcell}
\usepackage{longtable}
\usepackage{makecell}
\usepackage{varwidth}
\usepackage{fancyhdr}
\usepackage{array,multirow,colortbl}
\usepackage{caption}
\usepackage{subfig}
\usepackage[table]{xcolor}
\pagestyle{fancy}
\fancyhf{} % sets both header and footer to nothing
\fancyfoot{}
\begin{document}

\arrayrulecolor{white}

\definecolor{maincol}{rgb}{.118, .565, 1.00}
\definecolor{textcol}{rgb}{.118, .565, 1.00}

\captionsetup[table]{aboveskip=0pt}
\captionsetup[table]{belowskip=10pt}
\textcolor{textcol}{\textbf{ XYZ }}
\scriptsize

\arrayrulecolor{white}
\begin{longtable}{|M{1.4cm}|M{1.4cm}|M{1cm}|M{3.7cm}|M{1.8cm}|M{1.4cm}|}
\rowcolor{maincol} \textbf{ \textcolor{white}{A}} &\textbf{      \textcolor{white}{B}} &\textbf{ \textcolor{white}{C}} &\textbf{ \textcolor{white}{D}} &\textbf{ \textcolor{white}{E}}  &\textbf{    \textcolor{white}{F} }\\
\hline
\rowcolor{rowcol}
AA
&  AA&  A&  DDD  & [1, 2]  &  TTT \\
\hline
\rowcolor{rowcol}
& & & & Total  & TTT \\
\end{longtable}
\scriptsize
\textit{This is Caption}
\end{document}

-

## marked as duplicate by Axel Sommerfeldt, Kurt, Martin Schröder, percusse, Stefan Kottwitz♦Jan 16 '13 at 12:30

For your purpose you can set skip=0pt using the caption-package.

As was asked by the OP:

How can i control the font size of caption?

font={<font options>}


The available optiones are: scriptsize, footnotesize, small, normalsize, large and Large. Simply add this to your captionsetup.

For other options regarding the captions, you should check out the documentation.

Here an example.

\documentclass{article}

\usepackage{caption}
\captionsetup{skip=0pt}

\begin{document}

\begin{table}
\centering
\begin{tabular}{llr}
\hline
\multicolumn{2}{c}{Item}             \\
\cline{1-2}
Animal    & Description & Price (\\$) \\
\hline
Gnat      & per gram    & 13.65      \\
& each        & 0.01       \\
Gnu       & stuffed     & 92.50      \\
Emu       & stuffed     & 33.33      \\
Armadillo & frozen      & 8.99       \\
\hline
\end{tabular}
\caption{The classic}
\end{table}

\end{document}


Result

-
Great! How can i control the font size of caption? – manish Jan 16 '13 at 8:58
Depending on what you want: font=large, font=small pr in general font=[fontsize] (note that note all sizes are useable). – xfoo Jan 16 '13 at 9:07
Where to write this font=small, in caption – manish Jan 16 '13 at 9:09
I edited my answer so it should be clear, but here how it can be done: \captionsetup{skip=0pt,font=small}. – xfoo Jan 16 '13 at 9:17

Thank you for giving your entire document ;-). However, for tables the best practice is to put the captions above the table. In your case putting skip=0pt and putting the caption above the longtable :

 \documentclass{article}
\usepackage{transparent}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{hyphenat}
\usepackage{xstring}
\usepackage{forloop}
\usepackage{collcell}
\usepackage{longtable}
\usepackage{makecell}
\usepackage{varwidth}
\usepackage{fancyhdr}
\usepackage{array,multirow,colortbl}
\usepackage{caption}
\usepackage{subfig}
\usepackage[table]{xcolor}
\pagestyle{fancy}
\fancyhf{} % sets both header and footer to nothing
\fancyfoot{}
% \begin{document}

\arrayrulecolor{white}

\definecolor{rowcol}{rgb}{.118, .565, 1.00}
\definecolor{maincol}{rgb}{.118, .565, 1.00}
\definecolor{textcol}{rgb}{.118, .565, 1.00}
\newcolumntype{M}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\captionsetup[table]{skip=0pt}        %% here
% \captionsetup[table]{belowskip=10pt}
\textcolor{textcol}{\textbf{ XYZ }}
\scriptsize
\arrayrulecolor{white}
\begin{longtable}{|M{1.4cm}|M{1.4cm}|M{1cm}|M{3.7cm}|M{1.8cm}|M{1.4cm}|}
\caption{this is caption}\\\hline                                       %% caption here
\rowcolor{maincol} \textbf{ \textcolor{white}{A}} &\textbf{\textcolor{white}{B}} &\textbf{ \textcolor{white}{C}} &\textbf{ \textcolor{white}{D}} &\textbf{ \textcolor{white}{E}}  &\textbf{    \textcolor{white}{F} }\\
\hline
\rowcolor{rowcol}
AA  &  AA&  A&  DDD  & [1, 2]  &  TTT \\
\hline
\rowcolor{rowcol}
& & & & Total  & TTT \\
\end{longtable}
\scriptsize
\end{document}


Please note that caption of tables and figures is inserted through a syntax:

\caption[short caption]{long caption}


where short caption is used for running content like headers and list of tables and long caption is what is seen above the table. Also, in long table, the width of the caption is fixed at 4in by default. You may change the width by putting a suitable value in

\setlength{\LTcapwidth}{5in}


@user15662: Already skip=0pt. That means the intermediate space is only the baselineskip. If you want to reduce that also (which I think a bad idea), use something like \textcolor{textcol}{\textbf{ XYZ }} \vspace{-.5\baselineskip}  – Harish Kumar Jan 16 '13 at 9:21