[Tex/LaTex] How to remove space between a specific image and its caption

captions

In this post (How to reduce space between image and its caption?) there is an excellent explanation about the way you can reduce space between figures and its captions.

The problem is it works for every figure in the document. How could I change the space between a specific image (just one) and its caption?

Thanks.

Best Answer

You can use the caption package and its skip key inside a \captionsetup with local effect (use the desired length instead of the 0pt I chose for the example):

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}

\begin{document}

\begin{figure}
\centering
\captionsetup{skip=0pt}
\includegraphics[width=6cm]{example-image-a}
\caption{A test caption}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=6cm]{example-image-b}
\caption{A test caption}
\end{figure}

\end{document}

enter image description here