我如何创建以下绘图?
我想在我的报告中添加下图:
我听说可以用 LaTeX 完成,所以我读了一些https://es.sharelatex.com/blog/2013/09/02/tikz-series-pt4.html尝试一下:
\documentclass{article}
\usepackage{circuitikz}
\usepackage{siunitx}
\begin{document}
\begin{center}
\begin{circuitikz}\draw
(0,0) to[battery] (0,6.5)
to[ammeter] (5.5,6.5) to[resistor] (5.5,0)
(2.5,0) to[voltmeter] (2.5,6.5)
;
\end{circuittikz}\end{center}
\end{document}
正如你所看到的,我太糟糕了,我在角落里推销坐标。
答案1
PSTricks 解决方案使用pst-circ
包裹:
\documentclass{article}
\usepackage{amsmath} % used for the \overset macro
\usepackage{pst-circ} % used for the electrical components
\begin{document}
\begin{pspicture}(-1.25,0)(6.33,7) % boundry found manually
\psline[arrowscale = 1.5, arrowinset = 0]{->}(0,0)(3.5,0)(3.5,3.25)(5,3.25)
\psline(0,5)(0,6.5)(2.5,6.5)
\circledipole[labeloffset = 0](2.5,6.5)(5.5,6.5){A}
\psline(0,0)(0,1)
\vdc(0,3)(0,1){$\overset{+}{-}$}
\rput(-1,2){$\mathcal{E}$}
\resistor[dipolestyle = zigzag](0,3)(0,5){$r$}
\psframe[linestyle = dashed](-1.25,1.5)(1.0,4.9)
\circledipole[labeloffset = 0](2.5,0)(2.5,6.5){V}
\resistor[dipolestyle = zigzag](5.5,6.5)(5.5,0){$R$}
\psline(5.3,0)(5.7,0)
\end{pspicture}
\end{document}
答案2
像这样(纠正评论中提到的错别字)?
\documentclass[tikz, border=5pt, multi]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{arrows.meta}
\usepackage{siunitx}
\begin{document}
\begin{circuitikz}
\draw (0,0)
to[battery] (0,6.5)
to[ammeter] (5.5,6.5) to[resistor] (5.5,0) (2.5,0) to[voltmeter] (2.5,6.5)
;
\end{circuitikz}
\end{document}
稍微扩展一下并添加一些标签:
\begin{circuitikz}[font=\sffamily]
\draw
(0,0) to [battery, l=$\varepsilon$, n=batt] (0,3.25) to [R=r] (0,6.5) -- (2.5,6.5) to [ammeter] (5.5,6.5) to [R=R] (5.5,0) node [rground] {}
(0,0) -- (2.5,0) to [voltmeter] (2.5,6.5)
[-{Triangle[]}] (2.5,0) -- (3.5,0) |- (5,3.25)
;
\node [label=0:$+$] at ([xshift=12.5pt]batt.east) {};
\node [label=0:$-$] at ([xshift=12.5pt]batt.west) {};
\end{circuitikz}
编辑
我忘了添加最终版本。您可以使用fit
库来创建电池和电阻周围的虚线容器(如果您为它们命名)。
\documentclass[tikz, border=5pt, multi]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{arrows.meta,fit}
\usepackage{siunitx}
\begin{document}
\begin{circuitikz}[font=\sffamily]
\draw
(0,0) to [battery, l=$\varepsilon$, n=batt] (0,3.25) to [R=r,n=res] (0,6.5) -- (2.5,6.5) to [ammeter] (5.5,6.5) to [R=R] (5.5,0) node [rground] {}
(0,0) -- (2.5,0) to [voltmeter] (2.5,6.5)
[-{Triangle[]}] (2.5,0) -- (3.5,0) |- (5,3.25)
;
\node [label=0:$+$] at ([xshift=10pt]batt.east) {};
\node [label=0:$-$] at ([xshift=10pt]batt.west) {};
\node [dashed, draw, inner xsep=15pt, fit=(batt) (res)] {};
\end{circuitikz}
\end{document}