# How can I draw the switch of this diagram in circuitikz?

I am trying to draw this diagram. I do not know how to draw the switch.

I tried

\documentclass[]{article}
\usepackage{circuitikz}
\ctikzset{european resistors}% preferred way to set global options, circuitkz has too many package options...
\usepackage[locale = DE]{siunitx}
\begin{document}
\begin{circuitikz}
\draw (0,0) to[R=$R$] (2,0) to[R=$R$] (4,0)  (6,0) to[L,  inductors/width=1.4,inductors/coils=12,l={$L$}] (6,-3)
(4,0)  to[capacitor,l={$C$}] (4,-3)
(2,0)  to[R=$R$] (2,-3)
(0,0) to[battery2] (0,-3)
(0,-3) -- (6,-3);
\end{circuitikz}
\end{document}


And get

This is a bit tricky, because you need a rotated switch; if I had to draw it from scratch, I would start with the switch and then do the rest by moving relative to it.

I commented on the code --- if you need to look at the perpendicular coordinate system, you can look in the circuitikz manual --- they're explained in the tutorials; or in the TikZ manual itself.

\documentclass[]{article}
\usepackage{circuitikz}
\ctikzset{european resistors}
\usepackage[locale = DE]{siunitx}
\begin{document}
\begin{circuitikz}
\draw (0,0) to[R=$R$] (2,0) to[R=$R$] (4,0);
% I would not do it like that --- using relative coordinate is
% better. But...
% Let's place the "node" element (pag 137)
\draw (4.5,0) node[cute spdt mid, anchor=east, rotate=90](SW){};
% connect using the sub-nodes (not needed if you fill the poles, but...)
\draw (4,0) -- (SW-out 1.n) (SW-out 2.s) -- (6,0);
% labels
\path (SW.east) node[above]{$K$} (SW-out 1) node[below]{\strut $a$} (SW-out 2) node[below]{\strut $b$};
% position the capacitor, using perpendicular coordinates
% you need a bit more gimmick if you need it lined with the center of the R
\draw (SW.in) to [C=$C$] (SW.in |- 0,-3);
\draw (6,0) to[L,  inductors/width=1.4,inductors/coils=12,l={$L$}] (6,-3)
(2,0)  to[R=$R$] (2,-3)
(0,0) to[battery2] (0,-3)
(0,-3) -- (6,-3);
\end{circuitikz}
\end{document}


This also show why the geographical anchors of the switch are positioned lined up with the center of the poles, and why it is needed to provide a way to access the node's sub-poles.

• Can you add a code in your manual to draw a switch. E.x \draw (0,0) to[switch] (2,0)? Sep 24 at 1:26
• For a two-pole switch, you can already. The three pole ones and the multiple don't really fit as a path component - they're more like a transistor, don't you think? Sep 24 at 6:50

Quite similar to @Rmano answer (+1):

\documentclass[]{article}
\usepackage{circuitikz}
\usepackage[locale = DE]{siunitx}

\begin{document}
\begin{circuitikz}
\ctikzset{bipoles/capacitor/width/.initial=.1,
inductors/coils=5, inductors/width=0.8,
european resistors}
\draw   (0,0) node[spdt, rotate=90] (s) {}
(s.in)      to [C=$C$]      ++ (0,-2) coordinate (a)
(s.out 1)   to [R=$R$]      ++ (-2,0) coordinate (b)
to [R=$R$]      ++ (-2,0) coordinate (c)
to [battery2]   (c |- a)
to [short, -*]  (b |- a)
to [short, -*]      (a)
-- ++ (2,0)               coordinate (d)
to [L, a=$L$]   (d |- s.in)
|- (s.out 2)
(b)         to [short, *-]  (b |- s.in)
to [R=$R$]      (b |- a)
;
\end{circuitikz}
\end{document}


• Yes, quite elegant! I like the lining up of the rlc tank, +1 Sep 23 at 22:02