8

A previous question inquires about animating some simple text, with an elegant solution that uses the animate package and the xstring package.

Is there a way to alter this code so that it works in math mode? For example, how can the following be animated to appear letter by letter?

Pythagorean theorem $a^2 + b^2 = c^2$

Also, is it possible to animate the following to appear character by character?

\begin{equation} \text{Quadratic formula } x = \frac{-b \pm \sqrt{b^2 - 4 a c } }{ 2 a} \end{equation}

Animating either of these statements would be quite helpful.

Late edit:

Bonus for doing multiple lines in a single animation,

Pythagorean theorem $a^2 + b^2 = c^2$\par
This means $c = \sqrt{a^2 + c^2}$
\[Cos \theta = \frac{c}{a}\]
12
+50
\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}

\begin{document}

\Huge
\let~\pause
\frame{
    P~y~t~h~a~g~o~r~e~a~n~\ $a^{~2}~+~b^{~2}~=~c^{~2}$
}

\end{document}

Another approach

\documentclass{beamer}
\setbeamertemplate{navigation symbols}{}

\begin{document}

\makeatletter
\def\BB{\pgfsys@begininvisible}
\def\EE{\pgfsys@endinvisible}
\makeatother

\begin{frame}
    \begin{equation}
        \text{Qua\only<1>{\BB}dra\only<2>{\BB}tic\only<3>{\BB} formula }
            x = \frac{-b \pm \sqrt{b^2 - 4 a c } }{ 2 a}
        \EE
    \end{equation}
\end{frame}

\begin{frame}
    \begin{equation}
        \text{Quadratic for\only<1>{\BB}mu\only<2>{\BB}la\only<3>{\BB} }
            x = \frac{-b \pm \sqrt{b^2 - 4 a c } }{ 2 a}
        \EE
    \end{equation}
\end{frame}

\begin{frame}
    \begin{equation}
        \text{Quadratic formula }
            x = \only<+>\BB\frac{-b\only<+>\BB\pm\only<+>\BB\sqrt{b^2 - 4 a c } }{ 2 a}
        \EE
    \end{equation}
\end{frame}

\begin{frame}
    \begin{equation}
        \text{Quadratic formula }
            x = \frac{-b \pm \sqrt{\only<+>\BB b^2\only<+>\BB- 4 a c\only<+>\BB} }{ 2 a}
        \EE
    \end{equation}
\end{frame}

\begin{frame}
    \begin{equation}
        \text{Quadratic formula }
            x = \frac{-b \pm \sqrt{b^2 - 4 a c } }{\only<+>\BB 2 a\only<+>\BB}
        \EE
    \end{equation}
\end{frame}


\begin{frame}
    \begin{equation}
    \BB
        \text{Quadratic \only<+>\EE formula \only<+>\EE}
            x = \only<+>\EE\frac{-b \pm \only<+>\EE\sqrt{b^2 - 4 a c } \only<+>\EE}{ 2 a}
    \end{equation}
    \only<+>\EE
\end{frame}

\end{document}

3
  • I meant to show two different approaches: \pause is no-brainer. Using \pgfsys gives you more control. (When to start and when to end). I'm pretty sure both lines can be done in both ways. Depending on how automatic it should be, maybe someone on this site can write a macro that insert \pause at every possible position. Edit the question to let people know what you want. – Symbol 1 Jun 17 '20 at 20:56
  • What did you use to build these files? For me, MikTex pdfLaTex didn't work. – axsvl77 Jun 17 '20 at 22:04
  • I needed to follow tex.stackexchange.com/questions/133781/… Seems to work now. – axsvl77 Jun 18 '20 at 1:21

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.