# Problems with crossing over another line

So not too long ago, I was on here asking about a way to make a line on a Tikz image cross over another line by arcing over it. I was looking for a way to clean up a Tikz image that I had created for someone at work. Someone was able to link me to another very useful Stackexchange page that helped me get the code started. However, I noticed that one limitation was that the arrows created did not have arrow heads on them. The MWE I provided is my closest attempt. You will see when you typeset the code that the closest I have been able to come to an answer still leaves one line under the intersection of the line (it would be helpful to hide this line but still be able to reference it when I do the curving algorithm) and in this case one line over it. I have tried changing the lines (i.e, other line is the one arcing) but it removes the arrow head from the arrow.

I hope someone can help me here. It would be really great to improve this project.

Thanks much,

Rob

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes,arrows,shapes.multipart}
\begin{document}
\begin{tikzpicture}[node distance = 3.00cm, auto, ]
\tikzset{
decision/.style = {diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
block/.style = {rectangle, draw, fill=blue!20,
text width=5em, text centered, rounded corners, minimum height=4em},
line/.style = {draw, -latex'},
cloud/.style = {draw, ellipse,fill=red!20, node distance=3cm,
minimum height=2em},
subroutine/.style = {draw,rectangle split, rectangle split horizontal,
rectangle split parts=3,minimum height=1cm,
rectangle split part fill={red!50, green!50, blue!20, yellow!50}},
connector/.style = {draw,circle,node distance=3cm,fill=yellow!20},
data/.style = {draw, trapezium,node distance=1.5cm,fill=olive!20}
}

\tikzset{
connect/.style args={(#1) to (#2) over (#3) by #4}{
insert path={
let \p1=($(#1)-(#3)$), \n1={veclen(\x1,\y1)},
\n2={atan2(\x1,\y1)}, \n3={abs(#4)}, \n4={#4>0 ?180:-180}  in
(#1) -- ($(#1)!\n1-\n3!(#3)$)
arc (\n2:\n2+\n4:\n3) -- (#2)
}
},
}

\node [block,fill=green] (cs110) {\textbf{CS110} \emph{CS Class 1}};
\node[block,fill=blue,right of=cs110] (cs120){\textbf{CS120} \emph{CS Class 2}};
\node[block,fill=red, above of=cs120] (cs220) {Test 3};
\node[block,fill=orange,right of = cs220] (cs330) {Test 4};
\path[line, name path=120to220] (cs120) -- (cs220);
\path[line, name path = 110to330] (cs110) -- (cs330);
\path[name intersections={of=120to220 and 110to330, by=inter}];
\draw [connect=(cs120) to (cs220) over (inter) by 5pt];
%\path [name intersections={of=110to120 and 110to320,by=inter3}];
%\draw [connect=(math260) to (math310) over (inter3) by 7pt];
\end{tikzpicture}
\end{document}


Maybe I'm misunderstanding the question, but I believe all you have to do is move the line style from the straight-line \path command to the connect path. That will leave the straight line invisible, and apply the line style (with the arrow head) to the connecting line with the arc:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows}
\usetikzlibrary{shapes,arrows,shapes.multipart}
\begin{document}
\begin{tikzpicture}[node distance = 3.00cm, auto, ]
\tikzset{
decision/.style = {diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
block/.style = {rectangle, draw, fill=blue!20,
text width=5em, text centered, rounded corners, minimum height=4em},
line/.style = {draw, -latex'},
cloud/.style = {draw, ellipse,fill=red!20, node distance=3cm,
minimum height=2em},
subroutine/.style = {draw,rectangle split, rectangle split horizontal,
rectangle split parts=3,minimum height=1cm,
rectangle split part fill={red!50, green!50, blue!20, yellow!50}},
connector/.style = {draw,circle,node distance=3cm,fill=yellow!20},
data/.style = {draw, trapezium,node distance=1.5cm,fill=olive!20}
}

\tikzset{
connect/.style args={(#1) to (#2) over (#3) by #4}{
insert path={
let \p1=($(#1)-(#3)$), \n1={veclen(\x1,\y1)},
\n2={atan2(\x1,\y1)}, \n3={abs(#4)}, \n4={#4>0 ?180:-180}  in
(#1) -- ($(#1)!\n1-\n3!(#3)$)
arc (\n2:\n2+\n4:\n3) -- (#2)
}
},
}

\node [block,fill=green] (cs110) {\textbf{CS110} \emph{CS Class 1}};
\node[block,fill=blue,right of=cs110] (cs120){\textbf{CS120} \emph{CS Class 2}};
\node[block,fill=red, above of=cs120] (cs220) {Test 3};
\node[block,fill=orange,right of = cs220] (cs330) {Test 4};
\path[ name path=120to220] (cs120) -- (cs220);
\path[line, name path = 110to330] (cs110) -- (cs330);
\path[name intersections={of=120to220 and 110to330, by=inter}];
\draw [line, connect=(cs120) to (cs220) over (inter) by 5pt];
\end{tikzpicture}
\end{document}

• I moved the word line from \path[line, name path=120to220] (cs120) -- (cs220); to \draw [connect=(cs120) to (cs220) over (inter) by 5pt]; – Jake Jun 22 '13 at 21:20
• Note that atan2 has changed in tikz since version 3.0. – cjorssen Sep 26 '14 at 12:37