20

I have a beamer presentation in latex where I want a formula to change its coloring schema over a couple of steps (The idea is to mark the "active" part of the formula at the given moment).

When I try to acomplish that like this,

    \begin{frame}{Title}

    \uncover<1-1>{
    \begin{align*}
       e=mc^3
    \end{align*}
    }

    \uncover<2-2>{
    \begin{align*}
       e=mc^{\color{red}3}
    \end{align*}
    }

    \uncover<3-3>{
    \begin{align*}
       e=mc^{\color{green}2}
    \end{align*}
    }

    \end{frame}

then, of course, the formula moves downward in the slide. Here is the question: how can I "update" a formula i.e. uncover a new version of the formula at exactly the location of its old version?

It seems that the problem is that after slide m is reached, the formula encapsulated in \uncover<3-3>{...} is hidden but it is still there..(it still occupies space)

migrated from stackoverflow.com Apr 19 '13 at 21:05

This question came from our site for professional and enthusiast programmers.

  • 1
    Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Apr 19 '13 at 21:16
23

The simplest way would be to use the \only command instead of \uncover. You could also put the formulas into the same \align block, making the code more compact. And as noted in comments, if the element is to be shown on just a single slide, you can simply use \only<n> instead of \only<n-n>.

\begin{align*}
    \only<1>{E=mc^1}
    \only<2>{E=mc^2}
    \only<3>{E=mc^3}
\end{align*}

For more information, and advanced techniques, see section 9.5 of the Beamer User Guide.

  • Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Apr 19 '13 at 21:17
  • 6
    You can just write \only<1> instead of <1-1> – Boris Brodski Oct 4 '14 at 4:45
2

If the formula, or whatever it is, is inside an environment (theorem, definition, ...) and have more then one line, then the solution provided by tobias_k could fail (wrt my sense of style):

suppose you have more then one \item (I use text for simplicity) inside an environment (definition, ...), then the gray background increase as the points go on, and it doesen't have the whole dimension from the start of frame (the standard for beamer):

suppose we want 3 incremental steps inside a definition:

1)

\begin{itemize}
    \item hallo \alert{world}
\end{itemize}

2)

\begin{itemize}
    \item hallo word
    \item the \alert{cat} is on the table
\end{itemize}

3)

\begin{itemize}
    \item hallo word
    \item the cat is on the table
    \item the \alert{windows} are open
\end{itemize}

A solution can be (thanks to the idea of tobias_k):

\begin{definition}
\begin{itemize}
    \only<1>{ % at #1 we need all space "covered" but only the first have to be shown
             \item hallo \alert{word}
             \item<2-> the cat is on the table % <2-> is for coerence: the only important thing is that it isn't <1-> or <1>
             \item<3> the windows are open % as above <3> is for coerence
             }
    \only<2->{ % from #2 the first is always on
             \item hallo word
             }
    \only<2>{ % at #2 only the second is highlight but we still need the third space "covered" and not shown
             \item the \alert{cat} is on the table
             \item<3> the windows are open
             }
    \only<3->{ % (from) #3 the second is always on too
             \item the cat is on the table
             }
    \only<3>{ % at #3 only the third is highlight (in this last case we can append the following line inside the last couple of brackets and delete this one )
             \item the \alert{windows} are open
            }
\end{itemize}
\end{definition}

And it replicate "exactly" (with the \alert!) what you see for:

\begin{definition}
\begin{itemize}
    \item<1-> hallo world
    \item<2-> the cat is on the table
    \item<3-> the windows are open
\end{itemize}
\end{definition} 

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.