4

Given circuitikz flip-flops (or multipoles), how can I shift the pin labels up or down a bit? (context: I want to draw some internal lines, and they overlap with the pin labels)

Something like this:

\documentclass{standalone}

\usepackage{circuitikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{circuitikz}
  % not what I want 
  \node [flipflop SR] (sr1) {};
  \draw [red] (sr1.bpin 1) -- (sr1.bpin 6) (sr1.bpin 3) -- (sr1.bpin 4) ;

  % something like this, but with proper distances,
  % and less cumbersome to write down: 
  \node [flipflop, right=of sr1] (sr2) {};
  \node [above right=0.05cm of sr2.bpin 1] {S}; 
  \node [below right=0.05cm of sr2.bpin 3] {R}; 
  \node [above left=0.05cm of sr2.bpin 6] {Q}; 
  \node [below left=0.05cm of sr2.bpin 4] {\ctikztextnot{Q}}; 
  \draw [red] (sr2.bpin 1) -- (sr2.bpin 6) (sr2.bpin 3) -- (sr2.bpin 4) ;
\end{circuitikz}

\end{document}

left: not nice; right: something like that

4
  • 4
    Can you please add a simple example? Thanks!
    – Rmano
    Commented Feb 21, 2023 at 8:36
  • You may have to replace ALL of he default pin labels with nodes for each. Commented Feb 21, 2023 at 15:19
  • @JohnKormylo, depending on the case, maybe some trick in the font option can do it. But it's impossible to say without the use case.
    – Rmano
    Commented Feb 21, 2023 at 16:39
  • I used answer 2 to give an example; sure, that is doable, but really cumbersome and looks bad. Commented Feb 22, 2023 at 9:31

2 Answers 2

3

enter image description here

\documentclass{standalone}

\usepackage{circuitikz}
\usetikzlibrary{positioning}
\tikzset{
  flipflop SR shifted/.style={
    flipflop,
    flipflop def={
      t1=\raisebox{\dimexpr0.5ex+\height}{S},
      t3=\raisebox{-\dimexpr0.5ex+\height}{R},
      t6=\raisebox{\dimexpr0.5ex+\height}{Q},
      t4=\raisebox{-\dimexpr0.5ex+\height}{\ctikztextnot{Q}}
    }
  },
}
\begin{document}

\begin{circuitikz}
  \node [flipflop SR shifted] (sr1) {};
  \draw [red] (sr1.bpin 1) -- (sr1.bpin 6) (sr1.bpin 3) -- (sr1.bpin 4) ;
\end{circuitikz}

\end{document}

2
  • Thanks! Not quite as straightforward as I had hoped, but probably the best that can be done here. Commented Feb 22, 2023 at 18:35
  • I think that this is really straightforward, though: you can even put the tikzset in an extra file and include it. Probably with a bit of box magic is even possible to move the labels outside...
    – Rmano
    Commented Feb 22, 2023 at 18:53
3

Although I think @gernot answer is the correct one, this is to show a couple of different solutions.

\documentclass{standalone}

\usepackage{circuitikz}
\usetikzlibrary{positioning}

\newcommand{\shiftedSRlabels}[1]{% node name
  \node [font=\small, anchor=base west] at ([yshift=1mm]#1.bpin 1) {S};
  \node [font=\small, anchor=base east] at ([yshift=1mm]#1.bpin 6) {Q};
  \node [font=\small, anchor=base west] at ([yshift=-3mm]#1.bpin 3) {R};
  \node [font=\small, anchor=base east] at ([yshift=-3mm]#1.bpin 4) {\ctikztextnot{Q}};
}

\newcommand{\outsideSRlabels}[1]{% node name
  \node [font=\small, anchor=base east] at ([yshift=1mm]#1.bpin 1) {S};
  \node [font=\small, anchor=base west] at ([yshift=1mm]#1.bpin 6) {Q};
  \node [font=\small, anchor=base east] at ([yshift=1mm]#1.bpin 3) {R};
  \node [font=\small, anchor=base west] at ([yshift=1mm]#1.bpin 4) {\ctikztextnot{Q}};
}

\begin{document}

\begin{circuitikz}
  % not what I want
  \node [flipflop SR] (sr1) {};
  \draw [red] (sr1.bpin 1) -- (sr1.bpin 6) (sr1.bpin 3) -- (sr1.bpin 4) ;

  % something like this, but with proper distances,
  % and less cumbersome to write down:
  \node [flipflop, right=of sr1] (sr2) {};
  \node [above right=0.05cm of sr2.bpin 1] {S};
  \node [below right=0.05cm of sr2.bpin 3] {R};
  \node [above left=0.05cm of sr2.bpin 6] {Q};
  \node [below left=0.05cm of sr2.bpin 4] {\ctikztextnot{Q}};
  \draw [red] (sr2.bpin 1) -- (sr2.bpin 6) (sr2.bpin 3) -- (sr2.bpin 4) ;

  \node [flipflop, right=of sr2] (sr3) {};
  \draw [red] (sr3.bpin 1) -- (sr3.bpin 6) (sr3.bpin 3) -- (sr3.bpin 4);
  \shiftedSRlabels{sr3}

  % I want the pins but not the labels
  \node [flipflop, , flipflop def={t1=~, t3=~, t4=~, t6=~}, right=of sr3] (sr4) {};
  \draw [red] (sr4.bpin 1) -- (sr4.bpin 6) (sr4.bpin 3) -- (sr4.bpin 4);
  \outsideSRlabels{sr4}

\end{circuitikz}

\end{document}

enter image description here

1
  • I Like the idea of putting the labels outside the FF. Commented Feb 22, 2023 at 18:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .