Circuitikz 라벨 배치가 일관되지 않은 것 같습니다. 어떻게 해결합니까?

Circuitikz 라벨 배치가 일관되지 않은 것 같습니다. 어떻게 해결합니까?

나는 처음이다circuitikzTikZ를 처음 접했고 겉으로는 간단한 문제가 있습니다. 내 저항기의 라벨은 내가 찾을 수 있는 이유 없이 반대쪽에 있습니다.

산출

\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}[node distance = 0.5cm, auto, font=\tiny, inner sep =0.8mm,american voltages]
    \ctikzset {label/align = straight }
    %PSU
    \draw[dashed](0.5,-3.5)rectangle(3.5,2.5);  
    \node at (2,2.7) (PSU_l){PSU};
    \draw (2,0) to[V=$V_{\mathrm{DS}}$,*-*] (2,2);
    \draw (2,-3) to[V=$V_{\mathrm{GS}}$,*-*] (2,-1);
    \draw (2,-1) to (4,-1) to (4,0) to (2,0);

    %Load resistors 
    \draw (2,2) to (4,2);
    \draw (4,2)to[R=$R_{\mathrm{L1}}$,*-*] (4,0); 
    \draw (2,-3) to (4,-3);
    \draw(4,-3)to[R=$R_{\mathrm{L2}}$,*-*] (4,-1); 
\end{tikzpicture}
\end{document}

아마도 레이블을 (반)수동으로 배치할 수 있을 것입니다(경로를 기준으로 노드를 배치하는 방법을 모르기 때문에 지금은 완전히 수동으로 배치해야 합니다). 그러나 다음과 같이 말할 수 있는 방법이 있어야 한다고 확신합니다. 라벨을 붙일 저항기(또는 다른 라인)의 어느 쪽에 있는지.

답변1

설명에서 언급했듯이 경로에서 서로 다른 방향이 사용되기 때문에 배치가 달라집니다. 첫 번째 구성 요소는 아래쪽으로 향하는 경로에 있고 두 번째 구성 요소는 위쪽으로 향하는 경로에 있습니다.

circuitikz경로 방향을 사용하여 레이블을 배치합니다. 기본적으로 레이블은 아래쪽으로 가는 경로의 경우 오른쪽에 배치되고 왼쪽에서 오른쪽으로 가는 경로의 경우 레이블은 위쪽에 배치됩니다. 레이블은 위쪽으로 가는 경로의 경우 왼쪽에 배치되고 오른쪽에서 왼쪽으로 가는 경로의 경우 아래쪽에 배치됩니다. 기본 배치 위치는 l^, l_수정자를 사용하여 변경할 수 있습니다(아래 두 번째 코드 참조).

일관된 결과를 얻으려면 동일한 방향의 경로를 사용하여 구성 요소를 그리면 됩니다. 따라서 두 번째 구성 요소의 경우

\draw(4,-3)to[R=$R_{\mathrm{L2}}$,*-*] (4,-1); 

당신이 사용할 수있는

\draw(4,-1)to[R=$R_{\mathrm{L2}}$,*-*] (4,-3); 

완전한 예:

\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}[node distance = 0.5cm, auto, font=\tiny, inner sep =0.8mm,american voltages]
    \ctikzset {label/align = straight }
    %PSU
    \draw[dashed](0.5,-3.5)rectangle(3.5,2.5);  
    \node at (2,2.7) (PSU_l){PSU};
    \draw (2,0) to[V=$V_{\mathrm{DS}}$,*-*] (2,2);
    \draw (2,-3) to[V=$V_{\mathrm{GS}}$,*-*] (2,-1);
    \draw (2,-1) to (4,-1) to (4,0) to (2,0);

    %Load resistors 
    \draw (2,2) to (4,2);
    \draw (4,2)to[R=$R_{\mathrm{L1}}$,*-*] (4,0); 
    \draw (2,-3) to (4,-3);
    \draw(4,-1)to[R=$R_{\mathrm{L2}}$,*-*] (4,-3); 
\end{tikzpicture}
\end{document}

여기에 이미지 설명을 입력하세요

또 다른 옵션은 임의의 방향으로 경로를 그린 다음 l^=또는 l_=구문을 사용하여 적절한 위치에 레이블을 배치하는 것입니다.

\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{tikzpicture}[node distance = 0.5cm, auto, font=\tiny, inner sep =0.8mm,american voltages]
    \ctikzset {label/align = straight }
    %PSU
    \draw[dashed](0.5,-3.5)rectangle(3.5,2.5);  
    \node at (2,2.7) (PSU_l){PSU};
    \draw (2,0) to[V=$V_{\mathrm{DS}}$,*-*] (2,2);
    \draw (2,-3) to[V=$V_{\mathrm{GS}}$,*-*] (2,-1);
    \draw (2,-1) to (4,-1) to (4,0) to (2,0);

    %Load resistors 
    \draw (2,2) to (4,2);
    \draw (4,2)to[R=$R_{\mathrm{L1}}$,*-*] (4,0); 
    \draw (2,-3) to (4,-3);
    \draw(4,-3)to[R,l_=$R_{\mathrm{L2}}$,*-*] (4,-1); 
\end{tikzpicture}
\end{document}

답변2

PSTricks 솔루션:

\documentclass{article}

\usepackage{pst-circ}

\begin{document}

\begin{pspicture}(7.25,10.4)
  \pnodes{P}(0,0)(0,0)(0,10)(5,10)(2.5,1)(2.5,4.5)(6,4.5)(6,1)(2.5,5.5)(2.5,9)(6,9)(6,5.5)
  \psframe[linestyle = dashed](P1)(P3)
  \pcline[linestyle = none, offset = 9pt](P2)(P3)
  \ncput{\textsc{psu}}
 \psset{arrows = *-*, dipolestyle = zigzag, labelInside = 2, labeloffset = 1}
  \Ucc(P4)(P5){$V_{\textsc{gs}}$}
  \wire(P5)(P6)
  \resistor(P6)(P7){$R_{\textsc{l}2}$}
  \wire(P7)(P4)
  \Ucc(P8)(P9){$V_{\textsc{ds}}$}
  \wire(P9)(P10)
  \resistor(P10)(P11){$R_{\textsc{l}1}$}
  \wire(P11)(P8)
\end{pspicture}

\end{document}

산출

관련 정보