3

My question is related to this one : Latex - Beamer: Applies the \cancel command only a specified slides. I tried to apply Loop Space's answer to this question, but I get a line jump when the xcancel appears. Can anyone help ? Here is a MWE :

\documentclass{beamer}
\usepackage[makeroom,thicklines]{cancel}
\renewcommand{\CancelColor}{\color{red}}
\newcommand<>{\xxcancel}[1]{\alt#2{\xcancel{#1}\vphantom{#1}}{#1}}%uncover the xcancel command
\begin{document}
\begin{frame}{Test Beamer xxcancel}
$\tilde{\chi}^{-1}\left(\mathbf{q},\omega\right)={\chi^{-1}\left(\mathbf{q},\omega\right)}
{- \xxcancel<2->{{} \dfrac{\lambda^{2}\cdot q^{2}}{C_{s,0}\cdot q^{2}+\omega^{2}}}}$
\end{frame}
\end{document}
pmassat
  • 115

1 Answers1

5

The \xcancel macro is adding a bit of extra space, so we need to make sure that the two versions take up the same amount of space. To deal with the horizontal space, the simplest fix is to remove the makeroom option. To deal with the vertical, we add a \vphantom to the non-cancelled part. (Indeed, I'm not at all sure why there's a \vphantom in the cancelled part since the cancelled version is bound to take up more vertical space than the non-cancelled one.)

There may well be better solutions, but in the meantime the above does seem to work:

\documentclass{beamer}
%\url{http://tex.stackexchange.com/q/362077/86}
\usepackage[thicklines]{cancel}
\renewcommand{\CancelColor}{\color{red}}
\newcommand<>{\xxcancel}[1]{\alt#2{\xcancel{#1}}{\vphantom{\xcancel{#1}}#1}}%uncover the xcancel command
\begin{document}
\begin{frame}{Test Beamer xxcancel}
$\tilde{\chi}^{-1}\left(\mathbf{q},\omega\right)={\chi^{-1}\left(\mathbf{q},\omega\right)}
{- \xxcancel<2->{{} \dfrac{\lambda^{2}\cdot q^{2}}{C_{s,0}\cdot q^{2}+\omega^{2}}}}$
\end{frame}
\end{document}
Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751