1

How can I move the subcaptions of the subfloat vertically? My subfigures have a lot of white space and there appears a long white space between the subfigures and the subcaptions. So, I want to move the subcaptions vertically and potentially on the subfigures. Here is the code:

\documentclass{article}
\usepackage{float}
\usepackage[caption=false,font=footnotesize,captionskip=-0.01mm,farskip=0mm]{subfig}
\usepackage{graphicx}
\begin{document}
\begin{figure}[!t]
            \hspace*{-0.85cm}
            \centering 
            \captionsetup{oneside,margin={0.5cm,0cm}}
            \subfloat[]{\includegraphics [height = 34mm] {example-image-a}}
            \hfil
            \vspace{-1.5mm}
            
            \hspace*{-0.85cm}
            \subfloat[]{\includegraphics [height = 34mm] {example-image-b}}
            \hfil
            \vspace{-1.5mm}
            
            \hspace*{-0.85cm}
            \subfloat[]{\includegraphics [height = 34mm] {example-image-c}}
            \hfil
            \vspace{-1.5mm}
            
            \hspace*{-0.85cm}
            \subfloat[]{\includegraphics [height = 34mm] {example-image-d}}
            \hfil
            \vspace{-1.5mm}
            
            \hspace*{-0.85cm}
            \subfloat[]{\includegraphics [height = 34mm] {example-image-e}}
            \vspace{3mm}
            
            \caption{Caption.}\vspace{-3mm}
            \label{label}
\end{figure}
\end{document}
5
  • As always provide a minimal working example (MWE) which includes all required packages and gives the output you get if compiled.
    – Imran
    Jan 18, 2022 at 17:35
  • Hi Imran. Is there anything missing in the above MWE?
    – Ali
    Jan 18, 2022 at 17:36
  • You need to add at least the packages necessary like caption, subcaption, etc and demo images to make the code compile without any modification.
    – Imran
    Jan 18, 2022 at 17:49
  • 1
    Something missing?, yes. Which package do you use for \subfloat command? Package graphicx is not loaded. And we don't have image_... files. It's better that you use images provided by mwe package.
    – Ignasi
    Jan 18, 2022 at 17:50
  • I added the packages that sounded relative. Please let me know what else should be added.
    – Ali
    Jan 18, 2022 at 18:04

1 Answer 1

1

You can control the position of the subcaption using captionskip. A negative value will overlay it on the subfigure.

Use farskip to add some vertical space between the subfigures.

b

\documentclass{article}

\usepackage[caption=false,font=footnotesize,captionskip=-8mm,farskip=5mm]{subfig} % changed <<<<<<<<<<<
\usepackage{graphicx}

\begin{document}
    \begin{figure}[!ht]
        \centering 
        \subfloat[]{\includegraphics [height = 34mm] {example-image-a}}     
        \hfil
        \subfloat[]{\includegraphics [height = 34mm] {example-image-b}}
        \hfil
        \subfloat[]{\includegraphics [height = 34mm] {example-image-c}}
        \hfil
        \subfloat[]{\includegraphics [height = 34mm] {example-image-a}}
        \hfil
        \subfloat[]{\includegraphics [height = 34mm] {example-image-b}}     
        \caption{Caption.}
        \label{label1}
    \end{figure}
\end{document}

\hfil fills all the horizontal space between adjacent subfigures. No need to use \hspace{}.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .