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 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!

share|improve this question
add comment

2 Answers

up vote 4 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.

\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

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
add comment

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?

M.

share|improve this answer
    
Question above edited –  Jasper D'Agostino Dec 3 '10 at 15:31
add 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.