Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following minimal working example. It's great to have an animation in pdf format. But sometimes it would be good to be able to export it into an animated gif or something else (swf, video file, svg?). How do I achieve this? I often have animations together with pgfplots.

\documentclass{article}

\usepackage{animate}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{animateinline}

\begin{document}

\begin{center}
\fboxsep1mm
    \begin{animateinline}[autoplay,loop]{2}
    a
    \newframe    
    b
    \newframe  
    c                 
    \end{animateinline}
\end{center}

\end{document}

Remark:

The animation is not visible in all pdf viewers. It surely works with a current Adobe Reader.

share|improve this question
    
See my answer that can produce many output format in one click. –  Please don't touch Oct 12 '13 at 15:14
add comment

1 Answer 1

up vote 4 down vote accepted
+50

After redefinition of some animate macros, LaTeX produces a multipage document which can be converted to SWF using pdf2swf or to bitmapped formats using other tools, e. g. dvipng.

\documentclass{article}

\usepackage{animate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[active,tightpage]{preview}
\makeatletter
\renewenvironment{animateinline}[2][]{%
  \setboolean{@anim@inside}{true}\begin{preview}}{%
  \end{preview}\setboolean{@anim@inside}{false}}
\renewcommand{\newframe}[1][]{\end{preview}\begin{preview}}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    
\begin{document}

\begin{center}
  \begin{animateinline}[autoplay,loop]{2}
  a
  \newframe
  b
  \newframe
  c
  \newframe
  \multiframe{3}{i=0+1}{\i}
  \end{animateinline}
\end{center}

\end{document}
share|improve this answer
    
Thanks! Is was hoping for a way that doesn't include changing the internal code of the animate package. –  Manuel Kuehner Oct 8 '13 at 20:55
    
Apparently there is no 'easy' alternative to your approach. Thanks for the answer! –  Manuel Kuehner Oct 16 '13 at 11:38
    
I might add some code to animate in the future that detects whether preview was loaded and which then takes the necessary actions. –  AlexG Oct 16 '13 at 11:45
    
Thanks. Looking forward to it. Animate is a great package - I use it a lot. –  Manuel Kuehner Oct 16 '13 at 12:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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