[Tex/LaTex] Drawing switches in circuitikz with connectors (dots)

circuitikztikz-pgf

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

  \begin{circuitikz}
\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};
\end{circuitikz}

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)
\makeatletter
%create the shape
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/interr/height 2}}{spst}{\ctikzvalof
{bipoles/interr/height}}{

\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

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,

Jasper

P.S. I love CircuiTikz!

Best Answer

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.

\documentclass{article}
\usepackage[free-standing-units]{siunitx}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}[scale=1.5]

\draw (0,0) to [V=E] (0,2)
to[short,-o](0.75,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);

\end{circuitikz}

\end{document}

Which will result in:

image

Leonardo

Related Question