Welcome to TeX.SE!
Here is a solution that borrows \int_step_variable:nnnNn
from expl3
:
\documentclass{beamer}
\usepackage{expl3}
\usepackage{tikz}
\ExplSyntaxOn
% Borrow a loop macro from expl3
\cs_set_eq:NN \intstepvariable \int_step_variable:nnnNn
\ExplSyntaxOff
\begin{document}
\begin{frame}{Circles in circle}
\begin{center}
\begin{tikzpicture}
\def\nsteps{10}
\def\bigcircleradius{3cm}
\def\smallcirclewidth{0.5cm}
% The big circle
\node[circle, minimum width=2*\bigcircleradius, draw] (C) {};
% The small circles and their labels
\intstepvariable{0}{1}{\nsteps - 1}{\i}{% {init}{step}{final}{variable}
\pgfmathsetmacro{\angle}{90 - \i*360/\nsteps}
\pgfmathsetmacro{\otherside}{\angle+180}
\pgfmathsetmacro{\iplusone}{int(\i+1)}
\pgfmathsetmacro{\iplustwo}{int(\i+2)}
\uncover<\iplustwo-> {
\node[circle, draw, minimum width=2*\smallcirclewidth,
label=\otherside:\iplusone] at (C.\angle) {};
}
\uncover<\iplustwo> { % fill one small circle per frame
\node[circle, fill=red!20, minimum width=2*\smallcirclewidth]
at (C.\angle) {};
}
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
...
...
Note: as an alternative to the following code:
\pgfmathsetmacro{\iplustwo}{int(\i+2)}
(...)
\uncover<\iplustwo-> { (...) }
\uncover<\iplustwo> { (...) }
one could use, assuming e-TeX extensions are available:
\uncover<\the\numexpr \i+2\relax-> { (...) }
\uncover<\the\numexpr \i+2\relax> { (...) }
Now, let's redo the same beamer
presentation, but using a more straightforward order (small circles at angles 1*360/10, 2*360/10, ..., 10*360/10 degrees, respectively). The main code is written in a (slightly) different way from the previous example: it uses two loops and the \pause
macro from beamer
, whereas the first example did everything in one loop, and used only \uncover
.
\documentclass{beamer}
\usepackage{expl3}
\usepackage{tikz}
\ExplSyntaxOn
% Borrow a loop macro from expl3
\cs_set_eq:NN \intstepvariable \int_step_variable:nnnNn
\ExplSyntaxOff
\begin{document}
\begin{frame}{Circles in circle}
\begin{center}
\begin{tikzpicture}
\def\nsteps{10}
\def\bigcircleradius{3cm}
\def\smallcirclewidth{0.5cm}
% The big circle
\node[circle, minimum width=2*\bigcircleradius, draw] (C) {};
% The filled circles: highlight a single small circle on each frame starting
% from frame 2.
\intstepvariable{2}{1}{\nsteps+1}{\i}{% {init}{step}{final}{variable}
\pgfmathsetmacro{\angle}{(\i-1)*360/\nsteps}
\uncover<\i>{
\node[circle, fill=red!20, minimum width=2*\smallcirclewidth]
at (C.\angle) {};
}
}
% The unfilled circles and their labels
\intstepvariable{1}{1}{\nsteps}{\i}{% {init}{step}{final}{variable}
\pgfmathsetmacro{\angle}{\i*360/\nsteps}
\pgfmathsetmacro{\otherside}{\angle+180}
\pause
\node[circle, draw, minimum width=2*\smallcirclewidth, label=\otherside:\i]
at (C.\angle) {};
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}
...
...