# How can I rotate a logic gates, and clean up the style with CircuiTikz?

I'm just a student trying to learn LaTeX on his own to make homework assignment submissions look a lot better than handwriting! So I've learned just enough to draw these simple logic gates with CircuiTikz, but I am having a hard time learning how to rotate my not gate, and to clean up things like the one NOT gate having the line inside it instead of at the tip, and getting the OR gate's outgoing line extending all the way to the compound statement that I have on the right. I am trying to add a second NOT gate going from "r" to the first AND gate (the one connected to "p"). I also don't know why the first line "Chapter 1.2: 42" is being made to fill the entire line with all that spacing, which I don't want.

Here is the code snippet. Any help would be greatly appreciated!

\documentclass{minimal}
\usepackage{CircuiTikz}
\begin{document}
\begin{enumerate}
\item Chapter 1.2: 42\linebreak\linebreak
\begin{circuitikz} \draw
% Create the gates.
(3,2) node[and port] (and1) {}
(5,-1) node[and port] (and2) {}
(7,1) node[or port] (or1) {}
(0.5,0.5) node[rotate=90,not port] (not1) {}
(2,-2) node[not port] (not2) {}

%Create the proprositional variables, and final output.
(and1.in 1) node[left=2cm](p) {p}
(and1.in 2) node[below left=2cm](r) {r}
(r) node[below=2cm](q) {q}
(or1.out) node[right=0.2cm](answer) {$(p \land r) \lor (\neg r \land \neg q)$}

%Feed AND gates to the OR gate.
(and1.out) -| (or1.in 1)
(and2.out) -| (or1.in 2)

%Feed not1 to and1.
(not1.out) -| (and1.in 2)

%Feed p and r to the first AND gate.
(p) -| (and1.in 1)

%Feed r into and1 via not1.
(r) -| (not1.in)

%Feed r and q (through NOT gate) to second AND gate.
(r) -| (and2.in 1)
(q) -| (not2.in)
(not2) -| (and2.in 2);
\end{circuitikz}
\end{enumerate}
\end{document}


# Update

I've figured out how to rotate my gates, but I still can't figure out why one of the NOT gates (named not2) has the line sticking inside it instead of it being connected at the tip. I also would love to learn how to add a dot at the point where the outgoing line from "r" splits to indicate that it's splitting.

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Phelype Oleinik Feb 1 '18 at 23:04
• @wwwrk instead of (not2) -| (and2.in 2) use (not2.out) -| (and2.in 2) – sergiokapone Feb 2 '18 at 7:27
• There are two ways to add dots: \node[circ] at (...) or \to[short,*-*]. See pages 33-35 of the manual. – John Kormylo Feb 2 '18 at 15:43

1. Logic gates are nodes in circuitikz. You can use the rotate=<angle> option to rotate any nodes.
2. You were drawing from not2 instead of not2.out. That's why there was a line inside not gate
3. A dot can be placed at either end of components with *-* or o-o option.

### MWE

\documentclass{minimal}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz} \draw
% Create the gates.
(3,2) node[and port] (and1) {}
(5,-1) node[and port] (and2) {}
(7,1) node[or port] (or1) {}
(0.5,0.5) node[rotate=90,not port] (not1) {}
(2,-2) node[not port] (not2) {}

%Create the proprositional variables, and final output.
(and1.in 1) node[left=2cm](p) {p}
(and1.in 2) node[below left=2cm](r) {r}
(r) node[below=2cm](q) {q}
(or1.out) node[right=0.2cm](answer) {$(p \land r) \lor (\neg r \land \neg q)$}

%Feed AND gates to the OR gate.
(and1.out) -| (or1.in 1)
(and2.out) -| (or1.in 2)

%Feed not1 to and1.
(not1.out) |- (and1.in 2)

%Feed p and r to the first AND gate.
(p) -| (and1.in 1)

%Feed r into and1 via not1.
(0.5,-0.5) to[short,*-] (not1.in)

%Feed r and q (through NOT gate) to second AND gate.
(r) -| (and2.in 1)
(q) -| (not2.in)
(not2.out) -| (and2.in 2);
\end{circuitikz}
\end{document}