1

Consider the following code

\begin{figure}[h!]
\centering
    \begin{minipage}{\linewidth}
    \centering
    \begin{subfigure}[b]{.4\textwidth}
    \centering
           \includegraphics[width=\linewidth]{example-image}
           \caption{}
    \end{subfigure}
    \centering
    \begin{subfigure}[b]{.4\textwidth}
   \centering
            \includegraphics[width=\linewidth]{example-image}
            \caption{}
    \end{subfigure}
    \end{minipage}
    \par\medskip
   \caption{Example main caption}
\end{figure}

which gives

enter image description here

Is it possible to raise the \caption{} of a single subfigure? For example, get something like

enter image description here

I have tried something like \vspace{-2mm}\caption{}\vspace{2mm}, but it does not seem to work. Any ideas?

1 Answer 1

3

\captionseup inside subfigure environment will only affect that sub-caption

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\captionsetup[sub]{position=bottom}

\begin{document}
\begin{figure}[h!]
  \centering
  \begin{subfigure}[t]{0.48\linewidth}
    \captionsetup{skip=1pt}%
    \includegraphics[width=\linewidth]{example-image}
    \caption{A}
  \end{subfigure}%
  \hfill
  \begin{subfigure}[t]{.48\textwidth}
    \includegraphics[width=\linewidth]{example-image}
    \caption{B}
  \end{subfigure}
  \caption{Example main caption}
\end{figure}
\end{document}

enter image description here

2
  • Any reason you changed [b] to [t]?
    – sam wolfe
    Commented Feb 2, 2023 at 16:13
  • If you keep [b], you essentially tell latex to align both groups w.r.t bottom parts per group, here captions. Because of a reduced distance between an image and a caption on the left, the whole image would be moved downwards. [t] on the other hand, tell latex to align both groups w.r.t. to top parts, here images.
    – Celdor
    Commented Feb 2, 2023 at 16:30

You must log in to answer this question.

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