[Tex/LaTex] Continuing enumerate Counters in Beamer

#enumeratebeamerlists

I'm trying to continue the numbering of examples in enumerate environments in beamer. For example, I'd like one slide to feature

  1. Foo
  2. Bar

and the next slide

  1. Zip
  2. Yadda

My strategy so far has been to define a counter that saves the enumerate counter at the end of the first environment and can then be queried to set the enumerate counter at the start of the second enumerate environment. (This is essentially the proposal also found at How to Continue Enumerate Across Columns in Beamer)

That works wonderfully so long as I don't try to uncover elements of the slide sequentially. The problem, of course, is that as each of the pdf-pages that make up the slide is created, the counter is advanced. Here's a MWE.

\documentclass{beamer}

\setbeamercovered{highly dynamic}

\newcounter{saveenumi}
\newcommand{\seti}{\setcounter{saveenumi}{\value{enumi}}}
\newcommand{\conti}{\setcounter{enumi}{\value{saveenumi}}}


\begin{document}

\begin{frame}[<+->]
  \begin{enumerate}
  \item foo
  \item bar%
    \seti
  \end{enumerate}
\end{frame}

\begin{frame}[<+->]
  \begin{enumerate}
    \conti
  \item zip
  \item yadda%
    \seti
  \end{enumerate}
\end{frame}

\end{document}

As the second slide is progressively uncovered (pages 3 and 4 of the resulting PDF), the counter at the beginning of the enumerate environment is advanced each time. So page 3 of the PDF has the right numbering, (3) and (4) respectively, while the fully revealed page has the wrong numbering. Pictures follow:

on one of the slides

Page3

on the following one

Page4

Best Answer

Use \resetcounteronoverlays to ensure that your counter is automatically reset on subsequent slides of a frame:

\resetcounteronoverlays{saveenumi}

A complete example using your code:

\documentclass{beamer}
\setbeamercovered{highly dynamic}

\newcounter{saveenumi}
\newcommand{\seti}{\setcounter{saveenumi}{\value{enumi}}}
\newcommand{\conti}{\setcounter{enumi}{\value{saveenumi}}}

\resetcounteronoverlays{saveenumi}

\begin{document}

\begin{frame}[<+->]
  \begin{enumerate}
  \item foo
  \item bar%
    \seti
  \end{enumerate}
\end{frame}

\begin{frame}[<+->]
  \begin{enumerate}
    \conti
  \item zip
  \item yadda%
    \seti
  \end{enumerate}
\end{frame}

\end{document}

enter image description here

enter image description here