我想用 LaTeX 来画这个:
这是我目前所拥有的:
%%%%%PREAMBLE%%%%%
\documentclass[border=0.25cm]{standalone}
\usepackage{circuitikz}
%%%%%HEAD%%%%%
\begin{document}
\begin{circuitikz}
%%%%%OBJECTS%%%%%
\draw (-3.50,-3.00) -- ++(0,3.50) node[above] (x) {\(x\)};
\draw (-2.50,-3.00) -- ++(0,3.50) node[above] (y) {\(y\)};
\draw (-1.50,-3.00) -- ++(0,3.50) node[above] (z) {\(z\)};
%%%%%%%%%%%%%%%%%
\draw (+0.67,-1.00) node[and port] (and2){};
\draw (+4.50,-1.00) node[and port] (and1){};
\draw (+0.00,-2.50) node[not port] (not2){};
\draw (+2.50,-1.75) node[or port] (orr1){};
%%%%%INPUTS%%%%%%
\draw[fill] (and1.in 1) -- (x |- and1.in 1) circle (1pt);
\draw[fill] (and2.in 2) -- (y |- and2.in 2) circle (1pt);
\draw[fill] (not2.in) -- (y |- not2.in) circle (1pt);
\draw[fill] (and2.in 1) -- (z |- and2.in 1) circle (1pt);
%%%%%%%%%%%%%%%%%
\draw (and2.out) -- (orr1.in 1);
\draw (not2.out) -- (orr1.in 2);
\draw (orr1.out) -- (and1.in 2);
%%%%%OUTPUT%%%%%%
\draw (and1.out) node[right=0.63cm](M){$M$};
\draw (and1.out) -- (M);
%%%%%TAIL%%%%%
\end{circuitikz}
\end{document}
显然,我只需移动一个与门,这样它们就不是直接平行的,但对输出的绝对控制会更好。
此外,如果我能让“与”门和非“非”门完美排列,那就太好了,但这并不是关键。
答案1
您可以随意绘制线条。像 这样的坐标and1.in 1
只是tikz
节点上的坐标。通过添加\usetikzlibrary{calc}
到序言中,您可以进行坐标操作。有时通过添加坐标可以更容易地看到您正在做什么。下面tmp
只是提升了 0.6 厘米。然后我首先绘制到和相交and1.in 1
的坐标,然后再回到。tmp
orr1.out
x
\coordinate (tmp) at ($(and1.in 1)+(0,0.6)$);
% \draw (tmp) circle (2pt);% Just to see where the coordinate is
\draw (and1.in 1) --(orr1.out |- tmp) -- (x |- tmp);
\draw[fill] (x |- tmp) circle (1pt);
也可以一次性完成\draw
\draw (and1.in 1) -- ($(orr1.out |- and1.in 1) + (0,0.6)$) -- ($(x |- and1.in 1) + (0,0.6)$) node[fill,circle,inner sep=1pt]{};
我猜这不是你要求的颜色,但它在这里:-)
\draw[color=red!40!yellow!100,thick] (and1.in 1) -- ($(orr1.out |- and1.in 1) + (0,0.6)$) -- ($(x |- and1.in 1) + (0,0.6)$) node[fill,circle,inner sep=1pt]{};