向开关添加箭头

向开关添加箭头

我想在打开和关闭开关上添加箭头。最简单的方法是什么?

\documentclass{article}
\usepackage[free-standing-units]{siunitx}
\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}[scale=1.5]
\draw (0,0) to [short] (0,2)
to[short,-o](0.75,2);
\draw[ very thick](0.78,2)-- +(30:0.46);
\draw (1.25,2)to[short,o-](2,2)
to [short](2,0)
to [short,-o](1.25,0);
\draw [very thick] (1.22,0)--(0.77,0);
\draw (0.75,0)to [short,o-](0,0);
\end{circuitikz}
\end{document}

开关

带箭头的开关

答案1

在 TikZ 方式上:

\documentclass{article}
\usepackage[free-standing-units]{siunitx}
\usepackage{circuitikz}
\usetikzlibrary[arrows.meta,backgrounds]

    \begin{document}
\begin{circuitikz}[scale=1.5,
    > = {Circle[length=1.6mm,fill=white]}
                    ]
\draw[->,shorten >=-0.8mm]  (0.00,0) |-   (0.75,2);
\draw[<->]                  (1.25,2) -|   (2,0) -- (1.25,0);
\draw[<-,shorten <=-0.8mm]  (0.75,0) --   (0,0);(0.75,0) --   (0,0);
%
\scoped[on background layer]
    \draw[very thick]   (0.75,2) -- + ( 30:0.5)
                        (1.25,0) -- + (180:0.5);
\draw[-{Straight Barb[]}]% arrows of switch   
    (0.75,2) + (+45:0.25) arc (45:-45:2.5mm);
\draw[-{Straight Barb[]}]% arrows of switch 
    (0.75,0) + (-45:0.25) arc (-45:45:2.5mm);

\end{circuitikz}
    \end{document}

在此处输入图片描述

补充:对于三角形箭头,您可以从提供arrows.meta库的众多选项中选择一个。借助库,bending您可以向箭头添加选项flex,以更好地确定箭头的方向:

\documentclass{article}
    \usepackage[free-standing-units]{siunitx}
    \usepackage{circuitikz}
\usetikzlibrary[arrows.meta,backgrounds,bending]

    \begin{document}
\begin{circuitikz}[
    > = {Circle[length=1.6mm,fill=white]}
                    ]
\draw[->,shorten >=-0.8mm]  (0.00,0) |-   (0.75,2);
\draw[<->]                  (1.25,2) -|   (2,0) -- (1.25,0);
\draw[<-,shorten <=-0.8mm]  (0.75,0) --   (0,0);
%
\scoped[on background layer]
    \draw[very thick]   (0.75,2) -- + ( 30:0.5)
                        (1.25,0) -- + (180:0.5);
\draw[-{Triangle[angle=60:3pt,flex]}]
    (0.75,2) + (+60:0.3) arc (60:-45:3mm);
\draw[-{Triangle[angle=60:3pt,flex]}]
    (0.75,0) + (-45:0.3) arc (-45:45:3mm);
\end{circuitikz}
    \end{document}

以上代码生成以下图片:

在此处输入图片描述

相关内容