答案1
以下是一种方法:
- 用白色填充圆圈,
- 使用图层在
background
和 - 垂直移动两个端点:
代码:
\documentclass{article}
\usepackage{tikz}
%% -------------------------------------- Declare the layers
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\begin{document}
\begin{tikzpicture}
\begin{pgfonlayer}{main}
\node[draw,circle,red, fill=white] (a) at (0,0) {$A$};
\node[draw,circle,blue, fill=white] (b) at (1,1) {$B$};
\end{pgfonlayer}
% -----------------------
\begin{pgfonlayer}{background}
\draw[line width=3pt]
([yshift=-0.30ex]a.north) to ([yshift=+0.30ex]b.south);
\end{pgfonlayer}
\end{tikzpicture}
\end{document}