3

I am trying to get my labels positioned correctly and perhaps extending the lines coming out of NAND2.in 1 and NAND2.in 2 nodes, such that my first circuit looks similar to the second circuit in terms of label arrangement. I looked through the CircuitTikz manual and was not able to solve my problem.

enter image description here

    \documentclass[12pt]{article}
    \import{circuitikz}
    \begin{document}
    \subsection*{(b) }
        \begin{center}
        \begin{tikzpicture}
        \node[nand port] (NAND1) {};
        \node[nand port] at ($(NAND1) + (2,0)$) (NAND2) {};
        
        
        \draw (NAND1.in 1) -- ++(-0.5,0) node[left ] {$p$};
        \draw (NAND1.in 2) -- ++(-0.5,0) node[left ] {$q$};
        \draw (NAND2.in 1)  node[above] {$\overline{p \land q}$};
        \draw (NAND2.in 2)  node[below] {$\overline{p \land q}$};

        
        \draw (NAND1.out)  -| (NAND2.in 1) -| (NAND2.in 2);
        \draw[->] (NAND2.out)  -- ++( 0.5,0) node[right] {$\overline{\overline{p \land q} \land \overline{p \land q}} \equiv \overline{\overline{p \land q}} \equiv p \land q$};
        \end{tikzpicture}
        \end{center}    
        \subsection*{(c) }
        \begin{center}
            \begin{tikzpicture}
            \node[nand port] (NAND1) {};
            \node[nand port] at ($(NAND1) + (0,-1.5)$) (NAND2) {};
            \node[nand port] at ($(NAND1) + (2,-0.75)$) (NAND3) {};

            
            \draw (NAND1.in 1) -- ++(-0.5,0) node[left ] {$p$};
            \draw (NAND1.in 2) -- ++(-0.5,0) node[left ] {$p$};
            \draw (NAND2.in 1) -- ++(-0.5,0) node[left ] {$q$};
            \draw (NAND2.in 2) -- ++(-0.5,0) node[left ] {$q$};
            \draw (NAND1.out)  node[above] {$\overline{p}$};
            \draw (NAND2.out)  node[below] {$\overline{q}$};
            
            \draw (NAND1.out)  -| (NAND3.in 1);
            \draw (NAND2.out)  -| (NAND3.in 2);
            \draw[->] (NAND3.out)  -- ++( 0.5,0) node[right] {$\overline{\overline{p} \land \overline{q}} \equiv \overline{\overline{p}} \lor \overline{\overline{q}} \equiv p \lor q$};
            \end{tikzpicture}
        \end{center}
        \end{document}  
1
  • I do not quite understand your request: where do you want the texts to appear?
    – Nicolas
    Commented Feb 8, 2021 at 16:33

1 Answer 1

3

A trivial solution using xshift and yshift:

\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
  \begin{tikzpicture}
  \node[nand port] (NAND1) {};
  \node[nand port] at ($(NAND1) + (2,0)$) (NAND2) {};
   
  \draw (NAND1.in 1) -- ++(-0.5,0) node[left ] {$p$};
  \draw (NAND1.in 2) -- ++(-0.5,0) node[left ] {$q$};
  \draw (NAND2.in 1)  node[above,yshift=0mm,xshift=-3.5mm] {$\overline{p \land q}$};
  \draw (NAND2.in 2)  node[below,yshift=-1mm,xshift=-3.5mm] {$\overline{p \land q}$};
  
  \draw (NAND1.out)  -| (NAND2.in 1) -| (NAND2.in 2);
  \draw[->] (NAND2.out)  -- ++( 0.5,0) node[right] {$\overline{\overline{p \land q} \land \overline{p \land q}} \equiv \overline{\overline{p \land q}} \equiv p \land q$};
  \end{tikzpicture}
 \end{document}   

enter image description here

1
  • Thank you, this functionality will definitely be useful in the future for me!
    – hexaquark
    Commented Feb 8, 2021 at 16:34

You must log in to answer this question.

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