4

I have the following code which outputs one subcaption for each subfigure:

\begin{figure}[]
  \centering
  \subcaptionbox{image 1}%
    {\includegraphics{image1.png}\hspace{0.5cm}
  \subcaptionbox{image 2}%
    {\includegraphics{image2.png}}%

\bigskip

  \subcaptionbox{image 3}}%
    {\includegraphics{image3.png}}\hspace{0.5cm}
  \subcaptionbox{image 4}%
    {\includegraphics{image4.png}}%
  \caption{Four images.}
\end{figure}

Is it possible to modify it to have one subcaption for images 1 and 2 and another subcaption for images 3 and 4?

2 Answers 2

3

Yes, just place two images in each \subcaptionbox.

enter image description here

\documentclass{article}
\usepackage[demo]{graphicx} % the demo option replace images with black boxes
\usepackage{subcaption}
\begin{document}
\begin{figure}
  \centering
  \subcaptionbox{image 1 and 2}%
    {\includegraphics{image1.png}\hspace{0.5cm}\includegraphics{image2.png}}%

\bigskip

  \subcaptionbox{image 3 and 4}%
    {\includegraphics{image3.png}\hspace{0.5cm}\includegraphics{image4.png}}%
  \caption{Four images.}
\end{figure}
\end{document}
1

I think an easier method is to start a subfigure environment and just put the caption after the first and second image instead of making subcaption box.

\begin{figure}[h]
  \centering
  \begin{subfigure}{\textwidth}
        \includegraphics[width=0.49\textwidth]{image1.png}
        \hspace{1cm}
        \includegraphics[width=0.49\textwidth]{image2.png}
        \caption{Image 1 and 2}
        \label{fig:1-2}
  \end{subfigure}
 \hspace{0.5cm}
  \begin{subfigure}{\textwidth}
        \includegraphics[width=0.49\textwidth]{image3.png}
        \hspace{1cm}
        \includegraphics[width=0.49\textwidth]{image4.png}
        \caption{Image 3 and 4}
        \label{fig:3-4}
  \end{subfigure}
\end{figure}

You must log in to answer this question.

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