[Tex/LaTex] How to adjust the gap between figure and caption within the same subfloat

subfloats

My question is:

How to adjust the gap between figure and caption within the same subfloat

Not the gap between two subfloat.

For the following example:

\begin{figure}
    \centering
    \subfloat[A]{\includegraphics[ scale=0.5]{images/a.jpg}}
    \vspace{-10pt}
    \subfloat[B]{\includegraphics[scale=0.5]{images/b.jpg}}
    \vspace{-10pt}
    \caption{}\label{fig:online_test}
\end{figure}

I got the following figure:

enter image description here

The sub-caption of (a) is too close to the sub-figure B. I hope the caption (a) to stay closer to sub-figure A. How can I adjust the space between the caption and figure within a subfloat?

Thank you all for helping me and I would prefer a solution for subfloat, instead of using other packages. But I would also appreciate a solution of using other packages.

I know my question looks similar to this question. But please make it clear. I'm asking for how to adjust the gap between figure and caption within a subfloat, not the gap between two subfloat. That is, the gap between the caption "a" and the figure "A"

Thank you.

Best Answer

your have more problems:

  • with your code i can't reproduce provided images. they are in one line ...
  • problem is probably in images, which have white space below image. to check this, put image in \fbox{...} like

\subfloat[A]{\fbox{\includegraphics[scale=0.5]{images/a.jpg}}}

and see, if the frame is tied width image

  • other causes can be in your document preamble, which you not show. for example the following mwe

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\usepackage[skip=1ex]{caption}

\begin{document}
\begin{figure}
    \centering
    \subfloat[A]{\fbox{\includegraphics[scale=0.5]{images/a.jpg}}}

    \subfloat[B]{\includegraphics[scale=0.5]{images/b.jpg}}
    \caption{}\label{fig:online_test}
\end{figure}
\end{document}

gives the following result:

enter image description here

  • distance between subfloat[...]{...} and caption is determined with option \package[skip=1ex]{caption}. this set vertical space determined by skip globally. if you like to change only for this image, than please add after \begin{figure}

\captionsetup{skip=<desired value}