8

I want to animate rows of equations to look like they are manually written by hands on a piece of paper.

Requirements

  • The equations must be decorated with minimal numbers of cluttering animating decorators.
  • For each frame, the first part of an equation sticks to the left and the subsequent parts of the equations flow to the right. (Rather than the first part starts from the center and it get pushed to the left when the subsequent parts come).
  • we can also animate fraction, integral, limit, etc. For example, \frac{a}{b} will be animated to produce a followed by a horizontal line and followed by b. Another example, \int_a^b will be animated as an integral sign followed by b that is followed by a.

  • To make it more portable, not using beamer is preferred.

Question

How to achieve such requirements? I will give a bounty of 2000 for those who can provide me with a satisfying code. Any additional features from your creativity is also welcome!

MWE

Warning: the following code will spin undefinetely.

\documentclass[12pt]{beamer}
\usepackage{amsmath}
\usepackage[active,tightpage]{preview}
\PreviewBorder=12pt\relax
\PreviewEnvironment{align*}

\newcounter{counter}
\newcommand{\foo}[1]{\stepcounter{counter}\only<\thecounter->{#1}}
\begin{document}
\begin{frame}
    \begin{align*}
    \foo{a}\foo{+b}&\foo{=1}\\
    \foo{\frac{1}{2}}\foo{+\frac{3}{2}}\foo{&=2}% I don't know whether "&" should be outside or inside "\foo".
    \end{align*}
\end{frame}
\end{document}
  • 1
    As for "the code spins undefinetely": on p. 24 the beamer manual says "Euclid finds that he can also add a \pause between the definition and the example. So, \pauses seem to transcend environments, which Euclid finds quite useful. After some experimentation he finds that \pause only does not work in align environments. He immediately writes an email about this to beamer’s author, but receives a polite answer stating that the implementation of align does wicked things and there is no fix for this. Also, Euclid is pointed to the last part of the user’s guide, where a workaround is described." – marmot Mar 10 at 10:51
6

This is not a full answer but a longer reply to your comment. There are many things I do not understand about your approach, and here is a suggestion how to fix them. The main point is that IMHO your \foo attempts to reinvent the wheel something beamer already has.

\documentclass[12pt,beamer,preview,multi={gather*}]{standalone}
\usepackage{amsmath,mathtools}
\newcommand{\foo}[1]{\visible<+->{#1}}
\newcommand{\foop}[1]{\only<+>{#1}}
\newcommand{\foopp}[1]{\only<+->{#1}}
\newcommand{\fooint}[2]{\foop{\mathrlap{\int\limits_{\phantom{#1}}^{\phantom{#2}}}}%
\foop{\mathrlap{\int\limits_{#1}^{\phantom{#2}}}}%
\foo{\int\limits_{#1}^{#2}}}
\newcommand{\foofrac}[2]{\foop{\mathrlap{\genfrac{}{}{0pt}{0}{#1}{\phantom{#2}}}}%
\foop{\mathrlap{\frac{#1}{\phantom{#2}}}}%
\foo{\frac{#1}{#2}}}

\begin{document}
\begin{standaloneframe}%\show\genfrac
    \begin{gather*}
    \foo{a}\foo{+}\foo{b}\foo{=}\foo{1}\\
    \fooint{a}{b}\foo{f}\foo{(}\foo{x}\foo{)}
    \foo{\,\mathsf{d}}\foo{x}\foo{=}\foo{2}\\
    \foofrac{a}{b}
    \foo{=}
    \foofrac{c}{d}\\[1cm]
    \end{gather*}
\end{standaloneframe}
\end{document}

enter image description here

EDIT: Added a missing \mathrlap, thanks to The Inventor of God (or reinventer of the wheel? ;-)!

As I said, this is an extended comment, not a full answer. I guess a full answer will have to allow one to nest these macros. With the tools above, one could write something like \frac{a\,b}{c} in such a way that first a appears, then b and finally the full thing. But it will be cumbersome. I could imagine to cook up a more automatized version with loops, but this will most likely be fragile. So I stop here.

  • 1
    marmot your paw hand is invisible to me perhaps your tikz is not tokz :-) – KJO Mar 10 at 12:10
  • 1
    @marmot my vision was that The inventor wanted to see the users mouse moving left to right but I guess your paw holding said mouse would do – KJO Mar 10 at 12:26
  • 2
    I guess the fractions did not make it into the animation because the page size changes within the document. – user36296 Mar 10 at 13:08
  • 2
    How nice :-). The time duration of the characters is as slow as my students would like during my explanations. LOL. – Sebastiano Mar 10 at 16:35
  • 1
    @Sebastiano Well, if it was as readable as this, I would not complain. I sometimes feel I am not the only one with claws. ;-) – marmot Mar 10 at 16:37

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.