A chain of nodes is drawn using tikz chains
. I would like to draw a rectangle node covering the chain nodes (or, multiple rectangle nodes covering subsets of them). I am using tikz fit
.
Unfortunately, by the way I use it, the rectangle nodes are considered part of the chains. As a result, additional join edges are drawn to the rectangle positions are kind of messed up. The following are the MWE:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{chains, fit}
\begin{document}
\begin{tikzpicture}[start chain, node distance=5mm, every node/.style={draw, on chain, join}, every join/.style=->]
\node (a) {a};
\node (b) {b};
\node (c) {c};
\node (d) {d};
\begin{scope} [start branch=numbers, every join/.style=<-]
\node (1) [on chain=going above] {1};
\node (2) [on chain=going above] {2};
\end{scope}
\node (e) {e};
\node (fit2) [draw, inner sep=2pt, fit=(a) (b) ] {};
\node (fit1) [draw, inner sep=2pt, fit=(d) (1) (e)] {};
\end{tikzpicture}
\end{document}
The result, without and with the covering rectangles, are