Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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

share|improve this answer
    
Thanks it really worked well, excellent work! –  Jasper D'Agostino Nov 28 '10 at 22:54
    
Actually if you wouldn't mind helping with one more thing..I noticed that if I try and use to[short, -*] for a connector it disrupts the positioning of the switch itself. Is there a way to have connectors (black dots) at the base of the line where the switch would be connected? It's for an analog electronics report. –  Jasper D'Agostino Nov 28 '10 at 23:09
    
@Jasper: I'm not sure what you mean (I have never used circuitikz myself and i'm mostly unfamiliar with circuit diagrams). If it isn't directly connected with drawing a switch without arrow, it is better if you ask a new question. –  Caramdir Nov 29 '10 at 1:49
    
Ok, thank you for your insight. –  Jasper D'Agostino Nov 29 '10 at 2:23
    
@Caramdir, @Jasper: I'm curious, where are these switches (cspst and ospst)? I just looked at the circuit section in the pgfmanual and can't find them. I did find (section 29.4.5) some symbols for contacts which look very similar to what Caramdir's drawn here. –  Andrew Stacey Nov 29 '10 at 9:51
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.