0

I'm just trying add some animation into my thesis, but pdf-backend still compliants to me, that requested file can't be found.

Also I would like to know how to proceed, if the image is not stored in the same directory. For attached MNWE, file is stored in same directory as compiled test.tex file.

If I am right, the syntax should be like (The number of frames need not be specified):

\animategraphics[<options>]{<frames per second>}{<name without extension>}{<first frame>}{<last frame>}

Compiled by:

  • lualatex --enable-write18 --shell-escape test.tex works NOK
  • pdflatex --enable-write18 --shell-escape test.tex works OK

MNWE

\documentclass{article}
\usepackage{graphicx}
\usepackage{animate}


\begin{document}
  text

  \begin{figure}
    \centering
   \animategraphics[controls,autoplay,loop]{2}{animation}{}{}
 \end{figure}

\end{document}

For sake of completens, I also try the answer in the similar post Animation using a sequence of images in a single pdf file, but the behavior is the same.

Code for generating PDF with 20 pages used for animation:

    % This animation helps explain the geometric interpretation of the 
    % definite integral.
    % http://texample.net/tikz/examples/animated-definite-integral/

    \documentclass[tikz]{standalone}
    \usepackage{tikz, pgf}
    \usepackage{multido}


    \begin{document}
    %
    \multido{\n=1+1}{20}{%
        \begin{tikzpicture}[scale=1.25]
        \draw[red,thick,<->] (-1,1) parabola bend (0,0) (2.1,4.41)
            node[below right] {\(y=x^2\)};
        \draw[loosely dotted] (-1,0) grid (4,4);
        \draw[->] (-0.2,0) -- (4.25,0) node[right] {\(x\)};
        \draw[->] (0,-0.25) -- (0,4.25) node[above] {\(y\)};
        \foreach \x/\xtext in {1/1, 2/2, 3/3}
        \draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {\(\xtext\)};
        \foreach \y/\ytext in {1/1, 2/2, 3/3, 4/4}
        \draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {\(\ytext\)};
    %
        \def\mc{\n*\n}
        \pgfmathsetmacro\result{int(\n*\n*\n)}
        \shade[top color=blue,bottom color=gray!50]
            (0,0) parabola (0.1*\n,0.01*\mc) |- (0,0);
        \node[draw, fill=white] at (3cm,2cm) 
        {\(\int\limits_0^{\frac{\n}{10}}\!\!x^2\mathrm{d}x = \frac{\result}{3000}\)};
        \draw[fill=black,color=black] (0.1*\n,0.01*\mc) circle (1.2pt);
        \end{tikzpicture}
    }
    \end{document}
JardaFait
  • 3,922
  • The command looks correct. Does a simple \includegraphics{animation} find the file? (Its name should be animation.pdf, obviously a multipage PDF.) – AlexG Nov 25 '19 at 12:01
  • You may use \graphicspath{...} to extend the list of paths to be searched for graphics files. – AlexG Nov 25 '19 at 12:09
  • Also, case matters: aniMation.PDF might not be found. – AlexG Nov 25 '19 at 12:24
  • @AlexG doesn't work for me either with lualatex (pdflatex is fine). – Ulrike Fischer Nov 25 '19 at 12:49
  • 1
    @Ulrike lualatex fails for some reason, that's new: due to recent changes of grf*-related pkgs or the renewed l2e format, perhaps? On the other hand, no problem with pdflatex and xelatex... – AlexG Nov 25 '19 at 13:31
  • @AlexG You need to unquote the file name when using \pdfximage. I can give you code in the chat. – Ulrike Fischer Nov 25 '19 at 13:33
  • @Ulrike So, \pdfximage (pdfTeX) and \saveimageresource (LuaTeX) have different syntax? (I do \let\pdfximage\saveimageresource in pdfbase, as suggested in the LuaTeX manual.) AND I don't use quotes ... – AlexG Nov 25 '19 at 13:43
  • @AlexG: You are author of the package Animate, or it is coincidence with Alexander Grahn :-). Sorry for off-topic. – JardaFait Nov 25 '19 at 13:46
  • @JardaFait No coincidence ;-) – AlexG Nov 25 '19 at 13:47
  • @AlexG. I try to use the package 'luatex85' because it provides emulation of pdfTEX primitives for LuaTEX, but it doesn't work. – JardaFait Nov 25 '19 at 13:56
  • Note that, even with the pdflatex-compiled version, the animation does not work if the final pdf is opened in Mac Preview. (It does, however, work as expected if opened on a Mac using Adobe Acrobat Reader.) – murray Nov 25 '19 at 14:47
  • @murray Preview has never worked. animate-type PDF-animations run in AR, Foxit, PDFXChange. Apart from this, you can produce animated SVG which run everywhere, where Chromium-based browsers exist. Firefox too, but with bad performance. – AlexG Nov 25 '19 at 15:12
  • @AlexG: Can SVG graphics be created from LaTeX/TikZ and then be embedded in a PDF document that would run "anywhere"? – murray Nov 27 '19 at 16:28
  • @murray No, SVG cannot be embedded into PDF without being converted itself to PDF before. Yet, SVG may be used as output format for complete documents instead of PDF, see https://tex.stackexchange.com/a/235180 . – AlexG Nov 27 '19 at 17:24

1 Answers1

2

Luatex and pdftex handle quoted file names differently. A work-around (until animate is corrected) could be

\documentclass{article}
\usepackage{graphicx}
\usepackage{animate}
\makeatletter
\def\@anim@getpagecount#1#2#3{%
    \edef\@anim@tempfilename{\noexpand\unquote@name{#1.#2}}%
    \pdfximage page 1 {\@anim@tempfilename}\xdef#3{\the\pdflastximagepages}%
  }
\makeatother
\begin{document}
  text

  \begin{figure}
    \centering
   \animategraphics[controls,autoplay,loop]{2}{example-image-duck}{}{}
 \end{figure}

\end{document}
Ulrike Fischer
  • 327,261