0

How can I reduce the gap between the subfloat and its caption? I tried to use

\captionsetup[subfigure]{aboveskip=0pt} 

but it doesnt work for me. Below is the snippet i have and the output

\begin{figure}
\captionsetup[subfigure]{labelformat=empty}
\captionsetup[subfigure]{aboveskip=0pt}
    \centering
    \subfloat[Ground Truth]{{\includegraphics[width=\textwidth]{ood-ms/ood-1-gt.png} }}
    \\ \vspace{-1\baselineskip}
    \subfloat[Recurrent Neural Network]{{\includegraphics[width=\textwidth]{ood-ms/ood-1-rnn.png} }}
    \\ \vspace{-1\baselineskip}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-1-vrnn.png} }}
    \\ \vspace{-0.5\baselineskip} \noindent\rule{14cm}{0.4pt}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-3-gt.png} }}
    \\ \vspace{-1\baselineskip}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-3-rnn.png} }}
    \\ \vspace{-1\baselineskip}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-3-vrnn.png} }}
    \\ \vspace{-0.5\baselineskip} \noindent\rule{14cm}{0.4pt}
        \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-1-gt.png} }}
    \\ \vspace{-1\baselineskip}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-1-rnn.png} }}
    \\ \vspace{-1\baselineskip}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-1-vrnn.png} }}
    \\ \vspace{-0.5\baselineskip} \noindent\rule{14cm}{0.4pt}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-3-gt.png} }}
    \\ \vspace{-1\baselineskip}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-3-rnn.png} }}
    \\ \vspace{-1\baselineskip}
    \subfloat[]{{\includegraphics[width=\textwidth]{ood-ms/ood-3-vrnn.png} }}
    \\ \vspace{-1\baselineskip}
    \caption{}
    \label{fig:ms}
\end{figure}

Here is the output

enter image description here

5
  • Try just using skip= (I don't recommend 0pt), and remove the \vspaces.
    – Bernard
    Dec 24, 2017 at 23:19
  • i need the vspace to keep my large figure in 1 page
    – Kong
    Dec 24, 2017 at 23:22
  • With skip=0pt+ \vspace{-\baselineskip}, there are chances the figures touch each other. Is there any reason why some rows might not go to the following page?
    – Bernard
    Dec 24, 2017 at 23:27
  • i need all the subplots to be in a page and if i do not use \vspace some of them dont show up in the page. I tried \captionsetup[subfigure]{skip=-10pt} and some other numbers but i dont see any effect
    – Kong
    Dec 24, 2017 at 23:31
  • any easier solution ?
    – Kong
    Dec 27, 2017 at 20:51

1 Answer 1

2

like this?

enter image description here

instead of \subfloat environments from subfig package i would rather use tabular and for rules use \midrule from booktabs package:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{booktabs}

%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{figure}[p]
\newcommand\insertimage[1]{\includegraphics[width=\textwidth,height=13mm]{#1}}
    \centering
\begin{tabular*}{\textwidth}{@{}c@{}}
\insertimage{ood-ms/ood-1-gt.png}       \\
    Ground Truth                        \\
\insertimage{ood-ms/ood-1-rnn.png}      \\
    Recurrent Neural Network            \\
\insertimage{ood-ms/ood-1-vrnn.png}     \\
    \midrule
    \addlinespace
\insertimage{ood-ms/ood-3-gt.png}       \\
\insertimage{ood-ms/ood-3-rnn.png}      \\
\insertimage{ood-ms/ood-3-vrnn.png}     \\
    \midrule
    \addlinespace
\insertimage{ood-ms/ood-1-gt.png}       \\
\insertimage{ood-ms/ood-1-rnn.png}      \\
\insertimage{ood-ms/ood-1-vrnn.png}     \\
    \midrule
    \addlinespace
\insertimage{ood-ms/ood-3-gt.png}       \\
\insertimage{ood-ms/ood-3-rnn.png}      \\
\insertimage{ood-ms/ood-3-vrnn.png}
    \end{tabular*}
\caption{}
    \label{fig:ms}
\end{figure}
\end{document}
3
  • your code squeezes my figures horizontally
    – Kong
    Dec 27, 2017 at 20:56
  • @kong, sorry, i don't understand you. i haven't your figure, so i use demo option. size of figures are determined on the same way as you dona in your mwe.
    – Zarko
    Dec 27, 2017 at 21:36
  • sorry, i just had to remove height=13 for it to work correctly. thank you.
    – Kong
    Dec 27, 2017 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.