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 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?

share|improve this question
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 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
Thank you! both work beautifully. –  Danial Tz Apr 14 '11 at 17:37

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.