[Tex/LaTex] CircuiTikZ logic gates alignment

circuitikztikz-pgf

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?

Best Answer

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}

enter image description here

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}

enter image description here

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}

enter image description here