8

I have about a hundred images named 001.png to 123.png. I want to create a document which includes each image in center of a page. i.e. a 123 page document with each image on a single page.

I know that doing this is possible using macros but I have no clue how to do that. Any help is appreciated.

Asghar
  • 83

1 Answers1

10

If you need only the images in the center of the page, just loop:

\documentclass{article}
\usepackage[a4paper,margin=0pt]{geometry}
\usepackage[demo]{graphicx}

\pagestyle{empty}

\newcounter{image}
\newcommand{\placeimages}[2]{%
  \setcounter{image}{#1}\addtocounter{image}{-1}%
  \loop\ifnum\value{image}<#2\relax
    \stepcounter{image}%
    \vspace*{\fill}
    \edef\current{\threedigits{image}}%
    \includegraphics{\current}%
    \\[12pt]\texttt{\current.png} % comment if you don't want the file name here
    \vfill
    \newpage
  \repeat
}
\newcommand{\threedigits}[1]{%
  \ifnum\value{#1}<100 0\fi\ifnum\value{#1}<10 0\fi\arabic{#1}%
}
\begin{document}
\centering
\placeimages{1}{123}
\end{document}

I used the demo option for graphicx just to avoid the need to populate my folder with mock images.

egreg
  • 1,121,712