1

I'm trying to combine the syntax for orthogonal edges (p |- q) with the syntax for calculation relative coordinates ($ (a) + (1,0) $). Example:

\draw ($ (node1.south) + (1,0) $) to ( ($ (node1.south) + (1,0) $) |- node2.north);

However, I get an error:

Package pgf Error: No shape named ($ (node1 is known.

There is an obvious work-around in this case, but for educational purpose I'd like to understand why this syntax does not work, and how to solve the problem in general? Intuitively the documentation would suggest that I can simply combine these two syntaxes.

Update -- MWE:

\documentclass{report}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\node at (0,  0) (node1) {Hello};
\node at (0, -2) (node2) {World};

% working:
\draw ($ (node1.south) + (1,0) $) to ( node1.south |- node2.north);

% not working:
\draw ($ (node1.south) + (1,0) $) to ( ($ (node1.south) + (1,0) $) |- node2.north);

\end{tikzpicture}
\end{document}
bluenote10
  • 1,479
  • It would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem, and shows what you have tried. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. –  Apr 17 '14 at 11:54
  • Most likely, node1 has never been defined before. – Claudio Fiandrino Apr 17 '14 at 11:55
  • Try moving the ( following to to the front of node2.north in the last not working line. – Jesse Apr 17 '14 at 12:35
  • @Jesse: This compiles but is not semantically equivalent (you are connecting 3 points instead of 2, and the middle point is only meant as a means for construction, not as a point for drawing). – bluenote10 Apr 17 '14 at 12:41
  • @percusse: Yes indeed, if only I knew that !.5! has anything to do with coordinate calculation :). – bluenote10 Apr 17 '14 at 13:14

1 Answers1

1

Disclaimer: I'm trying to answer my own question despite severe lack of knowledge...

After a closer examination of related problems, I have found that combining this and that answer serves as an appropriate answer to my question as well (my question might be marked as duplicate although the respective questions go into a slightly different direction).

For future Tikz learners I add an example of the probably most convenient workaround, i.e., introducing temporary node names:

\draw ($ (node1.south) + (1,0) $) coordinate(temp) to (temp |- node2.north);
bluenote10
  • 1,479