# Drawing a circle with nodes shift with Tikz

I am newby in Tikz and want to draw a circle with on it 16 circle-shaped nodes. Each slide increment would shift to the next node rightward or leftward ( an example with both should be fine), while highlighting it (the highlight should be about the current position/node). Anybody could help me achieving this ? An example of the drawing is attached :

Thank you

EDIT : This is a good start but i need circle shaped nodes not text with one node each time hightlighted (colored with blue) (the current position) and node shift could be right or left :

\documentclass{report}
\usepackage{tikz,calc}

\begin{document}
\begin{tikzpicture}
\foreach \a in {1,2,...,17}{
\draw (\a*360/17: 4cm) node{angle \a};
}
\end{tikzpicture}
\end{document}

• Welcome to TeX.SX! With what part are you having problems with? What have you tried so far? Also see this question which is similar. – siracusa Jul 18 at 15:53
• Thx pls see edit i need to move to the next or previous node on increment slide button – user1319236 Jul 18 at 16:07

I think something like this is what you're after.

\documentclass{beamer}
\usepackage{tikz}
% define a counter
\newcount\CircNum
% macro to hold a color name
\newcommand\Clr{black}
\begin{document}
\begin{frame}
% set up an animation, \CircNum changes from 1 to 17
% with each frame
\animatevalue<1-17>{\CircNum}{1}{17}
\begin{tikzpicture}
% draw the main circle
\node [circle, draw, minimum size=8cm] (c) {};

\foreach \a in {1,2,...,17}{
% if \a is equal to \CircNum, set the color to blue
% otherwise set it to black
\ifnum\a=\the\CircNum
\renewcommand\Clr{blue}
\else
\renewcommand\Clr{black}
\fi
% make a new node for the small circles
\node[\Clr, % with the color defined by the macro
draw, thick, % draw the outline
fill, % fill it
minimum size=5mm, % set the size
circle, % circular shape
label={[\Clr]\a*360/17+180:\a} % add the number on the inside
] at (c.\a*360/17) % position it on the edge of the main circle
{};
}
\end{tikzpicture}
\end{frame}
\end{document}


Here are the first three slides of the PDF:

• Thx its almost that except the current position / node should be all colored not just the periphery – user1319236 Jul 18 at 17:30
• @user1319236 Just add fill to the node options for the \node in the \foreach loop. – Torbjørn T. Jul 18 at 17:32
• Yep you got it right thx – user1319236 Jul 18 at 17:48

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\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\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}


...

...

• Thx for the answer maybe next time i use this in another project but for now i'm going to go with the solution not requiring additional package setup like the \usepackage{expl3} – user1319236 Jul 18 at 18:00
• +1, but I would have expected an l3draw circle :D – TeXnician Jul 18 at 19:32
• @TeXnician Thanks! Regarding l3draw, I believe its edges are still a bit rough for me. :-p – frougon Jul 18 at 19:38