Circuitikz – How to Add Adjustable or Variable Indication Arrow to Component

circuitikz

I'm trying to create an RF block diagram using circuitikz and was wondering what the best way of adding an arrow to indicate that it has an adjustable/variable parameter would be.

E.g. turn this

\node[oscillator, label=LO]{};

enter image description here

into this

\node[v_oscillator, label=LO]{};

enter image description here

Can I somehow create a new component, e.g. some "v_oscillator" that already has this arrow? Or is there some alternative way that is simpler?

Best Answer

In theory, you should be able to use the "generic tunable arrow" --- in practice, there is a small bugglitch when the element has the center anchor on a side (happens in several components, for easiness of positioning). So you have to patch the thing (I'll fix it in the next release, 1.5.0).

\documentclass[12pt,]{article}
\usepackage[T1]{fontenc}
\usepackage[siunitx, RPvoltages]{circuitikz}
\makeatletter
\def\ctikztunablearrow{\pgfutil@ifnextchar[{\ctikztunablearrow@full}{\ctikztunablearrow@simple}}%
\def\ctikztunablearrow@simple{\ctikztunablearrow@full[]}%
\def\ctikztunablearrow@full[#1]#2#3#4#5{%
    % add tunable arrow to a component
    % relative thickness, relative length, rotation from axis, name of the component
    \scope
    \draw
    \pgfextra{\pgfcirc@set@arrows{tunable}{}{latexslim}
    \pgfsetlinewidth{#2\pgflinewidth}} [#1]
        let \p1=($(#5.north east)-(#5.south west)$), \p2=($(#5.east)-(#5.west)$),
        \n1 = {veclen(\x1,\y1)},
        \n2 = {atan2(\y2,\x2)} in
        % node[above]{\n1, \n2}
        ($(#5.west)!0.5!(#5.east)$) ++({\n2+(#4)}:{-0.5*(\n1)*(#3)}) -- ++({\n2+(#4)}:{(\n1)*(#3)});
    \endscope
}
\makeatother

\begin{document}
\begin{tikzpicture}
    \node [oscillator](M) at(0,0){};
    \ctikztunablearrow[color=blue, densely dashed]{1}{1.2}{45}{M}
\end{tikzpicture}
\end{document}

enter image description here