TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to draw an example of the logical operation of a logic gate for an analog electronics report. In the following code:

\draw (-3,0) to[battery] (-3,2);
\draw (-3,2) to[switch=${\rm s_1}$] (-1,2);
\draw (-1,2) to[switch=${\rm s_2}$] (1,2);
\draw (1,2) -- (1,2);
\draw (1,2) to[lamp=L] (1,0);
\draw (1,0) -- (-3,0);
\draw (-0.8,0) node[anchor=north] {$s_1$ \underline{and} $s_2=$ L};
\draw (0.62,1) node[anchor=east] {L};

I noticed that if I try and use to to[short, -*] for a connector before the switch command 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?

M. Redaelli--

Hi, thank you for your answer. I tried the ospst command when i first compiled the image, but i wanted the arrows removed and the connectors in at the base of the line. I asked a question about removing the arrows and someone replied. He created the following:

%macro for switches without the arrows (cspst) and (ospst)
%create the shape
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/interr/height 2}}{spst}{\ctikzvalof


%make the shape accessible with nice syntax
\tikzset{switch/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@spst@path, l=#1}}
\tikzset{spst/.style = {switch = #1}}

which worked well for the switch without the arrow. The reason I wanted to remove the arrows and add the connectors is because I am converting one of my electronics professor's hand written notes into tex files. I just discovered tikz and circuitikz, so I am very new to these environments. As a result I have tried to create style files for such a switch but I have not been successful.

Thank you for your time,


P.S. I love CircuiTikz!

share|improve this question
up vote 7 down vote accepted

I think Jasper needs switches looking like the followings, but using a simple command for each one (am I right?). The nodes could be black also. Personally, I need the both.




\draw (0,0) to [V=E] (0,2)
\draw[ very thick](0.78,2)-- +(30:0.46);
\draw (1.25,2)to[short,o-](2,2)
to [C=$C$](2,0)
to [short,-o](1.25,0);
\draw [very thick] (1.22,0)--(0.77,0);
\draw (0.75,0)to [short,o-](0,0);



Which will result in:



share|improve this answer
Yes! This is exactly what I need except I changed the open connectors (-o) and (o-) to (-*) for the black connector dots. Thank you kindly! Now I just need to figure out a nice simple syntax for the new switch. – Jasper D'Agostino Dec 7 '10 at 3:03
You're welcome, Jasper. I need the same! – Leonardo Dec 7 '10 at 3:23
If I generate something useful I will surely send it your way! – Jasper D'Agostino Dec 7 '10 at 23:45

I'm not sure what switch is supposed to be. I don't remember putting that bipole in CircuiTikz, and your code doesn't compile here, complaining about that.

I substituted:

\draw (-3,2) to[ospst=${\rm s_1}$] (-1,2);
\draw (-1,2) to[ospst=${\rm s_2}$] (1,2);

and it works for me. Is that what you need?


share|improve this answer
Question above edited – Jasper D'Agostino Dec 3 '10 at 15:31

Your Answer


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.