Circuitikz 双极子:自动长度

Circuitikz 双极子:自动长度

我想在 Circuitikz 中声明一个双极子,它会根据坐标自动改变其长度。MWE:

\documentclass{standalone}

\usepackage[european,strokediode]{circuitikz}

\ctikzset{bipoles/length=5mm}

\makeatletter
% used to process styles for to-path
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}
% restore size value for bipole definitions
\pgf@circ@Rlen = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
\makeatother

\newlength{\ResUp} \newlength{\ResDown}
\newlength{\ResLeft} \newlength{\ResRight}



\ctikzset{bipoles/mstline/height/.initial=.30}
\ctikzset{bipoles/mstline/width/.initial=1.80}
\pgfcircdeclarebipole{}
{\ctikzvalof{bipoles/mstline/height}}
{mstline}
{\ctikzvalof{bipoles/mstline/height}}
{\ctikzvalof{bipoles/mstline/width}}
{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfextractx{\ResRight}{\northeast}
\pgfextractx{\ResLeft}{\southwest}
\pgfextracty{\ResDown}{\southwest}
\pgfpathrectanglecorners{\southwest}{\northeast}
\pgfusepath{draw}
}
\def\speakerpath#1{\TikzBipolePath{mstline}{#1}}
\tikzset{mstline/.style = {\circuitikzbasekey, /tikz/to path=\speakerpath, l=#1}}


\begin{document}
\scriptsize
\begin{circuitikz}
\draw (0,0) to [mstline] ++(40mm,0);
\end{circuitikz}
\end{document}

现在我希望双极子的mstline宽度为 40 毫米,如果我将 40 毫米改为 50 毫米,那么符号的宽度也应该是 50 毫米。这样的事可能吗?如何实现?我尝试了一下,但没有找到答案。

相关内容