lundi 9 juillet 2007

animated pdf figure : beamer + xfig + mpost/mptopdf

Minitutorial
This is a summary of usefull information I have found on the web and some tricks I've found myself.
You can have ave a look at http://www.xfig.org/userman/latex_and_xfig.html
(Xfig and pdf / section 4)

If your animation will just consists of successives layers of a figure you can
defines these layers with xfig provided that you will export the figure in the multimetapost format (.mmp files).
It is not so easy, to define the differents layers. With xfig you have to set the depths of your elements. Elements of consecutive depths will be parts of the same layer. Layers of deapest elements will be showned first.
Then when you have generated the .mmp file you may need to edit it.
For example I have had some latex code just for the accents.
% +MP-ADDITIONAL-HEADER
verbatimtex
%&latex
\documentclass{article}
\usepackage[french]{babel}
\usepackage[latin9]{inputenc}
\usepackage[cyr]{aeguill}
\usepackage[T1]{fontenc}
\begin{document}
etex
% -MP-ADDITIONAL-HEADER
then use mpost + mptopdf or just mptopdf that whill call mpost (I had problem using just mptopdf)
mpost -tex=latex myfile.mmp
mptopdf myfile.*
or just
mptopdf --latex myfile.mmp

In beamer you have to deactivate the covered feature if you normally use it.
For example:
\documentclass{beamer}
%\usepackage ...
\usepackage{xmpmulti}
% \DeclareGraphicsRule{*}{mps}{*}{}
\begin{document}
\setbeamercovered{transparent}
% some frames with transparent

\setbeamercovered{invisible} % deactivate transparent covered mode
\begin{frame}
\frametitle{my frame with the pdf animated figure}
\multiinclude[graphics={width=\textwidth},format=pdf]{figures/myfile}
\end{frame}
\setbeamercovered{transparent} % back to transparent covered mode
With xfig, I will suggest you first define the number of layers you want for your figure, let's say ten. Then set to 91,92,..,99 the depth of the elements that you want to be in the first layer; 81,82,..,89 the depth of the elements that you want to be in the second layer; and so on to 1,2,..9 the depth of the elements you want to be in the last layer.
In this way the number of tens indicate the number of the layer of the element, since you will probably not need more than 9 deapths for any layer (a diagram basically consists of a background shape, text, arrows, and eventually a foreground shape).

That's it.
It's just like a memo for me, but in the same time hope it could help ...
Don't hesitate to give feedback.

Today I prefer to use tikz with overlays and pause to do such animations in pdf documents generated by latex. It's more geeky, more hacker's tool !
I'll may post some example of what I have done with it later here.


update 15/08/2007
Tomorrow (another day :), I will test the animate package of Alexander Grahn
http://tug.ctan.org/macros/latex/contrib/animate/doc/animate.pdf
that auto-animate sets of graphics files or inline graphics.
Even il you don't need automatic animation, one feature of the package is that the animation running remains on the same pdf page whereas without this package animation like explain in this article creates various pages.
One drawback is that animation created with this package only can be seen with Adobe Reader or Acrobat.


Nicogeek

1 commentaire:

Unknown a dit…

huumm hummm...ça me fait penser à manger une crêpe au Nutella..