我想连接线或箭头仅接触边缘的节点,但实际上线和箭头指向节点的中心。这是我的代码:
\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\begin{tikzpicture}
\coordinate (a) at (0,0);
\coordinate (b) at (-1,-1);
\coordinate (c) at ( 1,-1);
\node at (a) [circle,draw] () {a};
\node at (b) [circle,draw] () {b};
\node at (c) [circle,draw] () {c};
\draw[-] (a) to (b);
\draw[-] (a) to (c);
\end{tikzpicture}
\end{document}
输出如下:
编辑:我现在看到了问题所在。我通过删除坐标并更改来修复
\node at (a) [circle,draw] () {a};
和类似的
\node at (0,0) [circle,draw] (a) {a};
答案1
对于您的图像,您不需要单独定义它们的坐标:
\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\begin{tikzpicture}
\node (a) [circle,draw] at ( 0, 0) {a};
\node (b) [circle,draw] at (-1,-1) {b};
\node (c) [circle,draw] at ( 1,-1) {c};
\draw[-] (a) to (b);
\draw[-] (a) to (c);
\end{tikzpicture}
\end{document}
如果您需要这些坐标用于其他用途,则现在可以将其作为(a.center)
、(b.center)
或 来使用(c.center)
。