我希望能够将联系人的标签放在上面或下面,以避免叠加
\documentclass[border=7pt,10pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC,positioning,chains,calc,fit}
\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (0,-1)coordinate(a0) to [make contact={info=$a_i$,name=ai}]+ (2,0) to [break contact={info=$b_i$,yscale=-1}] +(4,0)coordinate(ab);
\draw (0,-2.5) --+(2,0) to [make contact={info=$b_i$}] +(4,0) to [break contact={info=$c_i$,yscale=-1}] +(6,0) coordinate(vv)to [bulb={info=V}] +(8,0);
\draw (0,-4)coordinate(a2) to [break contact={info=$a_i$,yscale=-1,name=Nai}]+(2,0) --+ (4,0) to [make contact={info=$c_i$}] +(6,0)--(vv);
\draw[dashed] (ai) -- (Nai);
\draw (0,-0.5)node[above]{$0V$} -- (0,-4.5) ;
\draw (8,-0.5)node[above]{$12 V$} -- (8,-4.5) ;
\draw (ab)-|(vv);
\end{tikzpicture}
\end{document}
答案1
请参阅“TikZ \&PGF 版本 3.0.1a 手册”,第 553 页。根据那里的解释:
/tikz/info=[<options>]<angle>:<text>
例如你可以写:
[break contact={info=below:$c_2$,yscale=-1}]
您的电路解决方案的一个示例是(使用包后代码略微简化和改进siunitx
):
\documentclass[border=7pt,10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (0, 0) to [make contact={info=$a_1$,name=ai}] ++ (2,0)
to [break contact={info=below:$b_1$,yscale=-1}] ++(2,0) % <---
-- ++ (2,0) coordinate(ab);
\draw (0,-2) -- ++ (2,0)
to [make contact={info=$b_2$}] ++(2,0)
to [break contact={info=below:$c_2$,yscale=-1}] ++(2,0) % <---
to [bulb={info=V}] ++ (2,0);
\draw (0,-4) to [break contact={info=$a_3$,yscale=-1,name=Nai}] ++ (2,0)
-- ++ (2,0)
to [make contact={info=$c_3$}] ++ (2,0)
-- (ab);
\draw[dashed] (ai) -- (Nai);
\draw (0,0.5) node[above] {\SI{ 0}{V}} -- (0,-4.5) ;
\draw (8,0.5) node[above] {\SI{12}{V}} -- (8,-4.5) ;
\end{tikzpicture}
\end{document}
这使
编辑: 使用以下较短的符号可以得到相同的结果:
info'=<text>
即使用以下图像代码:
\begin{tikzpicture}[circuit ee IEC]
\draw (0, 0) to [make contact={info=$a_1$,name=ai}] ++ (2,0)
to [break contact={info'=$b_1$,yscale=-1}] ++(2,0) % <---
-- ++ (2,0) coordinate(ab);
\draw (0,-2) -- ++ (2,0)
to [make contact={info=$b_2$}] ++(2,0)
to [break contact={info'=$c_2$,yscale=-1}] ++(2,0) % <---
to [bulb={info=V}] ++ (2,0);
\draw (0,-4) to [break contact={info=$a_3$,yscale=-1,name=Nai}] ++ (2,0)
-- ++ (2,0)
to [make contact={info=$c_3$}] ++ (2,0)
-- (ab);
\draw[dashed] (ai) -- (Nai);
\draw (0,0.5) node[above] {\SI{ 0}{V}} -- (0,-4.5) ;
\draw (8,0.5) node[above] {\SI{12}{V}} -- (8,-4.5) ;
\end{tikzpicture}