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.

Is there a way in beamer to have some kind of dynamic picture that will change if the mouse is moved over it or if the button is clicked?

share|improve this question
2  
Related : tex.stackexchange.com/questions/65096/… –  percusse Nov 7 '12 at 21:04
    
Very interesting link, but this kind of solution needs javascript programming :-( And should only solve my second case (button clicked)... –  Lionel MANSUY Nov 7 '12 at 21:20
2  
Unfortunately, Javascript is seemingly the only way to achieve satisfactory interaction. (even worse only with AcroRead) –  percusse Nov 7 '12 at 21:44
    
you can simply use \inlcudegraphics<1>{...} what should be on overlay <1> and so on. –  Herbert Nov 8 '12 at 8:10
1  
animate package? –  AlexG Nov 8 '12 at 9:03
show 2 more comments

1 Answer

up vote 10 down vote accepted

Here is a straightforward solution using a Widget Annotation (Push Button) according to the PDF specification. It displays different pictures depending on the current mouse position and its button state (out, roll-over, button-down).

\documentclass{article}
\usepackage{mwe}

\newsavebox\imga
\newsavebox\imgb
\newsavebox\imgc
\sbox\imga{\includegraphics{example-image-a}}
\sbox\imgb{\includegraphics{example-image-b}}
\sbox\imgc{\includegraphics{example-image-c}}
\edef\imgwd{\the\wd\imga}
\edef\imght{\the\ht\imga}

\immediate\pdfxform\imga
\edef\normalappearance{\the\pdflastxform\space 0 R}
\immediate\pdfxform\imgb
\edef\overappearance{\the\pdflastxform\space 0 R}
\immediate\pdfxform\imgc
\edef\downappearance{\the\pdflastxform\space 0 R}

\begin{document}

\hbox to \imgwd{\vbox to \imght{\vss%
  \pdfannot width \imgwd height \imght depth 0pt {
    /Subtype/Widget
    /F 4
    /FT/Btn/Ff 65536
    /T (my dynamic image) % Widget name; must be unique
    /H/P
    /AP <<
      /N \normalappearance
      /R \overappearance
      /D \downappearance
    >>
  }%
}\hss}

\end{document}

In case of multiple Widget annotations, the Widget's names, as specified by the /T (...) entry, must be uniqe.

enter image description here

share|improve this answer
    
How did you created the GIF above? –  I am who I say I am Nov 9 '12 at 8:04
2  
Recording with ffmpeg, Gif optimization with gifsicle. –  AlexG Nov 9 '12 at 8:19
2  
For those who are interested, the method for producing the window recording is given here. –  AlexG Nov 9 '12 at 9:34
    
@AlexG I'm in trouble with your code: it works nicely only for the first occurrence of a picture, not for the following ones... I've tried to replace the \Widget subtype by a \Link, but it does not work –  Lionel MANSUY Jan 8 '13 at 16:53
    
@LionelMANSUY : The PDF created from the code example works properly only in Adobe Reader (as demonstrated by the animated screen recording). –  AlexG Jan 9 '13 at 7:19
show 3 more comments

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.