3

I am trying to write a rather long workflow diagram so with will zigzag back and forth. For personal preference of esthetics, I would like to have some of the join arrow broken rather than straight.

I am using chains as I am trying to keep the code a minimal as possible. It will eventually go into a beamer presentation where the node will be displayed one at a time.

I have tried to change the link with join=by |-> but that changes the arrow itself rather than the link.

\documentclass[tikz]{standalone}

\usetikzlibrary{positioning, calc, arrows, chains}

\begin{document}

% https://tex.stackexchange.com/questions/56427/how-to-evenly-space-out-nodes-or-in-tikz
\begin{tikzpicture}[
        start chain,
        node distance = 15mm,
        every node/.style = {inner sep = 2mm, on chain, join},
        every join/.style = {->},
    ]
    \node (A) {A};
    \node (B) {B};
    \node (C) {C};
    \node (D) {D};
    \node[continue chain=going below, join = by |->] (E) {E}; % would like the join to be U shaped rather than straight down
    \node[continue chain=going left] (F) {F};
    \node (G) {G};
    \node (H) {H};
    \node (I) {I};
    \node[continue chain=going below, align=center] (J) {J}; 
    \node[join = by -, inner sep = 0pt] {};
    \node[continue chain=going right] (K) {K}; % L shaped link preferably without intermediary node
\end{tikzpicture}

\end{document}

enter image description here

  • 1
    What do you call a broken arrow? – AndréC Oct 8 '18 at 15:48
  • @AndréC I have updated the post with a modified image to show what I mean. – ArTourter Oct 8 '18 at 16:11
8

Perhaps this is of interest. It's possible to modify the path of a join, with the to path option. However, you need to remove join from the every node style, otherwise you'll get two arrows between the nodes. One from the join in every node, one from the additional join=by ....

To make it slightly less tedious to add the join back in, use scope environments, or (as in the code below) the shorthand for a scope made available by the scopes library.

The method for positioning the K is not ideal, I've just added some negative yshift to it.

enter image description here

\documentclass[tikz, border=5mm]{standalone}

\usetikzlibrary{ chains, scopes} % added scopes library

\begin{document}

% https://tex.stackexchange.com/questions/56427/how-to-evenly-space-out-nodes-or-in-tikz
\begin{tikzpicture}[
        start chain,
        node distance = 15mm,
        every node/.style = {inner sep = 2mm, on chain}, % removed join
        every join/.style = {->},
    ]
    { [every node/.append style={join}] % shorthand for scope environment requires scopes library
    \node (A) {A};
    \node (B) {B};
    \node (C) {C};
    \node (D) {D};
    }

    \node[continue chain=going below,
          % define a custom to path to use for this join
          % when you use "join=by ..." an edge is created and "..." are passed as options to the edge
          join = by {to path={(\tikztostart) -- ++(1cm,0) |- (\tikztotarget)}}
          ] (E) {E}; 

    { [every node/.append style={join}]
    \node[continue chain=going left] (F) {F};
    \node (G) {G};
    \node (H) {H};
    \node (I) {I};
    \node[continue chain=going below, align=center] (J) {J}; 
    }

    \node[continue chain=going right,
          yshift=-15mm, % move node down manually
          join=by {to path={(\tikztostart) |- (\tikztotarget)}}] (K) {K}; 

    { [every node/.append style={join}]
    \node (I) {L};
    % etc
    }
\end{tikzpicture}

\end{document}
3

Definitively not the best way

\documentclass[tikz]{standalone}

\usetikzlibrary{positioning, calc, arrows, chains}

\begin{document}

% https://tex.stackexchange.com/questions/56427/how-to-evenly-space-out-nodes-or-in-tikz
\begin{tikzpicture}[
        start chain,
        node distance = 15mm,
        every node/.style = {inner sep = 2mm, on chain, join},        
        every join/.style = {->},
    ]
    \node (A) {A};
    \node (B) {B};
    \node (C) {C};
    \node (D) {D};
    \node[continue chain=going below, join = by {white}] (E) {E}; % would like the join to be U shaped rather than straight down
    \node[continue chain=going left] (F) {F};
    \node (G) {G};
    \node (H) {H};
    \node (I) {I};
    \node[continue chain=going below, align=center] (J) {J}; 
    % \node[join = by -, inner sep = 0pt] {};
    \node[join= by {white}, inner sep = 0pt] {};
    \node[join= by {white}, continue chain=going right,] (K) {K}; % L shaped link preferably without intermediary node
    \draw[->, blue] (J.south) |- (K);
    \draw[->, blue] (D.east) |- ++(10mm,0) -- ($(E.east) + (10mm,0)$) -> (E.east);
\end{tikzpicture}

\end{document}

enter image description here

  • That helps indeed but I was trying to make the chain join do it semi automatically rather than adding additional elements. anyway, the way to remove the original arrows, I guess, is to change the every node definition to not include join and then add join to the nodes you want to automatically link and not to the one we define manually. That will I think be my last resort but I'll wait to see if someone comes up with a better solution. – ArTourter Oct 8 '18 at 16:26

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.