Use tikz and animate to animate in article document class

animatetikz-pgf

I want to take an animated note of gradient descent via latex, and I know that in the beamer document class, this is possible.

But I mainly want to make a note, I'm not happy with beamer's documentation style.

Is there any way, I can do the same thing in the article document?

\documentclass{beamer}

\usepackage{tikz}
\usepackage[
    autoplay,
    loop
]{animate}

\begin{document}

\begin{frame}
    \begin{animateinline}[
            begin={
                    \begin{tikzpicture}[blue,scale=1,line width=2pt]
                        \useasboundingbox[draw] (0,0)rectangle(4,4);
                    :   },
                        end={\end{tikzpicture}}
        ]{2}
        \newframe \draw[->](0,0)--(1,1);
        \newframe \draw[->](0,0)--(2,2);
        \newframe \draw[->](0,0)--(3,3);
        \draw[->](0,0)--(4,4);
    \end{animateinline}
\end{frame}

\end{document}

This code has nothing to do with gradient descent, but as an example, it doesn't matter.

How can I make the above code available when \documentclass{acrticle}?

Best Answer

Just change the class and remove frame.

\documentclass{article}

\usepackage{tikz}
\usepackage[
autoplay,
loop
]{animate}

\begin{document}

Text.
\begin{animateinline}[
  begin={
    \begin{tikzpicture}[blue,scale=1,line width=2pt]
      \useasboundingbox[draw] (0,0)rectangle(4,4);
      :   },
    end={\end{tikzpicture}}
  ]{2}
  \newframe \draw[->](0,0)--(1,1);
  \newframe \draw[->](0,0)--(2,2);
  \newframe \draw[->](0,0)--(3,3);
  \draw[->](0,0)--(4,4);
\end{animateinline}

\end{document}

enter image description here