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.

4
  • Welcome to TeX.SX! Will the document contain other things or just the images?
    – egreg
    Sep 27, 2012 at 10:34
  • Here is a very similar question with a lot of approaches: tex.stackexchange.com/q/53458/10570
    – Holle
    Sep 27, 2012 at 10:47
  • @Holle They are aimed at printing all files in some directories. Here the situation is simpler.
    – egreg
    Sep 27, 2012 at 10:50
  • @egreg Thanks :) No, I don't need anything else other than the images.
    – Asghar
    Sep 27, 2012 at 11:09

1 Answer 1

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.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .