# “Undefined control sequence.” when using animate package (animateinline)

\documentclass[11pt,a4paper,fleqn,final]{article}
%\usepackage{tikz}
\usepackage[tikz]{ocgx2}
\usepackage[dvipdfmx,loop,palindrome,autoplay]{animate}
\usepackage{chemfig}

\begin{document}
\begin{center}
\begin{animateinline}{1}
\setatomsep{3em}\chemfig{O=C=O}
\newframe
\setatomsep{2.5em}\chemfig{O=C=O}
\newframe
\setatomsep{2em}\chemfig{O=C=O}
\newframe
\setatomsep{1.5em}\chemfig{O=C=O}
\newframe
\setatomsep{1em}\chemfig{O=C=O}
\end{animateinline}
\end{center}
\end{document}


When I compile this I get the following warning + nothing on the page.

! Undefined control sequence.
<argument> \LaTeX3 error:
Erroneous variable \origin:pbs@obj16 used!
l.20 \end{animateinline}


The same goes with "\newframe". My suspicion is that its the pdfbase.sty that is throwing the error.

EDIT:

\documentclass[dvipdfmx,11pt,a4paper,fleqn,final]{article}
\usepackage[loop,palindrome,autoplay]{animate}

\begin{document}

\begin{center}
\begin{animateinline}{1}
a
\newframe
b
\newframe
c
\newframe
d
\newframe
e
\end{animateinline}
\end{center}
\end{document}


This render:

The driver dvipdfmx cannot be auto-detected and must be passed as an option to all packages which contain dvipdfmx-specific code. In the code example, these are animate and ocgx2 (not used, currently). (Another popular package is hyperref.)

Therefore, driver options are usually set globally with the documentclass as in:

\documentclass[dvipdfmx,11pt,a4paper,fleqn,final]{article}
%\usepackage{tikz}
\usepackage[tikz]{ocgx2}
\usepackage[loop,palindrome,autoplay]{animate}
\usepackage{chemfig}

\begin{document}
\begin{center}
\begin{animateinline}{1}
\setatomsep{3em}\chemfig{O=C=O}
\newframe
\setatomsep{2.5em}\chemfig{O=C=O}
\newframe
\setatomsep{2em}\chemfig{O=C=O}
\newframe
\setatomsep{1.5em}\chemfig{O=C=O}
\newframe
\setatomsep{1em}\chemfig{O=C=O}
\end{animateinline}
\end{center}
\end{document}


Note that the animation widget size is defined by the first frame's dimensions and that the frames to follow are stretched or squeezed to fit into this widget. Consider putting all frames into a box with the same pre-defined width together with a \strut to also extend the box vertically, e. g.

\makebox[8em][c]{\strut\setatomsep{3em}\chemfig{O=C=O}}

• This seems like a good solution but I cannot get it to work (except that I get SOMETHING rendered upon compilation). I have made the example even more slimmed down but cannot get the simple animation to work anyway... (added more info to the question). – Jimmy Westberg Jan 10 '17 at 13:40
• Which PDF viewer are you using? A-Reader, Foxit, PDF-XChange are supported (because animations rely on JavaScript) . – AlexG Jan 10 '17 at 13:54
• Adobe Acrobat Reader DC 2015.020.20042 – Jimmy Westberg Jan 10 '17 at 13:57
• Works perfectly here, using an older Acrobat Reader. Do you process the code with latex and dvipdfmx and is your TeX installation up-to-date? – AlexG Jan 10 '17 at 14:01
• I use BaKoMa and I guess that is what I do (latex + dvipdfmx). I have a hard time figuring out how to see this within the editor of BaKoMa. – Jimmy Westberg Jan 10 '17 at 14:07