我想知道是否有其他命令与开关符号相关联,这样就不必指定开关是打开还是关闭。我想要带有两个连接器和一条线的开关符号,而不是打开开关(ospst)和关闭开关(cspst)。我到处找了找,似乎找不到任何解决方案。谢谢
答案1
下面的代码是对 的定义的修改cspst
。我只是删除了圆弧和箭头。
\documentclass{minimal}
\usepackage{circuitikz}
% modified code from pgfcircbipoles.sty and circuitikz1.code.tex
\makeatletter
% create the shape
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/interr/height 2}}{spst}{\ctikzvalof{bipoles/interr/height}}{\ctikzvalof{bipoles/interr/width}}{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
\pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfusepath{draw}
}
% make the shape accessible with nice syntax
\def\pgf@circ@spst@path#1{\pgf@circ@bipole@path{spst}{#1}}
\tikzset{switch/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@spst@path, l=#1}}
\tikzset{spst/.style = {switch = #1}}
\makeatother
\begin{document}
\begin{circuitikz}
\draw (0,0) to[switch, l=$t_0$] (2,0)
to[spst] (2,-2);
\end{circuitikz}
\end{document}