我想绘制几个布尔电路图,如$w + x(y + zx')$
。是否有 Tikz 库可以绘制此组件?
我确信有正确的方法可以做到这一点,但在电路库中找不到任何东西。到目前为止,我有这个:
\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}
编辑:2019 年 7 月 10 日,07:27 CDT
刚刚找到arrows.meta
库和提示Circle[open]
,所以我改进了我的代码:
\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}
我觉得看起来不错!
答案1
我不知道是否有一个库可以满足您的要求。而且我不确定我是否会回答您的问题。
我创建了一个arrow
带有 TikZ 的,我称之为,circ
它有一个radius of 1.5pt
。
\pgfdeclarearrow{
name = circ,
parameters = { },
setup code = { },
drawing code = {
\newdimen\arrowsize%
\arrowsize=0.5pt%
\pgfsetdash{}{+0pt}%
\pgfsetmiterjoin%
\advance\arrowsize by .25\pgflinewidth
\pgfsetfillcolor{white}
\pgfpathcircle{\pgfpoint{3\arrowsize}{0}} {3\arrowsize}%
\pgfusepathqfillstroke%
},
defaults = { }
}
箭头的大小与 相同\circ
。我将文本锚定到底部,以便它的高度与您的高度相同。
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\pgfdeclarearrow{
name = circ,
parameters = { },
setup code = { },
drawing code = {
\newdimen\arrowsize%
\arrowsize=0.5pt%
\pgfsetdash{}{+0pt}%
\pgfsetmiterjoin%
\advance\arrowsize by .25\pgflinewidth
\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}
答案2
为了好玩,一个非常短的代码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}