# Circuit diagrams in LaTeX - Advanced features

## Introduction

as we learned in lesson 12, circuitikz is a powerful tool for circuit creation. but there are some pitfalls along the way. the circuitikz manual provides a nice reference for all components available, but lacks an in-depth explanation on how to use every element. basically, there are three important types of components available in circuitikz, which are namely monopoles, bipoles and tripoles. the other components mentioned in the manual can be used in a way similar to the classes mentioned in this tutorial.

## Lines

before i step into the various components, let me show you how to change the appearance of the basic lines in circuitikz. consider the following example:

\begin{figure}[h!]
\begin{circuitikz}
\draw (-1,0) to[short,o-o] (1,0);
\end{circuitikz}
\end{figure}

as you can see, the syntax changed a little from the previous lesson. the first line is pretty much the same. the first line will draw the upper line segment with an open connector at each end. the connectors can be selected by changing the o-o part in the code.

\begin{figure}[h!]
\begin{circuitikz}
\draw (-1,0) to[short,*-] (1,0);
\end{circuitikz}
\end{figure}

the notation for connectors is pretty straightforward. you can choose the type of connector at each end of the line by using either the * or o symbol. besides you can select that only one end or both ends of the line should have this kind of symbol e.g. o-, -o or o-o. if you don't want a connector at all, simply write to[short] without any additional symbols.

## Monopoles

\begin{figure}[h!]
\begin{circuitikz}
\draw (-1,0) to[short,o-o] (1,0);
\draw (0,0) to[short] node[ground] {} (0,-1);
\end{circuitikz}
\end{figure}

i took the line from the first section, but added a ground node to it. as you can see, the line differs in that the component is not specified as a bipole using the to operator, but as a node of type ground (node[ground]). it is imperative, that every node has a label in tikz. this label can be left empty, but the syntax should must be node[options] {}. if we decided to name our node, we could just write the text in between the braces such as

\begin{figure}[h!]
\begin{circuitikz}
\draw (-1,0) to[short,o-o] (1,0);
\draw (0,0) to[short] node[ground] {GND} (0,-1);
\end{circuitikz}
\end{figure}

that's all there is to monopoles in circuitikz.

## Bipoles

### Current arrows

the most basic way to add a current arrow to your bipole is by specifying the i option for the respective component. by default, the direction of the arrow and the position of the label are determined by circuitikz, but you can override those settings to enhance readability.

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,i=$i_1$] (2,0);
\end{circuitikz}
\end{figure}

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,i<=$i_1$] (2,0);
\end{circuitikz}
\end{figure}

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,i^=$i_1$] (2,0);
\end{circuitikz}
\end{figure}


\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,i_=$i_1$] (2,0);
\end{circuitikz}
\end{figure}

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,i<_=$i_1$] (2,0);
\end{circuitikz}
\end{figure}

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,i_>=$i_1$] (2,0);
\end{circuitikz}
\end{figure}

### Voltage arrows

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,v_>=$v_1$] (2,0);
\end{circuitikz}
\end{figure}

as you can see, the same operators apply to manipulate position and direction of the arrow

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,v^<=$v_1$] (2,0);
\end{circuitikz}
\end{figure}

### Labels

of course it's possible to add a label for the element itself as well. we do that by using the l option this time.

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,l^=$R_1$] (2,0);
\end{circuitikz}
\end{figure}

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) to[R,l_=$R_1$] (2,0);
\end{circuitikz}
\end{figure}

## Tripoles

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) node[npn](npn1) {}
(npn1.base) node[anchor=east] {B}
(npn1.collector) node[anchor=south] {C}
(npn1.emitter) node[anchor=north] {E};
\end{circuitikz}
\end{figure}

we can now refer to the nodes and attach some other elements to the transistor.

\begin{figure}[h!]
\begin{circuitikz}
\draw (0,0) node[npn](npn1) {}
(npn1.base) node[anchor=east] {B}
(npn1.collector) node[anchor=south,xshift=0.5cm] {C}
(npn1.emitter) node[anchor=north] {E};
\draw (npn1.collector) to[R] ++(0,2);
\end{circuitikz}
\end{figure}

note that i added an xshift option to the node, to prevent the label from overlapping with the new element. i hope you enjoyed my explanations and that you find using circuitikz a lot less confusing from now on.

## Summary

• There are three main classes of components in circuitikz
• All other classes can be used in a way similar to those main classes
• Usage examples are provided in the circuitikz manual