1

The MWE is as following ( I am using ConTeXt)

\usemodule[tikz]
\usetikzlibrary{positioning}
\usetikzlibrary{shapes}
\usetikzlibrary{calc}
\tikzset{arrow/.style={-stealth, thick, draw=black!70!white}}
\starttext
\starttikzpicture[ampersand replacement=\&]
% \draw[help lines](0,-5) grid (10,5);  
    \node[rectangle, rounded corners, draw, fill=white!90!black, minimum height=1cm] at (3,0) (S) {SSS};   
    \node[rectangle, rounded corners, draw, fill=white!90!black, minimum height=1cm] at (3,3) (C) {CCC};    
    \node[rectangle, rounded corners, draw, fill=white!90!black, minimum height=1cm] at (6,1.5) (I) {III};    
    \node[rectangle, rounded corners, draw, fill=white!90!black, minimum height=1cm] at (10,1.5) (P) {PPP};
\path[arrow]
(S) edge (I.south west)
(C) edge (I.north west)
(I) edge (P)
(C) -- (10,3) -|  (P.north)
(S) -- (10,0) -|  (P.south)
;

\stoptikzpicture \stoptext

My intention is to get the arrow at the end of the path from CCC to PPP (at the north of PPP), but it does not show. Please help. Thanks.

muzimuzhi Z
  • 26,474

1 Answers1

3

Arrows are only placed at the first and last subpath of a path, see https://tikz.dev/tikz-arrows#sec-16.2 .

In your example (C) -- (10,3) -| (P.north) and (S) -- (10,0) -| (P.south) are two subpaths (separated by move-to path operations), thus the arrow is only added to the (S) -- (10,0) -| (P.south).

Instead of splitting it into multiple paths, you can keep using edge to add multiple arrows to a single path, with some extra options:

(node a) edge[to path={-| (\tikztotarget)}] (node b)

see @Scz's answer to Tikz right-angle edges between nodes | TeX-SX#48397.

Complete adapted example:

  • Arrows are colored the same color as lines, using -{Stealth[black!70]} with arrows.meta library loaded.
  • New style keys are named to path hv and to path vh, because using | is key name ends with errors.
    ConTeXt sets catcode of | from 12 (other) to 13 (active), which I deduce is the cause. Never being a regular ConTeXt user, I just worked around it. Also see Which symbols need to be escaped in ConTeXt? | TeX-SX#48933.
    Update: this works but the expressiveness is lost: to path -\|/.style={...}.
% !TeX TS-program = context %.tex
\usemodule[tikz]
\usetikzlibrary{arrows.meta, calc, positioning, shapes}
\tikzset{
  arrow/.style={-{Stealth[black!70]}, thick, draw=black!70},
  % based on https://tex.stackexchange.com/a/250515
  to path hv/.style={to path={-| (\tikztotarget)}},
  to path vh/.style={to path={|- (\tikztotarget)}}
}
\starttext
\starttikzpicture[ampersand replacement=\&]
% \draw[help lines](0,-5) grid (10,5);
    \node[rectangle, rounded corners, draw, fill=white!90!black, minimum height=1cm] at (3,0) (S) {SSS};
    \node[rectangle, rounded corners, draw, fill=white!90!black, minimum height=1cm] at (3,3) (C) {CCC};
    \node[rectangle, rounded corners, draw, fill=white!90!black, minimum height=1cm] at (6,1.5) (I) {III};
    \node[rectangle, rounded corners, draw, fill=white!90!black, minimum height=1cm] at (10,1.5) (P) {PPP};
\path[arrow]
  (S) edge (I.south west)
  (C) edge (I.north west)
  (I) edge (P)
  (C) edge[to path hv] (P.north)
  (S) edge[to path hv] (P.south)
;

\stoptikzpicture \stoptext

enter image description here

muzimuzhi Z
  • 26,474