1

I have an animation

\documentclass{beamer}
\usepackage{tikz}
\usetheme{CambridgeUS}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\usepackage{ifthen}
\usepackage{animate}
\usepackage{pgffor}
\usetikzlibrary{calc}

 \makeatletter
 \newcommand*{\dothis}[1]{%
 \stringcases
 {#1}%
 {%
  {1}{
  \fill[blue] (-3,0)  circle[radius=3pt] node[below] {$110$};

  }%
  {2}{%
  \fill[red] (-1,0)  circle[radius=3pt] node[below] {$120$}; %
     }% 
  {3}{%
  \fill[green] (1,0)  circle[radius=3pt] node[below] {$130$};%
     }%
  }%
  }
  \newcommand{\stringcases}[3]{%
  \romannumeral
  \str@case{#1}#2{#1}{#3}\q@stop
  }
  \newcommand{\str@case}[3]{%
  \ifnum\pdf@strcmp{\unexpanded{#1}}{\unexpanded{#2}}=\z@
  \expandafter\@firstoftwo
  \else
  \expandafter\@secondoftwo
  \fi
  {\str@case@end{#3}}
 {\str@case{#1}}%
 }
 \newcommand{\str@case@end}{}
 \long\def\str@case@end#1#2\q@stop{\z@#1}
 \makeatother

\begin{document}
\begin{frame}[t]
 \begin{center}
\begin{animateinline}[controls,autoplay,loop]{2}
\multiframe{3}{n=1+1}{
\begin{tikzpicture}
\coordinate (O) at (-2,0);
\coordinate (OO) at (3.5,0);
\draw[fill=orange!50,thick] (O) circle [radius=2.5cm];
\fill (O)  circle[radius=2pt] node[below left] {$00000$};
\draw[fill=orange!50,thick] (OO) circle [radius=2.5cm];
\fill (OO)  circle[radius=2pt] node[below left] {$11111$};
\expandafter\dothis\n
\end{tikzpicture} 
}
\end{animateinline}
\end{center}
\end{frame}
\end{document}

The problem is that the points (110,120,130) are displayed sequentially. Please tell me how to do so that the frames overlap.

1

This can be achieved with the timeline feature of animate.

We separate the background (two orange circles) from the dots to be overlaid:

\begin{animateinline}[...]{2}
  %background
  \coordinate (O) at (-2,0);
  \coordinate (OO) at (3.5,0);
  \draw[fill=orange!50,thick] (O) circle [radius=2.5cm];
  \fill (O)  circle[radius=2pt] node[below left] {$00000$};
  \draw[fill=orange!50,thick] (OO) circle [radius=2.5cm];
  \fill (OO)  circle[radius=2pt] node[below left] {$11111$};
\newframe
  %to-be-overlaid points
  \multiframe{3}{n=1+1}{
    \expandafter\dothis\n
  }
\end{animateinline}

and combine (overlay) these images by means of a timeline defined in the text file timeline.txt:

%write timeline file to hard disk
\usepackage{filecontents}
\begin{filecontents}{timeline.txt} 
  :: 0x0 %background (image `0') to be repeated until the end ( `x0' )
  :: 1x0 %overlaid point 110 (image `1') to be repeated til end ( `x0' )
  :: 2x0 %overlaid point 120 (image `2') to be repeated til end ( `x0' )
  :: 3x0 %overlaid point 130 (image `3') to be repeated til end ( `x0' )
\end{filecontents}  

Complete example:

\documentclass{beamer}
\usepackage{tikz}
\usetheme{CambridgeUS}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{ifthen}
\usepackage{animate}
\usepackage{pgffor}
\usetikzlibrary{calc}

 \makeatletter
 \newcommand*{\dothis}[1]{%
 \stringcases
 {#1}%
 {%
  {1}{
  \fill[blue] (-3,0)  circle[radius=3pt] node[below] {$110$};

  }%
  {2}{%
  \fill[red] (-1,0)  circle[radius=3pt] node[below] {$120$}; %
     }% 
  {3}{%
  \fill[green] (1,0)  circle[radius=3pt] node[below] {$130$};%
     }%
  }%
  }
  \newcommand{\stringcases}[3]{%
  \romannumeral
  \str@case{#1}#2{#1}{#3}\q@stop
  }
  \newcommand{\str@case}[3]{%
  \ifnum\pdf@strcmp{\unexpanded{#1}}{\unexpanded{#2}}=\z@
  \expandafter\@firstoftwo
  \else
  \expandafter\@secondoftwo
  \fi
  {\str@case@end{#3}}
 {\str@case{#1}}%
 }
 \newcommand{\str@case@end}{}
 \long\def\str@case@end#1#2\q@stop{\z@#1}
 \makeatother

%write timeline file to hard disk
\usepackage{filecontents}
\begin{filecontents}{timeline.txt} 
  :: 0x0 %background (image `0') to be repeated until the end ( `x0' )
  :: 1x0 %overlaid point 110 (image `1') to be repeated til end ( `x0' )
  :: 2x0 %overlaid point 120 (image `2') to be repeated til end ( `x0' )
  :: 3x0 %overlaid point 130 (image `3') to be repeated til end ( `x0' )
\end{filecontents}  

\begin{document}
\begin{frame}[t]
 \begin{center}
\begin{animateinline}[
  timeline=timeline.txt,
  controls,autoplay,loop,
  begin={\begin{tikzpicture} \useasboundingbox (-4.52,-2.52) rectangle (6.02,2.52);},
  end={\end{tikzpicture}},
]{2}
  %background
  \coordinate (O) at (-2,0);
  \coordinate (OO) at (3.5,0);
  \draw[fill=orange!50,thick] (O) circle [radius=2.5cm];
  \fill (O)  circle[radius=2pt] node[below left] {$00000$};
  \draw[fill=orange!50,thick] (OO) circle [radius=2.5cm];
  \fill (OO)  circle[radius=2pt] node[below left] {$11111$};
\newframe  
  \multiframe{3}{n=1+1}{
    %to-be-overlaid points
    \expandafter\dothis\n
  }
\end{animateinline}
\end{center}
\end{frame}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.