# Problem with animate package and PSTricks

For some reason I haven't been able to discern yet, the code appended below returns the error message \begin{pspicture} on input line [...] ended by \end{animateinline when I try to compile over pdfLaTeX:

\documentclass{memoir}

\usepackage{xifthen,ifpdf,ifxetex}
\usepackage[pdfcrop = { --hires }]{auto-pst-pdf}

\ifpdf
\else\usepackage{pstricks}
\fi

\usepackage{animate}

\begin{document}
\psset{xunit = 1cm, yunit = 1cm}
\begin{animateinline}[%
begin = {\begin{pspicture}(0,0)(1,1)},
end = {\end{pspicture}}%
]{2}
\psline(0,0)(0.5,0.5)
\newframe*
\psline(0,0)(1,1)
\end{animateinline}
\end{document}


Anyone replicates this behavior or hints at what is wrong in my code? I'm on Windows Xp and MikTeX 2.9. In all those cases where I have been using the animate package without a pspicture environment, I had no trouble at all.

-

auto-pst-pdf chokes on the

begin = {\begin{pspicture}(0,0)(1,1)},
end = {\end{pspicture}}


stuff. Moving the pspicture environment into animateinline sidesteps the problem:

\documentclass{memoir}

\usepackage{xifthen,ifpdf,ifxetex}
\usepackage[pdfcrop = { --hires }]{auto-pst-pdf}

\ifpdf
\else\usepackage{pstricks}
\fi

\usepackage{animate}

\begin{document}
\psset{xunit = 1cm, yunit = 1cm}
\begin{animateinline}[%
%  begin = {\begin{pspicture}(0,0)(1,1)},
%  end = {\end{pspicture}}%
]{2}
\begin{pspicture}(0,0)(1,1)
\psline(0,0)(0.5,0.5)
\end{pspicture}
\newframe*
\begin{pspicture}(0,0)(1,1)
\psline(0,0)(1,1)
\end{pspicture}
\end{animateinline}

\end{document}

-

You can also use the all-in-one approach as follows. Compile it with pdflatex -shell-escape inputfile.tex.

% inputfile.tex

\documentclass[preview,border=12pt,12pt]{standalone}% change it back to your own documentclass (memoir)

\usepackage{filecontents}
\begin{filecontents*}{diagrams.tex}
\documentclass[pstricks,border=12pt,12pt]{standalone}
\psset{unit=2cm}
\begin{document}
\foreach \x in {{\psline(0.5,0.5)},{\psline(1,1)}}{%
\begin{pspicture}(1,1)
\x
\end{pspicture}}
\end{document}
\end{filecontents*}

\usepackage{pgffor}
\usepackage{animate}

% compiling the diagrams
\def\OptionA{%
\foreach \compiler/\ext in {latex/tex,dvips/dvi,{ps2pdf -dAutoRotatePages=/None}/ps}
{\immediate\write18{\compiler\space diagrams.\ext}}}

\edef\sharp{\string#}
\def\OptionB{%
\foreach \compiler/\ext in {latex/tex,dvips/dvi,{ps2pdf -dAutoRotatePages\sharp/None}/ps}
{\immediate\write18{\compiler\space diagrams.\ext}}}

% If you cannot use \OptionA (for OS other than Windows XP), use \OptionB (for Windows XP)
%\OptionA
\OptionB

\begin{document}
\animategraphics[autoplay,controls,scale=2,loop]{4}{diagrams}{}{}
\end{document}


Zoomed and running.

Stopped.

-
\OptionA and \OptionB are provided to cancel the auto rotate page feature in ps2pdf. Choose one of them based on your OS. –  cyanide-based food Jan 15 at 8:20