5

I have problems with using path names defined even in the same loop. the following code produces error message:

 ! Package tikz Error: I do not know the path named `ab6'. Perhaps you misspelt it.

The code:

\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows,chains,positioning,intersections}
\usetikzlibrary{calc}
\usepackage{ifthen}
\usepackage{tikz-3dplot}
%
%
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\begin{document}
%
\center
\tdplotsetmaincoords{47}{5}
\begin{tikzpicture}[scale=4,tdplot_main_coords]
\foreach\i in {0,...,6}
{\tdplotsetcoord{A\i}{1}{8+51.4*\i}{0};
\coordinate(B\i) at ([shift={(0,1.2,0)}]A\i);}
\foreach \k[evaluate=\k as \ki using {int(mod(\k+3,7))}] in {0,...,6}
{\path[%draw%
,thick,name path = pa\k](A\k)--(A\ki);
\path[%draw%
,thick,name path = pb\k](B\k)--(B\ki);
}
\foreach \j in {0,...,6}
{%\node at (C\j){$C_\j$};
\node at (A\j){$A_\j$};
%\node at (D\j){$D_\j$};
\node at (B\j){$B_\j$};
}
\foreach \j[evaluate={\ja={int(mod(\j+2,7))};\jc={int(mod(\j+6,7))}}] in  {0,...,6}
{
\path[name path=ba\j,draw](B\j)--(A\ja);
\path[name path=ab\j,draw](A\j)--(B\ja);
\path[name intersections={of={ba\j} and {ab\jc},by={C\j}}];
}
%\path[name intersections={of={ba0} and {ab6},by={C0}}]
\end{tikzpicture}
\end{document}

I've tried

name path global

and

name path globa/.expanded

but neither helps. When I comment the line causing this problem and uncomment

\path[name intersections={of={ba0} and {ab6},by={C0}}]

Then TikZ says it doesn't know the path named `ba0'.

5

In the first iteration of the loop \j is 0 but \jc is 6 and you are trying to do

  \path[name intersections={of={ba\j} and {ab\jc},by={C\j}}];

that is, finding intersections of ba0 and ab6, but ab6 doesn't yet exist. Use two separate loops:

\documentclass[12pt]{article}
\pagestyle{empty}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows,chains,positioning,intersections}
\usetikzlibrary{calc}
\usepackage{ifthen}
\usepackage{tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{47}{5}
\begin{tikzpicture}[scale=4,tdplot_main_coords]
\foreach\i in {0,...,6}
{\tdplotsetcoord{A\i}{1}{8+51.4*\i}{0};
\coordinate(B\i) at ([shift={(0,1.2,0)}]A\i);}
\foreach \k[evaluate=\k as \ki using {int(mod(\k+3,7))}] in {0,...,6}
{\path[%draw%
,thick,name path = pa\k](A\k)--(A\ki);
\path[%draw%
,thick,name path = pb\k](B\k)--(B\ki);
}
\foreach \j in {0,...,6}
{%\node at (C\j){$C_\j$};
\node at (A\j){$A_\j$};
%\node at (D\j){$D_\j$};
\node at (B\j){$B_\j$};
}

\foreach \j [evaluate={\ja={int(mod(\j+2,7))};\jc={int(mod(\j+6,7))}}] in  {0,...,6}
{
\path[name path global=ba\j,draw](B\j)--(A\ja);
\path[name path global=ab\j,draw](A\j)--(B\ja);
}

\foreach \j [evaluate={\ja={int(mod(\j+2,7))};\jc={int(mod(\j+6,7))}}] in  {0,...,6}
  \path[name intersections={of={ba\j} and {ab\jc},by={C\j}}];

\path[name intersections={of={ba0} and {ab6},by={C0}}];
\end{tikzpicture}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.