5

I'm new to the LaTeX chains package and try to join(=merge) together 2 (or maybe even more) branches in a single node again. I only know about a very inflexible way which is shown in the code snippet below. An explanation about the issue is added as a comment in the code (hopefully it makes the problem more clear).

\documentclass[12pt]{article}

\usepackage{tikz}
\usepackage{tikz-timing}
\usetikzlibrary{chains} 
\usetikzlibrary{decorations.markings}
\usetikzlibrary{external}
\usetikzlibrary{shapes}

\begin{document}

\begin{tikzpicture}[
box/.style={draw,rectangle,minimum width=10pt,minimum height=10pt},
arrow/.style={->},
]

\begin{scope}[
start chain,
>=stealth,
every join/.style={->},
skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}},
point/.style={on chain,join=by -,coordinate},
]

\node [point] {$$};
\node [box, on chain, join] (Start) {$A$};
\begin{scope}[start branch,node distance=4mm and 6mm]
\node [box, join, on chain=going above right] (L) {$B$};
\end{scope}
\begin{scope}[start branch,node distance=4mm and 6mm]
\node [box, join, on chain=going below right] (R) {$C$};
\end{scope}
% the next node line adds a node with relative distance to the 
% Start node but this is impractical for longer chains with many branches
% i want to "merge" two branches into a single one and then use 
% "on chain" again to go on
\node [box] (stream2) at ($(Start.east) + (23mm,0)$) {D};    
\draw[arrow] (L.east) -> ($(stream2.north west)$);
\draw[arrow] (R.east) -> ($(stream2.south west)$);  

\end{scope}
\end{tikzpicture}

\end{document}}

Is this even possible? I am thankful for all hints and help.

Daniel F
  • 539
  • 6
  • 14
  • 1
    Keep one branch as if the other one is not there and connect the dead end to the node simply with \draw[->] (C) -- (D); – percusse Mar 02 '13 at 23:52
  • @percusse : \node [box, on chain] (D) {$D$}; \draw[arrow] (R.east) -- (D.north west); pushes D too close to the other nodes. How do get that working? – Daniel F Mar 03 '13 at 15:13

1 Answers1

4

The only change I've done is to add

\node [box, join, on chain=going above right] (D) {$D$};

to the second scope and then at the end use

\draw[arrow] (B) -> (D);

which gives me

enter image description here

The MWE

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{chains} 
\usetikzlibrary{decorations.markings}


\begin{document}

\begin{tikzpicture}[
box/.style={draw,rectangle,minimum width=10pt,minimum height=10pt},
arrow/.style={->},
]

\begin{scope}[
start chain,
>=stealth,
every join/.style={->},
skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}},
point/.style={on chain,join=by -,coordinate},
]

\node [box, on chain, join] (Start) {$A$};
\begin{scope}[start branch,node distance=4mm and 6mm]
\node [box, join, on chain=going above right] (B) {$B$};
\end{scope}
\begin{scope}[start branch,node distance=4mm and 6mm]
\node [box, join, on chain=going below right] (C) {$C$};
\node [box, join, on chain=going above right] (D) {$D$};
\end{scope}
\draw[arrow] (B) -> (D);


\end{scope}
\end{tikzpicture}

\end{document}
percusse
  • 157,807