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.

I have made a beamer presentation and have a series of the slides with pstricks images on them. Each of these images either builds upon the previous, or moves an element of the previous. Is there a way I can set up the presentation so I only have to click once to run the whole series of slides?

Note: I have attempted to use the \animate command as described in the Beamer manual, but have had no success.

share|improve this question
    
Welcome to TeX.SX! –  Heiko Oberdiek May 24 at 15:49
    
Her are a lot of examples: tug.org/PSTricks/main.cgi?file=Animation/basics –  Herbert Jul 2 at 8:12
add comment

1 Answer 1

A best practice approach (IMHO):

Step 1

Put each diagram in a separate compilable input file with standalone document class as follows.

% frames.tex
\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\foreach \r in {0.1,0.2,...,1.0}{%
\begin{pspicture}(4,4)
    \pscircle(2,2){\r}
\end{pspicture}}
\end{document}

Because the diagram is already in a single, separate, standalone input file, it will be faster if you compile it with latex followed by dvips followed by ps2pdf to obtain a PDF output.

Note: Other alternative approaches to compile the diagram are either

  • with xelatex (but extremely slow), or
  • with pdflatex -shell-escape with auto-pst-pdf package loaded.

In this example I will use the first approach which is using latex->dvips->ps2pdf. Do the following in your terminal.

latex frames.tex
dvips frames.dvi
ps2pdf -dAutoRotatePages=/None frames.ps

Advantages of separating each diagram into a standalone input file: - we can reuse the code for many projects. - we can locate the errors if any easily. - we can reduce the amount of time needed to compile the code during development phase. Consider the opposite if you put all code in a single main input file; it will waste much of your time if you recompile the main input file again and again during development phase whenever you just edit some code to see the effect.

Step 2

Import the frames you already prepared as explained in the first step from within your beamr document as follows. Compile it with pdflatex (preferred as you can make use of microtype effectively).

% main.tex 
\documentclass{beamer}
\usepackage{animate}

\begin{document}
\begin{frame}{Animation}
    \begin{center}
        \animategraphics[autoplay,scale=1,loop,controls]{3}{frames}{}{}
    \end{center}
\end{frame}
\end{document}

From your terminal, invoke the following.

pdflatex main.tex

And you will get the animation in question. Done

Simulation

The following simulates everything explained above as a single step.

% compile it with 
% pdflatex -shell-escape main.tex

% the filename of this code is main.tex 
\documentclass{beamer}

\usepackage{filecontents}

\begin{filecontents*}{frames.tex}
\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\foreach \r in {0.1,0.2,...,1.0}{%
\begin{pspicture}(4,4)
    \pscircle(2,2){\r}
\end{pspicture}}
\end{document}
\end{filecontents*}

\usepackage{pgffor}
\foreach \compiler/\ext in {latex/tex,dvips/dvi,{ps2pdf -dAutoRotatePages=/None}/ps}{\immediate\write18{\compiler\space frames.\ext}}

\usepackage{animate}

\begin{document}
\begin{frame}{Animation}
    \begin{center}
        \animategraphics[autoplay,scale=1,loop,controls]{3}{frames}{}{}
    \end{center}
\end{frame}
\end{document}

Compile it with

pdflatex -shell-escape main.tex
share|improve this answer
    
animate also provides draft and final options that can be used with the animateinline environment to reduce compilation time in the all-in-one-file approach. –  AlexG Jul 2 at 6:52
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.