1

I'm still new to Latex and I am especially new to drawing/coding logic gates in Latex. I am having a problem scaling the text inside a logic gate and none of the solutions I've found online so far have been working for me (I am most definitely just doing something wrong). Still feel free to forward me to any posts that may be able to help me, although I have looked at quite a few.

This is my code so far:

\documentclass[12pt,a4paper,twoside]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{
  circuits.logic,
  circuits.logic.US,
  positioning
}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage{sidecap}
\usepackage{anyfontsize}

\begin{document}
 
\usetikzlibrary{decorations.pathreplacing}
\begin{figure}[h]
\center
\begin{tikzpicture}[circuit logic US,
    node distance=25mm]
    \node[not gate, scale = 1.2] (not1) {NOT};
    \draw (not1.input)--++(180:1cm) node[left] (A) {\textit{A}};
    \node[right, right = 1cm of not1.output] (Not A) {$\neg A$};     
    \draw (not1.output)--++(0:1cm);
\end{tikzpicture}
\end{figure}
\end{document}

This is what I get: The "NOT" text is going over the lines

The "NOT" text is going over the lines and I would like to just scale the "NOT" text. If I use commands like \small or \tiny the whole gate also gets scaled and the "NOT" text still goes over the edges. If I scale the whole gate, then the text inside gets scaled with it which doesn't help me. I have also tried this solution but that also doesn't seem to work for me (I must be doing something wrong). Can anyone help me to just scale the "NOT" text to fit the gate? Any help is greatly appreciated.

Thank you all in advance!

(This is my first post here so please excuse any mistakes)

1
  • 1
    Welcome to TeX.SX! You can adjust the font size in a node using the option font, for example, you could try \node[not gate, scale = 1.2, font=\tiny] (not1) {NOT};. BTW: Your MWE is missing \begin{document} and \end{document}- Dec 7, 2022 at 16:36

1 Answer 1

1

A few things wrong here:

  1. \begin{document} \end{document} is missing.
  2. do not use \center. Use \centering instead.

Now the solution: You can use text width = 20 to compel the node NOT to be that large. then align = center to have the text in the correct spot.

code:

\documentclass[12pt,a4paper,twoside]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{
    circuits.logic,
    circuits.logic.US,
    positioning
}
\usepackage[utf8]{inputenc}
\usepackage{latexsym}
\usepackage{sidecap}
\usepackage{anyfontsize}

\usetikzlibrary{decorations.pathreplacing}
\begin{document}
    \begin{figure}[h]
        \begin{tikzpicture}[circuit logic US,
        node distance=25mm]
        \node[not gate, scale = 2,text width=80,align =center] (not1) {NOT};
        \draw (not1.input)--++(180:1cm) node[left] (A) {\textit{A}};
        \node[right, right = 1cm of not1.output] (Not A) {$\neg A$};     
        \draw (not1.output)--++(0:1cm);
        \end{tikzpicture}
    \end{figure}
\end{document}

NB: in electrical engineering we do not need anything written inside the normalised symbols for gates.

1
  • 1
    Thanks for your help, that seems to help a bit. Apologies for the missing \begin{document} and \end{document}, I forgot to copy those over, but I will edit my question. I will also switch from \center to \centering.
    – VinStr
    Dec 7, 2022 at 22:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .