0

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}

%answer from Qrrbrbirlbel for https://tex.stackexchange.com/questions/134067/circuitikz-wire-kink-thingy-when-wires-cross
\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 radius/.initial=+.125cm,
  @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)$)
      arc [ radius     =\pgfkeysvalueof{/tikz/kinky cross radius},
            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: enter image description here

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

1 Answer 1

1

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

enter image description here

Here's the full code:

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

%answer from Qrrbrbirlbel for https://tex.stackexchange.com/questions/134067/circuitikz-wire-kink-thingy-when-wires-cross
\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 radius/.initial=+.125cm,
  @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)$)
      arc [ radius     =\pgfkeysvalueof{/tikz/kinky cross radius},
            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}
1
  • 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .