Document ClassesAnimate Graphics in "beamer" without Mouse Click

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
EdGatzke
Posts: 13
Joined: Thu Dec 02, 2010 5:48 pm

Animate Graphics in "beamer" without Mouse Click

Post by EdGatzke »

The default animategraphics operation requires the user to get the mouse over the animation and click.

I have had some success getting \animategraphics to "start" a movie when doing a presentation with only a PgDn or space click, allowing for a single button to advance through slides

Code: Select all

   
\visible <1-1>{\includegraphics[height=2.8in]{./movie/movie-101}} \\
\visible <2->{\vspace{-2.81 in}\hspace{.05 in}
     \animategraphics[height=2.8in,autoplay,palindrome,loop]{8}
                      {./movie/bbmovie-1}{01}{25}}
This requires your movie eps files to be in the ./movie directory and named movie-101 to movie-125.

The first image shows when you come to the slide, then the movie starts when you hit advance.

I tried using the \only flag for the visible objects, but I could not get it to work so I had to back up the second object, the animategraphics movie itself.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

EdGatzke
Posts: 13
Joined: Thu Dec 02, 2010 5:48 pm

Animate Graphics in "beamer" without Mouse Click

Post by EdGatzke »

And here is some matlab code that can be used to make animations.

Code: Select all

% This file should create the files required to make a eps movie in lyx
% using the animategraphics package.  The call itself looks something like:
% \animategraphics[height=2.8in,autoplay,palindrome,loop]{8}
%               {./movie1/fitmovie-1}{001}{025}

set(0,'defaultaxesfontsize',14);
set(0,'defaulttextfontsize',14);
linewidth=3;

directory='./movie-ex02/';
filenamestub='movie-';

makemovieflag=0;  % Print files for movie?  Set to 0 to test

a=[ [0:.1:1] [1.2:.2:3] ];

subplot(1,1,1)
for i=1:length(a)
    
    subplot(1,1,1)
    x=[0:.01:2]';
    y=x.^a(i);
    p=plot(x,y);
    set(p,'LineWidth',linewidth)
    axis([-0 2 0 8])
    title([ 'Example Plot, y=x^\alpha, \alpha=' num2str(a(i),'%3.1f') ])
    ylabel('y=f(x)')
    xlabel('x')
    
    % Must append 0s in front of small numbers, so start at 1000 and go up
    filename=[ directory filenamestub  num2str(i+1000,'%3.0f') '.eps' ];
    str1=['print -depsc ' filename ];
    
    % Must add bounding box to eps figures from matlab
    str2=['!epsffit 0 0 50 50 ' directory  filenamestub  num2str(i+1000,'%3.0f') ...
        '.eps ' directory 'fit' filenamestub  num2str(i+1000,'%3.0f') '.eps'  ];
    
    pause(.1)
    if makemovieflag  % print files with 001 to n on the file name
        eval(str1); 
        eval(str2);
    end
    
    
end

% Make a slide for the handouts with some of the movie included

y1=x.^a(3);
y2=x.^a(11);
y3=x.^a(i);

p=plot(x,y1,'b',x,y2,'r--',x,y3,'g-.');
set(p,'LineWidth',linewidth)


title([ 'Example Plot, y=x^\alpha, \alpha=' num2str(a(2),'%3.1f') ', ' ...
    num2str(a(11),'%3.1f') ', ' num2str(a(i),'%3.1f') ])
ylabel('y=f(x)')
xlabel('x')


legend(['\alpha=' num2str(a(3),'%3.1f')],['\alpha=' num2str(a(11),'%3.1f')], ...
    ['\alpha=' num2str(a(i),'%3.1f')],'Location','NorthWest')

str=['print -depsc ' directory filenamestub  'handout.eps' ];

if makemovieflag
  eval(str)
end

[*]
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Animate Graphics in "beamer" without Mouse Click

Post by localghost »

Read Section 14 (Animations, Sounds, and Slide Transitions; p. 135ff) of the beamer user guide.


Thorsten
EdGatzke
Posts: 13
Joined: Thu Dec 02, 2010 5:48 pm

Animate Graphics in "beamer" without Mouse Click

Post by EdGatzke »

Read Section 14 (Animations, Sounds, and Slide Transitions; p. 135ff) of the beamer user guide.
I did. That section talks about the \movie command. This apparently does not embed the movie into the file, so you have to copy movies and pdf files together.

I also doubt that it works with SVG / EPS files like animate graphics, relying rather on the raster movie format.

This section also points out that the movie does not play until you click on it. This is unacceptable behaviour for a presentation where you basically move forward and back with a clicker or keyboard. Having to navigate a mouse is a PITA.

The solution I provided above avoids mouse use, use vector graphics, and embeds all the information in a single pdf file.
Post Reply