[Tex/LaTex] How to improve a small electrical diagram with TikZ and circuitikz

circuitikz

I am a beginner in LaTeX, trying to use it for an industrial document. I am trying to make a small circuit in order to illustrate a point.

However, I would like to:

  1. add a sort of legend, such as "Rc: constriction resistance" . Due to the length of text, I feel it should be placed on the side, and not directly in the diagram. I could not find a way to do this properly.
  2. Also , I would like to add on both west and east sides of the diagram, a text, perhaps vertical, stating "Pin side" and "socket side" respectively.
  3. I have tried to highlight the "half coil" resistances" by a blue color, but only the text is blue and not the resistance itself…. Can this be improved ?
  4. Is there a way to make the code more elegant and more flexible/reusable (avoiding to put all dimensions manually by using foreach or another approach)?
  5. Any other tip or suggested improvement/clarification is welcome of course…

Here's a MWE

\documentclass[a4paper, oneside,11pt, english]{scrreprt}
\usepackage{tikz}
\usepackage[siunitx]{circuitikz} %------------ 

\ctikzset{bipoles/length=3em}

\begin{document}
\begin{figure}[H]
\centering
\begin{circuitikz}[scale =1]
\draw [ultra thick] (0,-5)-- (0,2);
\draw (0,1) to[R=Rc] (2,1);
\draw [blue] (2,1) to [R=R half coil] (3,0);
\draw (3,0) to [R=Rc] (6,0);
\draw  [blue] (2,-1) to[R=R half coil] (3,0);
\draw (0,-1) to[R=Rc] (2,-1);
\draw  [blue](2,-1) to [R=R half coil] (3,-2);
\draw (3,-2) to[R=Rc] (6,-2);
\draw  [blue] (2,-3) to[R=R half coil] (3,-2);
\draw (0,-3) to[R=Rc] (2,-3);
\draw  [blue] (2,-3) to[R=R half coil] (3,-4);
\draw (3,-4) to[R=Rc] (6,-4);
\draw [ultra thick] (6,-5) -- (6,2);
\end{circuitikz}
\caption{electrical model of a canted coil power contact element}
\end{figure}
\end{document}

Best Answer

  1. You can use a (rectangular) node to place the legend.

  2. Again, using nodes you can add the text.

  3. You can pass the color=blue option to the resistor:

    \draw (2,1) to [R=R h.c.,color=blue] (3,0)
    
  4. You could use \foreach, but I don't really think it contributes a lot in this particular case.

  5. To avoid using color=blue five (or more times), I used a scope with the option.

  6. In the circuit I used R h.c. instead of R half coil to increase readability and explained the meaning in the legend.

Here's a modified version of your code:

\documentclass[a4paper, oneside,11pt, english]{scrreprt}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[siunitx]{circuitikz}

\ctikzset{bipoles/length=3em}

\begin{document}
\begin{figure}[H]
\centering
\begin{circuitikz}[scale =1]

% the side lines
\draw [ultra thick] (0,-5)-- (0,2);
\draw [ultra thick] (6,-5) -- (6,2);

% the black resistors
\draw (0,1) to[R=Rc] (2,1);
\draw (3,0) to [R=Rc] (6,0);
\draw (0,-1) to[R=Rc] (2,-1);
\draw (3,-2) to[R=Rc] (6,-2);
\draw (0,-3) to[R=Rc] (2,-3);
\draw (3,-4) to[R=Rc] (6,-4);

% the blue resistors
\begin{scope}[color=blue]
\draw (2,1) to [R=R h.c.] (3,0);
\draw (2,-1) to[R=R h.c.] (3,0);
\draw (2,-1) to [R=R h.c.] (3,-2);
\draw (2,-3) to[R=R h.c.] (3,-2);
\draw (2,-3) to[R=R h.c.] (3,-4);
\end{scope}

% the side messages
\node [anchor=south,rotate=90] at (current bounding box.west) {Pin side};
\node [anchor=north,rotate=90] at (current bounding box.east) {Socket side};

% the legend
\node [rectangle,draw,text width=3cm,align=left] at ( $ (current bounding box.center) + (6,0) $ ) {Rc: constriction resistance \\ R h.c.: R half coil};
\end{circuitikz}
\caption{electrical model of a canted coil power contact element}
\end{figure}

\end{document}

enter image description here

Related Question