2

I have a case, where my files are named images_001.png .... images_011.png.

I tried to put them like this:

\def\filelists{1/{"t0_01"},2/{"038"}, 3/{"050"},4/{"060"}}

\foreach \i\element in \filelists {

\node[inner sep=0cm, outer sep=0cm] at (0, 1.5+\i*-3.1){\includegraphics[width=12cm, height=3cm,bb=390bp 70bp 3810bp 930bp,clip]{/Users/xxxxx/paper_animations/fig4_conc_set3_\element.png}};

}

but I could not manage finally. Any advice?

Martin Scharrer
  • 262,582
Danial Tz
  • 307
  • 3
    Does it work if you put a / (forward slash) between \i and \element? If not, it would help greatly to expand your example to make it a full document, and to describe the actual error you get. – Matthew Leingang Apr 14 '11 at 17:05

1 Answers1

2

AFAIK the \includegraphics macro only expands its path argument once, so you need to preprocess it and feed the fully expanded path to it:

\def\filelists{1/{"t0_01"},2/{"038"}, 3/{"050"},4/{"060"}}

  \foreach \i/\element in \filelists {
    \edef\imagepath{/Users/xxxxx/paper_animations/fig4_conc_set3_\element.png}
    \node[inner sep=0cm, outer sep=0cm] at (0, 1.5+\i*-3.1){\includegraphics[width=12cm,   height=3cm,bb=390bp 70bp 3810bp 930bp,clip]{\imagepath}};
}

If this doesn't work try:

\def\filelists{1/{"t0_01"},2/{"038"}, 3/{"050"},4/{"060"}}

  \foreach \i/\element in \filelists {
    \node[inner sep=0cm, outer sep=0cm] at (0, 1.5+\i*-3.1){%
    \edef\imagecmd{\noexpand\includegraphics[width=12cm,height=3cm,bb=390bp 70bp 3810bp 930bp,clip]{/Users/xxxxx/paper_animations/fig4_conc_set3_\element.png}}\imagecmd};
}

which should work.

As Matthew already commented: There is a / missing between \i and \element.

Martin Scharrer
  • 262,582