diff options
author | Karl Berry <karl@freefriends.org> | 2013-03-02 01:13:28 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-03-02 01:13:28 +0000 |
commit | e77fff9dbd365d2a2cf838b2a1f3d71ef5ecfad7 (patch) | |
tree | ca85b1713d99d96141cdba28d336ada6e762b581 /Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | |
parent | b979b6977fcd5d334404b254bba05601f4fd0bcb (diff) |
chemmacros (28feb13)
git-svn-id: svn://tug.org/texlive/trunk@29263 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | 452 |
1 files changed, 245 insertions, 207 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index e8212bf0bff..38b5e573c43 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.5a} -\def\chemmacros@date{2013/02/19} +\def\chemmacros@version{3.6} +\def\chemmacros@date{2013/02/26} \ProvidesExplPackage {chemmacros} @@ -302,7 +302,6 @@ \bool_new:N \l__chemmacros_strict_bool \bool_new:N \l__chemmacros_detect_bold_bool \bool_set_true:N \l__chemmacros_detect_bold_bool - \bool_new:N \l__chemmacros_use_upgreek_bool \bool_new:N \l__chemmacros_use_textgreek_bool \bool_new:N \l__chemmacros_option_greek_set_bool @@ -578,13 +577,13 @@ % --------------------------------------------------------------------------- % % circled charge signs \cs_new_protected:Npn \chemmacros_fplus: - { \ensuremath { \chemmacros_fplus_aux_i: } } + { \ensuremath { \__chemmacros_fplus: } } -\cs_new:Npn \chemmacros_fplus_aux_i: - { \mathpalette \chemmacros_fplus_aux_ii: \bigcirc } +\cs_new:Npn \__chemmacros_fplus: + { \mathpalette \__chemmacros_fplus_aux: \bigcirc } % TODO: can I rewrite this in a more "expl3-way"? -\cs_new:Npn \chemmacros_fplus_aux_ii: #1#2 +\cs_new:Npn \__chemmacros_fplus_aux: #1#2 { \ooalign { @@ -600,12 +599,12 @@ } \cs_new_protected:Npn \chemmacros_fminus: - { \ensuremath { \chemmacros_fminus_aux_i: } } + { \ensuremath { \__chemmacros_fminus: } } -\cs_new:Npn \chemmacros_fminus_aux_i: - { \mathpalette \chemmacros_fminus_aux_aux_ii: \bigcirc } +\cs_new:Npn \__chemmacros_fminus: + { \mathpalette \__chemmacros_fminus_aux_aux: \bigcirc } -\cs_new:Npn \chemmacros_fminus_aux_aux_ii: #1#2 +\cs_new:Npn \__chemmacros_fminus_aux_aux: #1#2 { \ooalign { @@ -667,7 +666,7 @@ % --------------------------------------------------------------------------- % % transition state symbol -\cs_new:Npn \chemmacros_transition_state_aux: +\cs_new:Npn \__chemmacros_transition_state: { \text { @@ -689,7 +688,7 @@ { \textstyle } { \scriptstyle } { \scriptscriptstyle } - \chemmacros_transition_state_aux: + \__chemmacros_transition_state: } } @@ -941,9 +940,8 @@ { \cs_set_eq:NN \Nu \chemmacros_Nu:w } } -\NewDocumentCommand \ba { o } +\cs_new:Npn \chemmacros_ba: { - \IfNoValueF { #1 } { \keys_set:nn { chemmacros / particle } { #1 } } \bool_if:NTF \l__chemmacros_particle_elpair_bool { \chemmacros_elpair:n { ba } \mch } { @@ -954,6 +952,14 @@ \chemmacros_xspace: } +\NewDocumentCommand \ba { o } + { + \group_begin: + \IfNoValueF { #1 } { \keys_set:nn { chemmacros / particle } { #1 } } + \chemmacros_ba: + \group_end: + } + \cs_new:Npn \chemmacros_elpair:n #1 { \bool_if:NTF \l__chemmacros_chemfig_bool @@ -1067,6 +1073,9 @@ { cip-kern .dim_set:N = \l__chemmacros_cip_kern_dim } \NewDocumentCommand \cip { m } + { \chemmacros_cip:n { #1 } } + +\cs_new:Npn \chemmacros_cip:n #1 { \cs_if_exist:NTF \EmbracOff { \textit* { (#1) } } @@ -1082,7 +1091,7 @@ % TikZ needs : to be other \ExplSyntaxOff -\NewDocumentCommand\Sconf{O{S}} +\def\chemmacros@sconf#1% {% \tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex] { @@ -1091,7 +1100,7 @@ }% } -\NewDocumentCommand\Rconf{O{R}} +\def\chemmacros@rconf#1% {% \tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex] { @@ -1101,6 +1110,9 @@ } \ExplSyntaxOn +\NewDocumentCommand \Sconf { O{S} } { \chemmacros@sconf { #1 } } +\NewDocumentCommand \Rconf { O{R} } { \chemmacros@rconf { #1 } } + % E(ntgegen)/Z(usammen) \DeclareChemIUPAC \E { \cip { E } } \DeclareChemIUPAC \Z { \cip { Z } } @@ -1375,7 +1387,7 @@ \chemmacros_xspace: } -\NewDocumentCommand \p { m } +\cs_new:Npn \chemmacros_p:n #1 { \group_begin: \chemmacros_p_style:n { p } @@ -1383,15 +1395,24 @@ \group_end: } +\NewDocumentCommand \p { m } + { \chemmacros_p:n { #1 } } + \cs_new_protected:Npn \pH - { \p { \chemmacros_chemformula:n { H } } \chemmacros_xspace: } + { + \chemmacros_p:n { \chemmacros_chemformula:n { H } } + \chemmacros_xspace: + } \cs_new_protected:Npn \pOH - { \p { \chemmacros_chemformula:n { OH } } \chemmacros_xspace: } + { + \chemmacros_p:n { \chemmacros_chemformula:n { OH } } + \chemmacros_xspace: + } \NewDocumentCommand \pKa { o } { - \p + \chemmacros_p:n { \Ka \IfNoValueF { #1 } { \c_math_subscript_token { \chemmacros_detect_bold:n { #1 } } } @@ -1401,7 +1422,7 @@ \NewDocumentCommand \pKb { o } { - \p + \chemmacros_p:n { \Kb \IfNoValueF { #1 } { \c_math_subscript_token { \chemmacros_detect_bold:n { #1 } } } @@ -1440,7 +1461,7 @@ \tl_new:N \l__chemmacros_mech_mol_tl \tl_new:N \l__chemmacros_mech_ar_tl -\cs_new_protected: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 } @@ -1452,55 +1473,55 @@ type .choice: , type / .code:n = { - \chemmacros_set_mech:nnn { S } + \__chemmacros_set_mech:nnn { S } { \( \c_math_subscript_token { \text {N} } \) } { } } , type / 1 .code:n = { - \chemmacros_set_mech:nnn { S } + \__chemmacros_set_mech:nnn { S } { \( \c_math_subscript_token { \text {N} } \) 1 } { } } , type / 2 .code:n = { - \chemmacros_set_mech:nnn { S } + \__chemmacros_set_mech:nnn { S } { \( \c_math_subscript_token { \text {N} } \) 2 } { } } , type / se .code:n = { - \chemmacros_set_mech:nnn { S } + \__chemmacros_set_mech:nnn { S } { \( \c_math_subscript_token { \text {E} } \) } { } } , type / 1e .code:n = { - \chemmacros_set_mech:nnn { S } + \__chemmacros_set_mech:nnn { S } { \( \c_math_subscript_token { \text {E} } \) 1 } { } } , type / 2e .code:n = { - \chemmacros_set_mech:nnn { S } + \__chemmacros_set_mech:nnn { S } { \( \c_math_subscript_token { \text {E} } \) 2 } { } } , type / ar .code:n = { - \chemmacros_set_mech:nnn { S } + \__chemmacros_set_mech:nnn { S } { \( \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 } + \__chemmacros_set_mech:nnn { E } { 1 \( \c_math_subscript_token { \text {cb} } \) } { } } , @@ -1550,15 +1571,15 @@ \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 +\cs_new_protected:Npn \__chemmacros_ox_process_number:n #1 { \bool_if:NTF \l__chemmacros_ox_parse_bool { \tl_if_in:nnTF { #1 } { / } - { \chemmacros_ox_fraction:n #1 } + { \__chemmacros_ox_fraction:n #1 } { - \chemmacros_ox_sign:n { #1 } - \chemmacros_ox_value:n { #1 } + \__chemmacros_ox_sign:n { #1 } + \__chemmacros_ox_value:n { #1 } } } { #1 } @@ -1574,16 +1595,16 @@ slash-symbol-font = lmr } -\cs_new: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 } + \__chemmacros_ox_sign:n { #1 } \bool_if:NTF \l__chemmacros_ox_side_bool - { \sfrac { \chemmacros_ox_value:n { #1 } } { #2 } } - { \sfrac [ chemmacros-ox-frac ] { \chemmacros_ox_value:n { #1 } } { #2 } } + { \sfrac { \__chemmacros_ox_value:n { #1 } } { #2 } } + { \sfrac [ chemmacros-ox-frac ] { \__chemmacros_ox_value:n { #1 } } { #2 } } } -\cs_new: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 { $+$ } } @@ -1593,23 +1614,23 @@ { $-$ } } -\cs_new_protected: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:V \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:V \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:V \l__chemmacros_ox_number_fp } - { \chemmacros_fp_show:V \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_protected: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 } @@ -1622,9 +1643,9 @@ \bool_set_false:N \l__chemmacros_ox_format_roman_bool } } -\cs_generate_variant:Nn \chemmacros_ox_is_integer:n { V } +\cs_generate_variant:Nn \__chemmacros_ox_is_integer:n { V } -\cs_new_protected: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 } @@ -1635,18 +1656,18 @@ { \int_to_Roman:n { \int_use:N \l__chemmacros_tmpa_int } } \group_end: } -\cs_generate_variant:Nn \chemmacros_fp_to_Roman:n { V } +\cs_generate_variant:Nn \__chemmacros_fp_to_Roman:n { V } -\cs_new_protected: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 { V } +\cs_generate_variant:Nn \__chemmacros_fp_to_arabic:n { V } -\cs_new_protected: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 } @@ -1659,9 +1680,9 @@ { \fp_to_tl:N \l__chemmacros_tmpa_tl } \group_end: } -\cs_generate_variant:Nn \chemmacros_fp_show:n { V } +\cs_generate_variant:Nn \__chemmacros_fp_show:n { V } -\cs_new_protected:Npn \chemmacros_ox_write: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 } } @@ -1674,13 +1695,13 @@ \chemmacros_text:n { #2 - $ ^ { \text { \tiny \chemmacros_ox_process_number:n { #1 } } } $ + $ ^ { \text { \tiny \__chemmacros_ox_process_number:n { #1 } } } $ } } \bool_if:NT \l__chemmacros_ox_side_bool { \chemmacros_text:n - { #2 ( \text { \chemmacros_ox_process_number:n { #1 } } ) } + { #2 ( \text { \__chemmacros_ox_process_number:n { #1 } } ) } } \bool_if:NT \l__chemmacros_ox_top_bool { @@ -1690,7 +1711,7 @@ { \clap } { \rlap } { \chemmacros_text:n - { \tiny \chemmacros_ox_process_number:n { #1 } } + { \tiny \__chemmacros_ox_process_number:n { #1 } } } } { \chemmacros_text:n { #2 } } @@ -1698,21 +1719,21 @@ } } -\cs_new_protected: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_protected: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_protected: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 @@ -1722,9 +1743,9 @@ \keys_define:nn { chemmacros / ox } { pos .choice: , - pos / top .code:n = \chemmacros_ox_pos_top: , - pos / super .code:n = \chemmacros_ox_pos_super: , - pos / side .code:n = \chemmacros_ox_pos_side: , + pos / top .code:n = \__chemmacros_ox_pos_top: , + pos / super .code:n = \__chemmacros_ox_pos_super: , + pos / side .code:n = \__chemmacros_ox_pos_side: , roman .bool_set:N = \l__chemmacros_ox_format_roman_bool , roman .default:n = true , parse .bool_set:N = \l__chemmacros_ox_parse_bool , @@ -1746,11 +1767,11 @@ \cs_new_protected:Npn \chemmacros_ox:nnnn #1#2#3#4 { \group_begin: - \tl_if_blank:nF { #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 } } { \tl_if_blank:nF { #2 } { \keys_set:nn { chemmacros / ox } { #2 } } } - \chemmacros_ox_write:nn { #3 } { #4 } + \__chemmacros_ox_write:nn { #3 } { #4 } \group_end: } @@ -1801,7 +1822,7 @@ { \node [inner~sep=0] (#1) { #2 } ; } } -\cs_new_protected: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 } @@ -1812,8 +1833,9 @@ \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 } { #2 } - \tl_if_empty:nF { #3 } { \tl_set:Nn \l__chemmacros_redox_tikz_tl { #3 } } + \__chemmacros_redox_coordinates:nn { #1 } { #2 } + \tl_if_blank: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 } @@ -1870,8 +1892,8 @@ { \chemmacros_redox:nnnnn #1 { } { } { #4 } } { \IfNoValueTF { #3 } - { \chemmacros_redox:nnnnn #1 { } { } { #4 } } - { \chemmacros_redox:nnnnn #1 { } { #3 } { #4 } } + { \chemmacros_redox:nnnnn #1 { #2 } { } { #4 } } + { \chemmacros_redox:nnnnn #1 { #2 } { #3 } { #4 } } } } @@ -1934,30 +1956,30 @@ \bool_new:N \l__chemmacros_nmr_custom_command_active_bool \bool_new:N \l__chemmacros_nmr_custom_command_used_bool -\cs_new_protected: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 } { [ } - { \chemmacros_nmr_element:w #2 \q_stop } + { \__chemmacros_nmr_element:w #2 \q_stop } { \tl_gset:No \g__chemmacros_nmr_element_tl { #2 } \tl_gclear:N \g__chemmacros_nmr_element_coupled_tl } } -\cs_new_protected: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_protected: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_protected: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 { @@ -1979,19 +2001,19 @@ - NMR } } -\cs_generate_variant:Nn \chemmacros_nmr_base:nn { VV } +\cs_generate_variant:Nn \__chemmacros_nmr_base:nn { VV } -\cs_new: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 } } + { \__chemmacros_nmr_frequency_aux_i:w #1 \q_stop } + { \__chemmacros_nmr_frequency_aux_ii:n { #1 } } } -\cs_new: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: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 } @@ -1999,7 +2021,7 @@ unit .tl_set:N = \l__chemmacros_nmr_unit_tl , unit .default:n = \mega\hertz , nucleus .code:n = - { \chemmacros_nmr_default_nucleus:w #1 \q_stop } , + { \__chemmacros_nmr_default_nucleus:w #1 \q_stop } , nucleus .default:n = { 1,H } , format .tl_set:N = \l__chemmacros_nmr_format_tl , pos-number .choice: , @@ -2048,6 +2070,7 @@ \NewDocumentCommand \RenewChemNMR { mm } { \chemmacros_renew_nmr:Nn #1 { #2 } } +% TODO: separate document and module level \AtBeginDocument { % \NMR{<num>,<elem>}(<num>,<unit>)[<solvent>] ALL arguments are optional @@ -2079,24 +2102,24 @@ { \bool_set_true:N \l__chemmacros_nmr_comma_bool } \IfNoValueTF { #2 } { - \chemmacros_nmr_nucleus:w + \__chemmacros_nmr_nucleus:w \l__chemmacros_nmr_isotope_default_tl , \l__chemmacros_nmr_element_default_tl \q_stop } - { \chemmacros_nmr_nucleus:w #2 \q_stop } + { \__chemmacros_nmr_nucleus:w #2 \q_stop } \mode_if_math:TF { \text { \group_begin: \tl_use:N \l__chemmacros_nmr_format_tl - \chemmacros_nmr_base:VV + \__chemmacros_nmr_base:VV \g__chemmacros_nmr_isotope_tl \g__chemmacros_nmr_element_tl \bool_if:NT \l__chemmacros_nmr_delimiters_bool { ~ ( } \bool_if:NT \l__chemmacros_nmr_frequency_bool - { \chemmacros_nmr_frequency:n { #3 } } + { \__chemmacros_nmr_frequency:n { #3 } } \bool_if:NT \l__chemmacros_nmr_comma_bool { , ~ } \bool_if:NT \l__chemmacros_nmr_solvent_bool @@ -2116,13 +2139,13 @@ { \group_begin: \tl_use:N \l__chemmacros_nmr_format_tl - \chemmacros_nmr_base:VV + \__chemmacros_nmr_base:VV \g__chemmacros_nmr_isotope_tl \g__chemmacros_nmr_element_tl \bool_if:NT \l__chemmacros_nmr_delimiters_bool { ~ ( } \bool_if:NT \l__chemmacros_nmr_frequency_bool - { \chemmacros_nmr_frequency:n { #3 } } + { \__chemmacros_nmr_frequency:n { #3 } } \bool_if:NT \l__chemmacros_nmr_comma_bool { , ~ } \bool_if:NT \l__chemmacros_nmr_solvent_bool @@ -2177,11 +2200,11 @@ \group_begin: \IfNoValueF { #1 } { \keys_set:nn { chemmacros / nmr } { #1 } } \bool_set_true:N \l__chemmacros_nmr_inner_bool - \cs_set_eq:NN \# \chemmacros_nmr_number:n - \cs_set_eq:NN \pos \chemmacros_nmr_position:n - \cs_set_eq:NN \J \chemmacros_nmr_coupling:w + \cs_set_eq:NN \# \chemmacros_nmr_number:n + \cs_set_eq:NN \pos \chemmacros_nmr_position:n + \cs_set_eq:NN \J \chemmacros_nmr_coupling:w \cs_set_eq:NN \data \chemmacros_data:w - \cs_set_eq:NN \val \chemmacros_val:n + \cs_set_eq:NN \val \chemmacros_val:n \bool_if:NT \l__chemmacros_nmr_list_bool { \list {} { \l__chemmacros_nmr_list_setup_tl } } } @@ -2223,27 +2246,27 @@ \tl_clear:N \l__chemmacros_nmr_coupling_nuclei_tl \tl_clear:N \l__chemmacros_nmr_coupling_bonds_tl \peek_meaning:NTF ( - { \chemmacros_nmr_coupling_auxi:w } - { \chemmacros_nmr_coupling_auxii:w } + { \__chemmacros_nmr_coupling:w } + { \__chemmacros_nmr_coupling_aux_i:w } } -\cs_new_protected:Npn \chemmacros_nmr_coupling_auxi:w (#1;#2) +\cs_new_protected:Npn \__chemmacros_nmr_coupling:w (#1;#2) { \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl { #1 } \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl { #2 } \tl_put_right:Nn \l__chemmacros_nmr_coupling_nuclei_tl { ) } \tl_put_left:Nn \l__chemmacros_nmr_coupling_nuclei_tl { ( } - \chemmacros_nmr_coupling_auxii:w + \__chemmacros_nmr_coupling_aux_i:w } -\cs_new:Npn \chemmacros_nmr_coupling_auxii:w +\cs_new:Npn \__chemmacros_nmr_coupling_aux_i:w { \peek_meaning:NTF [ - { \chemmacros_nmr_coupling_auxiii:w } - { \chemmacros_nmr_coupling_auxiv:n } + { \__chemmacros_nmr_coupling_aux_ii:w } + { \__chemmacros_nmr_coupling_aux_iii:n } } -\cs_new:Npn \chemmacros_nmr_coupling_auxiii:w [#1]#2 +\cs_new:Npn \__chemmacros_nmr_coupling_aux_ii:w [#1]#2 { \group_begin: \sisetup @@ -2259,7 +2282,7 @@ \group_end: } -\cs_new:Npn \chemmacros_nmr_coupling_auxiv:n #1 +\cs_new:Npn \__chemmacros_nmr_coupling_aux_iii:n #1 { \group_begin: \sisetup @@ -2409,15 +2432,15 @@ \bool_if:NTF \l__chemmacros_german_bool { \prop_map_function:NN \l__chemmacros_phases_german_prop - \chemmacros_define_phases:nn + \__chemmacros_define_phases:nn } { \prop_map_function:NN \l__chemmacros_phases_prop - \chemmacros_define_phases:nn + \__chemmacros_define_phases:nn } } -\cs_new_protected:Npn \chemmacros_define_phases:nn #1#2 +\cs_new_protected:Npn \__chemmacros_define_phases:nn #1#2 { \cs_set:cpn { #1 } { @@ -2542,7 +2565,7 @@ \newcounter { reaction } % switch to reaction tags -\cs_new:Npn \chemmacros_begin_reaction: +\cs_new:Npn \__chemmacros_begin_reaction: { % create individual names for `hyperref': \bool_if:NT \l__chemmacros_hyperref_bool @@ -2561,7 +2584,7 @@ } % switch back to equation tags -\cs_new:Npn \chemmacros_end_reaction: +\cs_new:Npn \__chemmacros_end_reaction: { \setcounter { reaction } { \value { equation } } \setcounter { equation } { \value { chemmacros_save_reaction } } @@ -2601,19 +2624,19 @@ { \NewEnviron { #2 } [ 2 ] [] { - \chemmacros_begin_reaction: + \__chemmacros_begin_reaction: \AddRxnDesc { ##1 } \begin { #3 } { ##2 } - \chemmacros_equation_chemformula:o { \BODY } + \chemmacros_equation_chemformula:V \BODY \end{ #3 } - \chemmacros_end_reaction: + \__chemmacros_end_reaction: } \bool_if:NT \l__chemmacros_reactions_star_bool { \NewEnviron { #2* } [ 1 ] { \begin { #3* } { ##1 } - \chemmacros_equation_chemformula:o { \BODY } + \chemmacros_equation_chemformula:V \BODY \end { #3* } } } @@ -2621,19 +2644,19 @@ { \NewEnviron { #2 } [ 1 ] [] { - \chemmacros_begin_reaction: + \__chemmacros_begin_reaction: \AddRxnDesc { ##1 } \begin { #3 } - \chemmacros_equation_chemformula:o { \BODY } + \chemmacros_equation_chemformula:V \BODY \end { #3 } - \chemmacros_end_reaction: + \__chemmacros_end_reaction: } \bool_if:NT \l__chemmacros_reactions_star_bool { \NewEnviron { #2* } { \begin { #3* } - \chemmacros_equation_chemformula:o { \BODY } + \chemmacros_equation_chemformula:V \BODY \end { #3* } } } @@ -2655,7 +2678,7 @@ { \cee { #1 } } { \ch { #1 } } } -\cs_generate_variant:Nn \chemmacros_equation_chemformula:n { o } +\cs_generate_variant:Nn \chemmacros_equation_chemformula:n { V } % predefined: \bool_if:NF \l__chemmacros_version_one_bool @@ -2807,26 +2830,25 @@ \l__chemmacros_thermod_delta_default_tl } -% TODO: separate document and module level % \DeclareChemState[<keyval>]{<name>}{<symbol>}{<unit>} \bool_if:NF \l__chemmacros_version_one_bool { \cs_new:Npn \DeclareChemState { \bool_set_false:N \l__chemmacros_renewstate_bool - \chemmacros_setnewstate_reset: + \__chemmacros_setnewstate_reset: \peek_meaning:NTF [ - { \setnewstate_aux_i:n } - { \setnewstate_aux_ii:nnn } + { \__chemmacros_setnewstate:n } + { \__chemmacros_setnewstate_aux:nnn } } % \RenewChemState[<keyval>]{<name>}{<symbol>}{<unit>} \cs_new:Npn \RenewChemState { \bool_set_true:N \l__chemmacros_renewstate_bool - \chemmacros_setnewstate_reset: + \__chemmacros_setnewstate_reset: \peek_meaning:NTF [ - { \setnewstate_aux_i:n } - { \setnewstate_aux_ii:nnn } + { \__chemmacros_setnewstate:n } + { \__chemmacros_setnewstate_aux:nnn } } \cs_set:Npn \setnewstate { @@ -2842,21 +2864,21 @@ } } -\cs_new:Npn \chemmacros_setnewstate_reset: +\cs_new:Npn \__chemmacros_setnewstate_reset: { - \tl_set:Nn \l__chemmacros_thermod_subscript_left_default_tl { true } + \tl_set:Nn \l__chemmacros_thermod_subscript_left_default_tl { true } \tl_clear:N \l__chemmacros_thermod_subscript_default_tl - \tl_set:Nn \l__chemmacros_thermod_exponent_default_tl { \standardstate } - \tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \Delta } + \tl_set:Nn \l__chemmacros_thermod_exponent_default_tl { \standardstate } + \tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \Delta } } -\cs_new:Npn \setnewstate_aux_i:n [#1] +\cs_new:Npn \__chemmacros_setnewstate:n [#1] { \keys_set:nn { chemmacros / setnewstate } { #1 } - \setnewstate_aux_ii:nnn + \__chemmacros_setnewstate_aux:nnn } -\cs_new:Npn \setnewstate_aux_ii:nnn #1#2#3 +\cs_new:Npn \__chemmacros_setnewstate_aux:nnn #1#2#3 { \bool_if:NTF \l__chemmacros_renewstate_bool { @@ -2942,25 +2964,25 @@ { \tl_use:N \l__chemmacros_thermod_subscript_left_tl } { true } { \chemmacros_state:fnn - { - subscript-left = true , - exponent = - { \tl_use:N \l__chemmacros_thermod_exponent_tl } , - delta = - { \tl_use:N \l__chemmacros_thermod_delta_tl } - } - { #2 } + { + subscript-left = true , + exponent = + { \tl_use:N \l__chemmacros_thermod_exponent_tl } , + delta = + { \tl_use:N \l__chemmacros_thermod_delta_tl } + } + { #2 } } { \chemmacros_state:fnn - { - subscript-left = false , - exponent = - { \tl_use:N \l__chemmacros_thermod_exponent_tl } , - delta = - { \tl_use:N \l__chemmacros_thermod_delta_tl } - } - { #2 } + { + subscript-left = false , + exponent = + { \tl_use:N \l__chemmacros_thermod_exponent_tl } , + delta = + { \tl_use:N \l__chemmacros_thermod_delta_tl } + } + { #2 } } { \tl_use:N \l__chemmacros_thermod_subscript_tl } = @@ -3015,7 +3037,6 @@ 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 { @@ -3024,20 +3045,24 @@ \group_begin: \IfNoValueF { #1 } { \keys_set:nn { chemmacros / newman } { #1 } } \IfNoValueTF { #2 } - { - \fp_set_eq:NN - \l__chemmacros_newman_rel_angle_fp - \l__chemmacros_newman_abs_angle_fp - } - { \fp_set:Nn \l__chemmacros_newman_rel_angle_fp { #2 } } - \chemmacros_newman_atoms:nnnnnn #3 + { \chemmacros_newman_atoms:nnnnnnn { } #3 } + { \chemmacros_newman_atoms:nnnnnnn { #2 } #3 } \group_end: } } % place atoms: -\cs_new:Npn \chemmacros_newman_atoms:nnnnnn #1#2#3#4#5#6 +% #1: angle +% #2 - #7: atoms +\cs_new:Npn \chemmacros_newman_atoms:nnnnnnn #1#2#3#4#5#6#7 { + \tl_if_blank:nTF { #1 } + { + \fp_set_eq:NN + \l__chemmacros_newman_rel_angle_fp + \l__chemmacros_newman_abs_angle_fp + } + { \fp_set:Nn \l__chemmacros_newman_rel_angle_fp { #1 } } \chemmacros_tikz_picture:xn { scale = \fp_to_tl:N \l__chemmacros_newman_scale_fp , @@ -3060,24 +3085,24 @@ \chemmacros_tikz_draw:f { \tl_use:N \l__chemmacros_newman_tikz_ring_tl } (0,0) circle (\fp_to_dim:N \l__chemmacros_newman_scale_fp * 15) ; - \chemmacros_newman_back_node:nf + \chemmacros_newman_back_node:nn { 30 } - { \IfNoValueF { #5 } { #5 } } + { \IfNoValueF { #6 } { #6 } } \chemmacros_newman_back_node:nf { 150 } - { \IfNoValueF { #6 } { #6 } } + { \IfNoValueF { #7 } { #7 } } \chemmacros_newman_back_node:nf { 270 } - { \IfNoValueF { #4 } { #4 } } + { \IfNoValueF { #5 } { #5 } } \chemmacros_newman_front_node:nf { 90 } - { \IfNoValueF { #1 } { #1 } } + { \IfNoValueF { #2 } { #2 } } \chemmacros_newman_front_node:nf { 210 } - { \IfNoValueF { #2 } { #2 } } + { \IfNoValueF { #3 } { #3 } } \chemmacros_newman_front_node:nf { 330 } - { \IfNoValueF { #3 } { #3 } } + { \IfNoValueF { #4 } { #4 } } } } @@ -3221,19 +3246,19 @@ \fp_new:N \l__chemmacros_orbital_opacity_fp \fp_set:Nn \l__chemmacros_orbital_opacity_fp { 0.5 } -\cs_new:Npn \chemmacros_orbital_options: +\cs_new:Npn \__chemmacros_orbital_options: { - \chemmacros_orbital_overlay: , \chemmacros_orbital_opacity: , + \__chemmacros_orbital_overlay: , \__chemmacros_orbital_opacity: , inner~sep=0 , outer~sep=0 , line~width=.2pt , rotate = { \fp_use:N \l__chemmacros_orbital_angle_fp - 90 } , baseline , minimum~size = 0 } -\cs_new:Npn \chemmacros_orbital_overlay: +\cs_new:Npn \__chemmacros_orbital_overlay: { \bool_if:NT \l__chemmacros_orbital_overlay_bool { overlay } } -\cs_new: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 } } @@ -3241,7 +3266,7 @@ % --------------------------------------------------------------------------- % % s-orbitals -\cs_new: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 @@ -3261,9 +3286,9 @@ color .tl_set:N = \l__chemmacros_orbital_s_color_tl } -\cs_new: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 } } + \keys_set:nn { chemmacros / orbital / s } { #1 } \bool_if:NTF \l__chemmacros_orbital_s_phase_bool { \tl_if_in:NnTF \l__chemmacros_orbital_s_color_tl { ! } @@ -3280,7 +3305,7 @@ \tl_set:Nn \l__chemmacros_orbital_s_phase_color_tl { black ! 5 } } - \chemmacros_tikz_picture:xn{ \chemmacros_orbital_options: } + \chemmacros_tikz_picture:xn{ \__chemmacros_orbital_options: } { \chemmacros_tikz_shade:f { ball~color = \l__chemmacros_orbital_s_phase_color_tl } @@ -3290,7 +3315,7 @@ % --------------------------------------------------------------------------- % % p-orbitals -\cs_new: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 @@ -3313,9 +3338,9 @@ half .default:n = true } -\cs_new: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 } } + \keys_set:nn { chemmacros / orbital / p } { #1 } \bool_if:NTF \l__chemmacros_orbital_p_phase_bool { \tl_if_in:NnTF \l__chemmacros_orbital_p_color_tl { ! } @@ -3344,7 +3369,7 @@ \tl_set:Nn \l__chemmacros_orbital_p_pphase_color_tl { black ! 5 } } - \chemmacros_tikz_picture:xn { \chemmacros_orbital_options: } + \chemmacros_tikz_picture:xn { \__chemmacros_orbital_options: } { \chemmacros_tikz_shadedraw:f { @@ -3386,7 +3411,7 @@ % --------------------------------------------------------------------------- % % sp-orbitals -\cs_new: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 @@ -3407,9 +3432,9 @@ color .tl_set:N = \l__chemmacros_orbital_sp_color_tl } -\cs_new: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 } } + \keys_set:nn { chemmacros / orbital / sp } { #1 } \bool_if:NTF \l__chemmacros_orbital_sp_phase_bool { \tl_if_in:NnTF \l__chemmacros_orbital_sp_color_tl { ! } @@ -3438,7 +3463,7 @@ \tl_set:Nn \l__chemmacros_orbital_sp_pphase_color_tl { black ! 5 } } - \chemmacros_tikz_picture:xn { \chemmacros_orbital_options: } + \chemmacros_tikz_picture:xn { \__chemmacros_orbital_options: } { \chemmacros_tikz_shadedraw:f { @@ -3477,7 +3502,7 @@ % --------------------------------------------------------------------------- % % sp2-orbitals -\cs_new: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 @@ -3498,9 +3523,9 @@ color .tl_set:N = \l__chemmacros_orbital_sptwo_color_tl } -\cs_new: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 } } + \keys_set:nn { chemmacros / orbital / sp2 } { #1 } \bool_if:NTF \l__chemmacros_orbital_sptwo_phase_bool { \tl_if_in:NnTF \l__chemmacros_orbital_sptwo_color_tl { ! } @@ -3529,7 +3554,7 @@ \tl_set:Nn \l__chemmacros_orbital_sptwo_pphase_color_tl { black ! 5 } } - \chemmacros_tikz_picture:xn { \chemmacros_orbital_options: } + \chemmacros_tikz_picture:xn { \__chemmacros_orbital_options: } { \chemmacros_tikz_shadedraw:f { @@ -3568,7 +3593,7 @@ % --------------------------------------------------------------------------- % % sp3-orbitals -\cs_new: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 @@ -3589,9 +3614,9 @@ color .tl_set:N = \l__chemmacros_orbital_spthree_color_tl } -\cs_new: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 } } + \keys_set:nn { chemmacros / orbital / sp3 } { #1 } \bool_if:NTF \l__chemmacros_orbital_spthree_phase_bool { \tl_if_in:NnTF \l__chemmacros_orbital_spthree_color_tl { ! } @@ -3620,7 +3645,7 @@ \tl_set:Nn \l__chemmacros_orbital_spthree_pphase_color_tl { black ! 5 } } - \chemmacros_tikz_picture:xn { \chemmacros_orbital_options: } + \chemmacros_tikz_picture:xn { \__chemmacros_orbital_options: } { \chemmacros_tikz_shadedraw:f { @@ -3674,28 +3699,34 @@ \keys_define:nn { chemmacros / orbital / type } { - s .code:n = { \chemmacros_orbital_type_s: } , - p .code:n = { \chemmacros_orbital_type_p: } , - sp .code:n = { \chemmacros_orbital_type_sp: } , - sp2 .code:n = { \chemmacros_orbital_type_sptwo: } , - sp3 .code:n = { \chemmacros_orbital_type_spthree: } + s .code:n = { \__chemmacros_orbital_type_s: } , + p .code:n = { \__chemmacros_orbital_type_p: } , + sp .code:n = { \__chemmacros_orbital_type_sp: } , + sp2 .code:n = { \__chemmacros_orbital_type_sptwo: } , + sp3 .code:n = { \__chemmacros_orbital_type_spthree: } + } + +\cs_new:Npn \chemmacros_orbital:n #1 + { + \bool_if:NT \l__chemmacros_orbital_type_s_bool + { \__chemmacros_orbital_s_draw:n { #1 } } + \bool_if:NT \l__chemmacros_orbital_type_p_bool + { \__chemmacros_orbital_p_draw:n { #1 } } + \bool_if:NT \l__chemmacros_orbital_type_sp_bool + { \__chemmacros_orbital_sp_draw:n { #1 } } + \bool_if:NT \l__chemmacros_orbital_type_sptwo_bool + { \__chemmacros_orbital_sptwo_draw:n { #1 } } + \bool_if:NT \l__chemmacros_orbital_type_spthree_bool + { \__chemmacros_orbital_spthree_draw:n { #1 } } } -% TODO separate document and module level \NewDocumentCommand \orbital { o m } { \group_begin: \keys_set:nn { chemmacros / orbital / type } { #2 } - \bool_if:NT \l__chemmacros_orbital_type_s_bool - { \chemmacros_orbital_s_draw:n { #1 } } - \bool_if:NT \l__chemmacros_orbital_type_p_bool - { \chemmacros_orbital_p_draw:n { #1 } } - \bool_if:NT \l__chemmacros_orbital_type_sp_bool - { \chemmacros_orbital_sp_draw:n { #1 } } - \bool_if:NT \l__chemmacros_orbital_type_sptwo_bool - { \chemmacros_orbital_sptwo_draw:n { #1 } } - \bool_if:NT \l__chemmacros_orbital_type_spthree_bool - { \chemmacros_orbital_spthree_draw:n { #1 } } + \IfNoValueTF { #1 } + { \chemmacros_orbital:n { } } + { \chemmacros_orbital:n { #1 } } \group_end: } @@ -3956,16 +3987,23 @@ Version history - changed defaults for horizontal spaces that have in set in ex into corresponding values in em. - improvements to the placement of sub- and superscripts -2012/02/19 - version 3.5a - bug fix: `ghsystem' recognizes language again -2013/??/?? - version 3.6 - support for use with the `breqn' package +2013/02/19 - version 3.5a - bug fix: `ghsystem' recognizes language again +2013/02/26 - version 3.6 - support for use with the `breqn' package - chemformula: math escaping also via \(\) - - chemformula: clearer escaping macros + - chemformula internal: clearer escaping macros - new options: `radical-vshift', `radical-hshift' and `radical-space' - bug fix: `radical-...' options are now correctly set - stoichiometric factors: add leading 0 if missing + - new option: `stoich-paren-parse' - internal changes: be way more rigid about protected and expandable macros + - internal changes: clearer distinction between + private macros and accessable module macros + - internal changes: clearer distinction between + document commands and module level commands + - chemformula's !()() syntax now also works with babel's + French % --------------------------------------------------------------------------- % % TODO: |