# Kink cross over/above vertical wires

I'm drawing a circuit schematic using tikz and got stuck doing the "kink" crosses on such circuit. I've found an answer on how to do them here. However, I was unable to extend the answer to skip above a vertical wire.

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\usepackage{circuitikz}
\pagestyle{empty}

\tikzset{
declare function={% in case of CVS which switches the arguments of atan2
atan3(\a,\b)=ifthenelse(atan2(0,1)==90, atan2(\a,\b), atan2(\b,\a));},
@kinky cross/.initial=+, kinky crosses/.is choice,
kinky crosses/left/.style={@kinky cross=-},kinky crosses/right/.style={@kinky cross=+},
kinky cross/.style args={(#1)--(#2)}{
to path={
let \p{@kc@}=($(\tikztotarget)-(\tikztostart)$),
\n{@kc@}={atan3(\p{@kc@})+180} in
-- ($(intersection of \tikztostart--{\tikztotarget} and #1--#2)!% \pgfkeysvalueof{/tikz/kinky cross radius}!(\tikztostart)$)
start angle=\n{@kc@},
delta angle=\pgfkeysvalueof{/tikz/@kinky cross}180 ]
-- (\tikztotarget)}}}

\begin{document}
\begin{tikzpicture}

\node (a) at (-1,0) {a};
\node (b) at (1,0) {b};
\node (c) at (0,1) {c};
\node (d) at (0,-1) {d};

\draw (a) -- (b);
\draw (c) to [kinky cross=(a)--(b), kinky crosses=left] (d);

\end{tikzpicture}
\end{document}


Which results in:

So, the problem is: I have a straight wire from c -- d, and I need to skip above it when going from a -- b.

Have I misunderstood? It seems to me that you only need to swap the roles of (a)--(b) and (c)--(d):

Here's the full code:

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\usepackage{circuitikz}
\pagestyle{empty}

\tikzset{
declare function={% in case of CVS which switches the arguments of atan2
atan3(\a,\b)=ifthenelse(atan2(0,1)==90, atan2(\a,\b), atan2(\b,\a));},
@kinky cross/.initial=+, kinky crosses/.is choice,
kinky crosses/left/.style={@kinky cross=-},kinky crosses/right/.style={@kinky cross=+},
kinky cross/.style args={(#1)--(#2)}{
to path={
let \p{@kc@}=($(\tikztotarget)-(\tikztostart)$),
\n{@kc@}={atan3(\p{@kc@})+180} in
-- ($(intersection of \tikztostart--{\tikztotarget} and #1--#2)!% \pgfkeysvalueof{/tikz/kinky cross radius}!(\tikztostart)$)
start angle=\n{@kc@},
delta angle=\pgfkeysvalueof{/tikz/@kinky cross}180 ]
-- (\tikztotarget)}}}

\begin{document}
\begin{tikzpicture}

\node (a) at (-1,0) {a};
\node (b) at (1,0) {b};
\node (c) at (0,1) {c};
\node (d) at (0,-1) {d};

\draw (c) -- (d);
\draw (a) to [kinky cross=(c)--(d), kinky crosses=left] (b);

\end{tikzpicture}
\end{document}

• How did I miss that? Should have tried in the MWE. I tried in my complex circuit, but with one coordinate wrong. Tried hard to make work in the circuit that I didn't even bother to try also in the MWE. Sorry and tks!
– Isma
Oct 10, 2017 at 17:23