I want to have a pair of 2-input logic gates placed such that the input of one aligns with the output of the other. It looks like the vertical shift needed is approximately 0.35 × american xor port/height.

But where does the 0.35 come from? I've looked at pgfcirctripoles.tex but can't seem to make sense of it.

\usetikzlibrary{arrows, calc}
\edef\q{\pgfkeysvalueof{/tikz/circuitikz/tripoles/american xor port/height}}
  every node/.style={font=\sffamily}
%\ctikzset{logic ports origin=center}
% doesn't seem to work: I get "I do not know the key '/tikz/logic ports origin'..."

\foreach \a [count=\k] in {31,32,...,37} {
      \node[and port, label={center:0.\a}] (U1) at (0,\k*\L) {};
      \node[xor port] (U2) at ($(0,\a*0.01*\q)+(2cm,\k*\L)$) {};
      \draw [-,red] (U1.out) -| (U2.in 2);

enter image description here

  • and how can I make the AND gate label be in the center? I'll ask in a separate question... – Jason S Mar 31 at 19:26
  • 1
    re: gate label in center: never mind, i was using an older version of circuitikz (0.8.something); the logic ports origin = center works. – Jason S Mar 31 at 20:24

If I correctly understood your question, than see if the following starting point gives what you after:

\node[and port] (U1) {xxx}; % <---
\node[xor port,right=of U1, anchor=in 2] (U2) {}; % <---
      \draw[red] (U1.out) -| (U2.in 2);

enter image description here

This should be easy expand to array of gates as you try to draw in \foreach loop.

| improve this answer | |
  • ah, the anchor=in 2 -- got it! – Jason S Mar 31 at 20:25
  • the \foreach was just an example – Jason S Mar 31 at 20:25
  • ick! the xor gate changed in the newer version to be more pointy. I really wish they would try to match what actually appears in datasheets, which is NOT a pointy stylized XOR gate. Is there a forum for this? – Jason S Mar 31 at 20:28
  • @JasonS, authors of package are very active members of this site. Just ask question here or even beer make features demand on github site. – Zarko Mar 31 at 21:58
  • 2
    @JasonS \ctikzset{american or shape=roundy} will go back to the old shapes. See a recent manual in the "logic port customization" section – Rmano Apr 1 at 9:16

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.