我目前正在制作我的第一个circuittikz
图形,遇到了一些问题。我想将内置的电流箭头变成彩色(红色)。有谁知道这是否可行?
\begin{circuitikz} \draw
% bottom line
(0,0) to [short,o-o] (11,0)
% shunt branches
(2,0) to [C, *-*,l=$C/2$,v=$V_C$] (2,3)
(9,0) to [C, *-*,l=$C/2$] (9,3)
% top line
(0,3) to [short,o-] (3,3)
to [R, l_=$R$,i=$I_1$] (5,3)
(5,3) -- (6,3)
to [L, l_=$L$] (8,3)
to [short,-o] (11,3)
% Input and output labels
(0,1.5) node[] {$V_s$}
(11,1.5) node[] {$V_r$}
;\end{circuitikz}
顺便问一下,有人知道是否可以将电压极性标记(包括标签)移离第一个电容器吗?
答案1
目前,箭头颜色设置为与其他颜色相同。但可以随时重新定义和添加内容。
\documentclass{standalone}
\usepackage{circuitikz}
\makeatletter
\ctikzset{current arrow color/.initial=black}% create key
\pgfdeclareshape{currarrow}{
\anchor{center}{
\pgfpointorigin
}
\anchor{tip}{
\pgfpointorigin
\pgf@circ@res@step = \pgf@circ@Rlen
\divide \pgf@circ@res@step by 16
\pgf@x =\pgf@circ@res@step
}
\behindforegroundpath{
\pgfscope
\pgf@circ@res@step = \pgf@circ@Rlen
\divide \pgf@circ@res@step by 16
\pgfpathmoveto{\pgfpoint{-.7\pgf@circ@res@step}{0pt}}
\pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{-.8\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{1\pgf@circ@res@step}{0pt}}
\pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{.8\pgf@circ@res@step}}
\pgfpathlineto{\pgfpoint{-.7\pgf@circ@res@step}{0pt}}
\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/current arrow color}}
\pgfusepath{draw,fill}
\endpgfscope
}
}
\makeatother
\begin{document}
\ctikzset{voltage/distance from node=.8}
\begin{circuitikz}[american]
\draw[circuitikz/current arrow color=red]
% bottom line
(0,0) to [short,o-o] (11,0)
% shunt branches
(2,0) to [C, *-*,l={$C/2$},v=$V_C$] (2,3)
(9,0) to [C, *-*,l=$C/2$,n=C2] (9,3)
% top line
(0,3) to [short,o-] (3,3)
to [R, l_=$R$,i=$I_1$] (5,3)
(5,3) -- (6,3)
to [L, l_=$L$] (8,3)
to [short,-o] (11,3)
% Input and output labels
(C2.s) node[right] {$V_s$};% anchors rotated
\draw[<->,red] (11,0.2) -- (11,2.8) node[midway,fill=white,text=black] {$V_r$};
\end{circuitikz}
\end{document}