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 made a simple animated graphic in a tikz/beamer environment. the problem is that when i click on one of the slides, all animations begin to move. what i am looking for is that on slide 2 S begins to shake a little. on slide 3, i want PRD and the expanding arrow connecting R to PRD to appear at the same time. same for R and PSD on slide 4. and so on...

 \documentclass[compress]{beamer}
 \usepackage{pgfpages}
 \usepackage[ngerman]{babel}
 \usepackage{animate}
 \usepackage{tikz}
 \usetikzlibrary{arrows,decorations.pathmorphing,through,backgrounds,positioning,fit,petri}
 \usetikzlibrary{shapes,shadows}
 \usetikzlibrary{shapes.multipart}
 \usetikzlibrary{calc}
 \usetikzlibrary{decorations.pathreplacing}
 \usepackage{animate}

 \begin{document}

 \begin{frame}
 \begin{animateinline}[]{10}
 \multiframe{10}{r = 1 + 1, rP = 0.1 + .1}{
 \begin{tikzpicture}
 [demand/.style={rounded rectangle, minimum size=8mm, minimum width=20mm, text width=1.2cm, text height=-.45cm, fill=blue!20!white, font=\tiny, text centered},
 rect/.style={rectangle, font=\tiny},
 cris/.style={ellipse, minimum size=8mm, minimum width=15mm, text width=1.3cm, text height=0cm, fill=red!10!white, font=\tiny, text centered},
 post/.style={->,>=stealth', very thin, draw=black!50}]
 \onslide<1->\node (b) at (0,0) [rect, fill=blue!30!white]  {R};
 \onslide<2->\node (r) at  (2,0) [cris, decorate, decoration={random steps,segment length=3pt,amplitude=\r}] {S};
 \onslide<3->\node (d) at (3,-2) [demand] {PRD};
 \onslide<3->\path (b.east) -- (d.west) node[pos=\rP] (p){};
 \draw[post] (b.east) -- (p.west);
 \onslide<4->\node (c) at (3,2) [demand] {PSD};
 \onslide<4->\path (b.east) -- (c.west) node[pos=\rP] (q){};
 \draw[post] (b.east) -- (q.west);
 \end{tikzpicture}
 }
 \end{animateinline}
 \end{frame}
 \end{document}

Hope someone can help!


Update:

thanks andrew for your quick reply! the problem is that when you click on one of the slides, all animations begin to move. what i am looking for is that on slide 2 S begins to shake a little. on slide 3, i want PRD and the expanding arrow connecting R to PRD to appear at the same time. same for R and PSD on slide 4.

 \documentclass[compress]{beamer}
 \usepackage{pgfpages}
 \usepackage[ngerman]{babel}
 \usepackage{animate}
 \usepackage{tikz}
 \usetikzlibrary{arrows,decorations.pathmorphing,through,backgrounds,positioning,fit,petri}
 \usetikzlibrary{shapes,shadows}
 \usetikzlibrary{shapes.multipart}
 \usetikzlibrary{calc}
 \usetikzlibrary{decorations.pathreplacing}
 \usepackage{animate}

 \begin{document}

 \begin{frame}
 \begin{animateinline}[]{10}
 \multiframe{10}{r = 1 + 1, rP = 0.1 + .1}{
 \begin{tikzpicture}
 [demand/.style={rounded rectangle, minimum size=8mm, minimum width=20mm, text width=1.2cm, text height=-.45cm, fill=blue!20!white, font=\tiny, text centered},
 rect/.style={rectangle, font=\tiny},
 cris/.style={ellipse, minimum size=8mm, minimum width=15mm, text width=1.3cm, text height=0cm, fill=red!10!white, font=\tiny, text centered},
 post/.style={->,>=stealth', very thin, draw=black!50}]
 \onslide<1->\node (b) at (0,0) [rect, fill=blue!30!white]  {R};
 \onslide<2->\node (r) at  (2,0) [cris, decorate, decoration={random steps,segment length=3pt,amplitude=\r}] {S};
 \onslide<3->\node (d) at (3,-2) [demand] {PRD};
 \onslide<3->\path (b.east) -- (d.west) node[pos=\rP] (p){};
 \draw[post] (b.east) -- (p.west);
 \onslide<4->\node (c) at (3,2) [demand] {PSD};
 \onslide<4->\path (b.east) -- (c.west) node[pos=\rP] (q){};
 \draw[post] (b.east) -- (q.west);
 \end{tikzpicture}
 }
 \end{animateinline}
 \end{frame}

\end{document}
share|improve this question
    
Could you edit this post and use the <code> tag ? It's hard to read... –  EEva May 10 '11 at 11:53
2  
@helga, @EEva: I took the liberty of editing. @helga: use four spaces to indent blocks of code and backticks to format inline code. Also, you might not get a lot of action on this question because your example is not minimal and a little intimidating. –  Matthew Leingang May 10 '11 at 11:57
2  
I just tried copying it and compiling it and I have no idea what I'm supposed to be seeing! I got one frame with a (complicated!) diagram and then 9 frames with just the words 'lo.png' on them (presumably from the headline template). When I commented out the headline template, I only got one frame. I strongly recommend that you trim out all the unnecessary stuff and look for a minimal case of what you are trying to do. –  Loop Space May 10 '11 at 12:08
    
sorry for the inconvenience. here's a light version of my code. the node "r" is animated. i want the arrows from b to d and b to c to expand one after the other as soon as slide 3 and 4 are opened. helga –  helga May 10 '11 at 12:58
    
I'm afraid you've reached the limit of my ability to answer. As I don't have access to an animation-able PDF viewer, I can't test the interaction between beamers overlays and the animate package's specifications. Figuring out how to make the arrows extend was the limit of my ability. If my answer is close, I recommend that you take the code from that answer, put it in your question, and explain what doesn't work with it. I think that if you use the smaller example then you are much more likely to get an answer. –  Loop Space May 10 '11 at 20:28

2 Answers 2

up vote 5 down vote accepted

I think I got Helga's idea. She probably wants an animation which is split into several stages with pauses in between and the user has to do some action to continue. For this, the animate package provides the \newframe* command. It introduces the desired breaks. After clicking onto the animation it continues playing. See the code listed below. Now, the entire animation resides on one Beamer slide (\onslide's removed). The code could still be optimized in terms of PDF size by using a timeline (see animate doc) which allows to embed objects once and to reference them in other animation frames (using PDF XObjects).

\documentclass[compress]{beamer}
\usepackage{pgfpages}
\usepackage[ngerman]{babel}
\usepackage{animate}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,through,backgrounds,positioning,fit,petri}
\usetikzlibrary{shapes,shadows}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{animate}

\begin{document}

\begin{frame}
\begin{animateinline}[
  begin={%
    \begin{tikzpicture}%
    [demand/.style={rounded rectangle, minimum size=8mm, minimum width=20mm, text width=1.2cm, text height=-.45cm, fill=blue!20!white, font=\tiny, text centered},%
    rect/.style={rectangle, font=\tiny},%
    cris/.style={ellipse, minimum size=8mm, minimum width=15mm, text width=1.3cm, text height=0cm, fill=red!10!white, font=\tiny, text centered},%
    post/.style={->,>=stealth', very thin, draw=black!50}]%
    \useasboundingbox (-0.25,-2.5) rectangle (4,2.5); %all frames having the same size
  },
  end={\end{tikzpicture}}
]{10}
  \node (b) at (0,0) [rect, fill=blue!30!white]  {R}; %[R] alone
\newframe*
\multiframe{10}{r = 1 + 1}{ %shaking `S'
  \node (b) at (0,0) [rect, fill=blue!30!white]  {R};
  \node (r) at (2,0) [cris, decorate, decoration={random steps,segment length=3pt,amplitude=\r}] {S};
}
\newframe*
\multiframe{10}{rP = 0.1 + .1, r = 1 + 1}{ %-->(PRD)
  \node (b) at (0,0) [rect, fill=blue!30!white]  {R};
  \node (r) at (2,0) [cris, decorate, decoration={random steps,segment length=3pt,amplitude=\r}] {S};
  \node (d) at (3,-2) [demand] {PRD};
  \path (b.east) -- (d.west) node[pos=\rP] (p){};
  \draw[post] (b.east) -- (p.west);
}
\newframe*
\multiframe{10}{rP = 0.1 + .1, r = 1 + 1}{ %-->(PSD)
  \node (b) at (0,0) [rect, fill=blue!30!white]  {R};
  \node (r) at (2,0) [cris, decorate, decoration={random steps,segment length=3pt,amplitude=\r}] {S};
  \node (d) at (3,-2) [demand] {PRD};
  \path (b.east) -- (d.west) node[pos=1] (p){};
  \draw[post] (b.east) -- (p.west);
  \node (c) at (3,2) [demand] {PSD};
  \path (b.east) -- (c.west) node[pos=\rP] (q){};
  \draw[post] (b.east) -- (q.west);
}
\end{animateinline}
\end{frame}

\end{document}
share|improve this answer
    
that's exactly what i was looking for! thanks a lot! –  helga May 11 '11 at 12:42

I cannot test this answer as I do not have a PDF viewer which is compatible with the animate package. However, I think that this will do what you want. To test it, I ran it without the animate package and manually looping through the frames, setting the variables to whatever I wanted them to be. The key is to use partway modifiers in specifying the target of the arrows. To do this, you need to use the calc TikZ library. For more on the syntax, see section 13.5.3 in the PGF manual (version 2.10, other versions may have different numbering).

Here's the answer without the animate package. The <1-10> and the \pgfmath stuff is to simulate looping over the animation.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}


\begin{document}

\def\r{3}
\def\s{0}

\begin{frame}<1-10>
\pgfmathsetmacro{\r}{2 + \r}
\pgfmathsetmacro{\s}{.1 + \s}
\global\let\r=\r
\global\let\s=\s
\begin{tikzpicture}[every node/.style={fill=green!50!white}]

\onslide<1->\node (b) at (-1,0) [ rectangle]  {R};
\onslide<2->\node (r) at  (1.4,0) [circle, minimum size=\r pt,xshift=-5mm] {S};
\onslide<3->\node (d) at (2.5,-2) [circle,xshift=-5mm] {PRD};
\onslide<3->\draw [->] (b.east) -- ($(b.east)!\s!(d.west)$);
\onslide<4->\node (c) at (2.5,2) [circle, xshift=-5mm] {PSD};
\onslide<4->\draw [->] (b.east) -- ($(b.east)!\s!(c.west)$);

\end{tikzpicture}
\end{frame}

\end{document}

Here's the answer with the animate package. Note that I am assuming a lot that I can't test here.

\documentclass{beamer}
\usepackage{animate}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{frame}
\begin{animateinline}[palindrome]{10}
\multiframe{10}{r=3 + 2,s=0+.1}{
\begin{tikzpicture}[every node/.style={fill=green!50!white}]

\onslide<1->\node (b) at (-1,0) [ rectangle]  {R};
\onslide<2->\node (r) at  (1.4,0) [circle, minimum size=\r pt,xshift=-5mm] {S};
\onslide<3->\node (d) at (2.5,-2) [circle,xshift=-5mm] {PRD};
\onslide<3->\draw [->] (b.east) -- ($(b.east)!\s!(d.west)$);
\onslide<4->\node (c) at (2.5,2) [circle, xshift=-5mm] {PSD};
\onslide<4->\draw [->] (b.east) -- ($(b.east)!\s!(c.west)$);

\end{tikzpicture}
}
\end{animateinline}
\end{frame}

\end{document}

(I've severely condensed your code to answer this. Indeed, I initially thought that I wouldn't be able to answer this and was just trying to help you condense the code to something where the question was evident. But in condensing the code, I had an idea and so turned it in to an answer.)

share|improve this answer
    
You need Adobe Reader, sorry. There is one for Linux too, if you run this platform. Evince, as an open-source viewer, is about getting a JavaScript engine. But it does not support this kind of animations yet :(. –  AlexG May 11 '11 at 8:06
    
@Alexander: don't be sorry! I just wanted to be clear that I can't test this - and I have no intention of installing extra software just to test something that I have no expectation of using myself in the near future. (It looks like a fantastic project, but I wouldn't switch PDF viewers to use it. If jarnal or xournal ever supports it, I may think again.) –  Loop Space May 11 '11 at 8:41

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.