beamer
beamer copied to clipboard
Enhance documentation
Sometimes the overlay counter has weird behavior.
Next document creates exactly 2 slides, but when the \mathrlap
line is uncommented then 6 slides are created.
This is due to the fact that \mathrlap
executes its argument multiple times thus incrementing the overlay counter more than expected.
\documentclass{beamer}
\usepackage{mathtools}
\begin{document}
\begin{frame}
This is slide \insertslidenumber\\
\visible<+->{$\mathrlap{\mbox{From slide 1}}$}\\
%$\mathrlap{\visible<+->{\mbox{From slide 2}}}$\\
\visible<+->{From slide 3}
\end{frame}
\end{document}
I could not find in the documentation mention of this feature such that solving this problem might be difficult for an average user. May be a section about troubles and limitations would help.
related https://github.com/josephwright/beamer/issues/624
In principle of course it's not just beamer, everything gets evaluated 4 times, and latex counter settings are global.
You could reset them all (as tabularx
does) but possibly just resetting the affected ones is better here, something like
\documentclass{beamer}
\usepackage{mathtools}
\makeatletter
\def\mathpalette#1#2{%
\edef\mathchoice@counter@reset{\global\c@beamerpauses=\the\c@beamerpauses\relax}%
\mathchoice
{\mathchoice@counter@reset#1\displaystyle{#2}}%
{\mathchoice@counter@reset#1\textstyle{#2}}%
{\mathchoice@counter@reset#1\scriptstyle{#2}}%
{\mathchoice@counter@reset#1\scriptscriptstyle{#2}}}
\makeatother
\begin{document}
\begin{frame}
This is slide \insertslidenumber\\
\visible<+->{$\mathrlap{\mbox{From slide 1}}$}\\
$\mathrlap{\visible<+->{\mbox{From slide 2}}}$\\
\visible<+->{From slide 3}
\end{frame}
\end{document}