# Drawing atomic orbitals upon a chemfig structure

Is there a way to draw an atomic orbital in a chemfig structure? I think you can better understand if you see want I want to get:

Here is what I've already done. Any improvement would be appreciated.

\documentclass[a4paper,12pt,twoside,openright,titlepage]{book}
\usepackage{chemfig,chemmacros,chemnum,modiagram}
\usepackage[version=3]{mhchem}
\makeatletter
\def\CF@node@content{%
\expandafter\expandafter\expandafter
\printatom\expandafter\expandafter\expandafter
{\csname atom@\number\CF@cnt@atomnumber\endcsname}%
\ensuremath{\CF@node@strut}%
}
\makeatother
\chemsetup[chemformula]{format=\sffamily}
%\renewcommand*\printatom[1]{\ensuremath{\mathsf{#1}}}
\renewcommand*{\printatom}[1]{{\sffamily\cf{#1}}}
\setdoublesep{0.32500 em}  % 'Bond Spacing'
\setatomsep{1.78500 em}    % 'Fixed Length'
\setbondoffset{0.18265 em} % 'Margin Width'
\newcommand{\bondwidth}{0.06642 em} % 'Line Width'
\setbondstyle{line width = \bondwidth}

\begin{document}
\schemestart
\setbondoffset{0pt}
\chemsetup[orbital]{
overlay ,
opacity = 0.5 ,
p/scale = 1.25 ,
s/color = gray!50 ,
s/scale = 1.25
}
\chemfig{*6(-=(-(-[,.2,,,draw=none]\Lewis{0.,}\orbital{s}))-=(-[,.4,,,draw=none]\Lewis{0.,}{\orbital[half,angle=90]{p}})-=-)}
\arrow
\setbondoffset{0pt}
\chemsetup[orbital]{
overlay ,
opacity = 0.5 ,
p/scale = 1.25 ,
s/color = gray!50 ,
s/scale = 1.25
}
\chemfig{[:-60]*6(-=-(=)-(-[,.0,,,draw=none]\Lewis{0.,}\orbital{s})-(-[,.4,,,draw=none]\Lewis{0.,}{\orbital[half,angle=90]{p}})=)}
\arrow
\setbondoffset{0pt}
\chemsetup[orbital]{
overlay ,
opacity = 0.5 ,
p/scale = 1.25 ,
s/color = gray!50 ,
s/scale = 1.25
}
\chemfig{*6(-=(-\orbital{s})-=-=)}
\schemestop

\end{document}

• Dec 8 '13 at 23:12
• Yes, sure. I already knew chemmacros. But what you get using chemmacrosis a 3d image of the orbital, I wanted to draw a scheme similar to that of the image. Moreover, I didn't find anywhere how insert the electron (the dots) in the orbital. Dec 9 '13 at 11:19
• chemmacros' orbitals are tikzpictures internally. You can use the same procedure: define macros that draw the orbitals in the way you want them and then place those macros in place of the atoms like in the post I linked Dec 9 '13 at 11:26

## 1 Answer

Final result, quite satisfactory:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[english,italian]{babel}
\usepackage{graphicx}
\usepackage{chemfig,chemmacros,modiagram}
\usepackage[version=3]{mhchem}
\makeatletter
\def\CF@node@content{%
\expandafter\expandafter\expandafter
\printatom\expandafter\expandafter\expandafter
{\csname atom@\number\CF@cnt@atomnumber\endcsname}%
\ensuremath{\CF@node@strut}%
}
\makeatother
\chemsetup[chemformula]{format=\sffamily}
\renewcommand*{\printatom}[1]{{\sffamily\cf{#1}}}
\setdoublesep{0.32500 em}
\setatomsep{1.78500 em}
\setbondoffset{0.18265 em}
\newcommand{\bondwidth}{0.06642 em}
\setbondstyle{line width = \bondwidth}

\begin{document}
\begin{figure}\centerline{
\schemestart
\chemsetup[orbital]{
overlay,
opacity=.4,
p/scale=1.5,
p/half,
s/scale=1.3
}
\chemname{\chemfig[][scale=0.75]{*6(-=(-(-[,.2,,,draw=none]\Lewis{0.,}\orbital{s}))-=(-[-2,0.001,,,draw=none]{{\orbital{p}}})(-[2,.4,,,draw=none]\lewis{2.,})-=)}}{{\footnotesize A'': \textsigma\ap{1},\textpi\ap{1}}}
\arrow{<->}
\chemsetup[orbital]{
overlay,
opacity=.4,
p/scale=1.5,
p/half,
s/scale=1.3
}
\chemname{\chemfig[][scale=0.75]{[:-60]*6(-=-(=)-(-[-2,0.001,,,draw=none]{{\orbital{s}}})(-[0,.1,,,draw=none]\lewis{2.,})-(-[-2,0.001,,,draw=none]{{\orbital{p}}})(-[2,.4,,,draw=none]\lewis{2.,})=)}}{{\footnotesize A'': \textsigma\ap{1},\textpi\ap{1}}}
\arrow{<->}
\chemsetup[orbital]{
overlay,
opacity=.4,
p/scale=1.5,
p/half,
s/scale=1.3
}
\chemname{\chemfig[][scale=0.75]{*6(-=(-\orbital{s})-=(-[-2,0.001,,,draw=none]{{\orbital{p}}})(-[2,.6,,,draw=none]\lewis{2.,})(-[2,.4,,,draw=none]\lewis{2.,})-=)}}{{\footnotesize A': \textsigma\ap{2},\textpi\ap{0}}}
\schemestop
}
\end{figure}\end{document}


• Nice :) If you move \chemsetup outside of the scheme you won't have to repeat it. BTW \centerline{} is a plain TeX command and shouldn't be used in LaTeX. Since you're in a figure a simple \centering would suffice. Another BTW: \chemsetup[chemformula]{format=\sffamily} seems useless since you're using mhchem's \cf anyway. Dec 9 '13 at 16:53