diff options
author | Karl Berry <karl@freefriends.org> | 2021-08-05 20:47:40 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-08-05 20:47:40 +0000 |
commit | eda08b76ad9d0ad91675a9e563c8c478df9af77a (patch) | |
tree | e86e02f996fe19e803fbb484b029dfc53cbb7912 /Master/texmf-dist/tex/latex/zref-check | |
parent | d728f6878800a22105df3da9d37de7d1cc0f0bcb (diff) |
zref-check (5aug21)
git-svn-id: svn://tug.org/texlive/trunk@60171 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/zref-check')
-rw-r--r-- | Master/texmf-dist/tex/latex/zref-check/zref-check.sty | 962 |
1 files changed, 962 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/zref-check/zref-check.sty b/Master/texmf-dist/tex/latex/zref-check/zref-check.sty new file mode 100644 index 00000000000..72e8a2f8784 --- /dev/null +++ b/Master/texmf-dist/tex/latex/zref-check/zref-check.sty @@ -0,0 +1,962 @@ +%% +%% This is file `zref-check.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% zref-check.dtx (with options: `package') +%% +%% This file was generated from file(s) of the LaTeX package "zref-check". +%% +%% Copyright (C) 2021 Gustavo Barros +%% +%% It may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in the file: +%% +%% https://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Gustavo Barros. +%% +%% This work consists of the files zref-check.dtx, +%% zref-check.ins, +%% zref-check.tex, +%% zref-check-code.tex, +%% and the derived files zref-check.sty and +%% zref-check.pdf, +%% zref-check-code.pdf. +%% +%% The released version of this package is available from CTAN. +%% +%% ----------------------------------------------------------------------- +%% +%% The development version of the package can be found at +%% +%% https://github.com/gusbrs/zref-check +%% +%% for those people who are interested. +%% +%% ----------------------------------------------------------------------- +%% +\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} +\IfFormatAtLeastTF{2021-06-01} + {} + {% + \PackageError{zref-check}{LaTeX kernel too old} + {% + 'zref-check' requires a LaTeX kernel newer than 2021-06-01.% + \MessageBreak Loading will abort!% + }% + \endinput + }% +\ProvidesExplPackage {zref-check} {2021-08-04} {0.1.0} + {Flexible cross-references with contextual checks based on zref} +\RequirePackage { zref-user } +\RequirePackage { zref-abspage } +\RequirePackage { ifdraft } +\int_new:N \g__zrefcheck_abschap_int +\int_new:N \g__zrefcheck_abssec_int +\AddToHook { cmd / chapter / before } + { + \int_gincr:N \g__zrefcheck_abschap_int + \int_zero:N \g__zrefcheck_abssec_int + } +\zref@newprop { abschap } [0] { \int_use:N \g__zrefcheck_abschap_int } +\zref@addprop \ZREF@mainlist { abschap } +\AddToHook { cmd / section / before } + { \int_gincr:N \g__zrefcheck_abssec_int } +\zref@newprop { abssec } [0] { \int_use:N \g__zrefcheck_abssec_int } +\zref@addprop \ZREF@mainlist { abssec } +\zref@newlist { zrefcheck } +\zref@addprops { zrefcheck } + { + abspage , + abschap , + abssec , + page + } +\cs_new:Npn \__zrefcheck_message:nnnn #1#2#3#4 + { + \use:c { msg_ \l__zrefcheck_msglevel_tl :nnnnn } + { zref-check } {#1} {#2} {#3} {#4} + } +\cs_generate_variant:Nn \__zrefcheck_message:nnnn { nnnx } +\msg_new:nnn { zref-check } { check-failed } + { + Failed~check~'#1'~for~label~'#2' \iow_newline: + on~page~#3~on~input~line~\msg_line_number:. + } +\msg_new:nnn { zref-check } { double-check } + { + Double-check~'#1'~for~label~'#2' \iow_newline: + on~page~#3~on~input~line~\msg_line_number:. + } +\msg_new:nnn { zref-check } { check-missing } + { Check~'#1'~not~defined~on~input~line~\msg_line_number:. } +\msg_new:nnn { zref-check } { property-undefined } + { Property~'#1'~not~defined~on~input~line~\msg_line_number:. } +\msg_new:nnn { zref-check } { property-not-in-label } + { Label~'#1'~has~no~property~'#2'~on~input~line~\msg_line_number:. } +\msg_new:nnn { zref-check } { property-not-integer } + { + Property~'#1'~for~label~'#2'~not~an~integer \iow_newline: + on~input~line~\msg_line_number:. + } +\msg_new:nnn { zref-check } { hyperref-preamble-only } + { + Option~'hyperref'~only~available~in~the~preamble. \iow_newline: + Use~the~starred~version~of~'\noexpand\zcheck'~instead. + } +\msg_new:nnn { zref-check } { missing-hyperref } + { Missing~'hyperref'~package. \iow_newline: Setting~'hyperref=false'. } +\msg_new:nnn { zref-check } { ignore-document-only } + { + Option~'ignore'~only~available~in~the~document. \iow_newline: + Use~option~'msglevel'~instead. + } +\msg_new:nnn { zref-check } { option-preamble-only } + { + Option~'#1'~only~available~in~the~preamble \iow_newline: + on~input~line~\msg_line_number:. + } +\msg_new:nnn { zref-check } { closerange-not-positive-integer } + { + Option~'closerange'~not~a~positive~integer \iow_newline: + on~input~line~\msg_line_number:.~Using~default~value. + } +\msg_new:nnn { zref-check } { labelcmd-undefined } + { + Control~sequence~named~'#1'~used~in~option~'labelcmd'~is~not~defined.~ + Using~default~value. + } +\cs_new_eq:NN \__zrefcheck_int_to_roman:w \__int_to_roman:w +\prg_new_conditional:Npnn \__zrefcheck_is_integer:n #1 { p, T , F , TF } + { + \tl_if_empty:oTF {#1} + { \prg_return_false: } + { + \tl_if_empty:oTF { \__zrefcheck_int_to_roman:w -0#1 } + { \prg_return_true: } + { \prg_return_false: } + } + } +\prg_new_protected_conditional:Npnn \__zrefcheck_is_integer_rgx:n #1 { TF } + { + \regex_match:nnTF { \A\d+\Z } {#1} + { \prg_return_true: } + { \prg_return_false: } + } +\bool_new:N \l__zrefcheck_use_hyperref_bool +\bool_new:N \l__zrefcheck_warn_hyperref_bool +\keys_define:nn { zref-check } + { + hyperref .choice: , + hyperref / auto .code:n = + { + \bool_set_true:N \l__zrefcheck_use_hyperref_bool + \bool_set_false:N \l__zrefcheck_warn_hyperref_bool + } , + hyperref / true .code:n = + { + \bool_set_true:N \l__zrefcheck_use_hyperref_bool + \bool_set_true:N \l__zrefcheck_warn_hyperref_bool + } , + hyperref / false .code:n = + { + \bool_set_false:N \l__zrefcheck_use_hyperref_bool + \bool_set_false:N \l__zrefcheck_warn_hyperref_bool + } , + hyperref .initial:n = auto , + hyperref .default:n = auto + } +\AtBeginDocument + { + \@ifpackageloaded { hyperref } + { + \bool_if:NT \l__zrefcheck_use_hyperref_bool + { + \RequirePackage { zref-hyperref } + \zref@addprop { zrefcheck } { anchor } + } + } + { + \bool_if:NT \l__zrefcheck_warn_hyperref_bool + { \msg_warning:nn { zref-check } { missing-hyperref } } + \bool_set_false:N \l__zrefcheck_use_hyperref_bool + } + \keys_define:nn { zref-check } + { + hyperref .code:n = + { \msg_warning:nn { zref-check } { hyperref-preamble-only } } + } + } +\tl_new:N \l__zrefcheck_msglevel_tl +\keys_define:nn { zref-check } + { + msglevel .choice: , + msglevel / warn .code:n = + { \tl_set:Nn \l__zrefcheck_msglevel_tl { warning } } , + msglevel / info .code:n = + { \tl_set:Nn \l__zrefcheck_msglevel_tl { info } } , + msglevel / none .code:n = + { \tl_set:Nn \l__zrefcheck_msglevel_tl { none } } , + msglevel / obeydraft .code:n = + { + \ifdraft + { \tl_set:Nn \l__zrefcheck_msglevel_tl { info } } + { \tl_set:Nn \l__zrefcheck_msglevel_tl { warning } } + } , + msglevel / obeyfinal .code:n = + { + \ifoptionfinal + { \tl_set:Nn \l__zrefcheck_msglevel_tl { warning } } + { \tl_set:Nn \l__zrefcheck_msglevel_tl { info } } + } , + msglevel .value_required:n = true , + msglevel .initial:n = warn , + ignore .code:n = + { \msg_warning:nn { zref-check } { ignore-document-only } } , + ignore .value_forbidden:n = true + } +\AtBeginDocument + { + \keys_define:nn { zref-check } + { ignore .meta:n = { msglevel = none } } + } +\bool_new:N \l__zrefcheck_msgonpage_bool +\keys_define:nn { zref-check } + { + onpage .choice: , + onpage / labelseq .code:n = + { + \bool_set_false:N \l__zrefcheck_msgonpage_bool + } , + onpage / msg .code:n = + { + \bool_set_true:N \l__zrefcheck_msgonpage_bool + } , + onpage / obeydraft .code:n = + { + \ifdraft + { \bool_set_false:N \l__zrefcheck_msgonpage_bool } + { \bool_set_true:N \l__zrefcheck_msgonpage_bool } + } , + onpage / obeyfinal .code:n = + { + \ifoptionfinal + { \bool_set_true:N \l__zrefcheck_msgonpage_bool } + { \bool_set_false:N \l__zrefcheck_msgonpage_bool } + } , + onpage .value_required:n = true , + onpage .initial:n = labelseq + } +\int_new:N \l__zrefcheck_close_range_int +\keys_define:nn { zref-check } + { + closerange .code:n = + { + \__zrefcheck_is_integer_rgx:nTF {#1} + { \int_set:Nn \l__zrefcheck_close_range_int { \int_eval:n {#1} } } + { + \msg_warning:nn { zref-check } { closerange-not-positive-integer } + \int_set:Nn \l__zrefcheck_close_range_int { 5 } + } + } , + closerange .value_required:n = true , + closerange .initial:n = 5 + } +\tl_new:N \l__zrefcheck_target_label_tl +\bool_new:N \l__zrefcheck_target_label_bool +\keys_define:nn { zref-check } + { + labelcmd .code:n = + { + \tl_set:Nn \l__zrefcheck_target_label_tl {#1} + \bool_set_true:N \l__zrefcheck_target_label_bool + } , + labelcmd .value_required:n = true , + } +\cs_new:Npn \__zrefcheck_target_label:n #1 + { \zref@labelbylist {#1} { zrefcheck } } +\AtBeginDocument + { + \bool_if:NT \l__zrefcheck_target_label_bool + { + \tl_if_blank:VT \l__zrefcheck_target_label_tl + { \tl_clear:N \l__zrefcheck_target_label_tl } + \cs_if_exist:cTF { \l__zrefcheck_target_label_tl } + { + \cs_set:Npx \__zrefcheck_target_label:n #1 + { + \exp_not:o + { \cs:w \l__zrefcheck_target_label_tl \cs_end: } + {#1} + } + } + { + \exp_args:NnnV \msg_warning:nnn { zref-check } + { labelcmd-undefined } { \l__zrefcheck_target_label_tl } + } + } + \keys_define:nn { zref-check } + { + labelcmd .code:n = + { + \msg_warning:nnn { zref-check } + { option-preamble-only } { labelcmd } + } + } + } +\RequirePackage { l3keys2e } +\ProcessKeysOptions { zref-check } +\NewDocumentCommand \zrefchecksetup { m } + { \keys_set:nn { zref-check } {#1} } +\prop_new:N \g__zrefcheck_auxfile_lblseq_prop +\tl_set:Nn \g_tmpa_tl { \c_sys_jobname_str .aux } +\file_if_exist:nT { \g_tmpa_tl } + { + \ior_open:Nn \g_tmpa_ior { \g_tmpa_tl } + \group_begin: + \int_zero:N \l_tmpa_int + \tl_clear:N \l_tmpa_tl + \tl_clear:N \l_tmpb_tl + \bool_set_false:N \l_tmpa_bool + \ior_map_variable:NNn \g_tmpa_ior \l_tmpa_tl + { + \tl_map_variable:NNn \l_tmpa_tl \l_tmpb_tl + { + \tl_if_eq:NnTF \l_tmpb_tl { \zref@newlabel } + { + \bool_set_true:N \l_tmpa_bool + } + { + \bool_if:NTF \l_tmpa_bool + { + \bool_set_false:N \l_tmpa_bool + \int_incr:N \l_tmpa_int + \prop_gput:Nxx \g__zrefcheck_auxfile_lblseq_prop + { \l_tmpb_tl } { \int_use:N \l_tmpa_int } + } + { + \tl_map_break: + } + } + } + } + \group_end: + \ior_close:N \g_tmpa_ior + } +\begingroup + \let \@addtoreset \ltx@gobbletwo + \newcounter { zrefcheck } +\endgroup +\setcounter { zrefcheck } { 0 } +\cs_new:Npn \__zrefcheck_check_lblfmt:n #1 { zrefcheck@ \int_use:N #1 } +\cs_new:Npn \__zrefcheck_end_lblfmt:n #1 { #1 @zrefcheck } +\cs_new:Npn \zrefcheck_get_astl:nnn #1#2#3 + { + \tl_clear:N #3 + \tl_if_eq:nnTF {#2} { lblseq } + { + \prop_get:NnNF \g__zrefcheck_auxfile_lblseq_prop {#1} #3 + { + \msg_warning:nnnn { zref-check } + { property-not-in-label } {#1} {#2} + } + } + { + \zref@ifrefundefined {#1} + {} + { + \zref@ifpropundefined {#2} + { \msg_warning:nnnn { zref-check } { property-undefined } {#2} } + { + \zref@ifrefcontainsprop {#1} {#2} + { + \tl_set:Nx #3 + { \zref@extractdefault {#1} {#2} { \c_empty_tl } } + } + { + \msg_warning:nnnn + { zref-check } { property-not-in-label } {#1} {#2} + } + } + } + } + } +\bool_new:N \l__zrefcheck_integer_bool +\tl_new:N \l__zrefcheck_propval_tl +\cs_new:Npn \zrefcheck_get_asint:nnn #1#2#3 + { + \zrefcheck_get_astl:nnn {#1} {#2} { \l__zrefcheck_propval_tl } + \__zrefcheck_is_integer:nTF { \l__zrefcheck_propval_tl } + { + \int_set:Nn #3 { \int_eval:n { \l__zrefcheck_propval_tl } } + } + { + \bool_set_false:N \l__zrefcheck_integer_bool + \zref@ifrefundefined {#1} + { } + { + \msg_warning:nnnn { zref-check } + { property-not-integer } {#2} {#1} + } + } + } +\NewDocumentCommand \zcheck + { s O { } > { \SplitList { , } } m > { \SplitList { , } } O { } m } + { \zref@wrapper@babel \__zrefcheck_zcheck:nnnnn {#3} {#1} {#2} {#4} {#5} } +\int_new:N \g__zrefcheck_id_int +\tl_new:N \l__zrefcheck_checkbeg_tl +\tl_new:N \l__zrefcheck_checkend_tl +\tl_new:N \l__zrefcheck_link_label_tl +\tl_new:N \l__zrefcheck_link_anchor_tl +\bool_new:N \l__zrefcheck_link_star_tl +\cs_new:Npn \__zrefcheck_zcheck:nnnnn #1#2#3#4#5 + { + \group_begin: + \keys_set:nn { zref-check } {#3} + \int_gincr:N \g__zrefcheck_id_int + \tl_set:Nx \l__zrefcheck_checkbeg_tl + { \__zrefcheck_check_lblfmt:n { \g__zrefcheck_id_int } } + \tl_set:Nx \l__zrefcheck_checkend_tl + { \__zrefcheck_end_lblfmt:n { \l__zrefcheck_checkbeg_tl } } + \zref@labelbylist { \l__zrefcheck_checkbeg_tl } { zrefcheck } + \tl_set:Nn \l__zrefcheck_link_label_tl { \tl_head:n {#1} } + \bool_set:Nn \l__zrefcheck_link_star_tl {#2} + \zref@ifrefundefined { \l__zrefcheck_link_label_tl } + {#5} + { + \bool_if:nTF + { + \l__zrefcheck_use_hyperref_bool && + ! \l__zrefcheck_link_star_tl + } + { + \exp_args:Nx \zrefcheck_get_astl:nnn + { \l__zrefcheck_link_label_tl } + { anchor } { \l__zrefcheck_link_anchor_tl } + \hyperlink { \l__zrefcheck_link_anchor_tl } {#5} + } + {#5} + } + \zref@labelbylist { \l__zrefcheck_checkend_tl } { zrefcheck } + \tl_map_function:nN {#1} \zref@refused + \__zrefcheck_run_checks:nnV {#4} {#1} { \l__zrefcheck_checkbeg_tl } + \group_end: + } +\NewDocumentCommand \zctarget { m +m } + { + \group_begin: + \refstepcounter { zrefcheck } + \zref@wrapper@babel \__zrefcheck_target_label:n {#1} + #2 + \zref@wrapper@babel + \zref@labelbylist { \__zrefcheck_end_lblfmt:n {#1} } { zrefcheck } + \group_end: + } +\NewDocumentEnvironment {zcregion} { m } + { + \refstepcounter { zrefcheck } + \zref@wrapper@babel \__zrefcheck_target_label:n {#1} + } + { + \zref@wrapper@babel + \zref@labelbylist { \__zrefcheck_end_lblfmt:n {#1} } { zrefcheck } + } +\cs_new:Npn \__zrefcheck_run_checks:nnn #1#2#3 + { + \group_begin: + \tl_map_inline:nn {#2} + { + \tl_map_inline:nn {#1} + { \__zrefcheck_do_check:nnn {####1} {##1} {#3} } + } + \group_end: + } +\cs_generate_variant:Nn \__zrefcheck_run_checks:nnn { nnV } +\bool_new:N \l__zrefcheck_passedcheck_bool +\bool_new:N \l__zrefcheck_onpage_bool +\seq_new:N \c__zrefcheck_onpage_checks_seq +\seq_set_from_clist:Nn \c__zrefcheck_onpage_checks_seq + { above , below , before , after } +\cs_generate_variant:Nn \exp_args:Nnno { Nnoo } +\cs_new:Npn \__zrefcheck_do_check:nnn #1#2#3 + { + \group_begin: + \zref@ifrefundefined {#2} + {} + { + \tl_if_empty:nF {#1} + { + \bool_set_true:N \l__zrefcheck_passedcheck_bool + \bool_set_false:N \l__zrefcheck_onpage_bool + \cs_if_exist:cTF { __zrefcheck_check_ #1 :nnF } + { + \use:c { __zrefcheck_check_ #1 :nnF } + {#2} {#3} + { \bool_set_false:N \l__zrefcheck_passedcheck_bool } + \exp_args:Nnno \use:c { __zrefcheck_check_ #1 :nnF } + {#2} { \__zrefcheck_end_lblfmt:n {#3} } + { \bool_set_false:N \l__zrefcheck_passedcheck_bool } + \zref@ifrefundefined { \__zrefcheck_end_lblfmt:n {#2} } + {} + { + \exp_args:Nno \use:c { __zrefcheck_check_ #1 :nnF } + { \__zrefcheck_end_lblfmt:n {#2} } {#3} + { \bool_set_false:N \l__zrefcheck_passedcheck_bool } + \exp_args:Nnoo \use:c { __zrefcheck_check_ #1 :nnF } + { \__zrefcheck_end_lblfmt:n {#2} } + { \__zrefcheck_end_lblfmt:n {#3} } + { \bool_set_false:N \l__zrefcheck_passedcheck_bool } + } + \seq_if_in:NnT \c__zrefcheck_onpage_checks_seq {#1} + { + \__zrefcheck_check_thispage:nnT + {#2} {#3} + { \bool_set_true:N \l__zrefcheck_onpage_bool } + \__zrefcheck_check_thispage:nnT + {#2} { \__zrefcheck_end_lblfmt:n {#3} } + { \bool_set_true:N \l__zrefcheck_onpage_bool } + \zref@ifrefundefined { \__zrefcheck_end_lblfmt:n {#2} } + {} + { + \__zrefcheck_check_thispage:nnT + { \__zrefcheck_end_lblfmt:n {#2} } {#3} + { \bool_set_true:N \l__zrefcheck_onpage_bool } + \__zrefcheck_check_thispage:nnT + { \__zrefcheck_end_lblfmt:n {#2} } + { \__zrefcheck_end_lblfmt:n {#3} } + { \bool_set_true:N \l__zrefcheck_onpage_bool } + } + } + \bool_if:NTF \l__zrefcheck_passedcheck_bool + { + \bool_if:nT + { + \l__zrefcheck_msgonpage_bool && + \l__zrefcheck_onpage_bool + } + { + \__zrefcheck_message:nnnx { double-check } {#1} {#2} + { \zref@extractdefault {#3} {page} {'unknown'} } + } + } + { + \__zrefcheck_message:nnnx { check-failed } {#1} {#2} + { \zref@extractdefault {#3} {page} {'unknown'} } + } + } + { \msg_warning:nnn { zref-check } { check-missing } {#1} } + } + } + \group_end: + } +\int_new:N \l__zrefcheck_lbl_int +\int_new:N \l__zrefcheck_ref_int +\int_new:N \l__zrefcheck_lbl_b_int +\int_new:N \l__zrefcheck_ref_b_int +\prg_new_conditional:Npnn \__zrefcheck_check_thispage:nn #1#2 { T , F , TF } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abspage } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abspage } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_above:nn #1#2 { F , TF } + { + \group_begin: + \__zrefcheck_check_thispage:nnTF {#1} {#2} + { + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { lblseq } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { lblseq } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } < { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_below:nn #1#2 { F , TF } + { + \__zrefcheck_check_thispage:nnTF {#1} {#2} + { + \__zrefcheck_check_above:nnTF {#1} {#2} + { \prg_return_false: } + { \prg_return_true: } + } + { \prg_return_false: } + } +\prg_new_conditional:Npnn \__zrefcheck_check_before:nn #1#2 { F } + { + \__zrefcheck_check_pagesbefore:nnTF {#1} {#2} + { \prg_return_true: } + { + \__zrefcheck_check_above:nnTF {#1} {#2} + { \prg_return_true: } + { \prg_return_false: } + } + } +\prg_new_conditional:Npnn \__zrefcheck_check_after:nn #1#2 { F } + { + \__zrefcheck_check_pagesafter:nnTF {#1} {#2} + { \prg_return_true: } + { + \__zrefcheck_check_below:nnTF {#1} {#2} + { \prg_return_true: } + { \prg_return_false: } + } + } +\prg_new_conditional:Npnn \__zrefcheck_check_nextpage:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abspage } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abspage } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int + 1 } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_prevpage:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abspage } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abspage } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int - 1 } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_pagesbefore:nn #1#2 { F , TF } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abspage } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abspage } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } < { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\cs_new_eq:NN \__zrefcheck_check_ppbefore:nnF \__zrefcheck_check_pagesbefore:nnF +\prg_new_conditional:Npnn \__zrefcheck_check_pagesafter:nn #1#2 { F , TF } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abspage } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abspage } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } > { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\cs_new_eq:NN \__zrefcheck_check_ppafter:nnF \__zrefcheck_check_pagesafter:nnF +\prg_new_conditional:Npnn \__zrefcheck_check_facing:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abspage } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abspage } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \legacy_if_p:n { @twoside } && + ( + ( + \int_if_odd_p:n { \l__zrefcheck_ref_int } && + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int - 1 } + ) || + ( + \int_if_even_p:n { \l__zrefcheck_ref_int } && + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int + 1 } + ) + ) && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_close:nn #1#2 { F , TF } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abspage } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abspage } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \int_abs:n { \l__zrefcheck_lbl_int - \l__zrefcheck_ref_int } } + < + { \l__zrefcheck_close_range_int + 1 } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_far:nn #1#2 { F } + { + \__zrefcheck_check_close:nnTF {#1} {#2} + { \prg_return_false: } + { \prg_return_true: } + } +\prg_new_conditional:Npnn \__zrefcheck_check_thischap:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_nextchap:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int + 1 } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_prevchap:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int - 1 } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_chapsafter:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } > { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_chapsbefore:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } < { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_thissec:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abssec } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abssec } { \l__zrefcheck_ref_int } + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_b_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_b_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_b_int } = { \l__zrefcheck_ref_b_int } && + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_nextsec:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abssec } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abssec } { \l__zrefcheck_ref_int } + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_b_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_b_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_b_int } = { \l__zrefcheck_ref_b_int } && + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int + 1 } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_prevsec:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abssec } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abssec } { \l__zrefcheck_ref_int } + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_b_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_b_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_b_int } = { \l__zrefcheck_ref_b_int } && + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } = { \l__zrefcheck_ref_int - 1 } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_secsafter:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abssec } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abssec } { \l__zrefcheck_ref_int } + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_b_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_b_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_b_int } = { \l__zrefcheck_ref_b_int } && + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } > { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +\prg_new_conditional:Npnn \__zrefcheck_check_secsbefore:nn #1#2 { F } + { + \group_begin: + \bool_set_true:N \l__zrefcheck_integer_bool + \zrefcheck_get_asint:nnn {#1} { abssec } { \l__zrefcheck_lbl_int } + \zrefcheck_get_asint:nnn {#2} { abssec } { \l__zrefcheck_ref_int } + \zrefcheck_get_asint:nnn {#1} { abschap } { \l__zrefcheck_lbl_b_int } + \zrefcheck_get_asint:nnn {#2} { abschap } { \l__zrefcheck_ref_b_int } + \bool_lazy_and:nnTF + { \l__zrefcheck_integer_bool } + { + \int_compare_p:nNn + { \l__zrefcheck_lbl_b_int } = { \l__zrefcheck_ref_b_int } && + \int_compare_p:nNn + { \l__zrefcheck_lbl_int } < { \l__zrefcheck_ref_int } && + ! \int_compare_p:nNn { \l__zrefcheck_lbl_int } = { 0 } && + ! \int_compare_p:nNn { \l__zrefcheck_ref_int } = { 0 } + } + { \group_insert_after:N \prg_return_true: } + { \group_insert_after:N \prg_return_false: } + \group_end: + } +%% +%% +%% End of file `zref-check.sty'. |