How can I draw the switch in circuitikz?
Like this?
with use of the switch symbol spdt
(see circuitikz
package documentation, page 108) and use default (american
) style of circuits drawing :
\documentclass[border=3.141592mm]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\node[spdt, rotate=90] (sw) {};
\draw (sw.in) to [L={$(L,r)$}] ++ (0,-2)
to [R=$R$] ++ (0,-2) coordinate (aux1)
(sw.out 2) node[above] {(2)} to [short] ++ (+1,0) |- (aux1)
(sw.out 1) node[above] {(1)} to [short] ++ (-1,0) coordinate (aux2)
to [vsource, a=$E$] (aux2 |- aux1)
to [short] (aux1);
\end{circuitikz}
\end{document}
For european
style, you need to add circuitikz
option european
:
\begin{circuitikz}[european]
In this case result is the following:
However, if you like to have mix og the both styles, then MWE is:
\documentclass[border=3.141592mm]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\node[spdt, rotate=90] (sw) {};
\draw (sw.in) to [L={$(L,r)$}] ++ (0,-2)
to [R=$R$, european] ++ (0,-2) coordinate (aux1)
(sw.out 2) node[above] {(2)} to [short] ++ (+1,0) |- (aux1)
(sw.out 1) node[above] {(1)} to [short] ++ (-1,0) coordinate (aux2)
to [vsource, a=$E$] (aux2 |- aux1)
to [short] (aux1);
\end{circuitikz}
\end{document}
which produce:
And for the label, you have to add curly brackets INSIDE the $: ${(L,r)}$, otherwise the parser mess up. It gives you finally:
\documentclass[border=3.141592mm]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
\node[spdt, rotate=90] (sw) {};
\draw (sw.in) to [L=${(L,r)}$] ++ (0,-2)
to [R=$R$, european] ++ (0,-2) coordinate (aux1)
(sw.out 2) node[above] {(2)} to [short] ++ (+1,0) |- (aux1)
(sw.out 1) node[above] {(1)} to [short] ++ (-1,0) coordinate (aux2)
to [vsource, a=$E$] (aux2 |- aux1)
to [short] (aux1);
\end{circuitikz}
\end{document}```
here is my contribution
\documentclass[border=2mm]{standalone}
\usepackage[european, cute inductors]{circuitikz}
\begin{document}
\begin{circuitikz}
\node[spdt, rotate=90] (inter) {};
\draw (inter.in)
to [L, l=\mbox{$(L,r)$}] ++ (0,-2)
to [R, l=$R$] ++ (0,-2) coordinate (aux1)
(inter.out 2) node[above] {(2)}
to [short] ++ (+1,0) |- (aux1)
(inter.out 1) node[above] {(1)}
to [short] ++ (-1,0) coordinate (aux2)
to [vsource, a=$E$] (aux2 |- aux1)
to [short] (aux1);
\end{circuitikz}
\end{document}
I used \mbox
to write the detail of the dipole L, r.
Being European, I insert the option european
into the circuitikz package directly. As Zarko indicates, on the other hand, you must also add the option cute inductors
to avoid obtaining a black rectangle as the inductor.