6

I have a simple question but I am not sure on how to proceed. I would like to put 10 figures on the same page: a grid of 5 rows and 2 columns.

What should I type in order to have the figure inserted like this and with equal alignement/size ? Eventually with custom captions... ;)

15

There are several possibilities here.

Case A: ten subfigures

Three options: the first one, using the subfig package; the second one, using the subcaption package; the third one, using the floatrow package.

Using subfig:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}

\captionsetup[subfigure]{justification=raggedright}

\begin{document}

\begin{figure}
\centering
\subfloat[first subfigure]{\label{sfig:a}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subfloat[second subfigure]{\label{sfig:b}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subfloat[third subfigure]{\label{sfig:c}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subfloat[fourth subfigure]{\label{sfig:d}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subfloat[fifth subfigure]{\label{sfig:e}\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\\
\subfloat[sixth subfigure]{\label{sfig:f}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subfloat[seventh subfigure]{\label{sfig:g}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subfloat[eighth subfigure]{\label{sfig:h}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subfloat[ninth subfigure]{\label{sfig:i}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subfloat[tenth subfigure]{\label{sfig:j}\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\\
\caption{A figure with ten subfigures}
\label{fig:test}
\end{figure}

\end{document}

enter image description here

Using subcaption:

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

\captionsetup[subfigure]{justification=raggedright}

\begin{document}

\begin{figure}
\centering
\subcaptionbox{first subfigure\label{sfig:a}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subcaptionbox{second subfigure\label{sfig:b}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subcaptionbox{third subfigure\label{sfig:c}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subcaptionbox{fourth subfigure\label{sfig:d}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\hfill
\subcaptionbox{fifth subfigure\label{sfig:e}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}\\
\subcaptionbox{sixth subfigure\label{sfig:f}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subcaptionbox{seventh subfigure\label{sfig:g}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subcaptionbox{eighth subfigure\label{sfig:h}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subcaptionbox{ninth subfigure\label{sfig:i}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\hfill
\subcaptionbox{tenth subfigure\label{sfig:j}}{\includegraphics[width=.18\textwidth,height=2cm]{example-image-b}}\\
\caption{A figure with ten subfigures}
\label{fig:test}
\end{figure}

\end{document}

enter image description here

Using floatrow:

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

\renewcommand\subfloatrowsep{\hskip7pt} 

\begin{document}

\begin{figure}
\captionsetup{justification=raggedright}
\ffigbox[\textwidth]{%
\begin{subfloatrow}[5]
\ffigbox[\FBwidth]{\caption{first subfigure}\label{sfig:a}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{second subfigure}\label{sfig:b}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{third subfigure}\label{sfig:c}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{fourth subfigure}\label{sfig:d}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{fifth subfigure}\label{sfig:e}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\end{subfloatrow}
\begin{subfloatrow}[5]
\ffigbox[\FBwidth]{\caption{sixth subfigure}\label{sfig:f}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{seventh subfigure}\label{sfig:g}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{eighth subfigure}\label{sfig:h}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{ninth subfigure}\label{sfig:i}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\ffigbox[\FBwidth]{\caption{tenth subfigure}\label{sfig:j}}
  {\includegraphics[width=.18\textwidth,height=2cm]{example-image-a}}
\end{subfloatrow}
}{\caption{A figure with ten subfigures}\label{fig:test}}
\end{figure}

\end{document}

enter image description here

Case B: ten independent figures

If we are talking about an array of ten independent figures, ten minipages can be used.

If the whole construct should be allowed to float, the minipages can go inside a figure environment:

\documentclass{article}
\usepackage{caption}
\usepackage{graphicx}

\begin{document}

\begin{figure}
\captionsetup{justification=raggedright}
\centering
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{first figure}
\label{fig:a}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{second figure}
\label{fig:b}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{third figure}
\label{fig:c}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{fourth figure}
\label{fig:d}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{fifth figure}
\label{fig:e}
\end{minipage}\\
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{sixth figure}
\label{fig:f}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{seventh figure}
\label{fig:g}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{eighth figure}
\label{fig:h}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{ninth figure}
\label{fig:i}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\caption{tenth figure}
\label{fig:j}
\end{minipage}
\end{figure}

\end{document}

enter image description here

If the whole construct shouldn't be allowed to float, the ten minipages can go inside a minipage environment (or a center environment); in this situation, captions can be provided using \captionof (from the caption or capt-of packages):

\documentclass{article}
\usepackage{caption}
\usepackage{graphicx}

\begin{document}

\noindent\begin{minipage}{\textwidth}
\captionsetup{justification=raggedright}
\centering
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{first figure}
\label{fig:a}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{second figure}
\label{fig:b}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{third figure}
\label{fig:c}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{fourth figure}
\label{fig:d}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{fifth figure}
\label{fig:e}
\end{minipage}\\
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{sixth figure}
\label{fig:f}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{seventh figure}
\label{fig:g}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{eighth figure}
\label{fig:h}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{ninth figure}
\label{fig:i}
\end{minipage}\hfill
\begin{minipage}[t]{.18\textwidth}
\includegraphics[width=\linewidth,height=2cm]{example-image-a}
\captionof{figure}{tenth figure}
\label{fig:j}
\end{minipage}
\end{minipage}

\end{document}
  • what to say? many thanks for this wonderful answer! – ℕʘʘḆḽḘ Jul 5 '13 at 11:57
  • @Noobie You're welcome! I'm glad I could help. – Gonzalo Medina Jul 6 '13 at 17:18
0

If you don't need (e.g., hyperref) links to each individual subfigure, then this might work, though it is quite squeezed. I am also assuming that your figures are a uniform size, since you speak of placing them in a regular array. Correct me if I'm wrong.

\documentclass{article}
\usepackage{stackengine}
\begin{document}
\def\myfig{\rule{.8in}{1in}}
\newcommand\mycap[2]{\parbox[t]{.8in}{\raggedright(#1) #2}}

\begin{figure}
\small\centering
\Shortstack{%
  {\protect\myfig} {\protect\mycap{a}{Caption for subfig a}} {} 
  {\protect\myfig} {\protect\mycap{f}{Caption for subfig f}}
}
\Shortstack{%
  {\protect\myfig} {\protect\mycap{b}{Caption for subfig b}} {} 
  {\protect\myfig} {\protect\mycap{g}{Caption for subfig g}}
}
\Shortstack{%
  {\protect\myfig} {\protect\mycap{c}{Caption for subfig c}} {} 
  {\protect\myfig} {\protect\mycap{h}{Caption for subfig h}}
}
\Shortstack{%
  {\protect\myfig} {\protect\mycap{d}{Caption for subfig d}} {} 
  {\protect\myfig} {\protect\mycap{i}{Caption for subfig i}}
}
\Shortstack{%
  {\protect\myfig} {\protect\mycap{e}{Caption for subfig e}} {} 
  {\protect\myfig} {\protect\mycap{j}{Caption for subfig j}}
}
\caption{Overall Figure Caption}
\end{figure}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.