# How to draw electrical scheme?

Can someone write the code for these two schemes, I am a beginner and do not know how to do. To create the proper connector at the \draw command, you can use the command \left.

I just dont know how to put the name of the i_{b1},i_{b2}..ect how to make the source and the +-.

What I want to achieve:

MWE:

\documentclass{article}
\usepackage{circuitikz}
\begin{document}

\begin{figure}[ht!]
\begin{circuitikz}[american current source,european,>=latex']
\draw(-8,4) to [open, v=$u_{ul}$,o-o] (-8,1);
\draw(-8,4) -- (-6,4);
\draw(-6,4) to[R,l_=$h_{ie1}$,i>=$i_{b1}$,*-] (-3,4);
\draw(-6,4) to [R,l=$R_{B1}$,i>=$i_{B1}$,-*](-6,1);
\draw(-0.5,4) to[european inductor,l_=$L_i$,i>=$i_{12}$,*-*] (-0.5,1);
\draw(-3,4) to[C,l_=$C_{E1}$,i>=$i_{e1}$,*-] (-3,1);
\draw(3.5,1) to[american current source,color=magenta,l=$h_{fe}i_{b2}$] (3.5,4);
\draw(-1,4) to[american current source,color=magenta,l=$h_{fe}i_{b1}$] (-3,4);
\draw(-0.5,4) to[R,l_=$h_{ie2}$,i>=$i_{b2}$,*-*] (3,4);
\draw(5.5,4) to[R,l_=$Z_{E2}$] (5.5,1);
\draw(7,4) to[R,l_=$R_p$] (7,1);
\draw(-8,1) -- (7,1);
\draw(3.5,4) -- (5.5,4);
\draw(5.5,4) -- (7,4);
\draw(-1,4) -- (0,4);
\draw(7.5,4) to [open, v=$u_{iz}$,] (7.5,1);
\draw (-6,4.3)node{$B_1$} (-3,4.3)node{$E_1$} (-1,4.3)node{$C_1$} (0,4.3)node{$B_2$} (3.5,4.3)node{$E_2$} (3.5,0.7)node{$C_2$};
\end{circuitikz}
\end{figure}
\end{document}


My current result:

• Comments cleaned up: question now rather different. Commented Jan 8, 2016 at 10:39
• It looks like the american current source argument is causing the current labels to appear near the components rather than the lines.
– AJN
Commented Jan 8, 2016 at 11:39

I already posted an answer in the LaTeX Community forum where you started a thread about such circuits earlier: Help with a circuitikz problem.

What I would improve at first:

• Avoid having coordinate numbers everywhere. Working on it, it's hard to remember what (3.5,4) actually means. It's better to use a name such as (E2) for it, so you always know the meaning. You can even label the coordinates, so no need for extra nodes.

• Use length or macros, build coordinates on parameters, which makes changes easier, such as shifting a whole row of coordinates upwards.

• Use styles for all what has formatting or color, so later re-styling is much easier.

• Let TikZ calculate points such as midpoints, so it will adjust automatically when you change coordinates. Also calculating points with a defined distance is good, so you still can tweak the distance in the whole drawing or document.

• Use spacing to have a better readable code.

Here's a sample where I added + and - and the colored lines with rounded corners and arrow to your code, and improved your code a bit (just my opinion). Some options (european) did not work on my system, so it's omitted.

And as AJH already mentioned in a comment, the option american current source should be removed for the desired label positioning near the line instead of the component.

\documentclass{article}
\usepackage[european]{circuitikz}
\usetikzlibrary{arrows.meta,quotes,positioning}
\def\distance{0.5}
\def\leftColor{red}
\def\rightColor{blue}
\def\Top{4}
\def\Bottom{1}
\tikzset{
sign1/.style={anchor=center, text=\leftColor},
sign2/.style={anchor=center, text=\rightColor},
}
\begin{document}
\begin{figure}[ht!]
\begin{circuitikz}
\coordinate (LeftTop)            at ( -8,\Top);
\coordinate (RightTop)           at (  7,\Top);
\coordinate ["$B_1$"] (B1)       at ( -6,\Top);
\coordinate ["$B_2$"] (B2)       at (  0,\Top);
\coordinate ["$E_1$"] (E1)       at ( -3,\Top);
\coordinate ["$E_2$"] (E2)       at (3.5,\Top);
\coordinate ["$C_1$"] (C1)       at ( -1,\Top);
\coordinate           (ZT)       at (5.5,\Top);
\coordinate (LeftBottom)         at ( -8,\Bottom);
\coordinate (RightBottom)        at (  7,\Bottom);
\coordinate          (B2B)       at (  0,\Bottom);
\coordinate          (E1B)       at ( -3,\Bottom);
\coordinate ["below:$C_2$"] (C2) at (3.5,\Bottom);
\coordinate           (ZB)       at (5.5,\Bottom);
%\draw (LeftTop) to [open, v=$u_{ul}$,o-o] (LeftBottom);
\draw (LeftTop) -- (B1);
\draw (B1) to[R,l_=$h_{ie1}$,i>=$i_{b1}$,*-] (E1);
\draw (B1) to [R,l=$R_{B1}$,i>=$i_{B1}$,-*] (-6,1);
\draw (-0.5,4) to[european inductor,l_=$L_i$,i>=$i_{12}$,*-*] (-0.5,1);
\draw (E1) to[C,l_=$C_{E1}$,i>=$i_{e1}$,*-] (-3,1);
\draw (3.5,1) to[american current source,color=magenta,l=$h_{fe}i_{b2}$] (3.5,4);
\draw (C1) to[american current source,color=magenta,l=$h_{fe}i_{b1}$] (-3,4);
\draw (-0.5,4) to[R,l_=$h_{ie2}$,i>=$i_{b2}$,*-*] (3,4);
\draw (5.5,4) to[R,l_=$Z_{E2}$] (5.5,1);
\draw (RightTop) to[R,l_=$R_p$] (RightBottom);
\draw (LeftBottom) -- (RightBottom);
\draw (E2) -- (5.5,4);
\draw (5.5,4) -- (RightTop);
\draw (C1) -- (B2);
%\draw (7.5,4) to [open, v=$u_{iz}$,] (7.5,1);
\node (plus1)  [below = \distance of LeftTop,    sign1] {$+$};
\node (minus1) [above = \distance of LeftBottom, sign1] {$-$};
\draw [rounded corners, \leftColor, ->, >=Triangle]
($(plus1)!.5!(minus1)+(\distance,0)$) --
($(plus1)+(\distance,0)$)             --
($(E1) -(\distance,\distance)$)       --
($(E1B)+(-\distance,\distance)$)      ->
($(minus1)+(\distance,0)$)
;
\node (plus2)  at ($(B2)+(0,-\distance)$) [sign2] {$+$};
\node (minus2) at ($(B2B)+(0,\distance)$) [sign2] {$-$};
\node (plus3)  at ($(RightTop)+(\distance,-\distance)$) [sign2] {$+$};
\node (minus3) at ($(RightBottom)+(\distance,\distance)$) [sign2] {$-$};
\draw [rounded corners, \rightColor, dashed, ->, >=Triangle]
($(B2)!.5!(B2B)+(\distance,0)$)   --
($(B2)+(\distance,-\distance)$)    --
($(ZT) + (\distance,-\distance)$) --
($(ZB) + (\distance,\distance)$)  ->
($(minus2)+(\distance,0)$)
;
\end{circuitikz}
\end{figure}
\end{document}


Also the LaTeX Community thread is open for further discussion.

• For the OP; the FAQ section of the Circuitikz manual mentioned "open" circuits which can be used to draw the currents such as $i_{ul}$ (top left). Commented Jan 8, 2016 at 13:21

Just to help you compare, here is another solution that makes use of Circuit Macros:

.PS
cct_init
l=1.2*elen_

# Define label at starting point, to draw 'gap' here later
S: Here
arrowline(right_ 3*l/4);rlabel(,i_{ul})
# Diversion: draw resistor downwards
{
dot
"$\mathrm{B}_1$" above
RB1:resistor(down_ l,E);llabel(,R_{_{B1}})
b_current(i_{_{B1}},,O,E,0.4)
dot
}
resistor(right_ l,E);rlabel(,h_{ie1})
b_current(i_{b1},,O,E,0.5)
# Diversion: draw capacitor downwards
{
E1:dot
"$\mathrm{E}_1$" above
capacitor(down_ l);rlabel(,C_{_{E1}})
b_current(i_{_{e1}},,O,E,0.4)
dot
}
setrgb(1,0,1)
source(right_ l,I,,R)
setrgb(0,0,0)
rlabel(,h_{fe}i_{b1})
llabel(,,\;\;\mathrm{C}_1)
# Diversion: draw inductor downwards
{
dot
ebox(down_ l,,,0);rlabel(,L_1);dlabel(0.2,0.2,+,u_{_{12}},-)
b_current(i_{_{12}},,O,E,0.4)
dot
}
resistor(right_ l,E);rlabel(,h_{ie2})
llabel(\mathrm{B}_2\;\;)
b_current(i_{b2},,O,E,0.5)
# Diversion: draw current source downwards
{
E2:dot
"$\mathrm{E}_2$" above
setrgb(1,0,1)
L1:source(down_ l,I,,R)
setrgb(0,0,0)
rlabel(,L_1)
b_current(i_{_{12}},,O,E,0.4)
dot
"$\mathrm{C}_2$" at Here-(0,0.05) below
}
line right_ 3*l/4
# Diversion: draw resistor downwards
{
dot
resistor(down_ l,E);rlabel(,Z_{_{E2}})
dot
}
arrowline(right_ l/2);rlabel(,i_{iz})
corner
# draw resistor downwards
resistor(down_ l,E);rlabel(,R_p);dlabel(0.3,0.25,+,u_{iz},-)
corner
line left_ Here.x-S.x
gap(up_ l,1);clabel(-,u_{ul},+)

# Now the loop paths
# using a bit of pic language
w=1.5*l
h=0.8*l
c=0.1
Center: RB1+(0.12,0)
setrgb(1,0,0)
line up l from Center+(-w/2,0) to Center+(-w/2,h/2-c)
spline up c then right c
line right w-2*c
spline right c then down c
line down h-2*c
spline down c then left c
line -> left w-c
setrgb(0,0,0)

w=1.6*l
h=0.8*l
c=0.1
Center: L1+(0.1,0)
setrgb(0,0,1)
line up l from Center+(-w/2,0) to Center+(-w/2,h/2-c) dashed
spline up c then right c dashed
line right w-2*c dashed
spline right c then down c dashed
line down h-2*c dashed
spline down c then left c dashed
line -> left w-c dashed
setrgb(0,0,0)

# Finishing. Some minor corrections:
dot(at E1)  # Correct magenta running over dot
dot(at E2)  # Correct magenta running over dot

.PE


Resulting in:

Of course this approach has the disadvantage of needing additional processing steps (in my case I used "source->pic->tikz"), but it has other benefits, such as no need to worry about absolute coordinates.

Hope this helps.

• There's an obvious labelling error at upwards current source. Label command should be "rlabel(,h_{fe}i_{b2})" instead of "rlabel(,L_1)". Hope that readers noticed it. Commented Jun 6, 2016 at 16:43