[Tex/LaTex] How to generate a table of figures
subfloatstables
Related Solutions
You can use the \subcaption
command from the package with the same name to add a caption for each sufigure.
There is a problem with using subcaptions inside a tabularx
, see this bug report at SourceForge, so it's better to use a regular tabular
with p
columns.
Notes about the code:
- The
\label
always has to be placed after (or within) the\caption
. - I reduced the size of the images a bit, they need to be smaller to be able to fit in the page, due to the extra space added by the subcaptions. (Even with my adjustment the table may wider than the text block, depending on your settings.)
A space between the image and the subcaption seems to introduce extra vertical spacing. I.e., instead of
\includegraphics[width=1.8in,height=1.2in]{example-image} \subcaption{Text}
write
\includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text}
To further compress the table vertically, you can add
\renewcommand\arraystretch{0}
right before thetabular
. You can also move the subcaption closer to the images with\captionsetup[subtable]{aboveskip=2pt}
. These are in the code, but commented.
\documentclass{article}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{subcaption}
\begin{document}
\begin{sidewaystable}
\centering\small\setlength\tabcolsep{2pt}%
%\renewcommand\arraystretch{0}
%\captionsetup[subtable]{aboveskip=2pt}
\begin{tabular}{@{}*{4}{p{1.8in}}@{}}
\includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-a}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-b}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-c}\subcaption{Text} \\
\includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-a}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-b}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-c}\subcaption{Text} \\
\includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-a}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-b}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-c}\subcaption{Text} \\
\includegraphics[width=1.8in,height=1.2in]{example-image}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-a}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-b}\subcaption{Text} &
\includegraphics[width=1.8in,height=1.2in]{example-image-c}\subcaption{Text} \\
\end{tabular}
\caption{The main caption of the table.}
\label{tab:gr}
\end{sidewaystable}
\end{document}
One (semi automatic) way is to form three files:
write all figures and tables as separate files (with help of standalone package you can compile them locally and them include them in "main" files as TeX files or as PDF files)
form three "main" files:
- main files with text, in which you include figure's and table's files in float environments with captions and labels
- file with figures in which you include only figures in non-float environment (without captions and labels)
- file with tables, in which you include only tables on the same was as you do with figures.
In this the package standalone
can be of big help. With its use, you can individually compile each figure and table and on this way tested, if they are as you like to to have them. Example of such figure file is:
\documentclass[border=1mm,
class=article
preview]{standalone}
\usepackage{...}
\usepackage{...}
%% for easy remember file name is put here file name (if you wish)
\begin{document}
%%
\begin{tikzpicture}
... image code ...
\end{tikzpicture}
\end{document}
Package standalone
in main files strip preamble with begin{document}
and end{document}
from images and table files, so they can be compiled with mine files or if you lie to speed-up compilation, you can include their pdf files (which are generated at individual compilation of figures and tables) as
\includegraphics[ ... options if needed ...]{file name}
The main documents:
\documentclass{article}
\usepackage{standalone}
%
\usepackage{...}
\begin{document}
\section{introduction}
your text
\begin{figure}
\input{file-name}
\caption{Figure 1}
\label{fig: figure-1}
\end{figure}
... your text ...
\end{document}
Similarly the file with collected figures can be:
\documentclass{article}
\usepackage{standalone}
%
\usepackage{...}
\begin{document}
\begin{center}%% file of figure 1
\input{file-name}
\end{center}
\begin{center}%% file of figure 2
\input{file-name}
\end{center}
\end{document}
On the same way you can form file of tables. Files of tables and figures you can store in the same folder as min files or in subfolders with figures and tables. In this case you need to define path to them.
Best Answer
For a table of figures like this one you can use the package
booktabs
, like this:But, as you can see in the figure below, the text in the first column will not be vertically aligned.
In order to do this, you need to use the
array
package and create a new column type:Then, use this new column type for the columns containing the figures, like this: