Graphics, Figures & Tables ⇒ Automatically generate a grid of images
-
- Posts: 60
- Joined: Tue Sep 30, 2008 9:24 pm
Automatically generate a grid of images
Thanks,
Dave
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Automatically generate a grid of images
you could rename your images as 1-1.jpg, 1-2.jpg, ... , 1-5.jpg (those who will appear in the first row); 2-1.jpg, 2-2.jpg, ... , 2-5.jpg (those who will appear in the second row); ... 5-1.jpg, 5-2.jpg, ... , 5-5.jpg (those who will appear in the fifth row) and then use, for example, two nested \foreach constructs (of the PGF/TikZ package) to achieve the desired result. The following code illustrates schematically this approach:
Code: Select all
\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
\foreach \i in {1,...,5}{
\foreach \j in {1,...,5}{
\noindent\includegraphics{\i-\j}
}\\
}
\end{document}
Code: Select all
\documentclass{article}
\usepackage{graphicx}
\usepackage{ifthen}
\begin{document}
\newcounter{myrow}
\newcounter{mycolumn}
\setcounter{myrow}{1}
\whiledo{\themyrow<6}{
\whiledo{\themycolumn<5}{
\stepcounter{mycolumn}
\noindent\includegraphics{\themyrow-\themycolumn}
}\setcounter{mycolumn}{0}\\\stepcounter{myrow}
}
\end{document}
-
- Posts: 60
- Joined: Tue Sep 30, 2008 9:24 pm
Re: Automatically generate a grid of images
Dave