CircuiTikZ logic gates alignment

I want to align the output of a XOR gate with input 1 of a NAND gate like this

However, with the following code, I am not getting perfect alignment

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

\begin{figure}[h!]
\begin{circuitikz}
\draw
(0,0) node[xor port] (xor1) {}
(2,0.3) node[nand port] (nand1) {}
;\end{circuitikz}
\end{figure}
\end{document}


Is there a way to achieve perfect alignment?

• Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jan 18 '15 at 10:49

Like this?

\documentclass[border=5]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) node[xor port](xor1) {} to
(2,0) node[scale=1.2,nand port,anchor=in 1] (nand1) {}
(nand1.in 2) -- (xor1.in 2|-nand1.in 2)
;\end{circuitikz}
\end{document}


With another gate:

\documentclass[border=5]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) node[xor port](xor1) {} to
(2,0) node[scale=1.2,nand port,anchor=in 1] (nand1) {}
(nand1.out) to +(2,0) node[scale=1.3,xor port,anchor=in 1] (xor2) {}    %% 3rd gate
(nand1.in 2) -- (xor1.in 2|-nand1.in 2)
(xor2.in 2) -- (xor1.in 2|-xor2.in 2)
;\end{circuitikz}
\end{document}


Actually you don't have to align them as it is possible to connect them easily.

\documentclass[border=5]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,0) node[xor port](xor1) {}
(2,-1) node[nand port] (nand1) {}
(xor1.out) -| (nand1.in 1)    %% connect them
(nand1.in 2) -- +(-2,0)
;\end{circuitikz}
\end{document}


• How do I align a third gate after the NAND gate? (in the first part of your answer) – Surag Jan 18 '15 at 12:06
• How do I draw a line from input 1 of the first XOR gate to x-coordinate of -2 (absolute) but the same y coordinate? – Surag Jan 18 '15 at 13:10
• I want to extend input 1 backwards to x-coordinate of -2. – Surag Jan 18 '15 at 13:22
• @Surag (xor1.in 1) -- +(-2,0) (xor1.in 2) -- +(-2,0) – user11232 Jan 18 '15 at 13:27