Arranging images in a grid
The \includegraphics command could load a more extensive set of photos, plots, or diagrams with some space in between, for example, positioned using minipage environments. A \foreach loop may help if the filenames can be generated programmatically.
In this recipe, we will produce a grid of aligned images with arbitrary names, which will be easy to arrange.
How to do it...
We will use a tabular environment for positioning. That’s no surprise yet. However, we will read in the tabular cell content, which we will then use as filenames for inclusion. The collcell package provides the required feature. Follow these steps:
- Load the graphicx package and the collcell package:
\usepackage{graphicx} \usepackage{collcell}
- Define a command for including an image with a chosen width and height:
\newcommand{\includepic}[1]{% \includegraphics[width=3cm,height=2cm, keepaspectratio]{#1}}
- Define a new column type that uses...