我可以改变几乎所有组件的颜色CircuiTikZ使用此处解释的方法:Circuitikz 线和组件颜色
以下示例显示了我的电解电容器存在的问题,因为加号和填充保持黑色:
\documentclass[border=3mm]{standalone}
\usepackage[siunitx,european]{circuitikz}
\begin{document}
\begin{circuitikz}
\draw (0,2) to [diode] (0,0);
\draw[blue] (1,2) to [diode, color=blue] (1,0);
\draw (3,2) to [elko] (3,0);
\draw[blue] (4,2) to [elko, color=blue] (4,0);
\end{circuitikz}
\end{document}
我添加了一个二极管的示例,其中着色正常工作以使问题更加清晰。
答案1
不幸的是,你不能。很多地方都硬编码了“黑色”。这可能是一个错误,我应该用基本颜色来更改它...我会研究一下。
同时我可以给你一个技巧,重新定义一个更好的 elko:
\documentclass[border=3mm]{standalone}
\usepackage[siunitx,european]{circuitikz}
\makeatletter
%% Electrolytic Capacitor
\pgfcircdeclarebipolescaled{capacitors}
{}
{\ctikzvalof{bipoles/ecapacitor/height}}
{ecapacitor}
{\ctikzvalof{bipoles/ecapacitor/height}}
{\ctikzvalof{bipoles/ecapacitor/width}}
{
\pgfsetrectcap
% % % Draw plus pole
\pgf@circ@setlinewidth{bipoles}{\pgfstartlinewidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{.4\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgf@circ@draworfill
% % Draw minus pole
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{.4\pgf@circ@res@right}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfsetfillcolor{\ctikzvalof{color}}
\pgfusepath{draw,fill}
\pgfsetcolor{\ctikzvalof{color}}
% % plus pole annotation
\pgftext[right,at=\pgfpoint{1.2\pgf@circ@res@left}{.6\pgf@circ@res@up}]
{\ctikzvalof{bipoles/ecapacitor/font} $+$}
}
\makeatother
\begin{document}
\begin{circuitikz}
\draw (0,2) to [diode] (0,0);
\draw[blue] (1,2) to [diode, color=blue] (1,0);
\draw (3,2) to [elko] (3,0);
\draw[color=blue] (4,2) to [elko, color=blue] (4,0);
\end{circuitikz}
\end{document}
PD 在很多地方它都不是硬编码的......我会修好它。
或者,
\documentclass[border=3mm]{standalone}
\usepackage[siunitx,european]{circuitikz}
\tikzset{ccolor/.code=\colorlet{black}{#1}}
\begin{document}
\begin{circuitikz}
\draw (0,2) to [diode] (0,0);
\draw (1,2) to [diode, ccolor=blue] (1,0);
\draw (3,2) to [elko] (3,0);
\draw (4,2) to [elko, ccolor=blue] (4,0);
\end{circuitikz}
\end{document}