\begin{circuitikz} \draw
  (0,3) node[not port] (mynot1) {}
  (mynot1.in) node[anchor=east] {$r$}
  (mynot1.out) node[anchor=south] {$\neg r$}
  (0,1) node[not port] (mynot2) {}
  (mynot2.in) node[anchor=east] {$q$}
  (mynot2.out) node[anchor=south] {$\neg q$}
  (3,4) node[and port] (myand1) {}
  (myand1.in 1) node[anchor=east] {$p$}
  (myand1.out) node[anchor=west] {$p \wedge \neg r$}
  (3,0) node[and port] (myand2) {}
  (myand2.in 2) node[anchor=east] {$r$}
  (myand2.out) node[anchor=west] {$\neg q \wedge r$}
  (mynot1.out) -| (myand1.in 2)
  (mynot2.out) -| (myand2.in 1)
  (5,2) node[or port] (myor) {}
  (myor.out) node[anchor=west] {$(p \wedge \neg r) \vee (\neg q \wedge r)$}
  (myand1.out) |- (myor.in 1)
  (myand2.out) |- (myor.in 2)


The above is how I draw my logic circuit by using package circuitikz. I can basically figure out how to draw the circuit but it looks ugly, see

enter image description here

1) I want it to look nicer, i.e. smaller "not" gate, colored label text, more compact in positioning, arrowheads on the input and output, etc. just like the style of this: enter image description here

Any idea?

  • 1
    While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving problem. Nov 8, 2012 at 19:30
  • ok I just replaced the code snippet with a complete tex file.
    – Romstar
    Nov 8, 2012 at 19:54

1 Answer 1


Here is a first approach to a smaller logic circuit, with more compact positioning, and colored label text.


\begin{circuitikz}[every label/.style={blue}]
% draw And1 gate with label then Not1 gate with label
(3,3) node[and port] (myand1) {}
    (-1,3.3) node[label=left:$p$] {} -- (myand1.in 1) 
    (myand1.out)  node[label=right:$p \wedge \neg r$] {}
(0,2.75) node[scale=0.7,not port] (mynot1) {}
    (-1,2.75)node[label=left:$r$] {} -- (mynot1.in) 
    (mynot1.out)    node[label=above:$\neg r$] {}
    (mynot1.out) -- (myand1.in 2)
% draw And2 gate with label then Not2 gate with label
(3,1) node[and port] (myand2) {}
    (-1,0.75) node[label=left:$r$] {} -- (myand2.in 2)
    (myand2.out)  node[label=right:$\neg q \wedge r$] {}
(0,1.3) node[scale=0.7,not port] (mynot2) {}
    (-1,1.3) node[label=left:$q$] {} -- (mynot2.in)
    (mynot2.out)    node[label=above:$\neg q$] {}
    (mynot2.out) -- (myand2.in 1)
% draw Or gate with inputs and output label
(6,2) node[or port] (myor) {}
    (myand1.out) |- (myor.in 1)
    (myand2.out) |- (myor.in 2)
    (myor.out) -- (8,2) node[label=above:$(p \wedge \neg r) \vee (\neg q \wedge r)$] {}


enter image description here

  • Thanks! This is what I need, the one last missing part is the arrowheads on the input and output.
    – Romstar
    Nov 10, 2012 at 1:43
  • any updates? :)
    – Romstar
    Nov 12, 2012 at 16:08

You must log in to answer this question.

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