Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

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

1 Answer

up vote 10 down vote accepted

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.

share|improve this answer
    
Thanks, exactly what I needed . –  Asghar Sep 27 '12 at 12:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.