3

enter image description here

I understand how to add images in a (2 X 2) or a (m X n) grid in latex using subcaption, but is it possible to add images in this manner using subcaption?

If not possible, then is there some other package which allows this configuration and also allows cross-referencing?

Here is the MWE that I tried

\usepackage{graphicx} %package for graphics/images
\usepackage{subcaption} %package for subcaptions(Chitran's edit)
\graphicspath{{Figures/}}

\begin{document}
\begin{figure}[t]
    \centering
    \begin{subfigure}[t]{0.24\textwidth}
        \centering
        \includegraphics[width= \linewidth]{Figures/A.png}
        \phantomsubcaption
        \label{figA}
    \end{subfigure}
    \hfill
    \begin{subfigure}[t]{0.24\textwidth}
        \centering
        \includegraphics[width= \linewidth]{Figures/B.png}
        \phantomsubcaption
        \label{figB}
    \end{subfigure}
    \hfill
    \begin{subfigure}[t]{0.48\textwidth}
        \centering
        \includegraphics[width=\linewidth]{Figures/C.png}
        \phantomsubcaption 
        \label{figC}
    \end{subfigure}
     \hfill
    \begin{subfigure}[b]{0.48\textwidth}
        \centering
        \includegraphics[width=\linewidth]{Figures/D.png}
        \phantomsubcaption 
        \label{figD}
    \end{subfigure}
    \caption{(a) fig.A (b) fig.B (c) fig.C (d) fig.D}\label{fig_needed}
\end{figure}

\end{document}

What I end up having is something like this enter image description here

P.S. : Hearty apologies for the imprecise post with no MWE before.

5

1 Answer 1

4

You don't need subfigure if you don't have subcaptions.

I don't have your images, it's up to you to ensure that the heights match.

\documentclass{article}
\usepackage{graphicx} %package for graphics/images
\usepackage{subcaption} %package for subcaptions(Chitran's edit)
\graphicspath{{Figures/}}

\begin{document}

\begin{figure}[t]

\setlength{\tabcolsep}{0pt}% leave computations to LaTeX

\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}ccc}
\includegraphics[width=0.24\columnwidth]{example-image-9x16} &
\includegraphics[width=0.24\columnwidth]{example-image-9x16} &
\begin{tabular}[b]{c}
  \includegraphics[width=0.48\columnwidth]{example-image-16x9} \\[1ex]
  \includegraphics[width=0.48\columnwidth]{example-image-16x9}
\end{tabular}
\end{tabular*}

\caption{(a)~fig.~A (b)~fig.~B (c)~fig.~C (d)~fig.~D}\label{fig_needed}

\end{figure}

\end{document}

enter image description here

A trick if your images don't really match like the one I used.

I experimented a bit and discovered that 0.27 for the first two pictures and 0.41 for the other two gives almost the sizes we need. Since there is a bit of room in the vertical spacing between the wide pictures, we can make it to be automatically filled.

\documentclass{article}
\usepackage{graphicx} %package for graphics/images

\newlength{\mylength}

\begin{document}

\begin{figure}[t]

\setlength{\tabcolsep}{0pt}% leave computations to LaTeX
\settoheight{\mylength}{\includegraphics[width=0.27\columnwidth]{example-image-9x16}}

\begin{tabular*}{\columnwidth}{@{\extracolsep{\fill}}ccc}
\includegraphics[width=0.27\columnwidth]{example-image-9x16} &
\includegraphics[width=0.27\columnwidth]{example-image-9x16} &
\vbox to \mylength{
  \hbox{\includegraphics[width=0.41\columnwidth]{example-image-16x9}}
  \vfil
  \hbox{\includegraphics[width=0.41\columnwidth]{example-image-16x9}}
}
\end{tabular*}

\caption{(a)~fig.~A (b)~fig.~B (c)~fig.~C (d)~fig.~D}\label{fig_needed}

\end{figure}

\end{document}

enter image description here

1
  • Thanks dude. The more simpler first version with tabular allowed me with just the solution that I needed.
    – Ghosal_C
    Commented Jun 17 at 6:02

You must log in to answer this question.

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