Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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?

share|improve this question
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. –  Peter Grill Nov 8 '12 at 19:30
    
ok I just replaced the code snippet with a complete tex file. –  user21916 Nov 8 '12 at 19:54
add comment

1 Answer 1

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

share|improve this answer
    
Thanks! This is what I need, the one last missing part is the arrowheads on the input and output. –  user21916 Nov 10 '12 at 1:43
    
any updates? :) –  user21916 Nov 12 '12 at 16:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.