我想在电路中使用可变电容二极管。但是,由于我的符号相当小,可变电容线太靠近会产生问题,从而产生难看的结果:
我无法找到两条线的距离的配置选项,因此我将无容二极管的代码复制到我的文档的前言中。
\makeatletter
\pgfcircdeclarebipole{
\anchor{strokepathstart}{
\northeast
\pgf@y=0cm
\pgf@x=.8\pgf@x
}
\anchor{strokepathend}{
\northeast
\pgf@y=0cm
}
}{\ctikzvalof{bipoles/varcap/height}}{emptyvarcap}{\ctikzvalof{bipoles/varcap/height}}{\ctikzvalof{bipoles/varcap/width}}{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfscope
\pgftransformxshift{\pgf@circ@res@left}
\pgfpathmoveto{\pgfpoint{\pgf@circ@[email protected]\pgf@circ@res@left}{0pt}}
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@[email protected]\pgf@circ@res@left}{0pt}}
\pgfusepath{draw}
\pgfpathmoveto{\pgfpoint{\pgf@circ@[email protected]\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@[email protected]\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathmoveto{\pgfpoint{\pgf@circ@[email protected]\pgf@circ@res@left}{\pgf@circ@res@down}} %%%% MODIFIED HERE
\pgfpathlineto{\pgfpoint{\pgf@circ@[email protected]\pgf@circ@res@left}{\pgf@circ@res@up}} %%%% AND HERE
\pgfusepath{draw}
\endpgfscope
}
\makeatother
我修改了标有 %%%% 的两行,并插入了因子 1.3,然后得出以下结果:
在我看来,这看起来好多了。但是,我如何才能更改连接线开始的锚点?正如我们所见,下一条线有一个小“尾巴”。
答案1
回答您的问题:在这种情况下,正确的锚点是 strokpathstart/strokpathend,因为您使用的是描边二极管符号。
尽管如此,这种情况不应该发生,我将根据上述答案调整 circuitikz 上的符号。
顺便说一句,如果您想使用描边符号,您应该使用此代码(更改了 strokepathstart 锚点)
\pgfcircdeclarebipole{
\anchor{strokepathstart}{
\northeast
\pgf@y=0cm
\advance\pgf@x by -\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgflinewidth
\advance\pgf@x by -\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgflinewidth
}
\anchor{strokepathend}{
\northeast
\pgf@y=0cm
}
}{\ctikzvalof{bipoles/varcap/height}}{emptyvarcap}{\ctikzvalof{bipoles/varcap/height}}{\ctikzvalof{bipoles/varcap/width}}{
\pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth
\pgfsetlinewidth{\pgf@circ@res@temp}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
\pgfusepath{draw}
%
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{\pgf@circ@res@up}}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfusepath{draw}
}
谨致问候,Stefan
答案2
双极子的连接点始终位于\pgf@circ@res@left
和\pgf@circ@res@right
,因此您需要将所有东西都安装在这些限制之内。
后来我想到,通过使间隙的大小与线条的粗细相同,两条线就永远不会重叠。
\documentclass[border=2mm]{standalone}
\usepackage{circuitikz}
\makeatletter
\pgfcircdeclarebipole{
\anchor{strokepathstart}{
\northeast
\pgf@y=0cm
\pgf@x=.8\pgf@x
}
\anchor{strokepathend}{
\northeast
\pgf@y=0cm
}
}{\ctikzvalof{bipoles/varcap/height}}{emptyvarcap}{\ctikzvalof{bipoles/varcap/height}}{\ctikzvalof{bipoles/varcap/width}}{
\pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth
\pgfsetlinewidth{\pgf@circ@res@temp}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{0pt}}
\pgfusepath{draw}
%
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right-2\pgf@circ@res@temp}{\pgf@circ@res@up}}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfusepath{draw}
}
\makeatother
\begin{document}
\begin{circuitikz}
\draw (0,0) to[VCo] (2,0) to[VCo] (2,2) to[VCo] (0,0);
\begin{scope}[xshift=3cm,scale=0.5,circuitikz/bipoles/length=.5cm]
\draw (0,0) to[VCo] (2,0) to[VCo] (2,2) to[VCo] (0,0);
\end{scope}
\begin{scope}[xshift=4.5cm,very thin,scale=0.5,circuitikz/bipoles/length=.5cm]
\draw (0,0) to[VCo] (2,0) to[VCo] (2,2) to[VCo] (0,0);
\end{scope}
\end{circuitikz}
\end{document}