4

I want to make a diagram like this:

enter image description here

see the labelled endpoints, A, B, C, Y.

Currently my code:

\documentclass{article}
\usepackage{circuitikz}
\begin{document}

\begin{circuitikz} \draw
(0,2) node[and port] (myand1) {}
(0,0) node[and port] (myand2) {}
(2,1) node[xnor port] (myxnor) {}
(myand1.out) -- (myxnor.in 1)
(myand2.out) -- (myxnor.in 2);
\end{circuitikz}

\end{document}

Does not label the endpoints and I don't know how to.

Also in cases like

\begin{circuitikz} \draw
(0,1) node[and port] (myand1) {}
(2,0) node[xnor port] (myxnor) {}
(myand1.out) -- (myxnor.in 1);
\end{circuitikz}

The second input to the xnor gate, I would like it to extend all the way to the left of the diagram (and then be labelled).

0

2 Answers 2

7

Just use the gate objet points to put a node with text with some desired anchor definition like this.

RESULT:

enter image description here

MWE:

\documentclass[tikz,border=15pt]{standalone}
\usepackage{circuitikz}
\begin{document}
    \begin{tikzpicture}
    \draw
        (0,2) node[and port] (myand1) {}
        (0,0) node[and port] (myand2) {}
        (2,1) node[xnor port] (myxnor) {}
        (myand1.out) -- (myxnor.in 1)
        (myand2.out) -- (myxnor.in 2);
    \draw (myand1.out) node[anchor=south,scale=0.5]{out};
    \draw (myand1.in 1) node[anchor=south,color=blue]{in1};
    \draw (myand1.in 2) node[anchor=south east,rotate=90,scale=0.5]{in2};
    \end{tikzpicture}

\end{document}

Update:

Just use circuit tikz node "short" in a relative point:

RESULT:

enter image description here

MWE:

\documentclass[tikz,border=15pt]{standalone}
\usepackage{circuitikz}
\begin{document}
    \begin{tikzpicture}
    \draw
        (0,2) node[and port] (myand1) {}
        (0,0) node[and port] (myand2) {}
        (2,1) node[xnor port] (myxnor) {}
        (myand1.out) -- (myxnor.in 1)
        (myand2.out) -- (myxnor.in 2);
    \draw (myand1.out) node[anchor=south,scale=0.5]{out};
    \draw (myand1.in 1) node[anchor=south,color=blue]{in1};
    \draw (myand1.in 2) node[anchor=south east,rotate=90,scale=0.5]{in2};

    %Second question

    \draw[color=red]
    (myand1.in 1) % Starting point
        to [short,-*] ++ (-1,0) %++ indicates that the coordinate is relative to the starting point
        node[anchor=east]{Ext input}
    (myxnor.out)
        to [short,-*] ++ (2,0)
        node[anchor=west]{xnor output};
    \end{tikzpicture}

\end{document}

you can see more complicated implementation and animation in my old answers about this issues. How do I simulate a logic circuit in latex?

2
  • how about the second part of my question May 14, 2019 at 20:59
  • I have updated some things that I hope will help you...
    – J Leon V.
    May 14, 2019 at 21:33
5

in the circuitikz manual page 45 they do something like this (with transistors. here converted to xnor)

\documentclass[border=5pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}
\draw
(0,0) node[xnor port] (myxnor) {}
(myxnor.in 1) node[anchor=east](label xnor in 1){A}
(myxnor.in 2) node[anchor=east](label xnor in 1){B};
\end{circuitikz}
\end{document}

enter image description here

2
  • How about the second part of my question? May 14, 2019 at 21:01
  • @theonlygusti I wasn't exactly sure what you ment, but you ended up getting a nice answer ;-) May 15, 2019 at 7:14

You must log in to answer this question.

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