diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemnum/chemnum.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemnum/chemnum.sty | 465 |
1 files changed, 246 insertions, 219 deletions
diff --git a/Master/texmf-dist/tex/latex/chemnum/chemnum.sty b/Master/texmf-dist/tex/latex/chemnum/chemnum.sty index 39578d42ec5..608c9142bf9 100644 --- a/Master/texmf-dist/tex/latex/chemnum/chemnum.sty +++ b/Master/texmf-dist/tex/latex/chemnum/chemnum.sty @@ -1,6 +1,6 @@ % ---------------------------------------------------------------------------- -\def\chemnumdate{2014/03/12} -\def\chemnumversion{1.0} +\def\chemnumdate{2014/06/02} +\def\chemnumversion{1.0b} \def\chemnuminfo{a comprehensive approach for the numbering of chemical compounds} \RequirePackage{expl3}[2013/07/14] @@ -35,7 +35,7 @@ \msg_new:nnn {chemnum} {unknown-counter-format} { - I~ do~ not~ know~ the~ counter~ format~ `#1'.~ I'll~ use~ `arabic'~ + I~ do~ not~ know~ the~ counter~ format~ `#1'.~ I'll~ use~ `arabic'~ instead~ \msg_line_context: } @@ -70,27 +70,27 @@ . \c_space_tl \c_space_tl \c_space_tl label ~=~ \chemnum_expandable_get_compound_property:nn {#1} - {counter-representation} \\ + {counter-representation} \\ . \c_space_tl \c_space_tl \c_space_tl pre~ label~ code ~=~ \chemnum_expandable_get_compound_property:nn {#1} - {pre-label-code} \\ + {pre-label-code} \\ . \c_space_tl \c_space_tl \c_space_tl post~ label~ code ~=~ \chemnum_expandable_get_compound_property:nn {#1} - {post-label-code} \\ + {post-label-code} \\ . \c_space_tl \c_space_tl \c_space_tl pre~ main~ label~ code ~=~ \chemnum_expandable_get_compound_property:nn {#1} - {pre-main-label-code} \\ + {pre-main-label-code} \\ . \c_space_tl \c_space_tl \c_space_tl post~ main~ label~ code ~=~ \chemnum_expandable_get_compound_property:nn {#1} - {post-main-label-code} \\ + {post-main-label-code} \\ . \c_space_tl \c_space_tl \c_space_tl format ~=~ \chemnum_expandable_get_compound_property:nn {#1} - {label-format} \\ + {label-format} \\ ................................................. } @@ -121,7 +121,7 @@ . \c_space_tl \c_space_tl \c_space_tl label ~=~ \chemnum_expandable_get_subcompound_property:nnn {#1} {#2} - {counter-representation} \\ + {counter-representation} \\ ................................................. } @@ -134,8 +134,8 @@ % ---------------------------------------------------------------------------- % deprecated command names: -% #1: old name -% #2: new name +% #1: old name +% #2: new name \cs_new_protected:Npn \chemnum_deprecated_command:NN #1#2 { \cs_new:Npn #1 @@ -148,15 +148,15 @@ % ---------------------------------------------------------------------------- % variants of kernel functions: -\cs_generate_variant:Nn \prop_gput:Nnn { Nnx , cnx , cnV } -\cs_generate_variant:Nn \prop_put:Nnn { NV , NVV , NVx } -\cs_generate_variant:Nn \prop_if_in:NnTF { NV } +\cs_generate_variant:Nn \prop_gput:Nnn { Nnx , cnx , cnV } +\cs_generate_variant:Nn \prop_put:Nnn { NV , NVV , NVx } +\cs_generate_variant:Nn \prop_if_in:NnTF { NV } \cs_generate_variant:Nn \quark_if_no_value:nTF { V } -\cs_generate_variant:Nn \quark_if_no_value:nF { V } -\cs_generate_variant:Nn \seq_set_split:Nnn { NV , NVV } -\cs_generate_variant:Nn \seq_use:Nnnn { NVVV } -\cs_generate_variant:Nn \tl_if_eq:nnF { Vx } -\cs_generate_variant:Nn \tl_if_in:nnTF { VV } +\cs_generate_variant:Nn \quark_if_no_value:nF { V } +\cs_generate_variant:Nn \seq_set_split:Nnn { NV , NVV } +\cs_generate_variant:Nn \seq_use:Nnnn { NVVV } +\cs_generate_variant:Nn \tl_if_eq:nnF { Vx } +\cs_generate_variant:Nn \tl_if_in:nnTF { VV } % ---------------------------------------------------------------------------- % temporary variables: @@ -188,55 +188,56 @@ \seq_new:N \g__chemnum_initiated_compounds_seq \seq_new:N \g__chemnum_defined_compounds_seq +\seq_new:N \g__chemnum_compound_defined_subcompounds_seq -\tl_new:N \l__chemnum_label_format_tl -\tl_set:Nn \l__chemnum_label_format_tl {\bfseries} -\tl_new:N \l__chemnum_local_label_format_tl +\tl_new:N \l__chemnum_label_format_tl +\tl_set:Nn \l__chemnum_label_format_tl {\bfseries} +\tl_new:N \l__chemnum_local_label_format_tl \tl_set_eq:NN \l__chemnum_local_label_format_tl \l__chemnum_label_format_tl -\tl_new:N \l__chemnum_default_counter_representation_tl -\tl_set:Nn \l__chemnum_default_counter_representation_tl {arabic} -\tl_new:N \l__chemnum_default_subcounter_representation_tl -\tl_set:Nn \l__chemnum_default_subcounter_representation_tl {alph} -\tl_new:N \l__chemnum_pre_counter_default_tl -\tl_new:N \l__chemnum_post_counter_default_tl -\tl_new:N \l__chemnum_pre_label_default_tl -\tl_new:N \l__chemnum_post_label_default_tl -\tl_new:N \l__chemnum_pre_main_label_default_tl -\tl_new:N \l__chemnum_post_main_label_default_tl -\tl_new:N \l__chemnum_main_separator_tl -\tl_set:Nn \l__chemnum_main_separator_tl {,} -\tl_new:N \l__chemnum_sub_separator_tl -\tl_set:Nn \l__chemnum_sub_separator_tl {,} -\tl_new:N \l__chemnum_compound_separator_tl -\tl_set:Nn \l__chemnum_compound_separator_tl {.} - -\tl_new:N \l__chemnum_sep_list_two_tl +\tl_new:N \l__chemnum_default_counter_representation_tl +\tl_set:Nn \l__chemnum_default_counter_representation_tl {arabic} +\tl_new:N \l__chemnum_default_subcounter_representation_tl +\tl_set:Nn \l__chemnum_default_subcounter_representation_tl {alph} +\tl_new:N \l__chemnum_pre_counter_default_tl +\tl_new:N \l__chemnum_post_counter_default_tl +\tl_new:N \l__chemnum_pre_label_default_tl +\tl_new:N \l__chemnum_post_label_default_tl +\tl_new:N \l__chemnum_pre_main_label_default_tl +\tl_new:N \l__chemnum_post_main_label_default_tl +\tl_new:N \l__chemnum_main_separator_tl +\tl_set:Nn \l__chemnum_main_separator_tl {,} +\tl_new:N \l__chemnum_sub_separator_tl +\tl_set:Nn \l__chemnum_sub_separator_tl {,} +\tl_new:N \l__chemnum_compound_separator_tl +\tl_set:Nn \l__chemnum_compound_separator_tl {.} + +\tl_new:N \l__chemnum_sep_list_two_tl \tl_set:Nn \l__chemnum_sep_list_two_tl { \GetTranslation {chemnum-sep-two} } -\tl_new:N \l__chemnum_sep_list_more_tl +\tl_new:N \l__chemnum_sep_list_more_tl \tl_set:Nn \l__chemnum_sep_list_more_tl {,~} -\tl_new:N \l__chemnum_sep_list_last_two_tl +\tl_new:N \l__chemnum_sep_list_last_two_tl \tl_set:Nn \l__chemnum_sep_list_last_two_tl { \GetTranslation {chemnum-sep-last-two} } -\tl_new:N \l__chemnum_sep_sublist_two_tl +\tl_new:N \l__chemnum_sep_sublist_two_tl \tl_set:Nn \l__chemnum_sep_sublist_two_tl {,} -\tl_new:N \l__chemnum_sep_sublist_more_tl +\tl_new:N \l__chemnum_sep_sublist_more_tl \tl_set:Nn \l__chemnum_sep_sublist_more_tl {,} -\tl_new:N \l__chemnum_sep_sublist_last_two_tl +\tl_new:N \l__chemnum_sep_sublist_last_two_tl \tl_set:Nn \l__chemnum_sep_sublist_last_two_tl {,} -\tl_new:N \l__chemnum_sep_sublist_range_tl +\tl_new:N \l__chemnum_sep_sublist_range_tl \tl_set:Nn \l__chemnum_sep_sublist_range_tl {--} -\tl_new:N \l__chemnum_compound_replace_tl -\tl_new:N \l__chemnum_compound_replace_format_tl -\tl_new:N \l__chemnum_compound_replace_local_format_tl +\tl_new:N \l__chemnum_compound_replace_tl +\tl_new:N \l__chemnum_compound_replace_format_tl +\tl_new:N \l__chemnum_compound_replace_local_format_tl \tl_set:Nn \l__chemnum_compound_replace_format_tl { \sffamily } -\tl_new:N \l__chemnum_compound_replace_tag_tl +\tl_new:N \l__chemnum_compound_replace_tag_tl \tl_set:Nn \l__chemnum_compound_replace_tag_tl { TMP } -\tl_new:N \l__chemnum_psfrag_texpos_tl -\tl_new:N \l__chemnum_psfrag_local_texpos_tl +\tl_new:N \l__chemnum_psfrag_texpos_tl +\tl_new:N \l__chemnum_psfrag_local_texpos_tl \tl_set:Nn \l__chemnum_psfrag_texpos_tl { b } -\tl_new:N \l__chemnum_psfrag_pspos_tl -\tl_new:N \l__chemnum_psfrag_local_pspos_tl +\tl_new:N \l__chemnum_psfrag_pspos_tl +\tl_new:N \l__chemnum_psfrag_local_pspos_tl \tl_set:Nn \l__chemnum_psfrag_pspos_tl { b } \bool_new:N \l__chemnum_compound_local_bool @@ -278,8 +279,8 @@ { \chemnum_add_label_format:nn {#1} {#2} } \newcmpdcounterformat {arabic} { \int_to_arabic:n } -\newcmpdcounterformat {alph } { \int_to_alph:n } -\newcmpdcounterformat {Alph } { \int_to_Alph:n } +\newcmpdcounterformat {alph } { \int_to_alph:n } +\newcmpdcounterformat {Alph } { \int_to_Alph:n } \newcmpdcounterformat {roman } { \int_to_roman:n } \newcmpdcounterformat {Roman } { \int_to_Roman:n } \newcmpdcounterformat {greek } { \chemgreek_int_to_greek:n } @@ -293,12 +294,12 @@ % they're also assigned to the `compound' group. \keys_define:nn {chemnum} { - local .bool_set:N = \l__chemnum_compound_local_bool , - local .groups:n = {compound} , + local .bool_set:N = \l__chemnum_compound_local_bool , + local .groups:n = {compound} , % counter: - counter-within .code:n = \@addtoreset{cmpdmain}{#1} , - counter-within .groups:n = {general} , - counter-format .code:n = + counter-within .code:n = \@addtoreset{cmpdmain}{#1} , + counter-within .groups:n = {general} , + counter-format .code:n = \prop_if_in:NnTF \l__chemnum_label_formats_prop {#1} { \tl_set:Nn @@ -311,8 +312,8 @@ \l__chemnum_default_counter_representation_tl {arabic} } , - counter-format .groups:n = {compound,general} , - sub-counter-format .code:n = + counter-format .groups:n = {compound,general} , + sub-counter-format .code:n = \prop_if_in:NnTF \l__chemnum_label_formats_prop {#1} { \tl_set:Nn @@ -325,128 +326,128 @@ \l__chemnum_default_subcounter_representation_tl {arabic} } , - sub-counter-format .groups:n = {compound,general} , + sub-counter-format .groups:n = {compound,general} , % label: - pre-label-code .tl_set:N = \l__chemnum_pre_label_default_tl , - pre-label-code .groups:n = {compound} , - post-label-code .tl_set:N = \l__chemnum_post_label_default_tl , - post-label-code .groups:n = {compound} , - pre-main-label-code .tl_set:N = \l__chemnum_pre_main_label_default_tl , - pre-main-label-code .groups:n = {compound} , - post-main-label-code .tl_set:N = \l__chemnum_post_main_label_default_tl , - post-main-label-code .groups:n = {compound} , - main-sub-sep .tl_set:N = \l__chemnum_compound_separator_tl , - main-sub-sep .groups:n = {general,list} , - list-label-sep .tl_set:N = \l__chemnum_main_separator_tl , - list-label-sep .groups:n = {general,list} , - sub-list-label-sep .tl_set:N = \l__chemnum_sub_separator_tl , - sub-list-label-sep .groups:n = {general,list} , - format .code:n = + pre-label-code .tl_set:N = \l__chemnum_pre_label_default_tl , + pre-label-code .groups:n = {compound} , + post-label-code .tl_set:N = \l__chemnum_post_label_default_tl , + post-label-code .groups:n = {compound} , + pre-main-label-code .tl_set:N = \l__chemnum_pre_main_label_default_tl , + pre-main-label-code .groups:n = {compound} , + post-main-label-code .tl_set:N = \l__chemnum_post_main_label_default_tl , + post-main-label-code .groups:n = {compound} , + main-sub-sep .tl_set:N = \l__chemnum_compound_separator_tl , + main-sub-sep .groups:n = {general,list} , + list-label-sep .tl_set:N = \l__chemnum_main_separator_tl , + list-label-sep .groups:n = {general,list} , + sub-list-label-sep .tl_set:N = \l__chemnum_sub_separator_tl , + sub-list-label-sep .groups:n = {general,list} , + format .code:n = \tl_set:Nn \l__chemnum_local_label_format_tl {#1} \bool_if:NF \l__chemnum_compound_local_bool { \tl_set:Nn \l__chemnum_label_format_tl {#1} } , - format .groups:n = {compound,general} , - sub-only .bool_set:N = \l__chemnum_sub_only_bool , - sub-only .groups:n = {compound,sub-only} , - sub-all .bool_set:N = \l__chemnum_sub_all_bool , - sub-all .groups:n = {compound} , - compress .bool_set:N = + format .groups:n = {compound,general} , + sub-only .bool_set:N = \l__chemnum_sub_only_bool , + sub-only .groups:n = {compound,sub-only} , + sub-all .bool_set:N = \l__chemnum_sub_all_bool , + sub-all .groups:n = {compound} , + compress .bool_set:N = \l__chemnum_compress_subcompounds_bool , - compress .groups:n = {compound,general} , - merge .bool_set:N = + compress .groups:n = {compound,general} , + merge .bool_set:N = \l__chemnum_merge_list_bool , - merge .groups:n = {general,list} , + merge .groups:n = {general,list} , % initiation: - init .choice: , - init / true .code:n = + init .choice: , + init / true .code:n = \bool_set_true:N \g__chemnum_initiate_bool \bool_set_true:N \g__chemnum_initiate_sub_bool \bool_set_false:N \g__chemnum_initiate_strict_bool , - init / main .code:n = + init / main .code:n = \bool_set_true:N \g__chemnum_initiate_bool \bool_set_false:N \g__chemnum_initiate_sub_bool \bool_set_false:N \g__chemnum_initiate_strict_bool , - init / false .code:n = + init / false .code:n = \bool_set_false:N \g__chemnum_initiate_bool \bool_set_false:N \g__chemnum_initiate_sub_bool \bool_set_false:N \g__chemnum_initiate_strict_bool , - init / strict .code:n = + init / strict .code:n = \bool_set_true:N \g__chemnum_initiate_bool \bool_set_true:N \g__chemnum_initiate_sub_bool \bool_set_true:N \g__chemnum_initiate_strict_bool , - init / main-strict .code:n = + init / main-strict .code:n = \bool_set_true:N \g__chemnum_initiate_bool \bool_set_false:N \g__chemnum_initiate_sub_bool \bool_set_true:N \g__chemnum_initiate_strict_bool , - init .default:n = true , - init .groups:n = {general} , + init .default:n = true , + init .groups:n = {general} , % list processing: - list-sep-two .tl_set:N = \l__chemnum_sep_list_two_tl , - list-sep-two .groups:n = {general,list} , - list-sep-more .tl_set:N = \l__chemnum_sep_list_more_tl , - list-sep-more .groups:n = {general,list} , - list-sep-last-two .tl_set:N = \l__chemnum_sep_list_last_two_tl , - list-sep-last-two .groups:n = {general,list} , - sub-list-sep-two .tl_set:N = \l__chemnum_sep_sublist_two_tl , - sub-list-sep-two .groups:n = {compound,general} , - sub-list-sep-more .tl_set:N = \l__chemnum_sep_sublist_more_tl , - sub-list-sep-more .groups:n = {compound,general} , - sub-list-sep-last-two .tl_set:N = \l__chemnum_sep_sublist_last_two_tl , - sub-list-sep-last-two .groups:n = {compound,general} , - sub-list-sep-range .tl_set:N = \l__chemnum_sep_sublist_range_tl , - sub-list-sep-range .groups:n = {compound,general} , + list-sep-two .tl_set:N = \l__chemnum_sep_list_two_tl , + list-sep-two .groups:n = {general,list} , + list-sep-more .tl_set:N = \l__chemnum_sep_list_more_tl , + list-sep-more .groups:n = {general,list} , + list-sep-last-two .tl_set:N = \l__chemnum_sep_list_last_two_tl , + list-sep-last-two .groups:n = {general,list} , + sub-list-sep-two .tl_set:N = \l__chemnum_sep_sublist_two_tl , + sub-list-sep-two .groups:n = {compound,general} , + sub-list-sep-more .tl_set:N = \l__chemnum_sep_sublist_more_tl , + sub-list-sep-more .groups:n = {compound,general} , + sub-list-sep-last-two .tl_set:N = \l__chemnum_sep_sublist_last_two_tl , + sub-list-sep-last-two .groups:n = {compound,general} , + sub-list-sep-range .tl_set:N = \l__chemnum_sep_sublist_range_tl , + sub-list-sep-range .groups:n = {compound,general} , % logging and other information: - log .choice: , - log / true .code:n = + log .choice: , + log / true .code:n = \bool_set_true:N \l__chemnum_log_bool \bool_set_false:N \l__chemnum_log_verbose_bool , - log / silent .code:n = + log / silent .code:n = \bool_set_true:N \l__chemnum_log_bool \bool_set_false:N \l__chemnum_log_verbose_bool , - log / false .code:n = + log / false .code:n = \bool_set_false:N \l__chemnum_log_bool \bool_set_false:N \l__chemnum_log_verbose_bool , - log / verbose .code:n = + log / verbose .code:n = \bool_set_true:N \l__chemnum_log_bool \bool_set_true:N \l__chemnum_log_verbose_bool , - log .default:n = true , - log .groups:n = {general} , - show-keys .choice: , - show-keys / true .code:n = + log .default:n = true , + log .groups:n = {general} , + show-keys .choice: , + show-keys / true .code:n = \bool_set_true:N \l__chemnum_show_def_bool \bool_set_true:N \l__chemnum_show_ref_bool , - show-keys / false .code:n = + show-keys / false .code:n = \bool_set_false:N \l__chemnum_show_def_bool \bool_set_false:N \l__chemnum_show_ref_bool , - show-keys / def .code:n = + show-keys / def .code:n = \bool_set_true:N \l__chemnum_show_def_bool \bool_set_false:N \l__chemnum_show_ref_bool , - show-keys / ref .code:n = + show-keys / ref .code:n = \bool_set_false:N \l__chemnum_show_def_bool \bool_set_true:N \l__chemnum_show_ref_bool , - show-keys .default:n = true , - show-keys .groups:n = {general} , - replace .bool_set:N = \l__chemnum_replace_local_bool , - replace .groups:n = {replace} , - replace-auto .bool_set:N = \l__chemnum_compound_replace_auto_bool , - replace-tag .tl_set:N = \l__chemnum_compound_replace_tag_tl , - replace-tag .groups:n = {general} , - tag .code:n = + show-keys .default:n = true , + show-keys .groups:n = {general} , + replace .bool_set:N = \l__chemnum_replace_local_bool , + replace .groups:n = {replace} , + replace-auto .bool_set:N = \l__chemnum_compound_replace_auto_bool , + replace-tag .tl_set:N = \l__chemnum_compound_replace_tag_tl , + replace-tag .groups:n = {general} , + tag .code:n = \tl_set:Nn \l__chemnum_compound_replace_tag_tl {#1} \bool_set_false:N \l__chemnum_compound_replace_auto_this_bool , - tag .groups:n = {replace} , - replace-style .tl_set:N = \l__chemnum_compound_replace_format_tl , - replace-style .groups:n = {general} , - style .code:n = + tag .groups:n = {replace} , + replace-style .tl_set:N = \l__chemnum_compound_replace_format_tl , + replace-style .groups:n = {general} , + style .code:n = \tl_set:Nn \l__chemnum_compound_replace_local_format_tl {#1} \bool_set_true:N \l__chemnum_replace_local_bool , - style .groups:n = {replace} , - replace-pos .code:n = \__chemnum_set_psfrag_pos:nn #1 , - replace-pos .groups:n = {general} , - pos .code:n = + style .groups:n = {replace} , + replace-pos .code:n = \__chemnum_set_psfrag_pos:nn #1 , + replace-pos .groups:n = {general} , + pos .code:n = \bool_set_true:N \l__chemnum_replace_local_bool \__chemnum_set_psfrag_local_pos:nn #1 , - pos .groups:n = {replace} + pos .groups:n = {replace} } % ---------------------------------------------------------------------------- @@ -488,14 +489,14 @@ % ---------------------------------------------------------------------------- % initiating new compounds % - property list that holds -% - ID -% - counter value -% - counter represetation -% - pre-counter-code -% - post-counter-code -% - pre-label-code -% - post-label-code -% - formatting code +% - ID +% - counter value +% - counter represetation +% - pre-counter-code +% - post-counter-code +% - pre-label-code +% - post-label-code +% - formatting code % - add to list of initiated compounds \cs_new_protected:Npn \chemnum_initiate_compound:n #1 @@ -565,37 +566,41 @@ % case... this would overwrite options that really should stay set. % \chemnum_compound_set_property:nnV {#1} {pre-label-code} - % \l__chemnum_pre_label_default_tl + % \l__chemnum_pre_label_default_tl % \chemnum_compound_set_property:nnV {#1} {post-label-code} - % \l__chemnum_post_label_default_tl + % \l__chemnum_post_label_default_tl % \chemnum_compound_set_property:nnV {#1} {post-main-label-code} - % \l__chemnum_post_main_label_default_tl + % \l__chemnum_post_main_label_default_tl % \chemnum_compound_set_property:nnV {#1} {label-format} - % \l__chemnum_label_format_tl + % \l__chemnum_label_format_tl % \__chemnum_write_compound_to_auxfile:nnnVVVV {#1} - % { \int_use:N \g__chemnum_main_int } - % { - % \tl_use:N \l__chemnum_pre_counter_default_tl - % \__chemnum_label_format:NV - % \c@cmpdmain % \g__chemnum_main_int - % \l__chemnum_default_counter_representation_tl - % \tl_use:N \l__chemnum_post_counter_default_tl - % } - % \l__chemnum_pre_label_default_tl - % \l__chemnum_post_label_default_tl - % \l__chemnum_post_main_label_default_tl - % \l__chemnum_label_format_tl + % { \int_use:N \g__chemnum_main_int } + % { + % \tl_use:N \l__chemnum_pre_counter_default_tl + % \__chemnum_label_format:NV + % \c@cmpdmain % \g__chemnum_main_int + % \l__chemnum_default_counter_representation_tl + % \tl_use:N \l__chemnum_post_counter_default_tl + % } + % \l__chemnum_pre_label_default_tl + % \l__chemnum_post_label_default_tl + % \l__chemnum_post_main_label_default_tl + % \l__chemnum_label_format_tl % \chemnum_compound_update_properties:n {#1} } \cs_new_protected:Npn \chemnum_initialize_compound:n #1 { - \seq_gput_right:Nn \g__chemnum_defined_compounds_seq {#1} - \int_gincr:N \g__chemnum_main_int - \stepcounter{cmpdmain} - \seq_new:c { g__chemnum_#1_initiated_subcompounds_seq } + \seq_if_in:NnF \g__chemnum_defined_compounds_seq {#1} + { + \seq_gput_right:Nn \g__chemnum_defined_compounds_seq {#1} + \int_gincr:N \g__chemnum_main_int + \stepcounter{cmpdmain} + } + \seq_if_exist:cF { g__chemnum_#1_initiated_subcompounds_seq } + { \seq_new:c { g__chemnum_#1_initiated_subcompounds_seq } } } - + % #1: main ID % #2: sub ID \cs_new_protected:Npn \chemnum_define_subcompound:nn #1#2 @@ -638,7 +643,9 @@ { \seq_new:c { g__chemnum_compound_#1_subcompounds_seq } } \prop_if_exist:cF { g__chemnum_compound_#1_subcompounds_prop } { \prop_new:c { g__chemnum_compound_#1_subcompounds_prop } } - \seq_gput_right:cn { g__chemnum_compound_#1_subcompounds_seq } {#2} + \seq_if_in:cnF { g__chemnum_compound_#1_subcompounds_seq } {#2} + { \seq_gput_right:cn { g__chemnum_compound_#1_subcompounds_seq } {#2} } + \seq_gput_right:Nn \g__chemnum_compound_defined_subcompounds_seq {#1#2} \prop_gput:cnx { g__chemnum_compound_#1_subcompounds_prop } {#2} { \int_use:c { g__chemnum_compound_#1_subcompound_int } : @@ -655,7 +662,7 @@ { \bool_if:NTF \l__chemnum_log_verbose_bool { \msg_log:nnn {chemnum} {log-compound-verbose} {#1} } - { \msg_log:nnn {chemnum} {log-compound-silent} {#1} } + { \msg_log:nnn {chemnum} {log-compound-silent} {#1} } } } @@ -665,7 +672,7 @@ { \bool_if:NTF \l__chemnum_log_verbose_bool { \msg_log:nnnn {chemnum} {log-subcompound-verbose} {#1} {#2} } - { \msg_log:nnnn {chemnum} {log-subcompound-silent} {#1} {#2} } + { \msg_log:nnnn {chemnum} {log-subcompound-silent} {#1} {#2} } } } @@ -703,7 +710,7 @@ \prg_new_protected_conditional:Npnn \chemnum_subcompound_if_defined:nn #1#2 { T,F,TF } { - \seq_if_in:cnTF { g__chemnum_compound_#1_subcompounds_seq } {#2} + \seq_if_in:NnTF \g__chemnum_compound_defined_subcompounds_seq {#1#2} { \prg_return_true: } { \prg_return_false: } } @@ -934,6 +941,7 @@ % #8: label format \cs_new_protected:Npn \chemnum@cmpd #1#2#3#4#5#6#7#8 { + % \chemnum_initialize_compound:n {#1} \prop_if_exist:cF { g__chemnum_compound_#1_prop } { \prop_new:c { g__chemnum_compound_#1_prop } } \prop_gput:cnn { g__chemnum_compound_#1_prop } @@ -960,6 +968,10 @@ { \prop_if_exist:cF { g__chemnum_compound_#1_#2_properties_prop } { \prop_new:c { g__chemnum_compound_#1_#2_properties_prop } } + \seq_if_exist:cF { g__chemnum_compound_#1_subcompounds_seq } + { \seq_new:c { g__chemnum_compound_#1_subcompounds_seq } } + \seq_if_in:cnF { g__chemnum_compound_#1_subcompounds_seq } {#2} + { \seq_gput_right:cn { g__chemnum_compound_#1_subcompounds_seq } {#2} } \prop_gput:cnn { g__chemnum_compound_#1_#2_properties_prop } {previous-number} {#3} \prop_gput:cnn { g__chemnum_compound_#1_#2_properties_prop } @@ -980,7 +992,7 @@ \bool_if:NT \g__chemnum_initiate_bool { \bool_if:NTF \g__chemnum_initiate_strict_bool - { \msg_error:nnn {chemnum} {compound-not-initiated} {#2} } + { \msg_error:nnn {chemnum} {compound-not-initiated} {#2} } { \msg_warning:nnn {chemnum} {compound-not-initiated} {#2} } } \bool_if:NT \l__chemnum_show_def_bool @@ -1184,7 +1196,7 @@ \cs_set:Npn \__chemnum_split_sub_from_main_aux:nnnw ##1##2##3##4#1##5#1##6 \q_stop { \bool_if:NF ##2 { \chemnum_declare_compound:nn {##3} {##4} } - \keys_set_groups:nnn {chemnum} {sub-only} {#4} + \keys_set_groups:nnn {chemnum} {sub-only} {#4} \chemnum_if_write_and_or_read:NNTF #2 #3 { \chemnum_compound_start:n {##4} } { \chemnum_expandable_compound_start:n {##4} } @@ -1220,7 +1232,7 @@ % \chemnum_write_main:nnnn will write the main label, either with saved % values (+ variant, boolean #2=true), or only register it (* variant, boolean % #1=true) -% +% % #1: boolean: if true register compound but don't write the label % #2: boolean: if true only read compound % #3: options @@ -1363,10 +1375,20 @@ { \seq_put_right:Nn #6 { \chemnum_write_subcompound:NNnnn #1 #2 {#4} {#5} {##1} } - \seq_put_right:Nx #7 + \bool_if:NTF #2 { - \chemnum_expandable_get_subcompound_property:nnn - { #5 } { ##1 } { number } + \seq_put_right:Nx #7 + { + \chemnum_expandable_get_subcompound_property:nnn + {#5} {##1} {previous-number} + } + } + { + \seq_put_right:Nx #7 + { + \chemnum_expandable_get_subcompound_property:nnn + {#5} {##1} {number} + } } } } @@ -1557,11 +1579,11 @@ } } % merge = true: - % \l__chemnum_tmpa_prop now holds all main labels with possible sublabel + % \l__chemnum_tmpa_prop now holds all main labels with possible sublabel % lists % merge = false - % \l__chemnum_tmpa_prop now holds all main labels with all occurences of - % the respective main label as property + % \l__chemnum_tmpa_prop now holds all main labels with all occurences of + % the respective main label as property % % build sequence that holds entries of #1 in order of already defined % labels: @@ -1619,7 +1641,7 @@ } % \l__chemnum_tmpb_seq now holds all labels that are already defined % merge = true : - % the same \l__chemnum_tmpc_seq which only holds the /main/ labels + % the same \l__chemnum_tmpc_seq which only holds the /main/ labels \bool_if:NTF \l__chemnum_merge_list_bool { \seq_map_inline:Nn #1 @@ -1688,7 +1710,7 @@ \cs_new_protected:Npn \chemnum_cmpd_replace:nnn #1#2#3 { % place the label - % just in case it hasn't been declared: + % just in case it hasn't been declared: \labelcmpd[{#2}]{#3} % set specific replacement options \keys_set_groups:nnn {chemnum} {replace} { replace=false, #2 } @@ -1711,7 +1733,7 @@ \l__chemnum_compound_replace_tag_tl \bool_set_true:N \l__chemnum_compound_replace_auto_this_bool } - % replace in EPS, this must not be in a group: + % replace in EPS, this must not be in a group: \bool_if:NTF \l__chemnum_replace_local_bool { \__chemnum_psfrag:VVVx @@ -1756,13 +1778,13 @@ % ---------------------------------------------------------------------------- % the user level version of the main command: -\NewDocumentCommand \cmpd { st+O{}m } +\NewDocumentCommand \cmpd { st+O{}m } { \chemnum_cmpd:nnnn {#1} {#2} {#3} {#4} } -\NewDocumentCommand \refcmpd { O{}m } +\NewDocumentCommand \refcmpd { O{}m } { \chemnum_cmpd:nnnn { \c_false_bool } { \c_true_bool } {#1} {#2} } -\NewDocumentCommand \labelcmpd { O{}m } +\NewDocumentCommand \labelcmpd { O{}m } { \chemnum_cmpd:nnnn { \c_true_bool } { \c_false_bool } {#1} {#2} } \DeclareExpandableDocumentCommand \cmpdplain { m } @@ -1787,7 +1809,7 @@ \cs_new_protected:Npn \chemnum_init:nn #1#2 { \group_begin: - % this is semantically wrong! The conflict: either I allow initiation + % this is semantically wrong! The conflict: either I allow initiation % to be set locally (which does not make sense, really) or I use wrong % semantics at this very point in the package code... \bool_set_false:N \g__chemnum_initiate_bool @@ -1814,39 +1836,39 @@ % ---------------------------------------------------------------------------- % language support: -\DeclareTranslationFallback {chemnum-sep-two} {~and~} -\DeclareTranslation {English} {chemnum-sep-two} {~and~} -\DeclareTranslation {German} {chemnum-sep-two} {~und~} -\DeclareTranslation {French} {chemnum-sep-two} {~et~} -\DeclareTranslation {Spanish} {chemnum-sep-two} {~y~} -\DeclareTranslation {Italian} {chemnum-sep-two} {~e~} -\DeclareTranslation {Catalan} {chemnum-sep-two} {~i~} +\DeclareTranslationFallback {chemnum-sep-two} {~and~} +\DeclareTranslation {English} {chemnum-sep-two} {~and~} +\DeclareTranslation {German} {chemnum-sep-two} {~und~} +\DeclareTranslation {French} {chemnum-sep-two} {~et~} +\DeclareTranslation {Spanish} {chemnum-sep-two} {~y~} +\DeclareTranslation {Italian} {chemnum-sep-two} {~e~} +\DeclareTranslation {Catalan} {chemnum-sep-two} {~i~} \DeclareTranslation {Portuguese} {chemnum-sep-two} {~e~} -\DeclareTranslation {Dutch} {chemnum-sep-two} {~en~} -\DeclareTranslation {Danish} {chemnum-sep-two} {~og~} -\DeclareTranslation {Swedish} {chemnum-sep-two} {~och~} -\DeclareTranslation {Finnish} {chemnum-sep-two} {~ja~} -\DeclareTranslation {Norwegian} {chemnum-sep-two} {~og~} - -\DeclareTranslationFallback {chemnum-sep-last-two} {~and~} -\DeclareTranslation {English} {chemnum-sep-last-two} {~and~} -\DeclareTranslation {American} {chemnum-sep-last-two} {,~and~} -\DeclareTranslation {British} {chemnum-sep-last-two} {~and~} -\DeclareTranslation {German} {chemnum-sep-last-two} {~und~} -\DeclareTranslation {French} {chemnum-sep-last-two} {~et~} -\DeclareTranslation {Spanish} {chemnum-sep-last-two} {~y~} -\DeclareTranslation {Italian} {chemnum-sep-last-two} {~e~} -\DeclareTranslation {Catalan} {chemnum-sep-last-two} {~i~} +\DeclareTranslation {Dutch} {chemnum-sep-two} {~en~} +\DeclareTranslation {Danish} {chemnum-sep-two} {~og~} +\DeclareTranslation {Swedish} {chemnum-sep-two} {~och~} +\DeclareTranslation {Finnish} {chemnum-sep-two} {~ja~} +\DeclareTranslation {Norwegian} {chemnum-sep-two} {~og~} + +\DeclareTranslationFallback {chemnum-sep-last-two} {~and~} +\DeclareTranslation {English} {chemnum-sep-last-two} {~and~} +\DeclareTranslation {American} {chemnum-sep-last-two} {,~and~} +\DeclareTranslation {British} {chemnum-sep-last-two} {~and~} +\DeclareTranslation {German} {chemnum-sep-last-two} {~und~} +\DeclareTranslation {French} {chemnum-sep-last-two} {~et~} +\DeclareTranslation {Spanish} {chemnum-sep-last-two} {~y~} +\DeclareTranslation {Italian} {chemnum-sep-last-two} {~e~} +\DeclareTranslation {Catalan} {chemnum-sep-last-two} {~i~} \DeclareTranslation {Portuguese} {chemnum-sep-last-two} {~e~} -\DeclareTranslation {Dutch} {chemnum-sep-last-two} {~en~} -\DeclareTranslation {Danish} {chemnum-sep-last-two} {~og~} -\DeclareTranslation {Swedish} {chemnum-sep-last-two} {~och~} -\DeclareTranslation {Finnish} {chemnum-sep-last-two} {~ja~} -\DeclareTranslation {Norwegian} {chemnum-sep-last-two} {~og~} +\DeclareTranslation {Dutch} {chemnum-sep-last-two} {~en~} +\DeclareTranslation {Danish} {chemnum-sep-last-two} {~og~} +\DeclareTranslation {Swedish} {chemnum-sep-last-two} {~och~} +\DeclareTranslation {Finnish} {chemnum-sep-last-two} {~ja~} +\DeclareTranslation {Norwegian} {chemnum-sep-last-two} {~og~} % ---------------------------------------------------------------------------- % TODO: add a warning for those options that can't be set with the setup -% command, i.e., those belonging to the `compound' group +% command, i.e., those belonging to the `compound' group \cs_new_protected:Npn \chemnum_setup:n #1 { \keys_set_filter:nnn {chemnum} {compound,general} {#1} @@ -1866,10 +1888,10 @@ TODO: % ---------------------------------------------------------------------------- new features in chemnum v1.0: - \cmpdplain{<id>} => reads label and writes it expandably without - formatting. It is not able to parse a list. Its sole purpose is usage in + formatting. It is not able to parse a list. Its sole purpose is usage in pdfstrings (cf. \texorpdfstring{<tex>}{<pdfstring>}). - \refcmpd[<options>]{<id>} only reference a label, similar to \cmpdplain but - unexpandable and able to parse a list. The same as \cmpd+ + unexpandable and able to parse a list. The same as \cmpd+ - \cmpdproperty, \subcmpdproperty - \newcmpdcounterformat - logging messages @@ -1880,4 +1902,9 @@ new features in chemnum v1.0: % ---------------------------------------------------------------------------- HISTORY: +2014/03/12 v1.0 - first published +2014/05/30 v1.0a - bug fix: subcompounds can now be correctly referenced + before they're defined +2014/06/02 v1.0b - bug fix: list of sublabels can now correctly be sorted and + compressed if referenced before they're defined |