Note: I'm aware of another response here, but its solution was a quick-fix rather than the underlying issue.
Say I want to create the following diagram but using iteration:
\begin{tikzpicture}
\foreach \x/\y in {1/10,2/11,3/12,4/13,5/14,6/15}
{
\draw (\x,0) circle (7pt);
\draw (\x,0) node {$\y$};
}
\end{tikzpicture}
I could easily exploit the fact that tikz chooses an appropiate center so that
\begin{tikzpicture}
\foreach \x in {10,11,...,15}
{
\draw (\x,0) circle (7pt);
\draw (\x,0) node {$\x$};
}
\end{tikzpicture}
works just as well. But if I don't want to use this exploit, and try
\begin{tikzpicture}
\foreach \x/\y in {1/10,2/11,...,6/15}
{
\draw (\x,0) circle (7pt);
\draw (\x,0) node {$\y$};
}
\end{tikzpicture}
I get a bunch of errors, beginning with
Illegal unit of measure (pt inserted). [ }]
Two questions: it is possible to iterate over several variables in a list (let's assume the lists are large enough that it's not feasible to do each of the cases by hand as above), and what's causing the error?
Thanks
count
:\foreach [count=\x] \y in {10,11,...,15}{\draw (\x,0) circle (7pt);\draw (\x,0) node {$\y$};}
\foreach
with two variables and a list of values.pgf
isn't coded to support that syntax". So would you agree that we can close as a duplicate of my question?