我正在尝试在节点内绘制并将线连接到其锚点。使用矩形可以很好地工作,但是当我尝试面对面连接两条线时,如下面的示例所示,仍然存在间隙。有人可以帮我告诉我如何消除差距吗?
围绕节点的[绘制]仅用于定向,我想保持边界不可见。
感谢您的事先帮助!
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
% define macro for drawing inside node
\newcommand{\myMacro}[1]{
\tikz[]{
\draw[thick] ([xshift=0.2mm]2*#1,0)
-- (2*#1,0)
arc (0:180:2*#1)
-- ([xshift=-0.2mm]-2*#1,0);
\draw[thick] (0,0) circle (#1);
\draw[thick] (0,-#1) -- (0,-2*#1);
}
}
% node with drawing inside
\node[inner sep=0, minimum size=0, outer sep=0, draw=black!20, very thin](n1) at (0,0) {\myMacro{0.15}};
% connect lines to node.
% blue circle: connection like it's supposed to be
% red circle: connection with gap! :-(
\draw[thick] (n1.west) node[draw=red, circle, inner sep=0.05cm, thin]{} -- ++(-0.5,0);
\draw[thick] (n1.east) -- ++(0.5,0);
\draw[thick] (n1.south) -- ++(0,-0.5);
\draw[thick] (n1.north) node[draw=blue, circle, inner sep=0.05cm, thin]{} -- ++(0,0.5);
\end{tikzpicture}
\end{document}
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
% define macro for drawing inside node
\newcommand{\myMacro}[1]{
\draw[thick] ([xshift=0.2mm]2*#1,0)
-- (2*#1,0)
arc (0:180:2*#1)
-- ([xshift=-0.2mm]-2*#1,0);
\draw[thick] (0,0) circle (#1);
\draw[thick] (0,-#1) -- (0,-2*#1);
}
% node with drawing inside
\begin{scope}[local bounding box=n1]
\myMacro{0.15};
\end{scope}
% connect lines to node.
% blue circle: connection like it's supposed to be
% red circle: connection with gap! :-(
\draw[thick] (n1.west) node[draw=red, circle, inner sep=0.05cm, thin]{} -- ++(-0.5,0);
\draw[thick] (n1.east) -- ++(0.5,0);
\draw[thick] (n1.south) -- ++(0,-0.5);
\draw[thick] (n1.north) node[draw=blue, circle, inner sep=0.05cm, thin]{} -- ++(0,0.5);
\end{tikzpicture}
\end{document}