[Tex/LaTex] circuitikz labeling

circuitikztikz-pgf

I am trying to create a few logic circuits for a class that I teach. After brief investigation I decided to use TikZ library circuit due to the lack of the support by PSTricks for American notation. It works like a charm apart of the fact that I have small problem with labeling. This is the picture I am trying to program.

enter image description here

This is the code

\documentclass{article}
\usepackage{circuitikz}
\begin{document}
\begin{center}
  \begin{circuitikz} 
    \draw
      (0,0) node[and port] (myand){AND}
      (myand.in 1) node[anchor=east]{P} 
      (myand.in 2) node[anchor=east]{Q} 
      (0.9,0) node[scale=0.7,not port] (mynot){NOT}
      (mynot.out) node[anchor=west]{S}
      (myand.out) -- (mynot.in);
  \end{circuitikz}
\end{center}
\end{document}

which produces this output

enter image description here

As you can see everything is almost perfect apart of the fact that I do not know how to center words "AND" and "NOT" into the middle of drawings.
How do you change the absolute/relative position of labels in a circuit diagram?

By the way this is the second time I use TikZ in my life and it took me only 5 minutes of playing to reproduce almost perfect image. It speaks volumes about the quality of TikZ.

Best Answer

You may have to play around with the label distances, but the following works: Placing the additional nodes for the labels after setting the circuit.

Labels on circuit elements

\documentclass{article}
\usepackage{circuitikz}% http://ctan.org/pkg/circuitikz
\begin{document}
\begin{center}
  \begin{circuitikz}
    \draw (0,0) node[and port] (myand){}
      (myand.in 1) node[anchor=east]{P} 
      (myand.in 2) node[anchor=east]{Q} 
      (0.9,0) node[scale=0.7,not port] (mynot){}
      (mynot.out) node[anchor=west]{S}
      (myand.out) -- (mynot.in);
    \draw (myand) node[left=4pt] {AND}; % AND label
    \draw (mynot) node[left=-5pt, scale=0.5] {NOT}; % NOT label
  \end{circuitikz}
\end{center}
\end{document}