The following code attempts to absolutely position two nodes with rectangular outlines, then draw a line that goes from the right-hand side of one to the left-hand side of the other, along orthogonal lines with the vertical segment lying directly between the two nodes. But instead of getting that result, this happens:

alt text

I can't get the hang of how LaTeX and TikZ length commands work. How can I fix what I've got here?





[yscale = -1]

\begin{scope} % Boxes
[ every node/.style = { draw,
                        inner sep = 3mm,
    \node (a) at (0,20mm) {Apple};
    \node (b) at (28mm,0) {Banana};

\begin{scope} % Arrows
[->, > = angle 90, very thick]
    \setlength{\mylengthC}{\mylengthA/2 + \mylengthB/2}
    \draw (\mylengthA,20mm) -- (\mylengthC,20mm) |- (\mylengthB,0);



This works:

% mark the midpoint between nodes a and b
\path (a.east) -- (b.west) node[coordinate,midway] (c) {};
% Arrows
\draw[->,>=angle 90, very thick] (a.east) -| (c) |- (b.west);

You almost never have to use \pgfextracts. Instead, use named coordinate nodes and transformations.

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.