8

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}?

2
  • I think you need to create two projects: One project with beamer class and preview package to generate a tight multipage pdf. The other project with article class and animate package to import the tight multipage PDF. In the first project, you can use all beamer overlay features. Commented Apr 2, 2022 at 16:00
  • Package animate is document class independent.
    – AlexG
    Commented Apr 3, 2022 at 8:23

1 Answer 1

7

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

3
  • The black lines around the animation are from my video capture tool. The animation inserted in the article is in a total white page.
    – FHZ
    Commented Apr 2, 2022 at 16:03
  • How many pdflatex invocations are needed? Two? Commented Apr 2, 2022 at 16:03
  • @TheCodeMocker, it was necessary only one. I shall point out to visualize the animate I must open in some PDF viewer (Adobe in my case). I don't know which TeX editors have an embedded visualizer that can show animations.
    – FHZ
    Commented Apr 2, 2022 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .