
El MWE es el siguiente (estoy usando 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
Mi intención es colocar la flecha al final del camino de CCC a PPP (al norte de PPP), pero no se muestra. Por favor ayuda. Gracias.
Respuesta1
Las flechas solo se colocan en la primera y última subruta de una ruta, consultehttps://tikz.dev/tikz-arrows#sec-16.2.
En su ejemplo, (C) -- (10,3) -| (P.north)
y (S) -- (10,0) -| (P.south)
son dos subrutas (separadas por operaciones de desplazamiento a la ruta), por lo que la flecha solo se agrega al archivo (S) -- (10,0) -| (P.south)
.
En lugar de dividirlo en varios caminos, puedes seguir usándolo edge
para agregar varias flechas a un solo camino, con algunas opciones adicionales:
(node a) edge[to path={-| (\tikztotarget)}] (node b)
ver la respuesta de @Scz aBordes en ángulo recto de Tikz entre nodos | TeX-SX#48397.
Ejemplo completo adaptado:
- Las flechas tienen el mismo color que las líneas y se usan
-{Stealth[black!70]}
conarrows.meta
la biblioteca cargada. - Las nuevas claves de estilo se denominan
to path hv
yto path vh
, porque el uso|
de su nombre de clave termina con errores.
ConTeXt establece un código cat de|
12 (otro) a 13 (activo), lo que deduzco es la causa. Como nunca fui un usuario habitual de ConTeXt, simplemente lo solucioné. Ver también¿Qué símbolos deben tener escape en ConTeXt? | TeX-SX#48933.
Actualización: esto funciona pero se pierde la expresividad: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