# [Tex/LaTex] Drawing a circuit structure in LaTeX

circuitikzdiagramstikz-pgf

I want to create the following structure in LaTeX:

Unfortunately I couldn't find a similar example in the pgf manual using the same symbols. An answer just showing basically how to produce a structure like the image shows, meaning a bit of code from which I can deduce the rest, would be fine.

EDIT: After taking a look at the circuitikz documentation, I came to the following result:

\documentclass{article}
\usepackage{circuitikz}

\begin{document}

\begin{tikzpicture}
\node [ocirc, label=left:1]       (1) at (0,3) {};
\node [ocirc, label=left:0]       (0) at (0,2) {};
\node [ocirc, label=left:{$x_1$}] (x) at (0,1) {};
\node [ocirc, label=left:{$\overline{x_1}$}] (nx) at (0,0) {};
\node [ocirc, label=right:{$y$}] (y) at (5,1.5) {};

\node [circ] (c1) at (4,2) {};
\node [circ] (c2) at (4,1) {};
\node [circ] (c3) at (4,1.5) {};

\draw (c3) to (y);
\draw (1) to[cspst] (4,3);
\draw (0) to[cspst] (c1);
\draw (x) to[cspst] (c2);
\draw (nx)to[cspst] (4,0);
\draw (4,3) to (4,0);
\end{tikzpicture}

\end{document}


Resulting in:

Now my more precise questions are:

• How can I draw lines with multiple cspst at a specific place?
• How to avoid the line begining in the ocirc?
• Is there a simpler way without using coordinates?

Addressing your specific questions, but in reverse order:

1. Is there a simpler way without using coordinates?

Yes. You can use positioning tikz library which allows you to specify the placement of a new node or coordinate relative to the position to another node, with a simple syntax: \node[below=1cm of 0], for example, asuming that (0) is the name of a known node. In fact, the use of absolute coordinates can be avoided for the the whole figure, as the example at the end shows.

In adition, you can use intersection coordinate system, which allows to define the placement of a new coordinate as the intersection of a horizontal and a vertical line passing through other two nodes. For example (node1-|node2) is the coordinate at the intersection of a horizontal line passing through node1 and a vertical one pasing through node2. You can use this trick to specify the positions of your "black circles".

Finally, it is also very convenient the use of interpolated coordinates as a way to specify a point which lays in a line bewteen any other two given nodes. The syntax is ($(node1)!<factor>!(node2)$), being factor a real number between 0 and 1. This syntax requires usually \usetikzlibrary{calc}, but apparently circuitikz already includes it.

2. How to avoid the line begining in the ocirc?

I assume you mean how to avoid the line intersecting the circle. I would avoid completly the use of the node shape ocirc, using instead a "shapeless" node, and the connection style o-. You can also use the connection style -* to get the black circles.

3. How can I draw lines with multiple cspst at a specific place?

I would "break" the path into several sub-paths, inserting cspst in those sub-paths. Interpolating coordinates (as explained above) for the intermediate points looks the most convenient solution.

The following MWE shows all these ideas in action:

\documentclass{article}
\usepackage{circuitikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
\node [label=left:1]                       (1) {};
\node [label=left:0, below=1cm of 1]       (0) {};
\node [label=left:{$x_1$}, below=1cm of 0] (x) {};
\node [label=left:{$\overline{x_1}$}, below=1cm of x]
(nx) {};

% Auxiliary coordinate: the point where all branches join
\coordinate[above right=5mm and 5cm of x] (right side);
\node [label=right:{$y$}, right=1cm of right side]
(y) {};

% Auxiliary coordinates, right end of each branch
\coordinate (1r)  at (1  -|right side);
\coordinate (0r)  at (0  -|right side);
\coordinate (xr)  at (x  -|right side);
\coordinate (nxr) at (nx -|right side);

\draw (1) to[cspst, o-]  ($(1)!.3!(1r)$) to[cspst]     (1r);
\draw (0) to[cspst, o-]  ($(0)!.7!(0r)$) to[cspst, -*] (0r);
\draw (y) to[short, o-*] (y-|right side);
\draw (x) to[cspst, o-]  ($(x)!.3!(xr)$)
to[short]      ($(x)!.7!(xr)$) to[cspst,-*] (xr);
\draw (nx)to[short,o-]   ($(nx)!.3!(nxr)$)
to[cspst]      ($(nx)!.5!(nxr)$)
to[cspst]      ($(nx)!.7!(nxr)$) to [short] (nxr);
\draw (1r) -- (nxr);
\end{tikzpicture}
\end{document}