0

I am a Latex beginner and I am trying to add some black dots in a circuit.

Here you are my code:

\documentclass[10pt,english, openany]{book}

\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{matrix,calc, arrows, shapes.gates.logic.US,}

\begin{document}
\begin{circuitikz}[label distance=2mm, scale=2]
\node (x) at (0.5,0) {$x$};
\node (y) at (1,0) {$y$};
\node (z) at (1.5,0) {$z$};
\node (w) at (2,0) {$w$};
\node[and gate US, draw, rotate=0, logic gate inputs=nnn, scale=1.5] at ($(w)+(2,-1)$) (t1) {$\bar{x}\bar{y}\bar{w}\phantom{q}$};
\node[and gate US, draw, rotate=0, logic gate inputs=nnn, scale=1.5] at ($(w)+(2,-2)$) (t2) {$xzw\phantom{q}$};
\node[and gate US, draw, rotate=0, logic gate inputs=nnnn, scale=1.5] at ($(w)+(2,-3)$) (t3) {$xy\bar{z}\bar{w}$};
\node[and gate US, draw, rotate=0, logic gate inputs=nnnn, scale=1.5] at ($(w)+(2,-4)$) (t4) {$\bar{x}y\bar{z}w$};
\node[not gate US, draw, scale=0.75] at ($(t1.input 1)+(-0.5,0)$) (nx1) {};
\node[not gate US, draw, scale=0.75] at ($(t1.input 2)+(-0.5,0)$) (ny1) {};
\node[not gate US, draw, scale=0.75] at ($(t1.input 3)+(-0.5,0)$) (nw1) {};
\node[not gate US, draw, scale=0.75] at ($(t3.input 3)+(-0.5,0)$) (nz3) {};
\node[not gate US, draw, scale=0.75] at ($(t3.input 4)+(-0.5,0)$) (nw3) {};
\node[not gate US, draw, scale=0.75] at ($(t4.input 1)+(-0.5,0)$) (nx4) {};
\node[not gate US, draw, scale=0.75] at ($(t4.input 3)+(-0.5,0)$) (nz4) {};
\node[or gate US, draw, logic gate inputs=nnnn, scale=1.25] at ($(t3.output) + (2, 0.5)$) (orTot) {$f(x,y,z,w)$};

\draw (x) -- ($(x) + (0,-4.5)$);
\draw (y) -- ($(y) + (0,-4.5)$);
\draw (z) -- ($(z) + (0,-4.5)$);
\draw (w) -- ($(w) + (0,-4.5)$);

\draw (nx1) -- (t1.input 1);
\draw (ny1) -- (t1.input 2);
\draw (nw1) -- (t1.input 3);
\draw (nz3) -- (t3.input 3);
\draw (nw3) -- (t3.input 4);
\draw (nx4) -- (t4.input 1);
\draw (nz4) -- (t4.input 3);

\draw (x) |- (nx1);
\draw (x) |- (nx4);
\draw (y) |- (ny1);
\draw (z) |- (nz3);
\draw (z) |- (nz4);
\draw (w) |- (nw1);
\draw (w) |- (nw3);

\draw (x) |- (t2.input 1);
\draw (z) |- (t2.input 2);
\draw (w) |- (t2.input 3);
\draw (x) |- (t3.input 1);
\draw (y) |- (t3.input 2);
\draw (y) |- (t4.input 2);
\draw (w) |- (t4.input 4);

\draw (t1.output) -- ([xshift=0.3cm]t1.output) |- (orTot.input 1);
\draw (t2.output) -- ([xshift=0.2cm]t2.output) |- (orTot.input 2);
\draw (t3.output) -- ([xshift=0.2cm]t3.output) |- (orTot.input 3);
\draw (t4.output) -- ([xshift=0.3cm]t4.output) |- (orTot.input 4);

\end{circuitikz}
\end{document}

And here you are the result:

enter image description here

As you can see the left part of the circuit is a little bit messy as it is difficult to distinguish between inputs, that's why I'd like to have some dots on the input vertical lines.

How can I add them? Is there an automatic way to do it?
Thank you in advance for your patience.

1
  • 1
    Just a notice - the tag was wrong, this is not related to circuitikz; the circuit library of TikZ and circuitikz are very different packages. – Rmano Apr 27 '20 at 21:37
2

To set the dots at the connections with the vertical lines you can set a node as a small filled circle. You have drawn the lines as |- meaning you want to draw the dot at the knee, which you find by pos=0.5.

\documentclass[10pt,english, openany]{book}

\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{matrix,calc, arrows, shapes.gates.logic.US,}

\begin{document}
\begin{circuitikz}[label distance=2mm, scale=2,
  connection/.style={draw,circle,fill=black,inner sep=1.5pt}
  ]
\node (x) at (0.5,0) {$x$};
\node (y) at (1,0) {$y$};
\node (z) at (1.5,0) {$z$};
\node (w) at (2,0) {$w$};
\node[and gate US, draw, rotate=0, logic gate inputs=nnn, scale=1.5] at ($(w)+(2,-1)$) (t1) {$\bar{x}\bar{y}\bar{w}\phantom{q}$};
\node[and gate US, draw, rotate=0, logic gate inputs=nnn, scale=1.5] at ($(w)+(2,-2)$) (t2) {$xzw\phantom{q}$};
\node[and gate US, draw, rotate=0, logic gate inputs=nnnn, scale=1.5] at ($(w)+(2,-3)$) (t3) {$xy\bar{z}\bar{w}$};
\node[and gate US, draw, rotate=0, logic gate inputs=nnnn, scale=1.5] at ($(w)+(2,-4)$) (t4) {$\bar{x}y\bar{z}w$};
\node[not gate US, draw, scale=0.75] at ($(t1.input 1)+(-0.5,0)$) (nx1) {};
\node[not gate US, draw, scale=0.75] at ($(t1.input 2)+(-0.5,0)$) (ny1) {};
\node[not gate US, draw, scale=0.75] at ($(t1.input 3)+(-0.5,0)$) (nw1) {};
\node[not gate US, draw, scale=0.75] at ($(t3.input 3)+(-0.5,0)$) (nz3) {};
\node[not gate US, draw, scale=0.75] at ($(t3.input 4)+(-0.5,0)$) (nw3) {};
\node[not gate US, draw, scale=0.75] at ($(t4.input 1)+(-0.5,0)$) (nx4) {};
\node[not gate US, draw, scale=0.75] at ($(t4.input 3)+(-0.5,0)$) (nz4) {};
\node[or gate US, draw, logic gate inputs=nnnn, scale=1.25] at ($(t3.output) + (2, 0.5)$) (orTot) {$f(x,y,z,w)$};

\draw (x) -- ($(x) + (0,-4.5)$);
\draw (y) -- ($(y) + (0,-4.5)$);
\draw (z) -- ($(z) + (0,-4.5)$);
\draw (w) -- ($(w) + (0,-4.5)$);

\draw (nx1) -- (t1.input 1);
\draw (ny1) -- (t1.input 2);
\draw (nw1) -- (t1.input 3);
\draw (nz3) -- (t3.input 3);
\draw (nw3) -- (t3.input 4);
\draw (nx4) -- (t4.input 1);
\draw (nz4) -- (t4.input 3);

\draw (x) |- (nx1) node[connection,pos=0.5]{};
\draw (x) |- (nx4) node[connection,pos=0.5]{};
\draw (y) |- (ny1) node[connection,pos=0.5]{};
\draw (z) |- (nz3) node[connection,pos=0.5]{};
\draw (z) |- (nz4) node[connection,pos=0.5]{};
\draw (w) |- (nw1) node[connection,pos=0.5]{};
\draw (w) |- (nw3) node[connection,pos=0.5]{};

\draw (x) |- (t2.input 1) node[connection,pos=0.5]{};
\draw (z) |- (t2.input 2) node[connection,pos=0.5]{};
\draw (w) |- (t2.input 3) node[connection,pos=0.5]{};
\draw (x) |- (t3.input 1) node[connection,pos=0.5]{};
\draw (y) |- (t3.input 2) node[connection,pos=0.5]{};
\draw (y) |- (t4.input 2) node[connection,pos=0.5]{};
\draw (w) |- (t4.input 4) node[connection,pos=0.5]{};

\draw (t1.output) -- ([xshift=0.3cm]t1.output) |- (orTot.input 1);
\draw (t2.output) -- ([xshift=0.2cm]t2.output) |- (orTot.input 2);
\draw (t3.output) -- ([xshift=0.2cm]t3.output) |- (orTot.input 3);
\draw (t4.output) -- ([xshift=0.3cm]t4.output) |- (orTot.input 4);

\end{circuitikz}
\end{document}

enter image description here

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.