22

I've tried to make a diagram which shows pi bonding through chemfig, but I was not successful. Here is what I want. pi bonding in google images1
(source: chem1.com)

or

pi bonding in google images2
(source: uwaterloo.ca)

Since I was unable to do it with chemfig I decided to do it with tikz. This is the best I could do:

\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}

my Diagram

The end result is quite satisfactory, but

  1. A shorter code would be nice
  2. I am not sure how to use node and label pi bond and sigma bond(usage of quoate box would also look good), and label the atoms as well
2
  • 4
    This reminds me of something I one did: writelatex.com/read/xmsxvkrcbvjw – cgnieder Oct 28 '13 at 15:57
  • You might want to add the standard settings to your tikzpicture environment: \begin{tikzpicture}[every shade/.append style={shading=ball}]. Maybe there is still a more efficient way to do it as you have e.g. two symmetry axes. – strpeter Jan 21 '14 at 8:26
3
+50

Answer to your first question

You can keep your code short by applying for-loops in tikz code, like e.g.:

\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};

Answer to your second question

It is possible to append at every point a node with some text like in the example above. The best advice that I can give you is to read the introducing examples in the manual or short introduction at CTAN or ask more details - there is a lot of stuff you might do with nodes...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.