I would like to draw with \foreach
command but in below example, the first tikzpicture
works fine, the second one doesn't.
But I think the second one should be the same as the first one. Why doesn't it work?
\documentclass[border=10mm]{standalone}
\usepackage{tikz}
\begin{document}
% This one works
\begin{tikzpicture}
\draw[black] (0,0) \foreach \x/\y in {1/1,1/1.732} {
-- (\x,\y)
} -- cycle;
\end{tikzpicture}
% This one doesn't work
\begin{tikzpicture}
\draw[black] \foreach \x/\y in {0/0,1/1,1/1.732} {
(\x,\y) --
} cycle;
\end{tikzpicture}
\end{document}
\draw[black] (0,0) \foreach \x/\y [remember=\x as \xold (initially 0),remember=\y as \yold (initially 0)] in {1/1,1/1.732} {% -- (\x,\y) -- (\xold,\yold) };