How to typeset an array of figures?

  • MHB
  • Thread starter Ackbach
  • Start date
  • Tags
    Array
In summary, the caption environment in LaTeX can be used to typeset a 3 x 2 array of figures (that is, three rows of two columns), for answers to a multiple-choice question.
  • #1
Ackbach
Gold Member
MHB
4,155
92
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
  • #2
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}
 
  • #3
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.
 

FAQ: How to typeset an array of figures?

1. How do I arrange multiple figures in a single array?

To typeset an array of figures, you can use the \begin{figure} and \end{figure} commands in LaTeX. Within these commands, you can use the \includegraphics command to insert your figures and the \caption command to add captions. Use the \subfigure command to arrange multiple figures in a single row.

2. Can I adjust the size of individual figures in the array?

Yes, you can use the \includegraphics[width= ] command to adjust the size of individual figures. You can specify the desired width in inches, centimeters, or a fraction of the textwidth. Alternatively, you can also use the \resizebox command to resize the figures.

3. How can I add labels or references to the figures in the array?

To label your figures, you can use the \label command within the \caption command. You can then use the \ref command to refer to the figure number in your text. For example, Figure \ref{fig:array} will display as "Figure 1" if the corresponding figure has the label "array".

4. Is it possible to have multiple arrays of figures in a single document?

Yes, you can have multiple arrays of figures in a single document by using the \begin{figure} and \end{figure} commands for each array. You can also use the \captionof command from the caption package to add captions to the arrays without including them in the list of figures.

5. Can I customize the layout and appearance of the figures in the array?

Yes, you can customize the layout and appearance of the figures in the array by using packages such as subcaption or subfig. These packages offer more options for arranging and labeling figures in the array. You can also use the \setlength command to adjust the spacing between figures or \renewcommand to modify the default formatting of captions.

Similar threads

Replies
5
Views
1K
Replies
2
Views
10K
Replies
2
Views
1K
Replies
4
Views
3K
Replies
1
Views
2K
Replies
9
Views
4K
Back
Top