11

I have a node which I draw with a double line. If I now draw a path that connects to this node, the path does not stop at the outer border of my node, but exactly in the middle between the two lines. Is there any way to fix this behavior such that the paths correctly ends at the other-most line that I have drawn?

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[line width=1mm, draw, double, double distance=1cm, circle, minimum width=4cm] (circ) at (0,0) {};
\draw[line width=1mm] (circ) -- (7,0);
\end{tikzpicture}
\end{document}

enter image description here

1 Answers1

11

You can make the line terminate at the outer edge of the node by setting outer sep to half the the double distance plus the line width (so 6mm in this case):

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[
    line width=1mm,
    draw,
    double distance=1cm,
    circle,
    minimum width=4cm,
    outer sep=0.6cm
] (circ) at (0,0) {};
\draw[red,line width=1mm] (circ) -- (7,0);
\end{tikzpicture}
\end{document}

If you want double distance to automatically update the outer sep, you can redefine an internal macro by putting the following code snippet somewhere after \usepackage{tikz}:

\makeatletter
\tikzoption{double distance}{%
  \pgfmathsetlength{\pgf@x}{#1}%
  \edef\tikz@double@setup{%
    \pgf@x=\the\pgf@x%
    \advance\pgf@x by2\pgflinewidth%
    \pgflinewidth=\pgf@x%
    \noexpand\pgfsetlinewidth{\pgflinewidth}%
    \noexpand\pgfsetinnerlinewidth{\the\pgf@x}%
  }%
  \pgfset{outer sep/.expand once=#1*0.5+\pgflinewidth}%
  \tikzset{double}}
\makeatother
Jake
  • 232,450