diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-29 23:21:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-29 23:21:30 +0000 |
commit | 966c0674997ff51e5ea9e4a79e6c873c4d93a9cf (patch) | |
tree | 5be91b484cec2431f63e8717793dcbe83538090c /Master/texmf-dist/tex/latex/chemmacros | |
parent | 13bacf6392e96e4d46c40e1d4b50b9e70055fb18 (diff) |
chemmacros (29jan13)
git-svn-id: svn://tug.org/texlive/trunk@28982 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros')
3 files changed, 751 insertions, 670 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty index d1ec7350dc8..630992621cd 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty @@ -99,6 +99,7 @@ \int_new:N \l__chemformula_tmpa_int \int_new:N \l__chemformula_tmpb_int \box_new:N \l__chemformula_tmpa_box +\box_new:N \l__chemformula_tmpb_box %-----------------------------------------------------------------------------% % gobble options @@ -291,16 +292,16 @@ \tl_set:Nn \l__chemformula_arrow_ratio_tl { .6 } \dim_new:N \l__chemformula_arrow_offset_dim -\dim_set:Nn \l__chemformula_arrow_offset_dim { 1.5ex } +\dim_set:Nn \l__chemformula_arrow_offset_dim { .75em } \dim_new:N \l__chemformula_compound_sep_dim -\dim_set:Nn \l__chemformula_compound_sep_dim { \medskipamount } +\dim_set:Nn \l__chemformula_compound_sep_dim { .5em } \dim_new:N \l__chemformula_arrow_yshift_dim \dim_set:Nn \l__chemformula_arrow_yshift_dim { 0pt } % determine length in dependency of labels -\cs_new:Npn \chemformula_determine_arrow_length:nn #1#2 +\cs_new:Npn \chemformula_determine_arrow_length:NN #1#2 { \box_set_eq:NN \l__chemformula_tmpa_box #1 \dim_set:Nn \l__chemformula_tmpa_dim { \box_wd:N \l__chemformula_tmpa_box } @@ -330,19 +331,19 @@ %-----------------------------------------------------------------------------% % define arrow types -\tl_new:N \l__chemformula_arrow_head_tl +\tl_new:N \l__chemformula_arrow_head_tl \tl_set:Nn \l__chemformula_arrow_head_tl { cf } -\tl_new:N \l__chemformula_upper_label_tl -\tl_new:N \l__chemformula_lower_label_tl -\tl_new:N \l__chemformula_arrow_style_tl -\tl_new:N \l__chemformula_arrow_label_style_tl +\tl_new:N \l__chemformula_upper_label_tl +\tl_new:N \l__chemformula_lower_label_tl +\tl_new:N \l__chemformula_arrow_style_tl +\tl_new:N \l__chemformula_arrow_label_style_tl \tl_set:Nn \l__chemformula_arrow_label_style_tl { \footnotesize } \prop_new:N \l__chemformula_arrows_code_prop -\seq_new:N \l__chemformula_arrows_type_seq -\tl_new:N \l__chemformula_arrow_type_tl -\box_new:N \l__chemformula_arrow_arg_i_box -\box_new:N \l__chemformula_arrow_arg_ii_box +\seq_new:N \l__chemformula_arrows_type_seq +\tl_new:N \l__chemformula_arrow_type_tl +\box_new:N \l__chemformula_arrow_arg_i_box +\box_new:N \l__chemformula_arrow_arg_ii_box % read optional arguments \cs_new_nopar:Npn \l__chemformula_arrow_read_args:w @@ -392,9 +393,11 @@ % draw the arrows \cs_new_nopar:Npn \chemformula_arrow_draw:n #1 { + \chemmacros_allow_break: % prepare arrow code for drawing: % TODO: flexible Pfeilspitzen, TikZ-Keys ermöglichen - \tl_set_rescan:Nnn \l__chemformula_tmpc_tl { \char_set_catcode_letter:N \_ } { #1 } + \tl_set_rescan:Nnn \l__chemformula_tmpc_tl + { \char_set_catcode_letter:N \_ } { #1 } % determine length of the arrow \chemformula_determine_arrow_length:NN \l__chemformula_arrow_arg_i_box @@ -431,9 +434,9 @@ ; \tl_use:N \l__chemformula_tmpc_tl } + \chemmacros_allow_break: } \cs_generate_variant:Nn \chemformula_arrow_draw:n { V } -\cs_generate_variant:Nn \chemformula_determine_arrow_length:nn { NN } % commands to declare arrows (can also be used by users): % #1: symbol, #2: code @@ -637,10 +640,10 @@ \mode_if_math:TF { \mathchoice - { \hbox:n { #1 } } - { \hbox:n { #1 } } - { \hbox:n { \scriptsize #1 } } - { \hbox:n { \tiny #1 } } + { \text { #1 } } + { \text { #1 } } + { \text { \scriptsize #1 } } + { \text { \tiny #1 } } } { #1 } } @@ -677,6 +680,7 @@ \cs_new:Npn \chemformula_name_cmpd:w { \peek_meaning:NTF ( { \chemformula_name_cmpd_aux:w } { ! } } +% TODO % this is no document command -- but now nesting of brackets is possible \NewDocumentCommand \chemformula_name_cmpd_aux:w {r()r()} { @@ -685,7 +689,7 @@ { \bool_if:NF \l__chemformula_name_width_bool { - \chemformula_width_to_dim:Nn \l__chemformula_name_dim + \chemmacros_dim_to_width:Nn \l__chemformula_name_dim { \l__chemformula_name_format_tl #1 } } \parbox @@ -696,13 +700,6 @@ \) } -\cs_new:Npn \chemformula_width_to_dim:Nn #1#2 - { - \hbox_set:Nn \l__chemformula_tmpa_box { #2 } - \dim_set:Nn #1 { \box_wd:N \l__chemformula_tmpa_box } - \box_clear:N \l__chemformula_tmpa_box - } - \cs_new:Npn \chemformula_generate_name:n #1 { \tl_set:Nn \l__chemformula_tmpa_tl { #1 } @@ -754,67 +751,58 @@ \bool_new:N \l__chemformula_charge_full_shift_bool % token lists: -\tl_new:N \l__chemformula_chemformula_tmpa_tl -\tl_new:N \g__chemformula_options_tl -\tl_new:N \g__chemformula_output_tl -\tl_new:N \l__chemformula_output_tl -\tl_new:N \l__chemformula_input_tl -\tl_new:N \l__chemformula_stoich_tl -\tl_new:N \l__chemformula_decimal_output_tl - \tl_set:Nn \l__chemformula_decimal_output_tl { . } -\tl_new:N \l__chemformula_font_family_tl - \tl_set_eq:NN \l__chemformula_font_family_tl \f@family +\tl_new:N \l__chemformula_chemformula_tmpa_tl +\tl_new:N \g__chemformula_options_tl +\tl_new:N \g__chemformula_output_tl +\tl_new:N \l__chemformula_output_tl +\tl_new:N \l__chemformula_input_tl +\tl_new:N \l__chemformula_stoich_tl +\tl_new:N \l__chemformula_decimal_output_tl +\tl_set:Nn \l__chemformula_decimal_output_tl { . } +\tl_new:N \l__chemformula_font_family_tl +\tl_set_eq:NN \l__chemformula_font_family_tl \f@family \tl_new:N \l__chemformula_font_series_tl - \tl_set_eq:NN \l__chemformula_font_series_tl \f@series +\tl_set_eq:NN \l__chemformula_font_series_tl \f@series \tl_new:N \l__chemformula_font_shape_tl - \tl_set_eq:NN \l__chemformula_font_shape_tl \f@shape -\tl_new:N \l__chemformula_format_tl -\tl_new:N \l__chemformula_fontspec_options_tl -\tl_new:N \l__chemformula_fontspec_argument_tl -\tl_new:N \l__chemformula_name_format_tl - \tl_set:Nn \l__chemformula_name_format_tl { \scriptsize\centering } -\tl_new:N \l_chemormula_sup_super_factor_tl - -\tl_new:N \l__chemformula_bond_style_tl - -% dimensions: -\dim_new:N \l__chemformula_stoich_space_dim - \dim_set:Nn \l__chemformula_stoich_space_dim { .1667em } -\dim_new:N \l__chemformula_math_space_dim - \dim_set:Nn \l__chemformula_math_space_dim { .1667em } -\dim_new:N \l__chemformula_plus_space_dim - \dim_set:Nn \l__chemformula_plus_space_dim { .3em } -\dim_new:N \l__chemformula_cdot_space_dim - \dim_set:Nn \l__chemformula_cdot_space_dim { .1333em } -\dim_new:N \l__chemformula_charge_shift_dim - \dim_set:Nn \l__chemformula_charge_shift_dim { .5ex } -\dim_new:N \l__chemformula_subscript_shift_default_dim - \dim_set:Nn \l__chemformula_subscript_shift_default_dim { -.65ex } -\dim_new:N \l__chemformula_subscript_shift_dim - \dim_set_eq:NN - \l__chemformula_subscript_shift_dim - \l__chemformula_subscript_shift_default_dim -\dim_new:N \l__chemformula_subscript_shift_additional_dim -\dim_new:N \l__chemformula_superscript_shift_default_dim - \dim_set:Nn \l__chemformula_superscript_shift_default_dim { .8ex } -\dim_new:N \l__chemformula_superscript_shift_dim - \dim_set_eq:NN - \l__chemformula_superscript_shift_dim - \l__chemformula_superscript_shift_default_dim -\dim_new:N \l__chemformula_superscript_shift_additional_dim -\dim_new:N \l__chemformula_subscript_dim - \dim_zero:N \l__chemformula_subscript_dim -\dim_new:N \l__chemformula_superscript_dim - \dim_zero:N \l__chemformula_superscript_dim -\dim_new:N \l__chemformula_bond_dim - \dim_set:Nn \l__chemformula_bond_dim { 1.1667ex } +\tl_set_eq:NN \l__chemformula_font_shape_tl \f@shape +\tl_new:N \l__chemformula_format_tl +\tl_new:N \l__chemformula_fontspec_options_tl +\tl_new:N \l__chemformula_fontspec_argument_tl +\tl_new:N \l__chemformula_name_format_tl +\tl_set:Nn \l__chemformula_name_format_tl { \scriptsize\centering } +\tl_new:N \l_chemormula_sup_super_factor_tl +\tl_new:N \l__chemformula_subscript_shift_additional_tl +\tl_set:Nn \l__chemformula_subscript_shift_additional_tl { 0pt } +\tl_new:N \l__chemformula_superscript_shift_additional_tl +\tl_set:Nn \l__chemformula_superscript_shift_additional_tl { 0pt } +\tl_new:N \l__chemformula_bond_style_tl + +% dimensions and skips: +\skip_new:N \l__chemformula_stoich_space_skip +\skip_set:Nn \l__chemformula_stoich_space_skip { .1667em plus .0333em minus .0117em } +\skip_new:N \l__chemformula_math_space_skip +\skip_set:Nn \l__chemformula_math_space_skip { .1667em plus .0333em minus .0117em } +\skip_new:N \l__chemformula_plus_space_skip +\skip_set:Nn \l__chemformula_plus_space_skip { .3em plus .1em minus .1em } +\dim_new:N \l__chemformula_cdot_space_dim +\dim_set:Nn \l__chemformula_cdot_space_dim { .1333em } +\dim_new:N \l__chemformula_charge_shift_dim +\dim_set:Nn \l__chemformula_charge_shift_dim { .5ex } +\dim_new:N \l__chemformula_subscript_shift_dim +\dim_new:N \l__chemformula_superscript_shift_dim +\dim_new:N \l__chemformula_subscript_dim +\dim_zero:N \l__chemformula_subscript_dim +\dim_new:N \l__chemformula_superscript_dim +\dim_zero:N \l__chemformula_superscript_dim +\dim_new:N \l__chemformula_bond_dim +\dim_set:Nn \l__chemformula_bond_dim { .5833em } % integers: \int_new:N \l__chemformula_count_tokens_int % property lists: % behaviour in a compound -\prop_new:N \l__chemformula_cmpd_prop +\prop_new:N \l__chemformula_cmpd_prop \prop_put:Nnn \l__chemformula_cmpd_prop { 0 } { \chemformula_subscript:n { 0 } } \prop_put:Nnn \l__chemformula_cmpd_prop { 1 } { \chemformula_subscript:n { 1 } } \prop_put:Nnn \l__chemformula_cmpd_prop { 2 } { \chemformula_subscript:n { 2 } } @@ -832,7 +820,7 @@ \prop_put:Nnn \l__chemformula_cmpd_prop { + } { \chemformula_triple_bond: } % numbers -\prop_new:N \l__chemformula_numbers_prop +\prop_new:N \l__chemformula_numbers_prop \prop_put:Nnn \l__chemformula_numbers_prop { 0 } { 0 } \prop_put:Nnn \l__chemformula_numbers_prop { 1 } { 1 } \prop_put:Nnn \l__chemformula_numbers_prop { 2 } { 2 } @@ -845,33 +833,23 @@ \prop_put:Nnn \l__chemformula_numbers_prop { 9 } { 9 } % behaviour in a charge -\prop_new:N \l__chemformula_charge_prop -\prop_put:Nnn \l__chemformula_charge_prop { 0 } - { \chemformula_charge_style:n { 0 } } -\prop_put:Nnn \l__chemformula_charge_prop { 1 } - { \chemformula_charge_style:n { 1 } } -\prop_put:Nnn \l__chemformula_charge_prop { 2 } - { \chemformula_charge_style:n { 2 } } -\prop_put:Nnn \l__chemformula_charge_prop { 3 } - { \chemformula_charge_style:n { 3 } } -\prop_put:Nnn \l__chemformula_charge_prop { 4 } - { \chemformula_charge_style:n { 4 } } -\prop_put:Nnn \l__chemformula_charge_prop { 5 } - { \chemformula_charge_style:n { 5 } } -\prop_put:Nnn \l__chemformula_charge_prop { 6 } - { \chemformula_charge_style:n { 6 } } -\prop_put:Nnn \l__chemformula_charge_prop { 7 } - { \chemformula_charge_style:n { 7 } } -\prop_put:Nnn \l__chemformula_charge_prop { 8 } - { \chemformula_charge_style:n { 8 } } -\prop_put:Nnn \l__chemformula_charge_prop { 9 } - { \chemformula_charge_style:n { 9 } } +\prop_new:N \l__chemformula_charge_prop +\prop_put:Nnn \l__chemformula_charge_prop { 0 } { \chemformula_charge_style:n { 0 } } +\prop_put:Nnn \l__chemformula_charge_prop { 1 } { \chemformula_charge_style:n { 1 } } +\prop_put:Nnn \l__chemformula_charge_prop { 2 } { \chemformula_charge_style:n { 2 } } +\prop_put:Nnn \l__chemformula_charge_prop { 3 } { \chemformula_charge_style:n { 3 } } +\prop_put:Nnn \l__chemformula_charge_prop { 4 } { \chemformula_charge_style:n { 4 } } +\prop_put:Nnn \l__chemformula_charge_prop { 5 } { \chemformula_charge_style:n { 5 } } +\prop_put:Nnn \l__chemformula_charge_prop { 6 } { \chemformula_charge_style:n { 6 } } +\prop_put:Nnn \l__chemformula_charge_prop { 7 } { \chemformula_charge_style:n { 7 } } +\prop_put:Nnn \l__chemformula_charge_prop { 8 } { \chemformula_charge_style:n { 8 } } +\prop_put:Nnn \l__chemformula_charge_prop { 9 } { \chemformula_charge_style:n { 9 } } \prop_put:Nnn \l__chemformula_charge_prop { + } { \chemformula_plus: } \prop_put:Nnn \l__chemformula_charge_prop { - } { \chemformula_minus: } \prop_put:Nnn \l__chemformula_charge_prop { . } { \chemformula_radical: } % stoichiometric factors -\prop_new:N \l__chemformula_stoich_prop +\prop_new:N \l__chemformula_stoich_prop \prop_put:Nnn \l__chemformula_stoich_prop { 0 } { 0 } \prop_put:Nnn \l__chemformula_stoich_prop { 1 } { 1 } \prop_put:Nnn \l__chemformula_stoich_prop { 2 } { 2 } @@ -882,10 +860,8 @@ \prop_put:Nnn \l__chemformula_stoich_prop { 7 } { 7 } \prop_put:Nnn \l__chemformula_stoich_prop { 8 } { 8 } \prop_put:Nnn \l__chemformula_stoich_prop { 9 } { 9 } -\prop_put:Nnn \l__chemformula_stoich_prop { . } - { { \l__chemformula_decimal_output_tl } } -\prop_put:Nnn \l__chemformula_stoich_prop { , } - { { \l__chemformula_decimal_output_tl } } +\prop_put:Nnn \l__chemformula_stoich_prop { . } { { \l__chemformula_decimal_output_tl } } +\prop_put:Nnn \l__chemformula_stoich_prop { , } { { \l__chemformula_decimal_output_tl } } \prop_put:Nnn \l__chemformula_stoich_prop { / } { / } \prop_put:Nnn \l__chemformula_stoich_prop { _ } { _ } \prop_put:Nnn \l__chemformula_stoich_prop { ( } { ( } @@ -897,7 +873,8 @@ \dim_set:Nn \l__chemformula_bond_space_dim { .07em } \prop_new:N \l__chemformula_bonds_prop -\cs_new:Npn \chemformula@bondlength { \l__chemformula_bond_dim } +\cs_new:Npn \chemformula@bondlength + { \l__chemformula_bond_dim } \cs_new:Npn \chemformula_single_bond: { @@ -914,7 +891,7 @@ \cs_new:Npn \chemformula_bond:n #1 { - \skip_horizontal:N \l__chemformula_bond_space_dim + \chemmacros_skip_nobreak:N \l__chemformula_bond_space_dim \chemformula_tikz:nn { inner~sep = 0 , @@ -933,7 +910,7 @@ { \chemformula_bond_draw:n { single } } { \chemformula_bond_draw:n { #1 } } } - \skip_horizontal:N \l__chemformula_bond_space_dim + \chemmacros_skip_nobreak:N \l__chemformula_bond_space_dim } \cs_new:Npn \chemformula_bond_draw:n #1 @@ -1123,9 +1100,23 @@ { \chemformula_star_adduct: } { * } } +\cs_new_protected:Npn \chemformula_subscript_raise:N #1 + { + \hbox_set:Nn \l__chemformula_tmpa_box + { $\scriptstyle Hg$ } + \hbox_set:Nn \l__chemformula_tmpb_box { Hg } + \dim_set:Nn #1 + { + - \box_ht:N \l__chemformula_tmpa_box + + .4 \box_ht:N \l__chemformula_tmpb_box + + \l__chemformula_subscript_shift_additional_tl + } + \tex_raise:D #1 + } + \cs_new:Npn \chemformula_subscript_write:n #1 { - \tex_raise:D \l__chemformula_subscript_shift_dim + \chemformula_subscript_raise:N \l__chemformula_subscript_shift_dim \hbox:n { $\scriptstyle @@ -1141,7 +1132,8 @@ { \hbox_set:Nn \l__chemformula_tmpa_box { \chemformula_subscript_write:n { #1 } } - \dim_set:Nn \l__chemformula_subscript_dim { -\box_wd:N \l__chemformula_tmpa_box } + \dim_set:Nn \l__chemformula_subscript_dim + { -\box_wd:N \l__chemformula_tmpa_box } \box_clear:N \l__chemformula_tmpa_box } \cs_generate_variant:Nn \chemformula_measure_subscript:n { V } @@ -1204,9 +1196,23 @@ { . } { \chemformula_radical: } } +\cs_new_protected:Npn \chemformula_superscript_raise:N #1 + { + \hbox_set:Nn \l__chemformula_tmpa_box + { $\scriptstyle Hg$ } + \hbox_set:Nn \l__chemformula_tmpb_box { Hg } + \dim_set:Nn #1 + { + + \box_ht:N \l__chemformula_tmpb_box + - .5 \box_ht:N \l__chemformula_tmpa_box + + \l__chemformula_superscript_shift_additional_tl + } + \tex_raise:D #1 + } + \cs_new:Npn \chemformula_superscript_write:n #1 { - \tex_raise:D \l__chemformula_superscript_shift_dim + \chemformula_superscript_raise:N \l__chemformula_superscript_shift_dim \hbox:n { $\scriptstyle @@ -1497,7 +1503,7 @@ } { \tl_put_right:Nn #2 - { \skip_horizontal:N \l__chemformula_stoich_space_dim } + { \skip_horizontal:N \l__chemformula_stoich_space_skip } \tl_clear:N \l__chemformula_stoich_tl } } @@ -1534,10 +1540,9 @@ \cs_new:Npn \chemformula_fontspec_aux:w [#1]#2 \q_stop { \newfontfamily \chemformula_font: [ #1 ] { #2 } } - -\cs_new:Npn \chemformula_handle_sub_and_superscripts:nN #1#2 +\cs_new:Npn \chemformula_sanitize:Nn #1#2 { - \tl_set_rescan:Nnn \l__chemformula_tmpa_tl + \tl_set_rescan:Nnn #1 { \char_set_catcode_letter:N \_ \char_set_catcode_letter:N \{ @@ -1545,7 +1550,12 @@ \char_set_catcode_letter:N \\ \char_set_catcode_letter:N \# } - { #1 } + { #2 } + } + +\cs_new:Npn \chemformula_handle_sub_and_superscripts:nN #1#2 + { + \chemformula_sanitize:Nn \l__chemformula_tmpa_tl { #1 } % let's see if the compound starts with a sub- or superscript: \exp_args:Nx \tl_if_in:nnT { \tl_head:V \l__chemformula_tmpa_tl } { ^ } { @@ -1628,9 +1638,9 @@ { \tl_put_right:Nn \l__chemformula_input_tl { - \skip_horizontal:N \l__chemformula_plus_space_dim + \skip_horizontal:N \l__chemformula_plus_space_skip + - \skip_horizontal:N \l__chemformula_plus_space_dim + \skip_horizontal:N \l__chemformula_plus_space_skip } } \bool_set_false:N \l__chemformula_is_plus_bool @@ -1706,10 +1716,14 @@ \tl_set_rescan:Nnn \l__chemformula_tmpa_tl { \ExplSyntaxNamesOn \char_set_catcode_other:N \: } { { #1 } } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { \_ } { chemformulaplaceholder } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { chemformulaplaceholder } { \_ } - \tl_set_rescan:Nno \l__chemformula_tmpa_tl { \ExplSyntaxOff } { \l__chemformula_tmpa_tl } + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { \_ } { chemformulaplaceholder } + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { _ } { \sb } % TODO use \c_math_subscript_token + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { chemformulaplaceholder } { \_ } + \tl_set_rescan:Nno \l__chemformula_tmpa_tl + { \ExplSyntaxOff } { \l__chemformula_tmpa_tl } \tl_put_right:NV \l__chemformula_input_tl \l__chemformula_tmpa_tl } @@ -1718,10 +1732,14 @@ \tl_set_rescan:Nnn \l__chemformula_tmpa_tl { \ExplSyntaxNamesOn \char_set_catcode_other:N \: } { { #1 } } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { \_ } { chemformulaplaceholder } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token? - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { chemformulaplaceholder } { \_ } - \tl_set_rescan:Nno \l__chemformula_tmpa_tl { \ExplSyntaxOff } { \l__chemformula_tmpa_tl } + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { \_ } { chemformulaplaceholder } + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { _ } { \sb } % TODO use \c_math_subscript_token? + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { chemformulaplaceholder } { \_ } + \tl_set_rescan:Nno \l__chemformula_tmpa_tl + { \ExplSyntaxOff } { \l__chemformula_tmpa_tl } \tl_put_right:NV \l__chemformula_input_tl \l__chemformula_tmpa_tl } @@ -1784,13 +1802,17 @@ \char_set_catcode_letter:N \} } { \mbox { \( #1 \) } } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { \_ } { chemformulaplaceholder } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token - \tl_replace_all:Nnn \l__chemformula_tmpa_tl { chemformulaplaceholder } { \_ } - \tl_set_rescan:Nno \l__chemformula_tmpa_tl { \ExplSyntaxOff } { \l__chemformula_tmpa_tl } + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { \_ } { chemformulaplaceholder } + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { _ } { \sb } % TODO use \c_math_subscript_token + \tl_replace_all:Nnn \l__chemformula_tmpa_tl + { chemformulaplaceholder } { \_ } + \tl_set_rescan:Nno \l__chemformula_tmpa_tl + { \ExplSyntaxOff } { \l__chemformula_tmpa_tl } \tl_put_right:NV \l__chemformula_input_tl \l__chemformula_tmpa_tl \tl_put_right:Nn \l__chemformula_input_tl - { \skip_horizontal:N \l__chemformula_math_space_dim } + { \skip_horizontal:N \l__chemformula_math_space_skip } } \cs_new:Npn \chemformula_first_last_math:n #1 @@ -1826,30 +1848,16 @@ \bool_set_false:N \l__chemformula_charge_full_shift_bool \dim_set:Nn \l__chemformula_charge_shift_dim { #1 } } , - charge-hshift .default:n = .5ex , - charge-vshift .code:n = - { - \dim_set:Nn \l__chemformula_superscript_shift_additional_dim { #1 } - \dim_set:Nn \l__chemformula_superscript_shift_dim - { - \l__chemformula_superscript_shift_default_dim + - \l__chemformula_superscript_shift_additional_dim - } - } , + charge-hshift .default:n = .25em , + charge-vshift .tl_set:N = + \l__chemformula_superscript_shift_additional_tl , charge-style .choice: , charge-style / text .code:n = \bool_set_false:N \l__chemformula_charge_style_math_bool , charge-style / math .code:n = \bool_set_true:N \l__chemformula_charge_style_math_bool , - subscript-vshift .code:n = - { - \dim_set:Nn \l__chemformula_subscript_shift_additional_dim { #1 } - \dim_set:Nn \l__chemformula_subscript_shift_dim - { - \l__chemformula_subscript_shift_default_dim + - \l__chemformula_subscript_shift_additional_dim - } - } , + subscript-vshift .tl_set:N = + \l__chemformula_subscript_shift_additional_tl , subscript-vshift .default:n = 0pt , subscript-style .choice: , subscript-style / text .code:n = @@ -1870,12 +1878,12 @@ \bool_set_false:N \l__chemformula_xfrac_bool \bool_set_true:N \l__chemformula_nicefrac_bool \bool_set_false:N \l__chemformula_mathfrac_bool , - stoich-space .dim_set:N = \l__chemformula_stoich_space_dim , - adduct-space .dim_set:N = \l__chemformula_cdot_space_dim , - plus-space .dim_set:N = \l__chemformula_plus_space_dim , - math-space .dim_set:N = \l__chemformula_math_space_dim , - name-format .tl_set:N = \l__chemformula_name_format_tl , - name-width .code:n = + stoich-space .skip_set:N = \l__chemformula_stoich_space_skip , + adduct-space .dim_set:N = \l__chemformula_cdot_space_dim , + plus-space .skip_set:N = \l__chemformula_plus_space_skip , + math-space .skip_set:N = \l__chemformula_math_space_skip , + name-format .tl_set:N = \l__chemformula_name_format_tl , + name-width .code:n = { \tl_if_eq:nnTF { #1 } { auto } { \bool_set_false:N \l__chemformula_name_width_bool } @@ -1915,7 +1923,7 @@ %-----------------------------------------------------------------------------% % hyperref support \AfterPackage* { hyperref } - { \pdfstringdefDisableCommands { \cs_set:Npn \cn #1 { #1 } } } + { \pdfstringdefDisableCommands { \cs_set:Npn \ch #1 { #1 } } } \tex_endinput:D %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index 26b5fae721b..abab3ca94d1 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -29,8 +29,8 @@ \RequirePackage{ expl3 , xparse , l3keys2e , xfrac , siunitx } \RequirePackage{ tikz , mathtools , environ , scrlfile , etoolbox , bm } \usetikzlibrary{calc,arrows} -\def\chemmacros@version{3.4b} -\def\chemmacros@date{2013/01/04} +\def\chemmacros@version{3.5} +\def\chemmacros@date{2013/01/28} \ProvidesExplPackage {chemmacros} @@ -126,6 +126,18 @@ \token_to_str:N #2 \c_space_tl instead. } +\cs_new_protected:Npn \chemmacros_define_deprecated:NNn #1#2#3 + { + \cs_new_protected:Npn #1 + { + \chemmacros_msg:nnxx { chemmacros } { command-deprecated } + { #1 } { #2 } + #3 + } + } +\NewDocumentCommand \DeclareChemDeprecated { mmm } + { \chemmacros_define_deprecated:NNn #1 #2 { #3 } } + \msg_set:nnnn { chemmacros } { command-dropped } { The~command~\token_to_str:N #1 \c_space_tl has~been~dropped.~I'm~sorry. } { The~command~\token_to_str:N #1 \c_space_tl has~been~dropped.~I'm~sorry. } @@ -268,6 +280,7 @@ \tl_new:N \l__chemmacros_tmpa_tl \tl_new:N \l__chemmacros_tmpb_tl \int_new:N \l__chemmacros_tmpa_int +\box_new:N \l__chemmacros_tmpa_box % --------------------------------------------------------------------------- % % package options @@ -292,7 +305,7 @@ \bool_new:N \l__chemmacros_use_upgreek_bool \bool_new:N \l__chemmacros_use_textgreek_bool -\bool_new:N \l__chemmacros_option_upgreek_set_bool +\bool_new:N \l__chemmacros_option_greek_set_bool \tl_new:N \l__chemmacros_language_tl \tl_set:Nn \l__chemmacros_language_tl { english } @@ -368,18 +381,22 @@ synchronize .default:n = true , greek .choice: , greek / upgreek .code:n = - \bool_set_true:N \l__chemmacros_use_upgreek_bool - \bool_set_false:N \l__chemmacros_use_textgreek_bool - \bool_set_true:N \l__chemmacros_option_upgreek_set_bool , + \bool_set_true:N \l__chemmacros_use_upgreek_bool + \bool_set_false:N \l__chemmacros_use_textgreek_bool + \bool_set_true:N \l__chemmacros_option_greek_set_bool , greek / textgreek .code:n = \bool_set_false:N \l__chemmacros_use_upgreek_bool \bool_set_true:N \l__chemmacros_use_textgreek_bool - \bool_set_true:N \l__chemmacros_option_upgreek_set_bool , + \bool_set_true:N \l__chemmacros_option_greek_set_bool , greek / math .code:n = \bool_set_false:N \l__chemmacros_use_upgreek_bool - \bool_set_false:N \l__chemmacros_use_textgreek_bool - \bool_set_true:N \l__chemmacros_option_upgreek_set_bool , - greek .default:n = upgreek , + \bool_set_false:N \l__chemmacros_use_textgreek_bool + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / auto .code:n = + \bool_set_false:N \l__chemmacros_use_upgreek_bool + \bool_set_false:N \l__chemmacros_use_textgreek_bool + \bool_set_false:N \l__chemmacros_option_greek_set_bool , + greek .default:n = auto , upgreek .code:n = \chemmacros_msg:nnxx { chemmacros } { option-deprecated } { upgreek } {} , @@ -418,7 +435,7 @@ { \bool_new:c { l__chemmacros_ #2 _bool } } } -\cs_new_nopar:Npn \chemmacros_set_language: +\cs_new_protected:Npn \chemmacros_set_language: { \prop_get:NoNTF \l__chemmacros_language_prop @@ -446,84 +463,70 @@ { \RequirePackage { xspace } } \bool_if:NT \l__chemmacros_use_mhchem_bool { \RequirePackage[ version=3 ]{ mhchem } } - \bool_if:NF \l__chemmacros_option_upgreek_set_bool + \bool_if:NF \l__chemmacros_option_greek_set_bool { \@ifpackageloaded { upgreek } { \bool_set_true:N \l__chemmacros_use_upgreek_bool } { \@ifpackageloaded { textgreek } { \bool_set_true:N \l__chemmacros_use_textgreek_bool } - {} + { } } } \bool_if:NTF \l__chemmacros_use_upgreek_bool { - \cs_set_nopar:Npn \Chemalpha { \ensuremath { \upalpha } } - \cs_set_nopar:Npn \Chembeta { \ensuremath { \upbeta } } - \cs_set_nopar:Npn \Chemgamma { \ensuremath { \upgamma } } - \cs_set_nopar:Npn \Chemdelta { \ensuremath { \updelta } } - \cs_set_nopar:Npn \Chemepsilon { \ensuremath { \upvarepsilon } } - \cs_set_nopar:Npn \Chemeta { \ensuremath { \upeta } } - \cs_set_nopar:Npn \Chemkappa { \ensuremath { \upkappa } } - \cs_set_nopar:Npn \Chemmu { \ensuremath { \upmu } } - \cs_set_nopar:Npn \Chemnu { \ensuremath { \upnu } } - \cs_set_nopar:Npn \Chemrho { \ensuremath { \uprho } } - \cs_set_nopar:Npn \Chempi { \ensuremath { \uppi } } - \cs_set_nopar:Npn \Chemsigma { \ensuremath { \upsigma } } - \cs_set_nopar:Npn \Chemomega { \ensuremath { \upomega } } - \cs_set_nopar:Npn \ChemDelta { \ensuremath { \Updelta } } + \cs_set:Npn \Chemalpha { \ensuremath { \upalpha } } + \cs_set:Npn \Chembeta { \ensuremath { \upbeta } } + \cs_set:Npn \Chemgamma { \ensuremath { \upgamma } } + \cs_set:Npn \Chemdelta { \ensuremath { \updelta } } + \cs_set:Npn \Chemepsilon { \ensuremath { \upvarepsilon } } + \cs_set:Npn \Chemeta { \ensuremath { \upeta } } + \cs_set:Npn \Chemkappa { \ensuremath { \upkappa } } + \cs_set:Npn \Chemmu { \ensuremath { \upmu } } + \cs_set:Npn \Chemnu { \ensuremath { \upnu } } + \cs_set:Npn \Chemrho { \ensuremath { \uprho } } + \cs_set:Npn \Chempi { \ensuremath { \uppi } } + \cs_set:Npn \Chemsigma { \ensuremath { \upsigma } } + \cs_set:Npn \Chemomega { \ensuremath { \upomega } } + \cs_set:Npn \ChemDelta { \ensuremath { \Updelta } } } { \bool_if:NT \l__chemmacros_use_textgreek_bool { - \cs_set_nopar:Npn \Chemalpha - { \ensuremath { \text { \textalpha } } } - \cs_set_nopar:Npn \Chembeta - { \ensuremath { \text { \textbeta } } } - \cs_set_nopar:Npn \Chemgamma - { \ensuremath { \text { \textgamma } } } - \cs_set_nopar:Npn \Chemdelta - { \ensuremath { \text { \textdelta } } } - \cs_set_nopar:Npn \Chemepsilon - { \ensuremath { \text { \textepsilon } } } - \cs_set_nopar:Npn \Chemeta - { \ensuremath { \text { \texteta } } } - \cs_set_nopar:Npn \Chemkappa - { \ensuremath { \text { \textkappa } } } - \cs_set_nopar:Npn \Chemmu - { \ensuremath { \text { \textmu } } } - \cs_set_nopar:Npn \Chemnu - { \ensuremath { \text { \textnu } } } - \cs_set_nopar:Npn \Chemrho - { \ensuremath { \text { \textrho } } } - \cs_set_nopar:Npn \Chempi - { \ensuremath { \text { \textpi } } } - \cs_set_nopar:Npn \Chemsigma - { \ensuremath { \text { \textsigma } } } - \cs_set_nopar:Npn \Chemomega - { \ensuremath { \text { \textomega } } } - \cs_set_nopar:Npn \ChemDelta - { \ensuremath { \text { \textDelta } } } + \cs_set_protected:Npn \Chemalpha { \ensuremath { \text { \textalpha } } } + \cs_set_protected:Npn \Chembeta { \ensuremath { \text { \textbeta } } } + \cs_set_protected:Npn \Chemgamma { \ensuremath { \text { \textgamma } } } + \cs_set_protected:Npn \Chemdelta { \ensuremath { \text { \textdelta } } } + \cs_set_protected:Npn \Chemepsilon { \ensuremath { \text { \textepsilon } } } + \cs_set_protected:Npn \Chemeta { \ensuremath { \text { \texteta } } } + \cs_set_protected:Npn \Chemkappa { \ensuremath { \text { \textkappa } } } + \cs_set_protected:Npn \Chemmu { \ensuremath { \text { \textmu } } } + \cs_set_protected:Npn \Chemnu { \ensuremath { \text { \textnu } } } + \cs_set_protected:Npn \Chemrho { \ensuremath { \text { \textrho } } } + \cs_set_protected:Npn \Chempi { \ensuremath { \text { \textpi } } } + \cs_set_protected:Npn \Chemsigma { \ensuremath { \text { \textsigma } } } + \cs_set_protected:Npn \Chemomega { \ensuremath { \text { \textomega } } } + \cs_set_protected:Npn \ChemDelta { \ensuremath { \text { \textDelta } } } } } } -\cs_new_nopar:Npn \Chemalpha { \ensuremath { \alpha } } -\cs_new_nopar:Npn \Chembeta { \ensuremath { \beta } } -\cs_new_nopar:Npn \Chemgamma { \ensuremath { \gamma } } -\cs_new_nopar:Npn \Chemdelta { \ensuremath { \delta } } -\cs_new_nopar:Npn \Chemepsilon { \ensuremath { \varepsilon } } -\cs_new_nopar:Npn \Chemeta { \ensuremath { \eta } } -\cs_set_nopar:Npn \Chemkappa { \ensuremath { \kappa } } -\cs_new_nopar:Npn \Chemmu { \ensuremath { \mu } } -\cs_new_nopar:Npn \Chemnu { \ensuremath { \nu } } -\cs_new_nopar:Npn \Chemrho { \ensuremath { \rho } } -\cs_new_nopar:Npn \Chempi { \ensuremath { \pi } } -\cs_new_nopar:Npn \Chemsigma { \ensuremath { \sigma } } -\cs_new_nopar:Npn \Chemomega { \ensuremath { \omega } } -\cs_new_nopar:Npn \ChemDelta { \ensuremath { \Delta } } +\cs_new:Npn \Chemalpha { \ensuremath { \alpha } } +\cs_new:Npn \Chembeta { \ensuremath { \beta } } +\cs_new:Npn \Chemgamma { \ensuremath { \gamma } } +\cs_new:Npn \Chemdelta { \ensuremath { \delta } } +\cs_new:Npn \Chemepsilon { \ensuremath { \varepsilon } } +\cs_new:Npn \Chemeta { \ensuremath { \eta } } +\cs_new:Npn \Chemkappa { \ensuremath { \kappa } } +\cs_new:Npn \Chemmu { \ensuremath { \mu } } +\cs_new:Npn \Chemnu { \ensuremath { \nu } } +\cs_new:Npn \Chemrho { \ensuremath { \rho } } +\cs_new:Npn \Chempi { \ensuremath { \pi } } +\cs_new:Npn \Chemsigma { \ensuremath { \sigma } } +\cs_new:Npn \Chemomega { \ensuremath { \omega } } +\cs_new:Npn \ChemDelta { \ensuremath { \Delta } } -\cs_new_nopar:Npn \chemmacros_xspace: +\cs_new:Npn \chemmacros_xspace: { \bool_if:NT \l__chemmacros_xspace_bool { \xspace } @@ -531,44 +534,60 @@ % --------------------------------------------------------------------------- % % TikZ drawings -\cs_new_nopar:Npn \chemmacros_tikz_picture:nn #1#2 +\cs_new:Npn \chemmacros_tikz_picture:nn #1#2 { \tikzpicture[#1] #2 \endtikzpicture } \cs_generate_variant:Nn \chemmacros_tikz_picture:nn { fn,xn } -\cs_new_nopar:Npn \chemmacros_tikz_draw:n #1 +\cs_new:Npn \chemmacros_tikz_draw:n #1 { \draw[#1] } \cs_generate_variant:Nn \chemmacros_tikz_draw:n { f,x } -\cs_new_nopar:Npn \chemmacros_tikz_node:n #1 +\cs_new:Npn \chemmacros_tikz_node:n #1 { \node[#1] } \cs_generate_variant:Nn \chemmacros_tikz_node:n { f,x } -\cs_new_nopar:Npn \chemmacros_tikz_shade:n #1 +\cs_new:Npn \chemmacros_tikz_shade:n #1 { \shade[#1] } \cs_generate_variant:Nn \chemmacros_tikz_shade:n { f,x } -\cs_new_nopar:Npn \chemmacros_tikz_shadedraw:n #1 +\cs_new:Npn \chemmacros_tikz_shadedraw:n #1 { \shadedraw[#1] } \cs_generate_variant:Nn \chemmacros_tikz_shadedraw:n { f,x } -\cs_new_nopar:Npn \chemmacros_tikz_node_in_draw:n #1 +\cs_new:Npn \chemmacros_tikz_node_in_draw:n #1 { node[#1] } \cs_generate_variant:Nn \chemmacros_tikz_node_in_draw:n { f,x } % --------------------------------------------------------------------------- % % general functions -\cs_new_protected_nopar:Npn \chemmacros_leave_vmode: +\cs_new_protected:Npn \chemmacros_leave_vmode: { \hbox_unpack:N \c_empty_box } + \cs_new_eq:NN \chemmacros_ignore_spaces: \tex_ignorespaces:D +\cs_new:Npn \chemmacros_nobreak: + { \tex_penalty:D \c_ten_thousand } + +\cs_new:Npn \chemmacros_allow_break: + { \tex_penalty:D \c_zero } + +\cs_new:Npn \chemmacros_skip_nobreak:N #1 + { + \chemmacros_nobreak: + \skip_horizontal:N #1 + \chemmacros_nobreak: + } + % --------------------------------------------------------------------------- % % circled charge signs -\cs_new_nopar:Npn \chemmacros_fplus: +\cs_new_protected:Npn \chemmacros_fplus: { \ensuremath { \chemmacros_fplus_aux_i: } } -\cs_new_nopar:Npn \chemmacros_fplus_aux_i: + +\cs_new:Npn \chemmacros_fplus_aux_i: { \mathpalette \chemmacros_fplus_aux_ii: \bigcirc } + % TODO: can I rewrite this in a more "expl3-way"? -\cs_new_nopar:Npn \chemmacros_fplus_aux_ii: #1#2 +\cs_new:Npn \chemmacros_fplus_aux_ii: #1#2 { \ooalign { @@ -583,11 +602,13 @@ } } -\cs_new_nopar:Npn \chemmacros_fminus: +\cs_new_protected:Npn \chemmacros_fminus: { \ensuremath { \chemmacros_fminus_aux_i: } } -\cs_new_nopar:Npn \chemmacros_fminus_aux_i: + +\cs_new:Npn \chemmacros_fminus_aux_i: { \mathpalette \chemmacros_fminus_aux_aux_ii: \bigcirc } -\cs_new_nopar:Npn \chemmacros_fminus_aux_aux_ii: #1#2 + +\cs_new:Npn \chemmacros_fminus_aux_aux_ii: #1#2 { \ooalign { @@ -607,7 +628,7 @@ \cs_new_eq:NN \fminus \chemmacros_fminus: % change output depending on circled-option -\cs_new_nopar:Npn \chemmacros_plus: +\cs_new:Npn \chemmacros_plus: { \bool_if:nTF { \l__chemmacros_circled_bool && !\l__chemmacros_circled_formal_bool } @@ -619,7 +640,7 @@ { + } } -\cs_new_nopar:Npn \chemmacros_minus: +\cs_new:Npn \chemmacros_minus: { \bool_if:nTF { \l__chemmacros_circled_bool && !\l__chemmacros_circled_formal_bool } @@ -631,21 +652,25 @@ { - } } -\cs_new_nopar:Npn \chemmacros_formal_plus: +\cs_new_protected:Npn \chemmacros_formal_plus: { - \bool_set_false:N \l__chemmacros_circled_formal_bool - \chemmacros_plus: + \group_begin: + \bool_set_false:N \l__chemmacros_circled_formal_bool + \chemmacros_plus: + \group_end: } -\cs_new_nopar:Npn \chemmacros_formal_minus: +\cs_new_protected:Npn \chemmacros_formal_minus: { - \bool_set_false:N \l__chemmacros_circled_formal_bool - \chemmacros_minus: + \group_begin: + \bool_set_false:N \l__chemmacros_circled_formal_bool + \chemmacros_minus: + \group_end: } % --------------------------------------------------------------------------- % % transition state symbol -\cs_new_nopar:Npn \chemmacros_transition_state_aux: +\cs_new:Npn \chemmacros_transition_state_aux: { \text { @@ -658,7 +683,7 @@ } } -\cs_new_nopar:Npn \transitionstatesymbol +\cs_new_protected:Npn \chemmacros_transition_state: { \ensuremath { @@ -671,6 +696,8 @@ } } +\cs_new_eq:NN \transitionstatesymbol \chemmacros_transition_state: + \cs_new:Nn \chemmacros_atom:n { \mode_if_math:TF @@ -685,17 +712,17 @@ % add a possibility to let chemformula use the chemformula % with method=chemformula, too \tl_new:N \l__chemmacros_chemformula_tl -\cs_new:Npn \chemmacros_chemformula:n #1 +\cs_new_protected:Npn \chemmacros_chemformula:n #1 { \bool_if:NTF \l__chemmacros_use_mhchem_bool { \ce { #1 } } { \group_begin: - \cs_set_eq:NN \chemformula_font_inner: \chemmacros_inner_font: - \chemformula_input_cmpd:nN { #1 } \l__chemmacros_chemformula_tl - \mode_if_math:TF - { \text { \l__chemmacros_chemformula_tl } } - { { \l__chemmacros_chemformula_tl } } + \cs_set_eq:NN \chemformula_font_inner: \chemmacros_inner_font: + \chemformula_input_cmpd:nN { #1 } \l__chemmacros_chemformula_tl + \mode_if_math:TF + { \text { \l__chemmacros_chemformula_tl } } + { { \l__chemmacros_chemformula_tl } } \group_end: } } @@ -706,46 +733,41 @@ \bool_new:N \l__chemmacros_charge_append_bool \bool_set_false:N \l__chemmacros_charge_append_bool +% TODO separate document and module level % \DeclareChemParticle, \RenewChemParticle \bool_if:NTF \l__chemmacros_use_mhchem_bool { \NewDocumentCommand \DeclareChemParticle { mm } { \cs_if_free:NTF #1 - { - \cs_new_nopar:Npn #1 - { \ce { #2 } \chemmacros_xspace: } - } + { \cs_new:Npn #1 { \ce { #2 } \chemmacros_xspace: } } { \chemmacros_msg:nnxx { chemmacros } { declare-particle } { #1 } {} } } \NewDocumentCommand \RenewChemParticle { mm } { \cs_if_free:NTF #1 { \chemmacros_msg:nnxx { chemmacros } { renew-particle } { #1 } {} } - { - \cs_set_nopar:Npn #1 - { \ce { #2 } \chemmacros_xspace: } - } + { \cs_set:Npn #1 { \ce { #2 } \chemmacros_xspace: } } } } { \NewDocumentCommand \DeclareChemParticle { mm } { \cs_if_free:NTF #1 - { \chemmacros_chem_particle:nn #1 { #2 } } + { \chemmacros_chem_particle:Nn #1 { #2 } } { \chemmacros_msg:nnxx { chemmacros } { declare-particle } { #1 } {} } } \NewDocumentCommand \RenewChemParticle { mm } { \cs_if_free:NTF #1 { \chemmacros_msg:nnxx { chemmacros } { renew-particle } { #1 } {} } - { \chemmacros_chem_particle:nn #1 { #2 } } + { \chemmacros_chem_particle:Nn #1 { #2 } } } } -\cs_new_nopar:Nn \chemmacros_chem_particle:nn +\cs_new_protected:Nn \chemmacros_chem_particle:Nn { - \cs_set_nopar:Npn #1 + \cs_set:Npn #1 { \bool_if:NTF \l__chemformula_inside_ch_bool { @@ -771,31 +793,31 @@ \bool_if:NTF \l__chemmacros_use_mhchem_bool { - \cs_new_nopar:Npn \el { \chemmacros_atom:n { e } \mch \chemmacros_xspace: } - \cs_new_nopar:Npn \prt { \chemmacros_atom:n { p } \pch \chemmacros_xspace: } + \cs_new:Npn \el { \chemmacros_atom:n { e } \mch \chemmacros_xspace: } + \cs_new:Npn \prt { \chemmacros_atom:n { p } \pch \chemmacros_xspace: } } { - \DeclareChemParticle \el { e- } + \DeclareChemParticle \el { e- } \DeclareChemParticle \prt { p+ } } \DeclareChemParticle \ntr { n^0 } -\cs_new_nopar:Npn \chemmacros_bm:n #1 +\cs_new:Npn \chemmacros_bm:n #1 { \bool_if:NTF \l__chemmacros_detect_bold_bool { \bm { #1 } } { #1 } } -\cs_new_nopar:Npn \chemmacros_bf:n #1 +\cs_new:Npn \chemmacros_bf:n #1 { \bool_if:NTF \l__chemmacros_detect_bold_bool { { \normalfont \bfseries #1 } } { { \normalfont #1 } } } -\cs_new_nopar:Npn \chemmacros_detect_bold:n #1 +\cs_new:Npn \chemmacros_detect_bold:n #1 { \chemmacros_if_bold:TF { @@ -814,7 +836,7 @@ } % charges -\cs_new_nopar:Npn \chemmacros_charge:n #1 +\cs_new:Npn \chemmacros_charge:n #1 { \bool_if:NTF \l__chemmacros_charge_append_bool { @@ -863,25 +885,25 @@ { \chemmacros_charge:n { #1 \chemmacros_formal_plus: } } } -\cs_new_nopar:Npn \delm +\cs_new:Npn \delm { \mbox { \tiny \( \delta \chemmacros_minus: \) } \chemmacros_xspace: } -\cs_new_nopar:Npn \delp +\cs_new:Npn \delp { \mbox { \tiny \( \delta \chemmacros_plus: \) } \chemmacros_xspace: } -\cs_new_nopar:Npn \fdelm +\cs_new:Npn \fdelm { \mbox { \tiny \( \delta \chemmacros_formal_minus: \) } \chemmacros_xspace: } -\cs_new_nopar:Npn \fdelp +\cs_new:Npn \fdelp { \mbox { \tiny \( \delta \chemmacros_formal_plus: \) } \chemmacros_xspace: } -\cs_new_nopar:Npn \scrm +\cs_new:Npn \scrm { \ensuremath { \scriptstyle \chemmacros_minus: } } -\cs_new_nopar:Npn \scrp +\cs_new:Npn \scrp { \ensuremath { \scriptstyle \chemmacros_plus: } } -\cs_new_nopar:Npn \fscrm +\cs_new:Npn \fscrm { \ensuremath { \scriptstyle \chemmacros_formal_minus: } } -\cs_new_nopar:Npn \fscrp +\cs_new:Npn \fscrp { \ensuremath { \scriptstyle \chemmacros_formal_plus: } } -\cs_new_nopar:Npn \fsscrm +\cs_new:Npn \fsscrm { \ensuremath { \scriptscriptstyle \chemmacros_formal_minus: } } -\cs_new_nopar:Npn \fsscrp +\cs_new:Npn \fsscrp { \ensuremath { \scriptscriptstyle \chemmacros_formal_plus: } } % --------------------------------------------------------------------------- % @@ -889,12 +911,10 @@ % proton, hydroxide, hydronium/oxonium, water, nucleophile, electrophile \bool_if:NTF \l__chemmacros_use_mhchem_bool { - \cs_new_nopar:Npn \Hpl { \chemmacros_atom:n { H } \pch \chemmacros_xspace: } - \cs_new_nopar:Npn \Hyd - { \chemmacros_atom:n { OH } \mch \chemmacros_xspace: } - \cs_new_nopar:Npn \HtO - { \chemmacros_chemformula:n { H3O } \pch \chemmacros_xspace: } - \cs_new_nopar:Npn \El { \chemmacros_atom:n { E } \pch \chemmacros_xspace: } + \cs_new:Npn \Hpl { \chemmacros_atom:n { H } \pch \chemmacros_xspace: } + \cs_new:Npn \Hyd { \chemmacros_atom:n { OH } \mch \chemmacros_xspace: } + \cs_new:Npn \HtO { \chemmacros_chemformula:n { H3O } \pch \chemmacros_xspace: } + \cs_new:Npn \El { \chemmacros_atom:n { E } \pch \chemmacros_xspace: } } { \DeclareChemParticle \Hpl { H+ } @@ -938,7 +958,7 @@ \chemmacros_xspace: } -\cs_new_nopar:Npn \chemmacros_elpair:n #1 +\cs_new:Npn \chemmacros_elpair:n #1 { \bool_if:NTF \l__chemmacros_chemfig_bool { @@ -979,34 +999,40 @@ % IUPAC \prop_new:N \l__chemmacros_iupac_prop -\NewDocumentCommand \DeclareChemIUPAC { mm } +\cs_new_protected:Npn \chemmacros_declare_iupac:Nn #1#2 { - \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl { \char_set_catcode_letter:N \\ } { #1 } - \tl_set:Nf \l__chemmacros_tmpa_tl { \tl_tail:V \l__chemmacros_tmpa_tl } + \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl + { \char_set_catcode_letter:N \\ } + { #1 } + \tl_set:Nf \l__chemmacros_tmpa_tl + { \tl_tail:V \l__chemmacros_tmpa_tl } \prop_if_in:NoTF \l__chemmacros_iupac_prop { \l__chemmacros_tmpa_tl } { \chemmacros_msg:nnxx { chemmacros } { declare-iupac } { #1 } { } } { \prop_put:Non \l__chemmacros_iupac_prop { \l__chemmacros_tmpa_tl } { #2 } } \chemmacros_make_iupac: } -\NewDocumentCommand \RenewChemIUPAC { mm } +\cs_new_protected:Npn \chemmacros_renew_iupac:Nn #1#2 { - \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl { \char_set_catcode_letter:N \\ } { #1 } - \tl_set:Nf \l__chemmacros_tmpa_tl { \tl_tail:V \l__chemmacros_tmpa_tl } + \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl + { \char_set_catcode_letter:N \\ } + { #1 } + \tl_set:Nf \l__chemmacros_tmpa_tl + { \tl_tail:V \l__chemmacros_tmpa_tl } \prop_if_in:NoTF \l__chemmacros_iupac_prop { \l__chemmacros_tmpa_tl } { \prop_put:Non \l__chemmacros_iupac_prop { \l__chemmacros_tmpa_tl } { #2 } } { \chemmacros_msg:nnxx { chemmacros } { renew-iupac } { #1 } { } } \chemmacros_make_iupac: } -\cs_new_nopar:Npn \chemmacros_make_iupac: +\cs_new_protected:Npn \chemmacros_make_iupac: { \bool_if:NT \l__chemmacros_in_document_bool { \bool_if:NTF \l__chemmacros_inside_iupac_bool { \prop_map_inline:Nn \l__chemmacros_iupac_prop - { \cs_set_protected_nopar:cpn { ##1 } { ##2 } } + { \cs_set_protected:cpn { ##1 } { ##2 } } } { \bool_if:NF \l__chemmacros_iupac_restricted_bool @@ -1014,13 +1040,13 @@ \bool_if:NTF \l__chemmacros_iupac_strict_bool { \prop_map_inline:Nn \l__chemmacros_iupac_prop - { \cs_set_protected_nopar:cpn { ##1 } { ##2 } } + { \cs_set_protected:cpn { ##1 } { ##2 } } } { \prop_map_inline:Nn \l__chemmacros_iupac_prop { \cs_if_exist:cF { ##1 } - { \cs_set_protected_nopar:cpn { ##1 } { ##2 } } + { \cs_set_protected:cpn { ##1 } { ##2 } } } } } @@ -1030,10 +1056,17 @@ \AtBeginDocument { \chemmacros_make_iupac: } +\NewDocumentCommand \DeclareChemIUPAC { mm } + { \chemmacros_declare_iupac:Nn #1 { #2 } } + +\NewDocumentCommand \RenewChemIUPAC { mm } + { \chemmacros_renew_iupac:Nn #1 { #2 } } + % stereo descriptors and other nomenclature commands % Cahn-Ingold-Prelog -\dim_new:N \l__chemmacros_cip_kern_dim -\dim_set:Nn \l__chemmacros_cip_kern_dim { .05ex } +\dim_new:N \l__chemmacros_cip_kern_dim +\dim_set:Nn \l__chemmacros_cip_kern_dim { .075em } + \keys_define:nn { chemmacros / iupac } { cip-kern .dim_set:N = \l__chemmacros_cip_kern_dim } @@ -1041,22 +1074,13 @@ { \cs_if_exist:NTF \EmbracOff { \textit* { (#1) } } - { \textit { (#1) } } + { \textit { (#1) } } \tex_kern:D \l__chemmacros_cip_kern_dim } -\cs_new_protected_nopar:Npn \Rcip - { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } - { \Rcip } { \R } - \cip { R } - } -\cs_new_protected_nopar:Npn \Scip - { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } - { \Scip } { \S } - \cip { S } - } +\DeclareChemDeprecated \Rcip \R { \cip { R } } +\DeclareChemDeprecated \Scip \S { \cip { S } } + \DeclareChemIUPAC \R { \cip { R } } \DeclareChemIUPAC \S { \cip { S } } @@ -1086,23 +1110,14 @@ \DeclareChemIUPAC \Z { \cip { Z } } % cis/trans & tert -\DeclareChemIUPAC \cis { \textit{ cis } } +\DeclareChemIUPAC \cis { \textit{ cis } } \DeclareChemIUPAC \trans { \textit { trans } } -\DeclareChemIUPAC \tert { \textit { tert } } +\DeclareChemIUPAC \tert { \textit { tert } } % Fischer -\cs_set_protected_nopar:Npn \Dfi - { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } - { \Dfi } { \D } - \textsc { d } - } -\cs_set_protected_nopar:Npn \Lfi - { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } - { \Lfi } { \L } - \textsc { l } - } +\DeclareChemDeprecated \Dfi \D { \textsc { d } } +\DeclareChemDeprecated \Lfi \L { \textsc { l } } + \DeclareChemIUPAC \D { \textsc { d } } \DeclareChemIUPAC \L { \textsc { l } } @@ -1117,6 +1132,7 @@ % coordination chemistry \bool_new:N \l__chemmacros_bridge_super_bool + \keys_define:nn { chemmacros / iupac } { bridge-number .choice: , @@ -1128,12 +1144,13 @@ coord-use-hyphen .default:n = true } -\cs_new_nopar:Npn \chemformula_hapto:n #1 +\cs_new:Npn \chemformula_hapto:n #1 { \Chemeta \chemformula_superscript:n { #1 } \chemmacros_break_point_hyphen: } -\cs_new_nopar:Npn \chemformula_bridge:n #1 +\cs_new:Npn \chemformula_bridge:n #1 { - \Chemmu \tl_if_blank:nF { #1 } + \Chemmu + \tl_if_blank:nF { #1 } { \bool_if:NTF \l__chemmacros_bridge_super_bool { \chemformula_superscript:n { #1 } } @@ -1146,11 +1163,11 @@ \DeclareChemIUPAC \bridge { \chemformula_bridge:n } % attachments to heteroatoms / added hydrogen -\DeclareChemIUPAC \H { \textit { H } } -\DeclareChemIUPAC \O { \textit { O } } -\DeclareChemIUPAC \N { \textit { N } } +\DeclareChemIUPAC \H { \textit { H } } +\DeclareChemIUPAC \O { \textit { O } } +\DeclareChemIUPAC \N { \textit { N } } \DeclareChemIUPAC \Sf { \textit { S } } -\DeclareChemIUPAC \P { \textit { P } } +\DeclareChemIUPAC \P { \textit { P } } % language specific settings \AtBeginDocument @@ -1180,13 +1197,16 @@ % - add a little space at breaking points if not broken % - enables all naming commands regardless if they're definied otherwise or not \cs_new_protected:Nn \chemmacros_allow_hyphens: - { \tex_penalty:D \c_ten_thousand \skip_horizontal:n { \c_zero_dim } } + { + \chemmacros_nobreak: + \skip_horizontal:n { \c_zero_dim } + } -\dim_new:N \l__chemmacros_iupac_hyphen_pre_dim +\dim_new:N \l__chemmacros_iupac_hyphen_pre_dim \dim_set:Nn \l__chemmacros_iupac_hyphen_pre_dim { .01em } -\dim_new:N \l__chemmacros_iupac_hyphen_post_dim +\dim_new:N \l__chemmacros_iupac_hyphen_post_dim \dim_set:Nn \l__chemmacros_iupac_hyphen_post_dim { -.03em } -\dim_new:N \l__chemmacros_iupac_break_dim +\dim_new:N \l__chemmacros_iupac_break_dim \dim_set:Nn \l__chemmacros_iupac_break_dim { .03em } \keys_define:nn { chemmacros / iupac } @@ -1198,7 +1218,7 @@ \cs_new_protected:Nn \chemmacros_break_point_hyphen: { - \tex_penalty:D \c_ten_thousand + \chemmacros_nobreak: \tex_discretionary:D { - } { } { \tex_kern:D \l__chemmacros_iupac_hyphen_pre_dim @@ -1210,7 +1230,7 @@ \cs_new_protected:Nn \chemmacros_break_point: { - \tex_penalty:D \c_ten_thousand + \chemmacros_nobreak: \tex_discretionary:D { - } { } { \tex_kern:D \l__chemmacros_iupac_break_dim } \chemmacros_allow_hyphens: @@ -1226,21 +1246,23 @@ \chemmacros_ignore_spaces: \cs_set_eq:NN \- \chemmacros_break_point_hyphen: \cs_set_eq:NN \| \chemmacros_break_point: - \cs_set_eq:NN \^ \chemformula_superscript:n + \cs_set_eq:NN \^ \textsuperscript #1 \group_end: } % Thanks to Joseph Wright and Enrico Gregorio for the help on the curious % redefinition of \- and the end of the compilation -\cs_set_protected_nopar:Npx \| { \exp_not:o { \| } } -\cs_set_protected_nopar:Npx \- { \exp_not:o { \- } } +% see http://tex.stackexchange.com/q/42405/5049 for reference +\cs_set_protected:Npx \| { \exp_not:o { \| } } +\cs_set_protected:Npx \- { \exp_not:o { \- } } \cs_set_eq:NN \@dischyph \- -\cs_set_eq:NN \iupac \chemmacros_iupac:n +\NewDocumentCommand \iupac { m } + { \chemmacros_iupac:n { #1 } } % latin phrases -\tl_new:N \l__chemmacros_latin_format_tl +\tl_new:N \l__chemmacros_latin_format_tl \tl_set:Nn \l__chemmacros_latin_format_tl { \itshape } \keys_define:nn { chemmacros / latin } @@ -1250,7 +1272,8 @@ { { \l__chemmacros_latin_format_tl #1 } } \prop_new:N \l__chemmacros_latin_prop -\NewDocumentCommand \DeclareChemLatin { mm } + +\cs_new_protected:Npn \chemmacros_declare_latin:Nn #1#2 { \cs_if_free:NTF #1 { @@ -1260,13 +1283,19 @@ { \chemmacros_msg:nnxx { chemmacros } { declare-latin } { #1 } { } } } -\NewDocumentCommand \RenewChemLatin { mm } +\cs_new_protected:Npn \chemmacros_renew_latin:Nn #1#2 { \prop_if_in:NnTF \l__chemmacros_latin_prop { #1 } { \cs_set:Npn #1 { \chemmacros_latin:n { #2 } \chemmacros_xspace: } } { \chemmacros_msg:nnxx { chemmacros } { renew-latin } { #1 } { } } } +\NewDocumentCommand \DeclareChemLatin { mm } + { \chemmacros_declare_latin:Nn #1 { #2 } } + +\NewDocumentCommand \RenewChemLatin { mm } + { \chemmacros_renew_latin:Nn #1 { #2 } } + \AtBeginDocument { \bool_if:NTF \l__chemmacros_chemstyle_bool @@ -1297,7 +1326,8 @@ \cs_new_eq:NN \chemmacros_p_style:n \textup -\cs_new_nopar:Npn \chemmacros_if_bold:TF #1#2 +% TODO: rewrite in expl3 style +\cs_new:Npn \chemmacros_if_bold:TF #1#2 { \ifx\f@series\l__chemmacros_if_bf_tl \expandafter\@firstoftwo @@ -1307,10 +1337,10 @@ { #1 }{ #2 } } -\tl_new:N \l__chemmacros_if_bf_tl +\tl_new:N \l__chemmacros_if_bf_tl \tl_set:Nn \l__chemmacros_if_bf_tl { bx } -\cs_new_protected_nopar:Npn \Ka +\cs_new_protected:Npn \Ka { \mbox { @@ -1325,7 +1355,7 @@ \chemmacros_xspace: } -\cs_new_protected_nopar:Npn \Kb +\cs_new_protected:Npn \Kb { \mbox { @@ -1337,7 +1367,7 @@ \chemmacros_xspace: } -\cs_new_protected_nopar:Npn \Kw +\cs_new_protected:Npn \Kw { \mbox { @@ -1357,10 +1387,10 @@ \group_end: } -\cs_new_protected_nopar:Npn \pH +\cs_new_protected:Npn \pH { \p { \chemmacros_chemformula:n { H } } \chemmacros_xspace: } -\cs_new_protected_nopar:Npn \pOH +\cs_new_protected:Npn \pOH { \p { \chemmacros_chemformula:n { OH } } \chemmacros_xspace: } \NewDocumentCommand \pKa { o } @@ -1389,6 +1419,7 @@ \DeclareSIUnit { \atmosphere } { atm } \DeclareSIUnit { \calory } { cal } \DeclareSIUnit { \cal } { cal } + \AtBeginDocument { \bool_if:NF \l__chemmacros_chemstyle_bool @@ -1398,6 +1429,7 @@ \DeclareSIUnit { \Molar } { \textsc{m} } } } + \DeclareSIUnit { \moLar } { \mole\per\liter } \DeclareSIUnit { \MolMass } { \gram\per\mole } \DeclareSIUnit { \normal } { \textsc{n} } @@ -1412,7 +1444,7 @@ \tl_new:N \l__chemmacros_mech_mol_tl \tl_new:N \l__chemmacros_mech_ar_tl -\cs_new_nopar:Npn \chemmacros_set_mech:nnn #1#2#3 +\cs_new_protected:Npn \chemmacros_set_mech:nnn #1#2#3 { \tl_set:Nn \l__chemmacros_mech_type_tl { #1 } \tl_set:Nn \l__chemmacros_mech_mol_tl { #2 } @@ -1425,94 +1457,104 @@ type / .code:n = { \chemmacros_set_mech:nnn { S } - { $ \c_math_subscript_token \text {N} $ } {} + { \( \c_math_subscript_token { \text {N} } \) } + { } } , type / 1 .code:n = { \chemmacros_set_mech:nnn { S } - { $ \c_math_subscript_token \text {N} $ 1 } {} + { \( \c_math_subscript_token { \text {N} } \) 1 } + { } } , type / 2 .code:n = { \chemmacros_set_mech:nnn { S } - { $ \c_math_subscript_token \text {N} $ 2 } {} + { \( \c_math_subscript_token { \text {N} } \) 2 } + { } } , type / se .code:n = { \chemmacros_set_mech:nnn { S } - { $ \c_math_subscript_token \text {E} $ } {} + { \( \c_math_subscript_token { \text {E} } \) } + { } } , type / 1e .code:n = { \chemmacros_set_mech:nnn { S } - { $ \c_math_subscript_token \text {E} $ 1 } {} + { \( \c_math_subscript_token { \text {E} } \) 1 } + { } } , type / 2e .code:n = { \chemmacros_set_mech:nnn { S } - { $ \c_math_subscript_token \text {E} $ 2 } {} + { \( \c_math_subscript_token { \text {E} } \) 2 } + { } } , type / ar .code:n = { \chemmacros_set_mech:nnn { S } - { $ \c_math_subscript_token \text {E} $ } { Ar - } + { \( \c_math_subscript_token { \text {E} } \) } + { Ar - } } , type / e .code:n = - { \chemmacros_set_mech:nnn { E } {} {} } , + { \chemmacros_set_mech:nnn { E } { } { } } , type / e1 .code:n = - { \chemmacros_set_mech:nnn { E } { 1 } {} } , + { \chemmacros_set_mech:nnn { E } { 1 } { } } , type / e2 .code:n = - { \chemmacros_set_mech:nnn { E } { 2 } {} } , + { \chemmacros_set_mech:nnn { E } { 2 } { } } , type / cb .code:n = { \chemmacros_set_mech:nnn { E } - { 1 $ \c_math_subscript_token \text {cb} $ } {} + { 1 \( \c_math_subscript_token { \text {cb} } \) } + { } } , type .default:n = } -\NewDocumentCommand \mech { o } +\cs_new_protected:Npn \chemmacros_mech:n #1 { - \IfNoValueTF { #1 } + \tl_if_blank:nTF { #1 } { \keys_set:nn { chemmacros / mech } { type } } { \keys_set:nn { chemmacros / mech } { type = #1 } } - \mbox - { - \tl_use:N \l__chemmacros_mech_ar_tl - \tl_use:N \l__chemmacros_mech_type_tl - \tl_use:N \l__chemmacros_mech_mol_tl - } + \mbox + { + \tl_use:N \l__chemmacros_mech_ar_tl + \tl_use:N \l__chemmacros_mech_type_tl + \tl_use:N \l__chemmacros_mech_mol_tl + } \chemmacros_xspace: } +\NewDocumentCommand \mech { o } + { + \IfNoValueTF { #1 } + { \chemmacros_mech:n { } } + { \chemmacros_mech:n { #1 } } + } + % --------------------------------------------------------------------------- % % oxidation numbers % \ox{<number>,<atom>} \bool_new:N \l__chemmacros_ox_sign_bool \bool_new:N \l__chemmacros_ox_integer_bool - \bool_new:N \l__chemmacros_ox_explicit_sign_bool \bool_set_false:N \l__chemmacros_ox_explicit_sign_bool - \bool_new:N \l__chemmacros_ox_format_roman_bool \bool_set_true:N \l__chemmacros_ox_format_roman_bool - \bool_new:N \l__chemmacros_ox_decimal_marker_comma_bool \bool_set_false:N \l__chemmacros_ox_decimal_marker_comma_bool - \bool_new:N \l__chemmacros_ox_parse_bool \bool_set_true:N \l__chemmacros_ox_parse_bool - -\int_new:N \l__chemmacros_ox_number_int -\fp_new:N \l__chemmacros_ox_number_fp - \bool_new:N \l__chemmacros_ox_side_bool \bool_new:N \l__chemmacros_ox_super_bool \bool_new:N \l__chemmacros_ox_top_bool \bool_set_true:N \l__chemmacros_ox_top_bool \bool_new:N \l__chemmacros_ox_align_center_bool -\cs_new_nopar:Npn \chemmacros_ox_process_number:n #1 +\int_new:N \l__chemmacros_ox_number_int +\fp_new:N \l__chemmacros_ox_number_fp + +\cs_new_protected:Npn \chemmacros_ox_process_number:n #1 { \bool_if:NTF \l__chemmacros_ox_parse_bool { @@ -1536,7 +1578,7 @@ slash-symbol-font = lmr } -\cs_new_nopar:Npn \chemmacros_ox_fraction:n #1/#2 +\cs_new:Npn \chemmacros_ox_fraction:n #1/#2 { \bool_set_false:N \l__chemmacros_ox_format_roman_bool \chemmacros_ox_sign:n { #1 } @@ -1545,7 +1587,7 @@ { \sfrac [ chemmacros-ox-frac ] { \chemmacros_ox_value:n { #1 } } { #2 } } } -\cs_new_nopar:Npn \chemmacros_ox_sign:n #1 +\cs_new:Npn \chemmacros_ox_sign:n #1 { \fp_compare:nNnT { #1 } > { 0 } { \bool_if:NT \l__chemmacros_ox_explicit_sign_bool { $+$ } } @@ -1555,23 +1597,23 @@ { $-$ } } -\cs_new_nopar:Npn \chemmacros_ox_value:n #1 +\cs_new_protected:Npn \chemmacros_ox_value:n #1 { \fp_set:Nn \l__chemmacros_ox_number_fp { #1 } \fp_abs:N \l__chemmacros_ox_number_fp - \chemmacros_ox_is_integer:N \l__chemmacros_ox_number_fp + \chemmacros_ox_is_integer:V \l__chemmacros_ox_number_fp \bool_if:NTF \l__chemmacros_ox_format_roman_bool { - \chemmacros_fp_to_Roman:N \l__chemmacros_ox_number_fp + \chemmacros_fp_to_Roman:V \l__chemmacros_ox_number_fp } { \bool_if:NTF \l__chemmacros_ox_integer_bool - { \chemmacros_fp_to_arabic:N \l__chemmacros_ox_number_fp } - { \chemmacros_fp_show:N \l__chemmacros_ox_number_fp } + { \chemmacros_fp_to_arabic:V \l__chemmacros_ox_number_fp } + { \chemmacros_fp_show:V \l__chemmacros_ox_number_fp } } } -\cs_new_nopar:Npn \chemmacros_ox_is_integer:n #1 +\cs_new_protected:Npn \chemmacros_ox_is_integer:n #1 { \fp_set:Nn \l__chemmacros_tmpa_tl { #1 } \fp_add:Nn \l__chemmacros_tmpa_tl { 1 } @@ -1584,9 +1626,9 @@ \bool_set_false:N \l__chemmacros_ox_format_roman_bool } } -\cs_generate_variant:Nn \chemmacros_ox_is_integer:n { N } +\cs_generate_variant:Nn \chemmacros_ox_is_integer:n { V } -\cs_new_nopar:Npn \chemmacros_fp_to_Roman:n #1 +\cs_new_protected:Npn \chemmacros_fp_to_Roman:n #1 { \group_begin: \fp_set:Nn \l__chemmacros_tmpa_tl { #1 } @@ -1597,18 +1639,18 @@ { \int_to_Roman:n { \int_use:N \l__chemmacros_tmpa_int } } \group_end: } -\cs_generate_variant:Nn \chemmacros_fp_to_Roman:n { N } +\cs_generate_variant:Nn \chemmacros_fp_to_Roman:n { V } -\cs_new_nopar:Npn \chemmacros_fp_to_arabic:n #1 +\cs_new_protected:Npn \chemmacros_fp_to_arabic:n #1 { \group_begin: \fp_set:Nn \l__chemmacros_tmpa_tl { #1 } \fp_to_tl:N \l__chemmacros_tmpa_tl \group_end: } -\cs_generate_variant:Nn \chemmacros_fp_to_arabic:n { N } +\cs_generate_variant:Nn \chemmacros_fp_to_arabic:n { V } -\cs_new_nopar:Npn \chemmacros_fp_show:n #1 +\cs_new_protected:Npn \chemmacros_fp_show:n #1 { \group_begin: \fp_set:Nn \l__chemmacros_tmpa_tl { #1 } @@ -1621,18 +1663,14 @@ { \fp_to_tl:N \l__chemmacros_tmpa_tl } \group_end: } -\cs_generate_variant:Nn \chemmacros_fp_show:n { N } +\cs_generate_variant:Nn \chemmacros_fp_show:n { V } -\cs_new_nopar:Npn \chemmacros_ox:nn #1#2 +\cs_new_protected:Npn \chemmacros_ox_write:nn #1#2 { \tl_if_blank:nT { #1 } - { - \msg_error:nnx { chemmacros } { ox } { oxidation~number~missing } - } + { \msg_error:nnx { chemmacros } { ox } { oxidation~number~missing } } \tl_if_blank:nT { #2 } - { - \msg_error:nnx { chemmacros } { ox } { atom~missing } - } + { \msg_error:nnx { chemmacros } { ox } { atom~missing } } \ensuremath { \bool_if:NT \l__chemmacros_ox_super_bool @@ -1664,21 +1702,21 @@ } } -\cs_new_nopar:Npn \chemmacros_ox_pos_top: +\cs_new_protected:Npn \chemmacros_ox_pos_top: { \bool_set_true:N \l__chemmacros_ox_top_bool \bool_set_false:N \l__chemmacros_ox_super_bool \bool_set_false:N \l__chemmacros_ox_side_bool } -\cs_new_nopar:Npn \chemmacros_ox_pos_super: +\cs_new_protected:Npn \chemmacros_ox_pos_super: { \bool_set_false:N \l__chemmacros_ox_top_bool \bool_set_true:N \l__chemmacros_ox_super_bool \bool_set_false:N \l__chemmacros_ox_side_bool } -\cs_new_nopar:Npn \chemmacros_ox_pos_side: +\cs_new_protected:Npn \chemmacros_ox_pos_side: { \bool_set_false:N \l__chemmacros_ox_top_bool \bool_set_false:N \l__chemmacros_ox_super_bool @@ -1709,36 +1747,47 @@ % \ox[<keyval>]{<num>,<atom>} % \ox*[<keyval>]{<num>,<atom>} => always number on the side -\NewDocumentCommand \ox { s o > { \SplitArgument { 1 } { , } } m } +\cs_new_protected:Npn \chemmacros_ox:nnnn #1#2#3#4 { \group_begin: - \IfBooleanT { #1 } { \chemmacros_ox_pos_super: } + \tl_if_blank:nF { #1 } { \chemmacros_ox_pos_super: } \bool_if:NTF \l__chemmacros_version_one_bool { \keys_set:nn { chemmacros / ox } { parse = false } } - { \IfNoValueF { #2 } { \keys_set:nn { chemmacros / ox } { #2 } } } - \chemmacros_ox:nn #3 + { \tl_if_blank:nF { #2 } { \keys_set:nn { chemmacros / ox } { #2 } } } + \chemmacros_ox_write:nn { #3 } { #4 } \group_end: } +\NewDocumentCommand \ox { s o > { \SplitArgument { 1 } { , } } m } + { + \IfBooleanTF { #1 } + { + \IfNoValueTF { #2 } + { \chemmacros_ox:nnnn { #1 } { } #3 } + { \chemmacros_ox:nnnn { #1 } { #2 } #3 } + } + { + \IfNoValueTF { #2 } + { \chemmacros_ox:nnnn { } { } #3 } + { \chemmacros_ox:nnnn { } { #2 } #3 } + } + } + % --------------------------------------------------------------------------- % % - oxidation arrows -\tl_new:N \l__chemmacros_redox_begin_tl -\tl_new:N \l__chemmacros_redox_end_tl - -\tl_new:N \l__chemmacros_redox_tikz_tl - -\fp_new:N \l__chemmacros_redox_shift_fp -\tl_new:N \l__chemmacros_redox_shift_tl +\tl_new:N \l__chemmacros_redox_begin_tl +\tl_new:N \l__chemmacros_redox_end_tl +\tl_new:N \l__chemmacros_redox_tikz_tl +\tl_new:N \l__chemmacros_redox_shift_tl +\tl_new:N \l__chemmacros_redox_anchor_tl +\tl_new:N \l__chemmacros_redox_side_tl -\tl_new:N \l__chemmacros_redox_anchor_tl +\fp_new:N \l__chemmacros_redox_shift_fp -\tl_new:N \l__chemmacros_redox_side_tl - -\dim_new:N \l__chemmacros_redox_sep_dim -\dim_new:N \l__chemmacros_redox_sep_default_dim +\dim_new:N \l__chemmacros_redox_sep_dim +\dim_new:N \l__chemmacros_redox_sep_default_dim \dim_set:Nn \l__chemmacros_redox_sep_default_dim { .2em } - -\dim_new:N \l__chemmacros_redox_dist_dim +\dim_new:N \l__chemmacros_redox_dist_dim \dim_set:Nn \l__chemmacros_redox_dist_dim {.6em} % place and name nodes: @@ -1746,42 +1795,30 @@ \NewDocumentCommand \OX { > { \SplitArgument { 1 } { , } } m } { \chemmacros_redox_partner:nn #1 } -\cs_new_nopar:Npn \chemmacros_redox_partner:nn #1#2 +\cs_new_protected:Npn \chemmacros_redox_partner:nn #1#2 { \tl_if_blank:nT { #1 } - { - \msg_error:nnx { chemmacros } { OX } { node~name~missing } - } + { \msg_error:nnx { chemmacros } { OX } { node~name~missing } } \tl_if_blank:nT { #2 } - { - \msg_error:nnx { chemmacros } { OX } { atom~missing } - } + { \msg_error:nnx { chemmacros } { OX } { atom~missing } } \tikz[baseline=(#1.base),remember~picture] - { - \node [inner~sep=0] (#1) { #2 } ; - } + { \node [inner~sep=0] (#1) { #2 } ; } } -\cs_new_nopar:Npn \chemmacros_redox_coordinates:nn #1#2 +\cs_new_protected:Npn \chemmacros_redox_coordinates:nn #1#2 { \tl_set:Nn \l__chemmacros_redox_begin_tl { #1 } - \tl_set:Nn \l__chemmacros_redox_end_tl { #2 } + \tl_set:Nn \l__chemmacros_redox_end_tl { #2 } } -\NewDocumentCommand \redox { > { \SplitArgument { 1 } { , } } r() o o G{} } +\cs_new_protected:Npn \chemmacros_redox:nnnnn #1#2#3#4#5 { - \IfNoValueT { #1 } - { - \msg_error:nnx { chemmacros } { redox } - { You~need~to~specify~coordinates } - } \tl_clear:N \l__chemmacros_redox_begin_tl \tl_clear:N \l__chemmacros_redox_end_tl \tl_clear:N \l__chemmacros_redox_tikz_tl - \chemmacros_redox_coordinates:nn #1 - \IfNoValueF { #2 } - { \tl_set:Nn \l__chemmacros_redox_tikz_tl { #2 } } - \IfNoValueTF { #3 } + \chemmacros_redox_coordinates:nn { #1 } { #2 } + \tl_if_empty:nF { #3 } { \tl_set:Nn \l__chemmacros_redox_tikz_tl { #3 } } + \tl_if_blank:nTF { #4 } { \fp_set:Nn \l__chemmacros_redox_shift_fp { 1 } \tl_set:Nn \l__chemmacros_redox_anchor_tl { above } @@ -1791,7 +1828,7 @@ \l__chemmacros_redox_sep_default_dim } { - \fp_compare:nNnTF { #3 } < { 0 } + \fp_compare:nNnTF { #4 } < { 0 } { \tl_set:Nn \l__chemmacros_redox_anchor_tl { below } \tl_set:Nn \l__chemmacros_redox_side_tl { south } @@ -1805,7 +1842,7 @@ \l__chemmacros_redox_sep_dim \l__chemmacros_redox_sep_default_dim } - \fp_set:Nn \l__chemmacros_redox_shift_fp { #3 } + \fp_set:Nn \l__chemmacros_redox_shift_fp { #4 } } \tl_set:Nn \l__chemmacros_redox_shift_tl { \fp_to_tl:N \l__chemmacros_redox_shift_fp } @@ -1818,7 +1855,7 @@ $) -- ++(0,\l__chemmacros_redox_shift_tl * \l__chemmacros_redox_dist_dim) -| - node [pos=.25,\l__chemmacros_redox_anchor_tl] { { #4 } } + node [pos=.25,\l__chemmacros_redox_anchor_tl] { { #5 } } ($ (\l__chemmacros_redox_end_tl . \l__chemmacros_redox_side_tl)+(0,\l__chemmacros_redox_sep_dim) @@ -1826,6 +1863,22 @@ } } +\NewDocumentCommand \redox { > { \SplitArgument { 1 } { , } } r() o o G{} } + { + \IfNoValueT { #1 } + { + \msg_error:nnx { chemmacros } { redox } + { You~need~to~specify~coordinates } + } + \IfNoValueTF { #2 } + { \chemmacros_redox:nnnnn #1 { } { } { #4 } } + { + \IfNoValueTF { #3 } + { \chemmacros_redox:nnnnn #1 { } { } { #4 } } + { \chemmacros_redox:nnnnn #1 { } { #3 } { #4 } } + } + } + % redox-keys \keys_define:nn { chemmacros / redox } { @@ -1847,22 +1900,22 @@ % --------------------------------------------------------------------------- % % spectroscopy -\tl_new:N \g__chemmacros_nmr_isotope_tl -\tl_new:N \l__chemmacros_nmr_isotope_default_tl +\tl_new:N \g__chemmacros_nmr_isotope_tl +\tl_new:N \l__chemmacros_nmr_isotope_default_tl \tl_set:Nn \l__chemmacros_nmr_isotope_default_tl { 1 } - -\tl_new:N \l__chemmacros_nmr_coupling_nuclei_tl -\tl_new:N \l__chemmacros_nmr_coupling_bonds_tl -\tl_new:N \g__chemmacros_nmr_element_coupled_tl - -\tl_new:N \g__chemmacros_nmr_element_tl -\tl_new:N \l__chemmacros_nmr_element_default_tl +\tl_new:N \l__chemmacros_nmr_coupling_nuclei_tl +\tl_new:N \l__chemmacros_nmr_coupling_bonds_tl +\tl_new:N \g__chemmacros_nmr_element_coupled_tl +\tl_new:N \g__chemmacros_nmr_element_tl +\tl_new:N \l__chemmacros_nmr_element_default_tl \tl_set:Nn \l__chemmacros_nmr_element_default_tl { H } -\tl_new:N \l__chemmacros_nmr_format_tl -\tl_new:N \l__chemmacros_nmr_delta_tl -\tl_new:N \l__chemmacros_nmr_coupling_unit_tl +\tl_new:N \l__chemmacros_nmr_format_tl +\tl_new:N \l__chemmacros_nmr_delta_tl +\tl_new:N \l__chemmacros_nmr_coupling_unit_tl \tl_set:Nn \l__chemmacros_nmr_coupling_unit_tl { \hertz } -\tl_new:N \l__chemmacros_nmr_list_setup_tl +\tl_new:N \l__chemmacros_nmr_unit_tl +\tl_set:Nn \l__chemmacros_nmr_unit_tl { \mega\hertz } +\tl_new:N \l__chemmacros_nmr_list_setup_tl \tl_set:Nn \l__chemmacros_nmr_list_setup_tl { \topsep\z@skip \partopsep\z@skip @@ -1885,10 +1938,7 @@ \bool_new:N \l__chemmacros_nmr_custom_command_active_bool \bool_new:N \l__chemmacros_nmr_custom_command_used_bool -\tl_new:N \l__chemmacros_nmr_unit_tl -\tl_set:Nn \l__chemmacros_nmr_unit_tl { \mega\hertz } - -\cs_new_nopar:Npn \chemmacros_nmr_nucleus:w #1,#2 \q_stop +\cs_new_protected:Npn \chemmacros_nmr_nucleus:w #1,#2 \q_stop { \tl_gset:Nn \g__chemmacros_nmr_isotope_tl { #1 } \tl_if_in:nnTF { #2 } { [ } @@ -1899,19 +1949,19 @@ } } -\cs_new_nopar:Npn \chemmacros_nmr_element:w #1[#2] \q_stop +\cs_new_protected:Npn \chemmacros_nmr_element:w #1[#2] \q_stop { \tl_gset:Nn \g__chemmacros_nmr_element_tl { #1 } \tl_gset:Nn \g__chemmacros_nmr_element_coupled_tl { #2 } } -\cs_new:Npn \chemmacros_nmr_default_nucleus:w #1,#2 \q_stop +\cs_new_protected:Npn \chemmacros_nmr_default_nucleus:w #1,#2 \q_stop { \tl_set:Nn \l__chemmacros_nmr_isotope_default_tl { #1 } \tl_set:Nn \l__chemmacros_nmr_element_default_tl { #2 } } -\cs_new_nopar:Npn \chemmacros_nmr_base:nn #1#2 +\cs_new_protected:Npn \chemmacros_nmr_base:nn #1#2 { \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl { @@ -1935,15 +1985,17 @@ } \cs_generate_variant:Nn \chemmacros_nmr_base:nn { VV } -\cs_new_nopar:Npn \chemmacros_nmr_frequency:n #1 +\cs_new:Npn \chemmacros_nmr_frequency:n #1 { \tl_if_in:nnTF { #1 } { , } { \chemmacros_nmr_frequency_aux_i:w #1 \q_stop } { \chemmacros_nmr_frequency_aux_ii:n { #1 } } } -\cs_new_nopar:Npn \chemmacros_nmr_frequency_aux_i:w #1,#2 \q_stop + +\cs_new:Npn \chemmacros_nmr_frequency_aux_i:w #1,#2 \q_stop { \SI { #1 } { #2 } } -\cs_new_nopar:Npn \chemmacros_nmr_frequency_aux_ii:n #1 + +\cs_new:Npn \chemmacros_nmr_frequency_aux_ii:n #1 { \SI { #1 } { \tl_use:N \l__chemmacros_nmr_unit_tl } } \keys_define:nn { chemmacros / nmr } @@ -1972,7 +2024,7 @@ \prop_new:N \l__chemmacros_nmr_prop -\NewDocumentCommand \DeclareChemNMR { mm } +\cs_new_protected:Npn \chemmacros_declare_nmr:Nn #1#2 { \prop_if_in:NnTF \l__chemmacros_nmr_prop { #1 } { \chemmacros_msg:nnxx { chemmacros } { declare-nmr } { #1 } { } } @@ -1983,7 +2035,7 @@ } } -\NewDocumentCommand \RenewChemNMR { mm } +\cs_new_protected:Npn \chemmacros_renew_nmr:Nn #1#2 { \prop_if_in:NnTF \l__chemmacros_nmr_prop { #1 } { @@ -1994,6 +2046,12 @@ { \chemmacros_msg:nnxx { chemmacros } { renew-nmr } { #1 } { } } } +\NewDocumentCommand \DeclareChemNMR { mm } + { \chemmacros_declare_nmr:Nn #1 { #2 } } + +\NewDocumentCommand \RenewChemNMR { mm } + { \chemmacros_renew_nmr:Nn #1 { #2 } } + \AtBeginDocument { % \NMR{<num>,<elem>}(<num>,<unit>)[<solvent>] ALL arguments are optional @@ -2109,13 +2167,13 @@ \IfBooleanF { #1 } { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { ~ = } } } -\cs_new_protected_nopar:Npn \chemmacros_val:n #1 +\cs_new_protected:Npn \chemmacros_val:n #1 { \tl_if_in:nnTF { #1 } { -- } { \chemmacros_val_aux:w #1 \q_nil } { \num { #1 } } } -\cs_new_protected_nopar:Npn \chemmacros_val_aux:w #1--#2 \q_nil +\cs_new_protected:Npn \chemmacros_val_aux:w #1--#2 \q_nil { \numrange { #1 } { #2 } } \NewDocumentEnvironment { experimental } { o } @@ -2164,7 +2222,7 @@ } } -\cs_new:Npn \chemmacros_nmr_coupling:w +\cs_new_protected:Npn \chemmacros_nmr_coupling:w { \tl_clear:N \l__chemmacros_nmr_coupling_nuclei_tl \tl_clear:N \l__chemmacros_nmr_coupling_bonds_tl @@ -2173,7 +2231,7 @@ { \chemmacros_nmr_coupling_auxii:w } } -\cs_new:Npn \chemmacros_nmr_coupling_auxi:w (#1;#2) +\cs_new_protected:Npn \chemmacros_nmr_coupling_auxi:w (#1;#2) { \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl { #1 } \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl { #2 } @@ -2224,20 +2282,22 @@ % --------------------------------------------------------------------------- % % placing text below atom/molecule -\cs_new_nopar:Npn \dim_to_width:nn #1#2 - { \settowidth { #1 } { #2 } } -\cs_generate_variant:Nn \dim_to_width:nn { Nn } +\cs_new_protected:Npn \chemmacros_dim_to_width:Nn #1#2 + { + \hbox_set:Nn \l__chemmacros_tmpa_box { #2 } + \dim_set:Nn #1 { \box_wd:N \l__chemmacros_tmpa_box } + \box_clear:N \l__chemmacros_tmpa_box + } \bool_new:N \l__chemmacros_mhname_width_bool \bool_set_false:N \l__chemmacros_mhname_width_bool -\dim_new:N \l__chemmacros_mhname_width_dim - -\tl_new:N \l__chemmacros_mhname_align_tl -\tl_set:Nn \l__chemmacros_mhname_align_tl { \centering } +\dim_new:N \l__chemmacros_mhname_width_dim -\tl_new:N \l__chemmacros_mhname_format_tl -\tl_new:N \l__chemmacros_mhname_fontsize_tl -\tl_set:Nn \l__chemmacros_mhname_fontsize_tl { \tiny } +\tl_new:N \l__chemmacros_mhname_align_tl +\tl_set:Nn \l__chemmacros_mhname_align_tl { \centering } +\tl_new:N \l__chemmacros_mhname_format_tl +\tl_new:N \l__chemmacros_mhname_fontsize_tl +\tl_set:Nn \l__chemmacros_mhname_fontsize_tl { \tiny } \keys_define:nn { chemmacros / mhName } { @@ -2267,7 +2327,7 @@ \underset { \bool_if:NF \l__chemmacros_mhname_width_bool - { \dim_to_width:Nn \l__chemmacros_mhname_width_dim { #2 } } + { \chemmacros_dim_to_width:Nn \l__chemmacros_mhname_width_dim { #2 } } \parbox { \dim_use:N \l__chemmacros_mhname_width_dim } { @@ -2286,8 +2346,10 @@ % --------------------------------------------------------------------------- % % - phases \bool_new:N \l__chemmacros_phases_sub_bool -\dim_new:N \l__chemmacros_phases_space_dim +\dim_new:N \l__chemmacros_phases_space_dim \dim_set:Nn \l__chemmacros_phases_space_dim { .1333 em } +\prop_new:N \l__chemmacros_phases_prop +\prop_new:N \l__chemmacros_phases_german_prop \keys_define:nn { chemmacros / phases } { @@ -2297,37 +2359,56 @@ space .dim_set:N = \l__chemmacros_phases_space_dim } -\prop_new:N \l__chemmacros_phases_prop -\prop_new:N \l__chemmacros_phases_german_prop - -\NewDocumentCommand \DeclareChemPhase { mom } +\cs_new_protected:Npn \chemmacros_declare_phase:Nnn #1#2#3 { - \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl { \char_set_catcode_letter:N \\ } { #1 } + \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl + { \char_set_catcode_letter:N \\ } + { #1 } \tl_set:Nf \l__chemmacros_tmpa_tl { \tl_tail:V \l__chemmacros_tmpa_tl } \cs_if_free:NTF #1 - { \cs_new_nopar:Npn #1 {} } + { \cs_new:Npn #1 {} } { \chemmacros_msg:nnxx { chemmacros } { declare-phase } { #1 } {} } - \IfNoValueTF { #2 } + \tl_if_blank:nTF { #2 } { \prop_put:Non \l__chemmacros_phases_german_prop { \l__chemmacros_tmpa_tl } { #3 } } { \prop_put:Non \l__chemmacros_phases_german_prop { \l__chemmacros_tmpa_tl } { #2 } } - \prop_put:Non \l__chemmacros_phases_prop { \l__chemmacros_tmpa_tl } { #3 } + \prop_put:Non \l__chemmacros_phases_prop + { \l__chemmacros_tmpa_tl } + { #3 } \chemmacros_make_phases: } -\NewDocumentCommand \RenewChemPhase { mom } +\cs_new_protected:Npn \chemmacros_renew_phase:Nnn #1#2#3 { - \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl { \char_set_catcode_letter:N \\ } { #1 } + \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl + { \char_set_catcode_letter:N \\ } + { #1 } \tl_set:Nf \l__chemmacros_tmpa_tl { \tl_tail:V \l__chemmacros_tmpa_tl } \cs_if_free:NT #1 { \chemmacros_msg:nnxx { chemmacros } { renew-phase } { #1 } {} } - \IfNoValueTF { #2 } + \tl_if_blank:nTF { #2 } { \prop_put:Non \l__chemmacros_phases_german_prop { \l__chemmacros_tmpa_tl } { #3 } } { \prop_put:Non \l__chemmacros_phases_german_prop { \l__chemmacros_tmpa_tl } { #2 } } - \prop_put:Non \l__chemmacros_phases_prop { \l__chemmacros_tmpa_tl } { #3 } + \prop_put:Non \l__chemmacros_phases_prop + { \l__chemmacros_tmpa_tl } + { #3 } \chemmacros_make_phases: } -\cs_new_nopar:Npn \chemmacros_make_phases: +\NewDocumentCommand \DeclareChemPhase { mom } + { + \IfNoValueTF { #2 } + { \chemmacros_declare_phase:Nnn #1 { } { #3 } } + { \chemmacros_declare_phase:Nnn #1 { #2 } { #3 } } + } + +\NewDocumentCommand \RenewChemPhase { mom } + { + \IfNoValueTF { #2 } + { \chemmacros_renew_phase:Nnn #1 { } { #3 } } + { \chemmacros_renew_phase:Nnn #1 { #2 } { #3 } } + } + +\cs_new_protected:Npn \chemmacros_make_phases: { \bool_if:NTF \l__chemmacros_german_bool { @@ -2340,9 +2421,9 @@ } } -\cs_new_nopar:Npn \chemmacros_define_phases:nn #1#2 +\cs_new_protected:Npn \chemmacros_define_phases:nn #1#2 { - \cs_set_nopar:cpn { #1 } + \cs_set:cpn { #1 } { \bool_if:NTF \l__chemmacros_phases_sub_bool { @@ -2363,9 +2444,9 @@ \DeclareChemPhase \sld [ f ] { s } \DeclareChemPhase \lqd [ f{}l ] { l } \DeclareChemPhase \gas { g } -\DeclareChemPhase \aq { aq } +\DeclareChemPhase \aq { aq } -\NewDocumentCommand \phase { m } +\cs_new:Npn \chemmacros_phase:n #1 { \bool_if:NTF \l__chemmacros_phases_sub_bool { \ensuremath { \c_math_subscript_token { \text { (#1) } } } } @@ -2378,9 +2459,12 @@ } } +\NewDocumentCommand \phase { m } + { \chemmacros_phase:n { #1 } } + \bool_if:NT \l__chemmacros_version_one_bool { - \cs_new_eq:NN \solid \sld + \cs_new_eq:NN \solid \sld \cs_new_eq:NN \liquid \lqd } @@ -2391,7 +2475,7 @@ % entry to the list of reactions even if the user redefines the reaction tag \AfterPackage* { mathtools } { - \cs_set_nopar:Npn \MT_define_tagform:nwnn #1[#2]#3#4 + \cs_set:Npn \MT_define_tagform:nwnn #1[#2]#3#4 { \@namedef{MT_tagform_#1:n}##1 { @@ -2412,19 +2496,23 @@ } \tl_new:N \g__chemmacros_reaction_description_tl -\NewDocumentCommand \AddRxnDesc { m } + +\cs_new_protected:Npn \chemmacros_add_reaction_description:n #1 { \tl_if_blank:nF { #1 } { \tl_gset:Nn \g__chemmacros_reaction_description_tl { : ~ #1 } } } +\NewDocumentCommand \AddRxnDesc { m } + { \chemmacros_add_reaction_description:n { #1 } } + % define \listofreactions -\tl_new:N \l__chemmacros_reaction_lorname_tl +\tl_new:N \l__chemmacros_reaction_lorname_tl \tl_set:Nn \l__chemmacros_reaction_lorname_tl { Reaction ~ } -\tl_new:N \reactionlistname +\tl_new:N \reactionlistname \tl_set:Nn \reactionlistname { List~of~reactions } -% language settings +% language settings % TODO \AtBeginDocument { \bool_if:NT \l__chemmacros_german_bool @@ -2458,12 +2546,12 @@ \newcounter { reaction } % switch to reaction tags -\cs_new_nopar:Npn \chemmacros_begin_reaction: +\cs_new:Npn \chemmacros_begin_reaction: { % create individual names for `hyperref': \bool_if:NT \l__chemmacros_hyperref_bool { - \cs_set_nopar:Npn \theHequation + \cs_set:Npn \theHequation { R . \theHsection . \arabic { reaction } } } % enable labelformat `reaction': @@ -2477,7 +2565,7 @@ } % switch back to equation tags -\cs_new_nopar:Npn \chemmacros_end_reaction: +\cs_new:Npn \chemmacros_end_reaction: { \setcounter { reaction } { \value { equation } } \setcounter { equation } { \value { chemmacros_save_reaction } } @@ -2498,6 +2586,7 @@ \tl_set:Nn \l__chemmacros_reaction_lorname_tl { #1 ~ } } +% TODO separate document and module level % \DeclareChemReaction[<keyval>]{<name>}{<type>} \bool_if:NF \l__chemmacros_version_one_bool { @@ -2568,7 +2657,7 @@ { \bool_if:NTF \l__chemmacros_use_mhchem_bool { \cee { #1 } } - { \ch { #1 } } + { \ch { #1 } } } \cs_generate_variant:Nn \chemmacros_equation_chemformula:n { o } @@ -2584,11 +2673,11 @@ % \standardstate as defined by the chemstyle package. Thanks to Joseph Wright \cs_if_exist:NF \standardstate { - \cs_new_nopar:Npn \standardstate + \cs_new:Npn \standardstate { \ensuremath { \chemmacros_standardstate: } } - \cs_new_nopar:Npn \chemmacros_standardstate: + \cs_new:Npn \chemmacros_standardstate: { \mathpalette \chemmacros_standardstate_aux: \circ } - \cs_new_nopar:Npn \chemmacros_standardstate_aux: #1#2 + \cs_new:Npn \chemmacros_standardstate_aux: #1#2 { \ooalign { @@ -2606,16 +2695,17 @@ % --------------------------------------------------------------------------- % % \State -\tl_new:N \l__chemmacros_State_delta_tl -\tl_set:Nn \l__chemmacros_State_delta_tl { \Delta } +\tl_new:N \l__chemmacros_State_delta_tl +\tl_set:Nn \l__chemmacros_State_delta_tl { \Delta } +\tl_new:N \l__chemmacros_State_exponent_tl +\tl_set:Nn \l__chemmacros_State_exponent_tl { \standardstate } + \bool_new:N \l__chemmacros_State_delta_bool \bool_set_true:N \l__chemmacros_State_delta_bool \bool_new:N \l__chemmacros_State_subscript_left_bool \bool_set_true:N \l__chemmacros_State_subscript_left_bool \bool_new:N \l__chemmacros_State_exponent_bool \bool_set_true:N \l__chemmacros_State_exponent_bool -\tl_new:N \l__chemmacros_State_exponent_tl -\tl_set:Nn \l__chemmacros_State_exponent_tl { \standardstate } \keys_define:nn { chemmacros / state } { @@ -2647,7 +2737,7 @@ % old syntax (v2.0): % \State[<keyval>]{<Symbol>}{<subscript>} % {<subscript>} is an optional argument! -\cs_new_nopar:Npn \chemmacros_state:nnn #1#2#3 +\cs_new:Npn \chemmacros_state:nnn #1#2#3 { \group_begin: \IfNoValueF { #1 } @@ -2684,19 +2774,16 @@ } % --------------------------------------------------------------------------- % -\tl_new:N \l__chemmacros_thermod_subscript_left_tl -\tl_new:N \l__chemmacros_thermod_subscript_left_default_tl -\tl_new:N \l__chemmacros_thermod_subscript_tl -\tl_new:N \l__chemmacros_thermod_subscript_default_tl - -\tl_new:N \l__chemmacros_thermod_unit_tl - -\tl_new:N \l__chemmacros_thermod_exponent_tl -\tl_new:N \l__chemmacros_thermod_exponent_default_tl +\tl_new:N \l__chemmacros_thermod_subscript_left_tl +\tl_new:N \l__chemmacros_thermod_subscript_left_default_tl +\tl_new:N \l__chemmacros_thermod_subscript_tl +\tl_new:N \l__chemmacros_thermod_subscript_default_tl +\tl_new:N \l__chemmacros_thermod_unit_tl +\tl_new:N \l__chemmacros_thermod_exponent_tl +\tl_new:N \l__chemmacros_thermod_exponent_default_tl \tl_set:Nn \l__chemmacros_thermod_exponent_default_tl { \standardstate } - -\tl_new:N \l__chemmacros_thermod_delta_tl -\tl_new:N \l__chemmacros_thermod_delta_default_tl +\tl_new:N \l__chemmacros_thermod_delta_tl +\tl_new:N \l__chemmacros_thermod_delta_default_tl \tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \Delta } \bool_new:N \l__chemmacros_renewstate_bool @@ -2724,6 +2811,7 @@ \l__chemmacros_thermod_delta_default_tl } +% TODO: separate document and module lavel % \DeclareChemState[<keyval>]{<name>}{<symbol>}{<unit>} \bool_if:NF \l__chemmacros_version_one_bool { @@ -2758,7 +2846,7 @@ } } -\cs_new_nopar:Npn \chemmacros_setnewstate_reset: +\cs_new:Npn \chemmacros_setnewstate_reset: { \tl_set:Nn \l__chemmacros_thermod_subscript_left_default_tl { true } \tl_clear:N \l__chemmacros_thermod_subscript_default_tl @@ -2809,7 +2897,7 @@ \tl_const:cn { l__chemmacros_ #1 _unit_tl } { #3 } - \cs_new_nopar:cpn {chemmacros_ #1 _reset: } + \cs_new:cpn {chemmacros_ #1 _reset: } { \tl_set_eq:Nc \l__chemmacros_thermod_subscript_tl @@ -2827,7 +2915,7 @@ \l__chemmacros_thermod_unit_tl { l__chemmacros_ #1 _unit_tl } } - \cs_new_nopar:cpn { #1 } + \cs_new:cpn { #1 } { \use:c {chemmacros_ #1 _reset: } \peek_meaning:NTF [ @@ -2838,19 +2926,19 @@ { \tl_use:c { #1 _aux_iii:n } } } } - \cs_new_nopar:cpn { #1 _aux_i:n } [##1] + \cs_new:cpn { #1 _aux_i:n } [##1] { \keys_set:nn { chemmacros / State } { ##1 } \peek_meaning:NTF ( { \tl_use:c { #1 _aux_ii:n } } { \tl_use:c { #1 _aux_iii:n } } } - \cs_new_nopar:cpn { #1 _aux_ii:n } (##1) + \cs_new:cpn { #1 _aux_ii:n } (##1) { \tl_set:Nn \l__chemmacros_thermod_subscript_tl { ##1 } \tl_use:c { #1 _aux_iii:n } } - \cs_new_nopar:cpn { #1 _aux_iii:n } ##1 + \cs_new:cpn { #1 _aux_iii:n } ##1 { \ensuremath { @@ -2890,37 +2978,32 @@ % predefined: \bool_if:NF \l__chemmacros_version_one_bool { - \DeclareChemState {Enthalpy} {H} {\kilo\joule\per\mole} + \DeclareChemState {Enthalpy} + {H} {\kilo\joule\per\mole} \DeclareChemState [ delta=false, subscript-left=false ] {Entropy} {S} {\joule\per\kelvin\per\mole} - \DeclareChemState {Gibbs} {G} {\kilo\joule\per\mole} + \DeclareChemState {Gibbs} + {G} {\kilo\joule\per\mole} } % --------------------------------------------------------------------------- % % Newman projections -\fp_new:N \l__chemmacros_newman_rel_angle_fp -\fp_zero:N \l__chemmacros_newman_rel_angle_fp -\fp_new:N \l__chemmacros_newman_tmp_angle_fp -\fp_new:N \l__chemmacros_newman_abs_angle_fp -\fp_zero:N \l__chemmacros_newman_abs_angle_fp - -\fp_new:N \l__chemmacros_newman_scale_fp -\fp_set:Nn \l__chemmacros_newman_scale_fp { 1 } - -\tl_new:N \l__chemmacros_newman_tikz_ring_tl -\tl_clear:N \l__chemmacros_newman_tikz_ring_tl - -\tl_new:N \l__chemmacros_newman_tikz_front_tl -\tl_clear:N \l__chemmacros_newman_tikz_front_tl - -\tl_new:N \l__chemmacros_newman_tikz_back_tl -\tl_clear:N \l__chemmacros_newman_tikz_back_tl +\fp_new:N \l__chemmacros_newman_rel_angle_fp +\fp_zero:N \l__chemmacros_newman_rel_angle_fp +\fp_new:N \l__chemmacros_newman_tmp_angle_fp +\fp_new:N \l__chemmacros_newman_abs_angle_fp +\fp_zero:N \l__chemmacros_newman_abs_angle_fp +\fp_new:N \l__chemmacros_newman_scale_fp +\fp_set:Nn \l__chemmacros_newman_scale_fp { 1 } +\fp_new:N \l__chemmacros_newman_x_fp +\fp_new:N \l__chemmacros_newman_y_fp + +\tl_new:N \l__chemmacros_newman_tikz_ring_tl +\tl_new:N \l__chemmacros_newman_tikz_front_tl +\tl_new:N \l__chemmacros_newman_tikz_back_tl \bool_new:N \l__chemmacros_newman_tikz_back_bool -\fp_new:N \l__chemmacros_newman_x_fp -\fp_new:N \l__chemmacros_newman_y_fp - \keys_define:nn { chemmacros / newman } { ring .tl_set:N = \l__chemmacros_newman_tikz_ring_tl , @@ -2936,6 +3019,7 @@ angle .default:n = 0 } +% TODO separate document and module level % \newman[<keyval>](<angle>){<1>,<2>,<3>,<4>,<5>,<6>} \bool_if:NF \l__chemmacros_version_one_bool { @@ -3002,30 +3086,25 @@ } % provide cartesian coordiantes from polar coordinates -% #1: angle pi #2: radius -\cs_new_nopar:Npn \chemmacros_newman_coordinates:nn #1#2 - { - \fp_set:Nn \l__chemmacros_newman_tmp_angle_fp { #1 } - \fp_div:Nn \l__chemmacros_newman_tmp_angle_fp { 180 } - \fp_mul:Nn \l__chemmacros_newman_tmp_angle_fp { \fp_use:N \c_pi_fp } - \fp_zero:N \l__chemmacros_newman_x_fp - \fp_zero:N \l__chemmacros_newman_y_fp - \fp_cos:Nn \l__chemmacros_newman_x_fp - { \fp_use:N \l__chemmacros_newman_tmp_angle_fp } - \fp_sin:Nn \l__chemmacros_newman_y_fp - { \fp_use:N \l__chemmacros_newman_tmp_angle_fp } - \fp_mul:Nn \l__chemmacros_newman_x_fp { \fp_use:N #2 } - \fp_mul:Nn \l__chemmacros_newman_y_fp { \fp_use:N #2 } - } -\cs_generate_variant:Nn \chemmacros_newman_coordinates:nn { on } +% #1: fp variable for x +% #2: fp variable for y +% #3: angle +% #4: radius +\cs_new:Npn \chemmacros_polar_to_cartesian:NNnn #1#2#3#4 + { + \fp_set:Nn #1 { #4 * cos( #3 / 180 * pi ) }% x + \fp_set:Nn #2 { #4 * sin( #3 / 180 * pi ) }% y + } % place back nodes \cs_new:Npn \chemmacros_newman_back_node:nn #1#2 { \group_begin: \fp_add:Nn \l__chemmacros_newman_rel_angle_fp { #1 } - \chemmacros_newman_coordinates:on - { \fp_to_int:N \l__chemmacros_newman_rel_angle_fp } + \chemmacros_polar_to_cartesian:NNnn + \l__chemmacros_newman_x_fp + \l__chemmacros_newman_y_fp + { \l__chemmacros_newman_rel_angle_fp } { \l__chemmacros_newman_scale_fp } \chemmacros_tikz_draw:f { \tl_use:N \l__chemmacros_newman_tikz_ring_tl } @@ -3038,8 +3117,10 @@ 30 * \fp_to_dim:N \l__chemmacros_newman_x_fp , 30 * \fp_to_dim:N \l__chemmacros_newman_y_fp ) ; - \chemmacros_newman_coordinates:on - { \fp_to_int:N \l__chemmacros_newman_rel_angle_fp } + \chemmacros_polar_to_cartesian:NNnn + \l__chemmacros_newman_x_fp + \l__chemmacros_newman_y_fp + { \l__chemmacros_newman_rel_angle_fp } { \l__chemmacros_newman_scale_fp } \chemmacros_tikz_node:f { @@ -3059,7 +3140,11 @@ % place front nodes: \cs_new:Npn \chemmacros_newman_front_node:nn #1#2 { - \chemmacros_newman_coordinates:nn { #1 } { \l__chemmacros_newman_scale_fp } + \chemmacros_polar_to_cartesian:NNnn + \l__chemmacros_newman_x_fp + \l__chemmacros_newman_y_fp + { #1 } + { \l__chemmacros_newman_scale_fp } \chemmacros_tikz_draw:f { \tl_use:N \l__chemmacros_newman_tikz_ring_tl } (0,0) -- ++ @@ -3067,7 +3152,11 @@ 30 * \fp_to_dim:N \l__chemmacros_newman_x_fp , 30 * \fp_to_dim:N \l__chemmacros_newman_y_fp ) ; - \chemmacros_newman_coordinates:nn { #1 } { \l__chemmacros_newman_scale_fp } + \chemmacros_polar_to_cartesian:NNnn + \l__chemmacros_newman_x_fp + \l__chemmacros_newman_y_fp + { #1 } + { \l__chemmacros_newman_scale_fp } \chemmacros_tikz_node:f { chemmacros_newman_atom_front, anchor = -180 + #1 } at @@ -3087,77 +3176,56 @@ \bool_new:N \l__chemmacros_orbital_type_sp_bool \bool_new:N \l__chemmacros_orbital_type_sptwo_bool \bool_new:N \l__chemmacros_orbital_type_spthree_bool - -\tl_new:N \l__chemmacros_orbital_s_color_tl -\tl_set:Nn \l__chemmacros_orbital_s_color_tl { black } -\tl_new:N \l__chemmacros_orbital_s_phase_color_tl - -\tl_new:N \l__chemmacros_orbital_p_color_tl -\tl_set:Nn \l__chemmacros_orbital_p_color_tl { black } -\tl_new:N \l__chemmacros_orbital_p_pphase_color_tl -\tl_new:N \l__chemmacros_orbital_p_mphase_color_tl - -\tl_new:N \l__chemmacros_orbital_sp_color_tl -\tl_set:Nn \l__chemmacros_orbital_sp_color_tl { black } -\tl_new:N \l__chemmacros_orbital_sp_pphase_color_tl -\tl_new:N \l__chemmacros_orbital_sp_mphase_color_tl - -\tl_new:N \l__chemmacros_orbital_sptwo_color_tl -\tl_set:Nn \l__chemmacros_orbital_sptwo_color_tl { black } -\tl_new:N \l__chemmacros_orbital_sptwo_pphase_color_tl -\tl_new:N \l__chemmacros_orbital_sptwo_mphase_color_tl - -\tl_new:N \l__chemmacros_orbital_spthree_color_tl -\tl_set:Nn \l__chemmacros_orbital_spthree_color_tl { black } -\tl_new:N \l__chemmacros_orbital_spthree_pphase_color_tl -\tl_new:N \l__chemmacros_orbital_spthree_mphase_color_tl - \bool_new:N \l__chemmacros_orbital_s_phase_bool \bool_set_true:N \l__chemmacros_orbital_s_phase_bool - \bool_new:N \l__chemmacros_orbital_p_phase_bool \bool_set_true:N \l__chemmacros_orbital_p_phase_bool - \bool_new:N \l__chemmacros_orbital_sp_phase_bool \bool_set_true:N \l__chemmacros_orbital_sp_phase_bool - \bool_new:N \l__chemmacros_orbital_sptwo_phase_bool \bool_set_true:N \l__chemmacros_orbital_sptwo_phase_bool - \bool_new:N \l__chemmacros_orbital_spthree_phase_bool \bool_set_true:N \l__chemmacros_orbital_spthree_phase_bool +\bool_new:N \l__chemmacros_orbital_p_half_bool +\bool_new:N \l__chemmacros_orbital_overlay_bool +\bool_new:N \l__chemmacros_orbital_opacity_bool -\tl_new:N \l__chemmacros_orbital_s_scale_tl +\tl_new:N \l__chemmacros_orbital_s_color_tl +\tl_set:Nn \l__chemmacros_orbital_s_color_tl { black } +\tl_new:N \l__chemmacros_orbital_s_phase_color_tl +\tl_new:N \l__chemmacros_orbital_p_color_tl +\tl_set:Nn \l__chemmacros_orbital_p_color_tl { black } +\tl_new:N \l__chemmacros_orbital_p_pphase_color_tl +\tl_new:N \l__chemmacros_orbital_p_mphase_color_tl +\tl_new:N \l__chemmacros_orbital_sp_color_tl +\tl_set:Nn \l__chemmacros_orbital_sp_color_tl { black } +\tl_new:N \l__chemmacros_orbital_sp_pphase_color_tl +\tl_new:N \l__chemmacros_orbital_sp_mphase_color_tl +\tl_new:N \l__chemmacros_orbital_sptwo_color_tl +\tl_set:Nn \l__chemmacros_orbital_sptwo_color_tl { black } +\tl_new:N \l__chemmacros_orbital_sptwo_pphase_color_tl +\tl_new:N \l__chemmacros_orbital_sptwo_mphase_color_tl +\tl_new:N \l__chemmacros_orbital_spthree_color_tl +\tl_set:Nn \l__chemmacros_orbital_spthree_color_tl { black } +\tl_new:N \l__chemmacros_orbital_spthree_pphase_color_tl +\tl_new:N \l__chemmacros_orbital_spthree_mphase_color_tl +\tl_new:N \l__chemmacros_orbital_s_scale_tl \tl_set:Nn \l__chemmacros_orbital_s_scale_tl { 1 } - -\tl_new:N \l__chemmacros_orbital_p_scale_tl +\tl_new:N \l__chemmacros_orbital_p_scale_tl \tl_set:Nn \l__chemmacros_orbital_p_scale_tl { 1 } - -\tl_new:N \l__chemmacros_orbital_sp_scale_tl +\tl_new:N \l__chemmacros_orbital_sp_scale_tl \tl_set:Nn \l__chemmacros_orbital_sp_scale_tl { 1 } - -\tl_new:N \l__chemmacros_orbital_sptwo_scale_tl +\tl_new:N \l__chemmacros_orbital_sptwo_scale_tl \tl_set:Nn \l__chemmacros_orbital_sptwo_scale_tl { 1 } - -\tl_new:N \l__chemmacros_orbital_spthree_scale_tl +\tl_new:N \l__chemmacros_orbital_spthree_scale_tl \tl_set:Nn \l__chemmacros_orbital_spthree_scale_tl { 1 } -\fp_new:N \l__chemmacros_orbital_angle_fp +\fp_new:N \l__chemmacros_orbital_angle_fp \fp_set:Nn \l__chemmacros_orbital_angle_fp { 90 } - -\bool_new:N \l__chemmacros_orbital_p_half_bool -\bool_set_false:N \l__chemmacros_orbital_p_half_bool - -\bool_new:N \l__chemmacros_orbital_overlay_bool -\bool_set_false:N \l__chemmacros_orbital_overlay_bool - -\bool_new:N \l__chemmacros_orbital_opacity_bool -\bool_set_false:N \l__chemmacros_opacity_overlay_bool - -\fp_new:N \l__chemmacros_orbital_opacity_fp +\fp_new:N \l__chemmacros_orbital_opacity_fp \fp_set:Nn \l__chemmacros_orbital_opacity_fp { 0.5 } -\cs_new_nopar:Npn \chemmacros_orbital_options: +\cs_new:Npn \chemmacros_orbital_options: { \chemmacros_orbital_overlay: , \chemmacros_orbital_opacity: , inner~sep=0 , outer~sep=0 , line~width=.2pt , @@ -3166,12 +3234,10 @@ minimum~size = 0 } -\cs_new_nopar:Npn \chemmacros_orbital_overlay: - { - \bool_if:NT \l__chemmacros_orbital_overlay_bool { overlay } - } +\cs_new:Npn \chemmacros_orbital_overlay: + { \bool_if:NT \l__chemmacros_orbital_overlay_bool { overlay } } -\cs_new_nopar:Npn \chemmacros_orbital_opacity: +\cs_new:Npn \chemmacros_orbital_opacity: { \bool_if:NT \l__chemmacros_orbital_opacity_bool { opacity = { \fp_use:N \l__chemmacros_orbital_opacity_fp } } @@ -3179,7 +3245,7 @@ % --------------------------------------------------------------------------- % % s-orbitals -\cs_new_nopar:Npn \chemmacros_orbital_type_s: +\cs_new:Npn \chemmacros_orbital_type_s: { \bool_set_true:N \l__chemmacros_orbital_type_s_bool \bool_set_false:N \l__chemmacros_orbital_type_p_bool @@ -3199,7 +3265,7 @@ color .tl_set:N = \l__chemmacros_orbital_s_color_tl } -\cs_new_nopar:Npn \chemmacros_orbital_s_draw:n #1 +\cs_new:Npn \chemmacros_orbital_s_draw:n #1 { \IfNoValueF { #1 } { \keys_set:nn { chemmacros / orbital / s } { #1 } } \bool_if:NTF \l__chemmacros_orbital_s_phase_bool @@ -3228,10 +3294,10 @@ % --------------------------------------------------------------------------- % % p-orbitals -\cs_new_nopar:Npn \chemmacros_orbital_type_p: +\cs_new:Npn \chemmacros_orbital_type_p: { \bool_set_false:N \l__chemmacros_orbital_type_s_bool - \bool_set_true:N \l__chemmacros_orbital_type_p_bool + \bool_set_true:N \l__chemmacros_orbital_type_p_bool \bool_set_false:N \l__chemmacros_orbital_type_sp_bool \bool_set_false:N \l__chemmacros_orbital_type_sptwo_bool \bool_set_false:N \l__chemmacros_orbital_type_spthree_bool @@ -3251,7 +3317,7 @@ half .default:n = true } -\cs_new_nopar:Npn \chemmacros_orbital_p_draw:n #1 +\cs_new:Npn \chemmacros_orbital_p_draw:n #1 { \IfNoValueF { #1 } { \keys_set:nn { chemmacros / orbital / p } { #1 } } \bool_if:NTF \l__chemmacros_orbital_p_phase_bool @@ -3324,11 +3390,11 @@ % --------------------------------------------------------------------------- % % sp-orbitals -\cs_new_nopar:Npn \chemmacros_orbital_type_sp: +\cs_new:Npn \chemmacros_orbital_type_sp: { \bool_set_false:N \l__chemmacros_orbital_type_s_bool \bool_set_false:N \l__chemmacros_orbital_type_p_bool - \bool_set_true:N \l__chemmacros_orbital_type_sp_bool + \bool_set_true:N \l__chemmacros_orbital_type_sp_bool \bool_set_false:N \l__chemmacros_orbital_type_sptwo_bool \bool_set_false:N \l__chemmacros_orbital_type_spthree_bool } @@ -3345,7 +3411,7 @@ color .tl_set:N = \l__chemmacros_orbital_sp_color_tl } -\cs_new_nopar:Npn \chemmacros_orbital_sp_draw:n #1 +\cs_new:Npn \chemmacros_orbital_sp_draw:n #1 { \IfNoValueF { #1 } { \keys_set:nn { chemmacros / orbital / sp } { #1 } } \bool_if:NTF \l__chemmacros_orbital_sp_phase_bool @@ -3415,12 +3481,12 @@ % --------------------------------------------------------------------------- % % sp2-orbitals -\cs_new_nopar:Npn \chemmacros_orbital_type_sptwo: +\cs_new:Npn \chemmacros_orbital_type_sptwo: { \bool_set_false:N \l__chemmacros_orbital_type_s_bool \bool_set_false:N \l__chemmacros_orbital_type_p_bool \bool_set_false:N \l__chemmacros_orbital_type_sp_bool - \bool_set_true:N \l__chemmacros_orbital_type_sptwo_bool + \bool_set_true:N \l__chemmacros_orbital_type_sptwo_bool \bool_set_false:N \l__chemmacros_orbital_type_spthree_bool } @@ -3436,7 +3502,7 @@ color .tl_set:N = \l__chemmacros_orbital_sptwo_color_tl } -\cs_new_nopar:Npn \chemmacros_orbital_sptwo_draw:n #1 +\cs_new:Npn \chemmacros_orbital_sptwo_draw:n #1 { \IfNoValueF { #1 } { \keys_set:nn { chemmacros / orbital / sp2 } { #1 } } \bool_if:NTF \l__chemmacros_orbital_sptwo_phase_bool @@ -3506,13 +3572,13 @@ % --------------------------------------------------------------------------- % % sp3-orbitals -\cs_new_nopar:Npn \chemmacros_orbital_type_spthree: +\cs_new:Npn \chemmacros_orbital_type_spthree: { \bool_set_false:N \l__chemmacros_orbital_type_s_bool \bool_set_false:N \l__chemmacros_orbital_type_p_bool \bool_set_false:N \l__chemmacros_orbital_type_sp_bool \bool_set_false:N \l__chemmacros_orbital_type_sptwo_bool - \bool_set_true:N \l__chemmacros_orbital_type_spthree_bool + \bool_set_true:N \l__chemmacros_orbital_type_spthree_bool } \keys_define:nn { chemmacros / orbital / sp3 } @@ -3527,7 +3593,7 @@ color .tl_set:N = \l__chemmacros_orbital_spthree_color_tl } -\cs_new_nopar:Npn \chemmacros_orbital_spthree_draw:n #1 +\cs_new:Npn \chemmacros_orbital_spthree_draw:n #1 { \IfNoValueF { #1 } { \keys_set:nn { chemmacros / orbital / sp3 } { #1 } } \bool_if:NTF \l__chemmacros_orbital_spthree_phase_bool @@ -3619,6 +3685,7 @@ sp3 .code:n = { \chemmacros_orbital_type_spthree: } } +% TODO separate document and module level \NewDocumentCommand \orbital { o m } { \group_begin: @@ -3730,7 +3797,7 @@ \NewDocumentCommand \chemsetup { o m } { \IfNoValueTF { #1 } - { \keys_set:nn { chemmacros } { #2 } } + { \keys_set:nn { chemmacros } { #2 } } { \keys_set:nn { chemmacros / #1 } { #2 } } \ignorespaces } @@ -3738,9 +3805,7 @@ % --------------------------------------------------------------------------- % % load old definitions: \bool_if:NT \l__chemmacros_version_one_bool - { - \input { chemmacros-version1 . cfg } - } + { \file_input:n { chemmacros-version1 . cfg } } % --------------------------------------------------------------------------- % % hyperref support @@ -3749,7 +3814,7 @@ { \pdfstringdefDisableCommands { - \cs_set:Npn \- { - } + \cs_set:Npn \- { - }% myabe not a good idea... \cs_set:Npn \| { } \cs_set:Npn \iupac #1 { #1 } \cs_set:Npn \pH { pH } @@ -3887,6 +3952,14 @@ Version history and `radical-radius' 2012/10/03 - version 3.4a - bug fix in coupling constant \J 2013/01/04 - version 3.4b - bug fix in the sub- and superscript handling +2013/01/28 - version 3.5 - disallow breaks at bonds + - allow breaks after arrows + - made some spaces in chemformulas stretch- and + shrinkable + - various internal code improvements + - changed defaults for horizontal spaces that have in + set in ex into corresponding values in em. + - improvements to the placement of sub- and superscripts % --------------------------------------------------------------------------- % % TODO: diff --git a/Master/texmf-dist/tex/latex/chemmacros/language/ghsystem_english.def b/Master/texmf-dist/tex/latex/chemmacros/language/ghsystem_english.def index 521d0d7cc6c..e4324bc4c71 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/language/ghsystem_english.def +++ b/Master/texmf-dist/tex/latex/chemmacros/language/ghsystem_english.def @@ -225,7 +225,7 @@ \prop_put:Nnn \l__ghsystem_p_prop { 283 } { Wear~fire/flame~re\-sis\-tant/re\-tar\-dant~clo\-thing. } \prop_put:Nnn \l__ghsystem_p_prop { 284 } { Wear~res\-pi\-ra\-to\-ry~pro\-tec\-tion. } \prop_put:Nnn \l__ghsystem_p_prop { 285 } { In~case~of~in\-ade\-quate~ven\-ti\-la\-tion~wear~res\-pi\-ra\-to\-ry~pro\-tec\-tion. } -\prop_put:Nnn \l__ghsystem_p_prop { 231 + 231 } { Handle~un\-der~inert~gas.~Pro\-tect~from~mois\-ture. } +\prop_put:Nnn \l__ghsystem_p_prop { 231 + 232 } { Handle~un\-der~inert~gas.~Pro\-tect~from~mois\-ture. } \prop_put:Nnn \l__ghsystem_p_prop { 235 + 410 } { Keep~cool.~Pro\-tect~from~sun\-light. } % 3.3 Precautionary Statements — Response |