18

I need an image with five subfigures arranged this way.

enter image description here

I have tried to use subfig and floatrow, but I haven't been able to place the figures as I need them

lockstep
  • 250,273
  • 1
    I found the package \usepackage{textpos} really good for this. Then you would simply place your images in brackets like \begin{textblock}{1}(5.5,2.5){1,1} Some figure \end{textblock}. Read more about the package here http://mirror.ctan.org/macros/latex/contrib/textpos/textpos.pdf. Another method is using minipages. – N3buchadnezzar Nov 18 '11 at 02:14

3 Answers3

14

You could use a combination of minipages and subfigure environments (from the subcaption package); a little example:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\begin{minipage}{.33\textwidth}
  \begin{subfigure}{\linewidth}
    \centering
    \includegraphics[width=.7\linewidth]{name1}
    \caption{First subfigure}
    \label{fig:sub1}
  \end{subfigure}\\[1ex]
  \begin{subfigure}{\linewidth}
    \centering
    \includegraphics[width=.7\linewidth]{name2}
    \caption{Second subfigure}
    \label{fig:sub2}
  \end{subfigure}
\end{minipage}%
\begin{minipage}{.33\textwidth}
  \begin{subfigure}{\linewidth}
    \centering
    \includegraphics[width=.7\linewidth]{name3}
    \caption{Third subfigure}
    \label{fig:sub3}
  \end{subfigure}
\end{minipage}%
\begin{minipage}{.33\textwidth}
  \begin{subfigure}{\linewidth}
    \centering
    \includegraphics[width=.7\linewidth]{name4}
    \caption{Fourth subfigure}
    \label{fig:sub4}
  \end{subfigure}\\[1ex]
  \begin{subfigure}{\linewidth}
    \centering
    \includegraphics[width=.7\linewidth]{name5}
    \caption{Fifth subfigure}
    \label{fig:sub5}
  \end{subfigure}
\end{minipage}
\caption{Five subfigures}
\label{fig:test}
\end{figure}

\end{document}

enter image description here

I used the demo option for the graphicx package to replace the actual figures with black rectangles and make my code compilable for everyone; do not use that option in your actual code.

Gonzalo Medina
  • 505,128
  • Gonzalo, perhaps add [!htpb] after \begin{figure} ? Seems like quite a standard thing to do. This way we restrict the floating of the figure quite a bit. Using 4 images, the chances of the figure actually fitting is quite low. Also great solution =) – N3buchadnezzar Nov 18 '11 at 02:29
  • 1
    @N3buchadnezzar: thanks. As for the placement specifiers, for some time now, I've opted for not using them in my example codes unless the person asking the question explicitly mentions a problem with their use. – Gonzalo Medina Nov 18 '11 at 03:18
10

You could use three minipages next to each other:

enter image description here

\documentclass{article}

\usepackage{caption,subcaption}
\begin{document}
\begin{figure}
\centering
\begin{minipage}{0.3\textwidth}
\subcaptionbox{A}{\rule{3cm}{3.5cm}}\\[1ex]
\subcaptionbox{B}{\rule{3cm}{3.5cm}}
\end{minipage}%
\begin{minipage}{0.3\textwidth}
\subcaptionbox{C}{\rule{3cm}{3.5cm}}
\end{minipage}%
\begin{minipage}{0.3\textwidth}
\subcaptionbox{D}{\rule{3cm}{3.5cm}}\\[1ex]
\subcaptionbox{E}{\rule{3cm}{3.5cm}}
\end{minipage}
\caption{Pictures!}
\end{figure}

\end{document}
Jake
  • 232,450
  • You could add % after the first and second \end{minipage} commands to prevent undesired blank spaces. – Gonzalo Medina Nov 18 '11 at 02:25
  • @GonzaloMedina: Good point, thanks! I've also adopted the \\[1ex] from your answer to get nicer vertical spacing. – Jake Nov 18 '11 at 02:46
6

Using the subfig package you can use tabulars to arrange the images:

enter image description here

\documentclass{article}
\usepackage{subfig}% http://ctan.org/pkg/subfig
\begin{document}
\begin{figure}[ht]
  \begin{tabular}{c}
    \subfloat[subfigure 1]{\rule{100pt}{50pt}} \\
    \subfloat[subfigure 2]{\rule{100pt}{50pt}}
  \end{tabular} \hfill
  \begin{tabular}[m]{c}
    \subfloat[subfigure 3]{\rule{100pt}{50pt}}
  \end{tabular} \hfill
  \begin{tabular}{c}
    \subfloat[subfigure 4]{\rule{100pt}{50pt}} \\
    \subfloat[subfigure 5]{\rule{100pt}{50pt}}
  \end{tabular}
  \caption{bla bla bla bla bla bla}
\end{figure}
\end{document}

Vertical alignment across the subfigures is obtained using the optional tabular parameter [m] for middle. Using \hfill as suggested will push the columns of subfigures to the outer edges of the text block. If you want these columns evenly spaces, use \null\hfill on the left of the first column and \hfill\null on the right of the last column. Alternatively, a fixed spacing using \hspace{<len>} is also possible, where <len> is any recognized TeX length.

tabular column specification necessarily adds a little horizontal space of \tabcolsep between columns. If you want this removed (for whatever reason), you can use a {@{}c@{}} column specification instead of {c}.

Moriambar
  • 11,466
Werner
  • 603,163