# The MOdiagram package

There is a new package of mine: MOdiagram. It enables to create simple molecular orbital diagrams. The package uses TikZ to draw the diagrams. The package has been strongly inspired by this question on TeX.SE.

Let’s take a look at an example:

\begin{documentclass{article}
\usepackage{modiagram}
\begin{document}

\begin{MOdiagram}
\atom{left} { 1s = {; up} }
\atom{right}{ 1s = {; up} }
\molecule { 1sMO = {1; pair } }
\end{MOdiagram}

\end{document
}

As you can see the syntax is rather simple: first you specify the two atoms that are interacting, the one positioned left, the other right. As argument you then specify the atomic orbitals, 1s in this case. They need two values, that describe them. The first one is the relative vertical position, the second the electron specification.

Then you do the same for the molecule: as argument you specify the MOs, that are created. In this case they’re called 1sMO. They need three values: the first one is the relative vertical offset in respect to the AOs, the second the electron specification of the bonding MO and the third the electron specification of the anti-bonding MO.

Compare with this example:

\begin{documentclass{article}
\usepackage{modiagram}
\begin{document}

\begin{MOdiagram}
\atom{left} { 1s, 2s = {2; pair} }
\atom{right}{ 1s = {.5; pair}, 2s = {2.25; up} }
\molecule { 1sMO = {1; pair, pair }, 2sMO = {1; pair, up} }
\end{MOdiagram}

\end{document
}

There are some possibilities to customize the diagrams. The package provides different styles for the diagrams, a possibility to add labels to the orbitals. And since the orbitals are nodes in the TikZ sense, the can easily be referred to for further actions.

\documentclass{article}
\usepackage{modiagram}
\begin{document}
\begin{MOdiagram}[style=square]
\atom{left} { 1s = {0;up} }
\atom{right}{ 1s = {0;up} }
\molecule{
1sMO = {.75;pair,} ,
label = {
1sigma = $\sigma$,
1sigma* = $\sigma^*$
}
}
\node[right] at (1sigma.-45) {bindend};
\node[right] at (1sigma*.45) {antibindend};
\end{MOdiagram}
\end{document
}

At last a complex example:

\documentclass{article}
\usepackage[version=3]{mhchem}
\usepackage{modiagram}
\begin{document}

\begin{figure}
\centering
\begin{MOdiagram}[style=fancy,labels,names,AO-width=8pt,labels-fs=\footnotesize]
\atom[\ce{O_a}]{left}{
1s, 2s, 2p = {5;pair,up,up}
}
\atom[\ce{O_b}]{right}{
1s, 2s, 2p = {5;pair,up,up}
}
\molecule[\ce{O2}]{
1sMO, 2sMO,
2pMO = {1.5,.5;pair,pair,pair,up,up,},
color = { 2piy*=red, 2piz*=red }
}
\EnergyAxis
\end{MOdiagram}
\caption{MO-Diagramm von $^3$\textSigma-\ce{O2}.}
\end{figure}
\end{document
}

Edited 2011/10/28: example code now matches v0.2