0

I am looking for a way to make text inside a logic gate bigger.

Here you are my code:

\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}

And here you are the result:

enter image description here

The circuit hasn't been finished yet but I think the problem is clear: the text inside the or gates is too small.
Is there a way to make it bigger? If not, it would be good to move it above the gates, in order to make them smaller even if the text would be normal sized.

Thank you for your patience.

2 Answers2

2

The space inside the gate is restricted and font size would reduce-- why not try out at the output of the gate which in any case is the summation of 4 inputs

enter image description here

Add the following to your code

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

You can scale the fontsize in the label with e.g. {\Large{$x+y+z+\bar{w}$}}, but this affects the size of the gates and requires repositioning. My take on this is to use the label inside the node definition and scaling the gate accordingly. The text is positioned on top of the gate, but if you need to can select the angle at which you want it with the angle number and a colon, e.g. right now it is at the equivalent of label=90:$myLabel$ See the example below

\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}