2

Is there a nice way to connect the output with the input of the same logic gate as shown in the following picture?

enter image description here

My current "code" looks like this:

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{arrows, shapes.gates.logic.US, calc}

\begin{document}
\tikzstyle{branch}=[fill,shape=circle,minimum size=3pt,inner sep=0pt]
\begin{tikzpicture}[label distance=2mm, scale=1.5]
    \node (x) at (0, 1) {$x_t$};
    \node[and gate US, draw, logic gate inputs=nn] at (1, 1) (and) {};  

    \draw (x) |- (and.input 1);
    \draw (and.output) 
        -- ([xshift=0.5cm] and.output) 
        |- ([yshift=-0.5cm] and.output)
        |- (and.input 2);

    \draw (and.output) -- node[above]{$y$} (2.5, 1);
\end{tikzpicture}
\end{document}          

but this is giving me the following output (also I don't know how to shift a branch on the x-axis lol)

enter image description here

As always, any help is appreciated!

  • Welcome to TeX.SE! Please provide a complete MWE, i.e. a document that starts with \documentclass and ends with \end{document} and can be compiled. – user121799 Oct 29 '18 at 21:58
  • @marmot edited the post, but you already presented a solution so I'm going to mark it as solved. Thank you very much! – user019231283 Oct 29 '18 at 22:14
1

I have no clue about circuitikz but I know TikZ enough to draw some lines...

\documentclass[circuitikz,border=3.14mm]{standalone} 
\usepackage{circuitikz}
\usetikzlibrary{circuits.logic.US}
\begin{document}
\begin{circuitikz}
\node[and gate US, draw, logic gate inputs=nn] at (1, 1) (and) {};  
\draw  (and.input 1) -- ++ (-0.5,0) node[left](x){$x_t$};
\draw (and.output) -- ++ (1,0) node[circle,fill,inner sep=2pt](bull){} 
 -- ++ (0.5,0);
 \draw  (and.input 2) -| ++ (-0.5,-0.5) -| (bull);
\end{circuitikz}
\end{document}

enter image description here

  • How would I add the letter "Q" to the upper right (output) as shown in the first picture? I tried the following code\draw (or.output) -- ++ (1,0) node[circle,fill,inner sep=1pt](bull){$TEXTHERE$} -- ++ (0.5,0); but that gave me an error message. – user019231283 Oct 29 '18 at 22:39
  • @user019231283 Try \draw (and.output) -- ++ (1,0) node[circle,fill,inner sep=2pt](bull){} -- ++ (0.5,0) node[right]{$Q$}; – user121799 Oct 30 '18 at 0:16
0

It's more or less the same than @marmot answer, but using the native circuitikz connectors and a bit of vertical/horizontal connections:

\documentclass[circuitikz,border=3.14mm]{standalone} 
\usepackage{circuitikz}
\usetikzlibrary{circuits.logic.US}
\begin{document}
\begin{circuitikz}
\node[and gate US, draw, logic gate inputs=nn] at (1, 1) (and) {};  
\draw  (and.input 1) to[short, -o] ++ (-0.5,0) node[left](x){$x_t$};
\draw (and.output) to[short, -*]  ++ (0.5,0) coordinate(dot) to[short, -o] ++(0.5,0) node[right]{$y_t$};
\draw (dot) -- ++(0, -0.5) -| ([xshift=-0.4cm] and.input 2) -- (and.input 2);
\end{circuitikz}
\end{document}

The trick here is:

  1. use to[short, -*] or variants instead of -- when you want the dots/connectors;
  2. use intermediate coordinate() to ease drawing;
  3. use ([xshift=...]named node) to have a bit of breath space;
  4. use -| (draw horizontally, then vertically --- Manhattan geometry is called, I think) where appropriate.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.