circuitikz - 如何仅改变双极子的颜色

circuitikz - 如何仅改变双极子的颜色

我想单独改变双极子的颜色(如果可能的话,也改变线的颜色)。标签和当前箭头应该保持黑色。有没有可能实现这一点?在下面的 MWE 中,当前箭头仍然是红色的,这是不想要的。

\documentclass{standalone}
\usepackage{tikz}
\usepackage[european,cuteinductors,fetbodydiode,straightvoltages]{circuitikz}

\begin{document}
    \begin{tikzpicture}[scale=0.6, arrowmos]
        \draw [color=red] (0,0) to[R,R=\textcolor{black}{$R_1$}, i_=\textcolor{black}{$i_1$}, bipole current append style={color=black}] (4,0);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

例如,您可以抑制当前符号的输出,然后手动添加它。

\documentclass{standalone}
\usepackage{tikz}
\usepackage[european,cuteinductors,fetbodydiode,straightvoltages]{circuitikz}

\begin{document}
    \begin{tikzpicture}[scale=0.6, arrowmos]
        \draw [color=red] (0,0) to[R,l=\textcolor{black}{$R_1$},
           i_=\textcolor{black}{$i_1$}, no i symbols, name=blah] (4,0);
        \node[currarrow] at (blah-Ipos) {};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

在这种情况下,不需要添加旋转,但如果需要,手册第 207 页有一个示例(请注意第将要随手册的不同版本而变化):

在此处输入图片描述

例如:

\documentclass{standalone}
\usepackage{tikz}
\usepackage[european,cuteinductors,fetbodydiode,straightvoltages]{circuitikz}

\begin{document}
    \begin{tikzpicture}[scale=0.6, arrowmos]
        \draw [color=red] (0,0) to[R,l=\textcolor{black}{$R_1$},
           i_=\textcolor{black}{$i_1$}, no i symbols, name=blah] (4,0) 
           to[R,l=\textcolor{black}{$R_2$},
           i_=\textcolor{black}{$i_2$}, no i symbols, name=blah2] (7,3);
        \node[currarrow] at (blah-Ipos) {};
        \node[currarrow, rotate=\ctikzgetdirection{blah2-Iarrow}] at (blah2-Ipos) {};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

但是,如果您经常使用它,那么像手册示例中的宏可能会更好:

\documentclass{standalone}
\usepackage{tikz}
\usepackage[european,cuteinductors,fetbodydiode,straightvoltages]{circuitikz}
%%% "fc" mnemonics: fixed color
\newcommand\textfc[1]{\textcolor{black}{#1}}
\newcommand\fcI[1]{\node[currarrow,
    rotate=\ctikzgetdirection{#1-Iarrow}] at (#1-Ipos) {}}

\begin{document}
    \begin{tikzpicture}[scale=0.6, arrowmos]
        \draw [color=red] (0,0) to[R=\textfc{$R_1$},
           i_=\textfc{$i_1$}, no i symbols, name=blah] (4,0) 
           to[R,l=\textfc{$R_2$},
           i_=\textfc{$i_2$}, no i symbols, name=blah2] (7,3);
        \fcI{blah};
        \fcI{blah2};
    \end{tikzpicture}
\end{document}

...另外还有额外好处,如果您决定使用蓝色的文本,您只需在一个地方更改它即可。

相关内容