5

In our childhood, probably all of us made some drawings on layered sheets of paper in order to make an animation.

[edit: This is to be added to an existing document, next to the page number for example.]

To do such an page-by-page animation in a LaTeX document of 123 pages (e.g.), I would like to include images named from "image001" to "image123" in successive pages, so that:

  • page 1 includes "image001"

  • page 2 includes "image002"

  • ...

  • page 123 includes "image123".

A way to do this is would be to use a command of the form:

\includegraphics[]{\BASENAME + \PAGENUMBER + \INCREMENT}

% \BASENAME: path of folder + beginning of name
% \PAGENUMBER: page number
% \INCREMENT: number of the first page to have an image (minus one)

but I do not know how to implement such a feature.

2 Answers 2

4

Use a whiledo-loop:

\documentclass{article}
\usepackage[demo]{graphicx} %remove if you have the images
\usepackage{ifthen}
\begin{document}
\newcommand\increment{1}
\whiledo{\increment < 50}
 {Image \ifnum\increment<10 0\fi\increment: 
  \includegraphics{image\ifnum\increment<10 0\fi\increment}\newpage
  \edef\increment{\the\numexpr\increment +1}%
 }

\end{document}
4
  • Thank you. I might no have been clear enough: I would like to add the images in an existing document, for example next to the page number. Your suggestion creates a new page for each figure. But your answer helped me understand the structure I should use. I will probably post a solution soon.
    – anderstood
    Aug 23, 2013 at 8:23
  • 1
    @anderstood: If the graphic is in the header or footer definition something like \includegraphics{image\arabic{page}} should work (you perhaps need some additional code to handle leading zeros). Aug 23, 2013 at 8:29
  • @Ultrike Fischer: I'd like to post my solution, based on your answer. How can I do this without not accepting your solution ?
    – anderstood
    Aug 23, 2013 at 8:42
  • @anderstood: You can edit your question. Or write a answer. Aug 23, 2013 at 8:45
0

There might be simpler solutions, but it is possible to add a sequence of images in the header doing so:

\documentclass{article}
\usepackage{graphicx}
\usepackage{fancyhdr} 
\usepackage[nomessages]{fp} 

\newcommand{\startImageNum}{15} % first included image is image15
\newcommand{\fileExtNumDef}{\FPeval\fileExtNum{round(\thepage + \startImageNum:0)}}

% define the right header:

\rhead[]{\fileExtNumDef\fileExtNum~\includegraphics[width=3cm]{image\fileExtNum}}

\begin{document}
...
\end{document}

It is possible to change the header anywhere by redefining rhead.

This solution requires fancyhdr and fp packages which i am already using.

You must log in to answer this question.

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