Jason A. French

Northwestern University

Using Figures Within Tables in LaTeX

| Comments

By using LaTeX to author APA manuscripts, researchers can address many problems associated with formatting their results into tables and figures. For example, ANOVA tables can be readily generated using the xtable package in R, and graphs from ggplot2 can be rendered within the manuscript using Sweave (see Wikipedia). However, more complicated layouts can be difficult to achieve.

In order to make test items or stimuli easier to understand, researchers occasionally organize examples in a table or figure. Using the standard \table command in LaTeX, it’s possible to include figures in an individual table cell without breaking the APA6.cls package. For example:

Bottom-Aligned Figures in LaTeX Tables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
\begin{table}
  [ht] \caption{Stimuli Category Explanations} \label{tab:stimuli}
  \begin{tabular}
      {lllll} \hline Category & Familiar Organism & Growth Model & Metamorphosis & Figure \\
      \hline \textbf{FDM} & Yes & Dramatic & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Meta-Dramatic} \\
      FDN & Yes & Dramatic & No &
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Dramatic} \\
      FGM & Yes & Growth & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Meta-Growth} \\
      \textbf{FGN} & Yes & Growth & No &
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Growth} \\
      FIM & Yes & Identical & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Meta-ID} \\
      FIN & Yes & Identical & No &
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Identical} \\
      FSM & Yes & Species Change & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Meta-Species} \\
      FSN & Yes & Species Change & No &
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Species} \\
      \textbf{UDM} & No & Dramatic & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-Dramatic} \\
      UDN & No & Dramatic & No &
      \includegraphics[width=1in]{"Figure Stimuli"/Un-Dramatic} \\
      UGM & No & Growth & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-Growth} \\
      \textbf{UGN} & No & Growth & No &
      \includegraphics[width=1in]{"Figure Stimuli"/Un-Growth} \\
      UIM & No & Identical & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-ID} \\
      UIN & No & Identical & No &
      \includegraphics[width=1in]{"Figure Stimuli"/Un-Identical} \\
      USM & No & Species Change & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-Species} \\
      USN & No & Species Change & No &
      \includegraphics[width=1in]{"Figure Stimuli"/Un-Species} \\
      USM & No & Species Change & Yes &
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-Species} \\
      \hline
  \end{tabular}
  \tabfnt{Note: Bold categories are biologically correct growth models.}
\end{table}

Center-Aligned Figures

However, the above code vertically aligned my images according to their bottom-edge, producing an awkward looking table. Instead, we want the figures to be vertically centered. A Google search revealed the LaTeX Wikibook, which suggests a few methods to force figures to vertically align according to their center. Below, I surround each \includegraphics{} command with the \parbox{} command, which centers it along 1 unit of measurement, set to 12 pts. in my apa6 class options.

Center-Aligned Figures in LaTeX Tables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
\begin{table}
  [ht] \caption{Stimuli Category Explanations} \label{tab:stimuli}
  \begin{tabular}
      {lllll} \hline Stimuli Category & Familiar Organism & Growth Model & Metamorphosis & Figure \\
      \hline \textbf{FDM} & Yes & Dramatic & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Meta-Dramatic}} \\
      FDN & Yes & Dramatic & No & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Dramatic}} \\
      FGM & Yes & Growth & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Meta-Growth}} \\
      \textbf{FGN} & Yes & Growth & No & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Growth}} \\
      FIM & Yes & Identical & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Meta-ID}} \\
      FIN & Yes & Identical & No & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Identical}} \\
      FSM & Yes & Species Change & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Meta-Species}} \\
      FSN & Yes & Species Change & No & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Fam-Species}} \\
      \textbf{UDM} & No & Dramatic & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-Dramatic}} \\
      UDN & No & Dramatic & No & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un-Dramatic}} \\
      UGM & No & Growth & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-Growth}} \\
      \textbf{UGN} & No & Growth & No & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un-Growth}} \\
      UIM & No & Identical & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-ID}} \\
      UIN & No & Identical & No & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un-Identical}} \\
      USM & No & Species Change & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-Species}} \\
      USN & No & Species Change & No & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un-Species}} \\
      USM & No & Species Change & Yes & \parbox[c]{1em}{
      \includegraphics[width=1in]{"Figure Stimuli"/Un2-Meta-Species}} \\
      \hline
  \end{tabular}
  \tabfnt{Note: Bold categories are biologically correct growth models.}
\end{table}

Output:

By using \parbox, figures are now vertically aligned with text cells. However, with the addition of figures the table is too long and we must span the table across 2-pages. To solve this, split the information across two tables. In this case, I can split by the stimuli category.

Alternatively, Brian Beitzel also pointed out that we can invoke longtable as a class option in APA6.cls, which allows tables to span multiple pages.

Comments