6

In beamer, overlay specifications can be used to make certain text commands take effect at different times. For example, \alert<2> applies the alert command only on the second slide.

Is there an equivalent for the cancel command instead on the alert command ?

Marco
  • 4,435
  • 1
    Take a look at my answer to this question: http://tex.stackexchange.com/questions/11571/uncover-a-multiline-equation-with-beamer/11617#11617 as there I defined an overlay-aware version of the cancel command. Does that do what you want? – Andrew Stacey Sep 21 '11 at 10:09
  • @Andrew Stacey: Great !!! This is exactly what I want :-) Thanks! – Marco Sep 21 '11 at 11:53
  • I've copied my code so that it's easier to find: the questions are sufficiently different that I don't think this is a duplicate. It's just coincidence that my answer to that one involved the cancel stuff. – Andrew Stacey Sep 21 '11 at 12:04

1 Answers1

8

(Although my answer at Uncover a multiline equation with beamer covers this case, the actual questions aren't duplicates so I'm copying the code here to make it easier for a casual "passer-by" to find it.)

Here's an overlay-aware version of the \xcancel command. I've written it as a wrapper rather than a replacement, but it wouldn't be hard to do the latter instead.

\documentclass{beamer}
\usepackage{amsmath}
\usepackage{cancel}
\newcommand<>{\xxcancel}[1]{\alt#2{\xcancel{#1}\vphantom{#1}}{#1}}
\begin{document}

\begin{frame}
    \begin{multline*}
        S(1,\dots,s) = \underbrace{\sum_{m=1}^{m_t} (-1)^{m+1} \sum_{i_1<\dots<i_m} I(i_1,\dots,i_m)}_{\text{entropy estimate with correlation order}\, m_t} \\
        \xxcancel<2->{{} + \underbrace{\sum_{m=m_t+1}^{s} (-1)^{m+1} \sum_{i_1<\dots<i_m} I(i_1,\dots,i_m)}_{\text{correlations of order higher than}\, m_t} }
    \end{multline*}
\end{frame}

\end{document}
Moriambar
  • 11,466
Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751
  • 1
    Thank for this neat solution. I'm believe it's better to rather write \newcommand<>{\xxcancel}[1]{\alt#2{\xcancel{#1}}{#1\vphantom{#1}}} so that the vertical space is reserved before and not after the right overlay, at least it works better in my code without any shifting. – Laurent Jacques Mar 06 '23 at 13:23