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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I try to make multiple slides in beamer with 3 figures on each slide and the title. I would like to loop through the list/array of figures and set the frame title. The name of the figure files and the name of the frame should be different.

Here is the attempt:

\def\fnames{red, green, blue}

\foreach \name in \fnames {%

    \includegraphics[width=4.cm]{./plots/tot\name _log.eps} 
    \includegraphics[width=4.cm]{./plots/tot\name _log.eps} 
    \includegraphics[width=4.cm]{./plots/tot\name _log.eps} 


The question: is it possible to set the title of the frame from a separate list or array. So instead of fnames, I would like to get it from: \def\tnames{white, gray, black}

share|improve this question
related (?) "For loop" in newcommand – cmhughes Jan 3 '13 at 18:16
Are you using pgffor? If so you may use the / for multiple lists (and variables). Otherwise you may consider to provide a MWE meta.tex.stackexchange.com/questions/228/… – bloodworks Jan 3 '13 at 20:50
up vote 5 down vote accepted

You can define a PGF array and access it via \pgfmathparse, the array index starts from 0 instead. I've used a,b,c for convenience.

EDIT: Added a general content loop but still it is not that economic on verbosity.

\usepackage{mwe} %<- for dummy images



\foreach \x[count=\xcount from 0] in \fnames {%
\foreach\y in{1,2,3}{


enter image description here

share|improve this answer
Thank you. That works! – Yuri Jan 4 '13 at 19:32
@Yuri: If you are happy with the answer, please upvote and accept it. That's the (nicest) way to say 'thanks' on TeX.SX. – Count Zero Jan 4 '13 at 19:40
Is it possible to make a loop inside the columns to repeat \column{0.33\textwidth} \includegraphics[width=4.cm]{example-image-\x} in a less verbose way? – kiss my armpit Mar 18 '13 at 19:32
@ClickMe Sorry I forgot this apparently. Now added a loop, but it's not that of a shortcut. – percusse Jun 1 '13 at 7:23
@anonymous Yes it is a known problem. Take a look at tex.stackexchange.com/questions/117732/tikz-and-babel-error – percusse Jul 22 '13 at 15:09

Your Answer


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.