我正在尝试绘制惠斯通电桥,这是我目前拥有的代码:
\documentclass[12pt]{article}
\usepackage[americanvoltages,fulldiodes,siunitx]{circuitikz}
\usepackage[pdftex]{graphicx}
\usepackage[width=16.00cm, height=22.00cm]{geometry}
\usepackage{letltxmacro}
\begin{document}
\begin{circuitikz}[scale=2.5]\draw
(0,0) to[battery1, l=$V$] (0,2) -- (2,2)
to[R=$R_1$,*-*] (1,1)
to[R=$R_3$, *-*] (2,0) -- (0,0);
\draw (2,2) to[R=$R_2$, *-*] (3,1)
to[R=$R_4$, *-*] (2,0);
\draw (1,1) to[R=$R_5$, *-*] (3,1);
\draw[>=latex,->,color=magenta,text=black, thick] (0.6,1.9)
to[out=-0,in=-0] (1.4,1.9) to[out=8,in=70] (0.8,1)node[anchor=east]{$I_a$}
to[out=-70,in=-0] (1.4,0.1) to[out=-0,in=-0] (0.5,0.1);
\draw[>=latex,->,color=magenta,text=black, thick](1.7,1.3)arc(220:-50:0.4 and 0.15);
\draw[>=latex,<-,color=magenta,text=black, thick](1.7,0.8)arc(-220:50:0.4 and 0.15);
\filldraw[fill=black] (2,1.5) circle(0pt)node[anchor=south]{$I_b$};
\filldraw[fill=black] (2,0.78) circle(0pt)node[anchor=north]{$I_c$};
\end{circuitikz}
它产生的结果是:
请注意对角电阻的标签有多大!
问题 1:
我怎样才能使这些标签的字体大小恢复正常(即与$R_5$
和大小相同$V$
)?我不想使用\tiny
或 之类的字体大小编辑器\small
;我已经这样做了,甚至\tiny
字体大小仍然比正常情况略大。应该有一种更自然的方式来调整字体大小不是增加并保持其应有的状态,不是吗?
问题2:
长弯曲箭头的$I_a$
中间附近有一个尖角,我想将其平滑(使其成为平滑的曲线),并且箭头的顶角和底角似乎过渡得不太自然(即您可以看到有点锯齿状,曲线没有自然地流入平线)。有没有一种简单的方法来修复这些顶角/中角/底角,而不必单独调整所有角度?in/out
如果有,怎么做?
谢谢你!
答案1
问题 1
x=<length>
您可以使用、 ,而不必缩放电路,y=<length>
这样标签等就不会受到影响。
问题2
您只需使用--
和rounded corners
即可轻松生成平滑的曲线路径。在下面的示例中,
\draw[>=latex,->,color=magenta,text=black, thick] (0.6,1.9)
to[out=-0,in=-0] (1.4,1.9) to[out=8,in=70] (0.8,1)node[anchor=east]{$I_a$}
to[out=-70,in=-0] (1.4,0.1) to[out=-0,in=-0] (0.5,0.1);
我用了
\draw[>=latex,->,color=magenta,text=black, thick,rounded corners=7pt]
(0.6,1.9) -- (1.6,1.9) --
(0.7,1) node[anchor=east]{$I_a$} --
(1.6,0.1) -- (0.5,0.1);
代码;我还在scope
末尾使用了 来简化代码,并将I_b
和I_c
作为节点放置在arc
路径上(这无需人工干预即可产生正确的定位并简化代码):
\documentclass[12pt]{article}
\usepackage[americanvoltages,fulldiodes,siunitx]{circuitikz}
\usepackage{graphicx}
\usepackage[width=16.00cm, height=22.00cm]{geometry}
\usepackage{letltxmacro}
\begin{document}
\begin{circuitikz}[x=2.5cm,y=2.5cm]
\draw
(0,0) to[battery1, l=$V$] (0,2) -- (2,2)
to[R=$R_1$,*-*] (1,1)
to[R=$R_3$, *-*] (2,0) -- (0,0);
\draw
(2,2) to[R=$R_2$, *-*] (3,1)
to[R=$R_4$, *-*] (2,0);
\draw
(1,1) to[R=$R_5$, *-*] (3,1);
\begin{scope}[>=latex,color=magenta,thick,text=black]
\draw[->,rounded corners=7pt]
(0.6,1.9) -- (1.6,1.9) --
(0.7,1) node[anchor=east]{$I_a$} --
(1.6,0.1) -- (0.5,0.1);
\draw[->]
(1.7,1.3) arc(220:-50:0.4 and 0.15)
node[pos=0.5,above] {$I_b$};
\draw[<-]
(1.7,0.8) arc(-220:50:0.4 and 0.15)
node[midway,above] {$I_c$};
\end{scope}
\end{circuitikz}
\end{document}
答案2
如果您可以不用对节点应用坐标变换,我可以提供一个补丁。作者可能忘记让当前变换独立于旋转。保护范围内所有可能的形状等有点繁琐,所以我只是关闭了变换。
\documentclass[12pt]{article}
\usepackage[americanvoltages,fulldiodes,siunitx]{circuitikz}
\usepackage[width=16.00cm, height=22.00cm]{geometry}
\usepackage{letltxmacro}
\makeatletter
\def\pgf@circ@drawrotlabel{
\pgfextra{
% calcolo rotazione label
\def\pgf@circ@temp{\ctikzvalof{bipole/label/position}} %%% àncora label
\edef\pgfcirclabrot{\pgf@circ@direction} % primo e quarto quadrante
\edef\pgfcircmathresult{\expandafter\pgf@circ@stripdecimals\pgf@circ@direction\pgf@nil}
\ifnum \pgfcircmathresult > 90 \ifnum \pgfcircmathresult < 270 % terzo e secondo
\pgfmathsubtract{\pgf@circ@direction}{180}
\edef\pgfcirclabrot{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil}
\pgfmathadd{\pgf@circ@temp}{180} %%%
\edef\pgf@circ@temp{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil} %%%
\fi\fi
\ifnum \ctikzvalof{mirror value} = -1
\pgfmathadd{\pgf@circ@temp}{180}
\edef\pgf@circ@temp{\expandafter\pgf@circ@stripdecimals\pgfmathresult\pgf@nil}
\fi
}
coordinate (labelcoor) at ($(\ctikzvalof{bipole/name})!2!(\ctikzvalof{bipole/name}.north)$)
(labelcoor) node [transform shape=false, rotate=\pgfcirclabrot] {\pgf@circ@finallabel{}}
}
\begin{document}
\begin{circuitikz}[scale=2.5]
\draw (0,0) to[battery1, l=$V$] (0,2) -- (2,2) to[R,l=$R_1$] (1,1) to[R,l=$R_3$, *-*] (2,0) -- (0,0);
\draw (2,2) to[R=$R_2$, *-*] (3,1)to[R=$R_4$, *-*] (2,0);
\draw (1,1) to[R=$R_5$, *-*] (3,1);
\draw[>=latex,->,color=magenta,text=black, thick] (0.6,1.9)
to[out=-0,in=-0] (1.4,1.9) to[out=8,in=70] (0.8,1)node[anchor=east]{$I_a$}
to[out=-70,in=-0] (1.4,0.1) to[out=-0,in=-0] (0.5,0.1);
\draw[>=latex,->,color=magenta,text=black, thick](1.7,1.3)arc(220:-50:0.4 and 0.15);
\draw[>=latex,<-,color=magenta,text=black, thick](1.7,0.8)arc(-220:50:0.4 and 0.15);
\filldraw[fill=black] (2,1.5) circle(0pt)node[anchor=south]{$I_b$};
\filldraw[fill=black] (2,0.78) circle(0pt)node[anchor=north]{$I_c$};
\end{circuitikz}
\end{document}