diff options
author | Karl Berry <karl@freefriends.org> | 2012-08-22 23:08:18 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-08-22 23:08:18 +0000 |
commit | 85f0c4bd18d5bdef009d8e78594cabf23d1df597 (patch) | |
tree | dd35e3957f6975a9addeede280a713aa8fb6c7c9 /Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | |
parent | f4edadfb71516f69b11060db846a8d500528cdc7 (diff) |
chemmacros (22aug12)
git-svn-id: svn://tug.org/texlive/trunk@27497 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 | 147 |
1 files changed, 99 insertions, 48 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index 306df5dfbb9..d1cbaf00c3a 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -29,11 +29,13 @@ \RequirePackage{ expl3 , xparse , l3keys2e , xfrac , siunitx } \RequirePackage{ tikz , mathtools , environ , scrlfile , etoolbox , bm } \usetikzlibrary{calc,arrows} +\def\chemmacros@version{3.3e} +\def\chemmacros@date{2012/08/21} \ProvidesExplPackage {chemmacros} - {2012/07/24} - {3.3d} + {\chemmacros@date} + {\chemmacros@version} {macros and commands for chemists} \@ifpackageloaded { chemformula } {} { \RequirePackage { chemformula } } @@ -669,7 +671,7 @@ { \text { \chemmacros_inner_font: #1 } } { \group_begin: \chemmacros_inner_font: #1 \group_end: } } -\cs_generate_variant:Nn \chemmacros_atom:n { o,f,x } +\cs_generate_variant:Nn \chemmacros_atom:n { o,f,x,V } \cs_new:Nn \chemmacros_text:n { \mode_if_math:TF { \text { #1 } } { #1 } } @@ -691,7 +693,7 @@ \group_end: } } -\cs_generate_variant:Nn \chemmacros_chemformula:n { x } +\cs_generate_variant:Nn \chemmacros_chemformula:n { x,V } % --------------------------------------------------------------------------- % % particles, charges @@ -1502,6 +1504,7 @@ \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 { @@ -1643,11 +1646,12 @@ { \overset { - \rlap - { - \chemmacros_text:n - { \tiny \chemmacros_ox_process_number:n { #1 } } - } + \bool_if:NTF \l_chemmacros_ox_align_center_bool + { \clap } { \rlap } + { + \chemmacros_text:n + { \tiny \chemmacros_ox_process_number:n { #1 } } + } } { \chemmacros_text:n { #2 } } } @@ -1656,7 +1660,7 @@ \cs_new_nopar:Npn \chemmacros_ox_pos_top: { - \bool_set_true:N \l_chemmacros_ox_top_bool + \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 } @@ -1664,7 +1668,7 @@ \cs_new_nopar: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_true:N \l_chemmacros_ox_super_bool \bool_set_false:N \l_chemmacros_ox_side_bool } @@ -1672,26 +1676,29 @@ { \bool_set_false:N \l_chemmacros_ox_top_bool \bool_set_false:N \l_chemmacros_ox_super_bool - \bool_set_true:N \l_chemmacros_ox_side_bool + \bool_set_true:N \l_chemmacros_ox_side_bool } \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: , - roman .bool_set:N = \l_chemmacros_ox_format_roman_bool , - roman .default:n = true , - parse .bool_set:N = \l_chemmacros_ox_parse_bool , - parse .default:n = true , - explicit-sign .bool_set:N = \l_chemmacros_ox_explicit_sign_bool , - explicit-sign .default:n = true , + 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: , + roman .bool_set:N = \l_chemmacros_ox_format_roman_bool , + roman .default:n = true , + parse .bool_set:N = \l_chemmacros_ox_parse_bool , + parse .default:n = true , + explicit-sign .bool_set:N = \l_chemmacros_ox_explicit_sign_bool , + explicit-sign .default:n = true , decimal-marker .choice: , decimal-marker / comma .code:n = { \bool_set_true:N \l_chemmacros_ox_decimal_marker_comma_bool } , decimal-marker / point .code:n = - { \bool_set_false:N \l_chemmacros_ox_decimal_marker_comma_bool } + { \bool_set_false:N \l_chemmacros_ox_decimal_marker_comma_bool } , + align .choice: , + align / center .code:n = \bool_set_true:N \l_chemmacros_ox_align_center_bool , + align / right .code:n = \bool_set_false:N \l_chemmacros_ox_align_center_bool } % \ox[<keyval>]{<num>,<atom>} @@ -1838,6 +1845,10 @@ \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_set:Nn \l_chemmacros_nmr_element_default_tl { H } @@ -1874,7 +1885,18 @@ \cs_new_nopar:Npn \chemmacros_nmr_nucleus:w #1,#2 \q_stop { \tl_gset:Nn \g_chemmacros_nmr_isotope_tl { #1 } - \tl_gset:Nn \g_chemmacros_nmr_element_tl { #2 } + \tl_if_in:nnTF { #2 } { [ } + { \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_nopar: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 @@ -1885,9 +1907,25 @@ \cs_new_nopar:Npn \chemmacros_nmr_base:nn #1#2 { + \tl_if_blank:VF \g_chemmacros_nmr_element_coupled_tl + { + \tl_put_left:Nn \g_chemmacros_nmr_element_coupled_tl { \{ } + \tl_put_right:Nn \g_chemmacros_nmr_element_coupled_tl { \} } + } + \tl_put_left:Nn \g_chemmacros_nmr_element_coupled_tl { #2 } \bool_if:NTF \l_chemmacros_bpchem_bool - { \IUPAC { \^ { #1 } #2 - NMR } } - { \iupac { \^ { #1 } } \chemmacros_atom:n { #2 } - NMR } + { \IUPAC { \^ { #1 } \g_chemmacros_nmr_element_coupled_tl - NMR } } + { + \iupac { \^ { #1 } } + \bool_if:NTF \l_chemmacros_nmr_parse_bool + { + \bool_if:NTF \l_chemmacros_use_mhchem_bool + { \exp_args:No \ce { \g_chemmacros_nmr_element_coupled_tl } } + { \exp_args:No \ch { \g_chemmacros_nmr_element_coupled_tl } } + } + { \chemmacros_atom:V \g_chemmacros_nmr_element_coupled_tl } + - NMR + } } \cs_generate_variant:Nn \chemmacros_nmr_base:nn { VV } @@ -2099,7 +2137,7 @@ #1 \, \bool_if:NTF \l_chemmacros_bpchem_bool { \g_chemmacros_nmr_element_tl } - { \chemmacros_atom:n { \g_chemmacros_nmr_element_tl } } + { \chemmacros_atom:V \g_chemmacros_nmr_element_tl } } \cs_new:Npn \chemmacros_nmr_position:n #1 @@ -2116,18 +2154,36 @@ { \chemmacros_chemformula:x { \g_chemmacros_nmr_element_tl _ #1 } } - { \chemmacros_atom:n { \g_chemmacros_nmr_element_tl } - #1 } + { \chemmacros_atom:V \g_chemmacros_nmr_element_tl - #1 } } } \cs_new:Npn \chemmacros_nmr_coupling:w { - \peek_meaning:NTF [ + \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:n } + { \chemmacros_nmr_coupling_auxi:w } + } + +\cs_new: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 } + \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 + } + +\cs_new:Npn \chemmacros_nmr_coupling_auxii:w + { + \peek_meaning:NTF [ + { \chemmacros_nmr_coupling_auxiii:w } + { \chemmacros_nmr_coupling_auxiv:n } } -\cs_new:Npn \chemmacros_nmr_coupling_auxi:w [#1]#2 +\cs_new:Npn \chemmacros_nmr_coupling_auxiii:w [#1]#2 { \group_begin: \sisetup @@ -2136,13 +2192,14 @@ list-pair-separator={,~}, list-units=single } - \tl_if_in:nnTF { #1 } { ; } - { \( J = \SIlist{#2}{#1} \) } - { \( J = \SI{#2}{#1} \) } + \( + ^{ \l_chemmacros_nmr_coupling_bonds_tl } J + \l_chemmacros_nmr_coupling_nuclei_tl = \SIlist{#2}{#1} + \) \group_end: } -\cs_new:Npn \chemmacros_nmr_coupling_auxii:n #1 +\cs_new:Npn \chemmacros_nmr_coupling_auxiv:n #1 { \group_begin: \sisetup @@ -2151,19 +2208,11 @@ list-pair-separator={,~}, list-units=single } - \tl_if_in:nnTF { #1 } { ; } - { - \( - J = \exp_args:Nno \SIlist - { #1 } { \l_chemmacros_nmr_coupling_unit_tl } - \) - } - { - \( - J = \exp_args:Nno \SI - { #1 } { \l_chemmacros_nmr_coupling_unit_tl } - \) - } + \( + ^{ \l_chemmacros_nmr_coupling_bonds_tl } J + \l_chemmacros_nmr_coupling_nuclei_tl + = \exp_args:Nno \SIlist { #1 } { \l_chemmacros_nmr_coupling_unit_tl } + \) \group_end: } @@ -3810,6 +3859,8 @@ Version history `iupac/cip-kern' - bug fix: messages needed to be defined before the options +2012/08/21 - version 3.3e - new option ox/align=center|right + - a new option to \NMR and to \J % --------------------------------------------------------------------------- % % TODO: |