# animated proof in latex [closed]

How can I make something like this? I would prefer tikz.

That's a pretty elaborate animation, so here's a start. If you have trouble (and probably you will), feel free to ask a new question, but remember to keep it focused on a specific issue you got stuck with.

Adding tikz to the standalone class options allows your pdf to have one page per frame.

To compile this as a .gif, install imagemagick in your system, then do this in your Terminal/Command Prompt:

convert -delay 10 -loop 0 -density 300 -scale 400 -alpha remove file.pdf file.gif


where file.pdf is the name of your file and file.gif is the name of the resulting .gif file, change the name accordingly.

## Code

\documentclass[tikz, margin=10pt]{standalone}

\newcommand\basicstuff{
\path (-5,-3) rectangle (5,3);
}

\tikzset{
bas/.style={text width=4cm}
}

\begin{document}\Huge
\foreach \x in {0,...,10}{
\begin{tikzpicture}
\basicstuff

\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};

\end{tikzpicture}
}
%
\foreach \x [
count=\xx starting from 0,
evaluate=\x as \opac using (\x/10),
evaluate=\x as \y using (3-\x)
] in {0,.25,...,2}{
\begin{tikzpicture}
\basicstuff

\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};

\node[bas, opacity=\opac] at (-\x,\y) {$\textcolor{red}{axx}$};
\end{tikzpicture}
}
%
\foreach \x in {1,...,10}{
\begin{tikzpicture}
\basicstuff

\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};

\node[bas] at (-2,1) {$\textcolor{red}{axx}$};
\end{tikzpicture}
}
%
\foreach \y [
count=\xx starting from 0,
evaluate=\xx as \xi using (-2.75-(.25*-\xx*1.5)),
evaluate=\xx as \yi using (.8-(.25*\xx*2.5)),
evaluate=\y as \x using (1-\y)
] in {1,.8,...,0}{
\begin{tikzpicture}
\basicstuff

\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};

\filldraw[draw=red, fill=red!50] (-2.75,.6) rectangle (\xi,\yi);
\path (-2.75,.8) -- (-2.75,\yi) node[left, midway] {$\textcolor{red}{ax}$};
\path (-2.75,.5) -- (\xi,.5) node[above, midway] {$\textcolor{red}{x}$};

\end{tikzpicture}
}
%
\foreach \x in {1,...,10}{
\begin{tikzpicture}
\basicstuff

\node[bas] at (0,3) {$\textcolor{red}{ax^2} + \textcolor{green}{bx} + \textcolor{blue}{c}$};

\filldraw[draw=red, fill=red!50] (-2.75,.6) rectangle (-.875,-2.325);
\path (-2.75,.8) -- (-2.75,-2.325) node[left, midway] {$\textcolor{red}{ax}$};
\path (-2.75,.5) -- (-.875,.5) node[above, midway] {$\textcolor{red}{x}$};

\end{tikzpicture}
}
\end{document}

• Thanks a lot you are so helpful :-) Because of you I can make some beautiful animations for my class. – user Apr 21 '16 at 17:38
• Why gif? I would use the animate package. (But I don't like such animations, I prefer when such explanation don't move so that I can study them at my pace). – Ulrike Fischer Apr 21 '16 at 18:10
• @UlrikeFischer It depends on the medium I suppose, but I totally see where you're coming from. I think that "animations" as in, animated transactions from one state to another, are nice to see in a presentation when the teacher is explaining. Or for example if the animation is relevant for the topic (i.e. physics class). I find the animate package to be a bit arduous to use. :P – Alenanno Apr 21 '16 at 18:19
• As you are drawing the pictures with tikz anyway, you only need to insert \newframe at suitable places. – Ulrike Fischer Apr 21 '16 at 18:28
• How does it work with animation adding \newframe. It might be useful for my student, since gif is too quick for some of them? – user Apr 21 '16 at 18:48