0

In this post, I have learned to plot the following three interesting figures in mathematics (p-adic numers):

\begin{tikzpicture}
        \draw[ ] (0,0) circle [radius=3];
        \node at (0,2) {0};
        \node at (2,-1) {1};
        \node at (-2,-1) {2};
        \end{tikzpicture}
\newcommand{\RA}{1.5}
        \pgfmathsetmacro{\RB}{\RA*(1+2/sqrt(3)}
        \begin{tikzpicture}
        \draw[ ] (0,0) circle[radius=\RB cm];
        \foreach \ang in {90,210,330}
        \draw[ ] (\ang:\RB-\RA) circle[radius=\RA cm];
        \node[red] at (0,2.5) {0};
        \node[red] at (-0.8,1.5) {6};
        \node[red] at (0.8,1.5) {3};
        \node[red] at (1.7,-0.1) {1};
        \node[red] at (2.4,-1.3) {4};
        \node[blue] at (1,-1.3) {7};
        \node[red] (8) at (-2.4,-1.3) {8};
        \node[blue] at (-1,-1.3) {5};
        \node[red] at (-1.7,-0.1) {2};
        \end{tikzpicture}
\newcommand{\RRA}{4}
            \pgfmathsetmacro{\RRB}{\RRA/(1+2/sqrt(3)}
            \begin{tikzpicture}
            \draw[ ] (0,0) circle[radius=\RRA cm];
            \foreach \ang [count = \i from 1] in {90,210,330}
            \draw[ ] (\ang:\RRA-\RRB) coordinate (center-\i) circle[radius=\RRB cm];
            \pgfmathsetmacro{\RRC}{\RRB/(1+2/sqrt(3)}
            \foreach \i in {1,2,3}
            \foreach \ang in {90,210,330}
            \draw[ ] ($(center-\i)+(\ang:\RRB-\RRC)$) circle[radius=\RRC cm];
            \node[red] at (0,3.6) {0};
            \node[red] at (0.3,3) {18};
            \node[green] at (-0.3,3) {9};
            \node[red] at (0.9,2.1) {6};
            \node[red] at (1.2,1.4) {24};
            \node[green] at (0.5,1.4) {15};
            \node[cyan] at (-0.5,1.4) {21};
            \node[cyan] at (-0.9,2.1) {3};
            \node at (-1.2,1.4) {12};
            \node[red] at (1.8,0.5) {2};
            \node[purple] at (-1.8,0.5) {1};
            \node at (-2.2,-0.33) {10};
            \node[purple] at (-1.4,-0.33) {19};
            \node[red] at (2.2,-0.33) {20};
            \node[green] at (1.4,-0.33) {11};
            \node[red] at (2.7,-1) {8};
            \node[red] at (3.2,-1.8) {26};
            \node[green] at (2.3,-1.8) {17};
            \node[cyan] (7) at (1,-1.1) {5};
            \node[cyan] (7) at (1.5,-1.8) {23};
            \node (7) at (0.5,-1.8) {14};
            \node[red] at (-2.7,-1) {4};
            \node at (-3.2,-1.8) {13};
            \node[red] at (-2.3,-1.8) {22};
            \node[purple] (7) at (-1,-1.1) {7};
            \node (7) at (-1.5,-1.8) {16};
            \node[purple] (7) at (-0.5,-1.8) {25};
            \end{tikzpicture}

The above three Tikz codes gives the following three figures, respectively:

enter image description here

enter image description here

enter image description here

My question:

I want to animate these three figures in such a way that the first figure will be displayed for 5 seconds, then the second figures will be displayed for 5 seconds and then the same for third figure.

I got PGF/TikZ manual but unable to apply here.

I appreciate your assitance.

Edit:

I have my preamble:

\documentclass[12pt,reqno]{amsart}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{compat=newest}
\pgfplotsset{ytick style={draw=none}}
\pgfplotsset{xtick style={draw=none}}
\topmargin=0.02cm
\textwidth =  17cm
\textheight = 23cm
\baselineskip=11pt
\setcounter{secnumdepth}{3}
\setlength{\oddsidemargin}{0.01 pt}
\setlength{\evensidemargin}{0.01 pt}
\renewcommand{\baselinestretch}{1.4}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{graphicx}
\graphicspath{ }
%\usepackage[bookmarks=false]{hyperref}
%\usetikzlibrary{animations}
\usepackage{mathrsfs}
\usepackage{epstopdf}
\usepackage{csquotes}
\usepackage{wrapfig}
\usepackage{accents}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{calligra}
\usepackage[colorlinks]{hyperref}
\usepackage{kantlipsum}
\hypersetup{colorlinks, 
    breaklinks,
    linkcolor=red,
    citecolor=red,
    linktocpage=true}
\newtheorem{fig}{figure}[section]
\numberwithin{figure}{section}
\newcommand\norm[1]{\left\lVert#1\right\rVert}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}{Corollary}[thm]
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\newtheorem{conj}{Conjecture}[section]
\newtheorem{exmp}{Example}[section]
\setcounter{tocdepth}{3}
\theoremstyle{remark}
\newtheorem*{rem}{Remark}
\newtheorem*{note}{Note}
\usetikzlibrary{calc}
\usepackage{mathtools}
\makeatletter
\@namedef{subjclassname@2020}{%
    \textup{2020} Mathematics Subject Classification}

\makeatother

\begin{document} .... \end{document}

learner
  • 663
  • 1
    Your code is not compilable. Please turn it into a complete, compilable example. – AlexG Sep 06 '23 at 12:19
  • @AlexG, which one is not compiling ? I can compile all 3 codes and I generated the figures in TeXstudio 2.12.6. Moreover, you can see here. Have you added \documentclass[tikz,border=3.14mm]{standalone} in the preamble ? – learner Sep 06 '23 at 12:23
  • 2
    None. Compilable code examples start with \documentclass and end with \end{document}. It is the questioners task to make the code complete. Please familiarise yourself with this site's conventions. – AlexG Sep 06 '23 at 12:25
  • @AlexG, but all are alright in my TeXstudio 2.12.6 editor. Still not working, then you can suggest me with any three figures (say, circle, triangle, square) instead of my figures so that I can follow the trick – learner Sep 06 '23 at 12:26
  • Animation mostly consists of having many pages with the same page number. – John Kormylo Sep 06 '23 at 13:36
  • @JohnKormylo, can you give an example as answer ? – learner Sep 06 '23 at 13:37
  • See beamer class. Every \pause causes the page to be duplicated. You might be able to do something with eforms and java script. – John Kormylo Sep 06 '23 at 13:40
  • See also https://tex.stackexchange.com/questions/286280/textfield-and-animateinline – John Kormylo Sep 06 '23 at 13:47
  • @JohnKormylo, I know the function of \pause. Thanks. However the link you mentioned doesn't deal with Tikz. I am seeking something with Tikz because I have drawn my figures with Tikz – learner Sep 06 '23 at 13:53
  • @learner Please update your question to make your code fragments compilable. Do you use beamer or another class? You can use beamer overlays with tikz. – samcarter_is_at_topanswers.xyz Sep 06 '23 at 14:09
  • @samcarter_is_at_topanswers.xyz, my code is compiling nicely. I am using TeXstudio editor. You can here, others answered it. See their codes. – learner Sep 06 '23 at 14:10
  • 1
    You code is missing a documentclass, the necessary packages and a document environment. It does not compile as it is shown in your question. – samcarter_is_at_topanswers.xyz Sep 06 '23 at 14:12
  • @samcarter_is_at_topanswers.xyz, ok, please see the edit, I have added my preamble – learner Sep 06 '23 at 14:18
  • @learner Thanks. amsart means no playing with \pause :) – samcarter_is_at_topanswers.xyz Sep 06 '23 at 14:21
  • @samcarter_is_at_topanswers.xyz, I use \pause in beamer presentation. – learner Sep 06 '23 at 14:28
  • ... but you use amsart here, so \pause is not available. – samcarter_is_at_topanswers.xyz Sep 06 '23 at 14:29
  • @samcarter_is_at_topanswers.xyz, Is \documentclass{article} alright ? – learner Sep 06 '23 at 14:32
  • 2
    amsart is fine. But your preamble is full of irrelevant pkgs. Please remove the unneeded ones. And insert your TikZ code in the body of the document. This may help you to set up a good example: https://tex.meta.stackexchange.com/questions/228/ive-just-been-asked-to-write-a-minimal-working-example-mwe-what-is-that – AlexG Sep 06 '23 at 14:49
  • @AlexG, thanks. Indeed, I have used several package for seeral purposes in the last 3-4 years and which is why so many commands. But I didn't understand your comment "And insert your TikZ code in the body of the document". Which body ? – learner Sep 06 '23 at 14:56

2 Answers2

1

As the code in OP is not complete/compilable, a simple example follows to demonstrate how to set up an animation where each frame is shown for 5 seconds:

\documentclass{article}
\usepackage{animate}

\begin{document} \begin{animateinline}[autoplay]{0.2}% 0.2 FPS corresponds to 5 s of frame visibility \fbox{1} \newframe \fbox{2} \newframe \fbox{3} \newframe % <-- this makes the last one disappear after another 5 s, as requested \end{animateinline} \end{document}

The frame rate can be set individually for each frame or animation section by means of the optional \newframe argument:

\documentclass{article}
\usepackage{animate}

\begin{document} \begin{animateinline}[autoplay]{0.2}% 0.2 FPS corresponds to 5 s of frame visibility \fbox{1} \newframe[0.5] % the next frame is shown for 2 s \fbox{2} \newframe[0.2] % reset to 5 s visibility \fbox{3} \newframe % <-- this makes the last one disappear after another 5 s, as requested \end{animateinline} \end{document}

Okular and A-Reader can be used for viewing the animation.

AlexG
  • 54,894
  • Thanks. But my code compiling, otherwise how could I generate those figures ? Please see here, I got the main code from it. – learner Sep 06 '23 at 14:11
  • What would be in the \fbox{1}, \fbox{2}, \fbox{3} ? Can I subsitute my codes in place 1, 2 or 3 ? – learner Sep 06 '23 at 14:13
  • Please see my preamble in the edited question, which can compile my code. – learner Sep 06 '23 at 14:19
  • Can you please clarify the use of \fbox{1}, \fbox{2}, \fbox{3} ? In general, we enclose some text with this funtion. But I have to write Tikz-code to generate figures – learner Sep 06 '23 at 14:33
  • 1
    \fbox{...} is for demonstration purposes only. Anything that produces visible content of non-zero width and height can be used instead. – AlexG Sep 06 '23 at 14:39
  • Great! It is working. I put my TikZ codes into the \fbox{}s and the generated pdf showing animation. Now please tell me how to loop it or cycle it ? I mean I want to display the figure 1-->2-->3-->1-->2-->3....so on – learner Sep 06 '23 at 14:52
  • Add the loop option for a repeating animation. \fbox is not required at all unless you want to have a frame drawn around your graphics. – AlexG Sep 06 '23 at 14:57
  • For loop, we have to use the syntax \foreach var_names in {values_for_each_var}{% sentences inside the loop};. What are the variables here and what are their values in my case? – learner Sep 06 '23 at 17:01
  • No additional code or variables. Just add , loop in the options argument of animateinline. And also remove \fbox from your code. – AlexG Sep 07 '23 at 05:29
  • Do you mean \begin{animateinline}[loop].....\end{animateinline} ? – learner Sep 07 '23 at 06:50
  • 1
    Yes, it is as simple. – AlexG Sep 07 '23 at 07:44
  • Thank you so much. You solved my problem. – learner Sep 07 '23 at 10:43
1

This uses the texpower package. It is every bit as complicated as beamer, but totally different in application.

\documentclass[12pt,reqno]{amsart}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{compat=newest}
\pgfplotsset{ytick style={draw=none}}
\pgfplotsset{xtick style={draw=none}}
\topmargin=0.02cm
\textwidth =  17cm
\textheight = 23cm
\baselineskip=11pt
\setcounter{secnumdepth}{3}
\setlength{\oddsidemargin}{0.01 pt}
\setlength{\evensidemargin}{0.01 pt}
\renewcommand{\baselinestretch}{1.4}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{graphicx}
\graphicspath{ }
%\usepackage[bookmarks=false]{hyperref}
%\usetikzlibrary{animations}
\usepackage{mathrsfs}
\usepackage{epstopdf}
\usepackage{csquotes}
\usepackage{wrapfig}
\usepackage{accents}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{calligra}
\usepackage[colorlinks]{hyperref}
\usepackage{kantlipsum}
\hypersetup{colorlinks, 
    breaklinks,
    linkcolor=red,
    citecolor=red,
    linktocpage=true}
\newtheorem{fig}{figure}[section]
\numberwithin{figure}{section}
\newcommand\norm[1]{\left\lVert#1\right\rVert}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}{Corollary}[thm]
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\newtheorem{conj}{Conjecture}[section]
\newtheorem{exmp}{Example}[section]
\setcounter{tocdepth}{3}
\theoremstyle{remark}
\newtheorem*{rem}{Remark}
\newtheorem*{note}{Note}
\usetikzlibrary{calc}
\usepackage{mathtools}

\makeatletter @namedef{subjclassname@2020}{% \textup{2020} Mathematics Subject Classification} \makeatother

\usepackage[display]{texpower}

\begin{document} Some text.

\stepwise{% \steponce{\begin{tikzpicture} \draw[ ] (0,0) circle [radius=3]; \node at (0,2) {0}; \node at (2,-1) {1}; \node at (-2,-1) {2}; \end{tikzpicture}}

\steponce{\newcommand{\RA}{1.5}% \pgfmathsetmacro{\RB}{\RA*(1+2/sqrt(3)}% \begin{tikzpicture} \draw[ ] (0,0) circle[radius=\RB cm]; \foreach \ang in {90,210,330} \draw[ ] (\ang:\RB-\RA) circle[radius=\RA cm]; \node[red] at (0,2.5) {0}; \node[red] at (-0.8,1.5) {6}; \node[red] at (0.8,1.5) {3}; \node[red] at (1.7,-0.1) {1}; \node[red] at (2.4,-1.3) {4}; \node[blue] at (1,-1.3) {7}; \node[red] (8) at (-2.4,-1.3) {8}; \node[blue] at (-1,-1.3) {5}; \node[red] at (-1.7,-0.1) {2}; \end{tikzpicture}}

\steponce{\newcommand{\RRA}{4}% \pgfmathsetmacro{\RRB}{\RRA/(1+2/sqrt(3)}% \begin{tikzpicture} \draw[ ] (0,0) circle[radius=\RRA cm]; \foreach \ang [count = \i from 1] in {90,210,330} \draw[ ] (\ang:\RRA-\RRB) coordinate (center-\i) circle[radius=\RRB cm]; \pgfmathsetmacro{\RRC}{\RRB/(1+2/sqrt(3)} \foreach \i in {1,2,3} \foreach \ang in {90,210,330} \draw[ ] ($(center-\i)+(\ang:\RRB-\RRC)$) circle[radius=\RRC cm]; \node[red] at (0,3.6) {0}; \node[red] at (0.3,3) {18}; \node[green] at (-0.3,3) {9}; \node[red] at (0.9,2.1) {6}; \node[red] at (1.2,1.4) {24}; \node[green] at (0.5,1.4) {15}; \node[cyan] at (-0.5,1.4) {21}; \node[cyan] at (-0.9,2.1) {3}; \node at (-1.2,1.4) {12}; \node[red] at (1.8,0.5) {2}; \node[purple] at (-1.8,0.5) {1}; \node at (-2.2,-0.33) {10}; \node[purple] at (-1.4,-0.33) {19}; \node[red] at (2.2,-0.33) {20}; \node[green] at (1.4,-0.33) {11}; \node[red] at (2.7,-1) {8}; \node[red] at (3.2,-1.8) {26}; \node[green] at (2.3,-1.8) {17}; \node[cyan] (7) at (1,-1.1) {5}; \node[cyan] (7) at (1.5,-1.8) {23}; \node (7) at (0.5,-1.8) {14}; \node[red] at (-2.7,-1) {4}; \node at (-3.2,-1.8) {13}; \node[red] at (-2.3,-1.8) {22}; \node[purple] (7) at (-1,-1.1) {7}; \node (7) at (-1.5,-1.8) {16}; \node[purple] (7) at (-0.5,-1.8) {25}; \end{tikzpicture}}}

Some more text \end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120