% Copyright 2007--2010 Alexander Grahn % % This material is subject to the LaTeX Project Public License. See % http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html % for the details of that license. % \documentclass[a4paper]{article} \frenchspacing \usepackage[UKenglish]{babel} \usepackage{pst-3dplot} \usepackage{animate} \usepackage{intcalc} \usepackage{graphicx} \graphicspath{{files/}} \usepackage{color} \usepackage{textcomp} \usepackage{lmodern} \usepackage{mflogo} \usepackage[T1]{fontenc} \usepackage[protrusion]{microtype} \usepackage{ifpdf} \usepackage{parskip} \usepackage{tabls} \usepackage{multirow} \usepackage{hyperref} \usepackage{amsmath} \usepackage[all]{hypcap} \clubpenalty=10000 \widowpenalty=10000 \displaywidowpenalty=10000 \renewcommand{\textfraction}{0.0} \renewcommand{\topfraction}{1.0} \renewcommand{\bottomfraction}{1.0} \makeatletter \renewcommand{\fnum@figure}[1]{\figurename~\thefigure} \newcommand\myparagraph{\@startsection{paragraph}{3}{\z@}% {\parskip}% {0.001\parskip}% {\itshape\normalsize}} \makeatother \ifpdf \makeatletter \@latex@error{This document contains PSTricks code.\MessageBreak Please compile it using the following commands:\MessageBreak\MessageBreak latex, dvips, ps2pdf -dNOSAFER\MessageBreak\MessageBreak Don't use option `-Ppdf` with dvips} \makeatother \fi \def\keywords{include portable PDF animation animated PDF animating embed animated graphics LaTeX pdfLaTeX PSTricks pgf TikZ LaTeX-picture MetaPost inline graphics vector graphics animated GIF LaTeX dvips ps2pdf dvipdfmx XeLaTeX JavaScript Adobe Reader} \hypersetup{ bookmarksnumbered,linktocpage,breaklinks, pdftitle={The animate Package}, pdfsubject={Documentation}, pdfauthor={Alexander Grahn}, pdfkeywords={\keywords}, citebordercolor={0 0 1}, filebordercolor={0 0 1}, linkbordercolor={0 0 1}, menubordercolor={0 0 1}, pagebordercolor={0 0 1}, urlbordercolor={0 0 1}, % pdfpagelayout=SinglePage } \def\XeLaTeX{X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}}\kern-.125em\LaTeX} \def\pXepLaTeX{(X\kern-.1667em\lower.5ex\hbox{\reflectbox{E}})\kern-.125em\LaTeX} \begin{document} \title{The {\sffamily animate} Package} \author{Alexander Grahn \animategraphics[autoplay,loop,height=1.8ex]{8}{bye_}{0}{3}\protect\footnote{Animated GIF taken from \href{http://www.phpBB.com}{phpBB} forum software and burst into a set of EPS files using \href{http://www.imagemagick.org}{ImageMagick} before embedding. Animations may run slowly if viewed in the Adobe Reader browser plugin.}\\[1ex]\includegraphics[height=2.7ex]{mailto}} \maketitle \begin{abstract} \raggedright \noindent A LaTeX package for creating portable, JavaScript driven PDF animations from sets of vector graphics or rasterized image files or from inline graphics. \vskip 0.2\baselineskip \emph{Keywords}: \keywords \end{abstract} \tableofcontents %\newpage \section{Introduction} This package provides an interface to create PDFs with animated content from sets of graphics or image files, from inline graphics, such as \LaTeX-picture, PSTricks or pgf/TikZ generated pictures, or just from typeset text. Unlike standard movie/video formats, which can be embedded, for example, using the \LaTeX{} package `movie15'~\cite{movie15}, package `animate' allows for animating vector graphics. The result is roughly similar to the SWF (Flash) format, although not as space-efficient. Package `animate' supports the usual PDF making workflows, i.\,e. pdf\LaTeX{}, \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller and \pXepLaTeX{} $\rightarrow$ \verb+(x)dvipdfmx+. The final PDF can be viewed in current Adobe Readers on all supported platforms. %The `animate' package relies on Optional Content Groups (OCG), also known as PDF layers, which is a feature provided by the PDF-1.5 specification. Each frame of an animation is associated with an OCG that is hidden or made visible in a dynamic fashion by means of Adobe Reader's built-in JavaScript engine. \section{Requirements} \begin{trivlist} \item $\varepsilon$-\TeX \item pdf\TeX{}, version $\ge1.20$ for direct PDF output \item Ghostscript, version $\ge8.31$ or Adobe Distiller for PS to PDF conversion \item dvipdfmx, version $\ge20080607$ for DVI to PDF conversion \item Adobe Reader, version $\ge7$ \end{trivlist} \section{Installation} Unzip the file \href{http://tug.ctan.org/tex-archive/install/macros/latex/contrib/animate.tds.zip}{`animate.tds.zip'} into the local TDS root directory which can be found by running `\verb+kpsewhich -var-value TEXMFLOCAL+' on the command line. After installation, update the filename database by running `\verb+texhash+' on the command line. \TeX-Live and MiK\TeX{} users should run the package manager of their system for installation. \section{Using the package} First of all, read Section~\ref{sect:bugs} on problems related to this package. Then, invoke the package by putting the line \begin{verbatim} \usepackage[]{animate} \end{verbatim} to the preamble of your document, i.\,e. somewhere between \verb+\documentclass+ and \verb+\begin{document}+. `animate' honours the package options: \begin{verbatim} dvipdfmx xetex autoplay autopause autoresume loop palindrome draft final controls buttonsize= buttonbg= buttonfg= step useocg poster[=first | none | last] \end{verbatim} Except for `\verb+dvipdfmx+' and `\verb+xetex+', the options above are also available (among others) as command options and will be explained shortly. However, if used as package options they have global scope, taking effect on all animations in the document. In turn, command options locally override global settings. Options without an argument are boolean options and can be negated, with the exception of package-only options `\verb+dvipdfmx+' and `\verb+xetex+', by appending `\verb+=false+'. If PDF is generated via DVI and Postscript by the command sequence \verb+latex+ $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+, the `graphicx' package is required. \begin{animateinline}[autoplay,loop]{1.5}\strut\emph{Important:}\newframe\newframe[5]\end{animateinline} The \verb+dvips+ option `\verb+-Ppdf+' should \emph{not} be set when converting the intermediate DVI into Postscript. If you cannot do without, put `\verb+-D 1200+' \emph{after} `\verb+-Ppdf+' on the command line. Users of \LaTeX-aware text editors with menu-driven toolchain invocation, such as \TeX{}nicCenter, should check the configuration of the \verb+dvips+ call. Sometimes, if the same animation sequence made from graphics files is to be embedded multiple times into the document, more compact PDF output may be obtained by passing option `\verb+-dMaxInlineImageSize=0+' to \verb+ps2pdf+. \XeLaTeX{} and \verb+dvipdfmx+ require the `graphicx' package to be loaded. While \XeLaTeX{} will be auto-detected (package option `\verb+xetex+' is optional), `animate' and `graphicx' need the package option `\verb+dvipdfmx+' in the case of \verb+dvipdfmx+. Occasionally, a second \LaTeX{} run may be necessary to resolve internally created object references. An appropriate warning will be issued in such a case. \section{The user interface} Package `animate' provides the command \begin{verbatim} \animategraphics[]{}{}{}{} \end{verbatim} and the environment \begin{verbatim} \begin{animateinline}[]{} ... typeset material ... \newframe[] ... typeset material ... \newframe*[] ... typeset material ... \newframe \multiframe{}{[]}{ ... repeated (parameterized) material ... } \end{animateinline} \end{verbatim} While \verb+\animategraphics+ can be used to assemble animations from sets of existing graphics files or from multipage PDF, the environment `\verb+animateinline+' is meant to create the animation from the typeset material it encloses. This material can be pictures drawn within the \LaTeX{} `\verb+picture+' environment or using the advanced capabilities of PSTricks or pgf/TikZ. Even ordinary textual material may be animated in this way. The parameter \verb++ specifies the number of frames per second of the animation. The \verb+\newframe+ command terminates a frame and starts the next one. It can be used only inside the `\verb+animateinline+' environment. There is a starred variant, \verb+\newframe*+. If placed after a particular frame, it causes the animation to pause at that frame. The animation continues as normal after clicking it again. Both \verb+\newframe+ variants take an optional argument that allows the frame rate to be changed in the middle of an animation. The \verb+\multiframe+ command allows the construction of loops around pictures. The first argument \verb++ does what one would expect it to do, the second argument \verb++ is a comma-separated list of variable declarations. The list may be of arbitrary, even zero, length. Variables may be used to parameterize pictures which are defined in the loop body (third argument of \verb+\multiframe+). A single variable declaration has the form \begin{verbatim} =+ \end{verbatim} \verb++ is a sequence of one or more letters \emph{without} a leading backslash\footnote{This is different from {\tt\string\multido} (package `multido') where variable names have a leading `{\tt\textbackslash}' in the declaration.}. The first (and possibly only) letter of the variable name determines the type of the variable. There are three different types: integers (`\verb+i+', `\verb+I+'), reals (`\verb+n+', `\verb+N+', `\verb+r+', `\verb+R+') and dimensions or \LaTeX{} lengths (`\verb+d+', `\verb+D+'). Upon first execution of the loop body, the variable takes the value \verb++. Each further iteration increments the variable by \verb++. Negative increments must be preceded by `\verb+-+'. Here are some examples: `\verb:i=1+2:', `\verb:Rx=10.0+-2.25:', `\verb:dim=20pt+1ex:'. Within the loop body, variables are expanded to their current value by prepending a backslash to the variable name, that is \verb+\i+, \verb+\Rx+ and \verb+\dim+ according to the previous examples. \verb+\multiframe+ must be surrounded by \verb+\begin{animateinline}+ and \verb+\end{animateinline}+ or by any of the \verb+\newframe+ variants. Two consecutive \verb+\multiframe+ commands must be separated by one of the \verb+\newframe+ variants. By default, the animation is built frame by frame in the order of inclusion of the embedded material. However, extended control of the order of appearance, superposition and repetition of the material is available through the `\verb+timeline+' option (see Section~\ref{sect:timeline}). \myparagraph*{Sets of graphics files} All files of the sequence should exist and be consecutively numbered. (Exception to this rule is allowed in connection with the `\verb+every+' option, see below.) {\tt } is the leftmost part of the file name that is common to all members of the sequence. \verb++ is the number of the first and \verb++ the number of the last file in the set. If \verb++ is greater than \verb++, files are embedded in reverse order. File names may be simply numbered, such as $0\dots99$. If there are leading zeros, make sure that all file numbers have the same number of digits, such as $0000\dots0099$, and that the \verb++ and \verb++ arguments are filled in accordingly. No file name extension may be specified as a parameter. The possible file formats depend on the output driver being used. In the case of \LaTeX{}+\verb+dvips+, files with the `eps' extension are at first searched for, followed by `mps' (\MP-generated Postscript) and `ps'. With pdf\LaTeX{} the searching order is: (1)~`pdf', (2)~`mps', (3)~`png', (4)~`jpg', (5)~`jpeg', (6)~`jbig2', (7)~`jb2', (8)~`jp2'\footnotemark[1], (9)~`j2k'\footnotemark[1], (10)~`jpx'\footnotemark[1]\footnotetext[1]{JPEG2000 is not yet supported by pdf\TeX.} and with \XeLaTeX{} or \LaTeX{}+\verb+dvipdfmx+: (1)~`pdf', (2)~`mps', (3)~`eps', (4)~`ps', (5)~`png', (6)~`jpg', (7)~`jpeg', (8)~`bmp'. That is, files capable of storing vector graphics are found first. Make sure that all file names have \emph{lower case} extensions. For example, given the sequence `frame\_5.png' through `frame\_50.png' from a possibly larger set that shall be used to build an animation running at 12 frames per second, the correct inclusion command would read \begin{verbatim} \animategraphics{12}{frame_}{5}{50} \end{verbatim} \myparagraph*{Multipage PDF {\rm(pdf\LaTeX, \XeLaTeX)} and JBIG2 {\rm(pdf\LaTeX)} inclusion} If the file `\verb++.(pdf|jbig2|jb2)' exists (again, no file name extension may be specified), it is taken as a multipage document where each page represents one frame of the animation. In this case, the last two arguments, \verb++ \& \verb++, are interpreted differently from above; they specify a zero-based range of pages to be included in the animation. Either or both of them may be omitted, `\verb+{}+', in which case they default to $0$ and $n-1$, where $n$ is the total number of available pages. Arguments that fall outside this range are automatically corrected to the actual limits. If \verb++ is greater than \verb++, pages are embedded in reverse order. For example, the line \begin{verbatim} \animategraphics{12}{frames}{}{} \end{verbatim} would create an animation from all pages of the file `frames.pdf', running at 12 fps. \section{Command options} The following options to \verb+\animategraphics+ and `\verb+animateinline+' have been provided: \subsection{Basic options} \begin{verbatim} poster[=first | none | last] \end{verbatim} Specifies which frame (first, last or none) to display and print if the animation is not activated. The first frame is shown by default. Thus `\verb+poster+' or `\verb+poster=first+' need not be explicitly set. \begin{verbatim} every= \end{verbatim} Build animation from every \verb++\emph{th} frame only. Skipped frames are discarded and not embedded into the document. In the case of \verb+\animategraphics+, skipped input files may be missing. \begin{verbatim} autopause \end{verbatim} Pause animation when the page is closed, instead of stopping and rewinding it to the default frame. \begin{verbatim} autoplay \end{verbatim} Start animation after the page has opened. Also resumes playback of a previously paused animation. \begin{verbatim} autoresume \end{verbatim} Resume previously paused animation when the page is opened again. \begin{verbatim} loop \end{verbatim} The animation restarts immediately after reaching the end. \begin{verbatim} palindrome \end{verbatim} The animation continuously plays forwards and backwards. \begin{verbatim} step \end{verbatim} Step through the animation one frame at a time per mouse-click. The \verb++ argument will be ignored. \begin{verbatim} width= height= depth= \end{verbatim} Resize the animation widget. Option `\verb+depth+' specifies how far the animation widget should extend below the base line of the running text. If only one or two of these options are given, the remaining, unspecified dimensions are scaled to maintain the aspect ratio. Any valid \TeX{} dimension is accepted as a parameter. In addition, the length commands \verb+\width+, \verb+\height+, \verb+\depth+ and \verb+\totalheight+ can be used to refer to the original dimensions of the animation widget which correspond to the size of the first frame of the animated sequence. \begin{verbatim} scale= \end{verbatim} Scales the animation widget by \verb++. \begin{verbatim} bb= \end{verbatim} (\verb+\animategraphics+ only, requires package `graphicx'.) The four, space separated arguments set the bounding box of the graphics files. Units can be omitted, in which case `bp' (Postscript points) is assumed. \begin{verbatim} viewport= \end{verbatim} (\verb+\animategraphics+ only, requires package `graphicx'.) This option takes four arguments, just like `\verb+bb+'. However, in this case the values are taken relative to the origin specified by the bounding box in the graphics files. \begin{verbatim} trim= \end{verbatim} (\verb+\animategraphics+ only, requires package `graphicx'.) Crops graphics at the edges. The four lengths specify the amount to be removed from or, if negative values have been provided, to be added to each side of the graphics. \begin{verbatim} controls \end{verbatim} Inserts control buttons below the animation widget. The meaning of the buttons is as follows, from left to right: stop \& first frame, step backward, play backward, play forward, step forward, stop \& last frame, decrease speed, default speed, increase speed. Both `play' buttons are replaced by a large `pause' button while the animation is playing. \begin{verbatim} buttonsize= \end{verbatim} Changes the control button height to \verb++, which must be a valid \TeX{} dimension. The default button height is \verb+1.44em+ and thus scales with the current font size. \begin{verbatim} buttonbg= buttonfg= \end{verbatim} By default, control button widgets are drawn with black strokes on transparent background. The background can be turned into a solid colour by the first option, while the second option specifies the stroke colour. The parameter \verb++ is an array of colon-(\verb+:+)-separated numbers in the range from 0.0 to 1.0. The number of array elements determines the colour model in which the colour is defined: (1) gray value, (3) RGB, (4) CMYK. For example, `\verb+1+', `\verb+1:0.5:0.2+' and `\verb+0.5:0.3:0.7:0.1+' are valid colour specifications. \begin{verbatim} draft final \end{verbatim} With `\verb+draft+' the animation is not embedded. Instead, a box with the exact dimensions of the animation is inserted. Option `\verb+final+' does the opposite as it forces the animation to be built and embedded. Both options can be used to reduce compilation time during authoring of a document. To get the most out of them it is recommended to set `\verb+draft+' globally as a package or class option and to set `\verb+final+' locally as a command option of the animation that is currently worked on. After the document has been finished, the global `\verb+draft+' option can be removed to embed all animations. \begin{verbatim} useocg \end{verbatim} Use an alternative animation method based on Optional Content Groups (OCGs, also known as PDF Layers). May result in slower animations. \begin{verbatim} measure \end{verbatim} Measures the frame rate during one cycle of the animation. (For testing purposes.) \begin{verbatim} begin={} end={} \end{verbatim} (`\verb+animateinline+' only.) \verb++ and \verb++ are inserted into the code at start and end of each frame. Mainly used for setting up some drawing environment, such as \begin{verbatim} begin={\begin{pspicture}(... , ...)(... , ...)}, end={\end{pspicture}} \end{verbatim} A short note on the `\verb+tikzpicture+' environment: Unlike `\verb+pspicture+', the `{\tt tikz\-pic\-ture}' environment is able to determine its size from the graphical objects it encloses. However, this may result in differently sized frames of a sequence, depending on the size and position of the graphical objects. Thus, in order to ensure that all frames of the sequence be displayed at the same scale in the animation widget, a common bounding box should be shared by the frames. A bounding box can be provided by means of an invisible `\verb+rectangle+' object: \begin{verbatim} begin={ \begin{tikzpicture} \useasboundingbox (... , ...) rectangle (... , ...); }, end={\end{tikzpicture}} \end{verbatim} \subsection{The `{\tt timeline}' option}\label{sect:timeline} \begin{verbatim} timeline= \end{verbatim} \verb++ is a plain text file whose contents determines the order of appearance of the embedded material during the animation. It allows the user to freely rearrange, repeat and overlay the material at any point of the animation. This may greatly reduce the file size of the resulting PDF, as objects that do not change between several or all frames, such as coordinate axes or labels, can be embedded once and re-used in other frames of the animation. (Technically, this is done by the XObject referencing mechanism of PDF.) If a timeline is associated with the animation, the graphics files or inline graphics embedded by \verb+\animategraphics+ and `\verb+animateinline+' no longer represent the actual frames of the animation. Rather, they are a collection of \emph{transparencies} that can be played with at will. However, it is now up to the author's responsibility to construct a timeline that makes use of \emph{each} of those transparencies and to put them into a sensible order. In order to identify the transparencies within the timeline file, they are numbered in the order of their inclusion, starting at zero. A timeline-based animation can be thought of as a \emph{living stack} of translucent transparencies. Each animation frame is a snapshot of the stack viewed \emph{from above}. Transparencies are usually put on top of that stack and stay there for a given number of frames before expiring (becoming invisible). The lifetime of each transparency within the stack can be set individually. Once expired, a transparency can be put on the stack again, if desired. The stack may also be divided into an arbitrary number of \emph{sub-stacks} to facilitate the creation of layers, such as background, foreground and intermediate layers. Sub-stacks allow the insertion of transparencies at depth positions of the global stack other than just the top. It is important to keep the stack-like nature of animations in mind because graphical objects on transparencies at higher stack positions overlay the content of transparencies at lower stack positions. \myparagraph*{General structure of the timeline file} Each line of the timeline file that is not blank and which does not begin with a comment (`\verb+%+') corresponds to \emph{one} frame of the animation. There may be more transparencies than animation frames and vice-versa. A frame specification consists of three, colon-(\verb+:+)-separated fields: \begin{verbatim} [*]:[]:[] \end{verbatim} While any field may be left blank, the colons are mandatory. An asterisk (`\verb+*+') in the leftmost field causes the animation to pause at that frame, very much as a \verb+\newframe*+ would do; a number in the second field changes the frame rate of the animation section that follows. In connection with the `\verb+timeline+' option, the asterisk extension and the optional \verb++ argument of \verb+\newframe+ cease to make sense and will be tacitly ignored if present. The third field \verb++ is a comma-separated \emph{list} of \emph{transparency specifications} that determines the transparencies to be put on the stack. Semicolons (\verb+;+) are used to separate sub-stacks (= layers) from each other. A \emph{single} transparency specification obeys the syntax \begin{verbatim} [x] \end{verbatim} where \verb++ is an integer number that identifies the transparency to be drawn into the current animation frame. As pointed out above, the transparencies are consecutively numbered in the order of their inclusion, starting at zero. The optional postfix `\verb+x+' specifies the number of consecutive frames within which the transparency is to appear. If omitted, a postfix of `\verb+x1+' is assumed, which causes the transparency to be shown in the current frame only. Obviously, \verb++ must be a non-negative integer number. The meaning of postfix `\verb+x0+' is special; it causes the transparency to be shown in all frames, starting with the current one, until the end of the animation or until the animation sub-stack to which it belongs is explicitly cleared. The letter `\verb+c+', if put into \verb++, clears an animation sub-stack, that is, it causes all transparencies added so far to be removed from the sub-stack, overriding any \verb++ value. The effect of `\verb+c+' is restricted to the sub-stack in which it appears. Thus, a `\verb+c+' must be applied to every sub-stack if the complete animation stack is to be cleared. Moreover, if applied, `\verb+c+' should go into the first position of the transparency list of a sub-stack because \emph{everything} in the sub-stack up to `\verb+c+' will be cleared. %If a frame is composed of more than one transparency, transparency specifications on the left of the input line are closer to the background and will be overprinted by those on the right of the input line or which appear on subsequent lines of the timeline file. That is, the depth \emph{de}creases from left to right within \verb++ as well as in top-down direction within the timeline file. %Also, if there are transparency specifications which span several frames (using postfix `\verb+x+'), they will be overprinted by transparency specifications that appear on subsequent lines in the timeline file. That is, the depth decreases in top-down direction within the timeline file. \myparagraph*{Timeline example with a single animation stack} Table~\ref{tab:single} is an example of a single-stack animation. It lists the contents of a timeline file together with the resulting stack of transparencies. Note how the stack is strictly built from the bottom up as transparency specifications are read from left to right and line by line from the timeline file. In frame No. 4, the stack is first cleared before new transparencies are deposited on it. Also note that the stack is viewed from above and transparencies in higher stack position overprint the lower ones. \begin{table}[ht]\centering \caption{Timeline example of a single-stack animation}\label{tab:single} \begin{tabular}[t]{c|l|c}\hline frame No. & timeline file & transparency stack\\\hline\hline \multirow{2}{*}{0} & \multirow{2}{*}{\tt::0x0,1x2} & ---------1---------\\&&---------0---------\\\cline{1-1}\cline{3-3} \multirow{3}{*}{1} & \multirow{3}{*}{\tt::2} & ---------2---------\\&&---------1---------\\&&---------0---------\\\cline{1-1}\cline{3-3} \multirow{2}{*}{2} & \multirow{2}{*}{\tt::3} & ---------3---------\\&&---------0---------\\\cline{1-1}\cline{3-3} \multirow{2}{*}{3} & \multirow{2}{*}{\tt::4} & ---------4---------\\&&---------0---------\\\cline{1-1}\cline{3-3} \multirow{2}{*}{4} & \multirow{2}{*}{\tt::c,5x0,6} & ---------6---------\\&&---------5---------\\\cline{1-1}\cline{3-3} \multirow{2}{*}{5} & \multirow{2}{*}{\tt::7} & ---------7---------\\&&---------5---------\\\cline{1-1}\cline{3-3} \multirow{2}{*}{6} & \multirow{2}{*}{\tt::8} & ---------8---------\\&&---------5---------\\\cline{1-1}\cline{3-3} \multirow{2}{*}{7} & \multirow{2}{*}{\tt::9} & ---------9---------\\&&---------5---------\\\hline \end{tabular} \end{table} Figures~\ref{fig:taylor} and \ref{fig:lorenz} in Section~\ref{sect:examples} are animation examples with a single transparency stack. \myparagraph*{Grouping objects into layers (= sub-stacks) using `{\tt;}'} Due to the stack-like nature of the animation, the position of a transparency specification in the timeline file determines its \emph{depth} level in relation to other transparencies. The timeline file is processed line by line and from left to right. In a single-stack animation, the stack is strictly built from the bottom up, such that earlier transparencies are overprinted by more recent ones. This may turn out to be inconvenient in certain situations. For example, it might be desirable to change the background image in the middle of an animation without affecting objects that are located in the foreground. For this purpose, transparency specifications can be grouped into layers or sub-stacks using the semicolon (\verb+;+) as a separator. New transparencies can now be put on top of the individual sub-stacks. After a line of the timeline file has been processed, the global stack is built by placing the sub-stacks on top of the other. Again, the left-to-right rule applies when determining the height of the sub-stacks in relation to each other within the global stack. The layer concept is best illustrated by an example. In the timeline of Table~\ref{tab:multi}, transparencies are grouped into two sub-stacks only. One is reserved for the background images, transparencies No. 0 \& 1, to be exchanged in frame No. 3, as well as for two other transparencies, No. 7 \& 8, to be interspersed in frame No. 1. A second sub-stack takes the foreground objects that are successively added to the scene. The dotted lines in the third column of the table just mark the border between the two sub-stacks. In frame No. 3, `\verb+c+' first clears the bottom sub-stack before the new background image is inserted. (Instead, `\verb+x3+' could have been used with transparency No. 0 in frame No. 0.) As can be seen in the specifications of frames No. 2 \& 4, sub-stacks need not be explicitly populated; the leading semicolons just ensure the proper assignment of transparencies to animation sub-stacks. \begin{table}[ht]\centering \caption{Timeline example with two sub-stacks}\label{tab:multi} \begin{tabular}[t]{c|l|c}\hline frame No. & timeline file & transparency stack\\\hline\hline \multirow{3}{*}{0} & \multirow{3}{*}{\tt::\ \ 0x0 ; 2x0} & ---------2---------\\&&{\tiny\dotfill}\\&&---------0---------\\\cline{1-1}\cline{3-3} \multirow{6}{*}{1} & \multirow{6}{*}{\tt::7,8x2 ; 3x0} & ---------3---------\\&&---------2---------\\&&\tiny\dotfill\\&&---------8---------\\&&---------7---------\\&&---------0---------\\\cline{1-1}\cline{3-3} \multirow{6}{*}{2} & \multirow{6}{*}{\tt::\ \ \ \ \ \ ; 4x0} & ---------4---------\\&&---------3---------\\&&---------2---------\\&&\tiny\dotfill\\&&---------8---------\\&&---------0---------\\\cline{1-1}\cline{3-3} \multirow{6}{*}{3} & \multirow{6}{*}{\tt::c,1x0 ; 5x0} & ---------5---------\\&&---------4---------\\&&---------3---------\\&&---------2---------\\&&\tiny\dotfill\\&&---------1---------\\\cline{1-1}\cline{3-3} \multirow{7}{*}{4} & \multirow{7}{*}{\tt::\ \ \ \ \ \ ; 6x0} & ---------6---------\\&&---------5---------\\&&---------4---------\\&&---------3---------\\&&---------2---------\\&&\tiny\dotfill\\&&---------1---------\\\hline \end{tabular} \end{table} %\small %\begin{verbatim} % % <--layer 1--> <--layer 2--> % % % :: 0x49 ; 2x0,3x0 % transparency `0' used as background % :: ; 4x0,5x0 % image during the first 49 frames % :: ; 6x0,7x0 % etc... % :: ; 98x0,99x0 % :: 1x0 ; 100x0,101x0 % transparency `1' used as new background % :: ; 102x0,103x0 % image until end of animation % :: ; 104x0,105x0 % etc... %\end{verbatim} %\normalsize % %Note that \emph{without} setting up two layers, that is, by replacing the semicolons with commas, the foreground objects (transparencies 2 through 99) which have been added during the first 49 frames would be overprinted by the new background image, transparency 1, from frame 50 onward. See the second animation, Fig.~\ref{fig:scarab}, in Section~\ref{sect:examples} for a working example that makes use of the timeline and the layer concept. \myparagraph*{Other things to note} When designing the timeline, care should be taken not to include a transparency more than once into the \emph{same} animation frame. Besides the useless redundancy, this may slow down the animation speed in the Reader because the graphical objects of a multiply included transparency have to be rendered unnecessarily often at the same time. `animate' is smart enough to detect multiple inclusion and issues a warning message along with the transparency ID and the frame number if it occurs. Here is an example of a poorly designed timeline: \small \begin{verbatim} ::0 ::1x0 ::2 ::3 ::4,2 ::5,1 % bad: transparency `1' included twice ::6 \end{verbatim} \normalsize Also, `animate' finds and warns about transparencies that have never been used in an animation timeline. This may help to avoid dead code in the final PDF. \section{Examples} \subsection[Animations from sets of files, using `animategraphics' command]{Animations from sets of files, using {\tt \string\animategraphics} command}\label{sect:examples} Animations in this section are made from graphics files that were prepared with \MP. Run `\verb+mpost --tex=latex+' on the files ending in `.mp' in the `files' directory to generate the graphics files. Both examples make use of the `\verb+timeline+' option to reduce the resulting PDF file size. The first example, Fig.~\ref{fig:taylor}, originally written by Jan Hole\v{c}ek~\cite{hol}, shows the exponential function $y=e^x$ and its approximation by Taylor polynomials of different degree. \small \begin{verbatim} \documentclass{article} \usepackage{animate} \usepackage{graphicx} \begin{document} \begin{center} \animategraphics[ controls, loop, timeline=timeline.txt ]{4}{exp_}{0}{8} \end{center} \end{document} \end{verbatim} \normalsize Contents of file `timeline.txt': \small \begin{verbatim} ::0x0 % coordinate system & y=e^x, repeated until last frame ::1 % one blue curve per frame ::2 ::3 ::4 ::5 ::6 ::7 ::8 \end{verbatim} \normalsize \begin{figure}\capstart \centering \animategraphics[controls,loop,timeline=timeline.txt]{4}{exp_}{0}{8} \caption{}\label{fig:taylor} \end{figure} The second, somewhat more complex example, Fig.~\ref{fig:scarab}, animates the geometric construction of a scarabaeus. In addition to the use of a timeline, it introduces the layer concept. This example is adapted from Maxime Chupin's original \MP{} source file \cite{chupin}. The present version separates stationary from moving parts of the drawing and saves them into different files. A total of 254 files, scarab\_0.mps through scarab\_253.mps, is written out by running `\verb+mpost --tex=latex+' on the source file `scarab.mp'. Files 0 through 100 contain the red line segments that make up the growing scarabaeus. Files 101 through 201 contain the moving construction lines and files 202 through 252 contain the gray lines which represent intermediate stages of the construction. The last file, No. 253, contains the coordinate axes, two stationary construction lines and the labels which do not move. A timeline file `scarab.tln' is written out on-the-fly during the \LaTeX{} run. It arranges the animation into three layers, forcing the gray lines into the background, the coordinate axes into the intermediate layer and the scarabaeus along with the moving construction lines into the foreground. The final animation consists of 101 individual frames. \begin{figure}[t] \centering \newcounter{scarab} \setcounter{scarab}{0} \newcounter{blueline} \setcounter{blueline}{101} \newcounter{grayline} \setcounter{grayline}{202} % \newwrite\TimeLineFile \immediate\openout\TimeLineFile=scarab.tln \whiledo{\thescarab<101}{ \ifthenelse{\intcalcMod{\thescarab}{2}=0}{ \immediate\write\TimeLineFile{::\thegrayline x0;253;\thescarab x0,\theblueline} \stepcounter{grayline} }{ \immediate\write\TimeLineFile{::;253;\thescarab x0,\theblueline} } \stepcounter{scarab} \stepcounter{blueline} } \immediate\closeout\TimeLineFile % \animategraphics[ width=0.8\linewidth, controls, loop, timeline=scarab.tln ]{12}{scarab_}{0}{253} % \caption{}\label{fig:scarab} \end{figure} \small \begin{verbatim} \documentclass{article} \usepackage{intcalc} %defines \intcalcMod for Modulo computation \usepackage{animate} \usepackage{graphicx} \newcounter{scarab} \setcounter{scarab}{0} \newcounter{blueline} \setcounter{blueline}{101} \newcounter{grayline} \setcounter{grayline}{202} %write timeline file \newwrite\TimeLineFile \immediate\openout\TimeLineFile=scarab.tln \whiledo{\thescarab<101}{ \ifthenelse{\intcalcMod{\thescarab}{2}=0}{ %a gray line is added to every 2nd frame \immediate\write\TimeLineFile{% ::\thegrayline x0;253;\thescarab x0,\theblueline} \stepcounter{grayline} }{ \immediate\write\TimeLineFile{% ::;253;\thescarab x0,\theblueline} } \stepcounter{scarab} \stepcounter{blueline} } \immediate\closeout\TimeLineFile \begin{document} \begin{center} \animategraphics[ width=0.8\linewidth, controls, loop, timeline=scarab.tln ]{12}{scarab_}{0}{253} \end{center} \end{document} \end{verbatim} \normalsize \subsection[Animating PSTricks graphics, using `animateinline' environment]{Animating PSTricks graphics, using `{\tt animateinline}' environment} Fig.~\ref{fig:torus} is an inline graphics example adapted from \cite{gilg05}. \small \begin{verbatim} \documentclass{article} \usepackage{pst-3dplot} \usepackage{animate} %draws a torus sector \newcommand{\torus}[2]{% #1: angle of the torus sector, % #2: linewidth of leading circle \psset{Beta=20,Alpha=50,linewidth=0.1pt,origin={0,0,0},unit=0.35}% \begin{pspicture}(-12.3,-6.3)(12.3,7)% \parametricplotThreeD[xPlotpoints=100](80,#1)(0,360){% t cos 2 mul 4 u sin 2 mul add mul t sin 2 mul 4 u sin 2 mul add mul u cos 4 mul }% \parametricplotThreeD[yPlotpoints=75](0,360)(80,#1){% u cos 2 mul 4 t sin 2 mul add mul u sin 2 mul 4 t sin 2 mul add mul t cos 4 mul }% \parametricplotThreeD[yPlotpoints=1,linewidth=#2](0,360)(#1,#1){% u cos 2 mul 4 t sin 2 mul add mul u sin 2 mul 4 t sin 2 mul add mul t cos 4 mul }% \end{pspicture}% } \begin{document} \begin{center} \begin{animateinline}[poster=last, controls, palindrome]{12}% \multiframe{29}{iAngle=80+10, dLineWidth=2.9pt+-0.1pt}{% %iAngle = 80, 90, ..., 360 degrees %dLineWidth = 2.9pt, 2.8pt, ..., 0.1pt \torus{\iAngle}{\dLineWidth}% }% \end{animateinline}% \end{center} \end{document} \end{verbatim} \normalsize \begin{figure} \centering \newcommand{\torus}[2]{% \psset{Beta=20,Alpha=50,linewidth=0.1pt,origin={0,0,0},unit=0.35}% \begin{pspicture}(-12.3,-6.3)(12.3,7)% \parametricplotThreeD[xPlotpoints=100](80,#1)(0,360){% t cos 2 mul 4 u sin 2 mul add mul t sin 2 mul 4 u sin 2 mul add mul u cos 4 mul }% \parametricplotThreeD[yPlotpoints=75](0,360)(80,#1){% u cos 2 mul 4 t sin 2 mul add mul u sin 2 mul 4 t sin 2 mul add mul t cos 4 mul }% \parametricplotThreeD[yPlotpoints=1,linewidth=#2](0,360)(#1,#1){% u cos 2 mul 4 t sin 2 mul add mul u sin 2 mul 4 t sin 2 mul add mul t cos 4 mul }% \end{pspicture}% } \begin{animateinline}[poster=last,controls,palindrome]{12}% \multiframe{29}{iAngle=80+10, dLineWidth=2.9pt+-0.1pt}{% \torus{\iAngle}{\dLineWidth}% }% \end{animateinline}% \caption{}\label{fig:torus} \end{figure} Another inline example, Fig.~\ref{fig:lorenz}, is an animation of the Lorenz Attractor. The Lorenz Attractor is a three-dimensional parametric curve whose coordinates are obtained by integrating the set of three ordinary differential equations \begin{align*} \frac{\mathrm{d}x}{\mathrm{d}t}& = \alpha (y-x)\\ \frac{\mathrm{d}y}{\mathrm{d}t}& = x(\beta-z)\\ \frac{\mathrm{d}z}{\mathrm{d}t}& = x y - \gamma z \end{align*} with respect to the independent parameter $t$. The shape of the attractor strongly depends on the values chosen for the coefficients $\alpha$, $\beta$ and $\gamma$ as well as on the initial conditions, that is, the coordinates $x_0$, $y_0$ and $z_0$ of the starting point of the curve. Here we use the values $\alpha=10$, $\beta=28$, $\gamma=8/3$ and the starting point $\mathbf{x}_0=(3,15,1)$. The right hand sides of the equations above are implemented in the Postscript procedure `\verb+lorenz+' which is passed to the macro \verb+\odesolve+. The latter implements the Runge-Kutta method for integrating sets of ordinary differential equations. Its core is also written in Postscript. Hence, the computation of the curve is performed by the Postscript interpreter while converting the PS document into PDF. The solution vectors $\mathbf{x}(t)$ are written to a text file subsequently read by the macro \verb+\parametricplotThreeD+ from the PSTricks package `pst-3dplot' in order to plot the curve. Note that the creation of intermediate files requires the Postscript interpreter to be run in unsafe mode. In the case of Ghostscript, option `\verb+-dNOSAFER+' must be passed to \verb+ps2pdf+. Feel free to copy the code of \verb+\odesolve+ verbatim in order to solve your own initial value problems. A timeline file, written on-the-fly, is used to assemble the curve segments frame by frame to the growing attractor which, in turn, is put on top of the $x$-$y$-$z$ coordinate system. After the attractor has been completed, the transparency stack is cleared. Then, transparencies containing the complete curve and the coordinate system seen from different viewpoints are put in a row to produce the animated fly-around. \begin{figure}[t] \centering \makeatletter% \def\odesolve{\@ifstar{\@odesolve[append]}{\@odesolve}}% \newcommand{\@odesolve}[8][]{% \def\append{false}% \def\filemode{w}% \ifthenelse{\equal{#1}{append}}{% \def\append{true}% \def\filemode{a}}{}% \def\initcond{}% \ifthenelse{\equal{#7}{}}{}{% \def\initcond{/laststate [#7] def}% }% \pstVerb{% /statefile (#2) (\filemode) file def /outvect [#3] def /t #4 def /tEnd #5 def /dt tEnd t sub #6\space 1 sub div def % step size /dt2 dt 2 div def % half step size \initcond %set initial state vector /xlength laststate length def % number of equations /xlength1 xlength 1 add def % number of equations plus 1 /ODESET { cvx exec #8 xlength array astore } def %system of ODEs /addvect { % [1 2 3] [4 5 6] addvect => [5 7 9] cvx exec xlength1 -1 roll {xlength1 -1 roll add} forall xlength array astore } def /mulvect { % [1 2 3] 4 mulvect => [4 8 12] /mul cvx 2 array astore cvx forall xlength array astore } def /divvect { % [4 8 12] 2 divvect => [2 4 6] /div cvx 2 array astore cvx forall xlength array astore } def /RK { % performs one Runge-Kutta integration step % [ state vector x(t) ] RK => [ state vector x(t + dt) ] dup ODESET /k0 exch def t dt2 add /t exch def dup k0 dt2 mulvect addvect ODESET /k1 exch def dup k1 dt2 mulvect addvect ODESET /k2 exch def t dt2 add /t exch def dup k2 dt mulvect addvect ODESET /k3 exch def k0 k1 2 mulvect addvect k2 2 mulvect addvect k3 addvect 6 divvect dt mulvect addvect } def /output { %output routine outvect { dup (t) eq { pop t 20 string cvs statefile exch writestring }{ laststate exch get 20 string cvs statefile exch writestring } ifelse statefile (\space) writestring } forall statefile (\string\n) writestring } def \append\space not {output} if #6\space 1 sub {laststate RK /laststate exch def output} repeat statefile closefile }% }% \makeatother% % %Lorenz' set of differential equations \pstVerb{ /lorenz { %get elements of current state vector /varz exch def /vary exch def /varx exch def % 10 vary varx sub mul %dx/dt varx 28 varz sub mul %dy/dt varx vary mul 8 3 div varz mul sub %dz/dt } def }% % %write timeline file \newwrite\OutFile% \immediate\openout\OutFile=lorenz.tln% \multido{\iLorenz=0+1}{101}{% \immediate\write\OutFile{::\iLorenz x0}% }% \immediate\write\OutFile{::c,101}% \multido{\iLorenz=102+1}{89}{% \immediate\write\OutFile{::\iLorenz}% }% \immediate\closeout\OutFile% % \psset{unit=0.155,linewidth=0.5pt}% \begin{animateinline}[ timeline=lorenz.tln, controls,poster=last, begin={\begin{pspicture}(-39,-13)(39,60)}, end={\end{pspicture}} ]{10}% \psset{Alpha=120,Beta=20}% \pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]% \newframe% \pstVerb{/laststate [3 15 1] def}% initial condition \multiframe{100}{rtZero=0+0.25,rtOne=0.25+0.25}{% t0, t1 \odesolve{lorenz.dat}{0 1 2}{\rtZero}{\rtOne}{26}{}{lorenz}% \pstVerb{/infile (lorenz.dat) (r) file def}% \parametricplotThreeD[plotstyle=line,xPlotpoints=26](0,0){infile 80 string readline pop cvx exec}% }% \newframe% required between two \multiframe \odesolve{lorenz.dat}{0 1 2}{0}{25}{2501}{3 15 1}{lorenz}% \multiframe{90}{rAlpha=116+-4}{% \psset{Alpha=\rAlpha,Beta=20}% \pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]% \pstVerb{/infile (lorenz.dat) (r) file def}% \parametricplotThreeD[plotstyle=line,xPlotpoints=2501](0,0){infile 80 string readline pop cvx exec}% }% \end{animateinline} \caption{}\label{fig:lorenz} \end{figure} \small \begin{verbatim} \documentclass{article} \usepackage{multido} \usepackage{pst-3dplot} \usepackage{pstricks-add} \usepackage{animate} \makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % odesolve % % LaTeX command for integrating systems of first order ODEs using the Runge- % Kutta method; values of the integration parameter `t' as well as the solution % (= state) vectors are written to a text file % % Usage: % % \odesolve{filename}{output vector}{ta}{tb}{nodes}{initial cond.}{function} % \odesolve*{filename}{output vector}{ta}{tb}{nodes}{initial cond.}{function} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % #1: output filename for solution data % #2: output vector format, e. g. `(t) 0 1'; specifies which data to be written % to #1; (t) (parentheses required) writes integration parameter to the data % file, 0, 1, 2, etc. specify the elements of the state vector to be written % #3: start value of integration parameter (ta) % #4: end value of integration parameter (tb) % #5: number of output points (nodes), including ta and tb % #6: initial condition vector; if empty, use state vector from last \odesolve % invocation % #7: right hand side of ODE system; the function provided should pop the % elements of the current state vector from the operand stack and push the % first derivatives (right hand side of ODE system) back to it, the % integration parameter can be accessed using `t' % % \odesolve* --> computed data are appended to existing data file (arg. #1) % rather than overwriting it %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \def\odesolve{\@ifstar{\@odesolve[append]}{\@odesolve}} \newcommand{\@odesolve}[8][]{% \def\append{false}% \def\filemode{w}% \ifthenelse{\equal{#1}{append}}{% \def\append{true}% \def\filemode{a}}{}% \def\initcond{}% \ifthenelse{\equal{#7}{}}{}{% \def\initcond{/laststate [#7] def}% }% \pstVerb{% /statefile (#2) (\filemode) file def /outvect [#3] def /t #4 def /tEnd #5 def /dt tEnd t sub #6\space 1 sub div def % step size /dt2 dt 2 div def % half step size \initcond %set initial state vector /xlength laststate length def % number of equations /xlength1 xlength 1 add def % number of equations plus 1 /ODESET { cvx exec #8 xlength array astore } def %system of ODEs /addvect { % [1 2 3] [4 5 6] addvect => [5 7 9] cvx exec xlength1 -1 roll {xlength1 -1 roll add} forall xlength array astore } def /mulvect { % [1 2 3] 4 mulvect => [4 8 12] /mul cvx 2 array astore cvx forall xlength array astore } def /divvect { % [4 8 12] 2 divvect => [2 4 6] /div cvx 2 array astore cvx forall xlength array astore } def /RK { % performs one Runge-Kutta integration step % [ state vector x(t) ] RK => [ state vector x(t + dt) ] dup ODESET /k0 exch def t dt2 add /t exch def dup k0 dt2 mulvect addvect ODESET /k1 exch def dup k1 dt2 mulvect addvect ODESET /k2 exch def t dt2 add /t exch def dup k2 dt mulvect addvect ODESET /k3 exch def k0 k1 2 mulvect addvect k2 2 mulvect addvect k3 addvect 6 divvect dt mulvect addvect } def /output { %output routine outvect { dup (t) eq { pop t 20 string cvs statefile exch writestring }{ laststate exch get 20 string cvs statefile exch writestring } ifelse statefile (\space) writestring } forall statefile (\string\n) writestring } def \append\space not {output} if #6\space 1 sub {laststate RK /laststate exch def output} repeat statefile closefile }% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \makeatother \begin{document} % % Lorenz' set of differential equations \pstVerb{ /lorenz { %get elements of current state vector /varz exch def /vary exch def /varx exch def % 10 vary varx sub mul %dx/dt varx 28 varz sub mul %dy/dt varx vary mul 8 3 div varz mul sub %dz/dt } def }% % %write timeline file \newwrite\OutFile% \immediate\openout\OutFile=lorenz.tln% \multido{\iLorenz=0+1}{101}{% \immediate\write\OutFile{::\iLorenz x0}% }% \immediate\write\OutFile{::c,101}% \multido{\iLorenz=102+1}{89}{% \immediate\write\OutFile{::\iLorenz}% }% \immediate\closeout\OutFile% % \begin{center} \psset{unit=0.155,linewidth=0.5pt}% \begin{animateinline}[ timeline=lorenz.tln, controls,poster=last, begin={\begin{pspicture}(-39,-13)(39,60)}, end={\end{pspicture}} ]{10}% \psset{Alpha=120,Beta=20}% \pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]% \newframe% \pstVerb{/laststate [3 15 1] def}% \multiframe{100}{rtZero=0+0.25,rtOne=0.25+0.25}{% t0, t1 \odesolve{lorenz.dat}{0 1 2}{\rtZero}{\rtOne}{26}{}{lorenz}% \pstVerb{/infile (lorenz.dat) (r) file def}% \parametricplotThreeD[% plotstyle=line,xPlotpoints=26](0,0){infile 80 string readline pop cvx exec}% }% \newframe% \odesolve{lorenz.dat}{0 1 2}{0}{25}{2501}{3 15 1}{lorenz}% \multiframe{90}{rAlpha=116+-4}{% \psset{Alpha=\rAlpha,Beta=20}% \pstThreeDCoor[xMax=33,yMax=33,zMax=55,linecolor=black]% \pstVerb{/infile (lorenz.dat) (r) file def}% \parametricplotThreeD[% plotstyle=line,xPlotpoints=2501](0,0){infile 80 string readline pop cvx exec}% }% \end{animateinline} \end{center} \end{document} \end{verbatim} \normalsize \section{Bugs}\label{sect:bugs} \begin{itemize} \item The maximum frame rate that can actually be achieved largely depends on the complexity of the graphics and on the available hardware. Starting with version 8, Adobe Reader appears to be somewhat slower. However, you might want to experiment with the graphical hardware acceleration feature that was introduced in Reader 8. Go to menu `Edit' $\rightarrow$ `Preferences' $\rightarrow$ `Page Display' $\rightarrow$ `Rendering' to see whether hardware acceleration is available. A 2D GPU acceleration check box will be visible if a supported video card has been detected. \item Animations may run very slowly if viewed in the Adobe Reader web-browser plugin. Instead, open the PDF locally in the Reader application for best results. \item The Adobe Reader setting `Use page cache' (menu `Edit' $\rightarrow$ `Preferences' $\rightarrow$ `Startup') should be \emph{dis}abled for version 7, while remaining \emph{en}abled beginning with version 8 (menu `Edit' $\rightarrow$ `Preferences' $\rightarrow$ `Page Display' $\rightarrow$ `Rendering'). \item The \verb+dvips+ option `\verb+-Ppdf+' should be avoided entirely or followed by something like `\verb+-D 1200+' on the command line in order to set a sensible DVI resolution. This does \emph{not} degrade the output quality! The configuration file `config.pdf' loaded by option `\verb+-Ppdf+' specifies an excessively high DVI resolution that will be passed on to the final PDF. Eventually, Adobe Reader gets confused and will not display the frames within the animation widget. \item Animations do not work if the PDF has been produced with Ghostscript versions older than 8.31. This applies to all versions of ESP Ghostscript that comes with many Linux distributions. \item If the \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller route is being taken, make sure that the original graphics size (i.\,e. not scaled by any of the `{\tt scale}', `{\tt width}', `{\tt height}' or `{\tt depth}' options) does not exceed the page size of the final document. During PS to PDF conversion every graphic of the animation is temporarily moved to the upper left page corner. Those parts of the graphics that do not fit onto the document page will be clipped in the resulting PDF. Fortunately, graphics files for building animations may be resized easily to fit into a given bounding box by means of the `{\tt epsffit}' command line tool: \quad{\tt epsffit -c infile.eps outfile.eps} {\tt } are the bounding box coordinates of the target document. They can be determined using Ghostscript. For a document named `document.ps' the command line is \quad{\tt gs -dNOPAUSE -q -dBATCH -sDEVICE=bbox document.ps} Note that the name of the Ghostscript executable may vary between operating systems (e.\,g. `{\tt gswin32c.exe}' on Win/DOS). \item Animations with complex graphics and/or many frames may cause \LaTeX{} to fail with a `\verb+TeX capacity exceeded+' error. The following steps should fix most of the memory related problems. MiK\TeX: \begin{enumerate} \item Open a DOS command prompt window (execute `cmd.exe' via `Start' $\rightarrow$ `Run'). \item\label{item:firststep} At the DOS prompt, enter\\ {\tt initexmf -{}-edit-config-file=latex} \item Type\\ {\tt main\_memory=10000000}\\ into the editor window that opens, save the file and quit the editor. \item\label{item:laststep} To rebuild the format, enter\\ {\tt initexmf -{}-dump=latex} \item Repeat steps \ref{item:firststep}--\ref{item:laststep} with config files `{\tt pdflatex}' and `{\tt xelatex}' \end{enumerate} \TeX\ Live: \begin{enumerate} \item Find the configuration file `texmf.cnf' by means of\\ {\tt kpsewhich texmf.cnf}\\ at the shell prompt in a terminal. \item As Root, open the file in your favourite text editor, scroll to the `{\tt main\_memory}' entry and change it to the value given above; save and quit. \item Rebuild the formats by\\ {\tt fmtutil-sys -{}-byfmt latex}\\ {\tt fmtutil-sys -{}-byfmt pdflatex}\\ {\tt fmtutil-sys -{}-byfmt xelatex} \end{enumerate} \item If you are postprocessing the created PDF file with tools such as pdftk to split the document into different parts, then the animation may fail. To work around this, do not use the `{\tt useocg}' (OCGs, PDF layers) option. In addition, the control buttons also use OCGs to change their appearance to provide feedback about the running state, independent of the `{\tt useocg}' option. The workaround for this is not to use the `{\tt controls}' option. \item Animations should not be placed on \emph{multilayered} slides created with presentation making classes such as Beamer or Powerdot. Although possible (on the last overlay of a slide, at best), the result might be disappointing. Put animations on flat slides only. (Of course, slides without animations may still have overlays.) \end{itemize} \section{Acknowledgements} I would like to thank Fran\c{c}ois Lafont who discovered quite a few bugs and made many suggestions that helped to improve the functionality of the package. Many thanks to Jin-Hwan Cho, the developer of `\verb+dvipdfmx+', for contributing the `\verb+dvipdfmx+' specific code, and to Walter Scott for proof-reading the documentation. \begin{thebibliography}{8} \bibitem{chupin} Chupin, M.: \href{http://melusine.eu.org/syracuse/metapost/animations/chupin/?idsec=scara}{\tt http://melusine.eu.org/syracuse/metapost/animations/} \href{http://melusine.eu.org/syracuse/metapost/animations/chupin/?idsec=scara}{\tt chupin/?idsec=scara} \bibitem{gilg05} Gilg, J.: PDF-Animationen. In: \emph{Die \TeX nische Kom\"odie}, Issue 4, 2005, pp.~30--37 \bibitem{hol} Hole\v{c}ek, J.: \emph{Animations in a pdf\TeX-generated PDF}. URL: \href{http://www.fi.muni.cz/~xholecek/tex/pdfanim.xhtml}{\tt http://www.} \href{http://www.fi.muni.cz/~xholecek/tex/pdfanim.xhtml}{\tt fi.muni.cz/\textasciitilde xholecek/tex/pdfanim.xhtml} \bibitem{movie15} \emph{The Movie15 Package}. URL: \href{http://www.ctan.org/tex-archive/macros/latex/contrib/movie15/}{\tt http://www.ctan.org/tex-archive/macros/} \href{http://www.ctan.org/tex-archive/macros/latex/contrib/movie15/}{\tt latex/contrib/movie15} \end{thebibliography} \end{document}