3

I'm trying to understand how wire crossings work with CircuiTikz. I have seen the famous "Kink crossings" but I would like first trying to solve the problem with the crossings CircuiTikz provides.

For instance: How would you draw a crossing on that intersection using the CircuiTikz package? Without knowing the coordinates nor relative position of the turn from C to D.

enter image description here

This is the code I wrote:

\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[]{circuitikzgit}
\begin{document}
    \begin{circuitikz}
       \draw (0,0)node[circ]{a} -- (4,0)node[circ]{b};
       \draw (1,2)node[circ]{c} |- (3,-2)node[circ]{d};
    \end{circuitikz}
\end{document}

It is important for me not to use the node-style format that the manual suggests, because this is for a bigger/more complex circuit I'm drawing and I would like to draw the crossing similar to a path style from one coordinate to another like:

\draw (1,2)node[circ]{c} to[crossing] |- (3,-2)node[circ]{d};

But obviously this does not work.

As you can see I have used the last release of CircuiTikz, this is were you can get it.

ElSabio
  • 361
  • https://tex.stackexchange.com/questions/111660/intersection-of-2-lines-not-really-connected-in-tikz?noredirect=1&lq=1 – js bibra Dec 29 '19 at 13:22
  • https://tex.stackexchange.com/a/118257/197451 – js bibra Dec 29 '19 at 13:23
  • Seems legit, but isn't there any other way to do this with the own tools CircuiTikz provides? It looks so simple and easy to implement that I think I am missing something... – ElSabio Dec 29 '19 at 13:28
  • https://tex.stackexchange.com/questions/395493/kink-cross-over-above-vertical-wires – js bibra Dec 29 '19 at 13:32
  • https://tex.stackexchange.com/questions/134067/circuitikz-wire-kink-thingy-when-wires-cross – js bibra Dec 29 '19 at 13:32
  • Yes thank you for that, but as I wrote, I would like to use the proper CircuiTikz tools before jumping to another functions. – ElSabio Dec 29 '19 at 13:33
  • http://mirrors.ibiblio.org/CTAN/graphics/pgf/contrib/circuitikz/doc/circuitikzmanual.pdf -- page 54 – js bibra Dec 29 '19 at 13:35
  • http://www.texample.net/tikz/examples/line-junction/ – js bibra Dec 29 '19 at 13:37
  • Yeah more of the same I guess, as I wrote on the post, I would like to understand how the crossings work when the lines that intersect have turns and whose coordinates or relative positions are unknown. I hope you no longer post random info you just find in google to post it here hehe, I bet you are not even going to read this comment. – ElSabio Dec 29 '19 at 13:42
  • 2
    The manual that @jsbibra linked states that the crossing jumper will be put in the center of the subpath where the to[crossing] is issued, so sometime a bit of trial and error is needed to position it. As I understand it this means that you cannot use this kind of crossing if you don't know (or don't want to try out) where the crossing is, in case it is not in the center of a line. The same goes for explicit crossing nodes described below in the manual. – Marijn Dec 29 '19 at 13:58

2 Answers2

6

The problem is that (a) |- (b) is processed as two separate sections and to[crossing] can only handle one.

\documentclass[border=10pt]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
  \draw (0,0)node[circ]{a} -- (4,0)node[circ]{b};
  \draw (1,2)node[circ]{c} to[crossing] (1,2 |- 3,-2) -- (3,-2)node[circ]{d};

\end{circuitikz}
\end{document}

demo


This version steals shamelessly from Fractal, but replaces the circ with a jump crossing.

\documentclass[border=10pt]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{intersections}

\newlength{\crossing}
\makeatletter
\setlength{\crossing}{\ctikzvalof{bipoles/crossing/size}\pgf@circ@Rlen}
\makeatother

\begin{document}
\begin{circuitikz}
  \draw[name path=ab] (0,0)node[circ]{a} -- (4,0)node[circ]{b};
  \draw[name path=cd] (1,1)node[circ]{c} |- (3,-2)node[circ]{d};
  \path[name intersections={of=ab and cd,by=e}];
  \fill[color=white] (e) circle[radius=0.5\crossing];% erase plain crossing
  \draw (e) node[jump crossing]{};
\end{circuitikz}
\end{document}

One can also use:

\path [name intersections={of=ab and cd,by=e}]
    [fill=white] (e) circle[radius=0.5\crossing]% erase plain crossing
    node[jump crossing,rotate=90]{};
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
3

As circuitikz is basically a (very good) extension of TikZ, I see absolutely no reasons why I should not use standard TikZ syntaxes for this.

\documentclass[a4paper,12pt]{article}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{circuitikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{circuitikz}
  \draw[name path=ab] (0,0)node[circ]{a} -- (4,0)node[circ]{b};
  \draw[name path=cd] (1,2)node[circ]{c} |- (3,-2)node[circ]{d};
  \path[name intersections={of=ab and cd,by=e}] (e) node[circ] {e};
\end{circuitikz}
\end{document}

enter image description here

fractal
  • 1,500