Add gaps to lines with TikZ

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. enter image description here

\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.

enter image description here

\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 (?).


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}

enter image description here

Tags:

Paths

Tikz Pgf