# Place coordinates in a circle with foreach with tikz

I tried to place coordinates as a circle and use them later to draw lines between the coordinates. To do so I thought it should be possible to use a foreach loop which works out perfectly if I use nodes, but not with coordinates. What is my mistake? Or does the loop just not work with coordinates? Thanks for your help.

\foreach \pos/\name in {{(60:4)/1}, {(30:4)/2}, {(0:4)/3}, {(330:4)/4}, {(300:4)/5}, {(270:4)/6}, {(240:4)/7}, {(210:4)/8}, {(180:4)/9}, {(150:4)/10}, {(120:4)/11}, {(90:4)/12}}
\coordinate (\name) at \pos {};
\draw (1) -- (2);
\draw (3) -- (5) -- (4) -- (7);
\draw (8) -- (9) -- (12) -- (10) -- (11);

• \coordinate (\name) at (\pos);  ? coordinates works in loop on the very same way as nodes, however you should use correct syntax for it. – Zarko Apr 1 '18 at 8:37
• How about \foreach \pos / \name in {60:4/1, 30:4/2, 0:4/3, 330:4/4, 300:4/5, 270:4/6, 240:4/7, 210:4/8, 180:4/9, 150:4/10, 120:4/11, 90:4/12} \coordinate (\name) at (\pos);? – Jeroen Zuiddam Apr 1 '18 at 8:55

\foreach is more powerful. Option evaluate can be used to calculate the angle:

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}
\draw
\foreach \i [evaluate=\i as \angle using 90 - \i * 30] in {1, ..., 12} {
(\angle:4) coordinate (\i)
}
(1) -- (2)
(3) -- (5) -- (4) -- (7)
(8) -- (9) -- (12) -- (10) -- (11)
;
\end{tikzpicture}
\end{document}


I think the following works:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\foreach \pos / \name in {60:4/1, 30:4/2, 0:4/3, 330:4/4, 300:4/5, 270:4/6, 240:4/7, 210:4/8, 180:4/9, 150:4/10, 120:4/11, 90:4/12} \coordinate (\name) at (\pos);
\draw (1) -- (2);
\draw (3) -- (5) -- (4) -- (7);
\draw (8) -- (9) -- (12) -- (10) -- (11);
\end{tikzpicture}
\end{document}

• you can read this in my comment :-) – Zarko Apr 1 '18 at 11:34