diff options
author | Karl Berry <karl@freefriends.org> | 2014-04-14 22:51:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-04-14 22:51:51 +0000 |
commit | 4f954575ea54e72fedc6cb767697c1c90e33bdbe (patch) | |
tree | 0411a23e9b1c7b333c86335c11eb4d0f9ea571bb /Master/texmf-dist/tex/latex | |
parent | b9d9e9d13ed7c7d0faf0733995d28567756be4f6 (diff) |
chemmacros (10apr14)
git-svn-id: svn://tug.org/texlive/trunk@33447 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemformula.sty | 395 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | 70 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty | 6 |
3 files changed, 385 insertions, 86 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty index 3774338595f..b88a3f8a315 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty @@ -27,8 +27,8 @@ % -------------------------------------------------------------------------- \RequirePackage{ expl3 , xparse , l3keys2e , tikz , amsmath , xfrac , nicefrac , scrlfile } \usetikzlibrary{arrows} -\def\chemformula@version{4.4} -\def\chemformula@date{2014/01/29} +\def\chemformula@version{4.5} +\def\chemformula@date{2014/04/08} \ProvidesExplPackage {chemformula} @@ -136,6 +136,7 @@ \cs_generate_variant:Nn \tl_if_in:nnT { x , nV } \cs_generate_variant:Nn \prop_get:Nn { NV } \cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV } +\cs_generate_variant:Nn \dim_set:Nn { NV } % -------------------------------------------------------------------------- % package options: @@ -218,17 +219,16 @@ \bool_new:N \l__chemformula_charge_full_shift_bool \bool_new:N \l__chemformula_tikzexternaldisable_bool \bool_set_true:N \l__chemformula_tikzexternaldisable_bool +\bool_new:N \l__chemformula_kroegervink_bool % dimensions: \dim_new:N \l__chemformula_arrow_length_dim +\dim_new:N \l__chemformula_arrow_label_height_dim \dim_new:N \l__chemformula_arrow_label_offset_dim \dim_set:Nn \l__chemformula_arrow_label_offset_dim { 2pt } \dim_new:N \l__chemformula_arrow_minimum_length_dim \dim_new:N \l__chemformula_arrow_shortage_dim \dim_new:N \l__chemformula_arrow_offset_dim -\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 { .5em } \dim_new:N \l__chemformula_arrow_yshift_dim \dim_set:Nn \l__chemformula_arrow_yshift_dim { 0pt } \dim_new:N \l__chemformula_radical_radius_dim @@ -238,7 +238,7 @@ \dim_new:N \l__chemformula_radical_vshift_dim \dim_set:Nn \l__chemformula_radical_vshift_dim { .5ex } \dim_new:N \l__chemformula_radical_space_dim -\dim_set:Nn \l__chemformula_radical_space_dim { .15em } +\dim_set:Nn \l__chemformula_radical_space_dim { .3em } \dim_new:N \l__chemformula_arrow_head_dim \dim_new:N \l__chemformula_name_dim \dim_new:N \l__chemformula_adduct_space_dim @@ -261,6 +261,14 @@ \dim_set:Nn \l__chemformula_elspec_pair_line_length_dim { 1.5ex } \dim_new:N \l__chemformula_elspec_pair_width_dim \dim_set:Nn \l__chemformula_elspec_pair_width_dim { 1pt } +\dim_new:N \l__chemformula_kroegervink_positive_radius_dim +\dim_set:Nn \l__chemformula_kroegervink_positive_radius_dim { .3ex } +\dim_new:N \l__chemformula_kroegervink_positive_hshift_dim +\dim_set:Nn \l__chemformula_kroegervink_positive_hshift_dim { .15em } +\dim_new:N \l__chemformula_kroegervink_positive_vshift_dim +\dim_set:Nn \l__chemformula_kroegervink_positive_vshift_dim { .5ex } +\dim_new:N \l__chemformula_kroegervink_positive_space_dim +\dim_set:Nn \l__chemformula_kroegervink_positive_space_dim { .4em } % skips: \skip_new:N \l__chemformula_stoich_space_skip @@ -276,6 +284,8 @@ \int_new:N \g__chemformula_lewis_int % token lists: +\tl_new:N \l__chemformula_compound_sep_tl +\tl_set:Nn \l__chemformula_compound_sep_tl { .5em } \tl_new:N \l__chemformula_arrow_ratio_tl \tl_set:Nn \l__chemformula_arrow_ratio_tl { .6 } \tl_new:N \l__chemformula_radical_style_tl @@ -290,6 +300,8 @@ \tl_new:N \l__chemformula_arrow_type_tl \tl_new:N \l__chemformula_arrow_penalty_tl \tl_set:Nn \l__chemformula_arrow_penalty_tl { 0 } +\tl_new:N \l__chemformula_arrow_offset_tl +\tl_set:Nn \l__chemformula_arrow_offset_tl { .75em } \tl_new:N \l__chemformula_plus_penalty_tl \tl_set:Nn \l__chemformula_plus_penalty_tl { 700 } \tl_new:N \l__chemformula_bond_penalty_tl @@ -327,6 +339,9 @@ \tl_new:N \l__chemformula_elspec_default_type_tl \tl_set:Nn \l__chemformula_elspec_default_type_tl { pair } \tl_const:Nx \c_chemformula_colon_tl { \token_to_str:N : } +\tl_new:N \l__chemformula_kroegervink_positive_style_tl +\tl_new:N \l__chemformula_kroegervink_neutral_tl +\tl_set:Nn \l__chemformula_kroegervink_neutral_tl { $\times$ } % property lists: \prop_new:N \l__chemformula_arrows_code_prop @@ -337,6 +352,7 @@ \prop_new:N \l__chemformula_numbers_prop \prop_new:N \l__chemformula_no_stoich_prop \prop_new:N \l__chemformula_lewis_elspec_types_prop +\prop_new:N \l__chemformula_kroegervink_prop % sequences: \seq_new:N \l__chemformula_arrows_type_seq @@ -356,7 +372,7 @@ \cs_new:Npn \chemformula_draw:nn #1#2 { \draw [ #1 ] #2 ; } -\cs_generate_variant:Nn \chemformula_draw:nn { xn,nx,xx,xf } +\cs_generate_variant:Nn \chemformula_draw:nn { xn,nx,xx,xf,Vn } \cs_new:Npn \chemformula_node:nn #1#2 { \node [ #1 ] { #2 } ; } @@ -528,20 +544,36 @@ % -------------------------------------------------------------------------- % Some basic internal commands: + +\cs_new_protected:Npn \chemformula_radical_or_decimal: + { + \peek_meaning:NTF \c_group_begin_token + { \chemformula_decimal: } + { \chemformula_radical: } + } + \cs_new_protected:Npn \chemformula_radical: { - \chemformula_tikz:xn + \hbox_overlap_right:n { - \l__chemformula_radical_style_tl , - baseline, - minimum~height=0pt, - inner~sep=0pt, - outer~sep=0pt - } - { - \fill (0,0) - ++(\l__chemformula_radical_hshift_dim,\l__chemformula_radical_vshift_dim) - circle (\l__chemformula_radical_radius_dim) ; + \chemformula_tikz:xn + { + \l__chemformula_radical_style_tl , + baseline , + minimum~ height = 0pt , + minimum~ width = 0pt , + inner~ sep = 0pt , + outer~ sep = 0pt , + overlay + } + { + \fill (0,0) + ++( + \l__chemformula_radical_hshift_dim , + \l__chemformula_radical_vshift_dim + ) + circle (\l__chemformula_radical_radius_dim) ; + } } \skip_horizontal:N \l__chemformula_radical_space_dim } @@ -567,6 +599,68 @@ \cs_new_eq:NN \chemformula_star_adduct: \chemformula_adduct: % -------------------------------------------------------------------------- +% Kroeger-Vink notation +\cs_new_protected:Npn \chemformula_kroegervink_negative: + { \ensuremath { \prime } } + +\cs_new_protected:Npn \chemformula_kroegervink_neutral: + { \ensuremath { \text {\l__chemformula_kroegervink_neutral_tl } } } + +\cs_new_protected:Npn \chemformula_kroegervink_positive: + { + \hbox_overlap_right:n + { + \chemformula_tikz:xn + { + \l__chemformula_kroegervink_positive_style_tl , + baseline , + minimum~ height = 0pt , + minimum~ width = 0pt , + inner~ sep = 0pt , + outer~ sep = 0pt , + overlay + } + { + \fill (0,0) + ++( + \l__chemformula_kroegervink_positive_hshift_dim , + \l__chemformula_kroegervink_positive_vshift_dim + ) + circle (\l__chemformula_kroegervink_positive_radius_dim) ; + } + } + \skip_horizontal:N \l__chemformula_kroegervink_positive_space_dim + } + +\cs_new:Npn \chemformula_prime: + { + \bool_if:NTF \l__chemformula_kroegervink_bool + { \chemformula_kroegervink_negative: } + { ' } + } + +\keys_define:nn { chemmacros / chemformula } + { + kroeger-vink .bool_set:N = + \l__chemformula_kroegervink_bool , + % TikZ style: + kv-positive-style .tl_set:N = + \l__chemformula_kroegervink_positive_style_tl , + kv-positive-radius .dim_set:N = + \l__chemformula_kroegervink_positive_radius_dim , + % spacing: + kv-positive-hshift .dim_set:N = + \l__chemformula_kroegervink_positive_hshift_dim , + kv-positive-vshift .dim_set:N = + \l__chemformula_kroegervink_positive_vshift_dim , + kv-positive-offset .dim_set:N = + \l__chemformula_kroegervink_positive_space_dim , + % symbol: + kv-neutral-symbol .tl_set:N = + \l__chemformula_kroegervink_neutral_tl + } + +% -------------------------------------------------------------------------- % ARROW DEFINITION % arrow heads: @@ -666,6 +760,7 @@ % determine length in dependency of labels \cs_new_protected:Npn \__chemformula_determine_arrow_length:NN #1#2 { + \dim_set:NV \l__chemformula_arrow_offset_dim \l__chemformula_arrow_offset_tl \box_set_eq:NN \l__chemformula_tmpa_box #1 \dim_set:Nn \l__chemformula_tmpa_dim { \box_wd:N \l__chemformula_tmpa_box } \box_set_eq:NN \l__chemformula_tmpa_box #2 @@ -676,8 +771,6 @@ { \dim_set_eq:NN \l__chemformula_arrow_length_dim \l__chemformula_tmpb_dim } \dim_add:Nn \l__chemformula_arrow_length_dim { 2\l__chemformula_arrow_offset_dim } -% \dim_add:Nn \l__chemformula_arrow_length_dim -% { \l__chemformula_arrow_offset_dim } \dim_compare:nF { \l__chemformula_arrow_length_dim > \l__chemformula_arrow_minimum_length_dim } { @@ -694,6 +787,16 @@ \dim_ratio:nn { \l__chemformula_arrow_ratio_tl pt } { 1pt } ) * 1/2 } + \box_set_eq:NN \l__chemformula_tmpa_box #1 + \dim_set:Nn \l__chemformula_tmpa_dim + { \box_ht:N \l__chemformula_tmpa_box + \box_dp:N \l__chemformula_tmpa_box } + \box_set_eq:NN \l__chemformula_tmpa_box #2 + \dim_set:Nn \l__chemformula_tmpb_dim + { \box_ht:N \l__chemformula_tmpa_box + \box_dp:N \l__chemformula_tmpa_box } + \box_clear:N \l__chemformula_tmpa_box + \dim_compare:nTF { \l__chemformula_tmpa_dim >= \l__chemformula_tmpb_dim } + { \dim_set_eq:NN \l__chemformula_arrow_label_height_dim \l__chemformula_tmpa_dim } + { \dim_set_eq:NN \l__chemformula_arrow_label_height_dim \l__chemformula_tmpb_dim } } % -------------------------------------------------------------------------- @@ -754,14 +857,14 @@ { \l__chemformula_arrow_style_tl } { coordinate (chemformula_arrow_start) (0pt,0pt) - ++ ( \l__chemformula_compound_sep_dim , .3432em) + ++ ( \l__chemformula_compound_sep_tl , .3432em) ++ (0pt,\l__chemformula_arrow_yshift_dim) coordinate (cf_arrow_start) ++ ( .5 * \dim_use:N \l__chemformula_arrow_length_dim , 0pt) coordinate (cf_arrow_mid) ++ ( .5 * \dim_use:N \l__chemformula_arrow_length_dim , 0pt) coordinate (cf_arrow_end) - ++ ( \l__chemformula_compound_sep_dim , 0pt ) + ++ ( \l__chemformula_compound_sep_tl , 0pt ) (cf_arrow_start) ++ (\l__chemformula_arrow_shortage_dim , 0pt) coordinate (cf_arrow_mid_start) (cf_arrow_end) ++ (-\l__chemformula_arrow_shortage_dim , 0pt) @@ -849,7 +952,7 @@ \draw[chemarrow,left~cf-] ([yshift=-.15ex]cf_arrow_mid_start) -- ([yshift=-.15ex]cf_arrow_mid_end) ; } -\NewChemArrow {<<=>} +\NewChemArrow { <<=> } { \draw[chemarrow,-left~cf] ([yshift=.15ex]cf_arrow_mid_start) -- ([yshift=.15ex]cf_arrow_mid_end) ; @@ -863,6 +966,33 @@ \draw[chemarrow,left~cf-] ([yshift=-.15ex]cf_arrow_start) -- ([yshift=-.15ex]cf_arrow_end) ; } +\NewChemArrow { >>=< } + { + \draw[chemarrow,right~cf-] + ([yshift=.15ex]cf_arrow_start) -- ([yshift=.15ex]cf_arrow_end) ; + \draw[chemarrow,-right~cf] + ([yshift=-.15ex]cf_arrow_mid_start) -- ([yshift=-.15ex]cf_arrow_mid_end) ; + } +\NewChemArrow { >=<< } + { + \draw[chemarrow,right~cf-] + ([yshift=.15ex]cf_arrow_mid_start) -- ([yshift=.15ex]cf_arrow_mid_end) ; + \draw[chemarrow,-right~cf] + ([yshift=-.15ex]cf_arrow_start) -- ([yshift=-.15ex]cf_arrow_end) ; + } +\NewChemArrow { >=< } + { + \draw[chemarrow,right~cf-] + ([yshift=.15ex]cf_arrow_start) -- ([yshift=.15ex]cf_arrow_end) ; + \draw[chemarrow,-right~cf] + ([yshift=-.15ex]cf_arrow_start) -- ([yshift=-.15ex]cf_arrow_end) ; + } +\NewChemArrow { <==> } + { + \draw[chemarrow,double~ equal~ sign~ distance,double,implies-implies] + (cf_arrow_start) -- (cf_arrow_end) ; + % \node at ([yshift=-.2ex]cf_arrow_mid) { $\Leftrightarrow$ } ; + } \NewChemArrow { -/> } { \draw[chemarrow,-cf] (cf_arrow_start) -- (cf_arrow_end) ; @@ -882,12 +1012,12 @@ % arrow customization \keys_define:nn { chemmacros / chemformula } { - arrow-offset .dim_set:N = \l__chemformula_arrow_offset_dim , + arrow-offset .tl_set:N = \l__chemformula_arrow_offset_tl , arrow-min-length .dim_set:N = \l__chemformula_arrow_minimum_length_dim , arrow-yshift .dim_set:N = \l__chemformula_arrow_yshift_dim , arrow-ratio .tl_set:N = \l__chemformula_arrow_ratio_tl , label-offset .dim_set:N = \l__chemformula_arrow_label_offset_dim , - compound-sep .dim_set:N = \l__chemformula_compound_sep_dim , + compound-sep .tl_set:N = \l__chemformula_compound_sep_tl , arrow-style .tl_set:N = \l__chemformula_arrow_style_tl , label-style .tl_set:N = \l__chemformula_arrow_label_style_tl , arrow-penalty .tl_set:N = \l__chemformula_arrow_penalty_tl , @@ -941,7 +1071,7 @@ \tl_if_blank:nTF { #1 } { \tl_gclear:N \g__chemformula_options_tl } { \tl_gset:Nn \g__chemformula_options_tl { #1 } } - \__chemformula_ch_aux_i:w #2 \\ \q_no_value \q_stop + \__chemformula_ch_newline:w #2 \\ \q_no_value \q_stop \group_align_safe_end: \tl_use:N \g__chemformula_output_tl \tl_gclear:N \g__chemformula_output_tl @@ -950,60 +1080,85 @@ % Trickery to use \ch inside align environment: % bypass \\: -\cs_new_protected:Npn \__chemformula_ch_aux_i:w #1 \\ #2 \q_stop +\cs_new_protected:Npn \__chemformula_ch_newline:w #1 \\ #2 \q_stop { - \__chemformula_ch_aux_ii:w #1 & \q_no_value \q_stop + \__chemformula_ch_align:w #1 & \q_no_value \q_stop \quark_if_no_value:nF { #2 } { \tl_gput_right:Nn \g__chemformula_output_tl { \\ } - \__chemformula_ch_aux_i:w #2 \q_stop + % look for optional argument: + \peek_meaning:NTF [ + { \__chemformula_ch_newline_skip:w } + { \__chemformula_ch_newline:w } + #2 \q_stop } } +\cs_new_protected:Npn \__chemformula_ch_newline_skip:w [ #1 ] + { + \tl_gput_right:Nn \g__chemformula_output_tl { [#1] } + \__chemformula_ch_newline:w + } + % bypass &: -\cs_new_protected:Npn \__chemformula_ch_aux_ii:w #1 & #2 \q_stop +\cs_new_protected:Npn \__chemformula_ch_align:w #1 & #2 \q_stop { - \__chemformula_ch_aux_iii:w #1 \label{} \q_no_value \q_stop + \__chemformula_ch_label:w #1 \label \q_no_value \q_stop \quark_if_no_value:nF { #2 } { \tl_gput_right:Nn \g__chemformula_output_tl { & } - \__chemformula_ch_aux_ii:w #2 \q_stop + \__chemformula_ch_align:w #2 \q_stop } } % bypass \label: -\cs_new_protected:Npn \__chemformula_ch_aux_iii:w #1 \label#2 #3 \q_stop +\cs_new_protected:Npn \__chemformula_ch_label:w #1 \label #2 \q_stop { - \__chemformula_ch_aux_iv:w #1 \tag{} \q_no_value \q_stop - \quark_if_no_value:nF { #3 } + \__chemformula_ch_tag:w #1 \tag{} \q_no_value \q_stop + \quark_if_no_value:nF { #2 } { - \tl_gput_right:Nn \g__chemformula_output_tl { \label { #2 } } - \__chemformula_ch_aux_iii:w #3 \q_stop - } + \tl_gput_right:Nn \g__chemformula_output_tl { \label } + \peek_meaning:NTF [ % ] + { \__chemformula_ch_label_opt:w } + { \__chemformula_ch_label_no_opt:n } + #2 \q_stop + } + } + +\cs_new_protected:Npn \__chemformula_ch_label_opt:w [ #1 ] #2 + { + \tl_gput_right:Nn \g__chemformula_output_tl { [{#1}] {#2} } + \__chemformula_ch_label:w + } + +\cs_new_protected:Npn \__chemformula_ch_label_no_opt:n #1 + { + \tl_gput_right:Nn \g__chemformula_output_tl { {#1} } + \__chemformula_ch_label:w } % here's something not working when used together with `hyperref' % which seems to be related to \nonumber % bypass \tag: -\cs_new_protected:Npn \__chemformula_ch_aux_iv:w #1 \tag#2 #3 \q_stop +\cs_new_protected:Npn \__chemformula_ch_tag:w #1 \tag#2 #3 \q_stop { - \__chemformula_ch_aux_v:w #1 \intertext{} \q_no_value \q_stop + \__chemformula_ch_intertext:w #1 \intertext{} \q_no_value \q_stop \quark_if_no_value:nF { #3 } { \tl_gput_right:Nn \g__chemformula_output_tl { \protect\tag { #2 } } - \__chemformula_ch_aux_iv:w #3 \q_stop + \__chemformula_ch_tag:w #3 \q_stop } } % bypass \intertext: -\cs_new_protected:Npn \__chemformula_ch_aux_v:w #1 \intertext#2 #3 \q_stop +\cs_new_protected:Npn \__chemformula_ch_intertext:w #1 \intertext#2 #3 \q_stop { \tl_gput_right:Nn \g__chemformula_output_tl { \__chemformula_ch_main:n { #1 } } \quark_if_no_value:nF { #3 } { \tl_gput_right:Nn \g__chemformula_output_tl { \intertext { #2 } } - \__chemformula_ch_aux_v:w #3 \q_stop + \__chemformula_ch_intertext:w #3 \q_stop } } @@ -1017,6 +1172,7 @@ { \group_begin: \keys_set:nn { chemmacros / chemformula } { #1 } + \__chemformula_save_catcodes: \__chemformula_sanitize:Nn \l__chemformula_chemformula_tmpa_tl { #2 } @@ -1035,7 +1191,14 @@ % arrow generation & detection \cs_new:Npn \__chemformula_generate_arrows:Nn #1#2 { - \tl_set:Nn \l__chemformula_tmpa_tl { #2 } + \tl_set_rescan:Nnn \l__chemformula_tmpa_tl + { + \char_set_catcode_other:N \> + \char_set_catcode_other:N \< + \char_set_catcode_other:N \- + \char_set_catcode_other:N \= + } + { #2 } \seq_map_inline:Nn \l__chemformula_arrows_type_seq { \tl_replace_all:Nnn \l__chemformula_tmpa_tl @@ -1050,7 +1213,7 @@ \bool_set_false:N \l__chemformula_is_arrow_bool \prop_map_inline:Nn \l__chemformula_arrows_code_prop { - \tl_set_rescan:Nnn \l__chemformula_tmpa_tl {} { ##1 } + \__chemformula_sanitize:Nn \l__chemformula_tmpa_tl { ##1 } \tl_if_in:nVT { #1 } \l__chemformula_tmpa_tl { \bool_set_true:N \l__chemformula_is_arrow_bool } } @@ -1123,6 +1286,7 @@ \prop_put:Nnn \l__chemformula_cmpd_prop { - } { \chemformula_single_bond: } \prop_put:Nnn \l__chemformula_cmpd_prop { = } { \chemformula_double_bond: } \prop_put:Nnn \l__chemformula_cmpd_prop { + } { \chemformula_triple_bond: } +\prop_put:Nnn \l__chemformula_cmpd_prop { ' } { \chemformula_prime: } % numbers \prop_put:Nnn \l__chemformula_numbers_prop { 0 } { 0 } @@ -1149,7 +1313,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: } +\prop_put:Nnn \l__chemformula_charge_prop { . } { \chemformula_radical_or_decimal: } +\prop_put:Nnn \l__chemformula_charge_prop { , } { \chemformula_decimal: } % stoichiometric factors \prop_put:Nnn \l__chemformula_stoich_prop { 0 } { 0 } @@ -1162,8 +1327,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 { . } { \chemformula_decimal: } +\prop_put:Nnn \l__chemformula_stoich_prop { , } { \chemformula_decimal: } \prop_put:Nnn \l__chemformula_stoich_prop { / } { / } \prop_put:Nnn \l__chemformula_stoich_prop { _ } { _ } \prop_put:Nnn \l__chemformula_stoich_prop { ( } { ( } @@ -1176,6 +1341,25 @@ \prop_put:Nnn \l__chemformula_no_stoich_prop { ( } { } \prop_put:Nnn \l__chemformula_no_stoich_prop { ) } { } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 0 } { \chemformula_charge_style:n { 0 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 1 } { \chemformula_charge_style:n { 1 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 2 } { \chemformula_charge_style:n { 2 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 3 } { \chemformula_charge_style:n { 3 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 4 } { \chemformula_charge_style:n { 4 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 5 } { \chemformula_charge_style:n { 5 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 6 } { \chemformula_charge_style:n { 6 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 7 } { \chemformula_charge_style:n { 7 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 8 } { \chemformula_charge_style:n { 8 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { 9 } { \chemformula_charge_style:n { 9 } } +\prop_put:Nnn \l__chemformula_kroegervink_prop { + } { \chemformula_plus: } +\prop_put:Nnn \l__chemformula_kroegervink_prop { - } { \chemformula_minus: } +\prop_put:Nnn \l__chemformula_kroegervink_prop { . } { \chemformula_radical_or_decimal: } +\prop_put:Nnn \l__chemformula_kroegervink_prop { , } { \chemformula_decimal: } +\prop_put:Nnn \l__chemformula_kroegervink_prop { ' } { \chemformula_kroegervink_negative: } +\prop_put:Nnn \l__chemformula_kroegervink_prop { x } { \chemformula_kroegervink_neutral: } +\prop_put:Nnn \l__chemformula_kroegervink_prop { * } { \chemformula_kroegervink_positive: } +\prop_put:Nnn \l__chemformula_kroegervink_prop { . } { \chemformula_kroegervink_positive: } + % -------------------------------------------------------------------------- % bonds: \cs_new:Npn \chemformula@bondlength @@ -1380,6 +1564,7 @@ % remove double or nested sub- and superscripts \cs_new_protected:Npn \chemformula_subscript:n #1 { + \chemformula_nobreak: \tl_if_eq:nnTF { #1 }{ \chemformula_superscript:n } { \__chemformula_subscript:n } { @@ -1476,6 +1661,7 @@ % remove double or nested sub- and superscripts \cs_new_protected:Npn \chemformula_superscript:n #1 { + \chemformula_nobreak: \tl_if_eq:nnTF { #1 } { \chemformula_superscript:n } { \__chemformula_superscript:n } { @@ -1520,11 +1706,30 @@ \tl_replace_all:Nnn \l__chemformula_superscript_tl { + } { \chemformula_plus: } \tl_replace_all:Nnn \l__chemformula_superscript_tl - { \chemformula_adduct: } { \chemformula_radical: } - \tl_replace_all:Nnn \l__chemformula_superscript_tl - { \chemformula_star_adduct: } { * } - \tl_replace_all:Nnn \l__chemformula_superscript_tl - { . } { \chemformula_radical: } + { \chemformula_adduct: } { \chemformula_radical_or_decimal: } + \bool_if:NTF \l__chemformula_kroegervink_bool + { + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { ' } { \chemformula_kroegervink_negative: } + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { \chemformula_adduct: } { . } + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { \chemformula_star_adduct: } { * } + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { \chemformula_radical_or_decimal: } { . } + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { \chemformula_prime: } { \chemformula_kroegervink_negative: } + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { * } { \chemformula_kroegervink_positive: } + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { . } { \chemformula_kroegervink_positive: } + } + { + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { \chemformula_star_adduct: } { * } + \tl_replace_all:Nnn \l__chemformula_superscript_tl + { . } { \chemformula_radical_or_decimal: } + } } \cs_new_protected:Npn \__chemformula_superscript_raise:N #1 @@ -1551,10 +1756,19 @@ { \c_math_toggle_token \scriptstyle - \prop_get:NoNTF \l__chemformula_charge_prop - { #1 } \l__chemformula_tmpa_tl - { \tl_use:N \l__chemformula_tmpa_tl } - { \chemformula_charge_style:n { #1 } } + \bool_if:NTF \l__chemformula_kroegervink_bool + { + \prop_get:NoNTF \l__chemformula_kroegervink_prop + { #1 } \l__chemformula_tmpa_tl + { \tl_use:N \l__chemformula_tmpa_tl } + { \chemformula_charge_style:n { #1 } } + } + { + \prop_get:NoNTF \l__chemformula_charge_prop + { #1 } \l__chemformula_tmpa_tl + { \tl_use:N \l__chemformula_tmpa_tl } + { \chemformula_charge_style:n { #1 } } + } \c_math_toggle_token } \group_end: @@ -1581,6 +1795,12 @@ \bool_set_false:N \l__chemformula_charge_full_shift_bool \dim_zero:N \l__chemformula_charge_shift_dim } + % no shift for Kroeger Vink notation + \bool_if:NT \l__chemformula_kroegervink_bool + { + \bool_set_false:N \l__chemformula_charge_full_shift_bool + \dim_zero:N \l__chemformula_charge_shift_dim + } % align to the right if isotope else to the left \bool_if:NTF \l__chemformula_is_isotope_bool { @@ -1666,6 +1886,7 @@ % read the input \cs_new_protected:Npn \chemformula_input:n #1 { + \__chemformula_save_catcodes: \__chemformula_sanitize:Nn \l__chemformula_chemformula_tmpa_tl { #1 } \chemformula_input_escape_text:V \l__chemformula_chemformula_tmpa_tl \chemformula_input_escape_math:n { #1 } @@ -1703,6 +1924,8 @@ % -------------------------------------------------------------------------- % input stoichiometric factors +\cs_new:Npn \chemformula_decimal: { { \l__chemformula_decimal_output_tl } } + \cs_new_protected:Npn \chemformula_input_stoich:n #1 { \bool_set_true:N \l__chemformula_stoich_bool @@ -1779,7 +2002,7 @@ { % get head: \tl_set:Nx \l__chemformula_tmpa_tl { \tl_head:n { #1 } } - \tl_set:Nn \l__chemformula_tmpb_tl { \l__chemformula_decimal_output_tl } + \tl_set:Nn \l__chemformula_tmpb_tl { \chemformula_decimal: } % check if stoich starts with decimal-marker and add leading 0 if so: \tl_if_eq:NNTF \l__chemformula_tmpa_tl \l__chemformula_tmpb_tl { \tl_put_right:Nn \l__chemformula_input_tl { 0#1 } } @@ -1907,7 +2130,7 @@ \tl_clear:N \l__chemformula_stoich_tl } } -\cs_generate_variant:Nn \chemformula_input_cmpd:nN { VN } +\cs_generate_variant:Nn \chemformula_input_cmpd:nN { V } \cs_new_protected:Npn \chemformula_font_inner: { @@ -1940,7 +2163,7 @@ \cs_new:Npn \__chemformula_fontspec_aux:w [#1]#2 \q_stop { \newfontfamily \chemformula_font: [ #1 ] { #2 } } -\cs_new_protected:Npn \__chemformula_sanitize:Nn #1#2 +\cs_new_protected:Npn \__chemformula_save_catcodes: { \cs_gset_protected:Npx \__chemformula_restore: { @@ -1952,7 +2175,13 @@ \char_set_catcode:nn { 35 } { \char_value_catcode:n { 35 } }% # \char_set_catcode:nn { 33 } { \char_value_catcode:n { 33 } }% ! \char_set_catcode:nn { 34 } { \char_value_catcode:n { 34 } }% " + \char_set_catcode:nn { 60 } { \char_value_catcode:n { 60 } }% < + \char_set_catcode:nn { 62 } { \char_value_catcode:n { 62 } }% > } + } + +\cs_new_protected:Npn \__chemformula_sanitize:Nn #1#2 + { \tl_set_rescan:Nnn #1 { % expl3 catcodes: @@ -1964,11 +2193,15 @@ \char_set_catcode_letter:N \{ \char_set_catcode_letter:N \} % this one seems not necessary any more: -% \char_set_catcode_letter:N \\ + % \char_set_catcode_letter:N \\ \char_set_catcode_letter:N \# % make the naming work with babel languages like French that make % ! active: \char_set_catcode_other:N \! + % make the naming work with babel languages like Spanish that make + % < and > active: + \char_set_catcode_other:N \> + \char_set_catcode_other:N \< % ensure " is other: \char_set_catcode_other:N \" } @@ -2041,17 +2274,23 @@ } { \prop_get:NnNTF \l__chemformula_cmpd_prop { ##1 } \l__chemformula_tmpb_tl - { \tl_put_right:No #2 { \l__chemformula_tmpb_tl } } + { \tl_put_right:NV #2 \l__chemformula_tmpb_tl } { \tl_put_right:Nn #2 { ##1 } } } } } { \prop_get:NnNTF \l__chemformula_cmpd_prop { ##1 } \l__chemformula_tmpb_tl - { \tl_put_right:No #2 { \l__chemformula_tmpb_tl } } + { \tl_put_right:NV #2 \l__chemformula_tmpb_tl } { \tl_put_right:Nn #2 { ##1 } } } } + \bool_if:NT \l__chemformula_kroegervink_bool + { + \tl_replace_all:Nnn #2 + { \chemformula_prime: } + { \chemformula_superscript:n { \chemformula_prime: } } + } } % -------------------------------------------------------------------------- @@ -2147,7 +2386,7 @@ } \bool_set_false:N \l__chemformula_is_arrow_bool } -\cs_generate_variant:Nn \chemformula_input_arrow:n { o } +\cs_generate_variant:Nn \chemformula_input_arrow:n { o,V } % -------------------------------------------------------------------------- % input compound name @@ -2221,6 +2460,7 @@ { _ } { \sb } \tl_replace_all:Nnn \l__chemformula_tmpa_tl { chemformulaplaceholder } { \_ } + % TODO: waum ist das auskommentiert % \__chemformula_reset:NV \l__chemformula_tmpa_tl \l__chemformula_tmpa_tl \tl_put_right:NV \l__chemformula_input_tl \l__chemformula_tmpa_tl } @@ -2499,7 +2739,12 @@ \cs_new_protected:Npn \__chemformula_lewis_elspec_pair_dots: { - \chemformula_draw:nn { fill } + \chemformula_draw:nn + { + fill, + inner~sep=0pt, + outer~sep=0pt + } { (node~cs \c_chemformula_colon_tl name = chlewis-\int_use:N \g__chemformula_lewis_int , @@ -2561,7 +2806,12 @@ \cs_new_protected:Npn \__chemformula_lewis_elspec_single: { - \chemformula_draw:nn { fill } + \chemformula_draw:nn + { + fill, + inner~sep=0pt, + outer~sep=0pt + } { (node~cs \c_chemformula_colon_tl name = chlewis-\int_use:N \g__chemformula_lewis_int , @@ -2777,10 +3027,21 @@ VERSION HISTORY - new option stoich-print - new command \chstoich 2014/01/29 - version 4.4 - treat a single `-' as a minus sign +2014/04/07 - version 4.5 - make sure that < and > have catcode 12 when read + as parts of arrows + - new arrow types `>=<', `>=<<', `>>=<' and `<==>' + - arrow lengths and compound offset now correctly + adapts to new fontsize if relative lengths (em,ex) + are used + - allow optional arguments to \\ in equation + environments + - allow optional arguments to \label in equation + environments + (credits: http://tex.stackexchange.com/a/166661/5049) + - support for Kröger-Vink notation % -------------------------------------------------------------------------- % TODO - Addukte: Zahlen nach * und . automatisch erkennen? -- optionale Argumente von \\ nach außen - make escaped text/math /truely/ escaped, i.e., behave as if it's been input /outside/ of \ch diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index 5c95c03bf23..846a9d86fcd 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -26,8 +26,8 @@ % - The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- \RequirePackage{ expl3 , xparse , l3keys2e } -\def\chemmacros@version{4.4} -\def\chemmacros@date{2014/01/29} +\def\chemmacros@version{4.5} +\def\chemmacros@date{2014/04/08} \ProvidesExplPackage {chemmacros} @@ -57,6 +57,7 @@ \cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV } \cs_generate_variant:Nn \tl_if_eq:nnTF { V } \cs_generate_variant:Nn \tl_const:cn { cV } +\cs_generate_variant:Nn \tl_to_lowercase:n { f } % -------------------------------------------------------------------------- % load required packages @@ -1393,21 +1394,49 @@ % --------------------------------------------------------------------------- % % acid / base \tl_new:N \l__chemmacros_k_acid_tl -\tl_set:Nn \l__chemmacros_k_acid_tl { \chemmacros_translate:n { K-acid } } \tl_new:N \l__chemmacros_k_base_tl -\tl_set:Nn \l__chemmacros_k_base_tl { \chemmacros_translate:n { K-base } } \tl_new:N \l__chemmacros_k_water_tl -\tl_set:Nn \l__chemmacros_k_water_tl { \chemmacros_translate:n { K-water } } + +\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 } } + } + +\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 } } + } + +\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 } } + } \keys_define:nn { chemmacros / acid-base } { - p-style .choice: , - p-style / slanted .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textsl , - p-style / italics .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textit , - p-style / upright .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textup , - 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 + p-style .choice: , + p-style / slanted .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textsl , + p-style / italics .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textit , + p-style / upright .code:n = \cs_set_eq:NN \chemmacros_p_style:n \textup , + 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 } \cs_new_eq:NN \chemmacros_p_style:n \textup @@ -4015,10 +4044,15 @@ % -------------------------------------------------------------------------- % language support -- provided through `translations' % equilibrium constants: -\DeclareTranslationFallback{K-acid}{A} -\DeclareTranslationFallback{K-base}{B} -\DeclareTranslationFallback{K-water}{W} -\DeclareTranslation{German}{K-acid}{S} +\DeclareTranslationFallback {K-acid} {A} +\DeclareTranslation{German} {K-acid} {S} +\DeclareTranslation{Dutch} {K-acid} {Z} + +\DeclareTranslationFallback {K-base} {B} +% \DeclareTranslation{Dutch} {K-base} {B} + +\DeclareTranslationFallback {K-water} {W} +% \DeclareTranslation{Dutch} {K-water} {W} % phases: \DeclareTranslation{German}{phase-sld}{ f } \DeclareTranslation{German}{phase-lqd}{ f{}l } @@ -4028,12 +4062,14 @@ \DeclareTranslation{German} {list-of-reactions} { Reaktionsverzeichnis } \DeclareTranslation{Italian} {list-of-reactions} { Elenco~ delle~ reazioni } \DeclareTranslation{French} {list-of-reactions} { Table~ des~ r\'eactions } +\DeclareTranslation{Dutch} {list-of-reactions} { Lijst~ van~ reacties } % \DeclareTranslationFallback {reaction} { Reaction } \DeclareTranslation{English} {reaction} { Reaction } \DeclareTranslation{German} {reaction} { Reaktion } \DeclareTranslation{Italian} {reaction} { Reazione } \DeclareTranslation{French} {reaction} { R\'eaction } +\DeclareTranslation{Dutch} {reaction} { Reactie } \tl_set:Nn \l__chemmacros_reaction_lorname_tl { \chemmacros_translate:n {reaction} } @@ -4291,6 +4327,8 @@ Version history changes in `translations' - new option `nmr/atom-number-cs' - new option `nmr/coupling-pos-cs' +2014/04/08 - version 4.5 - new option `acid-base/subscript' + - added Dutch translations % --------------------------------------------------------------------------- % % TODO: diff --git a/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty b/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty index e65997437f2..ebe94bd0db3 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty @@ -27,8 +27,8 @@ % - The Current Maintainer of this work is Clemens Niederberger. - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage{ expl3, xparse, l3keys2e } -\def\ghsystem@version{4.2e} -\def\ghsystem@date{2014/01/09} +\def\ghsystem@version{4.5} +\def\ghsystem@date{2014/04/08} \ProvidesExplPackage {ghsystem} {\ghsystem@date} @@ -641,7 +641,7 @@ VERSION HISTORY - added \ghsystem_dash: and \ghsystem_slash: 2014/01/09 - version 4.2e - bug fix: namespace after language file loading properly restored -2014/??/?? - version 4.3 - small changes in `ghsystem_italian.def' +2014/04/08 - version 4.5 - small changes in `ghsystem_italian.def' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % TODO: |