Code: Select all
\begin{tikzpicture}
\tikzstyle{every node}=[draw,shape=circle];
\foreach \n in {1,...,5} {
\path (\n*360/5:1cm) node (\n) {\n};
}
\draw (1) -- (2) -- (3) -- (4) -- (5) -- (1);
\end{tikzpicture}
Code: Select all
\begin{tikzpicture}
\tikzstyle{every node}=[draw,shape=circle];
\foreach \n in {1,...,5} {
\path (\n*360/5:1cm) node (\n) {\n};
}
\foreach \n in {1,...,4} {
\draw (\n) -- (\n+1);
}
\draw (5) -- (1);
\end{tikzpicture}
I get the following error messages (the last one is not appearing correctly):
! Package pgf Error: No shape named 1+1 is known.
! Package pgf Error: No shape named 1+1 is known.
! Package pgf Error: No shape named 2+1 is known.
! Package pgf Error: No shape named 3+1 is known.
! Package pgf Error: No shape named 4+1 is known.
Why won't this work right?! Undefined control sequence.
\endtikzpicture ...icturepositiononpage \endscope
\let \pgf@baseline =\pgf@s...
l.156 \end{tikzpicture}
Thanks.
P.S. Since you're answering that question, how 'bout also telling me how to use a variable for the 5 in the \foreach loop, so I can do something like this
Code: Select all
\begin{tikzpicture}
\tikzstyle{every node}=[draw,shape=circle];
\foreach \n in {1,...,\T} {
\path (\n*360/\T:1cm) node (\n) {\n};
}
\draw (1) -- (2) -- (3) -- (4) -- (5) -- (1);
\end{tikzpicture}