draw every 12th circle in red with tikz

As I said in my comment, \ifnum \x=12\relax...\else...\fi can be used to determine the 12th loop. But if you need to find multiples of 12, I here use a separate index cindex, that tracks with \x, but is reset to 0 whenever it reaches 12.

\documentclass{article}
\usepackage{tikz}
\newcounter{cindex}
\begin{document}
    \begin{tikzpicture}
    \draw (0,0) -- (\textwidth,0);
    \setcounter{cindex}{0};
    \foreach \x in {0,...,24} %
    {%
        \stepcounter{cindex};
        \ifnum \thecindex=12\relax
            \setcounter{cindex}{0};
            \draw[red](\x\textwidth/30,0) circle (1);
        \else
            \draw (\x\textwidth/30,0) circle (0.5);
        \fi%
    }
    \end{tikzpicture}
\end{document}

enter image description here


A different version:

\documentclass{article}
\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}
    \newcommand\Ncirc{24} % number of circles
    \draw (0,0) -- (\textwidth,0);
    \foreach [count=\i from 0,evaluate=\i as \y using {int(mod(\i,\Ncirc/2))}] \x in {0,...,\Ncirc} %
    { %
        \ifnum\y=0
            \draw[red](\x\textwidth/\Ncirc,0) circle (1);
        \else
            \draw (\x\textwidth/\Ncirc,0) circle (0.5);
        \fi
    }
    \end{tikzpicture}
\end{document}

enter image description here

Tags:

Tikz Pgf