# How to improve a small electrical diagram with TikZ and 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}

-

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}


-
Thanks a lot. It looks beautiful. I had unsucceffully tried to align the slope of the text "R h.c." with the resistor, with the "sloped" option... Woould that be an option in the new code? – Yves May 3 '12 at 18:03
@Yves You're welcome! I don't fully understand your request about the labels (R h.c.), can you please explain in a little more detail what you want to achieve? – Gonzalo Medina May 3 '12 at 20:17
Surprisingly, when I compile your code, the blue text "R h.c." associated to the blue resistors is horizontal in all cases. In your figure, they are nicely parallel with the axis of the blue resistors.. I wonder why.. May this have something to do with a different version of the package....? – Yves May 4 '12 at 16:37
@Yves: yes, most surely it's a version problem. Which version of LaTeX do you use? (I use TeX Live2011 last updated yesterday). You could try using \ctikzset{label/align = rotate} right after \begin{circuitikz}[scale=1] but I am not sure that this option will work in older versions of circuitikz. – Gonzalo Medina May 4 '12 at 17:34
I use at home Texlive 2010, as I have a relatively old Mac computer on OSX 10.4.11, where Texlive 2011 cannot be installed. The change you suggested does not work either. However I use a PC in the office and will investigate next week if the problem exists, and will update if necessary. – Yves May 4 '12 at 20:31