# Add gaps to lines with TikZ

I am drawing some block diagrams with TikZ. Sometimes, I need to combine several blocks together to form one large group by adding a border around the corresponding blocks. However, there are some arrows which cross the border, as shown in this picture.

The arrow "to ALC loop" and the arrow just below it looks ugly. What I would like to do is the following (note the small gaps around the arrows where they cross the thick border):

How is that possible with TikZ? The arrows are just ordinary arrows drawn with the \draw[->] (from) -- (to); macro, and the thick border is also just an ordinary line.

• See double option in section "15.3.4 Graphic Parameters: Double Lines and Bordered Lines", p.169, pgfmanual (v3.0.1a). – Paul Gaborit Jan 28 '17 at 14:57
• @Paul Gaborit - the disadvantage of the solution from your tip is that the shorten option can't be used as an input, because it is already applied in the problem solution: link -that is your solution here. Nevertheless your idea covers the case of overlapping arrow tip and external box border (in the picture in question). – forrest Jan 28 '17 at 15:15

Using @AboAmmar MWE, preaction can be used in the simple case:

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[> = latex]
\node [draw, thick, minimum size=5em] (rec) {};
\node [draw] (div) {$\div$};

\draw [preaction={draw, line width=3pt, white}][<->] (div) -- ++(5em,0);

\end{tikzpicture}

\end{document}


EDIT: there is some problem nevertheless - arrow tip changes path bending dependently on the size of this arrow tip. So the idea is not good solution.

\documentclass[border=2pt]{standalone}
\usepackage{tikz}

\tikzset{
outlined arrow/.style={
preaction={{}-{},draw,line width=3pt,yellow}
}
}

\begin{document}
\begin{tikzpicture}[> = latex]
\node [draw,thick,minimum size=5em] (rec) {};
\node [draw] (div) {$\div$};

\draw [outlined arrow][<->] (div) -- ++(5em,0);
\draw [outlined arrow][<->,shorten <=2pt] (div) .. controls +(-90:15mm) and +(180:15mm) .. ++(5em,-5em);

\end{tikzpicture}
\end{document}


EDIT 2: In the above case black arrow bent line goes not in the middle of yellow line - dependently on the arrow size. I found that @cfr response (arrow tip size independent on the line width) can be useful a bit here. The code below works only when the arrow tip setup my arrow is passed through optional argument.

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}[
outlined arrow/.style={preaction={double=yellow,double distance=2pt,draw=red}},
my arrow/.style={>={LaTeX[length=2mm]}},
yscale=0.6
]
\node [draw,thick,minimum size=5em] (rec) {};
\node [draw] (div) {$\div$};

\draw [outlined arrow][<->,my arrow] (div) -- ++(5em,0);
\draw [outlined arrow][<->,shorten <=2pt,my arrow]
(div) .. controls +(-90:15mm) and +(180:15mm) .. ++(5em,-5em);

\end{tikzpicture}
\end{document}


I considered also the use of @Qrrbrbirlbel solution (save a path and call it for stroking), but shorten option didn't work. Also @Paul Gaborit solution (surrounded arrow) excludes shorten option (?).

• this is perfect! – T. Pluess Jan 28 '17 at 20:15

These gaps at line crossings can be achieved with a thick white-colored line drawn the same way as your crossing line. Here is an example:

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[> = latex]
\node [draw, thick, minimum size=5em] (rec) {};
\node [draw] (div) {$\div$};

\draw [<->, line width=3pt, white](div) -- ++(5em,0);
\draw [<->] (div) -- ++(5em,0);

\end{tikzpicture}

\end{document}


• Thank you. I already had that idea too, but it has the disadvantage that the corresponding arrows have to be drawn twice. I wonder whether there is an 'automatic' way? – T. Pluess Jan 28 '17 at 14:10