在 Latex 中管理逻辑门内的文本

在 Latex 中管理逻辑门内的文本

我正在寻找一种方法来使逻辑门内的文本变得更大。

这是我的代码:

\documentclass[10pt,english, openany]{book}

\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{matrix,calc, arrows, shapes.gates.logic.US,}

\begin{document}
\begin{circuitikz}[label distance=2mm, scale=2,
  connection/.style={draw,circle,fill=black,inner sep=1.5pt}
  ]

\node (x) at (0.5,0) {$x$};
\node (y) at (1.5,0) {$y$};
\node (z) at (2.5,0) {$z$};
\node (w) at (3.5,0) {$w$};

\node[not gate US, draw, rotate=270, scale=0.75] at ($(x)+(0.5,-0.5)$) (notx) {};
\node[not gate US, draw, rotate=270, scale=0.75] at ($(y)+(0.5,-0.5)$) (noty) {};
\node[not gate US, draw, rotate=270, scale=0.75] at ($(z)+(0.5,-0.5)$) (notz) {};
\node[not gate US, draw, rotate=270, scale=0.75] at ($(w)+(0.5,-0.5)$) (notw) {};

\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-1.6)$) (t1) {$x+y+z+\bar{w}$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-2.4)$) (t2) {$x+y+\bar{z}+\bar{w}$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-3.2)$) (t3) {$x+\bar{y}+z+w$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-4.0)$) (t4) {$x+\bar{y}+\bar{z}+w$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-4.8)$) (t5) {$x+y+z+\bar{w}$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-5.6)$) (t6) {$x+y+z+\bar{w}$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-6.4)$) (t7) {$x+y+z+\bar{w}$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-7.2)$) (t8) {$x+y+z+\bar{w}$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-8.0)$) (t9) {$x+y+z+\bar{w}$};
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.5] at ($(w)+(1.5,-8.83)$) (t10) {$x+y+z+\bar{w}$};

\node[and gate US, draw, logic gate inputs=nnnnnn, scale=1.25] at ($(t5.output) + (2, 0)$) (andTot) {$f(x,y,z,w)$};

\draw (x) -| (notx) {};
\draw (y) -| (noty) {};
\draw (z) -| (notz) {};
\draw (w) -| (notw) {};

\draw (x) -- ($(x) + (0,-6.8)$);
\draw (y) -- ($(y) + (0,-6.8)$);
\draw (z) -- ($(z) + (0,-6.8)$);
\draw (w) -- ($(w) + (0,-6.8)$);

\draw (notx) -- ($(notx) + (0,-6.3)$);
\draw (noty) -- ($(noty) + (0,-6.3)$);
\draw (notz) -- ($(notz) + (0,-6.3)$);
\draw (notw) -- ($(notw) + (0,-6.3)$);

\draw (notx) |- (t1.input 1) node[connection,pos=0.5]{};
\draw (notx) |- (t2.input 1) node[connection,pos=0.5]{};
\draw (notx) |- (t3.input 1) node[connection,pos=0.5]{};
\draw (noty) |- (t1.input 2) node[connection,pos=0.5]{};
\draw (noty) |- (t2.input 2) node[connection,pos=0.5]{};
\draw (noty) |- (t4.input 2) node[connection,pos=0.5]{};
\draw (notz) |- (t1.input 3) node[connection,pos=0.5]{};
\draw (notz) |- (t3.input 3) node[connection,pos=0.5]{};
\draw (notz) |- (t5.input 3) node[connection,pos=0.5]{};
\draw (notw) |- (t1.input 4) node[connection,pos=0.5]{};
\draw (notw) |- (t2.input 4) node[connection,pos=0.5]{};
\draw (notw) |- (t5.input 4) node[connection,pos=0.5]{};

\draw (x) |- (t4.input 1) node[connection,pos=0.5]{};
\draw (x) |- (t5.input 1) node[connection,pos=0.5]{};
\draw (x) |- (t6.input 1) node[connection,pos=0.5]{};
\draw (y) |- (t3.input 2) node[connection,pos=0.5]{};
\draw (y) |- (t5.input 2) node[connection,pos=0.5]{};
\draw (y) |- (t6.input 2) node[connection,pos=0.5]{};
\draw (z) |- (t2.input 3) node[connection,pos=0.5]{};
\draw (z) |- (t4.input 3) node[connection,pos=0.5]{};
\draw (z) |- (t6.input 3) node[connection,pos=0.5]{};
\draw (w) |- (t3.input 4) node[connection,pos=0.5]{};
\draw (w) |- (t4.input 4) node[connection,pos=0.5]{};
\draw (w) |- (t6.input 4) node[connection,pos=0.5]{};

\end{circuitikz}
\end{document}

结果如下:

在此处输入图片描述

电路尚未完成,但我认为问题很明显:或门内的文本太小。
有没有办法让它变大?如果没有,最好将其移动到门上方,以便即使文本是正常大小,也可以使它们变小。

感谢您的耐心。

答案1

门内的空间是有限的,字体大小会减小——为什么不试试门的输出呢?无论如何,它都是 4 个输入的总和

在此处输入图片描述

将以下内容添加到您的代码中

\draw (t1.output) -- node[above]{$x+y+z+\bar{w}$} ($(t1) + (1.5, 0)$);

答案2

您可以使用以下方法缩放标签中的字体大小{\Large{$x+y+z+\bar{w}$}},但这会影响门的大小并需要重新定位。我对此的看法是使用节点定义内的标签并相应地缩放门。文本位于门的顶部,但如果您需要,可以使用角度编号和冒号选择您想要的角度,例如现在它相当于标签=90:$myLabel$ 请参阅下面的示例

\documentclass[10pt,english, openany]{book}

\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{matrix,calc, arrows, shapes.gates.logic.US,}

\begin{document}
\begin{circuitikz}[label distance=2mm, scale=2,
  connection/.style={draw,circle,fill=black,inner sep=1.5pt}
  ]

\node (x) at (0.5,0) {$x$};
\node (y) at (1.5,0) {$y$};
\node (z) at (2.5,0) {$z$};
\node (w) at (3.5,0) {$w$};

\node[not gate US, draw, rotate=270, scale=0.75] at ($(x)+(0.5,-0.5)$) (notx) {};
\node[not gate US, draw, rotate=270, scale=0.75] at ($(y)+(0.5,-0.5)$) (noty) {};
\node[not gate US, draw, rotate=270, scale=0.75] at ($(z)+(0.5,-0.5)$) (notz) {};
\node[not gate US, draw, rotate=270, scale=0.75] at ($(w)+(0.5,-0.5)$) (notw) {};

\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-1.6)$) (t1) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-2.4)$) (t2) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-3.2)$) (t3) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-4.0)$) (t4) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-4.8)$) (t5) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-5.6)$) (t6) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-6.4)$) (t7) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-7.2)$) (t8) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-8.0)$) (t9) {}; 
\node[or gate US, draw, rotate=0, logic gate inputs=nnnn, scale=0.8,label={\small{$x+y+z+\bar{w}$}}] at ($(w)+(1.5,-8.83)$) (t10) {}; 

\node[and gate US, draw, logic gate inputs=nnnnnn, scale=1.25] at ($(t5.output) + (2, 0)$) (andTot) {$f(x,y,z,w)$};

\draw (x) -| (notx) {};
\draw (y) -| (noty) {};
\draw (z) -| (notz) {};
\draw (w) -| (notw) {};

\draw (x) -- ($(x) + (0,-6.8)$);
\draw (y) -- ($(y) + (0,-6.8)$);
\draw (z) -- ($(z) + (0,-6.8)$);
\draw (w) -- ($(w) + (0,-6.8)$);

\draw (notx) -- ($(notx) + (0,-6.3)$);
\draw (noty) -- ($(noty) + (0,-6.3)$);
\draw (notz) -- ($(notz) + (0,-6.3)$);
\draw (notw) -- ($(notw) + (0,-6.3)$);

\draw (notx) |- (t1.input 1) node[connection,pos=0.5]{};
\draw (notx) |- (t2.input 1) node[connection,pos=0.5]{};
\draw (notx) |- (t3.input 1) node[connection,pos=0.5]{};
\draw (noty) |- (t1.input 2) node[connection,pos=0.5]{};
\draw (noty) |- (t2.input 2) node[connection,pos=0.5]{};
\draw (noty) |- (t4.input 2) node[connection,pos=0.5]{};
\draw (notz) |- (t1.input 3) node[connection,pos=0.5]{};
\draw (notz) |- (t3.input 3) node[connection,pos=0.5]{};
\draw (notz) |- (t5.input 3) node[connection,pos=0.5]{};
\draw (notw) |- (t1.input 4) node[connection,pos=0.5]{};
\draw (notw) |- (t2.input 4) node[connection,pos=0.5]{};
\draw (notw) |- (t5.input 4) node[connection,pos=0.5]{};

\draw (x) |- (t4.input 1) node[connection,pos=0.5]{};
\draw (x) |- (t5.input 1) node[connection,pos=0.5]{};
\draw (x) |- (t6.input 1) node[connection,pos=0.5]{};
\draw (y) |- (t3.input 2) node[connection,pos=0.5]{};
\draw (y) |- (t5.input 2) node[connection,pos=0.5]{};
\draw (y) |- (t6.input 2) node[connection,pos=0.5]{};
\draw (z) |- (t2.input 3) node[connection,pos=0.5]{};
\draw (z) |- (t4.input 3) node[connection,pos=0.5]{};
\draw (z) |- (t6.input 3) node[connection,pos=0.5]{};
\draw (w) |- (t3.input 4) node[connection,pos=0.5]{};
\draw (w) |- (t4.input 4) node[connection,pos=0.5]{};
\draw (w) |- (t6.input 4) node[connection,pos=0.5]{};

\end{circuitikz}
\end{document}

相关内容