我曾尝试通过 chemfig 制作一个显示 π 键的图表,但没有成功。这是我想要的。
(来源:chem1.com)
或者
(来源:uwaterloo.ca)
由于我无法使用 chemfig 来做到这一点,我决定使用 tikz 来做到这一点。这是我能做的最好的事情:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\shade[shading=ball, ball color=gray,draw,opacity=.7] (-2.5,0) .. controls (0,1) and (.5,0.5) .. (.5,0)
.. controls (.5,-.5) and (0,-1) .. (-2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (2.5,0) .. controls (.5,1) and (-.5,0.5) .. (-.5,0)
.. controls (-.5,-.5) and (.5,-1) .. (2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (-2.5,0) .. controls (-3.5,2.5) and (-3,3) .. (-2.5,3)
.. controls (-2,3) and (-1.5,2.5) .. (-2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (-2.5,0) .. controls (-3.5,-2.5) and (-3,-3) .. (-2.5,-3)
.. controls (-2,-3) and (-1.5,-2.5) .. (-2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (-2.5,0) .. controls (-4,0.5) and (-5,0.83) .. (-4.5,1.5)
.. controls (-4,2.17) and (-3.5,1.31) .. (-2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (-2.5,0) .. controls (-4,-0.5) and (-5,-0.83) .. (-4.5,-1.5)
.. controls (-4,-2.17) and (-3.5,-1.31) .. (-2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (2.5,0) .. controls (-3.5+5,2.5) and (-3+5,3) .. (2.5,3)
.. controls (-2+5,3) and (-1.5+5,2.5) .. (2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (2.5,0) .. controls (-3.5+5,-2.5) and (-3+5,-3) .. (2.5,-3)
.. controls (-2+5,-3) and (-1.5+5,-2.5) .. (2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (2.5,0) .. controls (4,0.5) and (5,0.83) .. (4.5,1.5)
.. controls (4,2.17) and (3.5,1.31) .. (2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (2.5,0) .. controls (4,-0.5) and (5,-0.83) .. (4.5,-1.5)
.. controls (4,-2.17) and (3.5,-1.31) .. (2.5,0);
\shade[shading=ball, ball color=blue,opacity=0.6] (4.5,1.5) circle (0.5);
\shade[shading=ball, ball color=blue,opacity=0.6] (4.5,-1.5) circle (.5);
\shade[shading=ball, ball color=blue,opacity=0.6] (-4.5,-1.5) circle (.5);
\shade[shading=ball, ball color=blue,opacity=0.6] (-4.5,1.5) circle (.5);
\end{tikzpicture}
\begin{tikzpicture}
\shade[shading=ball, ball color=gray,draw,opacity=.7] (-2.5,0) .. controls (0,1) and (.5,0.5) .. (.5,0)
.. controls (.5,-.5) and (0,-1) .. (-2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (2.5,0) .. controls (.5,1) and (-.5,0.5) .. (-.5,0)
.. controls (-.5,-.5) and (.5,-1) .. (2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (-2.5,0) .. controls (-4,0.5) and (-5,0.83) .. (-4.5,1.5)
.. controls (-4,2.17) and (-3.5,1.31) .. (-2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (-2.5,0) .. controls (-4,-0.5) and (-5,-0.83) .. (-4.5,-1.5)
.. controls (-4,-2.17) and (-3.5,-1.31) .. (-2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (2.5,0) .. controls (4,0.5) and (5,0.83) .. (4.5,1.5)
.. controls (4,2.17) and (3.5,1.31) .. (2.5,0);
\shade[shading=ball, ball color=gray,draw,opacity=.7] (2.5,0) .. controls (4,-0.5) and (5,-0.83) .. (4.5,-1.5)
.. controls (4,-2.17) and (3.5,-1.31) .. (2.5,0);
\shade[shading=ball, ball color=blue,opacity=0.6] (4.5,1.5) circle (0.5);
\shade[shading=ball, ball color=blue,opacity=0.6] (4.5,-1.5) circle (.5);
\shade[shading=ball, ball color=blue,opacity=0.6] (-4.5,-1.5) circle (.5);
\shade[shading=ball, ball color=blue,opacity=0.6] (-4.5,1.5) circle (.5);
\shade[shading=ball, ball color=black,draw,opacity=.7] (-2.5,0) .. controls (-3.5,2.5) and (-3,3) .. (-2.5,3)
.. controls (0,2) .. (2.5,3)
.. controls (3,3) and (3.5,2.5) .. (2.5,0)
.. controls (1.5,1) .. (0,1)
.. controls (-2,1) .. (-2.5,0);
\shade[shading=ball, ball color=black,draw,opacity=.7] (-2.5,0) .. controls (-3.5,-2.5) and (-3,-3) .. (-2.5,-3)
.. controls (0,-2) .. (2.5,-3)
.. controls (3,-3) and (3.5,-2.5) .. (2.5,-0)
.. controls (1.5,-1) .. (0,-1)
.. controls (-2,-1) .. (-2.5,-0);
\end{tikzpicture}
\end{document}
最终结果还是比较令人满意的,但是
- 代码更短一点就好了
- 我不确定如何使用节点并标记 pi 键和 sigma 键(使用 quotate 框看起来也不错),以及如何标记原子
答案1
回答你的第一个问题
你可以在 tikz 代码中应用 for 循环来使代码保持简短,例如:
\foreach \i in {-4.5,4.5}
\foreach \j in {-1.5,1.5}
\shade[ball color=blue,opacity=0.6] (\i,\j) circle (.5) node{H};
回答你的第二个问题
可以像上例一样在每个节点上附加一些文本。我能给你的最好建议是阅读手册中的介绍示例或简短介绍加拿大运输安全局或者询问更多细节 - 您可以用节点做很多事情......