# Counters incremented too many times in a beamer presentation with overlays

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

• beamer treats every slide as a separate chunk of code and executes them as many times as the number of slides. So it reads the counter incrementing lines more than you issue them. – percusse Sep 15 '14 at 20:49

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}


See section 9.6 of the manual

• Simple as that... I lost one hour today because of this tiny issue! Thank you. – remjg Sep 15 '14 at 21:05
• thank you very much, I tried to obtained this long, not obvious to find it in a doc. – lehalle Feb 11 '15 at 22:04