开路中间的 Circuitikz 标签

开路中间的 Circuitikz 标签

我刚刚开始使用 Circuitikz,我想知道如何在开路的中间(可能两边都有正号和负号)得到一个标签,比如“v”。

另外,是否可以插入没有对角线穿过的电流表或电压表?

谢谢

编辑:

\begin{circuitikz}[american, scale = 2]\draw
(0,0)       to [sV = $V_m\cos(\omega t + \theta)$]  (0,2)
            to [C = \si{10}{\pico\farad}]           (2,2)
            to [R = \si{250}{\ohm}, *-*]            (2,0)
            to [L = \si{300}{\micro\henry}]         (0,0)
(2,2)       --                                      (4,2)
            to [voltmeter = \si{800}{\nano\farad}]  (4,0)
            --                                      (2,0)
(0,2)       to [short, *-o]                         (0,3)
(2,2)       to [short, -o]                          (2,3)
;\end{circuitikz}

电路

答案1

您应该从 CircuiTikZ 代码中编辑电压表定义。我通过注释一些行并添加新行来旋转标签为您完成了这项工作。实际上,我基于原始组件创建了一个名为 myvoltmeter 的新组件。我也镜像了电感器。请按照包手册中的说明使用 siunitx。

\documentclass{article}
\usepackage{siunitx}
\usepackage{circuitikz}
\makeatletter
\def\pgf@circ@myvoltmeter@path#1{\pgf@circ@bipole@path{myvoltmeter}{#1}}
\tikzset{myvoltmeter/.style = {\circuitikzbasekey, /tikz/to
                               path=\pgf@circ@myvoltmeter@path}}
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/voltmeter/height}}{myvoltmeter}
    {\ctikzvalof{bipoles/voltmeter/height}}{\ctikzvalof{bipoles/voltmeter/width}}
{
  \def\pgf@circ@temp{right}
  \ifx\tikz@res@label@pos\pgf@circ@temp
    \pgf@circ@res@step=-1.2\pgf@circ@res@up
  \else
    \def\pgf@circ@temp{below}
    \ifx\tikz@res@label@pos\pgf@circ@temp
      \pgf@circ@res@step=-1.2\pgf@circ@res@up
    \else
      \pgf@circ@res@step=1.2\pgf@circ@res@up
    \fi
  \fi

  \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@zero}}     
  \pgfpointorigin   \pgf@circ@res@other =  \pgf@x
  \advance \pgf@circ@res@other by -\pgf@circ@res@up
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{\pgf@circ@res@zero}}
  \pgfusepath{draw}

  \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}
                   \pgfstartlinewidth}

  \pgfscope
    \pgfpathcircle{\pgfpointorigin}{\pgf@circ@res@up}
    \pgfusepath{draw}       
  \endpgfscope  

  \pgfsetlinewidth{\pgfstartlinewidth}
  \pgftransformrotate{90} % rotate the label
  %\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{.8\pgf@circ@res@up}}
  %\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{.8\pgf@circ@res@down}}
  %\pgfusepath{draw}
  \pgfnode{circle}{center}{\textbf{V}}{}{}
  \pgfscope
    % \pgftransformshift{\pgfpoint{-\pgf@circ@res@other}{.8\pgf@circ@res@up}}
    % \pgftransformrotate{45}
    % \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
  \endpgfscope

  \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@zero}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@zero}}
  \pgfusepath{draw}

  \pgfusepath{stroke}   
}
\makeatother

\begin{document}
\begin{circuitikz}[american, scale = 2]
\draw 
(0,0)       to [sV = $V_m\cos(\omega t + \theta)$]  (0,2) 
            to [C = \SI{10}{\pico F}]               (2,2) 
            to [R = \SI{250}{\ohm}, *-*]            (2,0) 
(0,0)       to [L = \SI{300}{\micro H}]             (2,0) 
(2,2)       --                                      (4,2) 
            to [myvoltmeter]                        (4,0) 
            --                                      (2,0) 
(0,2)       to [short, *-o]                         (0,3) 
(2,2)       to [short, -o]                          (2,3)
(0,3) [yshift=5pt] to [open, v=$v(t)$]              (2,3) 
;
\end{circuitikz} 
\end{document}

相关内容