diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemnum')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemnum/chemnum.sty | 483 |
1 files changed, 349 insertions, 134 deletions
diff --git a/Master/texmf-dist/tex/latex/chemnum/chemnum.sty b/Master/texmf-dist/tex/latex/chemnum/chemnum.sty index e14348008b3..8578febc43c 100644 --- a/Master/texmf-dist/tex/latex/chemnum/chemnum.sty +++ b/Master/texmf-dist/tex/latex/chemnum/chemnum.sty @@ -3,7 +3,7 @@ % - a comprehensive approach for the numbering of chemical compounds - % % --------------------------------------------------------------------------- % % - Clemens NIEDERBERGER - % -% - 2011/12/01 - % +% - 2011/12/08 - % % --------------------------------------------------------------------------- % % - http://www.mychemistry.eu/ - % % - contact@mychemistry.eu - % @@ -32,7 +32,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage { expl3 , xparse , l3keys2e , etoolbox , psfrag } -\ProvidesExplPackage {chemnum} {2011/12/01} {0.3e} {Numbering chemical compounds} +\ProvidesExplPackage {chemnum} {2011/12/08} {0.4} {An approach for the numbering of chemical compounds} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % CHECK FOR SUPPORT @@ -305,7 +305,11 @@ \cs_new_nopar:Npn \chemnum_cmpd_style_value:n { } % error message -\msg_set:nnn { chemnum } { cmpd-style } { The~value~of~"cmpd-style~=~<style>"~needs~to~be~a~(or~more)~macro~\msg_line_context: . } +\msg_set:nnn { chemnum } { cmpd-style } + { + The~value~of~"cmpd-style~=~<style>"~needs~to~be~a~(or~more)~macro~ + \msg_line_context: . + } % set style %TODO \cs_new_nopar:Npn \chemnum_cmpd_set_style:n #1 @@ -539,10 +543,14 @@ \tl_new:N \l_chemnum_cmpd_labelsep_tl \tl_set:Nn \l_chemnum_cmpd_labelsep_tl { . } +\tl_new:N \l_chemnum_sublist_input_separator_tl +\tl_set:Nn \l_chemnum_sublist_input_separator_tl { , } + +\tl_new:N \l_chemnum_sublist_output_separator_tl +\tl_set:Nn \l_chemnum_sublist_output_separator_tl { , } + \tl_new:N \l_chemnum_sublabel_range_marker_tl -% \char_make_other:N \: \tl_set:Nn \l_chemnum_sublabel_range_marker_tl { .. } -% \catcode 58 = 11 \relax \tl_new:N \l_chemnum_sub_range_sep_tl \tl_set:Nn \l_chemnum_sub_range_sep_tl { -- } @@ -551,59 +559,167 @@ \bool_set_false:N \l_chemnum_sub_label_only_bool %-----------------------------------------------------------------------------% +% hyperref support +\tl_new:N \l_chemnum_cmpd_hyper_name_tl + +\bool_new:N \l_chemnum_use_hyperref_bool +\bool_new:N \l_chemnum_hypertarget_bool +\bool_new:N \l_chemnum_hyperlink_bool + +\cs_new_eq:NN \chemnum_make_hyper:nn \use_ii:nn + +% #1: main label, #2: sub labels, #3: invisible +\cs_new_nopar:Npn \chemnum_hyperref:nnn #1#2#3 + { + \bool_if:nF { #3 || !\l_chemnum_use_hyperref_bool } + { + \bool_if:NT \l_chemnum_hypertarget_bool + { + \cs_set_nopar:Npn \chemnum_make_hyper:nn ##1##2 + { + \raisebox { 3ex } [ 0pt ] + { \hypertarget { ##1 } { } } ##2 + } + } + \bool_if:NT \l_chemnum_hyperlink_bool + { \cs_set_eq:NN \chemnum_make_hyper:nn \hyperlink } + \bool_if:nT + { !\l_chemnum_hypertarget_bool && !\l_chemnum_hyperlink_bool } + { + \tl_if_blank:nTF { #2 } + { % no sublabel + \tl_set:Nn \l_chemnum_cmpd_hyper_name_tl + { chemnum_cmpd_#1 } + \cs_if_exist:cTF { chemnum_cmpd_#1_hyper: } + { + \bool_set_false:N \l_chemnum_hypertarget_bool + \cs_set_eq:NN \chemnum_make_hyper:nn \hyperlink + } + { + \bool_set_true:N \l_chemnum_hypertarget_bool + \cs_set_nopar:Npn \chemnum_make_hyper:nn ##1##2 + { + \raisebox { 3ex } [ 0pt ] + { \hypertarget { ##1 } { } } ##2 + } + \cs_new_nopar:cpn { chemnum_cmpd_#1_hyper: } { } + } + } + { + \chemnum_cmpd_sublist:n { #2 } + \int_compare:nT { \l_chemnum_cmpd_sublist_length_int < 2 } + { % no sublabel list + \chemnum_cmpd_subrange_separate:n { #2 } + \tl_if_blank:VT \l_tmpb_tl + { % no sublabel range + \tl_set:Nn \l_chemnum_cmpd_hyper_name_tl + { chemnum_cmpd_#1_\l_tmpa_tl } + \cs_if_exist:cTF + { chemnum_cmpd_#1_ \l_tmpa_tl _hyper: } + { + \bool_set_false:N \l_chemnum_hypertarget_bool + \cs_set_eq:NN \chemnum_make_hyper:nn \hyperlink + } + { + \bool_set_true:N \l_chemnum_hypertarget_bool + \cs_set_nopar:Npn \chemnum_make_hyper:nn ##1##2 + { + \raisebox { 3ex } [ 0pt ] + { \hypertarget { ##1 } { } } ##2 + } + \cs_new_nopar:cpn + { chemnum_cmpd_#1_ \l_tmpa_tl _hyper: } { } + } + } + } + } + } + } + } + +%-----------------------------------------------------------------------------% % property keys for compounds \keys_define:nn { chemnum } { - cmpd-style .code:n = \chemnum_cmpd_set_style:n { #1 } , - cmpd-weight .choice: , - cmpd-weight / bold .code:n = \bool_set_true:N \l_chemnum_cmpd_bold_bool , - cmpd-weight / normal .code:n = \bool_set_false:N \l_chemnum_cmpd_bold_bool , - cmpd-label .code:n = + cmpd-style .code:n = \chemnum_cmpd_set_style:n { #1 } , + cmpd-weight .choice: , + cmpd-weight / bold .code:n = \bool_set_true:N \l_chemnum_cmpd_bold_bool , + cmpd-weight / normal .code:n = \bool_set_false:N \l_chemnum_cmpd_bold_bool , + cmpd-label .code:n = { \bool_set_true:N \l_chemnum_cmpd_name_bool \tl_set:Nn \l_chemnum_cmpd_name_tl { #1 } } , - cmpd-prefix .tl_set:N = \l_chemnum_cmpd_prefix_tl , - cmpd-prefix .default:n = { } , - cmpd-suffix .tl_set:N = \l_chemnum_cmpd_suffix_tl , - cmpd-suffix .default:n = { } , - cmpd-space .tl_set:N = \l_chemnum_cmpd_space_tl , - cmpd-space .default:n = { \penalty\@m\ }, - cmpd-delim .code:n = \chemnum_cmpd_delim:n { #1 }, - cmpd-delim .default:n = {(}{)} , - cmpd-odelim .tl_set:N = \l_chemnum_cmpd_odelim_tl , - cmpd-odelim .default:n = { } , - cmpd-cdelim .tl_set:N = \l_chemnum_cmpd_cdelim_tl , - cmpd-cdelim .default:n = { } , - cmpd-sep .tl_set:N = \l_chemnum_cmpd_separator_tl , - cmpd-sep .default:n = { } , - cmpd-all .bool_set:N = \l_chemnum_cmpd_all_bool , - cmpd-all .default:n = true , - cmpd-counter .choice: , - cmpd-counter .choice_code:n = + cmpd-prefix .tl_set:N = \l_chemnum_cmpd_prefix_tl , + cmpd-prefix .default:n = { } , + cmpd-suffix .tl_set:N = \l_chemnum_cmpd_suffix_tl , + cmpd-suffix .default:n = { } , + cmpd-space .tl_set:N = \l_chemnum_cmpd_space_tl , + cmpd-space .default:n = { \penalty\@m\ }, + cmpd-delim .code:n = \chemnum_cmpd_delim:n { #1 }, + cmpd-delim .default:n = { ( } { ) } , + cmpd-odelim .tl_set:N = \l_chemnum_cmpd_odelim_tl , + cmpd-odelim .default:n = { } , + cmpd-cdelim .tl_set:N = \l_chemnum_cmpd_cdelim_tl , + cmpd-cdelim .default:n = { } , + cmpd-all .bool_set:N = \l_chemnum_cmpd_all_bool , + cmpd-all .default:n = true , + cmpd-counter .choice: , + cmpd-counter .choice_code:n = \tl_set_eq:NN \l_chemnum_cmpd_kind_value_tl \l_keys_choice_tl , - cmpd-counter .generate_choices:n = + cmpd-counter .generate_choices:n = { arabic , alph , Alph , greek, Greek , roman , Roman , Symbol } , - cmpd-counter .default:n = arabic , - sub-counter .choice: , - sub-counter .choice_code:n = + cmpd-counter .default:n = arabic , + hyper-use .choice: , + hyper-use / true .code:n = + { + \bool_set_true:N \l_chemnum_use_hyperref_bool + \bool_set_false:N \l_chemnum_hypertarget_bool + \bool_set_false:N \l_chemnum_hyperlink_bool + } , + hyper-use / false .code:n = + { + \bool_set_false:N \l_chemnum_use_hyperref_bool + \bool_set_false:N \l_chemnum_hypertarget_bool + \bool_set_false:N \l_chemnum_hyperlink_bool + } , + hyper-use .default:n = true , + hyper-target .code:n = + { + \tl_set:Nn \l_chemnum_cmpd_hyper_name_tl { #1 } + \bool_set_true:N \l_chemnum_use_hyperref_bool + \bool_set_true:N \l_chemnum_hypertarget_bool + \bool_set_false:N \l_chemnum_hyperlink_bool + } , + hyper-link .code:n = + { + \tl_set:Nn \l_chemnum_cmpd_hyper_name_tl { #1 } + \bool_set_true:N \l_chemnum_use_hyperref_bool + \bool_set_false:N \l_chemnum_hypertarget_bool + \bool_set_true:N \l_chemnum_hyperlink_bool + } , + sub-counter .choice: , + sub-counter .choice_code:n = \tl_set_eq:NN \l_chemnum_cmpd_sub_kind_value_tl \l_keys_choice_tl , - sub-counter .generate_choices:n = + sub-counter .generate_choices:n = { arabic , alph , Alph , greek , Greek , roman , Roman , Symbol } , - sub-counter .default:n = alph , - sub-marker .code:n = \chemnum_subcmpdsep:n { #1 } , - sub-marker .default:n = . , - sub-range-marker .code:n = + sub-counter .default:n = alph , + sub-input-sep .code:n = \chemnum_subcmpdsep:n { #1 } , + sub-input-sep .default:n = . , + sub-output-sep .tl_set:N = \l_chemnum_cmpd_separator_tl , + sub-output-sep .default:n = { } , + sublist-input-sep .tl_set:N = + \l_chemnum_sublist_input_separator_tl , + sublist-input-sep .default:n = { , } , + sublist-output-sep .tl_set:N = + \l_chemnum_sublist_output_separator_tl , + sublist-output-sep .default:n = { , } , + sub-only .bool_set:N = \l_chemnum_sub_label_only_bool , + sub-only .default:n = true , + subrange-output-sep .tl_set:N = \l_chemnum_sub_range_sep_tl , + subrange-output-sep .default:n = { -- } , + subrange-input-sep .code:n = \chemnum_sublabel_range_marker:n { #1 } , - sub-range-marker .default:n = { .. } , - sub-range-sep .tl_set:N = \l_chemnum_sub_range_sep_tl , - sub-range-sep .default:n = { -- } , - sub-list .code:n = - { - \tl_set:Nn \l_chemnum_cmpd_sublabel_list_tl { #1 } - \bool_set_true:N \l_chemnum_sublabel_list_bool - } , - sub-only .bool_set:N = \l_chemnum_sub_label_only_bool , - sub-only .default:n = true + subrange-input-sep .default:n = { .. } } %-----------------------------------------------------------------------------% @@ -611,8 +727,8 @@ \bool_new:N \l_chemnum_no_serial_comma_bool \bool_set_false:N \l_chemnum_no_serial_comma_bool -\tl_new:N \l_chemnum_input_separator_tl -\tl_set:Nn \l_chemnum_input_separator_tl { , } +\tl_new:N \l_chemnum_list_input_separator_tl +\tl_set:Nn \l_chemnum_list_input_separator_tl { , } \tl_new:N \l_chemnum_list_separator_tl \tl_set:Nn \l_chemnum_list_separator_tl { , } @@ -656,14 +772,14 @@ list-suffix .tl_set:N = \l_chemnum_list_suffix_tl , list-suffix .default:n = { } , list-delim .code:n = \chemnum_list_delim:n { #1 } , - list-delim .default:n = {(}{)} , + list-delim .default:n = { ( } { ) } , list-odelim .tl_set:N = \l_chemnum_list_odelim_tl , list-odelim .default:n = { } , list-cdelim .tl_set:N = \l_chemnum_list_cdelim_tl , list-cdelim .default:n = { } , list-space .tl_set:N = \l_chemnum_list_space_tl , list-space .default:n = { \penalty\@m\ } , - list-input-sep .tl_set:N = \l_chemnum_input_separator_tl , + list-input-sep .tl_set:N = \l_chemnum_list_input_separator_tl , list-input-sep .default:n = { , } , list-output-sep .tl_set:N = \l_chemnum_list_separator_tl , list-output-sep .default:n = { , } , @@ -754,6 +870,23 @@ \cs_gset_eq:cc { chemnum_cmpd_#1_max: } { chemnum_cmpd_#1_#2: } } } +\cs_generate_variant:Nn \chemnum_cmpd_sub_declare:nn { no } + +\cs_new_nopar:Npn \chemnum_cmpd_sub_initiate:nn #1#2 + { + \cs_if_exist:cF { chemnum_cmpd_ #1 _ #2 _init: } + { + \bool_if:NTF \l_chemnum_cmpd_init_strict_bool + { + \msg_error:nnx { chemnum } { cmpd-init-sub } + { #1 \l_chemnum_cmpd_labelsep_tl #2 } + } + { + \msg_warning:nnx { chemnum } { cmpd-init-sub } + { #1 \l_chemnum_cmpd_labelsep_tl #2 } + } + } + } %-----------------------------------------------------------------------------% % label and sublabel initiation @@ -765,17 +898,13 @@ { \tl_if_blank:nF { #2 } { - \cs_if_exist:cF { chemnum_cmpd_ #1 _ #2 _init: } + \chemnum_cmpd_sublist:n { #2 } + \exp_args:No \tl_map_inline:nn { \l_chemnum_cmpd_sublist_tl } { - \bool_if:NTF \l_chemnum_cmpd_init_strict_bool - { - \msg_error:nnx { chemnum } { cmpd-sub-init } - { #1 \l_chemnum_cmpd_labelsep_tl #2 } - } - { - \msg_warning:nnx { chemnum } { cmpd-sub-init } - { #1 \l_chemnum_cmpd_labelsep_tl #2 } - } + \chemnum_cmpd_subrange_separate:n { ##1 } + \chemnum_cmpd_sub_initiate:nn { #1 } { \l_tmpa_tl } + \tl_if_blank:VF \l_tmpb_tl + { \chemnum_cmpd_sub_initiate:nn { #1 } { \l_tmpb_tl } } } } } @@ -809,13 +938,20 @@ \tl_new:N \l_chemnum_labelsep_tmp_tl -% actual separating +% set sublabel-separator \cs_new_nopar:Npn \chemnum_subcmpdsep:n #1 { \tl_if_blank:nTF { #1 } { \msg_error:nn { chemnum } { sub-label-separator } } { \tl_set:Nn \l_chemnum_cmpd_labelsep_tl { #1 } } } +\cs_new_nopar:Npn \chemnum_sublabel_range_marker:n #1 { + \tl_if_blank:nTF { #1 } + { \msg_error:nn { chemnum } { sub-label-range_sep } } + { \tl_set:Nn \l_chemnum_sublabel_range_marker_tl { #1 } } +} + +% actual separating \cs_new_nopar:Npn \chemnum_cmpd_labelsep:n #1 \q_stop { \tl_clear:N \l_chemnum_labelsep_tmp_tl \exp_args:Noo \tl_if_in:nnTF { #1 } { \l_chemnum_cmpd_labelsep_tl } @@ -842,39 +978,39 @@ \tl_set:Nn \l_chemnum_cmpd_sub_label_tl { #2 } } -% sublabel separating to display a range -\cs_new_nopar:Npn \chemnum_sublabel_range_marker:n #1 { - \tl_if_blank:nTF { #1 } - { \msg_error:nn { chemnum } { sub-label-range_sep } } - { \tl_set:Nn \l_chemnum_sublabel_range_marker_tl { #1 } } -} +% sublabel separating to display a list and/or range +\tl_new:N \l_chemnum_cmpd_sublist_tl +\int_new:N \l_chemnum_cmpd_sublist_length_int -\cs_new_nopar:Npn \chemnum_cmpd_sublabelsep:n #1 \q_stop { - \tl_clear:N \l_chemnum_sublabelsep_tmp_tl - \exp_args:Noo \tl_if_in:nnTF { #1 } { \l_chemnum_sublabel_range_marker_tl } - { - \tl_set:Nn \l_chemnum_sublabelsep_tmp_tl { #1 } - \exp_args:NNo \tl_replace_once:Nnn \l_chemnum_sublabelsep_tmp_tl - { \l_chemnum_sublabel_range_marker_tl } - { \q_nil } - \exp_after:wN \chemnum_cmpd_sublabelsep_aux_ii:n - \l_chemnum_sublabelsep_tmp_tl \q_stop - } - { \chemnum_cmpd_sublabelsep_aux_i:n { #1 } } -} - -\cs_new_nopar:Npn \chemnum_cmpd_sublabelsep_aux_i:n #1 { - \tl_set:Nn \l_chemnum_cmpd_sub_one_label_tl { #1 } - \tl_clear:N \l_chemnum_cmpd_sub_two_label_tl -} +\NewDocumentCommand \chemnum_cmpd_sublist:n + { > { \exp_args:No \SplitList { \l_chemnum_sublist_input_separator_tl } } m } + { + \tl_set:Nn \l_chemnum_cmpd_sublist_tl { #1 } + \int_zero:N \l_chemnum_cmpd_sublist_length_int + \exp_args:No \tl_map_inline:nn { \l_chemnum_cmpd_sublist_tl } + { \int_incr:N \l_chemnum_cmpd_sublist_length_int } + } -\cs_new_nopar:Npn \chemnum_cmpd_sublabelsep_aux_ii:n #1 \q_nil #2 \q_stop { - \tl_set:Nn \l_chemnum_cmpd_sub_one_label_tl { #1 } - \tl_set:Nn \l_chemnum_cmpd_sub_two_label_tl { #2 } -} +\cs_new_nopar:Npn \chemnum_cmpd_subrange_separate:n #1 + { + \tl_clear:N \l_tmpa_tl + \tl_clear:N \l_tmpb_tl + \tl_if_in:noTF { #1 } { \l_chemnum_sublabel_range_marker_tl } + { + \tl_set:Nn \l_tmpa_tl { #1 } + \exp_args:NNo \tl_replace_once:Nnn \l_tmpa_tl + { \l_chemnum_sublabel_range_marker_tl } { \q_nil } + \exp_after:wN \chemnum_cmpd_subrange_separate_aux:n \l_tmpa_tl \q_stop + } + { \tl_set:Nn \l_tmpa_tl { #1 } } + } -\cs_if_exist:NF \cs_if_eq:ccF - { \cs_generate_variant:Nn \cs_if_eq:NNF { ccF } } +\cs_new_nopar:Npn \chemnum_cmpd_subrange_separate_aux:n + #1 \q_nil #2 \q_stop + { + \tl_set:Nn \l_tmpa_tl { #1 } + \tl_set:Nn \l_tmpb_tl { #2 } + } %-----------------------------------------------------------------------------% % print compound label @@ -896,20 +1032,31 @@ } %-----------------------------------------------------------------------------% -% main internal compound label command +% main internal compound label command % #1: <main label> #2: <sub label> #3: <invisible> #4: <no delim> +% #2 may be a list of sublabels \cs_new_nopar:Npn \chemnum_cmpd_aux_i:nnnn #1#2#3#4 { \bool_if:NT \l_chemnum_cmpd_initiated_bool { \chemnum_cmpd_initiate:nn { #1 } { #2 } } \bool_if:NF \l_chemnum_cmpd_ref_bool { \chemnum_cmpd_declare:n { #1 } } + \chemnum_hyperref:nnn { #1 } { #2 } { #3 } \tl_if_blank:nF { #2 } { \cs_if_exist:cF { g_chemnum_cmpd_#1_int } { \int_new:c { g_chemnum_cmpd_#1_int } } + \chemnum_cmpd_sublist:n { #2 } \bool_if:NF \l_chemnum_cmpd_ref_bool - { \chemnum_cmpd_sub_declare:nn { #1 } { #2 } } + { + \exp_args:No \tl_map_inline:nn { \l_chemnum_cmpd_sublist_tl } + { + \chemnum_cmpd_subrange_separate:n { ##1 } + \chemnum_cmpd_sub_declare:no { #1 } { \l_tmpa_tl } + \tl_if_blank:VF \l_tmpb_tl + { \chemnum_cmpd_sub_declare:no { #1 } { \l_tmpb_tl } } + } + } } \bool_if:NTF #3 { \mode_if_horizontal:T { \tex_unskip:D } } @@ -919,6 +1066,8 @@ \tl_clear:N \l_chemnum_cmpd_odelim_tl \tl_clear:N \l_chemnum_cmpd_cdelim_tl } + \chemnum_make_hyper:nn { \l_chemnum_cmpd_hyper_name_tl } + { \chemnum_cmpd_print:n { \bool_if:NF \l_chemnum_sub_label_only_bool @@ -949,13 +1098,30 @@ \tl_if_blank:nF { #2 } { \tl_use:N \l_chemnum_cmpd_separator_tl - \bool_if:NTF \l_chemnum_cmpd_ref_bool - { \use:c { chemnum_cmpd_ #1 _ #2 _ref: } } - { \use:c { chemnum_cmpd_ #1 _ #2 : } } + \int_zero:N \l_tmpa_int + \exp_args:No \tl_map_inline:nn + { \l_chemnum_cmpd_sublist_tl } + { + \int_incr:N \l_tmpa_int + \chemnum_cmpd_subrange_separate:n { ##1 } + \bool_if:NTF \l_chemnum_cmpd_ref_bool + { \use:c { chemnum_cmpd_ #1 _ \l_tmpa_tl _ref: } } + { \use:c { chemnum_cmpd_ #1 _ \l_tmpa_tl : } } + \tl_if_blank:VF \l_tmpb_tl + { + \tl_use:N \l_chemnum_sub_range_sep_tl + \bool_if:NTF \l_chemnum_cmpd_ref_bool + { \use:c { chemnum_cmpd_ #1 _ \l_tmpb_tl _ref: } } + { \use:c { chemnum_cmpd_ #1 _ \l_tmpb_tl : } } + } + \int_compare:nF + { \l_tmpa_int = \l_chemnum_cmpd_sublist_length_int } + { \l_chemnum_sublist_output_separator_tl } + } } } } - } + } } } } @@ -969,6 +1135,7 @@ \tl_clear:N \l_chemnum_cmpd_main_label_tl \tl_clear:N \l_chemnum_cmpd_sub_label_tl \chemnum_cmpd_labelsep:n #1 \q_stop + \tl_remove_all:Nn \l_chemnum_cmpd_sub_label_tl { ~ } \chemnum_cmpd_aux_i:oonn { \l_chemnum_cmpd_main_label_tl } { \l_chemnum_cmpd_sub_label_tl } @@ -1006,10 +1173,10 @@ % \cmpd*+-[<key-value-list>]{<(possibly comma separated list of) compound % label(s)>} \NewDocumentCommand \chemnum_input_separator:n - { > { \exp_args:No \SplitList { \l_chemnum_input_separator_tl } } m } + { > { \exp_args:No \SplitList { \l_chemnum_list_input_separator_tl } } m } { \tl_set:Nn \l_tmpa_tl { #1 } } -\NewDocumentCommand \cmpd { s t+ t- o m } +\NewDocumentCommand \cmpd_main_command:w { s t+ t- o m } { \IfBooleanT #2 { @@ -1120,21 +1287,27 @@ \bool_set_false:N \l_chemnum_cmpd_ref_bool } +\cs_set_eq:NN \cmpd \cmpd_main_command:w + %-----------------------------------------------------------------------------% % INITIALISING LABELS \bool_new:N \l_chemnum_cmpd_initiated_bool \bool_new:N \l_chemnum_cmpd_init_strict_bool \bool_new:N \l_chemnum_cmpd_sub_init_bool \bool_new:N \l_chemnum_cmpd_init_declare_bool -\clist_new:N \l_chemnum_cmpd_init_clist + +\tl_new:N \l_chemnum_cmpd_init_separator_tl +\tl_set:Nn \l_chemnum_cmpd_init_separator_tl { , } % property keys for \cmpdinit command % strict=true will produce an error instead of a warning -\keys_define:nn { chemnum / init } { - strict .bool_set:N = \l_chemnum_cmpd_init_strict_bool , - strict .default:n = true , - sub-init .bool_set:N = \l_chemnum_cmpd_sub_init_bool , - sub-init .default:n = true +\keys_define:nn { chemnum } { + init-strict .bool_set:N = \l_chemnum_cmpd_init_strict_bool , + init-strict .default:n = true , + init-sub .bool_set:N = \l_chemnum_cmpd_sub_init_bool , + init-sub .default:n = true , + init-input-sep .tl_set:N = \l_chemnum_cmpd_init_separator_tl , + init-input-sep .default:n = { , } } % warning/error messages @@ -1144,9 +1317,9 @@ compound~"#1"~\msg_line_context: . } -\msg_set:nnn { chemnum } { cmpd-sub-init } +\msg_set:nnn { chemnum } { cmpd-init-sub } { - You~used~\token_to_str:N \cmpdinit \c_space_tl and~"sub-init~=~true"~ + You~used~\token_to_str:N \cmpdinit \c_space_tl and~"init-sub~=~true"~ but~didn't~initiate~sub-compound~"#1"~\msg_line_context: . } @@ -1169,24 +1342,28 @@ { \tl_if_blank:VF \l_chemnum_cmpd_sub_label_tl { - \cs_if_exist:cF + \exp_args:No \chemnum_cmpd_sublist:n { \l_chemnum_cmpd_sub_label_tl } + \exp_args:No \tl_map_inline:nn { \l_chemnum_cmpd_sublist_tl } { - chemnum_cmpd_ - \l_chemnum_cmpd_main_label_tl - _ - \l_chemnum_cmpd_sub_label_tl - _init: - } - { - \cs_new_nopar:cpn + \cs_if_exist:cF { - chemnum_cmpd_ + chemnum_cmpd_ \l_chemnum_cmpd_main_label_tl _ - \l_chemnum_cmpd_sub_label_tl + ##1 _init: } - { } + { + \cs_new_nopar:cpn + { + chemnum_cmpd_ + \l_chemnum_cmpd_main_label_tl + _ + ##1 + _init: + } + { } + } } } } @@ -1207,7 +1384,7 @@ \IfBooleanTF #1 { \bool_set_false:N \l_chemnum_cmpd_init_declare_bool } { \bool_set_true:N \l_chemnum_cmpd_init_declare_bool } - \IfNoValueF { #2 } { \keys_set:nn { chemnum / init } { #2 } } + \IfNoValueF { #2 } { \keys_set:nn { chemnum } { #2 } } \chemnum_input_separator:n { #3 } \tl_map_function:NN \l_tmpa_tl \chemnum_cmpd_init:n } @@ -1233,20 +1410,27 @@ % works similar to \schemeref command of the chemscheme package % \cmpdref-[<keyval>][<tag>]{<label name>} \tl_new:N \l_chemnum_cmpdref_tl -\int_new:N \l_chemnum_cmpdref_int + +\tl_new:N \l_chemnum_cmpdref_style_tl +\tl_set:Nn \l_chemnum_cmpdref_style_tl { \sffamily } + \tl_new:N \l_chemnum_cmpdref_marker_tl \tl_set:Nn \l_chemnum_cmpdref_marker_tl { TMP } +\int_new:N \l_chemnum_cmpdref_int + \keys_define:nn { chemnum } { - ref-tag .tl_set:N = \l_chemnum_cmpdref_marker_tl , - ref-tag .default:n = { TMP } + ref-tag .tl_set:N = \l_chemnum_cmpdref_marker_tl , + ref-tag .default:n = { TMP } , + ref-style .tl_set:N = \l_chemnum_cmpdref_style_tl , + ref-style .default:n = { } , } \NewDocumentCommand \cmpdref { t- o o m } { \IfBooleanT { #1 } - { \cmpdsetup { cmpd-delim = } } + { \keys_set:nn { chemnum } { cmpd-delim = } } \IfNoValueTF { #3 } { \int_incr:N \l_chemnum_cmpdref_int @@ -1261,10 +1445,24 @@ } \IfNoValueTF { #2 } { - \psfrag { \l_chemnum_cmpdref_tl } [ b ] [ b ] { \cmpd { #4 } } + \psfrag { \l_chemnum_cmpdref_tl } [ b ] [ b ] + { + \group_begin: + \keys_set:nn { chemnum } + { cmpd-style = \l_chemnum_cmpdref_style_tl } + \cmpd_main_command:w { #4 } + \group_end: + } } { - \psfrag { \l_chemnum_cmpdref_tl } [ b ] [ b ] { \cmpd [ #2 ] { #4 } } + \psfrag { \l_chemnum_cmpdref_tl } [ b ] [ b ] + { + \group_begin: + \keys_set:nn { chemnum } + { cmpd-style = \l_chemnum_cmpdref_style_tl } + \cmpd_main_command:w [ #2 ] { #4 } + \group_end: + } } } @@ -1334,7 +1532,7 @@ HISTORY: - choices "greek" and "Greek" for the cmpd-counter keys, choice "symbol" changed to "Symbol" - package option "textgreek = <value>" to control - usage of the textgreek package + usage of the `textgreek' package - former \cmpd+ is now \cmpd- - new \cmpd+ added which reads label from <jobname>.cmpd @@ -1362,10 +1560,10 @@ HISTORY: http://www.arkat-usa.org/get-file/29257/ or scheme 4 at http://www.arkat-usa.org/get-file/27301/ for reasons, why - 2011/11/08 version 0.3c - localization via babel is now supported with the - help of the translator package + 2011/11/08 version 0.3c - localization via `babel' is now supported with the + help of the `translator' package - key "list-serial-comma" added - 2011/12/01 version 0.3d - greek letters without textgreek package + 2011/12/01 version 0.3d - greek letters without `textgreek' package - new key cmpd-weight = bold/normal - bugfix: sublabels are now possible, when main label name contains a colon @@ -1373,12 +1571,29 @@ HISTORY: separator; this means the comma may be part of the label name 2011/12/01 version 0.3e - bugfix: labels have been saved in a wrong way, when - list-input-sep had been changed. this is fixed + "list-input-sep" had been changed. this is fixed + 2011/12/09 version 0.4 - new input of sublabel lists and ranges + - new key: "sublist-input-sep" + - new key: "sublist-output-sep" + - new key: "init-input-sep" + - "sub-marker" => "sub-input-sep" + - "cmpd-sep" => "sub-output-sep" + - "sub-range-sep" => "subrange-output-sep" + - "sub-range-marker" => "subrange-input-sep" + - "strict" => "init-strict" + - "sub-init" => "init-sub" + - key removed: "sub-list" + - it is now possible, to mark the labels with + \hypertarget and \hyperlink if `hyperref' is loaded + - new key: "hyper-use" + - new key: "hyper-target" + - new key: "hyper-link" + - new key: "ref-style" + - documentation got an index %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % TODO: - - natürliche Unterstützung für hyperref + - (rudimentäre) Unterstützung für hyperref und pdfstrings - polyglossia: localization of us-variant of english - - alphabetische Sortierung für sub-list - Bug: Key "cmpd-style" wenn zB \color{<farbe>} eingegeben: Fehler beim Test auf Makro; Test entfernen? - \cmpdref: Reihenfolge der optionalen Argumente vertauschen?
\ No newline at end of file |