circuitikz:双极标签位置取决于绘图方向

circuitikz:双极标签位置取决于绘图方向

我偶然发现了一些我认为奇怪的行为circuitikz

双极灯(在本例中为灯)的标签距离似乎取决于组件是从左到右(R)还是从右到左(L)绘制:与从左到右绘制相比,从右到左,下方的标签更靠近组件,而上方的标签则距离较远。

\documentclass{article}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}
\draw (1,0) to [lamp, l=R] ++(1,0)
            to [lamp, l_=R] ++(1,0);
\draw (4,0) to [lamp, l=L] ++(-1,0);
\draw (1,0) to [lamp, l_=L] ++(-1,0);
\end{circuitikz}

\end{document}

在此处输入图片描述

这是错误吗?有人知道如何修复此问题吗(在我的代码中本地修复还是总体修复)?

答案1

因为上下位置不是等距的,当你故意画一个反了的电路时,你得到的位置也是反的,如果你按照语法画的话就不会有问题。

它们可能不等距,因为分离必须相对于文本框,当文本中有字符时下降项,它分离得更多,因此为了补偿,分离比下面的标签更低。从视觉上看,这对程序员来说应该是合适的,但是当方向反转时,应该是交换距离,但这并没有发生。

如何修复这个问题,是一个自定义包问题,或者重新定义它,但是是语法之外发生的事情,因为我认为由于这个原因,存在方向修饰符,例如mirrorinvert

结果:

在此处输入图片描述

代码:

\documentclass[border=20pt]{standalone}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz}
%Normal sintaxis
\draw[color=blue] (0,0) 
    to [lamp, l=Sup-Lg,i_=i] ++(1.5,0)
    to [lamp, l=Sup-Rg,i=i] ++(1.5,0)
    to [lamp, l_=Inf-Rg,i=i] ++(1.5,0)
    to [lamp, l_=Inf-Lg,i=i] ++(1.5,0)
    to [short] ++(0,2)
    to [lamp, l=Sup-Lg,i=i] ++(-1.5,0)
    to [lamp, l=Sup-Rg,i=i] ++(-1.5,0)
    to [lamp, l_=Inf-Rg,i=i,invert] ++(-1.5,0) %invert command change symbol direction, has no effect in lamp
    to [lamp, l_=Inf-Lg,i=i] ++(-1.5,0);

%Bad sintaxis, that not define a circuit
\draw[color=blue] (1.5,-2)
    to [lamp, l=Sup-Rg,i=i] ++(1.5,0)
    to [lamp, l_=Inf-Lg,i=i] ++(1.5,0);
\draw[color=red] (6,-2)
    to [lamp, l=Sup-Rg,i=i] ++(-1.5,0);
\draw[color=green] (1.5,-2)
    to [lamp, l_=Inf-Lg,i=i] ++(-1.5,0);

%Revision draws
\draw[|-|,orange,thick] (1.2,0) -- ++(0,0.55) node[midway,right=-2pt]{\scriptsize 0.55};
\draw[|-|,orange,thick] (3.8,0) -- ++(0,-0.6) node[midway,right=4pt]{\scriptsize 0.6};
\draw[|-|,orange,thick] (1.2,2) -- ++(0,0.6) node[midway,right=-2pt]{\scriptsize 0.6};
\draw[|-|,orange,thick] (5.5,2) -- ++(0,-0.55) node[midway,right=4pt]{\scriptsize 0.55};

\draw[|-|,orange,thick] (1.2,-2) -- ++(0,0.6) node[midway,right=-2pt]{\scriptsize 0.6};
\draw[|-|,blue,thick] (5.5,-2) -- ++(0,-0.55) node[midway,right=4pt]{\scriptsize 0.55};

\draw[->,orange,thick] (.5,-.5) -- ++(2,0) node[midway,below=-2pt]{\scriptsize normal};
\draw[->,orange,thick] (3.5,.5) -- ++(2,0) node[midway,above=-2pt]{\scriptsize normal};
\draw[->,orange,thick] (2.5,-2) -- ++(1,0) node[midway,above=-2pt]{\scriptsize normal};
\draw[<-,orange,thick] (5,-1.5) -- ++(1,0) node[midway,above=-2pt]{\scriptsize reverse};
\draw[<-,orange,thick] (0.5,-2.5) -- ++(1,0) node[midway,below=-2pt]{\scriptsize reverse};
\draw[<-,orange,thick] (0.5,1.5) -- ++(2,0) node[midway,below=-2pt]{\scriptsize reverse};
\draw[<-,orange,thick] (3.5,2.5) -- ++(2,0) node[midway,above=-2pt]{\scriptsize reverse};

%finally with diodes:
\draw[color=blue](0,-4)
    to [D*,l=Sup-Lg,i=i] ++(1.5,0)
    to [D*,l=Sup-Rg,i=i,invert] ++(1.5,0) % invert has effect, but not in current.
    to [D*,l_=Inf-Lg,i<=i,invert] ++(1.5,0) % i<, is used to change the current.
    to [D*,l_=Inf-Lg,i=i] ++(1.5,0);

\draw[color=blue](1.5,-6)
    to [D*,l=Sup-Lg,i=i] ++(1.5,0)
    to [D*,l_=Inf-Rg,i=i] ++(1.5,0);
\draw[color=green](1.5,-6)
    to [D*,l_=Inf-Lg,i=i] ++(-1.5,0);
\draw[color=red](6,-6)
    to [D*,l=Sup-Lg,i=i] ++(-1.5,0);

\end{circuitikz}
\end{document}

相关内容