circuitikz 中的变量电池 1 符号

circuitikz 中的变量电池 1 符号

是否可以battery1在 中生成可变符号(带有一个向上倾斜箭头的电池) ?和(可变电阻)circuitikz有选项,但没有。我需要它来表示可变电源。 MWE 附加如下:vRvLbattery1

\documentclass{article}
\usepackage{tikz,circuitikz}
\begin{document}
\begin{circuitikz}
 \draw   (0,-2) to[battery1] (2,-2) node [right] {Powersupply};
\end{circuitikz}
\end{document}

从 MWE 生成:

我想要的是:

我想要的是

我可以手动放置一个向上箭头并将其定位到标志的中间battery1,但任何快捷方式vR都会vL有帮助。

答案1

只需定义您自己的组件。我复制并粘贴了battery1定义并添加了箭头。

\documentclass{article}
\usepackage{tikz,circuitikz}

\makeatletter

\def\pgf@circ@battery2@path#1{\pgf@circ@bipole@path{battery2}{#1}}
\compattikzset{battery2/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@battery2@path, \circuitikzbasekey/bipole/is voltage=true, v=#1}}

\ctikzset{bipoles/battery2/height/.initial=.6}
\ctikzset{bipoles/battery2/width/.initial=.3}

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/battery2/height}}{battery2}{\ctikzvalof{bipoles/battery2/height}}{\ctikzvalof{bipoles/battery2/width}}{
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@right}{0}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0}}
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@left}{0}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0}}
        \pgfusepath{draw}

        \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@left}{.5\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@left}{.5\pgf@circ@res@down}}

        \pgfpathmoveto{\pgfpoint{.33\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{.33\pgf@circ@res@right}{\pgf@circ@res@down}}

        \pgfsetarrowsend{latex'}
        \pgfpathmoveto{\pgfpoint{1.5\pgf@circ@res@left}{0.9\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint{1.5\pgf@circ@res@right}{0.9\pgf@circ@res@up}}

        \pgfusepath{draw}
}

\makeatother
\begin{document}
\begin{circuitikz}
 \draw   (0,-2) to[battery2] (2,-2) node [right] {Powersupply};
\end{circuitikz}
\end{document}

输出:

电池2

答案2

由于v1.4.1,您可以向任何组件添加“可调箭头”(请参阅​​手册“通用可调箭头”,第 84 页左右)。

\documentclass[border=2.718mm, tikz]{standalone}
\usepackage[RPvoltages]{circuitikz}
\begin{document}
\begin{tikzpicture}
 \draw   (0,-2) to[battery1, name=myB] (2,-2) node [right] {Powersupply};
 \ctikztunablearrow{1}{1}{60}{myB}
\end{tikzpicture}
\end{document}

在此处输入图片描述

PS/去争取死灵法师徽章......

相关内容