Circuitikz –固定長の直線電圧矢印

同じ固定(ユーザー定義)の長さですべての電圧矢印を描画するにはどうすればよいですか?よろしくお願いします。
\documentclass[a4paper,10pt]{scrartcl}
\usepackage[european,straightvoltages]{circuitikz}
\ctikzset{bipoles/thickness=1}
\begin{document}
\begin{circuitikz}[line width = 0.35mm,voltage shift = 0.5]
\draw (0,0)
to[vsource, v_<=$U_0$] (0,4)
to[R,v>=$U_1$] ++(5,0);
\draw (5,4)
to[R,v>=$U_2$] ++(0,-4);
\draw (5,4)
to[short] ++({2.5},0)
to[R,v>=$U_3$] ++(0,-2)
to[R,v>=$U_4$] ++(0,-2)
to[short] (0,0);
\end{circuitikz}
\end{document}
回答
明らかに、電圧の矢印は抵抗器のサイズではなく、抵抗器が引かれる座標間の距離に依存します。言い換えれば、この距離に等しいサイズを提供する必要があります。
\documentclass[margin=3mm]{standalone}
\usepackage[european, straightvoltages]{circuitikz}
\ctikzset{bipoles/thickness=1}
\begin{document}
\begin{circuitikz}[
line width = 0.8pt,
voltage shift = 0.5]
\draw (0,0) to[vsource, v_<=$U_0$] (0, 4) -- ++ (0.5,0)
to[R,v>=$U_1$] ++ (2, 0) -- ++ (0.5,0) coordinate (aux)
-- ++ (0,-1)
to[R,v>=$U_2$] ++ (0,-2) -- ++ (0 ,-1)
(aux) to[short] ++ (2, 0)
to[R,v>=$U_3$] ++ (0,-2)
to[R,v>=$U_4$] ++ (0,-2)
to[short] (0,0);
\end{circuitikz}
\end{document}
これは:

これは、パッケージの誤った機能と見なすことができます。パッケージの作成者の1人がすぐにあなたの質問を見て、より良い解決策を提案するか、パッケージの修正をptovideすることを願っています。
@Zarko(BTW、ありがとう!)が言ったように、矢印の長さと位置は、コンポーネントのサイズではなく、ブランチの位置によって異なります。これは、circuitikz
私が共同保守を開始するかなり前の、時代の幕開けからの設計上の決定でした。したがって、基本的には石に設定されています。
これを変更する可能性のあるフラグを考えることはできますが(少し時間があればすぐに)、このことに対する「自転車を捨てる」要求がたくさんあることに注意してください...多くの人々は異なる好みを持っています(そしてそれらを持つ権利!)
そこで最近、「高度な電圧、電流、流れ」(155ページ前後のマニュアル)の可能性を追加しました。構文はあまり良くありませんが、必要なものを簡単に取得できます(これも変更することを考えていますが、簡単ではありません)一般的なものを作るために)。
たとえば(コメントを読む)
\documentclass[a4paper,10pt]{scrartcl}
\usepackage[european,straightvoltages,EFvoltages]{circuitikz}
\ctikzset{bipoles/thickness=1}
\newcommand{\fixedvlen}[3][0.75cm]{% [semilength]{node}{label}
% get the center of the standard arrow
\coordinate (#2-Vcenter) at ($(#2-Vfrom)!0.5!(#2-Vto)$);
% draw an arrow of a fixed size around that center and on the same line
\draw[blue, -Triangle] ($(#2-Vcenter)!#1!(#2-Vfrom)$) -- ($(#2-Vcenter)!#1!(#2-Vto)$);
% position the label as it where if standard voltages were used
\node[blue, anchor=\ctikzgetanchor{#2}{Vlab}] at (#2-Vlab) {#3};
}
\begin{document}
\begin{circuitikz}[line width = 0.35mm,voltage shift = 0.5]
\draw (0,0)
% using name=... and v_< without arguments enables the labels and nodes
% for personalized voltages.
to[vsource, bipole/is voltage=false, v_<, name=u0] (0,4)
to[R,v>, name=u1] ++(5,0);
\draw (5,4)
to[R,v>, name=u2] ++(0,-4);
\draw (5,4)
to[short] ++({2.5},0)
to[R,v>,name=u3] ++(0,-2)
to[R,v>,name=u4] ++(0,-2)
to[short] (0,0);
% add the personalized voltages
\fixedvlen{u0}{$U_0$}
\fixedvlen{u1}{$U_1$}
\fixedvlen[1cm]{u2}{$U_2$} % longer, to show off
\fixedvlen{u3}{$U_3$}
\fixedvlen{u4}{$U_4$}
\end{circuitikz}
\end{document}

bipole/is voltage=false
ジェネレーターにフラグを追加して、その特別な処理を抑制していることに注意してください。
この手法は非常に強力です---電圧、電流、および流れを自分の気分に合わせて実際にパーソナライズできます(この場合、例として、これらを青色に着色しましたが、可能性は無限です)。また、一貫した命名を維持すると、物事を大幅に簡略化できます...たとえば、次のようにして5つの最後の行を変更できます(U_2
長さが異なります)。
\foreach \ii in {0,...,4} {\fixedvlen{u\ii}{$U_\ii$}}
更新:この例(およびコンポーネントの長さに基づく長さの電圧矢印の別の例)をマニュアルに追加します: https://github.com/circuitikz/circuitikz/pull/466
@Rmanoによるヒントに基づいて、電圧矢印の個々の長さと色、および正しいCircuiTikZ矢印の先端を使用したソリューションを次に示します。すべての矢印を同じように見せたい場合は、たとえば\ foreachループを使用して、すべてのパラメーターを同じ値に設定します。
\documentclass[border=1mm]{standalone}
\usepackage[european,straightvoltages,EFvoltages]{circuitikz}
% Set CircuiTikZ arrow dimensions
\makeatletter
\newdimen\ctikzAL\newdimen\ctikzAW
\pgfmathsetlength{\ctikzAL}{ 1.7 * \pgf@circ@Rlen / \ctikzvalof{current arrow scale} + 2*\pgflinewidth}
\pgfmathsetlength{\ctikzAW}{ 1.6 * \pgf@circ@Rlen / \ctikzvalof{current arrow scale} + 2*\pgflinewidth}
\makeatother
% #1 – Color, #2 – Length, #3 – Short name, #4 – Long name
\newcommand{\fxdvlen}[4][black]{
\coordinate (#3-Vcenter) at ($(#3-Vfrom)!0.5!(#3-Vto)$);
\draw[#1, -{Triangle[length=\the\ctikzAL, width=\the\ctikzAW]}] ($(#3-Vcenter)!#2!(#3-Vfrom)$) -- ($(#3-Vcenter)!#2!(#3-Vto)$);
\node[#1, anchor=\ctikzgetanchor{#3}{Vlab}] at (#3-Vlab) {#4};
}
\begin{document}
\begin{circuitikz}[line width = 0.35mm,voltage shift = 0.5]
\ctikzset{bipoles/thickness=1}
\draw (0,0)
% using name=... and v_< without arguments enables the labels and nodes for personalized voltages
to[vsource, bipole/is voltage=false, v_<, name=u0, i>=$I$] (0,3)
to[R,v>, name=u1] ++(3,0);
\draw (3,3)
to[R,v>, name=u2] ++(0,-3);
\draw (3,3)
to[short] ++(1.5,0)
to[R,v>,name=u3] ++(0,-1.5)
to[R,v>,name=u4] ++(0,-1.5)
to[short] (0,0);
%\foreach \ii in {0,...,4} {\fxdvlen[blue]{5mm}{u\ii}{$U_\ii$}}
Individual voltage arrows
\fxdvlen[red]{7mm}{u0}{$U_0$}
\fxdvlen[green]{6mm}{u1}{$U_1$}
\fxdvlen[blue]{5mm}{u2}{$U_2$}
\fxdvlen[brown]{4mm}{u3}{$U_3$}
\fxdvlen{3mm}{u4}{$U_4$}
\end{circuitikz}
\end{document}
