[Tex/LaTex] How to label inputs to a logic gate using Circuitikz

circuitikztikz-pgf

Is there any way, or how would I go about adding labels and straight line inputs to logic circuit diagram? The code I have now is as follows:

\documentclass[11pt]{article}

\usepackage{circuitikz}

\begin{document}

\begin{circuitikz} \draw
(0,1) node[or port] (myor1) {}
(2,0) node[and port] (myand1) {}

(myor1.out) -- (myand1.in 1);

\end{circuitikz}

\end{document}

What I would like to do, more specifically, is label the inputs A and B leading to the first OR gate with whole words, or preferably phrases. I'd also like to be able to have a straight line leading to the second input of the AND gate, which is also to be labelled.

How can I go about doing this?

Many thanks!

Best Answer

You can place nodes for the labels:

enter image description here

To extend a line you can use

\draw (myand1.in 2) to (myand1.in 2 -| myor1.in 2)

which draws a horizontal line from the myand1.in 2 node to a point vertically below the myor1.in 2 node.

Code:

\documentclass[11pt]{article}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz} \draw
(0,1) node[or port] (myor1) {}
    (myor1.in 1) node [anchor=east] {A}
    (myor1.in 2) node [anchor=east] {B}
(2,0) node[and port] (myand1) {}
    %(myand1.in 2) node [anchor=east] {C}
    (myand1.out) node [anchor=west] {X}
    (myor1.out) to (myand1.in 1);

\draw (myand1.in 2) to (myand1.in 2 -| myor1.in 2)
        node [anchor=east] {C};

\end{circuitikz}

\end{document}