Circuitikz – 고정 길이의 직선 전압 화살표

Dec 11 2020

예제 회로에는 5 개의 전압 화살표가 있습니다. 이들 중 4 개는 길이가 다릅니다.

동일하고 고정 된 (사용자 정의) 길이로 모든 전압 화살표를 어떻게 그릴 수 있습니까? 귀하의 지원에 미리 감사드립니다.

\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}

답변

6 Zarko Dec 11 2020 at 21:42

분명히 전압 화살표는 저항 크기가 아니라 저항이 그려지는 좌표 사이의 거리에 달려 있습니다. 즉,이 거리를 동일한 크기로 제공해야합니다.

\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}

다음을 제공합니다.

이것은 패키지의 잘못된 기능으로 간주 될 수 있습니다. 패키지 작성자 중 한 명이 곧 귀하의 질문을보고 더 나은 솔루션을 제안하거나 패키지 수정 사항을 제안하기를 바랍니다.

5 Rmano Dec 12 2020 at 02:14

@Zarko (BTW, 감사합니다!) 가 말했듯 이 화살표의 길이와 위치는 구성 요소의 크기가 아닌 지점에 따라 다릅니다. 이것은 circuitikz공동 유지 관리를 시작하기 훨씬 전인 시대의 여명기 (for ) 에서 설계 결정을 내린 것이기 때문에 기본적으로 결정되었습니다.

나는 이것을 바꿀 수있는 가능한 플래그에 대해 생각할 수있다 (시간이 조금 남자 마자). 그러나 이것에 대해 많은 "자전거 흘리기"요청이 있다는 것을 알 수있다 ... 많은 사람들이 다른 취향을 가지고있다 ( 그리고 그들을 가질 권리!)

그래서 최근에 "고급 전압, 전류 및 흐름"의 가능성을 추가했습니다 (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

Franklin Dec 17 2020 at 21:22

@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}