I want to include a sequence of images in Beamer (although it can be in another type of document). Something similar to the option Photo Album in LibreOffice and MS PowerPoint.

What I did is to make a template (that I can modify):


And then I use a Python script to generate the code for each frame, like this:

tex_file = open(filename + '.tex', 'a+')
for name in list_files:
    print >> tex_file, s1 %(comment, title, subtitle, name)


After that I just use an \include in my main file to add the sequence of images.

My question: Is there a package for this task? or a better way to do it?

  • Yes you can do this with loops in (La)TeX... no problem. What does the sequence look like... photo_001.jpg, photo_002.jpg, ...? – Werner Sep 23 '14 at 3:43
  • Yes, I generate the images automatically and name them like that: im-vf=1.png, im-vf=2.png, ... – nicoguaro Sep 23 '14 at 3:55

Here is an option using multido:

enter image description here

    \frametitle{Title: \i}
    \framesubtitle{Subtitle: \i}

The syntax is \multido{<var>=<start>+<inc>}{<times}{<stuff>} which defines <var> to be <start>, incremented by <inc> a total of <times>-1 times (since the first value counts as an iteration), and with each iteration it executes <stuff>. The special \i-notation means that <var> will be an integer.

The above example assumes minimal changes from one element to the next. If, for example, you have varied content for the frame title, subtitle and any additional comments on a per-photo basis, then using a list-like approach would be far better. For than, any of the techniques mentioned in How to iterate over a comma separated list? would be helpful.

  • Thanks, this is really useful! Although the \r and \n variables are not perfect they work. For more elaborated things I will look at iteration over a CSV file. – nicoguaro Sep 23 '14 at 21:53

I have a tex file that I wrote to produce a display of photos that does something like this. For me the goal is to arrange a changing collection of photos on a grid covering the page. I use tikz to both loop over the photos, that are stored as a comma separated list of image filenames, and to place the photos.

As you are talking about generating the list of filenames via python you could easily populate a variable list like the one used below.

Here is a cut down version:


\def\MyImages{example-image-a,example-image-b,example-image-c}% list of images
          picture/.style={draw,rectangle,anchor=#1,inner sep=0pt,outer sep=0pt}
     \foreach \Image in \MyImages {
       \node[picture=north west] at (\X,-101.5mm)
       \global\advance\X by 49.5mm

This produces:

enter image description here


enter image description here

This is possible using the \multiinclude command from beamer's xmpmulti package.

Assuming the images are called fig-0.png, fig-1.png etc. the macro can be used like this:


\multiinclude[<+->][format=png, graphics={width=\textwidth}]{fig}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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