# Easy way to draw atomic orbitals and integrate them into ChemFig structures

I'm looking for a method to draw molecules as skeleton structures via chemfig and include some atomic orbitals (i.e. s, p and d orbitals and some sp-hybrid orbitals too) into them (at positions where chemfig places atomlabels, i.e. at the ends of bonds). I give you an example:

The shapes needed for the different orbitals essentially boil down to the following

The right appearence would then be achieved by rotating and scaling these orbitals. This should ideally work with a simple command which tells chemfig to insert an orbital of a certain type (i.e. s, p, d, ...) at an atomic position and how this orbital shall be rotated, scaled or colored and which phase it should have. Is this doable? Or is there a package out there which provides such a functionality?

-

The chemmacros package offers s,p and sp-hybrid orbitals (based on TikZ), d orbitals are missing (for now). These are examples from the documentation:

\documentclass{article}
\usepackage{chemfig,chemmacros}

\begin{document}

\setbondoffset{0pt}
\chemsetup[orbital]{
overlay ,
opacity = .75 ,
p/scale = 1.6 ,
s/color = blue!50 ,
s/scale = 1.6
}
\chemfig{\orbital{s}-[:-20]{\orbital[scale=2]{p}}{\orbital[half,angle=0]{p}}{\orbital[angle=170,half]{p}}{\orbital[angle=-150,half]{p}}(-[:-150]\orbital{s})-\orbital{s}}

\end{document}


\documentclass{article}
\usepackage{chemfig,chemmacros}

\begin{document}

\chemsetup[orbital]{
overlay,
p/color = black!70
}
\setbondoffset{0pt}
\chemfig{?\orbital{p}-[,1.3]{\orbital[phase=-]{p}}-[:30,1.1]\orbital{p}-[:150,.9]{\orbital[phase=-]{p}}-[4,1.3]\orbital{p}-[:-150,1.1]{\orbital[phase=-]{p}}?}

\end{document}


-
 Thank you. That's an awesome package. That mostly solves my problem. There is only one tiny drawback: it includes s, p and sp-hybrid orbitals but no d orbitals. Is there also a solution for that? Or could you include them in a future version of chemmacros? – Philipp Jun 21 '12 at 15:46 @Philipp I have that on my TODO list for a while now. Maybe I can put it a bit higher on my list, though. – cgnieder Jun 21 '12 at 15:48 Sorry, I seem to have skipped the sentence where you alread wrote that there are no d orbitals included in the package. I guess I got distracted by the stunning pictures ;) It's nice to hear that it is already on your TODO list. Until then I will try to get by with ChemDraw when I have to draw something with d orbitals. – Philipp Jun 21 '12 at 15:54 The only real problem is the d$_z$ orbital. The others could be modelled by using 4 times \orbital[half]{p} with appropriate angles and colors... – cgnieder Jun 21 '12 at 16:38 I guess it is the torus contained in the $\mathrm{d}_{z^2}$ orbital which makes things complicated. Would it make things easier to build the orbital from two half p orbitals sandwiching an ellipse between them (like in the pictures contained in my question) or can't this be handled properly when it comes to rotation, scaling etc.? – Philipp Jun 22 '12 at 11:29