I draw two circles and name their path inside a \foreach loop. Trying to name intersections of these two paths throws an error unless I name a third path.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\foreach \s in {+,-} {
\draw [name path={C\s}] (\s1,0) circle (1.5);}
\draw [name path=Ca] (0,1) circle (1.5); % <- comment line to see error
\path [name intersections={of=C- and C+}];
\draw [dashed] (intersection-1) -- (intersection-2);
\end{tikzpicture}
\end{document}
Without the marked line commented, the error message reads:
Package tikz Error: I do not know the path named `C-'. Perhaps you misspelt it. ...\path [name intersections={of={C-} and C+}];
To me, this seems to be a bug. - Or am I doing something wrong?
\draw [name path global={C\s}] (\s1,0) circle (1.5);. This works. But it also works when you put any path (you do not have to name it) before\path [name intersections={of=C- and C+}];. Strange. – Mar 22 '18 at 09:41name intersectionshould consistently not work outside the loop. – FlorianL Mar 22 '18 at 10:00The code in the foreach loop is in a TeX group, so all definitions are local to this group.If you place the uncommented line before the foreach, it does not work nether. That mean that there a something strange happens (bug ?). – Tarass Mar 22 '18 at 11:54