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 want to make equations (or words) to continuously move in a page for a beamer talk. A simple example would be we have "A" on the left margin and "B" on the right margin and then "A" moves towards and below "B" to make the division B/A.

I thought about using the texpos package with the animate package so I did not have everything in a tikz picture. As I never used the animate package I'm looking for similar examples.

At TeXample, the examples I found of animation were about animating pictures and graphs. Here by "animation", all the questions I found mean changing an equation but not its position in a continuous manner.

share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted

Below I present two options.

Using the animate package

Here's a simple example, using the animate package. Initially you see "A" and "B" four centimeters apart and at the same height: when you play the animation (Acrobat Reader, please (restriction from animate)), "A" starts moving towards "B", and ends just below "B":

\documentclass{beamer}
\usepackage{animate}
\usepackage{ifthen}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\hypersetup{pdfpagemode=FullScreen}

\newcounter{tmp}
\stepcounter{tmp}
\def\Steps{20}

\begin{document}

\begin{frame}[fragile]{}
\begin{center}
\begin{animateinline}[loop,poster=first,controls]{2}
\whiledo{\thetmp<\Steps}{%
  \begin{tikzpicture}[
  decoration={
      markings,
      mark={
      at position \thetmp/(\Steps-1)
      with {\node {$A$};}}
      }]
    \coordinate (start) at (-2,0);
    \coordinate (end) at (2,0);
    \node at (end) {$B$};
    \path[postaction={decorate}]
      ([yshift=.35ex]start) to[out=-20,in=200] ([yshift=-3ex]end);
    \path[use as bounding box] (-3,-3) rectangle (3,3);
  \end{tikzpicture}%
  \stepcounter{tmp}
  \ifthenelse{\thetmp<\Steps}
    {\newframe}
    {\end{animateinline}\relax}
}
\end{center}
\end{frame}

\end{document}

I don't know how to convert an animation of this kind to be uploaded.

The idea is to place "A" in a \node and to use a decoration (from the decorations.markings library) to make "A" move; the movement is given by changing the at position key for the decoration; the decoration is applied as a postaction to a curved path that ends just below "B".

Increasing the value for \Steps (set initially to 20) the movement will be more "continuous".

To have a visual guide of the path used, you can add draw to the path; i.e., replace

\path[postaction={decorate}]
      ([yshift=.35ex]start) to[out=-20,in=200] ([yshift=-3ex]end);

with

\path[draw,postaction={decorate}]
      ([yshift=.35ex]start) to[out=-20,in=200] ([yshift=-3ex]end);

Using overlay specifications and a \foreach loop

Now the second option using overlay specifications and a loop to "fake" a real animation:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\def\Steps{40}

\begin{document}

\begin{frame}
\begin{center}
  \begin{tikzpicture}
  \coordinate (start) at (-3,0);
  \coordinate (end) at (3,0);
  \node at (end) {$B$};
  \foreach \Cont in {1,...,\Steps}
  \path<\Cont>[
  decoration={
    markings,
      mark=%
      at position \Cont/\Steps
      with {\node {A};}
  },
  postaction={decorate}]
    ([yshift=0.35ex]start) to[out=-30,in=210] ([yshift=-3ex]end);
  \end{tikzpicture}%
\end{center}
\end{frame}

\end{document}

enter image description here

share|improve this answer
add comment

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.