Say I have 7 subfigures, and I would like to place 1 figure at left and make it bigger enough to occupy two lines. Then all the other 6 figures are placed at the right, 3 figures for each line. The example is shown,
How should it be coded in latex?
Say I have 7 subfigures, and I would like to place 1 figure at left and make it bigger enough to occupy two lines. Then all the other 6 figures are placed at the right, 3 figures for each line. The example is shown,
How should it be coded in latex?
If your pictures are square, this is a way to accomplish perfect alignment.
\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\newsavebox{\houlubox}
\newlength{\houlumodule}
\newlength{\houlusep}
\begin{document}
\begin{figure}[htp]
% we decide that the big figure is 2/5 of the column width
\sbox{\houlubox}{%
\begin{subfigure}{0.4\dimexpr\columnwidth}
\includegraphics[width=\textwidth]{example-image-1x1}
\caption{}
\end{subfigure}%
}
% the width of the other images should be half the difference
% between twice the width and the height, minus a short gap
\setlength{\houlumodule}{\dimexpr(2\wd\houlubox-\ht\houlubox-\dp\houlubox)/2-0.5ex}
% let's compute the separation
\setlength{\houlusep}{\dimexpr(\columnwidth-\wd\houlubox-3\houlumodule)/3}
\parbox[b]{\wd\houlubox}{\usebox{\houlubox}\par\vspace{0pt}}\hfill
\parbox[b][\dimexpr\ht\houlubox+\dp\houlubox][s]{\dimexpr3\houlumodule+2\houlusep}{%
\begin{subfigure}{\houlumodule}
\includegraphics[width=\textwidth]{example-image-1x1}
\caption{}
\end{subfigure}\hfill
\begin{subfigure}{\houlumodule}
\includegraphics[width=\textwidth]{example-image-1x1}
\caption{}
\end{subfigure}\hfill
\begin{subfigure}{\houlumodule}
\includegraphics[width=\textwidth]{example-image-1x1}
\caption{}
\end{subfigure}
\vfill
\begin{subfigure}{\houlumodule}
\includegraphics[width=\textwidth]{example-image-1x1}
\caption{}
\end{subfigure}\hfill
\begin{subfigure}{\houlumodule}
\includegraphics[width=\textwidth]{example-image-1x1}
\caption{}
\end{subfigure}\hfill
\begin{subfigure}{\houlumodule}
\includegraphics[width=\textwidth]{example-image-1x1}
\caption{}
\end{subfigure}
\vspace{0pt}
}
\caption{Full caption}
\end{figure}
\end{document}
You may use a tabular environment with subcaptionbox command from the subcaption package.
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{multirow}
\usepackage{tabularx}
\newcolumntype{s}{>{\hsize=.2\hsize\linewidth=\hsize}X}
\newcolumntype{D}{>{\hsize=.4\hsize\linewidth=\hsize}X} %Double width column
\newcommand{\wdImg}{\dimexpr \linewidth-2\tabcolsep} %width of the image
\begin{document}
\begin{figure}
\begin{tabularx}{\textwidth}{D {3}{s}}
\multirow{-2.9}{}{\subcaptionbox{a\label{fig:1}}{\includegraphics[width=\wdImg]{example-image}}}
& \subcaptionbox{a\label{fig:2}}{\includegraphics[width=\wdImg]{example-image}}
& \subcaptionbox{a\label{fig:3}}{\includegraphics[width=\wdImg]{example-image}}
& \subcaptionbox{a\label{fig:4}}{\includegraphics[width=\wdImg]{example-image}}
\
& \subcaptionbox{a\label{fig:5}}{\includegraphics[width=\wdImg]{example-image}}
& \subcaptionbox{a\label{fig:6}}{\includegraphics[width=\wdImg]{example-image}}
& \subcaptionbox{a\label{fig:7}}{\includegraphics[width=\wdImg]{example-image}}
\
\end{tabularx}
\caption{A figure}
\label{fig:fig1}
\end{figure}
\end{document}
Aligning both the tops and bottoms is tricky. In the following only the height of the large image is found by trial and error. Note that the larger it gets, the smaller the other subfigures get.
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{tabularx}
\begin{document}
\begin{figure}
\captionsetup[subfigure]{skip=0pt}% reduce caption size
\setlength{\tabcolsep}{2pt}% reduce horizontal gaps
\sbox1{\includegraphics[height=4.175cm]{example-image}}% measure width
\sbox2{\parbox[t]{\wd1}{\subcaption{a}\label{fig:1}}}% first subcaption
\begin{tabularx}{\textwidth}{@{}lXXX@{}}
& \raisebox{-\height}{\includegraphics[width=\hsize]{example-image}}
& \raisebox{-\height}{\includegraphics[width=\hsize]{example-image}}
& \raisebox{-\height}{\includegraphics[width=\hsize]{example-image}}
\
& \subcaption{a}\label{fig:2}
& \subcaption{a}\label{fig:3}
& \subcaption{a}\label{fig:4}
\
\smash{\usebox1}% overlap preceding rows
& \includegraphics[width=\hsize]{example-image}
& \includegraphics[width=\hsize]{example-image}
& \includegraphics[width=\hsize]{example-image}
\
\usebox2
& \subcaption{a}\label{fig:5}
& \subcaption{a}\label{fig:6}
& \subcaption{a}\label{fig:7}
\end{tabularx}
\caption{A figure}\label{fig:fig1}
\end{figure}
\end{document}