插入边缘丑陋,斜线较粗

插入边缘丑陋,斜线较粗

具有以下 MWE:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw,circle] (a) at (0,0) {$A$};
\node[draw,circle] (b) at (1,1) {$B$};
\draw[line width=3pt] (a.north) to (b.south);
\end{tikzpicture}
\end{document}

我得到了以下图像:

在此处输入图片描述

有没有办法将粗边很好地插入节点中?

答案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}

相关内容