0

I am using the subfigure environment to show 4 figures, 2 in each line. Now, the problem is that the caption of each figure goes over two lines. I want the caption to be written in one line, but at the same time keep the dimensions of my figures small. Here is how I have included my figures:

\begin{figure}[t!]
    \centering
    \begin{subfigure}{.3\textwidth}
        \includegraphics[width=\linewidth]{imgs/first_figure.png}
        \vspace*{.2cm}
        \caption{My first subcaption.}
    \end{subfigure}\hspace*{3cm}
    \begin{subfigure}{.3\textwidth}
        \includegraphics[width=\linewidth]{imgs/second_figure.png}
        \vspace*{.2cm}
        \caption{second subcaption is slightly longer.}
    \end{subfigure} \\\vspace*{.5cm}
    \begin{subfigure}{.3\textwidth}
        \includegraphics[width=\linewidth]{imgs/third_figure.png}
        \vspace*{.2cm}
        \caption{third subcaption is slightly longer.}
    \end{subfigure}\hspace*{3cm}
    \begin{subfigure}{.3\textwidth}
        \includegraphics[width=\linewidth]{imgs/fourth_figure.png}
        \vspace*{.2cm}
        \caption{fourth subcaption is slightly longer.}
    \end{subfigure}
    \vspace*{.5cm}
    \caption{Four figures.}
\end{figure}

I tried putting an additional \hspace*{-2cm} in front of each subcaption, but it litterally had no effect at all. That's strange as the \vspace*{.2cm} is doing exactly what I intended. Any suggestions?

1
  • The caption gets its width from the minipage. Using negative \hspace won't help. You would need another minipage or \parbox with a wider width. Jun 22 '20 at 16:09
1

Since you have 4 subfigures, you can easily use up to 0.5\textwidth for each. You just need to shrink the images.

\documentclass{article} 
\usepackage{graphicx}
\usepackage{subcaption}
\begin{document}
\begin{figure}[t]
    \advance\abovecaptionskip  by 0.2cm
    \centering
    \begin{subfigure}{.5\textwidth}
        \centering
        \includegraphics[width=0.6\linewidth]{example-image-a}
        \caption{My first subcaption.}
    \end{subfigure}%
    \begin{subfigure}{.5\textwidth}
        \centering
        \includegraphics[width=0.6\linewidth]{example-image-b}
        \caption{second subcaption is slightly longer.}
    \end{subfigure}
    
    \begin{subfigure}{.5\textwidth}
        \centering
        \includegraphics[width=0.6\linewidth]{example-image-c}
        \caption{third subcaption is slightly longer.}
    \end{subfigure}%
    \begin{subfigure}{0.5\textwidth}
        \centering
        \includegraphics[width=0.6\linewidth]{example-image}
        \caption{fourth subcaption is slightly longer.}
    \end{subfigure}
    \vspace{.3cm}% plus 0.2
    \caption{Four figures.}
\end{figure}
\end{document}

demo

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.