这是产生下面第一张图片所示输出的代码:
\documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}
\begin{figure}[h!]
\begin{center}
\begin{circuitikz}[american]
\draw (0,0) to [isource, -*, l=$9mA$] (0,3);
\draw (0,3) to [R=$1k\Omega$, -*] (3,3);
\draw (3,3) to [isource, -*, a=$2mA$] (3,0);
\draw (3,0) to [R=$7k\Omega$] (0,0);
\draw (3,3) to [R=$6k\Omega$, -*] (6,3);
\draw (6,0) to [vsource, a=$4V$] (6,3);
\draw (6,0) to [R=$2k\Omega$] (3,0);
\draw (0,6) to [vsource, a=$2V$] (0,3);
\draw (0,6) to [R, a=$3k\Omega$, -*] (3,6);
\draw (3,6) to [R, a=$3k\Omega$] (3,3);
\draw (3,6) to [isource, a=$8mA$] (6,6);
\draw (6,6) to [R=$5k\Omega$] (6,3);
\draw (6,3) to [short, i=$I_A$] (5.2,3);
\draw (3,3) to [short, i=$I_B$] (3,3.8);
\draw (0,3) to [short, i=$I_C$] (0.8,3);
\draw (0,6) to [short, i=$I_D$] (0.8,6);
\draw (6,0) to [short, i=$I_E$] (5.2,0);
\draw (3,3) to node[ground, scale=1.4, rotate=45]{} (3,3);
\node[label=above:$V_1$] (0) at (3,6) {};
\node[label=below:$V_2$] (0) at (3,0) {};
\node[label=left:$V_3$] (0) at (0,3) {};
\node[label=right:$V_4$] (0) at (6,3) {};
\end{circuitikz}
\end{center}
\end{figure}
\end{document}
我的问题是如何在电压源图标外面放置极性标签(+/-)(就像第二张图片上那样)?
答案1
使用override source vif
,siunitx
语法表示所有值和相对坐标:
\documentclass[margin=3mm]{standalone}
\usepackage[siunitx]{circuitikz}
%\usetikzlibrary{positioning}
\begin{document}
\begin{circuitikz}[american]
\ctikzset{bipole/override source vif=true}
\draw (0,0) to [isource, l=9<\milli\ampere>,-*] ++ (0,3) coordinate[label=left:$V_3$] (A)
to [R=1<\kilo\ohm>, f>^=$I_C$, -*] ++ (3,0)
to [isource, a=2<\milli\ampere>,-*] ++ (0,-3) coordinate[label=below:$V_2$] (B)
to [R=7<\kilo\ohm>] ++ (-3,0)
%
(B) to [R, a=2<\kilo\ohm>, f_<=$I_E$] ++ (3,0)
to [esource, v=4<\volt>, -*] ++ (0,3) node[right] {$V_4$}
to [R, a=6<\kilo\ohm>, f>^=$I_A$] ++ (-3,0)
%
(A) to [esource, v^=2<\volt>] ++ (0,3)
to [R, a=3<\kilo\ohm>, f>^=$I_D$, -*] ++ (3,0) coordinate[label=above:$V_1$] (C)
to [R, a=$3k\Omega$] ++ (0,-3)
%
(C) to [isource, a=8<\milli\ampere>] ++ (3,0)
to [R=5<\kilo\ohm>] ++ (0,-3)
%
(A -| B) -- ++ (0.8,-0.4) node[ground]{}
;
\end{circuitikz}
\end{document}
答案2
欢迎来到 TeX.SX!请vsource, a=$4V$
使用代替esource, v_=$4V$
:
\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}[american]
\draw (0,0) to [isource, -*, l=$9mA$] (0,3);
\draw (0,3) to [R=$1k\Omega$, -*] (3,3);
\draw (3,3) to [isource, -*, a=$2mA$] (3,0);
\draw (3,0) to [R=$7k\Omega$] (0,0);
\draw (3,3) to [R=$6k\Omega$, -*] (6,3);
\draw (6,0) to [esource, v_=$4V$] (6,3);
\draw (6,0) to [R=$2k\Omega$] (3,0);
\draw (0,6) to [esource, v_=$2V$] (0,3);
\draw (0,6) to [R, a=$3k\Omega$, -*] (3,6);
\draw (3,6) to [R, a=$3k\Omega$] (3,3);
\draw (3,6) to [isource, a=$8mA$] (6,6);
\draw (6,6) to [R=$5k\Omega$] (6,3);
\draw (6,3) to [short, i=$I_A$] (5.2,3);
\draw (3,3) to [short, i=$I_B$] (3,3.8);
\draw (0,3) to [short, i=$I_C$] (0.8,3);
\draw (0,6) to [short, i=$I_D$] (0.8,6);
\draw (6,0) to [short, i=$I_E$] (5.2,0);
\draw (3,3) to node[ground, scale=1.4, rotate=45]{} (3,3);
\node[label=above:$V_1$] (0) at (3,6) {};
\node[label=below:$V_2$] (0) at (3,0) {};
\node[label=left:$V_3$] (0) at (0,3) {};
\node[label=right:$V_4$] (0) at (6,3) {};
\end{circuitikz}
\end{document}