I'm trying to draw a diagram with a bunch of nodes determined using partway calculations. I made a definition using \def\x{.35}
to store the partway distance (because I want to use the same distance in a bunch of calculations). (In particular, I want to draw some nodes that are equally spaced on the side of a line, but offset, kind of.)
When I try to use the \x value in a calculation (the commented out line below) where I'm also using a let statement (so that I can do modular arithmetic), it gives me the error Argument of \x has an extra }. Inserted text \par
.
If I replace \x with its value .35 in the \path command, everything compiles. The problematic line is commented out in the MWE below.
(I tried enclosing the \x in braces; no good. I tried putting it in the let statement as let \n1 = ..., \n2 = {\x} in ...
and that didn't work either.)
What is it about this command instead of the previous ones that TikZ doesn't like?
A minimal-ish working example:
\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\def\z{.1}
\def\x{.35}
\begin{tikzpicture}[vtx/.style={draw, circle, gray, font=\tiny, inner sep = 1 pt}, flag/.style={draw, circle, font=\tiny, inner sep = 1 pt}, scale = 3]
\node[vtx] (v0) at (0,0){$0$};
\foreach \i in {0, ..., 5}{
\node[vtx] (v1 \i) at (360*\i/6:1){$1_{\i}$};
\path let \n1 = {int(mod(\i+1, 6))} in node[vtx] (v4 \i) at ($(360*\n1/6:1)+(360*\n1/6-30:1)$){$4_{\i}$};
}
\foreach \i in {0, ..., 5}{
\node[flag] (0 \i) at ($(v0)!\x!(v1 \i)!\z!90:(v1 \i)$){};
\node[flag, fill=red] (b \i) at ($(v1 \i)!\x!(v4 \i)!\z!90:(v4 \i)$){};
%\path let \n1 = {int(mod(\i+1, 6))} in node[flag] (8 \i) at ($(v4 \i)!\x!({v1 \n1})!\z!90:({v1 \n1})$){};
}
\end{tikzpicture}
\end{document}
\x
and\z
. Change them to e.g.\XX
and\ZZ
. – user121799 Feb 9 '18 at 7:00