[Tex/LaTex] Different switch symbols in circuitikz

circuitikzsymbolstikz-pgf

I'm wondering if there are other commands associated with the switch symbol so that one doesn't have to specify if the switch is open or closed. I would like the switch symbol with two connectors and a line rather than the open switch (ospst) and closed switch (cspst). I've looked all over and can't seem to find any solution.
Thanks

Best Answer

The following code is a modification of the definition of cspst. I just removed the arc and the arrow.

\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}

example