1
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{intersections}
\begin{document}
%
\begin{tikzpicture}
    \node[name=w, rectangle, fill=darkgray, minimum width=3mm, minimum height = 6cm]{};
    \path[name path=wnw] (w.north west)--++(-6, 0);
    \path[name path=wv] (w.west)--++(128:6);
    \path [name intersections={of=wnw and wv, by={B}}];
    \draw (w.west)--(B);
\end{tikzpicture}
%
\end{document}

enter image description here

Question

Why the below approach does not work? (I get "undefined node" error.)

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{intersections}
\begin{document}
%
\begin{tikzpicture}
    \node[name=w, rectangle, fill=darkgray, minimum width=3mm, minimum height = 6cm]{};
    \path[name path=wnw] (w.north west)--++(-6, 0);
    \path[name path=wv] (w.west)--++(128:6);
    \coordinate (B) at (intersection of wnw and wv);
    \draw (w.west)--(B);
\end{tikzpicture}
%
\end{document}
blackened
  • 4,181
  • 1
    Why do you expect it to work? Is that syntax documented somewhere? – Torbjørn T. Aug 03 '17 at 18:29
  • @Torbjørn Looking at this answer, I was hoping it would work: https://tex.stackexchange.com/a/299185/48787 – blackened Aug 03 '17 at 18:45
  • 1
    Well, strictly speaking that syntax isn't documented (in the current manual) either. It was in version 2.0 though, before the introduction of the intersection library and name path. (If you're interested, download the source from https://sourceforge.net/projects/pgf/files/pgf/version%202.00/, find pgfmanual.pdf in doc/generic/pgf/, and look in section 12.2.4.) I would think that it doesn't work because it's not intended to work, but I don't know anything about the implementation. – Torbjørn T. Aug 03 '17 at 19:57

1 Answers1

1

Second example uses a deprecated syntax previous to intersections library, but it still works if you uses it correctly. The concept of named path doesn't exist and path are identified by two coordinates each one: A--B. Coordinates without parenthesis.

In your case, it's possible to write a path with w.north west--{++(-6,0)} where brackets hide the second coordinate parenthesis.

\documentclass[tikz, border=1cm]{standalone}
%\usetikzlibrary{intersections}
\begin{document}
%
\begin{tikzpicture}
    \node[name=w, rectangle, fill=darkgray, minimum width=3mm, minimum height = 6cm]{};
    \path (w.north west)--++(-6, 0);
    \path (w.west)--++(128:6);
    \coordinate (B) at (intersection of w.north west--{++(-6,0)} and w.west--{++(128:6)});
    \draw (w.west)--(B);
\end{tikzpicture}
%
\end{document}

enter image description here

Ignasi
  • 136,588