Graphics, Figures & TablesBeamer: Counters with overlays

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kliper
Posts: 2
Joined: Mon Mar 15, 2010 10:05 pm

Beamer: Counters with overlays

Post by kliper »

Hi Guys,

I am trying to use the counter with an animated slideshow using the beamer class.
The below code works eventually (meaning it does what I wanted) creating node by node and numbering it in increasing order.
But, it does not compile well, it says the counter cnt is already defined:

! LaTeX Error: Command \c@cnt already defined.
Or name \end... illegal, see p.192 of the manual.

I looked every where and cant find a solution, How can I avoid this problem?

Please Help ...




\documentclass[brown]{beamer}

\mode<presentation>
{
\usetheme{Warsaw}
}

%%%%% My included packages %%%%%%%%%%%%%
\usepackage{tikz} %To use tikzpicture
\usetikzlibrary{calc}

\beamerdefaultoverlayspecification{<+->}

\begin{document}

\begin{frame}
\newcounter{cnt}
\setcounter{cnt}{1}
\resetcounteronoverlays{cnt}

\begin{tikzpicture}
\foreach \x in {(1,2),(2,4),(5,5)}{
\node [draw, circle ,fill=green!50,inner sep=0pt, minimum size = 6mm] at \x (p$\thecnt$){$\thecnt$};
\stepcounter{cnt}
\pause
}
\end{tikzpicture}

\end{frame}
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Beamer: Counters with overlays

Post by localghost »

Just rename the counter »cnt«.


Best regards and welcome to the board
Thorsten
kliper
Posts: 2
Joined: Mon Mar 15, 2010 10:05 pm

Re: Beamer: Counters with overlays

Post by kliper »

Hi
Thanks for the replay.
Renaming the counter does not solve the problem. (You can try the code I posted)
This is since I am using overlays. The counter is redefined every time (and every slide) (what ever it is called) I need some kind of way to define it from outside or to let it know not to redefine it.

Thanks

Roi
Post Reply