# How to avoid beamer counter incrementing

In Latex beamer, I've created a handout environment for slides that are for the produced handout only (ie. not to be shown on the viewer). It looks like this:

\newenvironment{handout}[2][1]{
\begin{frame}<handout>[environment=handout,allowframebreaks]
}
{\end{frame}}


Key point in the above is: 1) <handout> ensures it is only visible on handout 2) allowframebreaks allows the handout to run over several slides.

OK so far. Only problem is that the framenumber counter (which is used to display page numbers) is incremented for each slide, which means that the handout material and the displayed material in the presentation gets out of sync. So I want to freeze the counter.

I tried simply to back up the current value of the framenumber counter to a temporary in the before part of the environment definition and reseting to that in the after part. That did however now work. Something like this:

\newenvironment{handout}[2][1]{
\begin{frame}<handout>[environment=handout,allowframebreaks]
\setcounter{backupcounter}{\value{framenumber}}
}
{\end{frame}\setcounter{framenumber}{\value{backupcounter}}}


So the question is basically, how do I avoid the counter incrementing over these slides?

-

## migrated from stackoverflow.comAug 28 '11 at 12:08

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – N.N. Sep 6 '11 at 14:06

## 1 Answer

Your solution works for me if you save the value of framenumber before starting the new frame (which makes it increase) like

\newenvironment{handout}{
\setcounter{backupcounter}{\value{framenumber}}
\begin{frame}<handout>[environment=handout,allowframebreaks]
}
{\end{frame}\setcounter{framenumber}{\value{backupcounter}}}

-
Indeed my bad about the placement of the backup of the counter. The problem still exists though, namely that if the frame runs over more than one page, the counter is only reset on the first of those pages. To clarify. Imagine we are at page 20, and a handout env with 10 pages are shown, then I expect the page after those ten pages to be labeled 21. However, it is labeled 30 (20 + (10 -1) +1) – user7688 Sep 6 '11 at 13:55
@Jesper: I converted the "answer" to a comment to smp's answer, this suits better. – Stefan Kottwitz Sep 6 '11 at 16:46