I'm trying to create a (flexible) method of creating a path around a set of nodes. Let me demonstrate with the help of a MWE:
\begin{tikzpicture}[
every node/.style={draw,black},
every path/.style={red}
]
\node at (0,0) (a) {A};
\node at (2,0) (b) {B};
\node at (3,0) (c) {C};
\node at (2,-1) (e) {E};
\node at (3,-1) (f) {F};
\node at (0,-1) (d) {D};
\path [draw, rounded corners]
(a.north west)
-- (c.north east)
-- (f.south east)
-- (e.south west)
-- (b.south west)
-- (a.south west)
-- cycle;
\end{tikzpicture}
Here's what it looks like:
There are two problems here:
- The surrounding node is too closely placed on the anchors. I need something like an
inner sep
but that doesn't work since this is a path, not a node. - The nodes to be surrounded have to be specified explicitly. This becomes very difficult to manage if we have a lot of nodes to surround and they're moved around at a later stage.
So, what I need is a better workflow for doing something like this to address the above two issues.
Update: After the answer by @ClaudioFiandrino, I would like to post what I need. I hacked around with my limited knowledge and arrived at this:
\newcommand{\shiftpoints}{4pt}
\begin{tikzpicture}[
every node/.style={draw,black},
every path/.style={red},
shifttl/.style={shift={(-\shiftpoints,\shiftpoints)}},
shifttr/.style={shift={(\shiftpoints,\shiftpoints)}},
shiftbl/.style={shift={(-\shiftpoints,-\shiftpoints)}},
shiftbr/.style={shift={(\shiftpoints,-\shiftpoints)}},
]
\node at (0,0) (a) {A};
\node at (2,0) (b) {B};
\node at (3,0) (c) {C};
\node at (2,-1) (e) {E};
\node at (3,-1) (f) {F};
\node at (0,-1) (d) {D};
\begin{scope}[transform shape]
\path [draw,rounded corners]
([shifttl] a.north west)
-- ([shifttr] c.north east)
-- ([shiftbr] f.south east)
-- ([shiftbl] e.south west)
-- ([shiftbl] b.south west)
-- ([shiftbl] a.south west)
-- cycle;
\end{scope}
\end{tikzpicture}
Which produces this:
So, any suggestions for improvement of the code. The end result seems ok for my purposes.
\path [draw, transform canvas={shift={(2,0)},xscale=1.1,yscale=1.2},transform canvas={shift={(-2.05,0)}},rounded corners]
and strange things happen :)