Using the \foreach statement, I generate a set of lines that form a grid. I want to use the loop variables to name the individual paths to later draw something at their intersections.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\newlength{\vlinedist}
\setlength{\vlinedist}{.4cm}
\newlength{\hlinedist}
\setlength{\hlinedist}{.4cm}
\usetikzlibrary{intersections}
\begin{tikzpicture}
\foreach \x in {1,...,10}
{
\draw[name path global/.expanded=h \x] (0,\hlinedist*\x) -- ++(33*\vlinedist,0);
}
\foreach \x in {1,...,32} {
\draw[name path global/.expanded=v \x] (\vlinedist*\x, 0) -- ++(0,11*\hlinedist);
}
\foreach \x in {1,...,10}
{
\foreach \y in {1,...,32}{
\draw[name intersections={of=h \x and v \y}] (intersection-1) circle (2pt);
}
}
\end{tikzpicture}
\end{document}
From this question I found I must use the global/.expanded stuff in order for the paths to be named (whatever the reason). But when trying to reference the different paths in the intersections={of=h \x and v \y} part, this does not work, I get the error:
Runaway argument?
h \x and v \y \tikz@stop \else \pgfkeys@case@two \fi \fi \fi \pgfkeys@parse \ET
C.
! File ended while scanning use of \tikz@intersect@path@names@parse.
<inserted text>
\par
<*> file.tex
?
Now I know there are other ways to make a grid and place points at some chosen intersections, however that is beside the point, as this is a rather general question of how I can use loop variables to reference named paths in tikz.
