2

I have a bunch of multi-page PDF files to be animated in various formats such as GIF, animated PDF, MP4, and animated SVG. To do so I write a batch file for each type of animations to animate those multi-page PDF files.

Only for the sake of simplicity, the code to produce a multi-page PDF is intentionally put into the animation-specific batch. In my real scenario, each batch only has code to produce a specific type of animation from a multi-page PDF.

The test input file to produce a multi-page PDF is given as follows:

% test.tex
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\begin{document}
\multido{\i=40+40}{9}
{
    \begin{pspicture}[showgrid=false](-2,-2)(2,2)
    \psline(2;\i)      
    \end{pspicture}
}
\end{document}

Each animating batch needs a wrapper that I actually put in my local TeX directory. The wrapper is as simple as follows.

% wrapper.tex
\documentclass[border=\Border]{standalone}
\usepackage[dvisvgm]{animate}
\usepackage[dvisvgm]{graphicx}
\begin{document}
\animategraphics[\Options]{\FrameRate}{\FileName}{}{}%
\end{document}

And the animating batch is as follows.

rem animator.bat
echo off

rem %1 input filename without extension
rem %2 frame rate
rem %3 animate options such as palindrome, controls, autoplay, scale=1, loop, etc
rem %4 standalone border

rem pre-cleaning
for %%x in (aux log dvi ps pdf svg) do (if exist "%~1.%%x" del "%~1.%%x")

latex "%~1.tex"
dvips "%~1.dvi"
ps2pdf "%~1.ps"

latex  --jobname="%~1" "\def\FileName{%~1}\def\FrameRate{%2}\def\Options{%~3}\def\Border{%4}\input{wrapper}"

dvisvgm --bbox=papersize --font-format=woff --zoom=-1 "%~1" 

rem post-cleaning
for %%x in (aux log dvi ps) do (if exist "%~1.%%x" del "%~1.%%x")

Problem

Only for simplicity I put all of those files in a single directory. I invoke the batch from command prompt as follows

animator.bat test 10 "controls,scale=1,loop,autoplay,palindrome" 12pt

but I got the following errors.

LaTeX Warning: Reference `anim@abspage0' on page 1 undefined on input line 5.

! Package xkeyval Error: controls,scale=1,loop,autoplay,palindrome' undefined in families anim@user'.

See the xkeyval package documentation for explanation. Type H for immediate help. ...

l.5 ...aphics[\Options]{\FrameRate}{\FileName}{}{} % ?

How to fix this error?

1 Answer 1

2

try \expandafter\animategraphics\expandafter[\Options]{\FrameRate}{\FileName}{}{}%

2
  • Out of topic: I found another problem when using --precision=x where x<6 as mentioned in my post here. Jun 23, 2020 at 14:14
  • Sorry. I meant x<4. Jun 23, 2020 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.