答案1
鈦kZ解:
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\node[align=center,fill=black,circle] (o) at (0,0) {\color{yellow}P:10\\\color{blue!50}N:10};
\draw (0,0) circle (1.25cm) circle (2cm);
\path[fill=red,draw=black] (90:1.25) circle (1.5mm);
\path[fill=red,draw=black] (-90:1.25) circle (1.5mm);
\path[fill=red,draw=black] (85:2) circle (1.5mm);
\path[fill=red,draw=black] (95:2) circle (1.5mm);
\path[fill=red,draw=black] (-85:2) circle (1.5mm);
\path[fill=red,draw=black] (-95:2) circle (1.5mm);
\path[fill=red,draw=black] (5:2) circle (1.5mm);
\path[fill=red,draw=black] (-5:2) circle (1.5mm);
\path[fill=red,draw=black] (175:2) circle (1.5mm);
\path[fill=red,draw=black] (-175:2) circle (1.5mm);
\end{tikzpicture}
\end{document}
編輯1
我們只需要定義一個新指令。我可以使用\newcommand
,但我更喜歡\def
因為我可以以 Ti 的形式使用該命令kZ命令:
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}
\def\pairelec[fill=#1,draw=#2,radius=#3] (#4:#5); {
\path[fill=#1,draw=#2] ({#4-5}:#5) circle (#3);
\path[fill=#1,draw=#2] ({#4+5}:#5) circle (#3);
}
\node[align=center,fill=black,circle] (o) at (0,0) {\color{yellow}P:10\\\color{blue!50}N:10};
\draw (0,0) circle (1.25cm) circle (2cm);
\path[fill=red,draw=black] (90:1.25) circle (1.5mm);
\path[fill=red,draw=black] (-90:1.25) circle (1.5mm);
\pairelec[fill=red,draw=black,radius=1.5mm] (0:2);
% Remember fill -> draw -> radius - you must have all three options!
\pairelec[fill=green,draw=blue,radius=1.5mm] (180:2);
\pairelec[fill=white,draw=red,radius=1.5mm] (90:2);
\pairelec[fill=yellow,draw=blue,radius=1.5mm] (-90:2);
\end{tikzpicture}
\end{document}
您可以選擇fill
顏色以及draw
顏色和半徑。
編輯2
代碼為真實的電子對:
\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\def\pairelec[fill=#1,draw=#2,radius=#3] (#4:#5); {
\path[name path=cir] (0,0) circle (#5cm);
\path[name path=smallcir] (#4:#5) circle (#3);
\path[name intersections={of=cir and smallcir},fill=#1,draw=#2] (intersection-1) circle (#3) (intersection-2) circle (#3);
}
\node[align=center,fill=black,circle] (o) at (0,0) {\color{yellow}P:10\\\color{blue!50}N:10};
\draw (0,0) circle (1.25cm) circle (2cm);
\path[fill=red,draw=black] (90:1.25) circle (1.5mm);
\path[fill=red,draw=black] (-90:1.25) circle (1.5mm);
\pairelec[fill=red,draw=black,radius=1.5mm] (-8:2);
% Remember fill -> draw -> radius - you must have all three options!
\pairelec[fill=green,draw=blue,radius=3mm] (150:2.5);
\pairelec[fill=white,draw=red,radius=1mm] (78:3);
\pairelec[fill=yellow,draw=blue,radius=1.5mm] (-111:3.5);
\end{tikzpicture}
\end{document}
您可能會看到電子脫離了軌道。這僅用於測試目的!