2

I'm trying to load images from a directory but I can't because I don't know why \i does not indicate the number, code searches the directory and the files were not found..

\documentclass{beamer}
\usepackage{pgfplots}
\usepackage{animate}
     \begin{document}
   \begin{frame}[label=detour]
    \animate<1-3>
    \begin{tikzpicture}
    \begin{axis}[name=plot1,
    clip=false,
    axis lines=center,
    height=4cm,
    width=4cm,
    x post scale=1.4,
    ]
    \foreach \i in {1,...,3}{
    \only<\i>{\addplot[blue, line width=0pt, fill=blue!20, opacity=0.5]   table [col sep=tab,trim cells=true, x index=0, y index=\i] {images_thesis/resolution_images/espectros_im_P_10_F_0_sigma_500.txt}\closedcycle}; 
 \only<\i>{\node[anchor=south west,inner sep=0] at (axis cs:20000,0) {\includegraphics[width=\textwidth]{./images_thesis/resolution_images/img-\i}};}}
   \end{axis}
   \end{tikzpicture}
   \end{frame}

   \end{document}

The error when pdflatex compiles is

File `./images_thesis/resolution_images/img-\i ' not found. \end{frame}
Karlo
  • 3,257
  • Just for testing, have you tried without the \only part? Or fast with the foreach and no tikzpicture – daleif Jul 31 '15 at 20:16
  • Yes, I did, but the pdf only shows an empty axes in the frame... no error curiously – Alejandro Munoz Ossa Jul 31 '15 at 20:20
  • I think the problem lies in the \i, because this one does not convert in 1, 2, 3 ... – Alejandro Munoz Ossa Jul 31 '15 at 20:22
  • Reduce even more, remove the plot and concentrate on getting get foreach + includegraphics to work, then add the rest later. Have you tried removing the "./" (should not make a difference). Does it work in a simple doc with the article class? Foreach comes from the pgffor package – daleif Jul 31 '15 at 20:25
  • What else do you get (I'm on a tablet so cannot test) – daleif Jul 31 '15 at 20:28
  • The table does not have problems, the table command plots the data correctily in the axes, the problem is in the images i dont understand the error... – Alejandro Munoz Ossa Jul 31 '15 at 20:33
  • Curiously in Article class load images but I need them on beamer class... – Alejandro Munoz Ossa Jul 31 '15 at 20:37
  • That is why I'm trying to get you to rule out as much as possible. Is it even possible to load images that way? Do you mind making a new doc that loads the article class plus pgffor and graphicx and then a simple foreach 1,2,3 loop to load the images. If that works, then the problem may be elsewhere. Just noticed the animate. It might even be that. What you tried a different name for the foreach loop variable. Does it work with {1,2,3} instead? – daleif Jul 31 '15 at 20:38
  • Yes, I can use another way, I tried with
     `\multiinclude[<+>][format=pdf,graphics={width=3cm,height=2cm},start=0,end=3]{images_thesis/resolution_images/IM_SPA_P_10_F_0_sigma_500}};`
    
    

    But I can load only one image per frame, when I put another multiinclude, ERROR, and its so slow too...

    – Alejandro Munoz Ossa Jul 31 '15 at 20:40
  • When I put the numbers manually img-1, img-2, img-3... the code responds correctly but I need 100 images... – Alejandro Munoz Ossa Jul 31 '15 at 20:47
  • Just tested you example on a pc. If I leave out the plot stuff (where I do not have the data), and have 3 images in the folder, then no problem looping over and including them. At least no compilation errors. You might want to make a data set and images available such that we can test something as close to what you are testing, as it is now we are testing blind. Cannot help more from here. – daleif Jul 31 '15 at 20:50
  • And the multiinclude was not what I was asking you to test. I was asking you to verify that image inclusion using pgffor actually works in the simplest of cases because than that is not the problem. Now I have went to the trouble of actually verifying that as much as what I could test in your example actually work. – daleif Jul 31 '15 at 20:53
  • Then at exactly which "i" does the code fail? Have you tried adding a file existence test? \IfFileExists{filename with ext}{found}{not found} – daleif Jul 31 '15 at 20:56

0 Answers0