[Tex/LaTex] LaTeX listing counter counts with every \pause-command

beamerlistingspause

I'm writing a TeX-File for a beamer presentation and have a problem with the \pause-command and the listing counter:

The Listing counter increments its count with every \pause command – although I don't change the frame or anything at the code. This looks very ugly. So I need to either stop the counter from incrementing its count with every \pause command or turn off the counter at all – and I couldn't even find out how this works.

Can someone please help me?

Here some of my listings-Setting:

\definecolor{kit-gray}{RGB}{224,224,224}
\definecolor{kit-green}{RGB}{32,149,128}
\usepackage{listings}
\usepackage{courier}
\lstset{
     basicstyle=\scriptsize\ttfamily, 
     numbers=left,              
     numberstyle=\tiny,         
     %stepnumber=2,                 
     numbersep=5pt,              
     tabsize=2,                         
     extendedchars=true,         
     breaklines=true,               
     %keywordstyle=\color{red},
     frame=t,         
 %frameround=tftf, 
     keywordstyle=[1]\textbf,       
     stringstyle=\color{blue}\ttfamily,     
     showspaces=false,              
     showtabs=false,                
     xleftmargin=17pt,
     framexleftmargin=17pt,
     framexrightmargin=6pt,
     framexbottommargin=4pt,
     backgroundcolor=\color{kit-gray},
     commentstyle=\color{kit-green},
     showstringspaces=true          
     %numberbychapter=false
}

Best Answer

As you are aware, beamer will create a new page for each overlay. Each time a page containing a lstlisting environment is created the counter lstlisting is incremented. As this goes for any counter (tables, figures, etc.) beamer supports resetting the counter on overlays. Place

\resetcounteronoverlays{lstlisting}

in the preamble and your problem should be resolved.

Related Question