I am quite new to TikZ. I have the following code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{chains}
\begin{document}
\begin{tikzpicture}[start chain=circle placed {at=(\tikzchaincount*30:1.5)},
regular/.style={draw,circle,inner sep=0,minimum size=4mm}]
\foreach \i in {0,...,11}
\node [on chain, regular] (\i) {\i};
\foreach \i in {0,...,11}
\draw [->] (\i) to ({\pgfmathparse{int(mod(\i+1,12))}\pgfmathresult});
\end{tikzpicture}
\end{document}
What I intended to do is to draw a series of 12 nodes evenly placed on a circle, and draw an arrow between every two neighbors. LaTeX gave an error message saying
!incomplete \iffalse; all text was ignored after ...
What is the correct way to do what I intended?
Best Answer
When using macros in node names, the macros have to be expandable in an
\edef
context.\pgfmathparse
is not. So you need to do the computation beforehand and only use the result of it in the node name. One way is to use theevaluate
key on the\foreach
as in the following.