[Tex/LaTex] How to make the logic circuit drawn by circuitikz look nicer

circuitikzlogictechnical-drawing

\documentclass{article}

\usepackage{circuitikz}

\begin{document}

\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)
;\end{circuitikz}

\end{document}

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?

Best Answer

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

\documentclass{article}

\usepackage{fullpage}
\usepackage[american]{circuitikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{circuitikz}[every label/.style={blue}]
\draw
% 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)$] {}
;
\end{circuitikz}

\end{document}

enter image description here