Graphics, Figures & Tables ⇒ Beamer: Counters with overlays
Beamer: Counters with overlays
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}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Beamer: Counters with overlays
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Beamer: Counters with overlays
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