2

I want to combine the perpendicular drawing of Tikz (|-) with the wire ending shapes of Circuitikz (*-) that is use inside the to operand. I want to do something like the last line of code where the |- has no effect.

\begin{circuitikz}[x=10mm,y=10mm]
    \draw   (0,0) to[inline not] ++(2,0) coordinate (A) to[inline not] ++(2,0) coordinate (B) to[inline not] ++(2,0) coordinate (C) to[inline not] ++(2,0) coordinate (D);
    \tikzset{mux/.style={muxdemux, muxdemux def={Lh=6, Rh=4, NL=4, NB=2, NR=1}}}
    \draw (5,-4) node[mux,rotate=-90] (sel) {A};

    \draw (D) |- ($(D)!0.5!(sel.lpin 1)$) -| (sel.lpin 1);
    \draw (C) |- ($(C)!0.5!(sel.lpin 2)$) -| (sel.lpin 2);
    \draw (B) |- ($(B)!0.5!(sel.lpin 3)$) -| (sel.lpin 3);
    \draw (A) to[short,*-,|-] ($(A)!0.5!(sel.lpin 4)$) -| (sel.lpin 4);
\end{circuitikz}

My output.

Thank you

2
  • to path={ |- (\tikztotarget)}?
    – user240002
    Apr 20, 2021 at 20:21
  • @user240002 maybe it would be possible but the to path macro of circuitikz is already a mess as it is, not sure if I want to do that... ;-)
    – Rmano
    Apr 20, 2021 at 20:25

2 Answers 2

2

You can't chain the to syntax with the |- because the syntax is (coord) to[] (coord) to draw an element. It will not work because |- is already a path element; it would be like saying (coord) to[element] to[vertical and horizontal wire] (coord) so Tikz does not know the intermediate point.

The easier solution here is to use this for your last line:

\draw (A)  node[circ]{} |- ($(A)!0.5!(sel.lpin 4)$) -| (sel.lpin 4); 
2
  • I am on a tablet now, sorry if the answer is not so well organized...
    – Rmano
    Apr 20, 2021 at 20:26
  • No problem, it works fine to me, so Ill take it. It's rare that you can't do both thing together in one step. Maybe I can build a macro that uses the calc library for more compact solution. Thanks
    – Agustin
    Apr 20, 2021 at 20:56
1

You can also use (A |- B) for the point below or above A and left or right of B.

\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}[x=10mm,y=10mm]
    \draw   (0,0) to[inline not] ++(2,0) coordinate (A) to[inline not] ++(2,0) coordinate (B) to[inline not] ++(2,0) coordinate (C) to[inline not] ++(2,0) coordinate (D);
    \tikzset{mux/.style={muxdemux, muxdemux def={Lh=6, Rh=4, NL=4, NB=2, NR=1}}}
    \draw (5,-4) node[mux,rotate=-90] (sel) {A};
    
    \coordinate (E) at ($(A)!0.5!(sel.lpin 4)$);% common north/south midpoint

    \draw (D) -- (D |- E) -| (sel.lpin 1);
    \draw (C) -- (C |- E) -| (sel.lpin 2);
    \draw (B) -- (B |- E) -| (sel.lpin 3);
    \draw (A) to[short,*-] (A |- E) -| (sel.lpin 4);
\end{circuitikz}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.