MHB How to typeset an array of figures?

  • Thread starter Thread starter Ackbach
  • Start date Start date
  • Tags Tags
    Array
AI Thread Summary
To typeset a 3 x 2 array of figures for a multiple-choice question, the standard LaTeX `figure` environment can be utilized effectively with the `graphicx`, `caption`, and `subcaption` packages. A suggested code structure involves using the `subfigure` environment to create individual figures within a main figure, allowing for captions and labels for each image. Spacing between images can be adjusted using commands like `~`, `\quad`, or `\qquad`. An alternative method mentioned is the `\subcaptionbox` command, which aligns sub-figures by their first caption line, providing a different approach to organizing figures. The documentation for the `subcaption` package offers further insights into these functionalities.
Ackbach
Gold Member
MHB
Messages
4,148
Reaction score
93
I want to typeset a 3 x 2 array of figures (that is, three rows of two columns), for answers to a multiple-choice question. How can I do that? The standard \begin{figure} environment seems to want to be outside of any environment. Ideas?
 
Physics news on Phys.org
I found a workable solution at this website. Here's the code, more or less:

Code:
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{figure}
        \centering
        \begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=\textwidth]{gull}
                \caption{A gull}
                \label{fig:gull}
        \end{subfigure}%
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=\textwidth]{tiger}
                \caption{A tiger}
                \label{fig:tiger}
        \end{subfigure}
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=\textwidth]{mouse}
                \caption{A mouse}
                \label{fig:mouse}
        \end{subfigure}
        \caption{Pictures of animals}\label{fig:animals}
\end{figure}
 
Ackbach said:
I found a workable solution at this website. Here's the code, more or less:

Code:
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{figure}
        \centering
        \begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=\textwidth]{gull}
                \caption{A gull}
                \label{fig:gull}
        \end{subfigure}%
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=\textwidth]{tiger}
                \caption{A tiger}
                \label{fig:tiger}
        \end{subfigure}
        ~ %add desired spacing between images, e. g. ~, \quad, \qquad etc.
          %(or a blank line to force the subfigure onto a new line)
        \begin{subfigure}[b]{0.3\textwidth}
                \includegraphics[width=\textwidth]{mouse}
                \caption{A mouse}
                \label{fig:mouse}
        \end{subfigure}
        \caption{Pictures of animals}\label{fig:animals}
\end{figure}

I general use `\subcaptionbox` which is also part of the subcaption package as well.

http://ctan.unixbrain.com/macros/latex/contrib/caption/subcaption.pdf

Chapter 4 of the documentation says:
A different way of setting sub-figures is offered by the \subcaptionbox
command, \subcaptionbox which automatically aligns the sub-figures resp. sub-tables by their very first caption line.
 

Similar threads

Back
Top