# Small handlers at end and beginning

I want to draw several diagrams for boolean circuits, as $w + x(y + zx')$. Is there a Tikz's library to draw this component? I'm sure there is a right way to do it but can't find anything in circuits library. I have this so far:

    \documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (1,0);
\draw (1.07,-0.014) node {$\circ$};
\draw (1.5,0.07) node {$x$};
\draw (2-0.07,-0.014) node {$\circ$};
\draw (2,0) -- (3,0);
\end{tikzpicture}
\end{document}


EDIT: Jul 10, 2019, 07:27 CDT

Just found arrows.meta library and the tip Circle[open], so I improved my code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw (0,0) [arrows = -{Circle[open]}] -- (1,0);
\draw (1.25,0.07) node {$x$};
\draw (1.5,0) [arrows = {Circle[open]}-] -- (2.5,0);
\end{tikzpicture}
\end{document}


Looks fine to me! • Do you have a web link that explains this notation $w + x(y + zx')$? Jul 10 '19 at 11:59
• @AndréC, they are boolean variables, + is unión, product is intersection, and prima is complement. Shannon use dual meaning in ccapitalia.net/descarga/docs/… Jul 10 '19 at 12:43
• Yes @AndréC, it is! Jul 13 '19 at 14:11
• It is better to answer your own question by stating that my solution gave you the idea. Answering your own question is encouraged here: tex.stackexchange.com/help/self-answer Jul 13 '19 at 17:18

I don't know if there is a library that does what you want. And I'm not sure I'll answer your question.

I created an arrow with TikZ that I called circ which has a radius of 1.5pt.

\pgfdeclarearrow{
name = circ,
parameters = { },
setup code = { },
drawing code = {
\newdimen\arrowsize%
\arrowsize=0.5pt%
\pgfsetdash{}{+0pt}%
\pgfsetmiterjoin%
\pgfsetfillcolor{white}
\pgfpathcircle{\pgfpoint{3\arrowsize}{0}} {3\arrowsize}%
\pgfusepathqfillstroke%
},
defaults = { }
}


The arrow is the same size as \circ. And I anchored the text to the base so it would be the same height as yours. \documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\pgfdeclarearrow{
name = circ,
parameters = { },
setup code = { },
drawing code = {
\newdimen\arrowsize%
\arrowsize=0.5pt%
\pgfsetdash{}{+0pt}%
\pgfsetmiterjoin%
\pgfsetfillcolor{white}
\pgfpathcircle{\pgfpoint{3\arrowsize}{0}} {3\arrowsize}%
\pgfusepathqfillstroke%
},
defaults = { }
}
\begin{document}
% We see that the new arrow circ at the same size as \circ
\begin{tikzpicture}
\draw[-circ] (0,0) -- (1,0);% new arrow circ
\draw (1.5,0.07) node {$x$};
\draw (2-0.07,0) node {$\circ$};% \circ
\draw (2,0) -- (3,0);

\begin{scope}[blue,yshift=-5mm]
% second draw with new circ arrow only
\draw[-circ] (0,0) -- (1,0)node (a){};
\draw[circ-] (2,0)node(b){} -- (3,0);
\node[anchor=base] at ($(a)!.5!(b)$) {$x$};
\end{scope}

\end{tikzpicture}
\end{document}


For fun, a veryshort code with pstricks:

\documentclass[border=4pt]{standalone}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}

\begin{document}

\begin{psmatrix}[mnode=r, emnode=p, colsep=0.8cm]
[name = L] & \psDefBoxNodes{X}{\makebox[2em]{$x$}} & [name=R]
\psset{ arrows =o-, linewidth=0.4pt,}%
\psline(X:Cl)(L) \psline(X:Cr)(R)%
\end{psmatrix}

\end{document} 