# Using fit for a box through a node

Hi i try to use the command fit to make a box around nodes. But the edge nodes should be only half in the box.

\begin{tikzpicture}
\node at (0,0) (CE1) {\includegraphics[height=3ex]{Bilder/Router.png}};
\node at (2,0) (PE1) {\includegraphics[height=3ex]{Bilder/Router.png}};
\node at (4,0) (P1) {\includegraphics[height=3ex]{Bilder/Router.png}};
\node at (6,0) (P2) {\includegraphics[height=3ex]{Bilder/Router.png}};
\node at (5,-2) (P3) {\includegraphics[height=3ex]{Bilder/Router.png}};
\node at (8,0) (PE2) {\includegraphics[height=3ex]{Bilder/Router.png}};
\node at (10,0) (CE2) {\includegraphics[height=3ex]{Bilder/Router.png}};
\node at (5,-3)(LDP)[scale=0.6, text=black] {directed LDP};
\node (test)[fill=lightgrey , rounded corners, fit= (PE1.mid) (P1) (P2) (P3.south) (PE2.mid)] {};
\end{tikzpicture}

while using PE1.mid the box dosn´t go exactly through the midle of PE1 it has an offset to the left. is there any way to go exactly through the midle of the node?

thx for help

steffen

• Welcome to TeX.SX! So that others can test your code, it is best to make it in to a complete minimal working example (MWE) and use a graphic that is available on standard systems such as example-image-a. – Andrew Swann Jul 16 '15 at 8:17

I think you're looking for inner {x|y}sep=0pt. Adjust it according your needs. Following code uses inner xsep=0pt and the result is:

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

\usetikzlibrary{fit}

\begin{document}

\begin{tikzpicture}
\node at (0,0) (CE1) {\includegraphics[height=3ex]{example-image-a}};
\node at (2,0) (PE1) {\includegraphics[height=3ex]{example-image-b}};
\node at (4,0) (P1) {\includegraphics[height=3ex]{example-image-c}};
\node at (6,0) (P2) {\includegraphics[height=3ex]{example-image-a}};
\node at (5,-2) (P3) {\includegraphics[height=3ex]{example-image-b}};
\node at (8,0) (PE2) {\includegraphics[height=3ex]{example-image-c}};
\node at (10,0) (CE2) {\includegraphics[height=3ex]{example-image-a}};
\node at (5,-3)(LDP)[scale=0.6, text=black] {directed LDP};

\node (test)[draw, rounded corners,
fit= (PE1.mid) (P1) (P2) (P3.south) (PE2.mid),
inner xsep=0pt] {};
\end{tikzpicture}

\end{document}
• thx a lot it works perfect – steffen Jul 16 '15 at 8:34