
ノード スタイルをHost
次のように定義します (ドイツ語のラベルで申し訳ありません)。
\tikzset{Host/.style={path picture={%
\coordinate (hinten links oben) at ($(path picture bounding box.north west)!0.33!(path picture bounding box.north east)$);
\coordinate (hp1) at ($(path picture bounding box.north west)!0.66!(path picture bounding box.north east)$);
\coordinate (vorne links oben) at ($(path picture bounding box.south west)!0.66!(path picture bounding box.north west)$);
\coordinate (vorne rechts unten) at ($(path picture bounding box.south west)!0.66!(path picture bounding box.south east)$);
\coordinate (vorne rechts oben) at ($(vorne rechts unten)!0.66!(hp1)$);
\coordinate (hinten rechts unten) at ($(path picture bounding box.south east)!0.33!(path picture bounding box.north east)$);
\path (vorne links oben) edge [-] (hinten links oben);
\path (hinten links oben) edge [-] (path picture bounding box.north east);
\path (path picture bounding box.north east) edge [-] (hinten rechts unten);
\path (hinten rechts unten) edge [-] (vorne rechts unten);
\path (vorne rechts unten) edge [-] (path picture bounding box.south west);
\path (path picture bounding box.south west) edge [-] (vorne links oben);
\path (vorne links oben) edge [-] (vorne rechts oben);
\path (vorne rechts oben) edge (path picture bounding box.north east) edge (vorne rechts unten);
}},minimum width=2em, minimum height=3em}
このスタイルを使用すると、境界ボックスの境界に沿った線が視覚的に細く表示されます。これは、線が定義する終点の周囲に伸びて、境界ボックスによって切り取られるためだと思います。
何らかの余白を挿入する簡単な方法はありますか?
答え1
簡単な修正方法としては、クリッピングを回避するために、パス画像の境界ボックス内で現在の線幅と同じだけシフトするだけです。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\tikzset{Host/.style={path picture={%
\coordinate (ppbbnw) at ([shift={(.5\pgflinewidth,-.5\pgflinewidth)}]path picture bounding box.north west);
\coordinate (ppbbne) at ([shift={(-.5\pgflinewidth,-.5\pgflinewidth)}]path picture bounding box.north east);
\coordinate (ppbbsw) at ([shift={(.5\pgflinewidth,.5\pgflinewidth)}]path picture bounding box.south west);
\coordinate (ppbbse) at ([shift={(-.5\pgflinewidth,.5\pgflinewidth)}]path picture bounding box.south east);
\coordinate (hlo) at ($(ppbbnw)!{1/3}!(ppbbne)$);
\coordinate (hp1) at ($(ppbbnw)!{2/3}!(ppbbne)$);
\coordinate (vlo) at ($(ppbbsw)!{2/3}!(ppbbnw)$);
\coordinate (vru) at ($(ppbbsw)!{2/3}!(ppbbse)$);
\coordinate (vro) at ($(vru)!{2/3}!(hp1)$);
\coordinate (hru) at ($(ppbbse)!{1/3}!(ppbbne)$);
\draw (ppbbne) -- (hru) -- (vru) -- (ppbbsw) -- (vlo) -- (hlo) -- cycle;
\draw (vlo) --(vro) -- (ppbbne) (vro) -- (vru);
}
},minimum width=2em, minimum height=3em}
\node[Host,thick] {};
\node[Host,ultra thin] at (1,0) {};
\node[Host] at (2,0) {};
\end{tikzpicture}
\end{document}