Circuitikz 내부의 스위치와 다른 스위치가 필요합니다. 이미 몇 개의 선으로 그렸지만 Circuitikz의 다른 표준 구성 요소처럼 사용하고 싶습니다. 저항과 같은 기존 구성 요소에 몇 줄을 추가하는 튜토리얼만 찾았지만 완전히 새로운 부품을 추가하는 방법을 모르겠습니다. 어쩌면 여러분 중 일부는 그렇게 할 수 있습니까?
다음은 제가 작업하는 최소한의 예입니다.
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[european]{circuitikz}
\begin{document}
\begin{circuitikz}
% Normally Open Switch
\draw[thick] (0,0) --++(0,0.5)--++(-0.4,1) coordinate (sw)
($(sw)+(0.4,0)$) --++(0,0.5);
% Normally Closed Switch
\draw[thick] (3,0) --++(0,0.5)--++(0.4,1) coordinate (sw)
($(sw)+(-0.4,-0.4)$) --++(0,0.9)
($(sw)+(-0.4,-0.4)$) --++(0.4,0);
\end{circuitikz}
\end{document}
결과:
나는 이것으로 동일한 결과를 얻고 싶습니다 :
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[european]{circuitikz}
\begin{document}
\begin{circuitikz}
% Normally Open Switch
\draw (0,0) to[nos] (0,2);
% Normally Closed Switch
\draw (3,0) to[ncs] (3,2);
\end{circuitikz}
\end{document}
감사합니다!
답변1
Offner와 Schliesser에 동일한 높이, 너비 및 깊이 매개변수를 사용했습니다.
\documentclass[border=5pt]{standalone}
%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
%\usepackage[ngerman]{babel}
\usepackage[european]{circuitikz}
\makeatletter
\ctikzset{bipoles/offner/height/.initial=.35}
\ctikzset{bipoles/offner/width/.initial=.5}
\ctikzset{bipoles/offner/depth/.initial=.1}
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/offner/depth}}{nos}{\ctikzvalof{bipoles/offner/height}}{\ctikzvalof{bipoles/offner/width}}{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
\pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfusepath{draw}
}
\def\nospath#1{\pgf@circ@bipole@path{nos}{#1}}
\compattikzset{nos/.style = {\circuitikzbasekey, /tikz/to path=\nospath, l=#1}}
\pgfcircdeclarebipole{}{\ctikzvalof{bipoles/offner/height}}{ncs}{\ctikzvalof{bipoles/offner/depth}}{\ctikzvalof{bipoles/offner/width}}{
\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
\pgfpathlineto{\pgfpoint{.9\pgf@circ@res@right}{\pgf@circ@res@down}}
\pgfusepath{draw}
\pgfsetlinewidth{\pgfstartlinewidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
\pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{0pt}}
\pgfpathlineto{\pgfpoint{.2\pgf@circ@res@right}{\pgf@circ@res@down}}
\pgfusepath{draw}
}
\def\ncspath#1{\pgf@circ@bipole@path{ncs}{#1}}
\compattikzset{ncs/.style = {\circuitikzbasekey, /tikz/to path=\ncspath, l=#1}}
\makeatother
\begin{document}
\begin{circuitikz}
% Normally Open Switch
\draw (0,0) to[nos] (0,2);
% Normally Closed Switch
\draw (3,0) to[ncs] (3,2);
\end{circuitikz}
\end{document}