I'm trying to use pgfmath to calculate a modular value. However, when I try to give this value as a label to a node, it does not compile.
The following code fails:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\N}{5}
\foreach \x in {0,...,\N}
{
\pgfmathtruncatemacro{\next}{Mod(\x+1,\N)}
\node at (\next,0) {\next};
% \node at (\next,0) {\x};
}
\end{tikzpicture}
\end{document}
It gives the error: "Missing } inserted. } l.16 }". Line 16 is the line with the "}".
The code where I replace the line with "\node" with the line that was commented out, it does compile (as an example). Could someone please explain what is going wrong, and how I can fix it?
I tried to do what is done in this answer, but math mode doesn't seem to help me.
Thanks!
pgfrcs.code.texline 67-73. The weird thing is that PGF usually protects itsnext, such as\@nextintikz.code.tex. – Symbol 1 May 01 '17 at 20:25\nextfor plain TeX compatibility looking for package input before loading anything yet. – percusse May 01 '17 at 21:07\nextnodeand add\tracingmacros1(even inside a group) around the\nodepart and then view your.log, you'll see some reference to\nextthat still exists. – Werner May 01 '17 at 21:39\nextthat come fromtikz.code.tex. So my previous comment is totally wrong. – Symbol 1 May 01 '17 at 21:43\nextis probably used to absorb the{in the construction\node{text};. – Symbol 1 May 01 '17 at 21:49