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?
Best Answer
Addressing your specific questions, but in reverse order:
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 throughnode1
and a vertical one pasing throughnode2
. 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)$)
, beingfactor
a real number between 0 and 1. This syntax requires usually\usetikzlibrary{calc}
, but apparentlycircuitikz
already includes it.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 styleo-
. You can also use the connection style-*
to get the black circles.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: