11

With the following code

\documentclass[beamer]{beamer}
\begin{document}
\begin{frame}
  \[
    \sqrt{\uncover<2->{a\uncover<3->{+b}}}
  \]
\end{frame}    
\end{document}

I can uncover a formula showing first outer elements then the inner ones.

How can I obtain the converse? That is: first display the "+b", then the "a" in front of it, then the square root sign around the sum?

  • A professor of mine did this on the blackboard. This provides a very handy way to explain a rather complicated formula on a step-by-step basis. – Dohn Joe Sep 29 '14 at 16:24
12

The square root is the problem.

\documentclass[beamer]{beamer}
\begin{document}
\begin{frame}
\[
  \only<1>{\phantom{\sqrt{\vphantom{a+b}}}\hphantom{a}+b}
  \only<2>{\phantom{\sqrt{\vphantom{a+b}}}a+b}
  \only<3>{\sqrt{a+b}}
\]
\end{frame}
\end{document}
| improve this answer | |
  • Ok, this works, thanks. But do you think this is the only way? I mean: the example is small, of course, but with big formulas it can be a pain to extend it... – brad Sep 29 '14 at 16:05
  • @brad I understand, but the square root must know what it applies to. – egreg Sep 29 '14 at 16:08
  • Do you mean that if something is covered in the current slide then it is not even computed? If so, I agree that there is no other solution. In that case, maybe a workaround for a complicated formula could be to use white ink for the whole formula and black from the inner to the outer... – brad Sep 29 '14 at 16:15
  • For this particular case, it might be easier to use power notation, as in x=(\uncover<1->a\uncover<2->{+b})\uncover<3->{^{1/2}}. – Mike Renfro Sep 29 '14 at 17:50
  • @brad You can avoid most of the work using a good editor. You can just write the first equation, then copy & paste the line remove an \*phantom command, copy and paste the line etc. For example in vim it wouldn't take many keystrokes: Yp to do the copy pasting of the whole line, dawxhx to remove the \*phantom{ and wx to remove the right }, T<rn to change the number to n (with minor tweaks depending on the line). You can produce that kind of output at about 15 keystrokes per line. – Bakuriu Sep 29 '14 at 18:29
4

I worked a little bit more on my example (I need it for a somewhat more complicated formula) and I discovered that inner \textcolor have priority on outer ones, so the following works:

\begin{frame}
  \[
    \textcolor<3>{black}{\textcolor<1-2>{white}{%
      \sqrt{%
        \textcolor<2>{black}{\textcolor<1>{white}{%
          a%
          \textcolor<1>{black}{%
            \vphantom{a}+b%
          }%
        }}%
      }%
    }}%
  \]
\end{frame}

In my case, I can generalize this easier than @egreg suggestion (which is, anyway, very nice and "TeXnical") As a more elaborated example, consider the following:

\begin{frame}
  \[
    \textcolor<6>{black}{\textcolor<1-5>{white}{%
    \textcolor<5->{black}{\textcolor<4>{red}{%
      {\sqrt{%
    \textcolor<3->{black}{\textcolor<2>{red}{%
        {\left(%
    \textcolor<2->{black}{\textcolor<1>{red}{%
          {\frac{a}{2}}%
      }}%
          \right)^{2}}%
      }}%
    \textcolor<4->{black}{\textcolor<3>{red}{%
      {\vphantom{1}+b}%
      }}%
      }}%
      }}%
    \textcolor<6->{black}{\textcolor<5>{red}{%
        {\vphantom{1}+\frac{c}{2}}%
      }}%
      }}%
  \]
\end{frame}
| improve this answer | |

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.