[Tex/LaTex] Counters incremented too many times in a beamer presentation with overlays

beamercountersoverlays

It seems that a frame with overlays in Beamer needs to be processed multiple times. The problem is that a counter that should only be incremented once is incremented more than expected.

How to avoid counters to be incremented multiple times in a Beamer presentation with overlays ?

Minimal working example

\documentclass{beamer}
\newcounter{Test}

\begin{document}
\begin{frame}
  \begin{itemize}
    \item Should be 0: \theTest
    \stepcounter{Test}\pause
    \item Should be 1: \theTest
    \stepcounter{Test}\pause
    \item Should be 2: \theTest
    \stepcounter{Test}\pause   
  \end{itemize}
\end{frame}
\end{document}

Output

Output

Best Answer

Add \resetcounteronoverlays{Test} to your preamble

\documentclass{beamer}
\newcounter{Test}
\resetcounteronoverlays{Test}

\begin{document}
\begin{frame}
  \begin{itemize}
    \item Should be 0: \theTest
    \stepcounter{Test}\pause
    \item Should be 1: \theTest
    \stepcounter{Test}\pause
    \item Should be 2: \theTest
    \stepcounter{Test}\pause
  \end{itemize}
\end{frame}
\end{document}

enter image description here

See section 9.6 of the manual