Circuitikz - define arrow position of variable capacitor

Why not reading the manual and make use of the mirror/invert options?

to[vC=$C_1$,invert, o-]

or

to[vC=$C_1$,mirror, o-]

or a combination of both should do the trick.

Example:

 \begin{circuitikz} % Begin add-on environment
  \draw (0,0) to[vC=$C_1$] ++(2,0)
    to[vC=$C_1$,invert] ++(2,0)
    to[vC=$C_1$,mirror] ++(2,0)
    to[vC=$C_1$,mirror,invert] ++(2,0);
 \end{circuitikz}

enter image description here

Best regards,

Stefan


If you're always going to want the given shape with arrows from left to right, you could simply redefine the shape associated with the variable capacitor using

\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vcapacitor/height}}{vcapacitor}{\ctikzvalof{bipoles/vcapacitor/height}}{\ctikzvalof{bipoles/vcapacitor/width}}{
        %\pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/width}\pgf@circ@Rlen
        \pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/capacitor width} \pgf@circ@res@right

        \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@down}}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}
        \pgfusepath{draw}

        \pgfscope
        \pgfsetarrowsend{latex'}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfusepath{draw}
        \endpgfscope

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{0pt}}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
        \pgfsetlinewidth{\pgfstartlinewidth}
        \pgfusepath{draw}
}

which is simply the definition from the circuitikz v0.8.1 with the lines

\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}

used instead of

\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}

to say draw from bottom left to top right instead of bottom right to top left.

Or you could define a new key Cv as (I've just followed the chain of commands that seem to be called by vC here and copied them to make a Cv variant which ends up calling the same definition with the same left/right swap as above) to use both Cv and vC

\compattikzset{Cv/.style = {\comnpatname capacitor variable = #1}}
\compattikzset{capacitor variable/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@capacitorv@path, l=#1}}
\def\pgf@circ@capacitorv@path#1{\pgf@circ@bipole@path{capacitorv}{#1}}
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vcapacitor/height}}{capacitorv}{\ctikzvalof{bipoles/vcapacitor/height}}{\ctikzvalof{bipoles/vcapacitor/width}}{
        %\pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/width}\pgf@circ@Rlen
        \pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/capacitor width} \pgf@circ@res@right

        \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@down}}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}
        \pgfusepath{draw}

        \pgfscope
        \pgfsetarrowsend{latex'}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfusepath{draw}
        \endpgfscope

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{0pt}}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
        \pgfsetlinewidth{\pgfstartlinewidth}
        \pgfusepath{draw}
}

Collecting this together in a single example

\documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}

\makeatletter%Create new circuitikz key Cv for variable capacitor with arrow in other direction
\compattikzset{Cv/.style = {\comnpatname capacitor variable = #1}}
\compattikzset{capacitor variable/.style = {\circuitikzbasekey, /tikz/to path=\pgf@circ@capacitorv@path, l=#1}}
\def\pgf@circ@capacitorv@path#1{\pgf@circ@bipole@path{capacitorv}{#1}}
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vcapacitor/height}}{capacitorv}{\ctikzvalof{bipoles/vcapacitor/height}}{\ctikzvalof{bipoles/vcapacitor/width}}{
        %\pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/width}\pgf@circ@Rlen
        \pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/capacitor width} \pgf@circ@res@right

        \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@down}}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}
        \pgfusepath{draw}

        \pgfscope
        \pgfsetarrowsend{latex'}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfusepath{draw}
        \endpgfscope

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{0pt}}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
        \pgfsetlinewidth{\pgfstartlinewidth}
        \pgfusepath{draw}
}
\makeatother

\begin{document}
\begin{center}
\texttt{vC} with default definition

\begin{circuitikz}
    \draw (2,0) to[vC=$C_1$, o-] (0,0);
\end{circuitikz}

New \texttt{Cv} key

\begin{circuitikz}
    \draw (2,0) to[Cv=$C_1$, o-] (0,0);
\end{circuitikz}

\makeatletter%Redefine arrow direction used by vC
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/vcapacitor/height}}{vcapacitor}{\ctikzvalof{bipoles/vcapacitor/height}}{\ctikzvalof{bipoles/vcapacitor/width}}{
        %\pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/width}\pgf@circ@Rlen
        \pgf@circ@res@step = \ctikzvalof{bipoles/vcapacitor/capacitor width} \pgf@circ@res@right

        \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
        \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{\pgf@circ@res@down}}

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}
        \pgfusepath{draw}

        \pgfscope
        \pgfsetarrowsend{latex'}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
        \pgfusepath{draw}
        \endpgfscope

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
        \pgfpathlineto{\pgfpoint{-\pgf@circ@res@step}{0pt}}
        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
        \pgfsetlinewidth{\pgfstartlinewidth}
        \pgfusepath{draw}
}
\makeatother

\texttt{vC} with arrow direction redefined

\begin{circuitikz}
    \draw (2,0) to[vC=$C_1$, o-] (0,0);
\end{circuitikz}
\end{center}
\end{document}

enter image description here

Tags:

Circuitikz