About the distance between the caption and the main body

I found that there is too much space between the caption of the figure and the main body. (The caption is below the figure). I don't know how to reduce the distance among them? the code I use now is as follows,

\begin{figure}[htbp]
\begin{center}
\includegraphics[width=8cm]{./Fig/ransac.eps}
\end{center}
\vspace{-4mm}
\caption{An illustration of a pair of mismatched images.}
\label{2_RANSAC}
\end{figure}


Does anyone know how to solve this?

• Welcome to TeX.SX! Could you please keep separate the questions? You are allowed to ask different questions, so it is better to split this one into two as they concern different topics. – Claudio Fiandrino Oct 27 '13 at 15:08
• Don't use the center environment but \centering instead. (The center environment will add extra vertical space.) – Axel Sommerfeldt Oct 27 '13 at 15:13
• @ClaudioFiandrino You mean that I have to split the questions in to 2 separately? – happygygt Oct 27 '13 at 15:26
• @AxelSommerfeldt I have replace the center with centering, But it seems that there is no use on the distance between the caption and the major body. – happygygt Oct 27 '13 at 15:28
• @happygygt Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – yo' Oct 27 '13 at 15:50

Two suggestions:

• Don't use the center environment to center a graph inside a figure environment. Use the instruction \centering instead. This will avoid inserting lots of unwanted vertical whitespace.

• Use the parameters \abovecaptionskip and \belowcaptionskip to set the distances between (a) the graph and the caption and (b) the caption and the "end" of the figure (or table) environment.

The following examples show the results of your original code, a modication that gets by without use of the center environment and without \vspace instructions, and a final modification that also shrinks the values of \abovecaptionskip and \belowcaptionskip, by 8 points each in the examples. The \hrule commands are there to outline the boundaries of the figure environments. I trust that these tools will let you find a setup that's to your liking.

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}

original code:
\hrule
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=8cm]{./Fig/ransac.eps}
\end{center}
\vspace{-4mm}
\caption{An illustration of a pair of mismatched images.}
\label{fig:1}
\end{figure}
\hrule

\bigskip
next try:
\hrule
\begin{figure}[htbp]
\centering
\includegraphics[width=8cm]{./Fig/ransac.eps}
\caption{An illustration of a pair of mismatched images.}
\label{fig:2}
\end{figure}
\hrule

\bigskip
final try:
\hrule
\begin{figure}[htbp]
\centering
\includegraphics[width=8cm]{./Fig/ransac.eps}
\caption{An illustration of a pair of mismatched images.}
\label{fig:3}
\end{figure}
\hrule
some text \emph{after} a figure'' environment
\end{document}

• I have tried your method. add the commanding,\hrule, \bigskip \addtolength\abovecaptionskip{-8pt},\addtolength\belowcaptionskip{-8pt}, and replace begin{center} with \centering. But it turns out useless. And there even appears a line below the caption. I really confused why does this command you suggested seem useless in my environment? – happygygt Oct 28 '13 at 0:30
• You are not supposed to put in the \hrules and the \bigskip. They are there to make the changes more visible. The suggestion is to replace the center environment with \centering and if that doesn't sufficiently reduce the space, tinker with different values of \abovecaptionskip and \belowcaptionskip. I would also point out that LaTeX adds \textfloatsep` between figures and the main body of text. You can also experiment with giving that length parameter different values. – Dan Oct 28 '13 at 4:14