[Tex/LaTex] Subfigure and caption placement

captionssubfloats

I have 5 images to place (using the subfigure environment), I would like to place them either in two columns (one with 3 images, the other with 2), or in two lines (idem) and use the empty place that a 6th image would have taken to put the caption. How can I do that?

Thanks!

Best Answer

You can use subfigure for the subfigures and a minipage for the caption:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\hfill
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\hfill
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\par
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\hfill
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\hfill
\begin{minipage}{.3\textwidth}
\caption{a figure with six subfigures and a caption placed beside one of the subfigures}
\end{minipage}
\end{figure}

\end{document}

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\centering
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\quad
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\par
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\quad
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\par
\begin{subfigure}{.3\textwidth}
\includegraphics[width=\linewidth]{example-image-a}
\caption{test subfigure}
\end{subfigure}\quad
\begin{minipage}{.3\textwidth}
\caption{a figure with six subfigures and a caption placed beside one of the subfigures}
\end{minipage}
\end{figure}

\end{document}

enter image description here

Use the optional argument for the environments to get the desired alignment, if required.

Related Question