From 48ea98193ab70b9d4d1e5fb2acddd70a1ff3d5ae Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 11 Feb 2012 00:49:37 +0000 Subject: chemmacros (10feb12) git-svn-id: svn://tug.org/texlive/trunk@25352 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/chemmacros/chemformula.sty | 226 +++++++++++++---- .../texmf-dist/tex/latex/chemmacros/chemmacros.sty | 272 ++++++++++++++------- .../texmf-dist/tex/latex/chemmacros/ghsystem.sty | 8 +- .../chemmacros/language/ghsystem_langtemplate.def | 2 +- 4 files changed, 367 insertions(+), 141 deletions(-) (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty index 3ba0ba784ac..b5e74df2f90 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty @@ -5,9 +5,9 @@ % - macros and commands for chemists - % % --------------------------------------------------------------------------- % % - Clemens Niederberger - % -% - 2012/02/05 - % +% - 2012/02/10 - % % --------------------------------------------------------------------------- % -% - http://www.mychemistry.eu/ - % +% - https://bitbucket.org/cgnieder/chemmacros/ - % % - contact@mychemistry.eu - % % --------------------------------------------------------------------------- % % - If you have any ideas, questions, suggestions or bugs to report, please - % @@ -28,7 +28,7 @@ % - The Current Maintainer of this work is Clemens Niederberger. - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage{ expl3 } -\ProvidesExplPackage {chemformula} {2012/02/05} {3.0c} {typeset chemical compounds and reactions} +\ProvidesExplPackage {chemformula} {2012/02/10} {3.0d} {typeset chemical compounds and reactions} %-----------------------------------------------------------------------------% % WARNING AND ERROR MESSAGES @@ -113,6 +113,7 @@ \textperiodcentered \skip_horizontal:N \l_chemformula_cdot_space_dim } +\cs_new_eq:NN \chemformula_star_adduct: \chemformula_adduct: %-----------------------------------------------------------------------------% % ARROW DEFINITION @@ -275,8 +276,20 @@ coordinate (chemformula_arrow_start) (0,0) ++ (\l_chemformula_compound_sep_dim,.3432em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim , 0) - node[pos=.5,above=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #1 } - node[pos=.5,below=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #2 } + node + [ + pos=.5, + above=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #1 } + node + [ + pos=.5, + below=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #2 } } \chemformula_draw:nn {} { @@ -297,8 +310,20 @@ coordinate (chemformula_arrow_start) (0,0) ++ (\l_chemformula_compound_sep_dim,.3432em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim , 0) - node[pos=.5,above=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #1 } - node[pos=.5,below=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #2 } + node + [ + pos=.5, + above=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #1 } + node + [ + pos=.5, + below=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #2 } } \chemformula_draw:nn {} { @@ -319,8 +344,20 @@ coordinate (chemformula_arrow_start) (0,0) ++ (\l_chemformula_compound_sep_dim,.3432em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim , 0) - node[pos=.5,above=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #1 } - node[pos=.5,below=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #2 } + node + [ + pos=.5, + above=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #1 } + node + [ + pos=.5, + below=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #2 } } \chemformula_draw:nn {} { @@ -341,14 +378,26 @@ coordinate (chemformula_arrow_start) (0,0) ++ (\l_chemformula_compound_sep_dim,.429em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim , 0) - node[pos=.5,above=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #1 } + node + [ + pos=.5, + above=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #1 } } \chemformula_draw:xn { left~\l_chemformula_arrow_head_tl- , \l_chemformula_arrow_style_tl } { (chemformula_arrow_start) ++ (\l_chemformula_compound_sep_dim,.2574em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim , 0) - node[pos=.5,below=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #2 } + node + [ + pos=.5, + below=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #2 } } \chemformula_draw:nn {} { @@ -369,14 +418,26 @@ coordinate (chemformula_arrow_start) (0,0) ++ (\l_chemformula_compound_sep_dim,.429em) ++ (0,\dim_use:N \l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim , 0) - node[pos=.5,above=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #1 } + node + [ + pos=.5, + above=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #1 } } \chemformula_draw:xn { left~\l_chemformula_arrow_head_tl- , \l_chemformula_arrow_style_tl } { (chemformula_arrow_start) ++ (\l_chemformula_compound_sep_dim + \l_chemformula_arrow_shortage_dim,.2574em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim -2*\l_chemformula_arrow_shortage_dim , 0) - node[pos=.5,below=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #2 } + node + [ + pos=.5, + below=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #2 } } \chemformula_draw:nn {} { @@ -397,13 +458,25 @@ coordinate (chemformula_arrow_start) (0,0) ++ (\l_chemformula_compound_sep_dim + \l_chemformula_arrow_shortage_dim,.429em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim - 2*\l_chemformula_arrow_shortage_dim , 0) - node[pos=.5,above=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #1 } + node + [ + pos=.5, + above=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #1 } } \chemformula_draw:xn { left~\l_chemformula_arrow_head_tl- , \l_chemformula_arrow_style_tl } { (chemformula_arrow_start) ++ (\l_chemformula_compound_sep_dim,.2574em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ ( \dim_use:N \l_chemformula_arrow_length_dim , 0) - node[pos=.5,below=\l_chemformula_arrow_label_offset_dim,font=\l_chemformula_arrow_label_style_tl,butt~cap-butt~cap] { #2 } + node + [ + pos=.5, + below=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #2 } } \chemformula_draw:nn {} { @@ -413,6 +486,45 @@ } } +% <> +\NewDocumentCommand \chemformula_arrow_both:w { O{}O{} } + { + \chemformula_determine_arrow_length:nn { #1 } { #2 } + \chemformula_tikz:nn { inner~sep=0, baseline=(chemformula_arrow_start.base) } + { + \chemformula_draw:xn { -\l_chemformula_arrow_head_tl , \l_chemformula_arrow_style_tl } + { + coordinate (chemformula_arrow_start) (0,0) + ++ (\l_chemformula_compound_sep_dim,.441em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ + ( \dim_use:N \l_chemformula_arrow_length_dim , 0) + node + [ + pos=.5, + above=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #1 } + } + \chemformula_draw:xn { \l_chemformula_arrow_head_tl- , \l_chemformula_arrow_style_tl } + { + (chemformula_arrow_start) ++ + (\l_chemformula_compound_sep_dim,.2454em) ++ (0,\l_chemformula_arrow_yshift_dim) -- ++ + ( \dim_use:N \l_chemformula_arrow_length_dim , 0) + node + [ + pos=.5, + below=\l_chemformula_arrow_label_offset_dim, + font=\l_chemformula_arrow_label_style_tl, + butt~cap-butt~cap + ] { #2 } + } + \chemformula_draw:nn {} + { + (\l_chemformula_compound_sep_dim,.3432em) ++ (0,\l_chemformula_arrow_yshift_dim) ++ + ( \l_chemformula_compound_sep_dim + \dim_use:N \l_chemformula_arrow_length_dim , 0) + } + } + } %-----------------------------------------------------------------------------% % arrow customization \keys_define:nn { chemmacros / chemformula } @@ -432,6 +544,7 @@ \NewDocumentCommand \chemformula_ch_aux_iii:w { > { \SplitList { ~ } } m } { \group_begin: + \bool_set_true:N \l_chemformula_inside_ch_bool \tl_if_blank:oF { \g_chemformula_options_tl } { \keys_set:no { chemmacros / chemformula } { \g_chemformula_options_tl } } \tl_map_function:nN { #1 } \chemformula_input:n @@ -447,6 +560,8 @@ \cs_new:Nn \chemformula_ch:nn { \group_align_safe_begin: + \cs_set:Npn \xspace {} + \leavevmode \IfNoValueTF { #1 } { \tl_gclear:N \g_chemformula_options_tl } { \tl_gset:Nn \g_chemformula_options_tl { #1 } } @@ -510,6 +625,8 @@ { \tl_replace_all:Nnn \l_tmpa_tl { <=>> } { \chemformula_arrow_equilibrium_right:w } } \tl_if_in:onT { \l_tmpa_tl } { <=> } { \tl_replace_all:Nnn \l_tmpa_tl { <=> } { \chemformula_arrow_equilibrium:w } } + \tl_if_in:onT { \l_tmpa_tl } { <> } + { \tl_replace_all:Nnn \l_tmpa_tl { <> } { \chemformula_arrow_both:w } } \tl_set_eq:NN \l_chemformula_output_tl \l_tmpa_tl } \cs_generate_variant:Nn \chemformula_generate_arrows:n { N } @@ -585,6 +702,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % parsing input % booleans: +\bool_new:N \l_chemformula_inside_ch_bool \bool_new:N \l_chemformula_stoich_bool \bool_new:N \l_chemformula_is_plus_bool \bool_new:N \l_chemformula_is_up_bool @@ -599,6 +717,7 @@ \bool_new:N \l_chemformula_charge_style_math_bool \bool_new:N \l_chemformula_sub_bool \bool_new:N \l_chemformula_sup_bool +\bool_new:N \l_chemformula_first_is_sup_bool \bool_new:N \l_chemformula_xfrac_bool \bool_new:N \l_chemformula_nicefrac_bool \bool_new:N \l_chemformula_mathfrac_bool @@ -642,7 +761,7 @@ \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 { .3ex } + \dim_set:Nn \l_chemformula_charge_shift_dim { 1ex } \dim_new:N \l_chemformula_subscript_shift_default_dim \dim_set:Nn \l_chemformula_subscript_shift_default_dim { -.6ex } \dim_new:N \l_chemformula_subscript_shift_dim @@ -654,6 +773,7 @@ \dim_zero:N \l_chemformula_subscript_dim \dim_new:N \l_chemformula_supscript_dim \dim_zero:N \l_chemformula_supscript_dim +\dim_new:N \l_chemformula_subscript_compare_dim \dim_new:N \l_chemformula_bond_dim \hbox_set:Nn \l_tmpa_box { \textendash } \dim_set:Nn \l_chemformula_bond_dim { \box_wd:N \l_tmpa_box } @@ -675,7 +795,7 @@ \prop_put:Nnn \l_chemformula_cmpd_prop { 7 } { \chemformula_subscript:n { 7 } } \prop_put:Nnn \l_chemformula_cmpd_prop { 8 } { \chemformula_subscript:n { 8 } } \prop_put:Nnn \l_chemformula_cmpd_prop { 9 } { \chemformula_subscript:n { 9 } } -\prop_put:Nnn \l_chemformula_cmpd_prop { * } { \chemformula_adduct: } +\prop_put:Nnn \l_chemformula_cmpd_prop { * } { \chemformula_star_adduct: } \prop_put:Nnn \l_chemformula_cmpd_prop { . } { \chemformula_adduct: } \prop_put:Nnn \l_chemformula_cmpd_prop { - } { \chemformula_single_bond: } \prop_put:Nnn \l_chemformula_cmpd_prop { = } { \chemformula_double_bond: } @@ -789,6 +909,7 @@ \tl_replace_all:Nnn \l_tmpc_tl { \chemformula_single_bond: } { \chemformula_minus: } \tl_replace_all:Nnn \l_tmpc_tl { \chemformula_triple_bond: } {\chemformula_plus: } \tl_replace_all:Nnn \l_tmpc_tl { \chemformula_adduct: } { . } + \tl_replace_all:Nnn \l_tmpc_tl { \chemformula_star_adduct: } { * } % measure width and save it \hbox_set:Nn \l_tmpa_box { @@ -802,13 +923,18 @@ { \chemformula_number_style:n { \l_tmpc_tl } }$ } \dim_set:Nn \l_chemformula_subscript_dim { -\box_wd:N \l_tmpa_box } + \prop_get:NnNTF \l_chemformula_charge_prop { #1 } \l_tmpa_tl + { \exp_args:NNo \hbox_set:Nn \l_tmpb_box { $ ^ { \chemformula_charge_style:n { \l_tmpa_tl } } $ } } + { \exp_args:NNo \hbox_set:Nn \l_tmpb_box { $ ^ { \chemformula_charge_style:n { \l_tmpc_tl } } $ } } + \dim_set:Nn \l_chemformula_subscript_compare_dim { -\box_wd:N \l_tmpb_box } \box_clear:N \l_tmpa_box + \box_clear:N \l_tmpb_box \bool_if:NT \l_chemformula_sup_bool { \chemformula_sub_or_supscript_skip: \bool_if:NT \l_chemformula_charge_shift_bool { - \skip_horizontal:n { \l_chemformula_charge_shift_dim +1pt } + \skip_horizontal:N \l_chemformula_charge_shift_dim \bool_set_false:N \l_chemformula_charge_shift_bool } \dim_zero:N \l_chemformula_supscript_dim @@ -845,6 +971,7 @@ \tl_replace_all:Nnn \l_tmpc_tl { \chemformula_triple_bond: } { \chemformula_plus: } \tl_replace_all:Nnn \l_tmpc_tl { + } { \chemformula_plus: } \tl_replace_all:Nnn \l_tmpc_tl { \chemformula_adduct: } { \chemformula_radical: } + \tl_replace_all:Nnn \l_tmpc_tl { \chemformula_star_adduct: } { * } \tl_replace_all:Nnn \l_tmpc_tl { . } { \chemformula_radical: } % measure width and save it \prop_get:NnNTF \l_chemformula_charge_prop { #1 } \l_tmpa_tl @@ -856,7 +983,7 @@ \bool_if:NT \l_chemformula_sub_bool { \chemformula_sub_or_supscript_skip: - \skip_horizontal:N \l_chemformula_charge_shift_dim + \skip_horizontal:n \l_chemformula_charge_shift_dim \bool_set_true:N \l_chemformula_charge_shift_bool \dim_zero:N \l_chemformula_subscript_dim } @@ -876,16 +1003,27 @@ \cs_new:Npn \chemformula_sub_or_supscript_skip: { - \dim_compare:nTF + \bool_if:NTF \l_chemformula_first_is_sup_bool { - \dim_abs:n { \l_chemformula_subscript_dim } - <= - \dim_abs:n { \l_chemformula_supscript_dim } + % when compound starts with a superscript only shift back + % by the width of the subscript to align them left + \bool_set_false:N \l_chemformula_first_is_sup_bool + \skip_horizontal:N \l_chemformula_subscript_compare_dim + \bool_set_false:N \l_chemformula_sup_bool + \bool_set_false:N \l_chemformula_sub_bool + } + { + \dim_compare:nTF + { + \dim_abs:n { \l_chemformula_subscript_compare_dim } + <= + \dim_abs:n { \l_chemformula_supscript_dim } + } + { \skip_horizontal:N \l_chemformula_subscript_compare_dim } + { \skip_horizontal:N \l_chemformula_supscript_dim } + \bool_set_false:N \l_chemformula_sup_bool + \bool_set_false:N \l_chemformula_sub_bool } - { \skip_horizontal:N \l_chemformula_subscript_dim } - { \skip_horizontal:N \l_chemformula_supscript_dim } - \bool_set_false:N \l_chemformula_sup_bool - \bool_set_false:N \l_chemformula_sub_bool } % handle sub- in superscripts and vice versa @@ -1084,7 +1222,7 @@ \tl_clear:N \l_chemformula_stoich_tl } } -\cs_generate_variant:Nn \chemformula_input_cmpd:nN { oN } +\cs_generate_variant:Nn \chemformula_input_cmpd:nN { oN , fN , xN } \cs_new:Nn \chemformula_font_inner: { @@ -1127,6 +1265,9 @@ \char_set_catcode_letter:N \\ } { #1 } + % let's see if the compound starts with a superscript: + \exp_args:Nx \tl_if_in:nnT { \tl_head:V \l_tmpa_tl } { ^ } + { \bool_set_true:N \l_chemformula_first_is_sup_bool } \tl_if_in:VnT \l_tmpa_tl { ^ } { \tl_replace_all:Nnn \l_tmpa_tl { ^ } { \chemformula_chief_supscript:n } } \tl_if_in:VnT \l_tmpa_tl { _ } @@ -1174,25 +1315,9 @@ { \chemformula_font_inner: ##1 } } \cs_set:Npn \chemmacros_xspace: {} - \tl_set:Nn \l_tmpa_tl { #1 } - \exp_args:NNo \tl_replace_all:Nnn \l_tmpa_tl { \l_chemformula_aq_tl } { _{(aq)} } - \bool_if:NTF \l_chemmacros_german_bool - { \exp_args:NNo \tl_replace_all:Nnn \l_tmpa_tl { \l_chemformula_sld_tl } { _{(f)} } } - { \exp_args:NNo \tl_replace_all:Nnn \l_tmpa_tl { \l_chemformula_sld_tl } { _{(s)} } } - \bool_if:NTF \l_chemmacros_german_bool - { \exp_args:NNo \tl_replace_all:Nnn \l_tmpa_tl { \l_chemformula_lqd_tl } { _{(f\/l)} } } - { \exp_args:NNo \tl_replace_all:Nnn \l_tmpa_tl { \l_chemformula_lqd_tl } { _{(l)} } } - \exp_args:NNo \tl_replace_all:Nnn \l_tmpa_tl { \l_chemformula_gas_tl } { _{(g)} } - \tl_set_eq:NN \l_chemformula_tmpa_tl \l_tmpa_tl } \cs_generate_variant:Nn \chemformula_clean_chem_macros:n { o } -\tl_new:N \l_chemformula_aq_tl -\tl_set_rescan:Nnn \l_chemformula_aq_tl { \char_set_catcode_letter:N \\ } { \aq } -\tl_set_rescan:Nnn \l_chemformula_sld_tl { \char_set_catcode_letter:N \\ } { \sld } -\tl_set_rescan:Nnn \l_chemformula_lqd_tl { \char_set_catcode_letter:N \\ } { \lqd } -\tl_set_rescan:Nnn \l_chemformula_gas_tl { \char_set_catcode_letter:N \\ } { \gas } - %-----------------------------------------------------------------------------% % input "and" sign \cs_new:Nn \chemformula_input_plus:n @@ -1277,7 +1402,7 @@ \cs_new:Npn \chemformula_read_escape_double:w "#1" \q_nil { \tl_set_rescan:Nnn \l_tmpa_tl - { \ExplSyntaxOn \char_set_catcode_other:N \: } + { \ExplSyntaxNamesOn \char_set_catcode_other:N \: } { #1 } \tl_replace_all:Nnn \l_tmpa_tl { \_ } { chemformulaplaceholder } \tl_replace_all:Nnn \l_tmpa_tl { _ } { \sb } @@ -1353,7 +1478,7 @@ { \tl_set_rescan:Nnn \l_tmpa_tl { - \ExplSyntaxOn \char_set_catcode_letter:N \{ + \ExplSyntaxNamesOn \char_set_catcode_letter:N \{ \char_set_catcode_letter:N \} } { \mbox { \( #1 \) } } @@ -1393,7 +1518,7 @@ \keys_define:nn { chemmacros / chemformula } { charge-hshift .dim_set:N = \l_chemformula_charge_shift_dim , - charge-hshift .default:n = .3ex , + charge-hshift .default:n = 1ex , charge-style .choice: , charge-style / text .code:n = \bool_set_false:N \l_chemformula_charge_style_math_bool , @@ -1478,6 +1603,13 @@ VERSION HISTORY renamed formula => chemformula 2012/02/02 - version 3.0b - updated documentation 2012/02/05 - version 3.0c - renamed pictogram files +2012/02/10 - version 3.0d - \xspace disabled inside \ch{} + - bugfix: \ch{_{123}^{23}U} now compiles (\leavevmode + added) + - bugfix: right shift for the super- und subscripts + - bugfix: escaped text recognizes space by ~ again + - * in superscript now gives excited state + - new arrow type <> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % TODO diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index f53fbd5bbe8..fcba2944cd4 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -5,9 +5,9 @@ % - macros and commands for chemists - % % --------------------------------------------------------------------------- % % - Clemens Niederberger - % -% - 2012/02/05 - % +% - 2012/02/10 - % % --------------------------------------------------------------------------- % -% - http://www.mychemistry.eu/ - % +% - https://bitbucket.org/cgnieder/chemmacros/ - % % - contact@mychemistry.eu - % % --------------------------------------------------------------------------- % % - If you have any ideas, questions, suggestions or bugs to report, please - % @@ -30,7 +30,7 @@ \RequirePackage{ expl3 , xparse , l3keys2e , xfrac , siunitx , tikz , mathtools , environ , scrlfile , etoolbox , bm } \usetikzlibrary{calc,arrows} -\ProvidesExplPackage {chemmacros} {2012/02/05} {3.0c} {macros and commands for chemists} +\ProvidesExplPackage {chemmacros} {2012/02/10} {3.0d} {macros and commands for chemists} \@ifpackageloaded { chemformula } {} { \RequirePackage { chemformula } } @@ -167,6 +167,7 @@ \AtEndPreamble { + \chemmacros_make_phases: \bool_if:NT \l_chemmacros_ghsystem_bool { \RequirePackage { ghsystem } } \bool_if:NT \l_chemmacros_bpchem_bool @@ -202,16 +203,40 @@ See~the~documentation~for~more~information. } -\msg_set:nnnn { chemmacros } { particle } +\msg_set:nnnn { chemmacros } { declare-particle } { The~command~sequence~ \token_to_str:N #1 \c_space_tl is~already~defined. } { - You've~tried~to~define~a~particle~with~\token_to_str:N \DeclareParticle ,~but + You've~tried~to~define~a~particle~with~\token_to_str:N \DeclareChemParticle ,~but ~the~command~sequence~ \token_to_str:N #1 \c_space_tl already~exists.~Choose~ another~name. } +\msg_set:nnnn { chemmacros } { renew-particle } + { The~particle~ \token_to_str:N #1 \c_space_tl is~not~defined. } + { + You've~tried~to~renew~the~particle~\token_to_str:N #1 , but~it~doesn't~ + exist. + } + +\msg_set:nnnn { chemmacros } { declare-phase } + { + The~command~sequence~ \token_to_str:N #1 \c_space_tl is~already~defined. + } + { + You've~tried~to~define~a~particle~with~\token_to_str:N \DeclareChemPhase ,~but + ~the~command~sequence~ \token_to_str:N #1 \c_space_tl already~exists.~Choose~ + another~name. + } + +\msg_set:nnnn { chemmacros } { renew-phase } + { The~phase~ \token_to_str:N #1 \c_space_tl is~not~defined. } + { + You've~tried~to~renew~the~phase~\token_to_str:N #1 , but~it~doesn't~ + exist. + } + \msg_set:nnn { chemmacros } { ox } { \token_to_str:N \ox \c_space_tl : ~ #1 ~ \msg_line_context: . @@ -357,40 +382,22 @@ % --------------------------------------------------------------------------- % % transition state symbol -\AtBeginDocument +\cs_new_nopar:Npn \transitionstatesymbol + { \ensuremath { \chemmacros_transitionstatesymbol: } } +\cs_new_nopar:Npn \chemmacros_transitionstatesymbol: + { \mathpalette \chemmacros_transitionstatesymbol_aux: = } +\cs_new_nopar:Npn \chemmacros_transitionstatesymbol_aux: #1#2 { - \cs_new_nopar:Npn \chemmacros_transitionstatesymbol: - { - \mode_if_math:TF - { \text { \chemmacros_transitionstatesymbol_aux: } } - { \chemmacros_transitionstatesymbol_aux: } - } - - \cs_new_nopar:Npn \chemmacros_transitionstatesymbol_aux: - { - \tikz[inner~sep=0,outer~sep=0,minimum~size=0,space-space,line~width=.3pt] - { - \draw (0,0) -- - node[pos=.36] - (chemmacros_transitionstate_x) {} - node[pos=.64] - (chemmacros_transitionstate_y){} - (0,.8em) ; - \draw (chemmacros_transitionstate_x) ++(-.4em,0) -- ++(.8em,0) ; - \draw (chemmacros_transitionstate_y) ++(-.4em,0) -- ++(.8em,0) ; - } - } - - \@ifpackageloaded{mychemistry} - { - \cs_set_eq:NN - \transitionstatesymbol - \chemmacros_transitionstatesymbol: - } + \ooalign { - \cs_new_eq:NN - \transitionstatesymbol - \chemmacros_transitionstatesymbol: + \tex_hfil:D + $#1\mid$ + \tex_hfil:D + \tex_cr:D + \tex_hfil:D + $#1#2$ + \tex_hfil:D + \tex_cr:D } } @@ -427,27 +434,66 @@ \bool_new:N \l_chemmacros_charge_append_bool \bool_set_false:N \l_chemmacros_charge_append_bool +% \DeclareChemParticle, \RenewChemParticle \bool_if:NTF \l_chemmacros_use_mhchem_bool { - \NewDocumentCommand \DeclareParticle { mm } + \NewDocumentCommand \DeclareChemParticle { mm } + { + \cs_if_free:NTF #1 + { + \cs_new_nopar: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 - { \chemmacros_atom:n { #2 } \chemmacros_xspace: } + { \ce { #2 } \chemmacros_xspace: } } - { \chemmacros_msg:nnxx { chemmacros } { particle } { #1 } {} } } } { - \NewDocumentCommand \DeclareParticle { mm } + \NewDocumentCommand \DeclareChemParticle { mm } { \cs_if_free:NTF #1 + { \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 } } + } + } + +\cs_new_nopar:Nn \chemmacros_chem_particle:nn + { + \cs_set_nopar:Npn #1 + { + \bool_if:NTF \l_chemformula_inside_ch_bool { - \cs_set_nopar:Npn #1 - { \chemmacros_chemformula:n { #2 } \chemmacros_xspace: } + \chemformula_input_cmpd:nN { #2 } \l_chemmacros_chemformula_tl + \tl_set_rescan:Nno \l_chemmacros_chemformula_tl + { \ExplSyntaxOn } + { \l_chemmacros_chemformula_tl } + \tl_use:N \l_chemmacros_chemformula_tl + \tl_clear:N \l_chemmacros_chemformula_tl + } + { + \group_begin: + \chemformula_input:n { #2 } + \tl_set_rescan:Nno \l_tmpa_tl + { \ExplSyntaxOn } + { \l_chemformula_input_tl } + \chemformula_write:n { \l_tmpa_tl } + \group_end: + \chemmacros_xspace: } - { \chemmacros_msg:nnxx { chemmacros } { particle } { #1 } {} } } } @@ -457,11 +503,11 @@ \cs_new_nopar:Npn \prt { \chemmacros_atom:n { p } \pch \chemmacros_xspace: } } { - \DeclareParticle \el { e- } - \DeclareParticle \prt { p+ } + \DeclareChemParticle \el { e- } + \DeclareChemParticle \prt { p+ } } -\DeclareParticle \ntr { n^0 } +\DeclareChemParticle \ntr { n^0 } \cs_new_nopar:Npn \chemmacros_bm:n #1 { @@ -570,13 +616,13 @@ \cs_new_nopar:Npn \El { \chemmacros_atom:n { E } \pch \chemmacros_xspace: } } { - \DeclareParticle \Hpl { H+ } - \DeclareParticle \Hyd { OH- } - \DeclareParticle \HtO { H3O+ } - \DeclareParticle \El { E+ } + \DeclareChemParticle \Hpl { H+ } + \DeclareChemParticle \Hyd { OH- } + \DeclareChemParticle \HtO { H3O+ } + \DeclareChemParticle \El { E+ } } -\DeclareParticle \water { H2O } +\DeclareChemParticle \water { H2O } \NewDocumentCommand \chemmacros_Nu:w { o } { @@ -1532,47 +1578,94 @@ % --------------------------------------------------------------------------- % % - phases -\char_set_catcode_math_subscript:N \@ -\cs_new_nopar:Npn \sld +\bool_new:N \l_chemmacros_phases_sub_bool +\dim_new:N \l_chemmacros_phases_space_dim +\dim_set:Nn \l_chemmacros_phases_space_dim { .1333 em } + +\keys_define:nn { chemmacros / phases } { - \peek_meaning:NTF [ - { \chemmacros_sld_aux_i:w } - { \chemmacros_sld_aux_ii:w } + pos .choice: , + pos / sub .code:n = \bool_set_true:N \l_chemmacros_phases_sub_bool , + pos / side .code:n = \bool_set_false:N \l_chemmacros_phases_sub_bool , + space .dim_set:N = \l_chemmacros_phases_space_dim } -\cs_new_nopar:Npn \chemmacros_sld_aux_i:w [#1] - { \ensuremath { @ \mathrm { ( #1 ) } } } +\char_set_catcode_math_subscript:N \@ +\prop_new:N \l_chemmacros_phases_prop +\prop_new:N \l_chemmacros_phases_german_prop -\cs_new_nopar:Npn \chemmacros_sld_aux_ii:w +\NewDocumentCommand \DeclareChemPhase { mom } { - \ensuremath { @ \mathrm { - ( - \bool_if:NTF \l_chemmacros_german_bool - { f } - { s } - ) - } } + \tl_set_rescan:Nnn \l_tmpa_tl { \char_set_catcode_letter:N \\ } { #1 } + \tl_set:Nf \l_tmpa_tl { \tl_tail:V \l_tmpa_tl } + \cs_if_free:NTF #1 + { \cs_new_nopar:Npn #1 {} } + { \chemmacros_msg:nnxx { chemmacros } { declare-phase } { #1 } {} } + \IfNoValueTF { #2 } + { \prop_put:Non \l_chemmacros_phases_german_prop { \l_tmpa_tl } { #3 } } + { \prop_put:Non \l_chemmacros_phases_german_prop { \l_tmpa_tl } { #2 } } + \prop_put:Non \l_chemmacros_phases_prop { \l_tmpa_tl } { #3 } + \chemmacros_make_phases: } -\cs_new_nopar:Npn \lqd +\NewDocumentCommand \RenewChemPhase { mom } { - \peek_meaning:NTF [ - { \chemmacros_lqd_aux_i: } - { \chemmacros_lqd_aux_ii: } + \tl_set_rescan:Nnn \l_tmpa_tl { \char_set_catcode_letter:N \\ } { #1 } + \tl_set:Nf \l_tmpa_tl { \tl_tail:V \l_tmpa_tl } + \cs_if_free:NT #1 + { \chemmacros_msg:nnxx { chemmacros } { renew-phase } { #1 } {} } + \IfNoValueTF { #2 } + { \prop_put:Non \l_chemmacros_phases_german_prop { \l_tmpa_tl } { #3 } } + { \prop_put:Non \l_chemmacros_phases_german_prop { \l_tmpa_tl } { #2 } } + \prop_put:Non \l_chemmacros_phases_prop { \l_tmpa_tl } { #3 } + \chemmacros_make_phases: } -\cs_new_nopar:Npn \chemmacros_lqd_aux_i: [#1] - { \ensuremath { @ \mathrm { ( #1 ) } } } +\cs_new_nopar:Npn \chemmacros_make_phases: + { + \bool_if:NTF \l_chemmacros_german_bool + { + \prop_map_function:NN \l_chemmacros_phases_german_prop + \chemmacros_define_phases:nn + } + { + \prop_map_function:NN \l_chemmacros_phases_prop + \chemmacros_define_phases:nn + } + } -\cs_new_nopar:Npn \chemmacros_lqd_aux_ii: +\cs_new_nopar:Npn \chemmacros_define_phases:nn #1#2 { - \ensuremath { @ \mathrm { - ( - \bool_if:NTF \l_chemmacros_german_bool - { f\/l } - { l } - ) - } } + \cs_set_nopar:cpn { #1 } + { + \bool_if:NTF \l_chemmacros_phases_sub_bool + { \ensuremath { @ { \text { (#2) } } } } + { + \ensuremath + { + \skip_horizontal:N \l_chemmacros_phases_space_dim + \text { (#2) } + } + } + } + } + +\DeclareChemPhase \sld [ f ] { s } +\DeclareChemPhase \lqd [ f{}l ] { l } +\DeclareChemPhase \gas { g } +\DeclareChemPhase \aq { aq } + +\NewDocumentCommand \phase { m } + { + \bool_if:NTF \l_chemmacros_phases_sub_bool + { \ensuremath { @ { \text { (#1) } } } } + { + \ensuremath + { + \skip_horizontal:N \l_chemmacros_phases_space_dim + \text { (#1) } + } + } } \bool_if:NT \l_chemmacros_version_one_bool @@ -1580,12 +1673,6 @@ \cs_new_eq:NN \solid \sld \cs_new_eq:NN \liquid \lqd } - -\cs_new_nopar:Npn \gas - { \ensuremath { @ \mathrm { (g) } } } - -\cs_new_nopar:Npn \aq - { \ensuremath { @ \mathrm { (aq) } } } \char_set_catcode_letter:N \@ % --------------------------------------------------------------------------- % @@ -2983,14 +3070,19 @@ Version history - renamed formula => chemformula and ghs => ghsystem to make the names unique (following a request by Karl Berry for TeXlive) -2012/02/03 - version 3.0b - new command \DeclareParticle, updated documentation +2012/02/03 - version 3.0b - new command \DeclareChemParticle, updated documentation 2012/02/05 - version 3.0c - renamed pictogram files (following a request by Karl Berry for TeXlive) - new package option "Nu" +2012/02/10 - version 3.0d - several bugfixes in chemformula + - bugfixes with \DeclareChemParticle + - new command \RenewChemParticle + - new option phases / pos + - new commands \DeclareChemPhase, \RenewChemPhase, \phase + - changed default behaviour of phases + - removed optional argument from \sld and \lqd % --------------------------------------------------------------------------- % % TODO: - ox-option xfrac vs math? -- Option „side“ for Phasen-Befehle? -- \Nu konflikt mit `mathspec' - resolve conflict with \listofreactions and \setcounter{reaction}{} \ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty b/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty index 6b1c240d86e..8ca91155606 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/ghsystem.sty @@ -5,9 +5,9 @@ % - macros and commands for chemists - % % --------------------------------------------------------------------------- % % - Clemens Niederberger - % -% - 2012/02/05 - % +% - 2012/02/10 - % % --------------------------------------------------------------------------- % -% - http://www.mychemistry.eu/ - % +% - https://bitbucket.org/cgnieder/chemmacros/ - % % - contact@mychemistry.eu - % % --------------------------------------------------------------------------- % % - If you have any ideas, questions, suggestions or bugs to report, please - % @@ -28,7 +28,7 @@ % - The Current Maintainer of this work is Clemens Niederberger. - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage{ expl3 } -\ProvidesExplPackage {ghsystem} {2012/02/05} {3.0c} {globally harmonised system} +\ProvidesExplPackage {ghsystem} {2012/02/10} {3.0d} {globally harmonised system} % --------------------------------------------------------------------------- % % error and warning messages: @@ -432,6 +432,8 @@ VERSION HISTORY 2012/01/30 - version 3.0a - bugfix in chemormula.sty, renamed ghs => ghsystem 2012/02/03 - version 3.0b - updated documentation 2012/02/05 - version 3.0c - renamed pictogram files +2012/02/1ß - version 3.0d - several bugfixes in chemformula, some new commands + and options in chemmacros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % TODO: diff --git a/Master/texmf-dist/tex/latex/chemmacros/language/ghsystem_langtemplate.def b/Master/texmf-dist/tex/latex/chemmacros/language/ghsystem_langtemplate.def index 357eccc33f9..d0e308f4a70 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/language/ghsystem_langtemplate.def +++ b/Master/texmf-dist/tex/latex/chemmacros/language/ghsystem_langtemplate.def @@ -1,7 +1,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % --------------------------------------------------------------------------- % % - the CHEMMACROS bundle - % -% - ghsystem_dlangtemplate.def - % +% - ghsystem_langtemplate.def - % % - macros and commands for chemists - % % --------------------------------------------------------------------------- % % - Clemens Niederberger - % -- cgit v1.2.3