summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/modiagram
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/modiagram
Initial commit
Diffstat (limited to 'macros/latex/contrib/modiagram')
-rw-r--r--macros/latex/contrib/modiagram/README30
-rw-r--r--macros/latex/contrib/modiagram/modiagram.sty2090
-rw-r--r--macros/latex/contrib/modiagram/modiagram_en.pdfbin0 -> 618728 bytes
-rw-r--r--macros/latex/contrib/modiagram/modiagram_en.tex1282
4 files changed, 3402 insertions, 0 deletions
diff --git a/macros/latex/contrib/modiagram/README b/macros/latex/contrib/modiagram/README
new file mode 100644
index 0000000000..31c6a50b81
--- /dev/null
+++ b/macros/latex/contrib/modiagram/README
@@ -0,0 +1,30 @@
+--------------------------------------------------------------------------
+the MODIAGRAM package 2015/09/23 v0.2g
+
+ easy creation of molecular orbital diagrams
+
+--------------------------------------------------------------------------
+Clemens Niederberger
+Web: https://www.bitbucket.org/cgnieder/modiagram
+E-Mail: contact@mychemistry.eu
+--------------------------------------------------------------------------
+If you have any ideas, questions, suggestions or bugs to report, please
+feel free to contact me.
+--------------------------------------------------------------------------
+Copyright 2011--2015 Clemens Niederberger
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3
+of this license or (at your option) any later version.
+The latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status `maintained'.
+
+The Current Maintainer of this work is Clemens Niederberger.
+
+This work consists of the files modiagram.sty, modiagram_en.tex,
+README and the derived file modiagram_en.pdf.
+--------------------------------------------------------------------------
diff --git a/macros/latex/contrib/modiagram/modiagram.sty b/macros/latex/contrib/modiagram/modiagram.sty
new file mode 100644
index 0000000000..b240da4c61
--- /dev/null
+++ b/macros/latex/contrib/modiagram/modiagram.sty
@@ -0,0 +1,2090 @@
+% --------------------------------------------------------------------------
+% the MODIAGRAM package
+%
+% easy creation of molecular orbital diagrams
+%
+% --------------------------------------------------------------------------
+% Clemens Niederberger
+% Web: https://www.bitbucket.org/cgnieder/modiagram
+% E-Mail: contact@mychemistry.eu
+% --------------------------------------------------------------------------
+% If you have any ideas, questions, suggestions or bugs to report, please
+% feel free to contact me.
+% --------------------------------------------------------------------------
+% Copyright 2011--2015 Clemens Niederberger
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Clemens Niederberger.
+%
+% This work consists of the files modiagram.sty, modiagram_en.tex,
+% README and the derived file modiagram_en.pdf.
+% --------------------------------------------------------------------------
+\RequirePackage{ expl3 , xparse , l3keys2e , tikz , chemgreek }
+\usetikzlibrary{calc,arrows}
+\ProvidesExplPackage
+ {modiagram}
+ {2015/09/23}
+ {0.2g}
+ {easy creation of molecular orbital diagrams}
+
+% --------------------------------------------------------------------------- %
+% error messages
+\msg_set:nnn { MOdiagram } { missing-atom }
+ {
+ You~need~to~specify~the~left~and~right~atom~first~before~you~can~use~
+ \token_to_str:N \molecule \c_space_tl \msg_line_context: .
+ }
+
+\msg_set:nnn { MOdiagram } { missing-AO }
+ {
+ You~need~to~specify~both~#2~AOs~first~before~you~can~use~
+ #1~ \msg_line_context: .
+ }
+
+\msg_set:nnn { MOdiagram } { electron-placement }
+ {
+ The~value~for~the~electron~placement~must~be~between~0~and~1~
+ \msg_line_context: .
+ }
+
+% --------------------------------------------------------------------------- %
+% temporary variables
+\tl_new:N \l__MOdiagram_tmpa_tl
+\tl_new:N \l__MOdiagram_tmpb_tl
+\dim_new:N \l__MOdiagram_tmpa_dim
+\fp_new:N \l__MOdiagram_tmpa_fp
+
+% --------------------------------------------------------------------------- %
+% variants of expl3 kernel commands:
+\cs_generate_variant:Nn \str_case:nnF { V }
+\cs_generate_variant:Nn \dim_compare:nNnTF { cNc }
+
+% --------------------------------------------------------------------------- %
+% main environment
+\NewDocumentEnvironment { MOdiagram } { o g }
+ {
+ \cs_set_eq:NN \atom \__MOdiagram_atom:
+ \cs_set_eq:NN \molecule \__MOdiagram_molecule:
+ \cs_set_eq:NN \AO \__MOdiagram_arbitrary_AO:
+ \cs_set_eq:NN \EnergyAxis \__MOdiagram_EnergyAxis:
+ \dim_gzero:N \g__MOdiagram_min_energy_dim
+ \dim_gzero:N \g__MOdiagram_max_energy_dim
+ \int_gzero:N \g__MOdiagram_AO_name_int
+ \IfNoValueF { #1 } { \keys_set:nn { MOdiagram / diagram } { #1 } }
+ \__MOdiagram_set_labels:
+ \__MOdiagram_tikzpicture:n { }
+ \char_set_catcode_letter:N \:
+ \char_set_catcode_other:N \;
+ }
+ {
+ \bool_if:NT \l__MOdiagram_names_bool
+ {
+ \__MOdiagram_node:f { \tl_use:N \l__MOdiagram_names_style_tl }
+ at
+ (
+ \l__MOdiagram_left_atom_position_dim ,
+ \g__MOdiagram_min_energy_dim - 1cm
+ )
+ { \tl_use:N \l__MOdiagram_atom_left_name_tl } ;
+ \__MOdiagram_node:f { \tl_use:N \l__MOdiagram_names_style_tl }
+ at
+ (
+ \l__MOdiagram_molecule_position_dim ,
+ \g__MOdiagram_min_energy_dim - 1cm
+ )
+ { \tl_use:N \l__MOdiagram_molecule_name_tl } ;
+ \__MOdiagram_node:f { \tl_use:N \l__MOdiagram_names_style_tl }
+ at
+ (
+ \l__MOdiagram_left_atom_position_dim
+ + \l__MOdiagram_inter_atom_distance_dim ,
+ \g__MOdiagram_min_energy_dim - 1cm
+ )
+ { \tl_use:N \l__MOdiagram_atom_right_name_tl } ;
+ }
+ \endtikzpicture
+ }
+
+\bool_new:N \l__MOdiagram_AO_square_bool
+\bool_new:N \l__MOdiagram_AO_round_bool
+\bool_new:N \l__MOdiagram_AO_circle_bool
+\bool_new:N \l__MOdiagram_AO_fancy_bool
+\bool_new:N \l__MOdiagram_AO_labels_bool
+\bool_new:N \l__MOdiagram_names_bool
+
+\tl_new:N \l__MOdiagram_names_style_tl
+\tl_set:Nn \l__MOdiagram_names_style_tl { anchor=base }
+
+\tl_new:N \l__MOdiagram_lines_tl
+\tl_set:Nn \l__MOdiagram_lines_tl { dotted }
+
+\tl_new:N \l__MOdiagram_orbital_label_fontsize_tl
+\tl_new:N \l__MOdiagram_orbital_label_style_tl
+
+\dim_new:N \l__MOdiagram_AO_width_dim
+\dim_set:Nn \l__MOdiagram_AO_width_dim { 10pt }
+
+\tl_new:N \l__MOdiagram_AO_up_electron_tl
+\tl_set:Nn \l__MOdiagram_AO_up_electron_tl { .4 }
+\tl_new:N \l__MOdiagram_AO_down_electron_tl
+\tl_set:Nn \l__MOdiagram_AO_down_electron_tl { .6 }
+
+\dim_new:N \l__MOdiagram_left_atom_position_dim
+\dim_set:Nn \l__MOdiagram_left_atom_position_dim { 1cm }
+\dim_new:N \l__MOdiagram_inter_atom_distance_dim
+\dim_set:Nn \l__MOdiagram_inter_atom_distance_dim { 4cm }
+\dim_new:N \l__MOdiagram_molecule_position_dim
+
+\dim_new:N \g__MOdiagram_min_energy_dim
+\dim_new:N \g__MOdiagram_max_energy_dim
+
+\dim_new:N \l__MOdiagram_energy_gain_dim
+\dim_new:N \l__MOdiagram_energy_loss_dim
+
+% detect lowest and highest orbital so we can draw the appropriate energy axis:
+\cs_new_protected:Npn \__MOdiagram_energy_range:N #1
+ {
+ \dim_set:Nn \l__MOdiagram_tmpa_dim { #1 }
+ \dim_compare:nT { \l__MOdiagram_tmpa_dim < \g__MOdiagram_min_energy_dim }
+ { \dim_gset_eq:NN \g__MOdiagram_min_energy_dim \l__MOdiagram_tmpa_dim }
+ \dim_compare:nT { \l__MOdiagram_tmpa_dim > \g__MOdiagram_max_energy_dim }
+ { \dim_gset_eq:NN \g__MOdiagram_max_energy_dim \l__MOdiagram_tmpa_dim }
+ }
+\cs_generate_variant:Nn \__MOdiagram_energy_range:N { n }
+
+% split energy levels for creating the MO; we need to detect wether the left
+% or the right AO is the lower or higher one, respectively
+\cs_new_protected:Npn \__MOdiagram_split_energy:NNN #1#2#3
+ {
+ \dim_compare:cNcTF
+ { l__MOdiagram_atom_left_#1_dim } < { l__MOdiagram_atom_right_#1_dim }
+ {
+ \dim_set_eq:Nc \l__MOdiagram_energy_gain_dim
+ { l__MOdiagram_atom_left_#1_dim }
+ \dim_sub:Nn \l__MOdiagram_energy_gain_dim { #2 }
+ \dim_set_eq:Nc \l__MOdiagram_energy_loss_dim
+ { l__MOdiagram_atom_right_#1_dim }
+ \dim_add:Nn \l__MOdiagram_energy_loss_dim { #3 }
+ }
+ {
+ \dim_set_eq:Nc \l__MOdiagram_energy_gain_dim
+ { l__MOdiagram_atom_right_#1_dim }
+ \dim_sub:Nn \l__MOdiagram_energy_gain_dim { #2 }
+ \dim_set_eq:Nc \l__MOdiagram_energy_loss_dim
+ { l__MOdiagram_atom_left_#1_dim }
+ \dim_add:Nn \l__MOdiagram_energy_loss_dim { #3 }
+ }
+ }
+\cs_generate_variant:Nn \__MOdiagram_split_energy:NNN { nNN }
+
+% position the spin-up/spin-down el:
+\cs_new_protected:Npn \__MOdiagram_AO_place_electron:nn #1#2
+ {
+ \fp_compare:nNnT { #2 } < { 0 }
+ { \msg_error:nn { MOdiagram } { electron-placement } }
+ \fp_compare:nNnT { abs( #2 ) } > { 1 }
+ { \msg_error:nn { MOdiagram } { electron-placement } }
+ \bool_if:nTF { #1 }
+ { \tl_set:Nn \l__MOdiagram_AO_down_electron_tl { #2 } }
+ { \tl_set:Nn \l__MOdiagram_AO_up_electron_tl { #2 } }
+ }
+\cs_generate_variant:Nn \__MOdiagram_AO_place_electron:nn { nx }
+
+\cs_new_protected:Npn \__MOdiagram_AO_place_electrons:n #1
+ {
+ \fp_set:Nn \l__MOdiagram_tmpa_fp { .5 * ( 1 - #1 ) }
+ \__MOdiagram_AO_place_electron:nx { 0 } { \fp_to_tl:N \l__MOdiagram_tmpa_fp }
+ \fp_set:Nn \l__MOdiagram_tmpa_fp { .5 * ( 1 + #1 ) }
+ \__MOdiagram_AO_place_electron:nx { 1 } { \fp_to_tl:N \l__MOdiagram_tmpa_fp }
+ }
+
+% place the right atom
+\cs_new_protected:Npn \__MOdiagram_molecule_position:n #1
+ {
+ \fp_set:Nn \l__MOdiagram_tmpa_fp { .5 * \dim_to_fp:n {#1} }
+ \dim_set:Nn \l__MOdiagram_molecule_position_dim
+ { \fp_to_dim:N \l__MOdiagram_tmpa_fp + \l__MOdiagram_left_atom_position_dim }
+ }
+\cs_generate_variant:Nn \__MOdiagram_molecule_position:n { f }
+
+\__MOdiagram_molecule_position:f
+ { \dim_use:N \l__MOdiagram_inter_atom_distance_dim }
+
+% set up keys for the environment
+\keys_define:nn { MOdiagram / diagram }
+ {
+ style .choice: ,
+ style / plain .code:n =
+ {
+ \bool_set_false:N \l__MOdiagram_AO_square_bool
+ \bool_set_false:N \l__MOdiagram_AO_round_bool
+ \bool_set_false:N \l__MOdiagram_AO_circle_bool
+ \bool_set_false:N \l__MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l__MOdiagram_lines_tl { dotted }
+ } ,
+ style / square .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_square_bool
+ \bool_set_false:N \l__MOdiagram_AO_round_bool
+ \bool_set_false:N \l__MOdiagram_AO_circle_bool
+ \bool_set_false:N \l__MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l__MOdiagram_lines_tl { gray }
+ } ,
+ style / circle .code:n =
+ {
+ \bool_set_false:N \l__MOdiagram_AO_square_bool
+ \bool_set_false:N \l__MOdiagram_AO_round_bool
+ \bool_set_true:N \l__MOdiagram_AO_circle_bool
+ \bool_set_false:N \l__MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l__MOdiagram_lines_tl { gray }
+ } ,
+ style / round .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_square_bool
+ \bool_set_true:N \l__MOdiagram_AO_round_bool
+ \bool_set_false:N \l__MOdiagram_AO_circle_bool
+ \bool_set_false:N \l__MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l__MOdiagram_lines_tl { gray }
+ } ,
+ style / fancy .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_square_bool
+ \bool_set_true:N \l__MOdiagram_AO_round_bool
+ \bool_set_false:N \l__MOdiagram_AO_circle_bool
+ \bool_set_true:N \l__MOdiagram_AO_fancy_bool
+ \tl_set:Nn \l__MOdiagram_lines_tl { densely~dashed }
+ } ,
+ lines .tl_set:N = \l__MOdiagram_lines_tl ,
+ distance .code:n =
+ {
+ \dim_set:Nn \l__MOdiagram_inter_atom_distance_dim { #1 }
+ \__MOdiagram_molecule_position:n { #1 }
+ } ,
+ AO-width .tl_set:N = \l__MOdiagram_AO_width_dim ,
+ up-el-pos .code:n = \__MOdiagram_AO_place_electron:nn { 0 } { #1 } ,
+ down-el-pos .code:n = \__MOdiagram_AO_place_electron:nn { 1 } { #1 } ,
+ el-sep .code:n = \__MOdiagram_AO_place_electrons:n { #1 } ,
+ labels .bool_set:N = \l__MOdiagram_AO_labels_bool ,
+ names .bool_set:N = \l__MOdiagram_names_bool ,
+ names-style .tl_set:N = \l__MOdiagram_names_style_tl ,
+ names-style-add .code:n =
+ { \tl_put_right:Nn \l__MOdiagram_names_style_tl { , #1 } } ,
+ labels-fs .tl_set:N = \l__MOdiagram_orbital_label_fontsize_tl ,
+ labels-style .tl_set:N = \l__MOdiagram_orbital_label_style_tl
+ }
+
+\ProcessKeysOptions { MOdiagram / diagram }
+
+% --------------------------------------------------------------------------- %
+% setup command
+\NewDocumentCommand \MOsetup { m }
+ { \keys_set:nn { MOdiagram / diagram } { #1 } }
+
+% --------------------------------------------------------------------------- %
+% draw AOs
+\tl_new:N \l__MOdiagram_atom_left_name_tl
+\tl_new:N \l__MOdiagram_atom_right_name_tl
+
+\bool_new:N \l__MOdiagram_left_atom_placed_bool
+\bool_set_false:N \l__MOdiagram_left_atom_placed_bool
+\bool_new:N \l__MOdiagram_right_atom_placed_bool
+\bool_set_false:N \l__MOdiagram_right_atom_placed_bool
+
+\NewDocumentCommand \__MOdiagram_atom: { o m m }
+ {
+ \__MOdiagram_atom_disable:
+ \keys_set:nn { MOdiagram / atom } { position = #2 }
+ \keys_set:nn { MOdiagram / atom } { #3 }
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { \bool_set_true:N \l__MOdiagram_left_atom_placed_bool }
+ { \bool_set_true:N \l__MOdiagram_right_atom_placed_bool }
+ \IfNoValueF { #1 }
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { \tl_set:Nn \l__MOdiagram_atom_left_name_tl { #1 } }
+ { \tl_set:Nn \l__MOdiagram_atom_right_name_tl { #1 } }
+ }
+ \__MOdiagram_one_s:
+ \__MOdiagram_two_s:
+ \__MOdiagram_two_p:
+% \__MOdiagram_three_s:
+% \__MOdiagram_three_p:
+% \__MOdiagram_four_s:
+ }
+
+\bool_new:N \l__MOdiagram_atom_left_bool
+
+% is \atom placed left or right?
+\keys_define:nn { MOdiagram / atom }
+ {
+ position .choice: ,
+ position / left .code:n =
+ { \bool_set_true:N \l__MOdiagram_atom_left_bool } ,
+ position / right .code:n =
+ { \bool_set_false:N \l__MOdiagram_atom_left_bool }
+ }
+
+\dim_new:N \l__MOdiagram_atom_xshift_dim
+
+% these are going to be our `arguments' for the \atom command:
+\keys_define:nn { MOdiagram / atom }
+ {
+ 1s .code:n = { \__MOdiagram_one_s_set:n { #1 } } ,
+ 1s .default:n = { 0 ; pair } ,
+ 2s .code:n = { \__MOdiagram_two_s_set:n { #1 } } ,
+ 2s .default:n = { 2 ; pair } ,
+ 2p .code:n = { \__MOdiagram_two_p_set:n { #1 } } ,
+ 2p .default:n = { 5 ; pair , pair , pair } ,
+ color .code:n = { \__MOdiagram_electron_color_set:n { #1 } } ,
+ label .code:n = { \__MOdiagram_orbital_label_set:n { #1 } } ,
+ up-el-pos .code:n = { \__MOdiagram_electron_up_set:n { #1 } } ,
+ down-el-pos .code:n = { \__MOdiagram_electron_down_set:n { #1 } }
+ }
+
+% --------------------------------------------------------------------------- %
+% 1s orbital
+\dim_new:N \l__MOdiagram_atom_one_s_dim
+\dim_new:N \l__MOdiagram_atom_left_one_s_dim
+\dim_new:N \l__MOdiagram_atom_right_one_s_dim
+
+\tl_new:N \l__MOdiagram_AO_one_s_electron_tl
+
+\bool_new:N \l__MOdiagram_atom_one_s_bool
+\bool_new:N \l__MOdiagram_one_s_left_bool
+\bool_set_false:N \l__MOdiagram_one_s_left_bool
+\bool_new:N \l__MOdiagram_one_s_right_bool
+\bool_set_false:N \l__MOdiagram_one_s_right_bool
+
+% read 1s argument
+\cs_new_protected:Npn \__MOdiagram_one_s_set:n #1
+ {
+ \bool_set_true:N \l__MOdiagram_atom_one_s_bool
+ \tl_if_in:onTF { #1 } { ; }
+ { \__MOdiagram_one_s_set_aux:n #1 \q_stop }
+ {
+ \tl_clear:N \l__MOdiagram_AO_one_s_electron_tl
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_atom_one_s_dim { 0 cm } }
+ { \dim_set:Nn \l__MOdiagram_atom_one_s_dim { #1 cm } }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_one_s_set_aux:n #1;#2 \q_stop
+ {
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_atom_one_s_dim { 0 cm } }
+ { \dim_set:Nn \l__MOdiagram_atom_one_s_dim { #1 cm } }
+ \tl_set:Nn \l__MOdiagram_AO_one_s_electron_tl { #2 }
+ }
+
+% display 1s orbital
+\cs_new_protected:Npn \__MOdiagram_one_s:
+ {
+ \bool_if:NT \l__MOdiagram_atom_one_s_bool
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ {
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_xshift_dim
+ \l__MOdiagram_left_atom_position_dim
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_left_one_s_dim
+ \l__MOdiagram_atom_one_s_dim
+ \bool_set_true:N \l__MOdiagram_one_s_left_bool
+ }
+ {
+ \dim_set:Nn \l__MOdiagram_atom_xshift_dim
+ {
+ \l__MOdiagram_left_atom_position_dim
+ + \l__MOdiagram_inter_atom_distance_dim
+ }
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_right_one_s_dim
+ \l__MOdiagram_atom_one_s_dim
+ \bool_set_true:N \l__MOdiagram_one_s_right_bool
+ }
+ \__MOdiagram_energy_range:N \l__MOdiagram_atom_one_s_dim
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (1s
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at ( \l__MOdiagram_atom_xshift_dim , \l__MOdiagram_atom_one_s_dim )
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ {
+ \__MOdiagram_get_electron_color:n { 1sleft }
+ \__MOdiagram_get_electron_up:n { 1sleft }
+ \__MOdiagram_get_electron_down:n { 1sleft }
+ }
+ {
+ \__MOdiagram_get_electron_color:n { 1sright }
+ \__MOdiagram_get_electron_up:n { 1sright }
+ \__MOdiagram_get_electron_down:n { 1sright }
+ }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_AO_one_s_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { \__MOdiagram_get_orbital_label:n { 1s left } }
+ { \__MOdiagram_get_orbital_label:n { 1s right } }
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% 2s orbital
+\dim_new:N \l__MOdiagram_atom_two_s_dim
+\dim_new:N \l__MOdiagram_atom_left_two_s_dim
+\dim_new:N \l__MOdiagram_atom_right_two_s_dim
+
+\tl_new:N \l__MOdiagram_AO_two_s_electron_tl
+
+\bool_new:N \l__MOdiagram_atom_two_s_bool
+\bool_new:N \l__MOdiagram_two_s_left_bool
+\bool_set_false:N \l__MOdiagram_two_s_left_bool
+\bool_new:N \l__MOdiagram_two_s_right_bool
+\bool_set_false:N \l__MOdiagram_two_s_right_bool
+
+% read 2s argument
+\cs_new_protected:Npn \__MOdiagram_two_s_set:n #1
+ {
+ \bool_set_true:N \l__MOdiagram_atom_two_s_bool
+ \tl_if_in:onTF { #1 } { ; }
+ { \__MOdiagram_two_s_set_aux:n #1 \q_stop }
+ {
+ \tl_clear:N \l__MOdiagram_AO_two_s_electron_tl
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_atom_two_s_dim { 2 cm } }
+ { \dim_set:Nn \l__MOdiagram_atom_two_s_dim { #1 cm } }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_s_set_aux:n #1;#2 \q_stop
+ {
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_atom_two_s_dim { 2 cm } }
+ { \dim_set:Nn \l__MOdiagram_atom_two_s_dim { #1 cm } }
+ \tl_set:Nn \l__MOdiagram_AO_two_s_electron_tl { #2 }
+ }
+
+% display 2s orbital
+\cs_new_protected:Npn \__MOdiagram_two_s:
+ {
+ \bool_if:NT \l__MOdiagram_atom_two_s_bool
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ {
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_xshift_dim
+ \l__MOdiagram_left_atom_position_dim
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_left_two_s_dim
+ \l__MOdiagram_atom_two_s_dim
+ \bool_set_true:N \l__MOdiagram_two_s_left_bool
+ }
+ {
+ \dim_set:Nn \l__MOdiagram_atom_xshift_dim
+ {
+ \l__MOdiagram_left_atom_position_dim
+ + \l__MOdiagram_inter_atom_distance_dim
+ }
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_right_two_s_dim
+ \l__MOdiagram_atom_two_s_dim
+ \bool_set_true:N \l__MOdiagram_two_s_right_bool
+ }
+ \__MOdiagram_energy_range:N \l__MOdiagram_atom_two_s_dim
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2s
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at ( \l__MOdiagram_atom_xshift_dim , \l__MOdiagram_atom_two_s_dim )
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ {
+ \__MOdiagram_get_electron_color:n { 2sleft }
+ \__MOdiagram_get_electron_up:n { 2sleft }
+ \__MOdiagram_get_electron_down:n { 2sleft }
+ }
+ {
+ \__MOdiagram_get_electron_color:n { 2sright }
+ \__MOdiagram_get_electron_up:n { 2sright }
+ \__MOdiagram_get_electron_down:n { 2sright }
+ }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_AO_two_s_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { \__MOdiagram_get_orbital_label:n { 2s left } }
+ { \__MOdiagram_get_orbital_label:n { 2s right } }
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% 2p orbital
+\dim_new:N \l__MOdiagram_atom_two_p_dim
+\dim_new:N \l__MOdiagram_atom_left_two_p_dim
+\dim_new:N \l__MOdiagram_atom_right_two_p_dim
+
+\dim_new:N \l__MOdiagram_atom_px_shift_dim
+\dim_new:N \l__MOdiagram_atom_py_shift_dim
+\dim_new:N \l__MOdiagram_atom_pz_shift_dim
+
+\tl_new:N \l__MOdiagram_AO_two_px_electron_tl
+\tl_new:N \l__MOdiagram_AO_two_py_electron_tl
+\tl_new:N \l__MOdiagram_AO_two_pz_electron_tl
+
+\bool_new:N \l__MOdiagram_atom_two_p_bool
+\bool_new:N \l__MOdiagram_two_p_left_bool
+\bool_set_false:N \l__MOdiagram_two_p_left_bool
+\bool_new:N \l__MOdiagram_two_p_right_bool
+\bool_set_false:N \l__MOdiagram_two_p_right_bool
+
+% read 2p argument
+\cs_new_protected:Npn \__MOdiagram_two_p_set:n #1
+ {
+ \bool_set_true:N \l__MOdiagram_atom_two_p_bool
+ \tl_if_in:onTF { #1 } { ; }
+ { \__MOdiagram_two_p_set_aux_i:n #1 \q_stop }
+ {
+ \tl_clear:N \l__MOdiagram_AO_two_px_electron_tl
+ \tl_clear:N \l__MOdiagram_AO_two_py_electron_tl
+ \tl_clear:N \l__MOdiagram_AO_two_pz_electron_tl
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_atom_two_p_dim { 5 cm } }
+ { \dim_set:Nn \l__MOdiagram_atom_two_p_dim { #1 cm } }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_p_set_aux_i:n #1;#2 \q_stop
+ {
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_atom_two_p_dim { 5 cm } }
+ { \dim_set:Nn \l__MOdiagram_atom_two_p_dim { #1 cm } }
+ \__MOdiagram_two_p_set_aux_ii:n { #2 }
+ }
+
+\NewDocumentCommand \__MOdiagram_two_p_set_aux_ii:n
+ { > { \SplitArgument { 2 } { , } } m }
+ { \__MOdiagram_two_p_set_aux_iii:nnn #1 }
+
+\cs_set_nopar:Npn \__MOdiagram_two_p_set_aux_iii:nnn #1#2#3
+ {
+ \tl_if_blank:nF { #1 } { \tl_set:Nn \l__MOdiagram_AO_two_px_electron_tl { #1 } }
+ \tl_if_blank:nF { #2 } { \tl_set:Nn \l__MOdiagram_AO_two_py_electron_tl { #2 } }
+ \tl_if_blank:nF { #3 } { \tl_set:Nn \l__MOdiagram_AO_two_pz_electron_tl { #3 } }
+ }
+
+% place the x, y, and z orbitals
+\cs_new_protected:Npn \__MOdiagram_p_orbitals_shift:nnn #1#2#3
+ {
+ \fp_set:Nn \l__MOdiagram_tmpa_fp { \dim_to_fp:n { \l__MOdiagram_AO_width_dim } }
+ {
+ \fp_set:Nn \l__MOdiagram_tmpa_fp { #1 * \l__MOdiagram_tmpa_fp }
+ \dim_gset:Nn \l__MOdiagram_atom_px_shift_dim { \fp_to_dim:N \l__MOdiagram_tmpa_fp }
+ }
+ {
+ \fp_set:Nn \l__MOdiagram_tmpa_fp { #2 * \l__MOdiagram_tmpa_fp }
+ \dim_gset:Nn \l__MOdiagram_atom_py_shift_dim { \fp_to_dim:N \l__MOdiagram_tmpa_fp }
+ }
+ {
+ \fp_set:Nn \l__MOdiagram_tmpa_fp { #3 * \l__MOdiagram_tmpa_fp }
+ \dim_gset:Nn \l__MOdiagram_atom_pz_shift_dim { \fp_to_dim:N \l__MOdiagram_tmpa_fp }
+ }
+ }
+
+% display 2p orbitals
+\cs_new_protected:Npn \__MOdiagram_two_p:
+ {
+ \bool_if:NT \l__MOdiagram_atom_two_p_bool
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ {
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_xshift_dim
+ \l__MOdiagram_left_atom_position_dim
+ \__MOdiagram_p_orbitals_shift:nnn { -4 } { -2 } { 0 }
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_left_two_p_dim
+ \l__MOdiagram_atom_two_p_dim
+ \dim_set_eq:NN
+ \l_energy_axis_dim
+ \l__MOdiagram_atom_px_shift_dim
+ \bool_set_true:N \l__MOdiagram_two_p_left_bool
+ }
+ {
+ \dim_set:Nn \l__MOdiagram_atom_xshift_dim
+ {
+ \l__MOdiagram_left_atom_position_dim
+ + \l__MOdiagram_inter_atom_distance_dim
+ }
+ \__MOdiagram_p_orbitals_shift:nnn { 0 } { 2 } { 4 }
+ \dim_set_eq:NN
+ \l__MOdiagram_atom_right_two_p_dim
+ \l__MOdiagram_atom_two_p_dim
+ \bool_set_true:N \l__MOdiagram_two_p_right_bool
+ }
+ \__MOdiagram_energy_range:N \l__MOdiagram_atom_two_p_dim
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2pz
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at
+ (
+ \l__MOdiagram_atom_xshift_dim + \l__MOdiagram_atom_pz_shift_dim ,
+ \l__MOdiagram_atom_two_p_dim
+ )
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ {
+ \__MOdiagram_get_electron_color:n { 2pz left }
+ \__MOdiagram_get_electron_up:n { 2pz left }
+ \__MOdiagram_get_electron_down:n { 2pz left }
+ }
+ {
+ \__MOdiagram_get_electron_color:n { 2pz right }
+ \__MOdiagram_get_electron_up:n { 2pz right }
+ \__MOdiagram_get_electron_down:n { 2pz right }
+ }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_AO_two_pz_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { \__MOdiagram_get_orbital_label:n { 2pz left } }
+ { \__MOdiagram_get_orbital_label:n { 2pz right } }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2py
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at
+ (
+ \l__MOdiagram_atom_xshift_dim + \l__MOdiagram_atom_py_shift_dim ,
+ \l__MOdiagram_atom_two_p_dim
+ )
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ {
+ \__MOdiagram_get_electron_color:n { 2py left }
+ \__MOdiagram_get_electron_up:n { 2py left }
+ \__MOdiagram_get_electron_down:n { 2py left }
+ }
+ {
+ \__MOdiagram_get_electron_color:n { 2py right }
+ \__MOdiagram_get_electron_up:n { 2py right }
+ \__MOdiagram_get_electron_down:n { 2py right }
+ }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_AO_two_py_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { \__MOdiagram_get_orbital_label:n { 2py left } }
+ { \__MOdiagram_get_orbital_label:n { 2py right } }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2px
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { left }
+ { right }
+ )
+ at
+ (
+ \l__MOdiagram_atom_xshift_dim + \l__MOdiagram_atom_px_shift_dim ,
+ \l__MOdiagram_atom_two_p_dim
+ )
+ {
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ {
+ \__MOdiagram_get_electron_color:n { 2px left }
+ \__MOdiagram_get_electron_up:n { 2px left }
+ \__MOdiagram_get_electron_down:n { 2px left }
+ }
+ {
+ \__MOdiagram_get_electron_color:n { 2px right }
+ \__MOdiagram_get_electron_up:n { 2px right }
+ \__MOdiagram_get_electron_down:n { 2px right }
+ }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_AO_two_px_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \bool_if:NTF \l__MOdiagram_atom_left_bool
+ { \__MOdiagram_get_orbital_label:n { 2px left } }
+ { \__MOdiagram_get_orbital_label:n { 2px right } }
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% draw MOs
+\tl_new:N \l__MOdiagram_molecule_name_tl
+
+\NewDocumentCommand \__MOdiagram_molecule: { o m }
+ {
+ \bool_if:nTF
+ {
+ \l__MOdiagram_left_atom_placed_bool
+ &&
+ \l__MOdiagram_right_atom_placed_bool
+ }
+ {
+ \__MOdiagram_molecule_disable:
+ \keys_set:nn { MOdiagram / molecule } { #2 }
+ \IfNoValueF { #1 }
+ { \tl_set:Nn \l__MOdiagram_molecule_name_tl { #1 } }
+ \__MOdiagram_one_mo_s:
+ \__MOdiagram_two_mo_s:
+ \__MOdiagram_two_mo_p:
+% \__MOdiagram_three_mo_s:
+% \__MOdiagram_three_mo_p:
+% \__MOdiagram_four_mo_s:
+ }
+ { \msg_error:nn { MOdiagram } { missing-atom } }
+ }
+
+% these are going to be our molecule arguments:
+\keys_define:nn { MOdiagram / molecule }
+ {
+ 1sMO .code:n = { \__MOdiagram_one_mo_s_set:n { #1 } } ,
+ 1sMO .default:n = { .5 ; pair , pair } ,
+ 2sMO .code:n = { \__MOdiagram_two_mo_s_set:n { #1 } } ,
+ 2sMO .default:n = { .5 ; pair , pair } ,
+ 2pMO .code:n = { \__MOdiagram_two_mo_p_set:n { #1 } } ,
+ 2pMO .default:n = { 1.5 , .5 ; pair , pair , pair , pair , pair , pair } ,
+ color .code:n = { \__MOdiagram_electron_color_set:n { #1 } } ,
+ label .code:n = { \__MOdiagram_orbital_label_set:n { #1 } } ,
+ up-el-pos .code:n = { \__MOdiagram_electron_up_set:n { #1 } } ,
+ down-el-pos .code:n = { \__MOdiagram_electron_down_set:n { #1 } }
+ }
+
+% --------------------------------------------------------------------------- %
+% 1sigma orbitals
+\dim_new:N \l__MOdiagram_molecule_one_sigma_dim
+\dim_new:N \l__MOdiagram_molecule_one_sigmas_dim
+
+\tl_new:N \l__MOdiagram_MO_one_sigma_s_electron_tl
+\tl_new:N \l__MOdiagram_MO_one_sigmas_s_electron_tl
+\bool_new:N \l__MOdiagram_molecule_one_mo_s_bool
+
+% read 1sMO argument
+\cs_new_protected:Npn \__MOdiagram_one_mo_s_set:n #1
+ {
+ \bool_set_true:N \l__MOdiagram_molecule_one_mo_s_bool
+ \tl_if_in:onTF { #1 } { ; }
+ { \__MOdiagram_one_mo_s_set_aux:n #1 \q_stop }
+ { \__MOdiagram_one_mo_s_set_energy:n { #1 } }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_one_mo_s_set_aux:n #1;#2 \q_stop
+ {
+ \__MOdiagram_one_mo_s_set_energy:n { #1 }
+ \__MOdiagram_one_mo_s_set_electrons:n { #2 }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_one_mo_s_set_energy:n #1
+ {
+ \tl_if_in:onTF { #1 } { / }
+ { \__MOdiagram_one_mo_s_set_energy_aux:n #1 \q_stop }
+ {
+ \tl_if_blank:nTF { #1 }
+ {
+ \dim_set:Nn \l__MOdiagram_molecule_one_sigma_dim { .5 cm }
+ \dim_set:Nn \l__MOdiagram_molecule_one_sigmas_dim { .5 cm }
+ }
+ {
+ \dim_set:Nn \l__MOdiagram_molecule_one_sigma_dim { #1 cm }
+ \dim_set:Nn \l__MOdiagram_molecule_one_sigmas_dim { #1 cm }
+ }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_one_mo_s_set_energy_aux:n #1/#2 \q_stop
+ {
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_molecule_one_sigma_dim { .5 cm } }
+ { \dim_set:Nn \l__MOdiagram_molecule_one_sigma_dim { #1 cm } }
+ \tl_if_blank:nTF { #2 }
+ { \dim_set:Nn \l__MOdiagram_molecule_one_sigmas_dim { .5 cm } }
+ { \dim_set:Nn \l__MOdiagram_molecule_one_sigmas_dim { #2 cm } }
+ }
+
+\cs_set_nopar:Npn \__MOdiagram_one_mo_s_set_electrons:n #1
+ {
+ \tl_if_in:onTF { #1 } { , }
+ { \__MOdiagram_one_mo_s_set_electrons_aux:n #1 \q_stop }
+ { \tl_set:Nn \l__MOdiagram_MO_one_sigma_s_electron_tl { #1 } }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_one_mo_s_set_electrons_aux:n #1,#2 \q_stop
+ {
+ \tl_set:Nn \l__MOdiagram_MO_one_sigma_s_electron_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_MO_one_sigmas_s_electron_tl { #2 }
+ }
+
+% display 1sigma/sigma* MOs:
+\cs_new_protected:Npn \__MOdiagram_one_mo_s:
+ {
+ \bool_if:NT \l__MOdiagram_molecule_one_mo_s_bool
+ {
+ \bool_if:nF
+ { \l__MOdiagram_one_s_left_bool && \l__MOdiagram_one_s_right_bool }
+ { \msg_error:nnxx { MOdiagram } { missing-AO } { 1sMO } { 1s } }
+ \__MOdiagram_split_energy:nNN { one_s }
+ \l__MOdiagram_molecule_one_sigma_dim
+ \l__MOdiagram_molecule_one_sigmas_dim
+ \__MOdiagram_energy_range:N \l__MOdiagram_energy_gain_dim
+ \__MOdiagram_energy_range:N \l__MOdiagram_energy_loss_dim
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (1sigma)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim ,
+ \l__MOdiagram_energy_gain_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 1sigma }
+ \__MOdiagram_get_electron_up:n { 1sigma }
+ \__MOdiagram_get_electron_down:n { 1sigma }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_one_sigma_s_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 1sigma }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (1sigma*)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim ,
+ \l__MOdiagram_energy_loss_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 1sigma* }
+ \__MOdiagram_get_electron_up:n { 1sigma* }
+ \__MOdiagram_get_electron_down:n { 1sigma* }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_one_sigmas_s_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 1sigma* }
+ \__MOdiagram_draw:f
+ { \l__MOdiagram_lines_tl }
+ (1s left.east) -- (1sigma.west) (1sigma.east) -- (1s right.west)
+ (1s left.east) -- (1sigma*.west) (1sigma*.east) -- (1s right.west) ;
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% 2sigma orbitals
+\dim_new:N \l__MOdiagram_molecule_two_sigma_dim
+\dim_new:N \l__MOdiagram_molecule_two_sigmas_dim
+
+\tl_new:N \l__MOdiagram_MO_two_sigma_s_electron_tl
+\tl_new:N \l__MOdiagram_MO_two_sigmas_s_electron_tl
+\bool_new:N \l__MOdiagram_molecule_two_mo_s_bool
+
+% read 2sMO argument
+\cs_new_protected:Npn \__MOdiagram_two_mo_s_set:n #1
+ {
+ \bool_set_true:N \l__MOdiagram_molecule_two_mo_s_bool
+ \tl_if_in:onTF { #1 } { ; }
+ { \__MOdiagram_two_mo_s_set_aux:n #1 \q_stop }
+ { \__MOdiagram_two_mo_s_set_energy:n { #1 } }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_s_set_aux:n #1;#2 \q_stop
+ {
+ \__MOdiagram_two_mo_s_set_energy:n { #1 }
+ \__MOdiagram_two_mo_s_set_electrons:n { #2 }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_s_set_energy:n #1
+ {
+ \tl_if_in:onTF { #1 } { / }
+ { \__MOdiagram_two_mo_s_set_energy_aux:n #1 \q_stop }
+ {
+ \tl_if_blank:nTF { #1 }
+ {
+ \dim_set:Nn \l__MOdiagram_molecule_two_sigma_dim { .5 cm }
+ \dim_set:Nn \l__MOdiagram_molecule_two_sigmas_dim { .5 cm }
+ }
+ {
+ \dim_set:Nn \l__MOdiagram_molecule_two_sigma_dim { #1 cm }
+ \dim_set:Nn \l__MOdiagram_molecule_two_sigmas_dim { #1 cm }
+ }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_s_set_energy_aux:n #1/#2 \q_stop
+ {
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_sigma_dim { .5 cm } }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_sigma_dim { #1 cm } }
+ \tl_if_blank:nTF { #2 }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_sigmas_dim { .5 cm } }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_sigmas_dim { #2 cm } }
+ }
+
+\cs_set_nopar:Npn \__MOdiagram_two_mo_s_set_electrons:n #1
+ {
+ \tl_if_in:onTF { #1 } { , }
+ { \__MOdiagram_two_mo_s_set_electrons_aux:n #1 \q_stop }
+ { \tl_set:Nn \l__MOdiagram_MO_two_sigma_s_electron_tl { #1 } }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_s_set_electrons_aux:n #1,#2 \q_stop
+ {
+ \tl_set:Nn \l__MOdiagram_MO_two_sigma_s_electron_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_MO_two_sigmas_s_electron_tl { #2 }
+ }
+
+% display 2sigma/sigma* MOs:
+\cs_new_protected:Npn \__MOdiagram_two_mo_s:
+ {
+ \bool_if:NT \l__MOdiagram_molecule_two_mo_s_bool
+ {
+ \bool_if:nF
+ { \l__MOdiagram_two_s_left_bool && \l__MOdiagram_two_s_right_bool }
+ { \msg_error:nnxx { MOdiagram } { missing-AO } { 2sMO } { 2s } }
+ \__MOdiagram_split_energy:nNN { two_s }
+ \l__MOdiagram_molecule_two_sigma_dim
+ \l__MOdiagram_molecule_two_sigmas_dim
+ \__MOdiagram_energy_range:N \l__MOdiagram_energy_gain_dim
+ \__MOdiagram_energy_range:N \l__MOdiagram_energy_loss_dim
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2sigma)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim ,
+ \l__MOdiagram_energy_gain_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 2sigma }
+ \__MOdiagram_get_electron_up:n { 2sigma }
+ \__MOdiagram_get_electron_down:n { 2sigma }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_two_sigma_s_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 2sigma }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2sigma*)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim ,
+ \l__MOdiagram_energy_loss_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 2sigma* }
+ \__MOdiagram_get_electron_up:n { 2sigma* }
+ \__MOdiagram_get_electron_down:n { 2sigma* }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_two_sigmas_s_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 2sigma* }
+ \__MOdiagram_draw:f
+ { \l__MOdiagram_lines_tl }
+ (2s left.east) -- (2sigma.west) (2sigma.east) -- (2s right.west)
+ (2s left.east) -- (2sigma*.west) (2sigma*.east) -- (2s right.west) ;
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% 2psigma and 2ppi orbitals
+\dim_new:N \l__MOdiagram_molecule_two_psigma_dim
+\dim_new:N \l__MOdiagram_molecule_two_psigmas_dim
+\dim_new:N \l__MOdiagram_molecule_two_ppi_dim
+\dim_new:N \l__MOdiagram_molecule_two_ppis_dim
+
+\tl_new:N \l__MOdiagram_MO_two_sigma_p_electron_tl
+\tl_new:N \l__MOdiagram_MO_two_sigmas_p_electron_tl
+\tl_new:N \l__MOdiagram_MO_two_piy_p_electron_tl
+\tl_new:N \l__MOdiagram_MO_two_piys_p_electron_tl
+\tl_new:N \l__MOdiagram_MO_two_piz_p_electron_tl
+\tl_new:N \l__MOdiagram_MO_two_pizs_p_electron_tl
+
+\bool_new:N \l__MOdiagram_molecule_two_mo_p_bool
+
+% read 2pMO argument
+\cs_set_nopar:Npn \__MOdiagram_two_mo_p_set:n #1
+ {
+ \bool_set_true:N \l__MOdiagram_molecule_two_mo_p_bool
+ \tl_if_in:onTF { #1 } { ; }
+ { \__MOdiagram_two_mo_p_set_aux:n #1 \q_stop }
+ { \__MOdiagram_two_mo_p_set_energy:n { #1 } }
+ }
+
+\cs_set_nopar:Npn \__MOdiagram_two_mo_p_set_aux:n #1;#2 \q_stop
+ {
+ \__MOdiagram_two_mo_p_set_energy:n { #1 }
+ \__MOdiagram_two_mo_p_set_electrons:n { #2 }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_p_set_energy:n #1
+ {
+ \tl_if_in:onTF { #1 } { , }
+ { \__MOdiagram_two_mo_p_set_energy_aux:n #1 \q_stop }
+ {
+ \tl_if_in:onTF { #1 } { / }
+ {
+ \__MOdiagram_two_mo_p_set_energy_sigma_aux:n #1 \q_stop
+ \__MOdiagram_two_mo_p_set_energy_pi:n { .5 }
+ }
+ {
+ \__MOdiagram_two_mo_p_set_energy_sigma:n { #1 }
+ \__MOdiagram_two_mo_p_set_energy_pi:n { .5 }
+ }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_p_set_energy_aux:n #1,#2 \q_stop
+ {
+ \tl_if_in:onTF { #1 } { / }
+ { \__MOdiagram_two_mo_p_set_energy_sigma_aux:n #1 \q_stop }
+ { \__MOdiagram_two_mo_p_set_energy_sigma:n { #1 } }
+ \tl_if_in:onTF { #2 } { / }
+ { \__MOdiagram_two_mo_p_set_energy_pi_aux:n #2 \q_stop }
+ { \__MOdiagram_two_mo_p_set_energy_pi:n { #2 } }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_p_set_energy_sigma:n #1
+ {
+ \tl_if_blank:nTF { #1 }
+ {
+ \dim_set:Nn \l__MOdiagram_molecule_two_psigma_dim { 1.5 cm }
+ \dim_set:Nn \l__MOdiagram_molecule_two_psigmas_dim { 1.5 cm }
+ }
+ {
+ \dim_set:Nn \l__MOdiagram_molecule_two_psigma_dim { #1 cm }
+ \dim_set:Nn \l__MOdiagram_molecule_two_psigmas_dim { #1 cm }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_p_set_energy_sigma_aux:n #1/#2 \q_stop
+ {
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_psigma_dim { 1.5 cm } }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_psigma_dim { #1 cm } }
+ \tl_if_blank:nTF { #2 }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_psigmas_dim { 1.5 cm } }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_psigmas_dim { #2 cm } }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_p_set_energy_pi:n #1
+ {
+ \tl_if_blank:nTF { #1 }
+ {
+ \dim_set:Nn \l__MOdiagram_molecule_two_ppi_dim { .5 cm }
+ \dim_set:Nn \l__MOdiagram_molecule_two_ppis_dim { .5 cm }
+ }
+ {
+ \dim_set:Nn \l__MOdiagram_molecule_two_ppi_dim { #1 cm }
+ \dim_set:Nn \l__MOdiagram_molecule_two_ppis_dim { #1 cm }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_p_set_energy_pi_aux:n #1/#2 \q_stop
+ {
+ \tl_if_blank:nTF { #1 }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_ppi_dim { .5 cm } }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_ppi_dim { #1 cm } }
+ \tl_if_blank:nTF { #2 }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_ppis_dim { .5 cm } }
+ { \dim_set:Nn \l__MOdiagram_molecule_two_ppis_dim { #2 cm } }
+ }
+
+\NewDocumentCommand \__MOdiagram_two_mo_p_set_electrons:n
+ { > { \SplitArgument { 5 } { , } } m }
+ { \__MOdiagram_two_mo_p_set_electrons_aux:n #1 }
+
+\cs_new_protected:Npn \__MOdiagram_two_mo_p_set_electrons_aux:n #1#2#3#4#5#6
+ {
+ \tl_set:Nn \l__MOdiagram_MO_two_sigma_p_electron_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_MO_two_sigmas_p_electron_tl { #6 }
+ \tl_set:Nn \l__MOdiagram_MO_two_piy_p_electron_tl { #2 }
+ \tl_set:Nn \l__MOdiagram_MO_two_piys_p_electron_tl { #4 }
+ \tl_set:Nn \l__MOdiagram_MO_two_piz_p_electron_tl { #3 }
+ \tl_set:Nn \l__MOdiagram_MO_two_pizs_p_electron_tl { #5 }
+ }
+
+% display 2sigma+pi/sigma*+pi* orbitals:
+\cs_new_protected:Npn \__MOdiagram_two_mo_p:
+ {
+ \bool_if:NT \l__MOdiagram_molecule_two_mo_p_bool
+ {
+ \bool_if:nF
+ { \l__MOdiagram_two_p_left_bool && \l__MOdiagram_two_p_right_bool }
+ { \msg_error:nnxx { MOdiagram } { missing-AO } { 2pMO } { 2p } }
+ \__MOdiagram_split_energy:nNN { two_p }
+ \l__MOdiagram_molecule_two_psigma_dim
+ \l__MOdiagram_molecule_two_psigmas_dim
+ \__MOdiagram_energy_range:N \l__MOdiagram_energy_gain_dim
+ \__MOdiagram_energy_range:N \l__MOdiagram_energy_loss_dim
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2psigma)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim ,
+ \l__MOdiagram_energy_gain_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 2psigma }
+ \__MOdiagram_get_electron_up:n { 2psigma }
+ \__MOdiagram_get_electron_down:n { 2psigma }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_two_sigma_p_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 2psigma }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2psigma*)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim ,
+ \l__MOdiagram_energy_loss_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 2psigma* }
+ \__MOdiagram_get_electron_up:n { 2psigma* }
+ \__MOdiagram_get_electron_down:n { 2psigma* }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_two_sigmas_p_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 2psigma* }
+ \__MOdiagram_split_energy:nNN { two_p }
+ \l__MOdiagram_molecule_two_ppi_dim
+ \l__MOdiagram_molecule_two_ppis_dim
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2piy)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim - \l__MOdiagram_AO_width_dim ,
+ \l__MOdiagram_energy_gain_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 2piy }
+ \__MOdiagram_get_electron_up:n { 2piy }
+ \__MOdiagram_get_electron_down:n { 2piy }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_two_piy_p_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 2piy }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2piy*)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim - \l__MOdiagram_AO_width_dim ,
+ \l__MOdiagram_energy_loss_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 2piy* }
+ \__MOdiagram_get_electron_up:n { 2piy* }
+ \__MOdiagram_get_electron_down:n { 2piy* }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_two_piys_p_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 2piy* }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2piz)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim + \l__MOdiagram_AO_width_dim ,
+ \l__MOdiagram_energy_gain_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 2piz }
+ \__MOdiagram_get_electron_up:n { 2piz }
+ \__MOdiagram_get_electron_down:n { 2piz }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_two_piz_p_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 2piz }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (2piz*)
+ at
+ (
+ \l__MOdiagram_molecule_position_dim + \l__MOdiagram_AO_width_dim ,
+ \l__MOdiagram_energy_loss_dim
+ )
+ {
+ \__MOdiagram_get_electron_color:n { 2piz* }
+ \__MOdiagram_get_electron_up:n { 2piz* }
+ \__MOdiagram_get_electron_down:n { 2piz* }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_MO_two_pizs_p_electron_tl }
+ { \tl_use:N \l__MOdiagram_electron_current_color_tl }
+ } ;
+ \__MOdiagram_get_orbital_label:n { 2piz* }
+ \__MOdiagram_draw:f
+ { \l__MOdiagram_lines_tl }
+ (2pz left.east) -- (2psigma.west) (2psigma.east) -- (2px right.west)
+ (2pz left.east) -- (2psigma*.west) (2psigma*.east) -- (2px right.west)
+ (2pz left.east) -- (2piy.west) (2piz.east) -- (2px right.west)
+ (2pz left.east) -- (2piy*.west) (2piz*.east) -- (2px right.west) ;
+ }
+ }
+
+% --------------------------------------------------------------------------- %
+% draw actual AO / MO
+\tl_new:N \l__MOdiagram_electron_color_tl
+
+\cs_new_protected:Npn \__MOdiagram_AO:nn #1#2
+ {
+ \group_begin:
+ \tl_set:Nn \l__MOdiagram_electron_color_tl { #2 }
+ \tikzpicture
+ \bool_if:NT \l__MOdiagram_AO_fancy_bool
+ {
+ \draw (0,0) -- ++(-.5*\l__MOdiagram_AO_width_dim,0) ;
+ \draw (2pt+\l__MOdiagram_AO_width_dim,0)
+ -- ++(.5*\l__MOdiagram_AO_width_dim,0) ;
+ }
+ \bool_if:NT \l__MOdiagram_AO_circle_bool
+ {
+ \draw (-.4142pt,0) ++(-.2071*\l__MOdiagram_AO_width_dim,0)
+ -- ++(-.25*\l__MOdiagram_AO_width_dim,0) ;
+ \draw (2.4142pt,0) ++(1.2071*\l__MOdiagram_AO_width_dim,0)
+ -- ++(.25*\l__MOdiagram_AO_width_dim,0) ;
+ }
+ \__MOdiagram_node:x
+ {
+ inner~sep = 0 ,
+ \bool_if:NT \l__MOdiagram_AO_square_bool { draw } ,
+ \bool_if:NT \l__MOdiagram_AO_circle_bool { circle , draw } ,
+ minimum~size =
+ \bool_if:NTF \l__MOdiagram_AO_square_bool
+ { 2pt+\l__MOdiagram_AO_width_dim }
+ {
+ \bool_if:NTF \l__MOdiagram_AO_circle_bool
+ { 1.4142*(2pt+\l__MOdiagram_AO_width_dim) }
+ { \l__MOdiagram_AO_width_dim }
+ } ,
+ \bool_if:NT \l__MOdiagram_AO_round_bool
+ { rounded~corners=2pt }
+ }
+ at (.5*\l__MOdiagram_AO_width_dim+1pt,0)
+ {
+ \tikz
+ {
+ \bool_if:nTF { \l__MOdiagram_AO_square_bool || \l__MOdiagram_AO_circle_bool }
+ { \draw[draw=none] (0,0) -- ++(\l__MOdiagram_AO_width_dim,0) ; }
+ { \draw (0,0) -- ++(\l__MOdiagram_AO_width_dim,0) ; }
+ \tl_set:Nn \l__MOdiagram_tmpa_tl { #1 }
+ \tl_remove_all:Nn \l__MOdiagram_tmpa_tl { ~ }
+ \str_case:VnF \l__MOdiagram_tmpa_tl
+ {
+ { up }
+ {
+ \__MOdiagram_draw:f
+ { -left~to,semithick , \l__MOdiagram_electron_color_tl , inner~sep=0,outer~sep=0 }
+ (\l__MOdiagram_AO_up_electron_tl*\l__MOdiagram_AO_width_dim,-.4*\l__MOdiagram_AO_width_dim)
+ -- ++(0,.8*\l__MOdiagram_AO_width_dim) ;
+ }
+ { down }
+ {
+ \__MOdiagram_draw:f
+ { -left~to,semithick , \l__MOdiagram_electron_color_tl }
+ (\l__MOdiagram_AO_down_electron_tl*\l__MOdiagram_AO_width_dim,.4*\l__MOdiagram_AO_width_dim)
+ -- ++(0,-.8*\l__MOdiagram_AO_width_dim) ;
+ }
+ { pair }
+ {
+ \__MOdiagram_draw:f
+ { -left~to,semithick , \l__MOdiagram_electron_color_tl }
+ (\l__MOdiagram_AO_up_electron_tl*\l__MOdiagram_AO_width_dim,-.4*\l__MOdiagram_AO_width_dim)
+ -- ++(0,.8*\l__MOdiagram_AO_width_dim) ;
+ \__MOdiagram_draw:f
+ { -left~to,semithick , \l__MOdiagram_electron_color_tl }
+ (\l__MOdiagram_AO_down_electron_tl*\l__MOdiagram_AO_width_dim,.4*\l__MOdiagram_AO_width_dim)
+ -- ++(0,-.8*\l__MOdiagram_AO_width_dim) ;
+ }
+ }
+ {}
+ }
+ } ;
+ \endtikzpicture
+ \group_end:
+ }
+\cs_generate_variant:Nn \__MOdiagram_AO:nn { ff }
+
+% -------------------------------------------------------------------------- %
+% per default disable all AOs / MOs
+\cs_new_protected:Npn \__MOdiagram_atom_disable:
+ {
+ \bool_set_false:N \l__MOdiagram_atom_one_s_bool
+ \bool_set_false:N \l__MOdiagram_atom_two_s_bool
+ \bool_set_false:N \l__MOdiagram_atom_two_p_bool
+% \bool_set_false:N \l__MOdiagram_atom_three_s_bool
+% \bool_set_false:N \l__MOdiagram_atom_three_p_bool
+ }
+
+\cs_new_protected:Npn \__MOdiagram_molecule_disable:
+ { \bool_set_false:N \l__MOdiagram_molecule_one_mo_s_bool }
+
+% --------------------------------------------------------------------------- %
+% arbitrary placement of AOs / MOs
+\dim_new:N \l__MOdiagram_AO_dim % y
+\dim_new:N \l__MOdiagram_AO_position_dim % x
+
+\dim_new:N \l__MOdiagram_AO_px_shift_dim
+\dim_new:N \l__MOdiagram_AO_py_shift_dim
+\dim_new:N \l__MOdiagram_AO_pz_shift_dim
+
+\tl_new:N \l__MOdiagram_AO_px_electron_tl
+\tl_new:N \l__MOdiagram_AO_py_electron_tl
+\tl_new:N \l__MOdiagram_AO_pz_electron_tl
+
+\tl_new:N \l__MOdiagram_AO_x_electron_color_tl
+\tl_new:N \l__MOdiagram_AO_y_electron_color_tl
+\tl_new:N \l__MOdiagram_AO_z_electron_color_tl
+
+\bool_new:N \l__MOdiagram_AO_label_bool
+\bool_new:N \l__MOdiagram_AO_x_label_bool
+\bool_new:N \l__MOdiagram_AO_y_label_bool
+\bool_new:N \l__MOdiagram_AO_z_label_bool
+
+\tl_new:N \l__MOdiagram_AO_x_label_tl
+\tl_new:N \l__MOdiagram_AO_y_label_tl
+\tl_new:N \l__MOdiagram_AO_z_label_tl
+
+\bool_new:N \l__MOdiagram_AO_up_electron_bool
+\bool_new:N \l__MOdiagram_AO_x_up_electron_bool
+\bool_new:N \l__MOdiagram_AO_y_up_electron_bool
+\bool_new:N \l__MOdiagram_AO_z_up_electron_bool
+\tl_new:N \l__MOdiagram_AO_x_up_electron_tl
+\tl_new:N \l__MOdiagram_AO_y_up_electron_tl
+\tl_new:N \l__MOdiagram_AO_z_up_electron_tl
+
+\bool_new:N \l__MOdiagram_AO_down_electron_bool
+\bool_new:N \l__MOdiagram_AO_x_down_electron_bool
+\bool_new:N \l__MOdiagram_AO_y_down_electron_bool
+\bool_new:N \l__MOdiagram_AO_z_down_electron_bool
+\tl_new:N \l__MOdiagram_AO_x_down_electron_tl
+\tl_new:N \l__MOdiagram_AO_y_down_electron_tl
+\tl_new:N \l__MOdiagram_AO_z_down_electron_tl
+
+\tl_new:N \l__MOdiagram_AO_name_tl
+
+\bool_new:N \l__MOdiagram_AO_p_bool
+\bool_new:N \l__MOdiagram_AO_left_bool
+
+\int_new:N \g__MOdiagram_AO_name_int
+
+% read argument in s case:
+\cs_new_protected:Npn \__MOdiagram_AO_s_set:n #1
+ {
+ \tl_if_in:onTF { #1 } { ; }
+ { \__MOdiagram_AO_s_set_aux:n #1 \q_stop }
+ {
+ \dim_set:Nn \l__MOdiagram_AO_dim { #1 cm }
+ \tl_set:Nn \l__MOdiagram_AO_px_electron_tl { pair }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_AO_s_set_aux:n #1;#2 \q_stop
+ {
+ \dim_set:Nn \l__MOdiagram_AO_dim { #1 cm }
+ \tl_set:Nn \l__MOdiagram_AO_px_electron_tl { #2 }
+ }
+
+% read argument in p case:
+\cs_new_protected:Npn \__MOdiagram_AO_p_set:n #1
+ {
+ \tl_if_in:onTF { #1 } { ; }
+ { \__MOdiagram_AO_p_set_aux:n #1 \q_stop }
+ {
+ \dim_set:Nn \l__MOdiagram_AO_dim { #1 cm }
+ \tl_set:Nn \l__MOdiagram_AO_px_electron_tl { pair }
+ \tl_set:Nn \l__MOdiagram_AO_py_electron_tl { pair }
+ \tl_set:Nn \l__MOdiagram_AO_pz_electron_tl { pair }
+ }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_AO_p_set_aux:n #1;#2 \q_stop
+ {
+ \dim_set:Nn \l__MOdiagram_AO_dim { #1 cm }
+ \__MOdiagram_AO_p_set_electrons:n { #2 }
+ }
+\NewDocumentCommand \__MOdiagram_AO_p_set_electrons:n
+ { > { \SplitArgument { 2 } { , } } m }
+ { \__MOdiagram_AO_p_set_electrons_aux:n #1 }
+
+\cs_new_protected:Npn \__MOdiagram_AO_p_set_electrons_aux:n #1#2#3
+ {
+ \tl_set:Nn \l__MOdiagram_AO_px_electron_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_py_electron_tl { #2 }
+ \tl_set:Nn \l__MOdiagram_AO_pz_electron_tl { #3 }
+ }
+
+\cs_new_protected:Npn \__MOdiagram_AO_get_orbital_x_label:n #1
+ {
+ \bool_if:nT { \l__MOdiagram_AO_x_label_bool || \l__MOdiagram_AO_label_bool }
+ {
+ \__MOdiagram_node:x
+ { below , \tl_use:N \l__MOdiagram_orbital_label_style_tl }
+ at ( #1 . south )
+ {
+ \tl_use:N \l__MOdiagram_orbital_label_fontsize_tl
+ \tl_use:N \l__MOdiagram_AO_x_label_tl
+ } ;
+ }
+ }
+\cs_generate_variant:Nn \__MOdiagram_AO_get_orbital_x_label:n { o }
+
+\cs_new_protected:Npn \__MOdiagram_AO_get_orbital_y_label:n #1
+ {
+ \bool_if:nT { \l__MOdiagram_AO_y_label_bool || \l__MOdiagram_AO_label_bool }
+ {
+ \__MOdiagram_node:x
+ { below , \tl_use:N \l__MOdiagram_orbital_label_style_tl }
+ at ( #1 . south )
+ {
+ \tl_use:N \l__MOdiagram_orbital_label_fontsize_tl
+ \tl_use:N \l__MOdiagram_AO_y_label_tl
+ } ;
+ }
+ }
+\cs_generate_variant:Nn \__MOdiagram_AO_get_orbital_y_label:n { o }
+
+\cs_new_protected:Npn \__MOdiagram_AO_get_orbital_z_label:n #1
+ {
+ \bool_if:nT { \l__MOdiagram_AO_z_label_bool || \l__MOdiagram_AO_label_bool }
+ {
+ \__MOdiagram_node:x
+ { below , \tl_use:N \l__MOdiagram_orbital_label_style_tl }
+ at ( #1 . south )
+ {
+ \tl_use:N \l__MOdiagram_orbital_label_fontsize_tl
+ \tl_use:N \l__MOdiagram_AO_z_label_tl
+ } ;
+ }
+ }
+\cs_generate_variant:Nn \__MOdiagram_AO_get_orbital_z_label:n { o }
+
+% these are going to be our arguments
+\keys_define:nn { MOdiagram / AO }
+ {
+ type .choice: ,
+ type / s .code:n = { \bool_set_false:N \l__MOdiagram_AO_p_bool } ,
+ type / p .code:n = { \bool_set_true:N \l__MOdiagram_AO_p_bool }
+ }
+
+\keys_define:nn { MOdiagram / AO / properties }
+ {
+ color .code:n =
+ {
+ \tl_set:Nn \l__MOdiagram_AO_x_electron_color_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_y_electron_color_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_z_electron_color_tl { #1 }
+ } ,
+ color[x] .tl_set:N = \l__MOdiagram_AO_x_electron_color_tl ,
+ color[y] .tl_set:N = \l__MOdiagram_AO_y_electron_color_tl ,
+ color[z] .tl_set:N = \l__MOdiagram_AO_z_electron_color_tl ,
+ label .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_label_bool
+ \tl_set:Nn \l__MOdiagram_AO_x_label_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_y_label_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_z_label_tl { #1 }
+ } ,
+ label[x] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_x_label_bool
+ \tl_set:Nn \l__MOdiagram_AO_x_label_tl { #1 }
+ } ,
+ label[y] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_y_label_bool
+ \tl_set:Nn \l__MOdiagram_AO_y_label_tl { #1 }
+ } ,
+ label[z] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_z_label_bool
+ \tl_set:Nn \l__MOdiagram_AO_z_label_tl { #1 }
+ } ,
+ up-el-pos .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_up_electron_bool
+ \tl_set:Nn \l__MOdiagram_AO_x_up_electron_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_y_up_electron_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_z_up_electron_tl { #1 }
+ } ,
+ up-el-pos[x] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_x_up_electron_bool
+ \tl_set:Nn \l__MOdiagram_AO_x_up_electron_tl { #1 }
+ } ,
+ up-el-pos[y] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_y_up_electron_bool
+ \tl_set:Nn \l__MOdiagram_AO_y_up_electron_tl { #1 }
+ } ,
+ up-el-pos[z] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_z_up_electron_bool
+ \tl_set:Nn \l__MOdiagram_AO_y_up_electron_tl { #1 }
+ } ,
+ down-el-pos .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_down_electron_bool
+ \tl_set:Nn \l__MOdiagram_AO_x_down_electron_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_y_down_electron_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_AO_z_down_electron_tl { #1 }
+ } ,
+ down-el-pos[x] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_x_down_electron_bool
+ \tl_set:Nn \l__MOdiagram_AO_x_down_electron_tl { #1 }
+ } ,
+ down-el-pos[y] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_y_down_electron_bool
+ \tl_set:Nn \l__MOdiagram_AO_y_down_electron_tl { #1 }
+ } ,
+ down-el-pos[z] .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_AO_z_down_electron_bool
+ \tl_set:Nn \l__MOdiagram_AO_z_down_electron_tl { #1 }
+ }
+ }
+
+% AO[<name>](<x-coord>){<type>}[<keyval>]{<AO-spec>}
+\NewDocumentCommand \__MOdiagram_arbitrary_AO: { o D(){0cm} m o m }
+ {
+ \group_begin:
+ \IfNoValueTF { #1 }
+ {
+ \int_gincr:N \g__MOdiagram_AO_name_int
+ \tl_set:Nn \l__MOdiagram_AO_name_tl
+ { AO \int_use:N \g__MOdiagram_AO_name_int }
+ }
+ { \tl_set:Nn \l__MOdiagram_AO_name_tl { #1 } }
+ \IfNoValueF { #4 }
+ { \keys_set:nn { MOdiagram / AO / properties } { #4 } }
+ \keys_set:nn { MOdiagram / AO } { type = #3 }
+ \bool_if:NTF \l__MOdiagram_AO_p_bool
+ { \__MOdiagram_AO_p_set:n { #5 } }
+ { \__MOdiagram_AO_s_set:n { #5 } }
+ \dim_set:Nn \l__MOdiagram_AO_position_dim { #2 }
+ \__MOdiagram_p_orbitals_shift:nnn { 0 } { 2 } { 4 }
+ \__MOdiagram_energy_range:N \l__MOdiagram_AO_dim
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ (
+ \tl_use:N \l__MOdiagram_AO_name_tl
+ \bool_if:NT \l__MOdiagram_AO_p_bool { x }
+ )
+ at
+ (
+ \l__MOdiagram_AO_position_dim + \l__MOdiagram_atom_px_shift_dim ,
+ \l__MOdiagram_AO_dim
+ )
+ {
+ \bool_if:nT
+ {
+ \l__MOdiagram_AO_up_electron_bool ||
+ \l__MOdiagram_AO_x_up_electron_bool
+ }
+ {
+ \__MOdiagram_AO_place_electron:nx { 0 }
+ { \tl_use:N \l__MOdiagram_AO_x_up_electron_tl }
+ }
+ \bool_if:nT
+ {
+ \l__MOdiagram_AO_down_electron_bool ||
+ \l__MOdiagram_AO_x_down_electron_bool
+ }
+ {
+ \__MOdiagram_AO_place_electron:nx { 1 }
+ { \tl_use:N \l__MOdiagram_AO_x_down_electron_tl }
+ }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_AO_px_electron_tl }
+ { \tl_use:N \l__MOdiagram_AO_x_electron_color_tl }
+ } ;
+ \__MOdiagram_AO_get_orbital_x_label:o
+ {
+ \tl_use:N \l__MOdiagram_AO_name_tl
+ \bool_if:NT \l__MOdiagram_AO_p_bool { x }
+ }
+ \bool_if:NT \l__MOdiagram_AO_p_bool
+ {
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ ( \tl_use:N \l__MOdiagram_AO_name_tl y )
+ at
+ (
+ \l__MOdiagram_AO_position_dim + \l__MOdiagram_atom_py_shift_dim ,
+ \l__MOdiagram_AO_dim
+ )
+ {
+ \bool_if:nT
+ {
+ \l__MOdiagram_AO_up_electron_bool ||
+ \l__MOdiagram_AO_y_up_electron_bool
+ }
+ {
+ \__MOdiagram_AO_place_electron:nx { 0 }
+ { \tl_use:N \l__MOdiagram_AO_y_up_electron_tl }
+ }
+ \bool_if:nT
+ {
+ \l__MOdiagram_AO_down_electron_bool ||
+ \l__MOdiagram_AO_y_down_electron_bool
+ }
+ {
+ \__MOdiagram_AO_place_electron:nx { 1 }
+ { \tl_use:N \l__MOdiagram_AO_y_down_electron_tl }
+ }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_AO_py_electron_tl }
+ { \tl_use:N \l__MOdiagram_AO_y_electron_color_tl }
+ } ;
+ % `o' expansion doesn't seem to make sense here:
+ \__MOdiagram_AO_get_orbital_y_label:o { \tl_use:N \l__MOdiagram_AO_name_tl y }
+ \__MOdiagram_node:n { inner~sep=0 , outer~sep=0 }
+ ( \tl_use:N \l__MOdiagram_AO_name_tl z )
+ at
+ (
+ \l__MOdiagram_AO_position_dim + \l__MOdiagram_atom_pz_shift_dim ,
+ \l__MOdiagram_AO_dim
+ )
+ {
+ \bool_if:nT
+ {
+ \l__MOdiagram_AO_up_electron_bool ||
+ \l__MOdiagram_AO_z_up_electron_bool
+ }
+ {
+ \__MOdiagram_AO_place_electron:nx { 0 }
+ { \tl_use:N \l__MOdiagram_AO_z_up_electron_tl }
+ }
+ \bool_if:nT
+ {
+ \l__MOdiagram_AO_down_electron_bool ||
+ \l__MOdiagram_AO_z_down_electron_bool
+ }
+ {
+ \__MOdiagram_AO_place_electron:nx { 1 }
+ { \tl_use:N \l__MOdiagram_AO_z_down_electron_tl }
+ }
+ \__MOdiagram_AO:ff
+ { \tl_use:N \l__MOdiagram_AO_pz_electron_tl }
+ { \tl_use:N \l__MOdiagram_AO_z_electron_color_tl }
+ } ;
+ \__MOdiagram_AO_get_orbital_z_label:o
+ { \tl_use:N \l__MOdiagram_AO_name_tl z }
+ }
+ \group_end:
+ }
+
+% --------------------------------------------------------------------------- %
+% connect arbitrary AOs / MOs
+\NewDocumentCommand \connect { m }
+ {
+ \clist_map_variable:nNn { #1 } \l__MOdiagram_tmpa_tl
+ {
+ \tl_remove_all:Nn \l__MOdiagram_tmpa_tl { ~ }
+ \tl_if_blank:VF \l__MOdiagram_tmpa_tl
+ {
+ \__MOdiagram_detect_nodes:x { \l__MOdiagram_tmpa_tl }
+ \tl_if_in:NnF \l__MOdiagram_node_A_tl { . }
+ { \tl_put_right:Nn \l__MOdiagram_node_A_tl { . east } }
+ \tl_if_in:NnF \l__MOdiagram_node_B_tl { . }
+ { \tl_put_right:Nn \l__MOdiagram_node_B_tl { . west } }
+ \__MOdiagram_draw_connection:xxx
+ { \tl_use:N \l__MOdiagram_lines_tl }
+ { \tl_use:N \l__MOdiagram_node_A_tl }
+ { \tl_use:N \l__MOdiagram_node_B_tl }
+ }
+ }
+ }
+
+\NewDocumentCommand \__MOdiagram_detect_nodes:n { > { \SplitArgument { 1 } { & } } m }
+ { \__MOdiagram_detect_nodes_aux_i:nn #1 }
+\cs_generate_variant:Nn \__MOdiagram_detect_nodes:n { x }
+
+\cs_new_protected:Npn \__MOdiagram_detect_nodes_aux_i:nn #1#2
+ {
+ \tl_set:Nn \l__MOdiagram_node_A_tl { #1 }
+ \tl_set:Nn \l__MOdiagram_node_B_tl { #2 }
+ }
+
+\cs_new:Npn \__MOdiagram_draw_connection:nnn #1#2#3
+ { \draw[#1] (#2) -- (#3) ; }
+\cs_generate_variant:Nn \__MOdiagram_draw_connection:nnn { xxx }
+
+% --------------------------------------------------------------------------- %
+% orbital labels
+\prop_new:N \l__MOdiagram_orbital_label_prop
+\tl_set:Nn \l__MOdiagram_orbital_label_fontsize_tl { \small }
+
+\cs_new:Npn \__MOdiagram_orbital_label_set:n #1
+ { \keys_set:nn { MOdiagram / label } { #1 } }
+
+\cs_new_protected:Npn \__MOdiagram_get_orbital_label:n #1
+ {
+ \tl_clear:N \l__MOdiagram_tmpa_tl
+ \tl_clear:N \l__MOdiagram_tmpb_tl
+ \prop_get:NnNT \l__MOdiagram_orbital_label_prop { #1 } \l__MOdiagram_tmpa_tl
+ {
+ \__MOdiagram_node:x
+ { below , \tl_use:N \l__MOdiagram_orbital_label_style_tl }
+ at ( #1 . south )
+ {
+ \tl_use:N \l__MOdiagram_orbital_label_fontsize_tl
+ \tl_use:N \l__MOdiagram_tmpa_tl
+ } ;
+ }
+ }
+
+\keys_define:nn { MOdiagram / label }
+ {
+ 1sleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 1sleft } { #1 } } ,
+ 1sright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 1sright } { #1 } } ,
+ 2sleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2sleft } { #1 } } ,
+ 2sright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2sright } { #1 } } ,
+ 2pxleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pxleft } { #1 } } ,
+ 2pxright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pxright } { #1 } } ,
+ 2pyleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pyleft } { #1 } } ,
+ 2pyright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pyright } { #1 } } ,
+ 2pzleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pzleft } { #1 } } ,
+ 2pzright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pzright } { #1 } } ,
+ 1sigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 1sigma } { #1 } } ,
+ 1sigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 1sigma* } { #1 } } ,
+ 2sigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2sigma } { #1 } } ,
+ 2sigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2sigma* } { #1 } } ,
+ 2psigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2psigma } { #1 } } ,
+ 2psigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2psigma* } { #1 } } ,
+ 2piy .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2piy } { #1 } } ,
+ 2piy* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2piy* } { #1 } } ,
+ 2piz .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2piz } { #1 } } ,
+ 2piz* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2piz* } { #1 } }
+ }
+
+\char_set_catcode_math_subscript:N \@
+\cs_new_protected:Npn \__MOdiagram_set_labels:
+ {
+ \bool_if:NT \l__MOdiagram_AO_labels_bool
+ {
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 1sleft } { 1s }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 1sright } { 1s }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2sleft } { 2s }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2sright } { 2s }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pxleft } { 2p$@x$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pxright } { 2p$@x$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pyleft } { 2p$@y$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pyright } { 2p$@y$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pzleft } { 2p$@z$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2pzright } { 2p$@z$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 1sigma } { 1\chemsigma$@s$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 1sigma* } { 1\chemsigma$^*@s$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2sigma } { 2\chemsigma$@s$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2sigma* } { 2\chemsigma$^*@s$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2psigma } { 2\chemsigma$@x$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2psigma* } { 2\chemsigma$^*@x$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2piy } { 2\chempi$@y$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2piy* } { 2\chempi$^*@y$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2piz } { 2\chempi$@z$ }
+ \prop_put:Nnn \l__MOdiagram_orbital_label_prop { 2piz* } { 2\chempi$^*@z$ }
+ }
+ }
+\char_set_catcode_letter:N \@
+
+% --------------------------------------------------------------------------- %
+% electron colours
+\prop_new:N \l__MOdiagram_electron_color_prop
+\tl_new:N \l__MOdiagram_electron_current_color_tl
+
+\cs_new:Npn \__MOdiagram_electron_color_set:n #1
+ { \keys_set:nn { MOdiagram / color } { #1 } }
+
+\cs_new_protected:Npn \__MOdiagram_get_electron_color:n #1
+ {
+ \tl_clear:N \l__MOdiagram_tmpa_tl
+ \tl_clear:N \l__MOdiagram_tmpb_tl
+ \prop_get:NnNT \l__MOdiagram_electron_color_prop { #1 } \l__MOdiagram_tmpa_tl
+ { \tl_set_eq:NN \l__MOdiagram_electron_current_color_tl \l__MOdiagram_tmpa_tl }
+ }
+
+\keys_define:nn { MOdiagram / color }
+ {
+ 1sleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 1sleft } { #1 } } ,
+ 1sright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 1sright } { #1 } } ,
+ 2sleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2sleft } { #1 } } ,
+ 2sright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2sright } { #1 } } ,
+ 2pxleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2pxleft } { #1 } } ,
+ 2pxright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2pxright } { #1 } } ,
+ 2pyleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2pyleft } { #1 } } ,
+ 2pyright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2pyright } { #1 } } ,
+ 2pzleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2pzleft } { #1 } } ,
+ 2pzright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2pzright } { #1 } } ,
+ 1sigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 1sigma } { #1 } } ,
+ 1sigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 1sigma* } { #1 } } ,
+ 2sigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2sigma } { #1 } } ,
+ 2sigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2sigma* } { #1 } } ,
+ 2psigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2psigma } { #1 } } ,
+ 2psigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2psigma* } { #1 } } ,
+ 2piy .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2piy } { #1 } } ,
+ 2piy* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2piy* } { #1 } } ,
+ 2piz .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2piz } { #1 } } ,
+ 2piz* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_color_prop { 2piz* } { #1 } }
+ }
+
+% --------------------------------------------------------------------------- %
+% electron positions
+\prop_new:N \l__MOdiagram_electron_up_prop
+
+\cs_new:Npn \__MOdiagram_electron_up_set:n #1
+ { \keys_set:nn { MOdiagram / up-pos } { #1 } }
+
+\cs_new_protected:Npn \__MOdiagram_get_electron_up:n #1
+ {
+ \tl_clear:N \l__MOdiagram_tmpa_tl
+ \tl_clear:N \l__MOdiagram_tmpb_tl
+ \prop_get:NnNT \l__MOdiagram_electron_up_prop { #1 } \l__MOdiagram_tmpa_tl
+ { \tl_set_eq:NN \l__MOdiagram_AO_up_electron_tl \l__MOdiagram_tmpa_tl }
+ }
+
+\keys_define:nn { MOdiagram / up-pos }
+ {
+ 1sleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 1sleft } { #1 } } ,
+ 1sright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 1sright } { #1 } } ,
+ 2sleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2sleft } { #1 } } ,
+ 2sright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2sright } { #1 } } ,
+ 2pxleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2pxleft } { #1 } } ,
+ 2pxright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2pxright } { #1 } } ,
+ 2pyleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2pyleft } { #1 } } ,
+ 2pyright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2pyright } { #1 } } ,
+ 2pzleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2pzleft } { #1 } } ,
+ 2pzright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2pzright } { #1 } } ,
+ 1sigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 1sigma } { #1 } } ,
+ 1sigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 1sigma* } { #1 } } ,
+ 2sigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2sigma } { #1 } } ,
+ 2sigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2sigma* } { #1 } } ,
+ 2psigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2psigma } { #1 } } ,
+ 2psigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2psigma* } { #1 } } ,
+ 2piy .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2piy } { #1 } } ,
+ 2piy* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2piy* } { #1 } } ,
+ 2piz .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2piz } { #1 } } ,
+ 2piz* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_up_prop { 2piz* } { #1 } }
+ }
+
+\prop_new:N \l__MOdiagram_electron_down_prop
+
+\cs_new:Npn \__MOdiagram_electron_down_set:n #1
+ { \keys_set:nn { MOdiagram / down-pos } { #1 } }
+
+\cs_new_protected:Npn \__MOdiagram_get_electron_down:n #1
+ {
+ \tl_clear:N \l__MOdiagram_tmpa_tl
+ \tl_clear:N \l__MOdiagram_tmpb_tl
+ \prop_get:NnNT \l__MOdiagram_electron_down_prop { #1 } \l__MOdiagram_tmpa_tl
+ { \tl_set_eq:NN \l__MOdiagram_AO_down_electron_tl \l__MOdiagram_tmpa_tl }
+ }
+
+\keys_define:nn { MOdiagram / down-pos }
+ {
+ 1sleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 1sleft } { #1 } } ,
+ 1sright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 1sright } { #1 } } ,
+ 2sleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2sleft } { #1 } } ,
+ 2sright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2sright } { #1 } } ,
+ 2pxleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2pxleft } { #1 } } ,
+ 2pxright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2pxright } { #1 } } ,
+ 2pyleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2pyleft } { #1 } } ,
+ 2pyright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2pyright } { #1 } } ,
+ 2pzleft .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2pzleft } { #1 } } ,
+ 2pzright .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2pzright } { #1 } } ,
+ 1sigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 1sigma } { #1 } } ,
+ 1sigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 1sigma* } { #1 } } ,
+ 2sigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2sigma } { #1 } } ,
+ 2sigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2sigma* } { #1 } } ,
+ 2psigma .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2psigma } { #1 } } ,
+ 2psigma* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2psigma* } { #1 } } ,
+ 2piy .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2piy } { #1 } } ,
+ 2piy* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2piy* } { #1 } } ,
+ 2piz .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2piz } { #1 } } ,
+ 2piz* .code:n =
+ { \prop_put:Nnn \l__MOdiagram_electron_down_prop { 2piz* } { #1 } }
+ }
+
+% --------------------------------------------------------------------------- %
+% energy axis
+\dim_new:N \l_energy_axis_dim
+\dim_set:Nn \l_energy_axis_dim { 0pt }
+
+\tl_new:N \l__MOdiagram_Eaxis_head_tl
+\tl_set:Nn \l__MOdiagram_Eaxis_head_tl { latex }
+\tl_new:N \l__MOdiagram_Eaxis_title_tl
+
+\bool_new:N \l__MOdiagram_Eaxis_title_bool
+\bool_set_false:N \l__MOdiagram_Eaxis_title_bool
+
+\NewDocumentCommand \__MOdiagram_EnergyAxis: { o }
+ {
+ \IfNoValueF { #1 } { \keys_set:nn { MOdiagram / axis } { #1 } }
+ \__MOdiagram_draw:f { - \tl_use:N \l__MOdiagram_Eaxis_head_tl }
+ (\l_energy_axis_dim , \g__MOdiagram_min_energy_dim - 1cm )
+ --
+ (\l_energy_axis_dim , \g__MOdiagram_max_energy_dim + 1cm )
+ \bool_if:NT \l__MOdiagram_Eaxis_title_bool
+ { node [ above ] { \tl_use:N \l__MOdiagram_Eaxis_title_tl } }
+ ;
+ }
+
+\keys_define:nn { MOdiagram / axis }
+ {
+ title .code:n =
+ {
+ \bool_set_true:N \l__MOdiagram_Eaxis_title_bool
+ \tl_set:Nn \l__MOdiagram_Eaxis_title_tl { #1 }
+ } ,
+ title .default:n = energy ,
+ head .tl_set:N = \l__MOdiagram_Eaxis_head_tl ,
+ head .default:n = >
+ }
+
+% --------------------------------------------------------------------------- %
+% tikz helper functions
+\cs_new:Npn \__MOdiagram_node:n #1
+ { \node [ #1 ] }
+\cs_generate_variant:Nn \__MOdiagram_node:n { f,x }
+
+\cs_new:Npn \__MOdiagram_draw:n #1
+ { \draw [ #1 ] }
+\cs_generate_variant:Nn \__MOdiagram_draw:n { f }
+
+\cs_new:Npn \__MOdiagram_tikz:nn #1
+ { \tikz [ #1 ] }
+\cs_generate_variant:Nn \__MOdiagram_tikz:nn { fn,xn }
+
+\cs_new:Npn \__MOdiagram_tikzpicture:n #1
+ { \tikzpicture [ #1 ] }
+\cs_generate_variant:Nn \__MOdiagram_tikzpicture:n { f }
+
+\tex_endinput:D
+
+% --------------------------------------------------------------------------- %
+Version history
+2011/09/25 version 0.1 - first upload to CTAN
+2011/10/27 version 0.2 - \atom, \molecule, \AO, \EnergyAxis only defined within
+ the MOdiagram environment
+ - bugfix in energy splitting process
+ - bugfix: wrong labelling of plain empty orbitals
+ - different values for energy gain and loss possible
+ - default values for the AO and MO; if empty values are
+ used, the ";" and "," can be omitted
+ - default node names for the arbitrary AOs
+ - horizontal shift of electrons possible
+ - customization of atom- and molecule names possible
+2013/04/28 version 0.2c - fix: adapt to deprecated expl3 command
+2014/05/12 version 0.2d - fix: adapt to deprecated expl3 command
+ - change dependency from `textgreek' to `chemgreek'
+2014/06/28 version 0.2e - fix: adapt to deprecated expl3 command
+2015/07/19 version 0.2f - fix: adapt to deprecated expl3 command
+2015/09/23 version 0.2g - fix: adapt to deprecated expl3 command
+
+TODO
+- 3s, 3p , 3sMO , 3pMO , 4s , sp3
+- energy axis: ticks? at orbital heights?
+- electron configuration
+- localisation for the energy axis title using the translator package
+- Default-Einheit (bislang cm) ändern können?
diff --git a/macros/latex/contrib/modiagram/modiagram_en.pdf b/macros/latex/contrib/modiagram/modiagram_en.pdf
new file mode 100644
index 0000000000..d63a233e3a
--- /dev/null
+++ b/macros/latex/contrib/modiagram/modiagram_en.pdf
Binary files differ
diff --git a/macros/latex/contrib/modiagram/modiagram_en.tex b/macros/latex/contrib/modiagram/modiagram_en.tex
new file mode 100644
index 0000000000..3d5cc900ed
--- /dev/null
+++ b/macros/latex/contrib/modiagram/modiagram_en.tex
@@ -0,0 +1,1282 @@
+% arara: pdflatex
+% arara: pdflatex
+% --------------------------------------------------------------------------
+% the MODIAGRAM package
+%
+% easy creation of molecular orbital diagrams
+%
+% --------------------------------------------------------------------------
+% Clemens Niederberger
+% Web: https://www.bitbucket.org/cgnieder/modiagram
+% E-Mail: contact@mychemistry.eu
+% --------------------------------------------------------------------------
+% If you have any ideas, questions, suggestions or bugs to report, please
+% feel free to contact me.
+% --------------------------------------------------------------------------
+% Copyright 2011--2015 Clemens Niederberger
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+%
+% The Current Maintainer of this work is Clemens Niederberger.
+%
+% This work consists of the files modiagram.sty, modiagram_en.tex,
+% README and the derived file modiagram_en.pdf.
+% --------------------------------------------------------------------------
+\documentclass[load-preamble+]{cnltx-doc}
+\usepackage[utf8]{inputenc}
+\usepackage{modiagram}
+
+\setcnltx{
+ package = modiagram ,
+ authors = Clemens Niederberger ,
+ email = contact@mychemistry.eu ,
+ url = https://bitbucket.org/cgnieder/modiagram/ ,
+ add-cmds = {
+ AO,
+ atom,
+ connect,
+ EnergyAxis,
+ molecule,
+ MOsetup
+ } ,
+ add-envs = { MOdiagram } ,
+ add-silent-cmds = {
+ ch,
+ draw,
+ chlewis,
+ node,
+ textcolor,
+ chemsigma,
+ chemSigma
+ } ,
+ abstract = {%
+ \begin{MOdiagram}[style=fancy,distance=7cm,AO-width=15pt,labels,names]
+ \atom[N]{left}{ 2p = {0;up,up,up} }
+ \atom[O]{right}{ 2p = {2;pair,up,up} }
+ \molecule[NO]{
+ 2pMO = {1.8,.4;pair,pair,pair,up},
+ color = { 2piy*=red }
+ }
+ \end{MOdiagram}
+ }
+}
+
+\defbibheading{bibliography}{\addsec{References}}
+
+\usepackage{booktabs}
+
+\usepackage{acro}
+\DeclareAcronym{AO}{
+ short = AO ,
+ long = atomic orbital
+}
+\DeclareAcronym{MO}{
+ short = MO ,
+ long = molecular orbital
+}
+
+\expandafter\def\csname libertine@figurestyle\endcsname{LF}
+\usepackage[libertine]{newtxmath}
+\expandafter\def\csname libertine@figurestyle\endcsname{OsF}
+
+\usepackage{chemmacros,chemformula}
+\chemsetup{
+ greek = newtx,
+ modules = units
+}
+\setchemformula{format=\libertineLF}
+
+\NewDocumentCommand \AOinline { o m }
+ {%
+ \begingroup
+ \IfNoValueTF{#1}
+ {\MOsetup{ style=square,AO-width=8pt }}%
+ {\MOsetup{ style=square,AO-width=8pt , #1 }}%
+ \begin{MOdiagram}
+ \AO{s}{0;#2}
+ \end{MOdiagram}%
+ \endgroup
+ }
+
+\newcommand*\TikZ{Ti\textit{k}Z}
+
+\begin{document}
+
+\section{Licence, Requirements}
+\license
+
+\modiagram\ uses \bnd{l3kernel}~\cite{bnd:l3kernel} and
+\bnd{l3packages}~\cite{bnd:l3packages}. It also uses \TikZ~\cite{pkg:pgf} and
+the package \pkg{chemgreek}~\cite{pkg:chemgreek} bundle. Additionally the
+\TikZ\ libraries \code{calc} and \code{arrows} are loaded. Knowledge of
+\TikZ\ is helpful.
+
+\section{Motivation}
+This package has been written as a reaction to a question on
+\url{http://tex.stackexchange.com/}. To be more precise: as a reaction to the
+question
+``\href{http://tex.stackexchange.com/questions/13863/molecular-orbital-diagrams-in-latex}%
+{Molecular orbital diagrams in LaTeX}.'' There it says
+\begin{cnltxquote}
+ I'm wondering if anyone has seen a package for drawing (qualitative)
+ molecular orbital splitting diagrams in \LaTeX? Or if there exist any
+ packages that can be easily re-purposed to this task?
+
+ Otherwise, I think I'll have a go at it in \TikZ.
+\end{cnltxquote}
+The problem was solved using \TikZ, since no package existed for that purpose.
+For one thing \modiagram\ is intended to fill this gap. I also found it very
+tedious, to make all this copying and pasting when I needed a second, third,
+\ldots\ diagram. \modiagram\ took care of that.
+
+
+\section{Main Commands}
+All molecular orbital (MO) diagrams are created using the environment
+\env{MOdiagram}{}.
+
+\subsection{The \cs*{atom} Command}
+\begin{commands}
+ \command{atom}[\oarg{name}\Marg{\meta{left}|\meta{right}}\marg{AO-spec}]
+ Place an \acs{AO} in the diagram. \meta{name} is caption of the atom,
+ \meta{left} and \meta{right} determine the placement in the diagram,
+ \meta{AO-spec} is the specification of the \ac{AO}.
+\end{commands}
+
+Let's take a look at an example:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{right}{
+ 1s = { 0; pair} ,
+ 2s = { 1; pair} ,
+ 2p = {1.5; up, down }
+ }
+ \end{MOdiagram}
+\end{example}
+
+As you can see, the argument \meta{AO-spec} is essential to create the actual
+orbitals and the electrons within. You can use these key/value pairs to specify
+what you need:
+\begin{options}
+ \keychoice{1s}{\{\meta{rel-energy}; \meta{el-spec}\}}
+ Energy level and electron specifications for the 1s orbital.
+ \keychoice{2s}{\{\meta{rel-energy}; \meta{el-spec}\}}
+ Energy level and electron specifications for the 2s orbital.
+ \keychoice{2p}{\{\meta{rel-energy}; \meta{x el-spec}{,} \meta{y el-spec}{,}
+ \meta{z el-spec}\}}
+ Energy level and electron specifications for the 2p orbitals.
+\end{options}
+\meta{el-spec} can have the values \code{pair}, \code{up} and \code{down} or
+can be left empty. \meta{rel-energy} actually is the $y$ coordinate and shifts
+the \ac{AO} vertically by \meta{rel-energy} \si{\centi\metre}.
+
+The argument \meta{left}/\meta{right} is important, when p~orbitals are used.
+For instance compare the following example to the one before:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left}{
+ 1s = { 0; pair} ,
+ 2s = { 1; pair} ,
+ 2p = {1.5; up, down }
+ }
+ \end{MOdiagram}
+\end{example}
+
+When both variants are used one can also see, that the right atom is shifted to
+the right (hence the naming). The right atom is shifted by \SI{4}{\centi\metre}
+per default and can be adjusted individually, see page~\pageref{option:distance}.
+\begin{example}
+ \begin{MOdiagram}
+ \atom{left}{
+ 1s = { 0; pair} ,
+ 2s = { 1; pair} ,
+ 2p = {1.5; up, down }
+ }
+ \atom{right}{
+ 1s = { 0; pair} ,
+ 2s = { 1; pair} ,
+ 2p = {1.5; up, down }
+ }
+ \end{MOdiagram}
+\end{example}
+With the command \cs{molecule} (section~\ref{ssec:molecule}) the reason for the
+shift becomes clear.
+
+Any of the arguments for the \ac{AO} can be left empty or be omitted.
+\begin{example}[side-by-side]
+ Without argument: default height, full:\par
+ \begin{MOdiagram}
+ \atom{left}{1s, 2s, 2p}
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ empty argument: default height, empty:\par
+ \begin{MOdiagram}
+ \atom{left}{1s=, 2s=, 2p=}
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ using some values:\par
+ \begin{MOdiagram}
+ \atom{left}{1s, 2s=1, 2p={;,up} }
+ \end{MOdiagram}
+\end{example}
+
+\subsection{The \cs*{molecule} Command}\label{ssec:molecule}
+\begin{commands}
+ \command{molecule}[\oarg{name}\marg{MO-spec}]
+ Place a \acs{MO} in the diagram. \meta{name} is caption of the molecule,
+ \meta{MO-spec} is the specification of the \ac{MO}.
+\end{commands}
+
+An example first:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left} { 1s = { 0; up } }
+ \atom{right}{ 1s = { 0; up } }
+ \molecule { 1sMO = {.75; pair } }
+ \end{MOdiagram}
+\end{example}
+The command \cs{molecule} connects the \acp{AO} with the bonding and
+anti-bondung \acp{MO}. \cs{molecule} can only be used \emph{after} one has
+set \emph{both} atoms since the orbitals that are to be connected must be
+known.
+
+The argument \meta{MO-spec} accepts a comma separated list of key/value pairs:
+\begin{options}
+ \keychoice{1sMO}{\{\meta{energy gain}/\meta{energy loss}; \meta{s
+ el-spec}{,} \meta{s* el-spec}\}}
+ connects the \acp{AO} specified by \option{1s}.
+ \keychoice{2sMO}{\{\meta{energy gain}/\meta{energy loss}; \meta{s
+ el-spec}{,} \meta{s* el-spec}\}}
+ connects the \acp{AO} specified by \option{2s}
+ \keychoice{2pMO}{\{\meta{s energy gain}/\meta{s energy loss}{,} \meta{p
+ energy gain}/\meta{p energy loss}; \meta{s el-spec}{,} \meta{py
+ el-spec}{,} \meta{pz el- spec}{,} \meta{py* el-spec}{,} \meta{pz*
+ el-spec}{,} \meta{s* el-spec}\}}
+ connects the \acp{AO} specified by \option{2p}.
+\end{options}
+
+Obviously the regarding \acp{AO} must have been set in order to connect them.
+This for example won't work:
+\begin{sourcecode}
+ \begin{MOdiagram}
+ \atom{left} { 1s = 0 }
+ \atom{right}{ 1s = 0 }
+ \molecule { 2sMO = .75 }
+ \end{MOdiagram}
+\end{sourcecode}
+The value used in \meta{energy gain} determines how many \si{\centi\metre} the
+bonding \ac{MO} lies below the lower \ac{AO} or how many \si{\centi\metre} the
+anti-bondung \ac{MO} lies above the higher \ac{AO}.
+
+\begin{example}[side-by-side]
+ same level:\par
+ \begin{MOdiagram}
+ \atom{left} { 1s = { 0; up } }
+ \atom{right}{ 1s = { 0; up } }
+ \molecule { 1sMO = {.75; pair } }
+ \end{MOdiagram}
+
+ different levels:\par
+ \begin{MOdiagram}
+ \atom{left} { 1s = { 0; up } }
+ \atom{right}{ 1s = { 1; up } }
+ \molecule { 1sMO = {.25; pair } }
+ \end{MOdiagram}
+\end{example}
+
+If you specify \meta{energy loss} you can create non-symmetrical splittings.
+Then, the first value (\meta{energy gain}) is used for the bonding \ac{MO} and
+the second value (\meta{energy loss}) is used for the anti-bonding \ac{MO}.
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left} { 1s = { 0; up } }
+ \atom{right}{ 1s = { 0; up } }
+ \molecule { 1sMO = {.75/.25; pair } }
+ \end{MOdiagram}
+
+ \begin{MOdiagram}
+ \atom{left} { 1s = { 0; up } }
+ \atom{right}{ 1s = { 1; up } }
+ \molecule { 1sMO = {.25/.75; pair } }
+ \end{MOdiagram}
+\end{example}
+
+Please be aware, that you have to specify \emph{two} such values or pairs with
+\option{2pMO}: the splitting of the \chemsigma\ orbitals and the splitting of
+the \chempi\ orbitals.
+\begin{example}
+ \begin{MOdiagram}
+ \atom{left} { 2p = { 0; up, up } }
+ \atom{right}{ 2p = { 1; up, up } }
+ \molecule { 2pMO = { 1.5, .75; pair, up, up } }
+ \end{MOdiagram}
+\end{example}
+
+The complete \ac{MO} diagram for triplett dioxygen now could look something
+like that:
+\begin{example}
+ \begin{MOdiagram}
+ \atom{left}{
+ 1s, 2s, 2p = {;pair,up,up}
+ }
+ \atom{right}{
+ 1s, 2s, 2p = {;pair,up,up}
+ }
+ \molecule{
+ 1sMO, 2sMO, 2pMO = {;pair,pair,pair,up,up}
+ }
+ \end{MOdiagram}
+\end{example}
+
+\subsection{The Naming Scheme}\label{Namensgebung}
+Since one wants to be able to put labels to the orbitals and since they are
+nodes in a \env*{tikzpicture}, the internal naming scheme is important. It
+closely follows the function:
+\begin{center}
+ \begin{MOdiagram}[
+ distance = 6cm,
+ AO-width = 20pt,
+ labels-fs = \ttfamily\footnotesize,
+ labels-style = {yshift=10pt}
+ ]
+ \atom{left}{
+ 1s = 0 ,
+ 2s = 2 ,
+ 2p = 5 ,
+ label = {
+ 1sleft = {1sleft} ,
+ 2sleft = {2sleft} ,
+ 2pxleft = {2pxleft} ,
+ 2pyleft = {2pyleft} ,
+ 2pzleft = {2pzleft}
+ }
+ }
+ \atom{right}{
+ 1s = 0 ,
+ 2s = 2 ,
+ 2p = 5 ,
+ label = {
+ 1sright = {1sright} ,
+ 2sright = {2sright} ,
+ 2pxright = {2pxright} ,
+ 2pyright = {2pyright} ,
+ 2pzright = {2pzright}
+ }
+ }
+ \molecule{
+ 1sMO = .5 ,
+ 2sMO = .5 ,
+ 2pMO = {1.5,.5} ,
+ label = {
+ 1sigma = {1sigma} ,
+ 1sigma* = {1sigma*} ,
+ 2sigma = {2sigma} ,
+ 2sigma* = {2sigma*} ,
+ 2psigma = {2psigma} ,
+ 2psigma* = {2psigma*} ,
+ 2piy = {2piy} ,
+ 2piy* = {2piy*} ,
+ 2piz = {2piz} ,
+ 2piz* = {2piz*}
+ }
+ }
+ \end{MOdiagram}
+\end{center}
+
+With these names it is possible to reference the orbitals with the known \TikZ
+commands:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left} { 1s = 0 }
+ \atom{right}{ 1s = 0 }
+ \molecule { 1sMO = .75 }
+ \draw[<->,red,semithick]
+ (1sigma.center) -- (1sigma*.center) ;
+ \draw[red]
+ (1sigma*) ++ (2cm,.5cm) node {splitting} ;
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}
+ \begin{MOdiagram}
+ \atom{left} { 1s = 0 }
+ \atom{right}{ 1s = 0 }
+ \molecule { 1sMO = .75 }
+ \draw[draw=blue,very thick,fill=blue!40,opacity=.5]
+ (1sigma*) circle (8pt);
+ \draw[<-,shorten <=8pt,shorten >=15pt,blue]
+ (1sigma*) --++(2,1) node {anti-bonding MO};
+ \end{MOdiagram}
+\end{example}
+
+\subsection{Placing AOs and MOs Arbitrarily}\label{ssec:AO_MO_irgendwo}
+The standard orbitals are not always sufficient in order to draw a correct
+\ac{MO} diagram. For example in the \ac{MO} diagram of \ch{XeF2} one would
+need the part that illustrates the interaction between the bonding and
+anti-bonding combination of two p orbitals of Flourine with one p orbital of
+Xenon:
+
+\begin{center}
+ \begin{MOdiagram}[names]
+ \atom[\chlewis{0.}{F}\hspace*{5mm}\chlewis{180.}{F}]{left}{
+ 1s=.2;up,up-el-pos={1sleft=.5}
+ }
+ \atom[Xe]{right}{1s=1.25;pair}
+ \molecule[\ch{XeF2}]{1sMO={1/.25;pair}}
+ \AO(1cm){s}{0;up}
+ \AO(3cm){s}{0;pair}
+ \connect{ AO1 & AO2 }
+ \node[right,xshift=4mm] at (1sigma) {\footnotesize bonding};
+ \node[above] at (AO2.90) {\footnotesize non-bonding};
+ \node[above] at (1sigma*.90) {\footnotesize anti-bonding};
+ \end{MOdiagram}
+\end{center}
+
+To create diagrams like this there is the following command, which draws a single
+\ac{AO}:
+\begin{commands}
+ \command{AO}[\oarg{name}\darg{xshift}\marg{type}\oarg{options}\Marg{\meta{energy};
+ \meta{el-spec}}]
+ Place an \acs{AO} in the diagram. \meta{<name>} (optional) is the name of
+ the node; if not specified, \code{AO\#} is used where \code{\#} is a
+ consecutive number. \meta{xshift} is the vertical position of the orbital(s),
+ a \TeX\ dimension. \meta{type} can be \code{s} or \code{p}.
+ \meta{options} is a list of key/value pairs with which the \ac{AO} can be
+ customized, see section~\ref{ssec:AO_anpassen}. \meta{AO-spec} is the
+ specification of the \ac{AO}.
+\end{commands}
+
+Depending on the \meta{type} one s or three p orbitals are drawn.
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \AO{s}{0;}
+ \AO(-20pt){p}{1;pair,up,down}
+ \end{MOdiagram}
+\end{example}
+
+If one wants to place such an \ac{AO} at the position of an atom, one has to
+know their \meta{xshift}. They have predefined values (also see
+section~\ref{orbital-positionen}):\label{xshift}
+\begin{itemize}
+ \item atom left: \SI{1}{\centi\metre}
+ \item molecule: \SI{3}{\centi\metre}
+ \item atom right: \SI{5}{\centi\metre}
+\end{itemize}
+
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left} {1s=0}
+ \atom{right}{1s=0}
+ \molecule {1sMO=1}
+ \AO(1cm){s}{2}
+ \AO(3cm){s}{2}
+ \AO(5cm){s}{2}
+ \end{MOdiagram}
+\end{example}
+
+Within the p orbitals there is an additional shift by \SI{20}{pt} per orbital.
+This is equivalent to a double shift by the length \code{AO-width} (see
+section~\ref{option:AO-width}):
+\begin{example}
+ \begin{MOdiagram}
+ \atom{left} {2p=0}
+ \atom{right}{2p=0}
+ % above the left atom:
+ \AO(1cm) {s}{ .5}
+ \AO(1cm-20pt){s}{ 1;up}
+ \AO(1cm-40pt){s}{1,5;down}
+ % above the right atom:
+ \AO(1cm) {s}{ .5}
+ \AO(5cm+20pt){s}{ 1;up}
+ \AO(5cm+40pt){s}{1.5;down}
+ \end{MOdiagram}
+\end{example}
+
+The \acp{AO} created with \cs{AO} also can be connected. For this you can use
+the \TikZ\ command \cs*{draw}, of course. You can use the predefined node
+names\ldots
+\begin{example}
+ \begin{MOdiagram}
+ \AO{s}{0} \AO(2cm){s}{1}
+ \AO{s}{2} \AO(2cm){s}{1.5}
+ \draw[red] (AO1.0) -- (AO2.180) (AO3.0) -- (AO4.180);
+ \end{MOdiagram}
+\end{example}
+\ldots\ or use own node names
+\begin{example}
+ \begin{MOdiagram}
+ \AO[a]{s}{0} \AO[b](2cm){s}{1}
+ \AO[c]{s}{2} \AO[d](2cm){s}{1.5}
+ \draw[red] (a.0) -- (b.180) (c.0) -- (d.180);
+ \end{MOdiagram}
+\end{example}
+
+The predefined names are \code{AO1}, \code{AO2} \etc for the type \code{s} and
+\code{AO1x}, \code{AO1y}, \code{AO1z}, \code{AO2x} \etc\ for the type
+\code{p}. Nodes of the type \code{p} get an \code{x}, \code{y} or \code{z} if
+you specify your own name, too.
+\begin{example}
+ \begin{MOdiagram}
+ \AO{p}{0}
+ \draw[<-,shorten >=5pt] (AO1y.-90) -- ++ (.5,-1) node {y};
+ \end{MOdiagram}
+ and
+ \begin{MOdiagram}
+ \AO[A]{p}{0}
+ \draw[<-,shorten >=5pt] (Ay.-90) -- ++ (.5,-1) node {y};
+ \end{MOdiagram}
+\end{example}
+
+However, if you want the lines to be drawn in the same style as the ones
+created by \cs{molecule}\footnote{which can be customized, see
+ page~\pageref{option:lines}}, you should use the command \cs{connect}.
+\begin{commands}
+ \command{connect}[\marg{AO-connect}]
+ Connects the specified \acp{AO}. \meta{AO-connect} is comma separated
+ list of node name pairs connected with \code{\&}.
+\end{commands}
+This command expects a comma separated list of node name pairs that are to be
+connected. The names have to be connected with a \code{\&}:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \AO{s}{0;} \AO(2cm){s}{1;}
+ \AO{s}{2;} \AO(2cm){s}{1.5;}
+ \connect{ AO1 & AO2, AO3 & AO4 }
+ \end{MOdiagram}
+\end{example}
+
+Some things still need to be said: \cs{connect} adds the anchor \code{east} to
+the first name and the anchor \code{west} to the second one. This means a
+connection only makes sense from the left to the right. However, you can add
+own anchors using the usual \TikZ\ way:
+\begin{example}
+ \begin{tikzpicture}
+ \draw (0,0) node (a) {a} ++ (1,0) node (b) {b}
+ ++ (0,1) node (c) {c} ++ (-1,0) node (d) {d} ;
+ \connect{ a.90 & d.-90, c.180 & d.0 }
+ \end{tikzpicture}
+\end{example}
+
+\subsection{The Positioning Scheme}\label{orbital-positionen}
+The figure below shows the values of the $x$ coordinates of the orbitals
+depending on the values of \meta{distance} (\meta{dist}) and \meta{AO-width}
+(\meta{AO}). In sections~\ref{option:distance} and \ref{option:AO-width} these
+lengths and how they can be changed are discussed.
+\begin{center}
+ \begin{MOdiagram}[
+ AO-width = 22pt ,
+ labels-fs = \ttfamily\tiny ,
+ labels-style = {text width=40pt,align=center,yshift=11pt}]
+ \atom{left}{
+ 1s = 0 ,
+ 2s = 2 ,
+ 2p = 5.5 ,
+ label = {
+ 1sleft = {1cm} ,
+ 2sleft = {1cm} ,
+ 2pxleft = {1cm - 4*\meta{AO}} ,
+ 2pyleft = {1cm - 2*\meta{AO}} ,
+ 2pzleft = {1cm}
+ }}
+ \atom{right}{
+ 1s = 0 ,
+ 2s = 2 ,
+ 2p = 5.5 ,
+ label = {
+ 1sright = {1cm + \meta{dist}} ,
+ 2sright = {1cm + \meta{dist}} ,
+ 2pxright = {1cm+ \meta{dist}} ,
+ 2pyright = {1cm + \meta{dist} + 2*\meta{AO}} ,
+ 2pzright = {1cm + \meta{dist} + 4*\meta{AO}}
+ }}
+ \molecule{
+ 1sMO = .5 ,
+ 2sMO = .5 ,
+ 2pMO = {2,.75} ,
+ label = {
+ 1sigma = {.5*\meta{dist} + 1cm} ,
+ 1sigma* = {.5*\meta{dist} + 1cm} ,
+ 2sigma = {.5*\meta{dist} + 1cm} ,
+ 2sigma* = {.5*\meta{dist} + 1cm} ,
+ 2psigma = {.5*\meta{dist} + 1cm} ,
+ 2psigma* = {.5*\meta{dist} + 1cm} ,
+ 2piy = {.5*\meta{dist} + 1cm - \meta{AO}} ,
+ 2piy* = {.5*\meta{dist} + 1cm - \meta{AO}} ,
+ 2piz = {.5*\meta{dist} + 1cm + \meta{AO}} ,
+ 2piz* = {.5*\meta{dist} + 1cm + \meta{AO}}
+ }
+ }
+ \end{MOdiagram}
+\end{center}
+
+\subsection{Default Values}
+If you leave the arguments (or better: values) for the specification of the
+\ac{AO} or \ac{MO} empty or omit them, default values are used. The table below
+shows you, which ones.
+\begin{center}
+ \small
+ \begin{tabular}{l>{\ttfamily}l>{\ttfamily}l>{\ttfamily}l}
+ \toprule &
+ \normalfont\bfseries\ac{AO}/\ac{MO} &
+ \normalfont\bfseries omitted &
+ \normalfont\bfseries empty \\
+ \midrule
+ syntax:
+ & & 1s & 1s= \\
+ \midrule
+ & 1s & \{0;pair\} & \{0;\} \\
+ & 2s & \{2;pair\} & \{2;\} \\
+ & 2p & \{5;pair,pair,pair\} & \{5;,{},\} \\
+ \midrule
+ & 1sMO & \{.5;pair,pair\} & \{.5;,\} \\
+ & 2sMO & \{.5;pair,pair\} & \{.5;,\} \\
+ & 2pMO & \{1.5,.5;pair,pair,pair,pair,pair,pair\} & \{1.5,.5;{},{},{},{},{},\} \\
+ \bottomrule
+ \end{tabular}
+\end{center}
+
+This is similar for the \cs{AO} command (page~\pageref{ssec:AO_MO_irgendwo});
+it needs a value for \meta{energy}, though.
+
+\begin{center}
+ \small
+ \begin{tabular}{>{\ttfamily}l>{\ttfamily}l>{\ttfamily}l}
+ \toprule
+ \bfseries\meta{type} & \bfseries \meta{el-spec} \\
+ \midrule
+ s & pair \\
+ p & pair,pair,pair \\
+ \bottomrule
+ \end{tabular}
+\end{center}
+
+Compare these examples:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left} { 1s={0;pair} }
+ \atom{right}{ 1s }
+ \end{MOdiagram}
+
+ \hrulefill
+
+ \begin{MOdiagram}
+ \atom{left}{ 1s=1 }
+ \atom{right}{ 1s= }
+ \end{MOdiagram}
+\end{example}
+
+\section{Customization}
+The options of the section~\ref{ssec:umgebungs_optionen} can be set global as
+package option, \ie, with \cs*{usepackage}\oarg{options}\Marg{modiagram}, or
+via the setup command \cs{MOsetup}\marg{options}.
+
+\subsection{Environment Options}\label{ssec:umgebungs_optionen}
+There are some options with which the layout of the \ac{MO} diagrams can be
+changed:
+\begin{options}
+ \keyval{style}{type}
+ change the style of the orbitals and the connecting lines,
+ section~\ref{option:style}.
+ \keyval{distance}{dim}
+ distance betwen left and right atom,
+ section~\ref{option:distance}.
+ \keyval{AO-width}{dim}
+ change the width of orbitals,
+ section~\ref{option:AO-width}.
+ \keyval{el-sep}{num}
+ distance between the electron pair arrows,
+ section~\ref{option:electrons}.
+ \keyval{up-el-pos}{num}
+ position of the spin-up arrow,
+ section~\ref{option:electrons}.
+ \keyval{down-el-pos}{num}
+ position of the spin-down arrow,
+ section~\ref{option:electrons}.
+ \keyval{lines}{tikz}
+ change the \TikZ\ style of the connecting lines,
+ section~\ref{option:lines}.
+ \keybool{names}
+ add captions to the atoms and the molecule,
+ section~\ref{option:names}.
+ \keyval{names-style}{tikz}
+ change the \TikZ\ style of the captions,
+ section~\ref{option:names_style}.
+ \keyval{names-style-add}{tikz}
+ change the \TikZ\ style of the captions,
+ section~\ref{option:names_style}.
+ \keybool{labels}
+ add default labels to the orbitals,
+ section~\ref{option:labels}.
+ \keyval{labels-fs}{cs}
+ change the font size of the labels,
+ section~\ref{option:labels-fs}.
+ \keyval{labels-style}{tikz}
+ change the \TikZ\ style of the labels,
+ section~\ref{option:labels-style}.
+\end{options}
+They all are discussed in the following sections. If they're used as options
+for the environment, they're set locally and only change that environment.
+\begin{sourcecode}
+ \begin{MOdiagram}[options]
+ ...
+ \end{MOdiagram}
+\end{sourcecode}
+
+\subsubsection{Option \option*{style}}\label{option:style}
+There are five different styles which can be chosen.
+\begin{itemize}
+ \item\keyis{style}{plain} \AOinline[style=plain]{pair} (default)
+ \item\keyis{style}{square} \AOinline[style=square]{pair}
+ \item\keyis{style}{circle} \AOinline[style=circle]{pair}
+ \item\keyis{style}{round} \AOinline[style=round]{pair}
+ \item\keyis{style}{fancy} \AOinline[style=fancy]{pair}
+\end{itemize}
+
+Let's take the \ac{MO} diagram of \ch{H2} to illustrate the different styles:
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[style=plain]% default
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[style=square]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[style=circle]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[style=round]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[style=fancy]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{Option \option*{distance}}\label{option:distance}
+Depending on labels and captions the \SI{4}{\centi\metre} by which the right
+and left atom are separated can be too small. With \key{distance}{dim} the
+length can be adjusted. This will change the position of the right atom to
+\code{1cm + \meta{dim}} and the position of the molecule is changed to
+\code{0.5*(1cm + \meta{dim})}, also see page~\pageref{xshift} and
+section~\ref{orbital-positionen}.
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[distance=6cm]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{Option \option*{AO-width}}\label{option:AO-width}
+The length \option{AO-width} sets the length of the horizontal line in a
+orbital displayed with the \code{plain} style. It's default value is
+\SI{10}{pt}.
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[AO-width=15pt]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[style=fancy,AO-width=15pt]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+By changing the value of \option{AO-width} the positions of the p and the
+\chempi\ orbitals also change, see section~\ref{orbital-positionen}.
+
+\subsubsection{Optionen \option*{el-sep}, \option*{up-el-pos} und
+ \option*{down-el-pos}}
+\label{option:electrons}
+
+These three options change the horizontal positions of the arrows representing
+the electrons in an \ac{AO}/\ac{MO}. The option \key{el-sep}{num} needs a
+value between \code{0} and \code{1}. \code{0} means \emph{no} distance between
+the arrows and \code{1} \emph{full} distance (with respect to the length
+\option{AO-width}, see section~\ref{option:AO-width}).
+
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[el-sep=.2]% default
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[el-sep=0]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[el-sep=1]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+The options \key{up-el-pos}{<num>} and \key{down-el-pos}{<num>} can be used
+alternatively to place the spin-up and spin-down electron, respectively.
+Again they need values between \code{0} and \code{1}. This time \code{0}
+means \emph{on the left} and \code{1} means \emph{on the right}.
+
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[up-el-pos=.4,down-el-pos=.6]% default
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[up-el-pos=.333,down-el-pos=.667]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[up-el-pos=.7,down-el-pos=.3]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{Option \option*{lines}}\label{option:lines}
+The option \option{lines} can be used to modify the \TikZ\ style of the
+connecting lines:
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[lines={gray,thin}]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{Option \option*{names}}\label{option:names}
+If you use the option \option{names} the atoms and the molecule get captions
+provided you have used the optional \meta{name} argument of \cs{atom} and/or
+\cs{molecule}.
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[names]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{Options \option*{names-style} and \option*{names-style-add}}\label{option:names_style}
+These options enable to customize the style of the captions of the atoms and
+of the molecule. By default this setting is used:
+\key{names-style}{anchor=base}\footnote{Please see ``\TikZ\ and PGF -- Manual
+ for Version 2.10'' p.\,183 section 16.4.4 (pgfmanual.pdf) for the meaning}.
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[names,names-style={draw=blue}]
+ \atom[p]{left} { 1s = {;up} }
+ \atom[b]{right}{ 1s = {;up} }
+ \molecule[\ch{X2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+With this the default setting is overwritten. As you can see it destroys the
+vertical alignment of the nodes. In order to avoid that you can for example
+specify \code{text height} and \code{text depth} yourself \ldots
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[names,names-style={text height=1.5ex, text depth=.25ex, draw=blue}]
+ \atom[p]{left} { 1s = {;up} }
+ \atom[b]{right}{ 1s = {;up} }
+ \molecule[\ch{X2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\ldots, add the \code{anchor} again \ldots
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[names,names-style={anchor=base, draw=blue}]
+ \atom[p]{left} { 1s = {;up} }
+ \atom[b]{right}{ 1s = {;up} }
+ \molecule[\ch{X2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\ldots\ or use the option \key{names-style-add}. It doesn't overwrite the
+current setting but appends the new declaration:
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[names,names-style-add={draw=blue}]
+ \atom[p]{left} { 1s = {;up} }
+ \atom[b]{right}{ 1s = {;up} }
+ \molecule[\ch{X2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}
+ % use package `chemmacros'
+ \MOsetup{
+ names,
+ names-style = {
+ text height = 2.5ex,
+ text depth = .5ex,
+ draw = blue!80,
+ rounded corners
+ }
+ }
+ \begin{MOdiagram}
+ \atom[p]{left} { 1s = {;up} }
+ \atom[b]{right}{ 1s = {;up} }
+ \molecule[\ch{X2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+ \begin{MOdiagram}[names-style-add={fill=blue!20}]
+ \atom[p]{left} { 1s = {;up} }
+ \atom[b]{right}{ 1s = {;up} }
+ \molecule[\ch{X2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{Option \option*{labels}}\label{option:labels}
+If you use the option \option{labels} predefined labels are written below the
+orbitals. These labels can be changed, see section~\ref{sec:key:label}.
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[labels]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{Option \option*{labels-fs}}\label{option:labels-fs}
+Labels are set with the font size \cs*{small}. If you want to change that you
+can use the option \option{labels-fs}.
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[labels,labels-fs=\footnotesize]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+This also allows you to change the font style or font shape of the labels.
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[labels,labels-fs=\sffamily\footnotesize]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{Option \option*{labels-style}}\label{option:labels-style}
+The option \option{labels-style} changes the \TikZ\ style of the nodes within
+which the labels are written.
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[labels,labels-style={blue,yshift=4pt}]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{ 1sMO = {.75;pair} }
+ \end{MOdiagram}
+\end{example}
+
+\subsection{\cs*{atom} and \cs*{molecule} Specific Customizations}
+\subsubsection{The \option*{label} Key}\label{sec:key:label}
+If you don't want to use the predefined labels, change single labels or use
+only one or two labels, you can use the key \option{label}. This option is
+used in the \cs{atom} and \cs{molecule} commands in the \meta{AO-spec} or
+\meta{MO-spec} argument, respectively. The key awaits a comma separated
+key/value list. The names mentioned in section~\ref{Namensgebung} are used as
+keys to specify the \ac{AO} that you want to label.
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[labels-fs=\footnotesize]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{
+ 1sMO = {.75;pair},
+ label = { 1sigma = {bonding MO} }
+ }
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ \begin{MOdiagram}[style=square,distance=6cm]
+ \atom{left} { 1s = {;up} }
+ \atom{right}{ 1s = {;up} }
+ \molecule{
+ 1sMO = {.75;pair} ,
+ label = {
+ 1sigma = \chemsigma,
+ 1sigma* = \chemsigma$^*$
+ }
+ }
+ \node[right] at (1sigma.-45) {bonding};
+ \node[right] at (1sigma*.45) {anti-bonding};
+ \end{MOdiagram}
+\end{example}
+
+If the option is used together with the \option{labels} option
+(page~\pageref{option:labels}) single labels are overwritten:
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[labels]
+ \atom[H]{left} { 1s = {;up} }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{
+ 1sMO = {.75;pair},
+ label = { 1sigma = \textcolor{red}{??} }
+ }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{The \option*{color} Key}\label{sec:key:color}
+Analogous to the \option{label} key the \option{color} key can be used to
+display coloured electrons:
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}[labels-fs=\footnotesize]
+ \atom[H]{left}{
+ 1s, color = { 1sleft = blue }
+ }
+ \atom[H]{right}{
+ 1s, color = { 1sright = red }
+ }
+ \molecule[\ch{H2}]{
+ 1sMO,
+ label = { 1sigma = {bonding MO} },
+ color = { 1sigma = green, 1sigma* = cyan }
+ }
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{The \option*{up-el-pos} and \option*{down-el-pos} keys}\label{sec:key:electrons}
+The options \option{up-el-pos} and \option{down-el-pos} allow it to shift the
+arrows representing the electrons in a single \ac{AO} or \ac{MO} individually.
+You need to use values between \code{0} and \code{1}, also see
+section~\ref{option:electrons}.
+\begin{example}[side-by-side]
+ % use package `chemmacros'
+ \begin{MOdiagram}
+ \atom[H]{left}{
+ 1s = {;up},
+ up-el-pos = { 1sleft=.5 }
+ }
+ \atom[H]{right}{ 1s = {;up} }
+ \molecule[\ch{H2}]{
+ 1sMO = {.75;pair} ,
+ up-el-pos = { 1sigma=.15 } ,
+ down-el-pos = { 1sigma=.85 }
+ }
+ \end{MOdiagram}
+\end{example}
+
+\subsection{\cs*{AO} Specific Customizations}\label{ssec:AO_anpassen}
+These keys enable to customize orbitals created with \cs{AO}.
+
+\subsubsection{The \option*{label} Key}\label{key:AO_label}
+The key \option{label}\Oarg{\meta{x}/\meta{y}/\meta{z}} allows you to put a
+label to the \ac{AO}/\ac{MO}. If you use the type \code{p} you can specify
+the orbital you want to label in square brackets:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}[style=square]
+ \AO{s}[label={s orbital}]{0}
+ \AO{p}[label[y]=py,label[z]=pz]{1.5}
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{The \option*{color} Key}\label{key:AO_color}
+Analogous to the \option{label} key there is the key
+\option{color}\Oarg{\meta{x}/\meta{y}/\meta{z}} which enables you to choose a
+color for the electrons. If you use the type \code{p} you can specify the
+orbital in square brackets:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}[style=square]
+ \AO{s}[color=red]{0}
+ \AO{p}[color[y]=green,color[z]=cyan]{1.5}
+ \end{MOdiagram}
+\end{example}
+
+\subsubsection{The \option*{up-el-pos} and \option*{down-el-pos} Keys}\label{key:AO_electrons}
+Then there are the keys \option{up-el-pos}\Oarg{\meta{x}/\meta{y}/\meta{z}}
+and \option{down-el-pos}\Oarg{\meta{x}/\meta{y}/\meta{z}} with which the
+electrons can be shifted horizontally. You can use values between \code{0}
+and \code{1}, also see section~\ref{option:electrons}. If you use the type
+\code{p} you can specify the orbital in square brackets:
+\begin{example}[side-by-side]
+ \begin{MOdiagram}[style=square]
+ \AO{s}[up-el-pos=.15]{0}
+ \AO{p}[up-el-pos[y]=.15,down-el-pos[z]=.15]{1.5}
+ \end{MOdiagram}
+\end{example}
+
+\subsection{Energy Axis}
+Last but not least one might want to add an energy axis to the diagram. For
+this there is the command \cs{EnergyAxis}.
+
+\begin{commands}
+ \command{EnergyAxis}[\oarg{option}]
+ Adds an energy axis to the diagram. \meta{options} are key/value pairs to
+ modify the axis.
+\end{commands}
+
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left} { 1s = {;up} }
+ \atom{right}{ 1s = {;up} }
+ \molecule{ 1sMO = {.75;pair} }
+ \EnergyAxis
+ \end{MOdiagram}
+\end{example}
+
+For the time being there are two options to modify the axis.
+\begin{options}
+ \keyval{title}{title}\Default{energy}
+ the axis label. If used without value the default is used.
+ \keyval{head}{tikz arrow head}\Default{>}
+ the arrow head; you can use the arrow heads specified in the \TikZ\ library
+ \code{arrows} (pgfmanual v2.10 pages 256ff.)
+\end{options}
+
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left} { 1s = {;up} }
+ \atom{right}{ 1s = {;up} }
+ \molecule{ 1sMO = {.75;pair} }
+ \EnergyAxis[title]
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[side-by-side]
+ \begin{MOdiagram}
+ \atom{left} { 1s = {;up} }
+ \atom{right}{ 1s = {;up} }
+ \molecule{ 1sMO = {.75;pair} }
+ \EnergyAxis[title=E,head=stealth]
+ \end{MOdiagram}
+\end{example}
+
+\section{Examples}
+The example from the beginning of section \ref{ssec:AO_MO_irgendwo}.
+\begin{example}
+ % use package `chemmacros'
+ \begin{MOdiagram}[names]
+ \atom[\chlewis{0.}{F}\hspace*{5mm}\chlewis{180.}{F}]{left}{
+ 1s=.2;up,up-el-pos={1sleft=.5}
+ }
+ \atom[Xe]{right}{1s=1.25;pair}
+ \molecule[\ch{XeF2}]{1sMO={1/.25;pair}}
+ \AO(1cm){s}{0;up}
+ \AO(3cm){s}{0;pair}
+ \connect{ AO1 & AO2 }
+ \node[right,xshift=4mm] at (1sigma) {\footnotesize bonding};
+ \node[above] at (AO2.90) {\footnotesize non-bonding};
+ \node[above] at (1sigma*.90) {\footnotesize anti-bonding};
+ \end{MOdiagram}
+\end{example}
+
+\begin{example}[outside]
+ % use package `chemmacros'
+ \begin{figure}[p]
+ \centering
+ \begin{MOdiagram}[style=square,labels,names,AO-width=8pt,labels-fs=\footnotesize]
+ \atom[\ch{O_a}]{left}{
+ 1s, 2s, 2p = {;pair,up,up}
+ }
+ \atom[\ch{O_b}]{right}{
+ 1s, 2s, 2p = {;pair,up,up}
+ }
+ \molecule[\ch{O2}]{
+ 1sMO, 2sMO, 2pMO = {;pair,pair,pair,up,up},
+ color = { 2piy*=red, 2piz*=red }
+ }
+ \EnergyAxis
+ \end{MOdiagram}
+ \caption{MO diagram of \ch{^3 "\chemSigma-" O2}.}
+ \end{figure}
+\end{example}
+
+\begin{example}[outside]
+ % use package `chemmacros'
+ \begin{figure}[p]
+ \centering
+ \MOsetup{style = fancy, distance = 7cm, AO-width = 15pt, labels}
+ \begin{MOdiagram}
+ \atom[N]{left}{
+ 2p = {0;up,up,up}
+ }
+ \atom[O]{right}{
+ 2p = {2;pair,up,up}
+ }
+ \molecule[NO]{
+ 2pMO = {1.8,.4;pair,pair,pair,up},
+ color = { 2piy*=red }
+ }
+ \EnergyAxis
+ \end{MOdiagram}
+ \caption{Part of the MO diagram of \chlewis{180.}{NO}.}
+ \end{figure}
+\end{example}
+
+\clearpage
+
+\end{document}