diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
7 files changed, 1173 insertions, 81 deletions
diff --git a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-dutch.lang b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-dutch.lang index 41c8c90a50c..cb619f5f24f 100644 --- a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-dutch.lang +++ b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-dutch.lang @@ -101,6 +101,7 @@ type = page , Name-pl = Pagina's , name-pl = pagina's , rangesep = {\textendash} , + rangetopair = false , type = line , gender = m , diff --git a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-english.lang b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-english.lang index 63d7fb66f01..d5aee7b1912 100644 --- a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-english.lang +++ b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-english.lang @@ -98,6 +98,7 @@ type = page , Name-pl = Pages , name-pl = pages , rangesep = {\textendash} , + rangetopair = false , type = line , Name-sg = Line , diff --git a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-french.lang b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-french.lang index 0518b3af6ad..22930160de0 100644 --- a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-french.lang +++ b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-french.lang @@ -101,6 +101,7 @@ type = page , Name-pl = Pages , name-pl = pages , rangesep = {-} , + rangetopair = false , type = line , gender = f , diff --git a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-german.lang b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-german.lang index c1e39cc917c..ff39f2e8773 100644 --- a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-german.lang +++ b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-german.lang @@ -157,6 +157,7 @@ type = page , Name-sg = Seite , Name-pl = Seiten , rangesep = {\textendash} , + rangetopair = false , type = line , gender = f , diff --git a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-portuguese.lang b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-portuguese.lang index c0750f8aede..6b4baabf0c6 100644 --- a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-portuguese.lang +++ b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-portuguese.lang @@ -105,6 +105,7 @@ type = page , Name-pl = Páginas , name-pl = páginas , rangesep = {\textendash} , + rangetopair = false , type = line , gender = f , diff --git a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-spanish.lang b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-spanish.lang index 90f33105676..1fb85b235a3 100644 --- a/Master/texmf-dist/tex/latex/zref-clever/zref-clever-spanish.lang +++ b/Master/texmf-dist/tex/latex/zref-clever/zref-clever-spanish.lang @@ -101,6 +101,7 @@ type = page , Name-pl = Páginas , name-pl = páginas , rangesep = {\textendash} , + rangetopair = false , type = line , gender = f , diff --git a/Master/texmf-dist/tex/latex/zref-clever/zref-clever.sty b/Master/texmf-dist/tex/latex/zref-clever/zref-clever.sty index 6877d2d5ce5..072951bb14e 100644 --- a/Master/texmf-dist/tex/latex/zref-clever/zref-clever.sty +++ b/Master/texmf-dist/tex/latex/zref-clever/zref-clever.sty @@ -53,7 +53,7 @@ }% \endinput }% -\ProvidesExplPackage {zref-clever} {2022-01-28} {0.2.0-alpha} +\ProvidesExplPackage {zref-clever} {2022-02-07} {0.2.1-alpha} {Clever LaTeX cross-references based on zref} \RequirePackage { zref-base } \RequirePackage { zref-user } @@ -249,6 +249,11 @@ Option~'ref=#1'~requested~\msg_line_context:.~ But~the~property~'#1'~is~not~declared,~falling-back~to~'default'. } +\msg_new:nnn { zref-clever } { endrange-property-undefined } + { + Option~'endrange=#1'~requested~\msg_line_context:.~ + But~the~property~'#1'~is~not~declared,~'endrange'~not~set. + } \msg_new:nnn { zref-clever } { hyperref-preamble-only } { Option~'hyperref'~only~available~in~the~preamble~\msg_line_context:.~ @@ -302,7 +307,7 @@ \exp_args:NNNo \exp_args:NNo \tl_set:Nn #1 { \zref@extractdefault {#2} {#3} {#4} } } -\cs_generate_variant:Nn \__zrefclever_extract_default:Nnnn { NVnn } +\cs_generate_variant:Nn \__zrefclever_extract_default:Nnnn { NVnn , Nnvn } \cs_new:Npn \__zrefclever_extract_unexp:nnn #1#2#3 { \exp_args:NNo \exp_args:No @@ -480,6 +485,7 @@ { cap , abbrev , + rangetopair , } \seq_const_from_clist:Nn \c__zrefclever_rf_opts_tl_type_names_seq @@ -938,6 +944,225 @@ } , } } +\keys_define:nn { zref-clever/langfile } + { + endrange .code:n = + { + \str_case:nnF {#1} + { + { ref } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + { } + } + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + { } + } + } + + { stripprefix } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_stripprefix } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + { } + } + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_stripprefix } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + { } + } + } + + { pagecomp } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomp } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + { } + } + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomp } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + { } + } + } + + { pagecomp2 } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomptwo } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + { } + } + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomptwo } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + { } + } + } + + { unset } + { } + } + { + \tl_if_empty:nTF {#1} + { + \msg_info:nnn { zref-clever } + { endrange-property-undefined } {#1} + } + { + \zref@ifpropundefined {#1} + { + \msg_info:nnn { zref-clever } + { endrange-property-undefined } {#1} + } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_property } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + {#1} + } + { + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_property } + \__zrefclever_opt_tl_gset_if_new:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + {#1} + } + } + } + } + } , + endrange .value_required:n = true , + } \seq_map_inline:Nn \c__zrefclever_rf_opts_tl_type_names_seq { @@ -1185,12 +1410,21 @@ { ref .code:n = { - \zref@ifpropundefined {#1} + \tl_if_empty:nTF {#1} { - \msg_warning:nnn { zref-clever } { zref-property-undefined } {#1} + \msg_warning:nnn { zref-clever } + { zref-property-undefined } {#1} \tl_set:Nn \l__zrefclever_ref_property_tl { default } } - { \tl_set:Nn \l__zrefclever_ref_property_tl {#1} } + { + \zref@ifpropundefined {#1} + { + \msg_warning:nnn { zref-clever } + { zref-property-undefined } {#1} + \tl_set:Nn \l__zrefclever_ref_property_tl { default } + } + { \tl_set:Nn \l__zrefclever_ref_property_tl {#1} } + } } , ref .initial:n = default , ref .value_required:n = true , @@ -1258,6 +1492,349 @@ nocomp .meta:n = { comp = false }, nocomp .value_forbidden:n = true , } +\NewHook { zref-clever/endrange-setup } +\keys_define:nn { zref-clever/reference } + { + endrange .code:n = + { + \str_case:nnF {#1} + { + { ref } + { + \tl_clear:c + { + \__zrefclever_opt_varname_general:nn + { endrangefunc } { tl } + } + \tl_clear:c + { + \__zrefclever_opt_varname_general:nn + { endrangeprop } { tl } + } + } + + { stripprefix } + { + \tl_set:cn + { + \__zrefclever_opt_varname_general:nn + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_stripprefix } + \tl_clear:c + { + \__zrefclever_opt_varname_general:nn + { endrangeprop } { tl } + } + } + + { pagecomp } + { + \tl_set:cn + { + \__zrefclever_opt_varname_general:nn + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomp } + \tl_clear:c + { + \__zrefclever_opt_varname_general:nn + { endrangeprop } { tl } + } + } + + { pagecomp2 } + { + \tl_set:cn + { + \__zrefclever_opt_varname_general:nn + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomptwo } + \tl_clear:c + { + \__zrefclever_opt_varname_general:nn + { endrangeprop } { tl } + } + } + + { unset } + { + \__zrefclever_opt_tl_unset:c + { + \__zrefclever_opt_varname_general:nn + { endrangefunc } { tl } + } + \__zrefclever_opt_tl_unset:c + { + \__zrefclever_opt_varname_general:nn + { endrangeprop } { tl } + } + } + } + { + \tl_if_empty:nTF {#1} + { + \msg_warning:nnn { zref-clever } + { endrange-property-undefined } {#1} + } + { + \zref@ifpropundefined {#1} + { + \msg_warning:nnn { zref-clever } + { endrange-property-undefined } {#1} + } + { + \tl_set:cn + { + \__zrefclever_opt_varname_general:nn + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_property } + \tl_set:cn + { + \__zrefclever_opt_varname_general:nn + { endrangeprop } { tl } + } + {#1} + } + } + } + } , + endrange .value_required:n = true , + } +\cs_new_protected:Npn \__zrefclever_get_endrange_property:nnN #1#2#3 + { + \tl_if_empty:NTF \l__zrefclever_endrangeprop_tl + { + \zref@ifrefcontainsprop {#2} { \l__zrefclever_ref_property_tl } + { + \__zrefclever_extract_default:Nnvn #3 + {#2} { l__zrefclever_ref_property_tl } { } + } + { \tl_set:Nn #3 { zc@missingproperty } } + } + { + \zref@ifrefcontainsprop {#2} { \l__zrefclever_endrangeprop_tl } + { + \bool_if:NTF \l__zrefclever_typeset_range_bool + { + \group_begin: + \bool_set_false:N \l_tmpa_bool + \exp_args:Nxx \tl_if_eq:nnT + { + \__zrefclever_extract_unexp:nnn + {#1} { externaldocument } { } + } + { + \__zrefclever_extract_unexp:nnn + {#2} { externaldocument } { } + } + { + \tl_if_eq:NnTF \l__zrefclever_ref_property_tl { page } + { + \exp_args:Nxx \tl_if_eq:nnT + { + \__zrefclever_extract_unexp:nnn + {#1} { zc@pgfmt } { } + } + { + \__zrefclever_extract_unexp:nnn + {#2} { zc@pgfmt } { } + } + { \bool_set_true:N \l_tmpa_bool } + } + { + \exp_args:Nxx \tl_if_eq:nnT + { + \__zrefclever_extract_unexp:nnn + {#1} { zc@counter } { } + } + { + \__zrefclever_extract_unexp:nnn + {#2} { zc@counter } { } + } + { + \exp_args:Nxx \tl_if_eq:nnT + { + \__zrefclever_extract_unexp:nnn + {#1} { zc@enclval } { } + } + { + \__zrefclever_extract_unexp:nnn + {#2} { zc@enclval } { } + } + { \bool_set_true:N \l_tmpa_bool } + } + } + } + \bool_if:NTF \l_tmpa_bool + { + \__zrefclever_extract_default:Nnvn \l_tmpb_tl + {#2} { l__zrefclever_endrangeprop_tl } { } + } + { + \zref@ifrefcontainsprop + {#2} { \l__zrefclever_ref_property_tl } + { + \__zrefclever_extract_default:Nnvn \l_tmpb_tl + {#2} { l__zrefclever_ref_property_tl } { } + } + { \tl_set:Nn \l_tmpb_tl { zc@missingproperty } } + } + \exp_args:NNNV + \group_end: + \tl_set:Nn #3 \l_tmpb_tl + } + { + \__zrefclever_extract_default:Nnvn #3 + {#2} { l__zrefclever_endrangeprop_tl } { } + } + } + { + \zref@ifrefcontainsprop {#2} { \l__zrefclever_ref_property_tl } + { + \__zrefclever_extract_default:Nnvn #3 + {#2} { l__zrefclever_ref_property_tl } { } + } + { \tl_set:Nn #3 { zc@missingproperty } } + } + } + } +\cs_generate_variant:Nn \__zrefclever_get_endrange_property:nnN { VVN } +\cs_new_protected:Npn \__zrefclever_get_endrange_stripprefix:nnN #1#2#3 + { + \zref@ifrefcontainsprop {#2} { \l__zrefclever_ref_property_tl } + { + \group_begin: + \UseHook { zref-clever/endrange-setup } + \tl_set:Nx \l_tmpa_tl + { + \__zrefclever_extract:nnn + {#1} { \l__zrefclever_ref_property_tl } { } + } + \tl_set:Nx \l_tmpb_tl + { + \__zrefclever_extract:nnn + {#2} { \l__zrefclever_ref_property_tl } { } + } + \bool_set_false:N \l_tmpa_bool + \bool_until_do:Nn \l_tmpa_bool + { + \exp_args:Nxx \tl_if_eq:nnTF + { \tl_head:V \l_tmpa_tl } { \tl_head:V \l_tmpb_tl } + { + \tl_set:Nx \l_tmpa_tl { \tl_tail:V \l_tmpa_tl } + \tl_set:Nx \l_tmpb_tl { \tl_tail:V \l_tmpb_tl } + \tl_if_empty:NT \l_tmpb_tl + { \bool_set_true:N \l_tmpa_bool } + } + { \bool_set_true:N \l_tmpa_bool } + } + \exp_args:NNNV + \group_end: + \tl_set:Nn #3 \l_tmpb_tl + } + { \tl_set:Nn #3 { zc@missingproperty } } + } +\cs_generate_variant:Nn \__zrefclever_get_endrange_stripprefix:nnN { VVN } +\prg_new_protected_conditional:Npnn + \__zrefclever_is_integer_rgx:n #1 { F , TF } + { + \regex_match:nnTF { \A\d+\Z } {#1} + { \prg_return_true: } + { \prg_return_false: } + } +\prg_generate_conditional_variant:Nnn + \__zrefclever_is_integer_rgx:n { V } { F , TF } +\cs_new_protected:Npn \__zrefclever_get_endrange_pagecomp:nnN #1#2#3 + { + \zref@ifrefcontainsprop {#2} { \l__zrefclever_ref_property_tl } + { + \group_begin: + \UseHook { zref-clever/endrange-setup } + \tl_set:Nx \l_tmpa_tl + { + \__zrefclever_extract:nnn + {#1} { \l__zrefclever_ref_property_tl } { } + } + \tl_set:Nx \l_tmpb_tl + { + \__zrefclever_extract:nnn + {#2} { \l__zrefclever_ref_property_tl } { } + } + \bool_set_false:N \l_tmpa_bool + \__zrefclever_is_integer_rgx:VTF \l_tmpa_tl + { + \__zrefclever_is_integer_rgx:VF \l_tmpb_tl + { \bool_set_true:N \l_tmpa_bool } + } + { \bool_set_true:N \l_tmpa_bool } + \bool_until_do:Nn \l_tmpa_bool + { + \exp_args:Nxx \tl_if_eq:nnTF + { \tl_head:V \l_tmpa_tl } { \tl_head:V \l_tmpb_tl } + { + \tl_set:Nx \l_tmpa_tl { \tl_tail:V \l_tmpa_tl } + \tl_set:Nx \l_tmpb_tl { \tl_tail:V \l_tmpb_tl } + \tl_if_empty:NT \l_tmpb_tl + { \bool_set_true:N \l_tmpa_bool } + } + { \bool_set_true:N \l_tmpa_bool } + } + \exp_args:NNNV + \group_end: + \tl_set:Nn #3 \l_tmpb_tl + } + { \tl_set:Nn #3 { zc@missingproperty } } + } +\cs_generate_variant:Nn \__zrefclever_get_endrange_pagecomp:nnN { VVN } +\cs_new_protected:Npn \__zrefclever_get_endrange_pagecomptwo:nnN #1#2#3 + { + \zref@ifrefcontainsprop {#2} { \l__zrefclever_ref_property_tl } + { + \group_begin: + \UseHook { zref-clever/endrange-setup } + \tl_set:Nx \l_tmpa_tl + { + \__zrefclever_extract:nnn + {#1} { \l__zrefclever_ref_property_tl } { } + } + \tl_set:Nx \l_tmpb_tl + { + \__zrefclever_extract:nnn + {#2} { \l__zrefclever_ref_property_tl } { } + } + \bool_set_false:N \l_tmpa_bool + \__zrefclever_is_integer_rgx:VTF \l_tmpa_tl + { + \__zrefclever_is_integer_rgx:VF \l_tmpb_tl + { \bool_set_true:N \l_tmpa_bool } + } + { \bool_set_true:N \l_tmpa_bool } + \bool_until_do:Nn \l_tmpa_bool + { + \exp_args:Nxx \tl_if_eq:nnTF + { \tl_head:V \l_tmpa_tl } { \tl_head:V \l_tmpb_tl } + { + \bool_lazy_or:nnTF + { \int_compare_p:nNn { \l_tmpb_tl } > { 99 } } + { \int_compare_p:nNn { \tl_head:V \l_tmpb_tl } = { 0 } } + { + \tl_set:Nx \l_tmpa_tl { \tl_tail:V \l_tmpa_tl } + \tl_set:Nx \l_tmpb_tl { \tl_tail:V \l_tmpb_tl } + } + { \bool_set_true:N \l_tmpa_bool } + } + { \bool_set_true:N \l_tmpa_bool } + } + \exp_args:NNNV + \group_end: + \tl_set:Nn #3 \l_tmpb_tl + } + { \tl_set:Nn #3 { zc@missingproperty } } + } +\cs_generate_variant:Nn \__zrefclever_get_endrange_pagecomptwo:nnN { VVN } \bool_new:N \l__zrefclever_typeset_range_bool \keys_define:nn { zref-clever/reference } { @@ -1550,6 +2127,22 @@ { \msg_warning:nn { zref-clever } { titleref-preamble-only } } } } +\keys_define:nn { zref-clever/reference } + { + vario .code:n = { \RequirePackage { zref-vario } } , + vario .value_forbidden:n = true , + } +\AddToHook { begindocument } + { + \keys_define:nn { zref-clever/reference } + { + vario .code:n = + { + \msg_warning:nnn { zref-clever } + { option-preamble-only } { vario } + } + } + } \tl_new:N \l__zrefclever_zcref_note_tl \keys_define:nn { zref-clever/reference } { @@ -1848,6 +2441,7 @@ { \tl_set:Nn \l__zrefclever_setup_type_tl {#1} \keys_set:nn { zref-clever/typesetup } {#2} + \tl_clear:N \l__zrefclever_setup_type_tl } \seq_map_inline:Nn \c__zrefclever_rf_opts_tl_not_type_specific_seq @@ -1890,6 +2484,118 @@ } \keys_define:nn { zref-clever/typesetup } { + endrange .code:n = + { + \str_case:nnF {#1} + { + { ref } + { + \tl_clear:c + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangefunc } { tl } + } + \tl_clear:c + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangeprop } { tl } + } + } + + { stripprefix } + { + \tl_set:cn + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangefunc } { tl } + } + { __zrefclever_get_endrange_stripprefix } + \tl_clear:c + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangeprop } { tl } + } + } + + { pagecomp } + { + \tl_set:cn + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomp } + \tl_clear:c + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangeprop } { tl } + } + } + + { pagecomp2 } + { + \tl_set:cn + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomptwo } + \tl_clear:c + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangeprop } { tl } + } + } + + { unset } + { + \__zrefclever_opt_tl_unset:c + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangefunc } { tl } + } + \__zrefclever_opt_tl_unset:c + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } { endrangeprop } { tl } + } + } + } + { + \tl_if_empty:nTF {#1} + { + \msg_warning:nnn { zref-clever } + { endrange-property-undefined } {#1} + } + { + \zref@ifpropundefined {#1} + { + \msg_warning:nnn { zref-clever } + { endrange-property-undefined } {#1} + } + { + \tl_set:cn + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_property } + \tl_set:cn + { + \__zrefclever_opt_varname_type:enn + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + {#1} + } + } + } + } , + endrange .value_required:n = true , + } +\keys_define:nn { zref-clever/typesetup } + { refpre .code:n = { % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha. @@ -2195,6 +2901,247 @@ } \keys_define:nn { zref-clever/langsetup } { + endrange .code:n = + { + \str_case:nnF {#1} + { + { ref } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + } + { + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + } + } + + { stripprefix } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_stripprefix } + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + } + { + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_stripprefix } + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + } + } + + { pagecomp } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomp } + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + } + { + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomp } + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + } + } + + { pagecomp2 } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomptwo } + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + } + { + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_pagecomptwo } + \tl_gclear:c + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + } + } + + { unset } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \__zrefclever_opt_tl_gunset:c + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + \__zrefclever_opt_tl_gunset:c + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + } + { + \__zrefclever_opt_tl_gunset:c + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + \__zrefclever_opt_tl_gunset:c + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + } + } + } + { + \tl_if_empty:nTF {#1} + { + \msg_warning:nnn { zref-clever } + { endrange-property-undefined } {#1} + } + { + \zref@ifpropundefined {#1} + { + \msg_warning:nnn { zref-clever } + { endrange-property-undefined } {#1} + } + { + \tl_if_empty:NTF \l__zrefclever_setup_type_tl + { + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_property } + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_default:enn + { \l__zrefclever_setup_language_tl } + { endrangeprop } { tl } + } + {#1} + } + { + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangefunc } { tl } + } + { __zrefclever_get_endrange_property } + \tl_gset:cn + { + \__zrefclever_opt_varname_lang_type:eenn + { \l__zrefclever_setup_language_tl } + { \l__zrefclever_setup_type_tl } + { endrangeprop } { tl } + } + {#1} + } + } + } + } + } , + endrange .value_required:n = true , + } +\keys_define:nn { zref-clever/langsetup } + { refpre .code:n = { % NOTE Option deprecated in 2022-01-10 for v0.1.2-alpha. @@ -2578,7 +3525,7 @@ \bool_set_false:N \l__zrefclever_sort_decided_bool % First we check if there's any "external document" difference (coming - % from 'zref-xr') and, if so, sort based on that. + % from `zref-xr') and, if so, sort based on that. \tl_if_eq:NNF \l__zrefclever_label_extdoc_a_tl \l__zrefclever_label_extdoc_b_tl @@ -2774,6 +3721,8 @@ \int_new:N \l__zrefclever_range_count_int \int_new:N \l__zrefclever_range_same_count_int \tl_new:N \l__zrefclever_range_beg_label_tl +\bool_new:N \l__zrefclever_range_beg_is_first_bool +\tl_new:N \l__zrefclever_range_end_ref_tl \bool_new:N \l__zrefclever_next_maybe_range_bool \bool_new:N \l__zrefclever_next_is_same_bool \tl_new:N \l__zrefclever_tpairsep_tl @@ -2786,8 +3735,11 @@ \tl_new:N \l__zrefclever_rangesep_tl \tl_new:N \l__zrefclever_namefont_tl \tl_new:N \l__zrefclever_reffont_tl +\tl_new:N \l__zrefclever_endrangefunc_tl +\tl_new:N \l__zrefclever_endrangeprop_tl \bool_new:N \l__zrefclever_cap_bool \bool_new:N \l__zrefclever_abbrev_bool +\bool_new:N \l__zrefclever_rangetopair_bool \seq_new:N \l__zrefclever_refbounds_first_seq \seq_new:N \l__zrefclever_refbounds_first_sg_seq \seq_new:N \l__zrefclever_refbounds_first_pb_seq @@ -2810,11 +3762,13 @@ \tl_clear:N \l__zrefclever_type_first_label_tl \tl_clear:N \l__zrefclever_type_first_label_type_tl \tl_clear:N \l__zrefclever_range_beg_label_tl + \tl_clear:N \l__zrefclever_range_end_ref_tl \int_zero:N \l__zrefclever_label_count_int \int_zero:N \l__zrefclever_type_count_int \int_zero:N \l__zrefclever_ref_count_int \int_zero:N \l__zrefclever_range_count_int \int_zero:N \l__zrefclever_range_same_count_int + \bool_set_false:N \l__zrefclever_range_beg_is_first_bool \bool_set_false:N \l__zrefclever_type_first_refbounds_set_bool % Get type block options (not type-specific). @@ -2889,9 +3843,9 @@ } % Handle warnings in case of reference or type undefined. - % Test: 'zc-typeset01.lvt': "Typeset refs: warn ref undefined" + % Test: `zc-typeset01.lvt': "Typeset refs: warn ref undefined" \zref@refused { \l__zrefclever_label_a_tl } - % Test: 'zc-typeset01.lvt': "Typeset refs: warn missing type" + % Test: `zc-typeset01.lvt': "Typeset refs: warn missing type" \zref@ifrefundefined { \l__zrefclever_label_a_tl } {} { @@ -2943,6 +3897,14 @@ { \l__zrefclever_label_type_a_tl } { \l__zrefclever_ref_language_tl } \l__zrefclever_reffont_tl + \__zrefclever_get_rf_opt_tl:nxxN { endrangefunc } + { \l__zrefclever_label_type_a_tl } + { \l__zrefclever_ref_language_tl } + \l__zrefclever_endrangefunc_tl + \__zrefclever_get_rf_opt_tl:nxxN { endrangeprop } + { \l__zrefclever_label_type_a_tl } + { \l__zrefclever_ref_language_tl } + \l__zrefclever_endrangeprop_tl \__zrefclever_get_rf_opt_bool:nnxxN { cap } { false } { \l__zrefclever_label_type_a_tl } { \l__zrefclever_ref_language_tl } @@ -2951,6 +3913,10 @@ { \l__zrefclever_label_type_a_tl } { \l__zrefclever_ref_language_tl } \l__zrefclever_abbrev_bool + \__zrefclever_get_rf_opt_bool:nnxxN { rangetopair } { true } + { \l__zrefclever_label_type_a_tl } + { \l__zrefclever_ref_language_tl } + \l__zrefclever_rangetopair_bool \__zrefclever_get_rf_opt_seq:nxxN { refbounds-first } { \l__zrefclever_label_type_a_tl } { \l__zrefclever_ref_language_tl } @@ -3008,7 +3974,7 @@ { % It is the last label of its type, but also the first one, and that's % what matters here: just store it. - % Test: 'zc-typeset01.lvt': "Last of type: single" + % Test: `zc-typeset01.lvt': "Last of type: single" { 0 } { \tl_set:NV \l__zrefclever_type_first_label_tl @@ -3021,7 +3987,7 @@ } % The last is the second: we have a pair (if not repeated). - % Test: 'zc-typeset01.lvt': "Last of type: pair" + % Test: `zc-typeset01.lvt': "Last of type: pair" { 1 } { \int_compare:nNnTF { \l__zrefclever_range_same_count_int } = { 1 } @@ -3049,7 +4015,7 @@ \int_case:nnF { \l__zrefclever_range_count_int } { % There was no range going on. - % Test: 'zc-typeset01.lvt': "Last of type: not range" + % Test: `zc-typeset01.lvt': "Last of type: not range" { 0 } { \int_compare:nNnTF { \l__zrefclever_ref_count_int } < { 2 } @@ -3071,15 +4037,15 @@ } } % Last in the range is also the second in it. - % Test: 'zc-typeset01.lvt': "Last of type: pair in sequence" + % Test: `zc-typeset01.lvt': "Last of type: pair in sequence" { 1 } { \int_compare:nNnTF { \l__zrefclever_range_same_count_int } = { 1 } { - % We know `range_beg_label' is not empty, since this is the - % second element in the range, but the third or more in the - % type list. + % We know `range_beg_is_first_bool' is false, since this is + % the second element in the range, but the third or more in + % the type list. \tl_put_right:Nx \l__zrefclever_typeset_queue_curr_tl { \exp_not:V \l__zrefclever_pairsep_tl @@ -3115,13 +4081,13 @@ } { % Repetition, not a range. - % Test: 'zc-typeset01.lvt': "Last of type: range to one" + % Test: `zc-typeset01.lvt': "Last of type: range to one" { 0 } { - % If `range_beg_label' is empty, it means it was also the - % first of the type, and hence its typesetting was already - % handled, and we just have to set refbounds. - \tl_if_empty:VTF \l__zrefclever_range_beg_label_tl + % If `range_beg_is_first_bool' is true, it means it was also + % the first of the type, and hence its typesetting was + % already handled, and we just have to set refbounds. + \bool_if:NTF \l__zrefclever_range_beg_is_first_bool { \seq_set_eq:NN \l__zrefclever_type_first_refbounds_seq \l__zrefclever_refbounds_first_sg_seq @@ -3153,11 +4119,11 @@ } % A `range', but with no skipped value, treat as pair if range % started with first of type, otherwise as list. - % Test: 'zc-typeset01.lvt': "Last of type: range to pair" + % Test: `zc-typeset01.lvt': "Last of type: range to pair" { 1 } { % Ditto. - \tl_if_empty:VTF \l__zrefclever_range_beg_label_tl + \bool_if:NTF \l__zrefclever_range_beg_is_first_bool { \seq_set_eq:NN \l__zrefclever_type_first_refbounds_seq \l__zrefclever_refbounds_first_pb_seq @@ -3189,9 +4155,9 @@ } { % An actual range. - % Test: 'zc-typeset01.lvt': "Last of type: range" + % Test: `zc-typeset01.lvt': "Last of type: range" % Ditto. - \tl_if_empty:VTF \l__zrefclever_range_beg_label_tl + \bool_if:NTF \l__zrefclever_range_beg_is_first_bool { \seq_set_eq:NN \l__zrefclever_type_first_refbounds_seq \l__zrefclever_refbounds_first_rb_seq @@ -3225,11 +4191,30 @@ } } } - \tl_put_right:Nx \l__zrefclever_typeset_queue_curr_tl + \bool_lazy_and:nnTF + { ! \tl_if_empty_p:N \l__zrefclever_endrangefunc_tl } + { \cs_if_exist_p:c { \l__zrefclever_endrangefunc_tl :VVN } } { - \exp_not:V \l__zrefclever_rangesep_tl - \__zrefclever_get_ref:VN \l__zrefclever_label_a_tl - \l__zrefclever_refbounds_last_re_seq + \use:c { \l__zrefclever_endrangefunc_tl :VVN } + \l__zrefclever_range_beg_label_tl + \l__zrefclever_label_a_tl + \l__zrefclever_range_end_ref_tl + \tl_put_right:Nx \l__zrefclever_typeset_queue_curr_tl + { + \exp_not:V \l__zrefclever_rangesep_tl + \__zrefclever_get_ref_endrange:VVN + \l__zrefclever_label_a_tl + \l__zrefclever_range_end_ref_tl + \l__zrefclever_refbounds_last_re_seq + } + } + { + \tl_put_right:Nx \l__zrefclever_typeset_queue_curr_tl + { + \exp_not:V \l__zrefclever_rangesep_tl + \__zrefclever_get_ref:VN \l__zrefclever_label_a_tl + \l__zrefclever_refbounds_last_re_seq + } } } } @@ -3252,15 +4237,18 @@ } { \bool_set_false:N \l__zrefclever_next_maybe_range_bool - \zref@ifrefundefined { \l__zrefclever_type_first_label_tl } - { } + \bool_if:NT \l__zrefclever_rangetopair_bool { - \__zrefclever_labels_in_sequence:nn - { \l__zrefclever_type_first_label_tl } - { \l__zrefclever_label_a_tl } + \zref@ifrefundefined { \l__zrefclever_type_first_label_tl } + { } + { + \__zrefclever_labels_in_sequence:nn + { \l__zrefclever_type_first_label_tl } + { \l__zrefclever_label_a_tl } + } } - % Test: 'zc-typeset01.lvt': "Last of type: option range" - % Test: 'zc-typeset01.lvt': "Last of type: option range to pair" + % Test: `zc-typeset01.lvt': "Last of type: option range" + % Test: `zc-typeset01.lvt': "Last of type: option range to pair" \bool_if:NTF \l__zrefclever_next_maybe_range_bool { \tl_set:Nx \l__zrefclever_typeset_queue_curr_tl @@ -3274,11 +4262,34 @@ \bool_set_true:N \l__zrefclever_type_first_refbounds_set_bool } { - \tl_set:Nx \l__zrefclever_typeset_queue_curr_tl + \bool_lazy_and:nnTF + { ! \tl_if_empty_p:N \l__zrefclever_endrangefunc_tl } + { \cs_if_exist_p:c { \l__zrefclever_endrangefunc_tl :VVN } } { - \exp_not:V \l__zrefclever_rangesep_tl - \__zrefclever_get_ref:VN \l__zrefclever_label_a_tl - \l__zrefclever_refbounds_last_re_seq + % We must get `type_first_label_tl' instead of + % `range_beg_label_tl' here, since it is not necessary + % that the first of type was actually starting a range for + % the `range' option to be used. + \use:c { \l__zrefclever_endrangefunc_tl :VVN } + \l__zrefclever_type_first_label_tl + \l__zrefclever_label_a_tl + \l__zrefclever_range_end_ref_tl + \tl_set:Nx \l__zrefclever_typeset_queue_curr_tl + { + \exp_not:V \l__zrefclever_rangesep_tl + \__zrefclever_get_ref_endrange:VVN + \l__zrefclever_label_a_tl + \l__zrefclever_range_end_ref_tl + \l__zrefclever_refbounds_last_re_seq + } + } + { + \tl_set:Nx \l__zrefclever_typeset_queue_curr_tl + { + \exp_not:V \l__zrefclever_rangesep_tl + \__zrefclever_get_ref:VN \l__zrefclever_label_a_tl + \l__zrefclever_refbounds_last_re_seq + } } \seq_set_eq:NN \l__zrefclever_type_first_refbounds_seq \l__zrefclever_refbounds_first_rb_seq @@ -3308,7 +4319,7 @@ { \bool_if:NTF \l__zrefclever_typeset_ref_bool { - % Test: 'zc-typeset01.lvt': "Last of type: option typeset ref" + % Test: `zc-typeset01.lvt': "Last of type: option typeset ref" \tl_put_left:Nx \l__zrefclever_typeset_queue_curr_tl { \__zrefclever_get_ref:VN \l__zrefclever_type_first_label_tl @@ -3318,14 +4329,14 @@ { \bool_if:NTF \l__zrefclever_typeset_name_bool { - % Test: 'zc-typeset01.lvt': "Last of type: option typeset name" + % Test: `zc-typeset01.lvt': "Last of type: option typeset name" \tl_set:Nx \l__zrefclever_typeset_queue_curr_tl { \bool_if:NTF \l__zrefclever_name_in_link_bool { \exp_not:N \group_begin: \exp_not:V \l__zrefclever_namefont_tl - % It's two '@s', but escaped for DocStrip. + % It's two `@s', but escaped for DocStrip. \exp_not:N \hyper@@link { \__zrefclever_extract_url_unexp:V @@ -3352,7 +4363,7 @@ % it should not occur, given that the options are set up to % typeset either "ref" or "name". Still, leave here a % sensible fallback, equal to the behavior of "both". - % Test: 'zc-typeset01.lvt': "Last of type: option typeset none" + % Test: `zc-typeset01.lvt': "Last of type: option typeset none" \tl_put_left:Nx \l__zrefclever_typeset_queue_curr_tl { \__zrefclever_get_ref_first: } } @@ -3378,11 +4389,11 @@ \int_case:nnF { \l__zrefclever_type_count_int } { % Single type. - % Test: 'zc-typeset01.lvt': "Last of type: single type" + % Test: `zc-typeset01.lvt': "Last of type: single type" { 0 } { \l__zrefclever_typeset_queue_curr_tl } % Pair of types. - % Test: 'zc-typeset01.lvt': "Last of type: pair of types" + % Test: `zc-typeset01.lvt': "Last of type: pair of types" { 1 } { \l__zrefclever_tpairsep_tl @@ -3391,7 +4402,7 @@ } { % Last in list of types. - % Test: 'zc-typeset01.lvt': "Last of type: list of types" + % Test: `zc-typeset01.lvt': "Last of type: list of types" \l__zrefclever_tlastsep_tl \l__zrefclever_typeset_queue_curr_tl } @@ -3412,11 +4423,13 @@ \tl_clear:N \l__zrefclever_type_first_label_tl \tl_clear:N \l__zrefclever_type_first_label_type_tl \tl_clear:N \l__zrefclever_range_beg_label_tl + \tl_clear:N \l__zrefclever_range_end_ref_tl \int_zero:N \l__zrefclever_label_count_int \int_zero:N \l__zrefclever_ref_count_int \int_incr:N \l__zrefclever_type_count_int \int_zero:N \l__zrefclever_range_count_int \int_zero:N \l__zrefclever_range_same_count_int + \bool_set_false:N \l__zrefclever_range_beg_is_first_bool \bool_set_false:N \l__zrefclever_type_first_refbounds_set_bool } } @@ -3447,13 +4460,16 @@ \l__zrefclever_label_type_a_tl \int_incr:N \l__zrefclever_ref_count_int - % If the next label may be part of a range, we set `range_beg_label' - % to "empty" (we deal with it as the "first", and must do it there, to - % handle hyperlinking), but also step the range counters. - % Test: 'zc-typeset01.lvt': "Not last of type: first is range" + % If the next label may be part of a range, signal it (we deal with it + % as the "first", and must do it there, to handle hyperlinking), but + % also step the range counters. + % Test: `zc-typeset01.lvt': "Not last of type: first is range" \bool_if:NT \l__zrefclever_next_maybe_range_bool { - \tl_clear:N \l__zrefclever_range_beg_label_tl + \bool_set_true:N \l__zrefclever_range_beg_is_first_bool + \tl_set:NV \l__zrefclever_range_beg_label_tl + \l__zrefclever_label_a_tl + \tl_clear:N \l__zrefclever_range_end_ref_tl \int_incr:N \l__zrefclever_range_count_int \bool_if:NT \l__zrefclever_next_is_same_bool { \int_incr:N \l__zrefclever_range_same_count_int } @@ -3470,6 +4486,7 @@ % There was no range going, we are starting one. \tl_set:NV \l__zrefclever_range_beg_label_tl \l__zrefclever_label_a_tl + \tl_clear:N \l__zrefclever_range_end_ref_tl \int_incr:N \l__zrefclever_range_count_int \bool_if:NT \l__zrefclever_next_is_same_bool { \int_incr:N \l__zrefclever_range_same_count_int } @@ -3487,7 +4504,7 @@ \int_case:nnF { \l__zrefclever_range_count_int } { % There was no range going on. - % Test: 'zc-typeset01.lvt': "Not last of type: no range" + % Test: `zc-typeset01.lvt': "Not last of type: no range" { 0 } { \int_incr:N \l__zrefclever_ref_count_int @@ -3501,11 +4518,11 @@ % Last is second in the range: if `range_same_count' is also % `1', it's a repetition (drop it), otherwise, it's a "pair % within a list", treat as list. - % Test: 'zc-typeset01.lvt': "Not last of type: range pair to one" - % Test: 'zc-typeset01.lvt': "Not last of type: range pair" + % Test: `zc-typeset01.lvt': "Not last of type: range pair to one" + % Test: `zc-typeset01.lvt': "Not last of type: range pair" { 1 } { - \tl_if_empty:VTF \l__zrefclever_range_beg_label_tl + \bool_if:NTF \l__zrefclever_range_beg_is_first_bool { \seq_set_eq:NN \l__zrefclever_type_first_refbounds_seq \l__zrefclever_refbounds_first_seq @@ -3547,10 +4564,10 @@ \l__zrefclever_range_same_count_int } { - % Test: 'zc-typeset01.lvt': "Not last of type: range to one" + % Test: `zc-typeset01.lvt': "Not last of type: range to one" { 0 } { - \tl_if_empty:VTF \l__zrefclever_range_beg_label_tl + \bool_if:NTF \l__zrefclever_range_beg_is_first_bool { \seq_set_eq:NN \l__zrefclever_type_first_refbounds_seq @@ -3569,10 +4586,10 @@ } } } - % Test: 'zc-typeset01.lvt': "Not last of type: range to pair" + % Test: `zc-typeset01.lvt': "Not last of type: range to pair" { 1 } { - \tl_if_empty:VTF \l__zrefclever_range_beg_label_tl + \bool_if:NTF \l__zrefclever_range_beg_is_first_bool { \seq_set_eq:NN \l__zrefclever_type_first_refbounds_seq @@ -3600,8 +4617,8 @@ } } { - % Test: 'zc-typeset01.lvt': "Not last of type: range" - \tl_if_empty:VTF \l__zrefclever_range_beg_label_tl + % Test: `zc-typeset01.lvt': "Not last of type: range" + \bool_if:NTF \l__zrefclever_range_beg_is_first_bool { \seq_set_eq:NN \l__zrefclever_type_first_refbounds_seq @@ -3620,15 +4637,34 @@ } } % For the purposes of the serial comma, and thus for the - % distinction of 'lastsep' and 'pairsep', a "range" counts - % as one. Since 'range_beg' has already been counted + % distinction of `lastsep' and `pairsep', a "range" counts + % as one. Since `range_beg' has already been counted % (here or with the first of type), we refrain from - % incrementing 'ref_count_int'. - \tl_put_right:Nx \l__zrefclever_typeset_queue_curr_tl + % incrementing `ref_count_int'. + \bool_lazy_and:nnTF + { ! \tl_if_empty_p:N \l__zrefclever_endrangefunc_tl } + { \cs_if_exist_p:c { \l__zrefclever_endrangefunc_tl :VVN } } { - \exp_not:V \l__zrefclever_rangesep_tl - \__zrefclever_get_ref:VN \l__zrefclever_label_a_tl - \l__zrefclever_refbounds_mid_re_seq + \use:c { \l__zrefclever_endrangefunc_tl :VVN } + \l__zrefclever_range_beg_label_tl + \l__zrefclever_label_a_tl + \l__zrefclever_range_end_ref_tl + \tl_put_right:Nx \l__zrefclever_typeset_queue_curr_tl + { + \exp_not:V \l__zrefclever_rangesep_tl + \__zrefclever_get_ref_endrange:VVN + \l__zrefclever_label_a_tl + \l__zrefclever_range_end_ref_tl + \l__zrefclever_refbounds_mid_re_seq + } + } + { + \tl_put_right:Nx \l__zrefclever_typeset_queue_curr_tl + { + \exp_not:V \l__zrefclever_rangesep_tl + \__zrefclever_get_ref:VN \l__zrefclever_label_a_tl + \l__zrefclever_refbounds_mid_re_seq + } } } } @@ -3685,6 +4721,45 @@ { \__zrefclever_ref_default: } } \cs_generate_variant:Nn \__zrefclever_get_ref:nN { VN } +\cs_new:Npn \__zrefclever_get_ref_endrange:nnN #1#2#3 + { + \str_if_eq:nnTF {#2} { zc@missingproperty } + { \__zrefclever_ref_default: } + { + \bool_if:nTF + { + \l__zrefclever_hyperlink_bool && + ! \l__zrefclever_link_star_bool + } + { + \exp_not:N \group_begin: + \exp_not:V \l__zrefclever_reffont_tl + \seq_item:Nn #3 { 1 } + % It's two `@s', but escaped for DocStrip. + \exp_not:N \hyper@@link + { \__zrefclever_extract_url_unexp:n {#1} } + { \__zrefclever_extract_unexp:nnn {#1} { anchor } { } } + { + \seq_item:Nn #3 { 2 } + \exp_not:n {#2} + \seq_item:Nn #3 { 3 } + } + \seq_item:Nn #3 { 4 } + \exp_not:N \group_end: + } + { + \exp_not:N \group_begin: + \exp_not:V \l__zrefclever_reffont_tl + \seq_item:Nn #3 { 1 } + \seq_item:Nn #3 { 2 } + \exp_not:n {#2} + \seq_item:Nn #3 { 3 } + \seq_item:Nn #3 { 4 } + \exp_not:N \group_end: + } + } + } +\cs_generate_variant:Nn \__zrefclever_get_ref_endrange:nnN { VVN } \cs_new:Npn \__zrefclever_get_ref_first: { \zref@ifrefundefined { \l__zrefclever_type_first_label_tl } @@ -3764,7 +4839,7 @@ \exp_not:V \l__zrefclever_reffont_tl \seq_item:Nn \l__zrefclever_type_first_refbounds_seq { 1 } - % It's two '@s', but escaped for DocStrip. + % It's two `@s', but escaped for DocStrip. \exp_not:N \hyper@@link { \__zrefclever_extract_url_unexp:V @@ -4052,14 +5127,9 @@ \cs_generate_variant:Nn \__zrefclever_extract_url_unexp:n { V } \cs_new_protected:Npn \__zrefclever_labels_in_sequence:nn #1#2 { - \__zrefclever_extract_default:Nnnn \l__zrefclever_label_extdoc_a_tl - {#1} { externaldocument } { } - \__zrefclever_extract_default:Nnnn \l__zrefclever_label_extdoc_b_tl - {#2} { externaldocument } { } - - \tl_if_eq:NNT - \l__zrefclever_label_extdoc_a_tl - \l__zrefclever_label_extdoc_b_tl + \exp_args:Nxx \tl_if_eq:nnT + { \__zrefclever_extract_unexp:nnn {#1} { externaldocument } { } } + { \__zrefclever_extract_unexp:nnn {#2} { externaldocument } { } } { \tl_if_eq:NnTF \l__zrefclever_ref_property_tl { page } { @@ -4104,8 +5174,6 @@ = { \__zrefclever_extract:nnn {#2} { zc@cntval } { -1 } } { - \bool_set_true:N - \l__zrefclever_next_maybe_range_bool \exp_args:Nxx \tl_if_eq:nnT { \__zrefclever_extract_unexp:nvn {#1} @@ -4117,6 +5185,8 @@ } { \bool_set_true:N + \l__zrefclever_next_maybe_range_bool + \bool_set_true:N \l__zrefclever_next_is_same_bool } } @@ -4424,6 +5494,7 @@ \cs_new_eq:NN \__zrefclever_orig_ltxlabel:n \ltx@label \cs_set_eq:NN \ltx@label \__zrefclever_ltxlabel:n } + \bool_new:N \l__zrefclever_amsmath_subequations_bool \AddToHook { env / subequations / begin } { \__zrefclever_zcsetup:x @@ -4437,7 +5508,9 @@ currentcounter = parentequation , countertype = { parentequation = equation } , } + \bool_set_true:N \l__zrefclever_amsmath_subequations_bool } + \zref@newprop { subeq } { \alph { equation } } \clist_map_inline:nn { equation , @@ -4457,7 +5530,11 @@ } { \AddToHook { env / #1 / begin } - { \__zrefclever_zcsetup:n { currentcounter = equation } } + { + \__zrefclever_zcsetup:n { currentcounter = equation } + \bool_if:NT \l__zrefclever_amsmath_subequations_bool + { \zref@localaddprop \ZREF@mainlist { subeq } } + } } \zcRefTypeSetup { equation } { reffont = \upshape } @@ -4504,6 +5581,7 @@ { \__zrefclever_if_package_loaded:nT { breqn } { + \bool_new:N \l__zrefclever_breqn_dgroup_bool \AddToHook { env / dgroup / begin } { \__zrefclever_zcsetup:x @@ -4517,7 +5595,11 @@ currentcounter = parentequation , countertype = { parentequation = equation } , } + \bool_set_true:N \l__zrefclever_breqn_dgroup_bool } + \zref@ifpropundefined { subeq } + { \zref@newprop { subeq } { \alph { equation } } } + { } \clist_map_inline:nn { dmath , @@ -4526,7 +5608,11 @@ } { \AddToHook { env / #1 / begin } - { \__zrefclever_zcsetup:n { currentcounter = equation } } + { + \__zrefclever_zcsetup:n { currentcounter = equation } + \bool_if:NT \l__zrefclever_breqn_dgroup_bool + { \zref@localaddprop \ZREF@mainlist { subeq } } + } } \msg_info:nnn { zref-clever } { compat-package } { breqn } } |