8

I am trying to create a circuit with resistors and voltage sources. I need to have each resistor labeled with their resistance (above) and the unknown current (below) flowing through the resistor. I manually added the unknown currents using nodes. Finally, I need to have arrows showing the flow of current through the circuit placed at each of the nodes. In my MWE (taken from an earlier question, circuitikz label malfunction), given below, there are four nodes (junctions). How do I get those arrows using what is provided by circuitikz? I need three arrows at each of the nodes indicating the flow of current (either into or out of).

\documentclass{article}
\usepackage[american,siunitx]{circuitikz}
\begin{document}
\begin{circuitikz}[x=1.5cm,y=1.2cm]
    \draw (0,0) to[battery, l=12<\volt>] (0,2) -- (0,3.5)
                to[R,l=4<\ohm>] (4,3.5) -- (4,2)
          (0,0) -- (4,0) to[battery, l=24<\volt>,i>] (4,2)
          (0,2) to[R, l=2<\ohm>, *-*] (2,2)
                to[R, l=3<\ohm>, -*] (4,2)
          (2,0) to[R, l=2.5<\ohm>, *-] (2,2);
    \draw (1,1.6) node { $I_2$};      
    \draw (3,1.6) node { $I_3$};
    \draw (2.3,1.0) node { $I_4$};
    \draw (2,3.1) node { $I_1$};
\end{circuitikz}
\end{document}

output

I would like to avoid having the add the arrows manually. There are several questions regarding circuits, however, I've been unsuccessful in finding an answer to my question. If this is a duplicate I apologize.

2 Answers 2

7

To add arrows representing the current flowing through resistors you just have to follow the package guide in which there are some examples about this problem in section 4.2 Currents.

Thus, the example becomes:

\documentclass{article}
\usepackage[american,siunitx]{circuitikz}
\begin{document}
\begin{circuitikz}[x=1.5cm,y=1.2cm]
    \draw (0,0) to[battery, l=12<\volt>] (0,2) -- (0,3.5)
                to[R,l=4<\ohm>,i_=$I_1$] (4,3.5) -- (4,2)
          (0,0) -- (4,0) to[battery, l=24<\volt>,i>] (4,2)
          (0,2) to[R, l=2<\ohm>, *-*,i_=$I_2$] (2,2)
                to[R, l=3<\ohm>, -*,i<_=$I_3$] (4,2)
          (2,0) to[R, l=2.5<\ohm>, *-,i<_=$I_4$] (2,2);
\end{circuitikz}
\end{document}

The result:

enter image description here

P.S. The current direction might be wrong ;)

3
  • I appreciate your solution, however, I would like to have each resistor doubly labeled (as in the MWE), on top (or to the left) with the resistance, and below (or to the right) with the unknown current. Then, arrows showing the current flow.
    – DJJerome
    Aug 12, 2013 at 22:28
  • @DJJerome: What you ask is more complicated than this solution and I think at the moment the package can't manage it automatically. To accomplish your idea you should hack the resistor code in order to provide a second label put in an opposite manner with respect to the traditional l. Aug 13, 2013 at 9:17
  • Yes, that is what I was afraid. I plan on working on some "hack" solution as soon as I get some time.
    – DJJerome
    Aug 13, 2013 at 17:51
4

For the arrows, you can use three small 'short' segments to put the arrows on the nodes:

\begin{circuitikz}
\draw
(0,4) 
to [R, l=R1] (2,4)
to [short, -*, i=$I_1$]  (3,4)
to [short, i<=$I_2$]  (4,4)
to [R, l=R2] (6,4)
(3,4) to [short, i=$I_3$]  (3,3)
to [R, l=R3] (3,1)
;
\end{circuitikz}

I'm not sure I understood the label problem. I use a lx label, from this thread:

Set label name on two lines in CircuiTikZ

Cheers!

3
  • This is better-suited as a comment then...
    – Werner
    Sep 18, 2014 at 17:19
  • The link you provided does not answer to the problem "I would like to have each resistor doubly labeled (as in the MWE)". The answer there puts two labels on the same side of a resistor, not on different sides. Sep 19, 2014 at 5:08
  • @ClaudioFiandrino, Indeed it does not solve the OP's question, although it does provides a way to label components without manually creating nodes.
    – Leonardo
    Nov 23, 2017 at 18:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .