3

With the following 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}

I obtain the following image:

enter image description here

Is there a way to have a nice insertion of the thick edge in the nodes?

  • 1
    What do you mean a nice insertion? Do you want the line behind the circles? – darthbith Feb 29 '16 at 12:40
  • 1
    Yes, and that it doesn't interrupt before the node (in the outer parts) – Filippo Bistaffa Feb 29 '16 at 12:42
2

Here is one way:

  • Fill the circles with white,
  • Use layers to put the thick line in the background and
  • Shift the two end points vertically:

enter image description here

Code:

\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}
|improve this answer|||||
  • That might work, but this would require to manually modify several images in which I use thick edges. I was thinking of a solution that applies to the edge's style, avoiding this problem. – Filippo Bistaffa Feb 29 '16 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.