4

I'm currently working on my first circuittikz figure, and I've run into some problems. I would like to make the built in current arrows colored (red). Is there anyone who knows if this is possible?

Below is the figure I'm working on: enter image description here And the code:

\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}

By the way, does anyone know if it is possible to move the voltage polarity marks including label, further away from the first capacitor?

1

1 Answer 1

6

Currently the current arrow color is set to the same color as everything else. But one can always redefine and add things.

\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}

demo

3
  • Hi John Thanks a lot for your reply! Just what i was looking for! You wouldn't happen to know if it is possible to move the polarity marks (+ and -) and voltage description (V_C) further away from the components when using american voltages? It is shown in the figure I've uploaded, for the left capacitor.
    – Holmen
    Feb 15, 2016 at 9:20
  • \ctikzset{voltage/distance from node=0.5} (default). 0 is as far as possible. 1 is right on the component. Feb 15, 2016 at 14:51
  • Due to changes in circuitikz, I revised the solution. Oct 18, 2017 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .