4

I'm relatively new to Circuitikz and I was wondering if it is possible to change the arrow head of the switches. As you can see below, it gets deformed if you zoom it or if you use a thicker line. What would be a better switch? Should I create my own using Tikz or is there an easy way to change the head of this switch? enter image description here

2
  • 1
    Please show us the code you used to create the given image ... Welcome to TeX.SE!
    – Mensch
    Jan 6, 2017 at 0:36
  • It is not that difficult to copy and modify the source code. Jan 6, 2017 at 5:50

1 Answer 1

3

I made two changes. First, you can now set the arrowhead using \ctikzset{bipoles/interr/arrowhead=...}. Second, I modified the linear extension to which the arrowhead was attached so that the line wouldn't show.

\documentclass{standalone}
\usepackage{circuitikz}

%% SPST
\ctikzset{bipoles/interr/arrowhead/.initial=latex'}

\makeatletter
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/interr/height 2}}{spst}{\ctikzvalof{bipoles/interr/height}}{\ctikzvalof{bipoles/interr/width}}{

            \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}

            \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
            \pgfpathlineto{\pgfpoint{.6\pgf@circ@res@right}{\pgf@circ@res@up}}
            \pgfpathmoveto{\pgfpoint{.9\pgf@circ@res@left}{.9\pgf@circ@res@up}}
            \pgfpatharc{65}{25}{\pgfkeysvalueof{/tikz/circuitikz/bipoles/interr/width}\pgf@circ@Rlen}
            \pgfpathlineto{\pgfpoint{.21\pgf@circ@res@right}{-.35\pgf@circ@res@up}}
            \pgfsetarrowsend{\ctikzvalof{bipoles/interr/arrowhead}}
      \pgfusepath{draw}
}
\makeatother

\begin{document}
\begin{circuitikz}
  \draw (0,0) to[spst] (1,0);
\end{circuitikz}

\end{document}

demo

You must log in to answer this question.

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