Graphics, Figures & TablesPSTricks | Multiple animations in the same document

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

PSTricks | Multiple animations in the same document

Post by svend_tveskaeg »

Hi all.

Consider the following example:

Code: Select all

% Dokumentet skal kompileres via
%
% latex fordelinger.tex
% dvips -Ppdf -D1200 fordelinger.dvi
% ps2pdf fordelinger.ps
%
% og åbnes med Adobe Reader.

\documentclass[
  a4paper,
  10pt,
  danish
]{article}

% Pakker.
\usepackage{babel}
\usepackage[
  utf8
]{inputenc}
\usepackage[
  hmargin=3cm,
  vmargin=2.4cm
]{geometry}
\usepackage[
  figureposition=bottom
]{caption}
\usepackage{pst-func}
\usepackage{animate}
\usepackage[
  locale=DE
]{siunitx}
\usepackage{microtype}
\usepackage{hyperref}

% Makroer.
\DisableLigatures[f]{encoding=T1}

\setcounter{secnumdepth}{0}

\makeatletter
  \providecommand*{\setfloatlocations}[2]{\@namedef{fps@#1}{#2}}
\makeatother
\setfloatlocations{figure}{htbp}

\addto\extrasdanish{%
  \def\figureautorefname{\textsc{Figur}}
}

\DeclareCaptionLabelSeparator{tilpasning}{:\quad}
\captionsetup{
  font=small,
  labelfont=sc,
  labelsep=tilpasning,
  width=0.6\textwidth
}

\sisetup{round-mode=places,round-precision=1}

% Normalfordeling.
\newcommand*{\normalS}[1]{
\psset{xunit=1,yunit=4cm}
 \begin{pspicture}(-5.5,-0.25)(6,1.35)
  \psaxes[Dy=0.2,comma]{->}(0,0)(-5.3,0)(5.5,1.1)[$x$,0][$y$,90]
  \pscustom[fillstyle=solid,fillcolor=blue!40,opacity=0.4,linecolor=red,linestyle=none]{%
    \psline(0,0)(-5,0)
    \psGauss[sigma=#1]{-5}{5}
    \psline(5,0)(0,0)
  }
  \psGauss[sigma=#1,linecolor=red,linewidth=1pt]{-5}{5}
  \rput(3,0.6){$\sigma = \num{#1}$}
 \end{pspicture}
}
\newcommand*{\normalK}[1]{
\psset{xunit=1,yunit=4cm}
 \begin{pspicture}(-5.5,-0.25)(6,1.35)
  \psaxes[Dy=0.2,comma]{->}(0,0)(-5.3,0)(5.5,1.1)[$x$,0][$y$,90]
%  \pscustom[fillstyle=solid,fillcolor=blue!40,opacity=0.4,linecolor=red,linestyle=none]{%
%    \psline(0,0)(-5,0)
%    \psGaussI[sigma=#1,Simpson=15]{-5}{5}
%    \psline(5,0)(0,0)
%  }
  \psGaussI[sigma=#1,Simpson=15,linecolor=red,linewidth=1pt]{-5}{5}
  \rput(-3,0.6){$\sigma = \num{#1}$}
 \end{pspicture}
}

% Den studerenes t-fordeling.
\newcommand*{\studenttS}[1]{
\psset{xunit=1cm,yunit=10cm}
 \begin{pspicture}(-5.5,-0.1)(6,0.5)
  \psaxes[Dy=0.1,comma]{->}(0,0)(-5.3,0)(5.5,0.45)[$x$,0][$y$,90]
  \pscustom[fillstyle=solid,fillcolor=blue!40,opacity=0.4,linecolor=red,linestyle=none]{%
    \psline(0,0)(-5,0)
    \psTDist[nue=#1]{-5}{5}
    \psline(5,0)(0,0)
  }
  \psTDist[nue=#1,linecolor=red,linewidth=1pt]{-5}{5}
  \rput(3,0.3){$\nu = \num{#1}$}
 \end{pspicture}
}

\begin{document}

\begin{center}
  \Huge{\textbf{Sandsynlighedsfordelinger}}
\end{center}
\vspace{10ex}

\noindent \textbf{Vigtigt:} \enskip Dokumentet skal åbnes med \textsf{Adobe Reader}, da dette program (så vidt jeg ved) er den eneste PDF-fremviser, der kan håndtere PostScript-animationer korrekt.

\section{Normalfordeling}
\begin{figure}
\centering
 \begin{animateinline}[poster=first,controls,palindrome]{10}
  \multiframe{52}{rA=0.4+0.1}{\normalS{\rA}}
 \end{animateinline}
\caption{Sandsynlighedstæthed for $\mu = 0$.}
\end{figure}

\begin{figure}
\centering
 \begin{animateinline}[poster=first,controls,palindrome]{10}
  \multiframe{51}{rA=0.5+0.1}{\normalK{\rA}}
 \end{animateinline}
\caption{Kumuleret sandsynlighed for $\mu = 0$.}
\end{figure}
\newpage

\section{Den studerenes \texorpdfstring{$t$}{t}-fordeling}
\begin{figure}
\centering
 \begin{animateinline}[poster=first,controls,palindrome]{10}
  \multiframe{51}{rA=0.0001+0.1}{\studenttS{\rA}}
 \end{animateinline}
\caption{Sandsynlighedsfordeling.}
\end{figure}

\end{document}
If I add a number of frames, say 10, to each animation, TeX's capacity is exceeded;

Code: Select all

! TeX capacity exceeded, sorry [main memory size=3000000].
How do I do this if I have an arbitrary number (read: 20 or something) of animations in the same document?

Thank you in advance!

P.S. I have had a look at this answer so it seems that pdfpages is our of the question. I cannot follow the other idea in the second section of the answer.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

PSTricks | Multiple animations in the same document

Post by CrazyHorse »

svend_tveskaeg wrote: P.S. I have had a look at this answer so it seems that pdfpages is our of the question. I cannot follow the other idea in the second section of the answer.
with

Code: Select all

main_memory = 5000000
in the local config file which on Linux can be found with

Code: Select all

cat `kpsewhich texmf.cnf`
no problem. However, I would use both functions in one animation.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

PSTricks | Multiple animations in the same document

Post by svend_tveskaeg »

Perfect!

Thank you Herbert!

This is (one of the reasons) why Linux is superior; finding things on the computer is much easier.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply