给定 circuitikz 触发器(或多极子),我怎样才能将引脚标签稍微向上或向下移动?(上下文:我想画一些内部线,它们与引脚标签重叠)
像这样:
\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}
答案1
\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
尽管我认为@gernot 答案是正确的,这是为了展示几个不同的解决方案。
\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}