# Typesetting a fancy grid of figures

So, I need TeX to arrange the page as can be seen below. More specifically, to arrange vector graphics .pdf figures in a rectangular grid, with strict fixed boundaries, captions below and possibly above, an optimal use of page-space as well as within each cell (figures fitting neatly), and possibly/optional border line, which I haven't decided upon yet.

The motive: having to deal with a massive amount of images, I've decided to dedicate a separate section of my work, just for them, and was hoping that the answer, showing how to do it for the below sample page, would guide me to do the rest myself. Currently I'm trying to learn boxes and alignment from TeXbook, but unfortunately, the time is not on my side, and I need visual results as soon as possible.

At present, I'm using a lay quick-fix, involving \includegraphics[]{}, \null\hfill, left/right alightment of images on the same line and manual tabbing of text, which is very unappealing, hard to TeX-type, and would fail to work if there were 3 columbs.

Would greatly appreciate any help,

Best Regards,

Piotr

• It is not difficult to get this. Are these ordinary figure captions or just texts that say caption and so on? – Schrödinger's cat Feb 24 at 3:42
• Not sure what you mean by 'ordinary', but they could be custom (left/right/center aligned texts that function as captions, followed by formulas, etc.) and multiline; as long as I can freely choose what to type under or over the image, I'd be happy. – Piotr Tarasov Feb 24 at 4:00

This is very simple-minded.

\documentclass{article}
\usepackage{cellspace}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htb]
\setkeys{Gin}{width=5.5cm}\renewcommand\arraystretch{2}%
\cellspacetoplimit4pt
\cellspacebottomlimit4pt
\centering
\begin{tabular}{|@{}c@{}|@{}c@{}|}
\hline
\begin{tabular}[t]{c@{}p{5.5cm}@{}c}
&\multicolumn{1}{@{}Sc@{}}{\includegraphics{example-image-a}}&\\
&Caption A&\\
\hline
&\multicolumn{1}{@{}Sc@{}}{\includegraphics[height=5.5cm]{example-image-c}}&\\
&Caption C&\\
\hline
&\multicolumn{1}{@{}Sc@{}}{\includegraphics[height=2cm]{example-image-c}}&\\
&Caption E&\\
\end{tabular}
&
\begin{tabular}[t]{c@{}p{5.cm}@{}c}
&\multicolumn{1}{@{}Sc@{}}{\includegraphics{example-image-b}}&\\
&Caption B&\\
\hline
&\multicolumn{1}{@{}Sc@{}}{\includegraphics{example-image-duck}}&\\
&Caption D&\\
\hline
&\multicolumn{1}{@{}Sc@{}}{\includegraphics[height=3cm]{example-image-c}}&\\
&Caption F&\\
\end{tabular}\\
\hline
\end{tabular}
\end{figure}
\end{document}


In the fortunate case of not choosing optional borders, you can just use standard figure floats with the [p] option in a two column layout. You can use this approach in one column documents (switch the layout of pages with \twocolumn and \onecolumn).

The MWE:

\documentclass[twocolumn]{article}
\usepackage[margin=3.5cm,tmargin=2cm,bmargin=2cm,columnsep=1.5cm]{geometry}
\usepackage{graphicx}
\usepackage{lipsum} % dummy text

% some tuning of vertical spaces
\abovecaptionskip0pt
\belowcaptionskip0pt
\floatsep 0pt plus 10em minus 10em

% macros to simplify float typing
\def\image#1{\begin{figure}[p]\centering
\includegraphics[width=\linewidth]{#1}\caption{{\lipsum[1][1-1]}}
\end{figure}}
\def\imager#1{\begin{figure}[p]\centering
\includegraphics[height=\linewidth,angle=90]{#1}\caption{{\lipsum[1][1-1]}}
\end{figure}}

\begin{document}
\image{example-image}
\imager{example-image-4x3}
\image{example-image-golden}
\image{example-image-a}
\image{example-image-golden}
\imager{example-image-4x3}
\end{document}


The macros \image and \imagerare only to show in a simplified way that you only have to type one float after other, nothing more. In real life you will want to type the floats directly, or change that macros to have more freedom of change things (at least the caption text!).

• Because the above, change to a layout of figures within the text is very easy: simply remove [p] or change to another float options. However, in documents with several images images the smartest decision will be use p plus some other options, such as [htbp] or [tbp!], so LaTeX will make page of figures only when needed and you will have less chances of a incomplete page of figures.
• Reorder, add or remove figures is easier with options as [tbp!], although is up to you check that that in page of figures the order of landscape/portrait images is still the correct to fill the available space.
Of course, you fix what figures are in a page of figures (using [p]) or not (using [<whatever except p>]) in the same document, but as more restrained options mean more risk of hamper LaTeX to place floats stylishly, I will use this only for the final draft.
• @PiotrTarasov You don't need to do that. It is enough write some like ... bla bla bla. \twocolumn\input{my-figures} \onecolumn Bla bla bla ... and make a file named my-figures.tex in the same directory with the code of the figures (not a complete document with preamble, etc.... only with the figures!) ... or alternatively, just replace \input{my-figures}` with the figures if you prefer work with only one document. – Fran Feb 24 at 11:37