diff options
author | Karl Berry <karl@freefriends.org> | 2015-02-08 21:52:12 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-02-08 21:52:12 +0000 |
commit | 0ab502f9af9ef6849cd94d45fe17d88bda544056 (patch) | |
tree | 20ecd1d3557c395ea01ef049366d5b672848a928 /Master/texmf-dist/tex/latex/chemmacros | |
parent | 577b2be3d7993050f549228cad438967d786a2ab (diff) |
chemmacros (8feb15)
git-svn-id: svn://tug.org/texlive/trunk@36234 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | 192 |
1 files changed, 107 insertions, 85 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index c1a37af5dcd..d6d1a07b195 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -12,7 +12,7 @@ % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % -------------------------------------------------------------------------- -% Copyright 2011-2014 Clemens Niederberger +% Copyright 2011-2015 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -27,8 +27,8 @@ % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- \RequirePackage{ expl3 , xparse , l3keys2e } -\def\chemmacros@version{4.6} -\def\chemmacros@date{2014/08/08} +\def\chemmacros@version{4.7} +\def\chemmacros@date{2015/02/08} \ProvidesExplPackage {chemmacros} @@ -1253,7 +1253,7 @@ \cs_new_protected:Nn \chemmacros_allow_hyphens: { \chemmacros_nobreak: - \skip_horizontal:n { \c_zero_dim } + \skip_horizontal:N \c_zero_dim } \dim_new:N \l__chemmacros_iupac_hyphen_pre_dim @@ -1310,25 +1310,30 @@ \char_set_catcode_active:N \| \char_set_catcode_active:N \^ -\cs_new_protected:Npn \chemmacros_iupac:n +\cs_new_protected:Npn \chemmacros_iupac:n #1 { \group_begin: \bool_set_true:N \l__chemmacros_inside_iupac_bool \chemmacros_make_iupac: \chemmacros_ignore_spaces: \cs_set_eq:NN \- \chemmacros_break_point_hyphen: - \char_set_catcode_active:N \| - \char_set_catcode_active:N \^ \chemmacros_define_deprecated:NN \| | \chemmacros_define_deprecated:NN \^ ^ - \chemmacros_iupac_aux:n - } - -\cs_new_protected:Npn \chemmacros_iupac_aux:n #1 - { - #1 + \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl + { + \char_set_catcode_active:N \| + \char_set_catcode_active:N \^ + } + {#1} + \l__chemmacros_tmpa_tl \group_end: } + +% \cs_new_protected:Npn \chemmacros_iupac_aux:n #1 +% { +% #1 +% \group_end: +% } \group_end: % Thanks to Joseph Wright and Enrico Gregorio for the help on the curious @@ -1420,31 +1425,16 @@ \tl_new:N \l__chemmacros_k_base_tl \tl_new:N \l__chemmacros_k_water_tl -\bool_new:N \l__chemmacros_subscript_lowercase_bool +% \bool_new:N \l__chemmacros_subscript_lowercase_bool \tl_set:Nn \l__chemmacros_k_acid_tl - { - \bool_if:NTF \l__chemmacros_subscript_lowercase_bool - { \tl_to_lowercase:f } - { \use:n } - { \chemmacros_translate:n { K-acid } } - } + { \chemmacros_translate:n {K-acid} } \tl_set:Nn \l__chemmacros_k_base_tl - { - \bool_if:NTF \l__chemmacros_subscript_lowercase_bool - { \tl_to_lowercase:f } - { \use:n } - { \chemmacros_translate:n { K-base } } - } + { \chemmacros_translate:n {K-base} } \tl_set:Nn \l__chemmacros_k_water_tl - { - \bool_if:NTF \l__chemmacros_subscript_lowercase_bool - { \tl_to_lowercase:f } - { \use:n } - { \chemmacros_translate:n { K-water } } - } + { \chemmacros_translate:n {K-water} } \keys_define:nn { chemmacros / acid-base } { @@ -1455,11 +1445,11 @@ K-acid .tl_set:N = \l__chemmacros_k_acid_tl , K-base .tl_set:N = \l__chemmacros_k_base_tl , K-water .tl_set:N = \l__chemmacros_k_water_tl , - subscript .choice: , - subscript / lowercase .code:n = - \bool_set_true:N \l__chemmacros_subscript_lowercase_bool , - subscript / uppercase .code:n = - \bool_set_false:N \l__chemmacros_subscript_lowercase_bool + subscript .code:n = \chemmacros_option_deprecated:n {#1} + % subscript / lowercase .code:n = + % \bool_set_true:N \l__chemmacros_subscript_lowercase_bool , + % subscript / uppercase .code:n = + % \bool_set_false:N \l__chemmacros_subscript_lowercase_bool } \cs_new_eq:NN \chemmacros_p_style:n \textup @@ -2122,6 +2112,10 @@ \leftmargin\z@ } \tl_new:N \l__chemmacros_nmr_position_tl +\tl_new:N \l__chemmacros_nmr_element_method_connector_tl +\tl_set:Nn \l__chemmacros_nmr_element_method_connector_tl {-} +\tl_new:N \l__chemmacros_nmr_method_tl +\tl_set:Nn \l__chemmacros_nmr_method_tl {NMR} \bool_new:N \l__chemmacros_nmr_coupling_nuclei_sub_bool \bool_new:N \l__chemmacros_nmr_frequency_bool @@ -2137,6 +2131,18 @@ \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:nn #1#2 + { + \tl_gset:Nn \g__chemmacros_nmr_isotope_tl { #1 } + \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_generate_variant:Nn \__chemmacros_nmr_nucleus:nn { VV } + \cs_new_protected:Npn \__chemmacros_nmr_nucleus:w #1,#2 \q_stop { \tl_gset:Nn \g__chemmacros_nmr_isotope_tl { #1 } @@ -2168,11 +2174,12 @@ \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} } } \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { #2 } - \iupac { \chemmacros_superscript: { #1 } } + \iupac { ^ { #1 } } \bool_if:NTF \l__chemmacros_nmr_parse_bool { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl } { \chemmacros_atom:V \g__chemmacros_nmr_element_coupled_tl } - - NMR + \tl_use:N \l__chemmacros_nmr_element_method_connector_tl + \tl_use:N \l__chemmacros_nmr_method_tl } \cs_generate_variant:Nn \__chemmacros_nmr_base:nn { VV } @@ -2200,6 +2207,8 @@ { \__chemmacros_nmr_default_nucleus:w #1 \q_stop } , nucleus .default:n = { 1,H } , format .tl_set:N = \l__chemmacros_nmr_format_tl , + method .tl_set:N = \l__chemmacros_nmr_method_tl , + connector .tl_set:N = \l__chemmacros_nmr_element_method_connector_tl , pos-number .choice: , pos-number / sub .code:n = \tl_set:Nn \l__chemmacros_nmr_position_tl { _ } @@ -2335,9 +2344,9 @@ { \bool_set_true:N \l__chemmacros_nmr_comma_bool } \tl_if_empty:nTF { #2 } { - \__chemmacros_nmr_nucleus:w - \l__chemmacros_nmr_isotope_default_tl , - \l__chemmacros_nmr_element_default_tl \q_stop + \__chemmacros_nmr_nucleus:VV + \l__chemmacros_nmr_isotope_default_tl + \l__chemmacros_nmr_element_default_tl } { \__chemmacros_nmr_nucleus:w #2 \q_stop } \mode_if_math:TF @@ -2456,20 +2465,20 @@ \cs_new_protected:Npn \chemmacros_nmr_position:n #1 { - \chemmacros_chemformula:x - { - \exp_not:V \g__chemmacros_nmr_element_tl - \bool_if:NF \l__chemmacros_nmr_position_side_bool - { - \exp_not:V \l__chemmacros_nmr_position_tl - \exp_not:n { {#1} } - } - } - \bool_if:NT \l__chemmacros_nmr_position_side_bool + \chemmacros_chemformula:x + { + \exp_not:V \g__chemmacros_nmr_element_tl + \bool_if:NF \l__chemmacros_nmr_position_side_bool { - \tl_use:N \l__chemmacros_nmr_position_tl - \__chemmacros_nmr_position:n { #1 } + \exp_not:V \l__chemmacros_nmr_position_tl + \exp_not:n { {#1} } } + } + \bool_if:NT \l__chemmacros_nmr_position_side_bool + { + \tl_use:N \l__chemmacros_nmr_position_tl + \__chemmacros_nmr_position:n { #1 } + } } \cs_new_protected:Npn \chemmacros_nmr_coupling:w @@ -2576,9 +2585,9 @@ \tl_set:Nx \l__chemmacros_tmpa_tl { \chemmacros_remove_backslash:N #1 } \cs_if_free:NF #1 - { \msg_error:nnn { chemmacros } { new-phase } { #1 } } - \exp_args:Nx \DeclareTranslationFallback - { phase-\l__chemmacros_tmpa_tl } { #2 } + { \msg_error:nnn {chemmacros} {new-phase} {#1} } + \exp_args:Nx \@trnslt@declare@translation + { phase-\l__chemmacros_tmpa_tl } {fallback} {#2} \__chemmacros_define_phase:Nx #1 { \exp_not:N \chemmacros_translate:n @@ -2590,8 +2599,8 @@ { \tl_set:Nx \l__chemmacros_tmpa_tl { \chemmacros_remove_backslash:N #1 } - \exp_args:Nx \DeclareTranslationFallback - { phase-\l__chemmacros_tmpa_tl } { #2 } + \exp_args:Nx \@trnslt@declare@translation + { phase-\l__chemmacros_tmpa_tl } {fallback} {#2} \__chemmacros_define_phase:Nx #1 { \exp_not:N \chemmacros_translate:n @@ -2603,10 +2612,10 @@ { \tl_set:Nx \l__chemmacros_tmpa_tl { \chemmacros_remove_backslash:N #1 } - \cs_if_free:NT #1 - { \msg_error:nnn { chemmacros } { renew-phase } { #1 } } - \exp_args:Nx \DeclareTranslationFallback - { phase-\l__chemmacros_tmpa_tl } { #2 } + \cs_if_exist:NF #1 + { \msg_error:nnn {chemmacros} {renew-phase} {#1} } + \exp_args:Nx \@trnslt@declare@translation + { phase-\l__chemmacros_tmpa_tl } {fallback} {#2} \__chemmacros_define_phase:Nx #1 { \exp_not:N \chemmacros_translate:n @@ -2615,40 +2624,46 @@ } \NewDocumentCommand \NewChemPhase { mom } - { \chemmacros_new_phase:Nn #1 { #3 } } + { \chemmacros_new_phase:Nn #1 {#3} } \NewDocumentCommand \DeclareChemPhase { mom } - { \chemmacros_define_phase:Nn #1 { #3 } } + { \chemmacros_define_phase:Nn #1 {#3} } \NewDocumentCommand \RenewChemPhase { mom } - { \chemmacros_renew_phase:Nn #1 { #3 } } + { \chemmacros_renew_phase:Nn #1 {#3} } \cs_new_protected:Npn \__chemmacros_define_phase:Nn #1#2 { - \cs_if_free:NT #1 { \cs_new:Npn #1 {} } - \cs_set_protected:Npn #1 + \cs_if_exist:NF #1 { \cs_new:Npn #1 {} } + \DeclareDocumentCommand #1 { o } { \bool_if:NTF \l__chemmacros_phases_sub_bool { \bool_if:NTF \l_chemformula_inside_ch_bool - { \chemformula_subscript:n { ( #2 ) } } - { \ensuremath { \c_math_subscript_token { \text { (#2) } } } } + { \chemformula_subscript:n { ( #2 \IfNoValueF {##1} {,~##1} ) } } + { + \ensuremath + { + \c_math_subscript_token + { \text { ( #2 \IfNoValueF {##1} {,~##1} ) } } + } + } } { \ensuremath { \skip_horizontal:N \l__chemmacros_phases_space_dim - \text { (#2) } + \text { ( #2 \IfNoValueF {##1} {,~##1} ) } } } } - } + } \cs_generate_variant:Nn \__chemmacros_define_phase:Nn { Nx } -\NewChemPhase\sld{ s } -\NewChemPhase\lqd{ l } -\NewChemPhase\gas{ g } -\NewChemPhase\aq { aq } +\NewChemPhase \sld {s} +\NewChemPhase \lqd {l} +\NewChemPhase \gas {g} +\NewChemPhase \aq {aq} \cs_new_protected:Npn \chemmacros_phase:n #1 { @@ -2664,7 +2679,7 @@ } \NewDocumentCommand \phase { m } - { \chemmacros_phase:n { #1 } } + { \chemmacros_phase:n {#1} } % -------------------------------------------------------------------------- % reaction environments @@ -4063,15 +4078,14 @@ % -------------------------------------------------------------------------- % language support -- provided through `translations' % equilibrium constants: -\DeclareTranslationFallback {K-acid} {A} -\DeclareTranslation{German} {K-acid} {S} -\DeclareTranslation{Dutch} {K-acid} {Z} +\DeclareTranslationFallback {K-acid} {\mathrm{a}} +\DeclareTranslation{German} {K-acid} {\mathrm{s}} +\DeclareTranslation{Dutch} {K-acid} {\mathrm{z}} + +\DeclareTranslationFallback {K-base} {\mathrm{b}} -\DeclareTranslationFallback {K-base} {B} -% \DeclareTranslation{Dutch} {K-base} {B} +\DeclareTranslationFallback {K-water} {\mathrm{w}} -\DeclareTranslationFallback {K-water} {W} -% \DeclareTranslation{Dutch} {K-water} {W} % phases: \DeclareTranslation{German}{phase-sld}{ f } \DeclareTranslation{German}{phase-lqd}{ f{}l } @@ -4352,10 +4366,18 @@ Version history 2014/08/08 - version 4.6 - from bundle to packages: packages `chemformula', `ghsystem' and `chemgreek' no longer belong to the bundle but now are packages of their own. +2015/02/08 - version 4.7 - fix \iupac so active letters like | still work + inside other macros (\section, ...) + - Change the default subscripts of the equilibrium + constants to match the usage in the IUPAC Green + Book + - allow \NewChemPhase and friends after \begin{document} + - new optional argument to phase commands + - new options `nmr/method' and `nmr/connector' % --------------------------------------------------------------------------- % % TODO: - add d-orbitals - make electron movement arrow tips (`el', `left el' and `right el') public -- make | and ^ active inside \iupac and use them instead of \| and \^ +- phase commands with arguments (see http://texwelt.de/wissen/fragen/9264) |