%% %% 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-2023 gusbrs %% %% 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 gusbrs. %% %% This work consists of the files zref-check.dtx, %% zref-check.ins, %% zref-check-doc.tex, %% zref-check-code.tex, %% and the files generated from them. %% %% 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. %% %% ----------------------------------------------------------------------- %% \def\zrefcheck@required@kernel{2023-11-01} \NeedsTeXFormat{LaTeX2e}[\zrefcheck@required@kernel] \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} \IfFormatAtLeastTF{\zrefcheck@required@kernel} {} {% \PackageError{zref-check}{LaTeX kernel too old} {% 'zref-check' requires a LaTeX kernel \zrefcheck@required@kernel\space or newer.% }% }% \ProvidesExplPackage {zref-check} {2023-11-14} {0.3.5} {Flexible cross-references with contextual checks based on zref} \RequirePackage { zref-user } \RequirePackage { zref-abspage } \RequirePackage { ifdraft } \newcounter { zc@abschap } \newcounter { zc@abssec } [ zc@abschap ] \AddToHook { cmd / chapter / before } { \stepcounter { zc@abschap } } \zref@newprop { zc@abschap } [0] { \int_use:N \c@zc@abschap } \zref@addprop \ZREF@mainlist { zc@abschap } \AddToHook { cmd / section / before } { \stepcounter { zc@abssec } } \zref@newprop { zc@abssec } [0] { \int_use:N \c@zc@abssec } \zref@addprop \ZREF@mainlist { zc@abssec } \zref@newlist { zrefcheck-check } \zref@addprops { zrefcheck-check } { page , % for messages abspage , zc@abschap , zc@abssec } \zref@newlist { zrefcheck-end } \zref@addprops { zrefcheck-end } { abspage , zc@abschap , zc@abssec } \zref@newlist { zrefcheck-zrefvario } \zref@addprops { zrefcheck-zrefvario } { page , % for messages abspage , } \tl_new:N \l__zrefcheck_tmpa_tl \tl_new:N \l__zrefcheck_tmpb_tl \tl_new:N \g__zrefcheck_tmpa_tl \int_new:N \l__zrefcheck_tmpa_int \bool_new:N \l__zrefcheck_tmpa_bool \ior_new:N \g__zrefcheck_tmpa_ior \cs_new_protected: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 { nnne } \msg_new:nnn { zref-check } { check-failed } { Check~failed~\msg_line_context:.~ Failed~check~'#1'~for~label~'#2'~on~page~#3. } \msg_new:nnn { zref-check } { double-check } { Same~page~check~\msg_line_context:.~ Double-check~'#1'~for~label~'#2'~on~page~#3. } \msg_new:nnn { zref-check } { empty-label } { Check~failed~\msg_line_context:.~ Failed~check~'#1'~for~empty~label. } \msg_new:nnn { zref-check } { no-checks } { No~checks~for~'\iow_char:N\\zcheck'~\msg_line_context:. } \msg_new:nnn { zref-check } { check-missing } { Check~'#1'~not~defined~\msg_line_context:. } \msg_new:nnn { zref-check } { property-undefined } { Property~'#1'~not~defined~\msg_line_context:. } \msg_new:nnn { zref-check } { property-not-in-label } { Label~'#1'~has~no~property~'#2'~\msg_line_context:. } \msg_new:nnn { zref-check } { property-not-integer } { Property~'#1'~for~label~'#2'~not~an~integer~\msg_line_context:. } \msg_new:nnn { zref-check } { hyperref-preamble-only } { Option~'hyperref'~only~available~in~the~preamble. \iow_newline: Use~the~starred~version~of~'\iow_char:N\\zcheck'~instead. } \msg_new:nnn { zref-check } { missing-hyperref } { Missing~'hyperref'~package. \iow_newline: Setting~'hyperref=false'. } \msg_new:nnn { zref-check } { ignore-ok-document-only } { Option~'#1'~only~available~in~the~document. \iow_newline: Use~option~'msglevel'~instead. } \msg_new:nnn { zref-check } { option-preamble-only } { Option~'#1'~is~preamble~only~\msg_line_context:. } \msg_new:nnn { zref-check } { closerange-not-positive-integer } { Option~'closerange'~not~a~positive~integer~\msg_line_context:.~ Using~default~value. } \msg_new:nnn { zref-check } { labelcmd-undefined } { Control~sequence~named~'#1'~used~in~option~'labelcmd'~is~not~defined.~ Using~default~value. } \msg_new:nnn { zref-check } { option-deprecated-with-alternative } { Option~'#1'~has~been~deprecated~\msg_line_context:.\iow_newline: Use~'#2'~instead. } \msg_new:nnn { zref-check } { option-deprecated } { Option~'#1'~has~been~deprecated~\msg_line_context:. } \msg_new:nnn { zref-check } { load-time-options } { 'zref-check'~does~not~accept~load-time~options.~ To~configure~package~options,~use~'\iow_char:N\\zrefchecksetup'. } \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 } \AddToHook { begindocument } { \@ifpackageloaded { hyperref } { \bool_if:NT \l__zrefcheck_use_hyperref_bool { \RequirePackage { zref-hyperref } } } { \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 / infoifdraft .code:n = { \ifdraft { \tl_set:Nn \l__zrefcheck_msglevel_tl { info } } { \tl_set:Nn \l__zrefcheck_msglevel_tl { warning } } } , msglevel / warniffinal .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:nnn { zref-check } { ignore-ok-document-only } { ignore } } , ignore .value_forbidden:n = true , ok .code:n = { \msg_warning:nnn { zref-check } { ignore-ok-document-only } { ok } } , ok .value_forbidden:n = true , } \AddToHook { begindocument } { \keys_define:nn { zref-check } { ignore .meta:n = { msglevel = none } , ok .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 / labelseqifdraft .code:n = { \ifdraft { \bool_set_false:N \l__zrefcheck_msgonpage_bool } { \bool_set_true:N \l__zrefcheck_msgonpage_bool } } , onpage / msgiffinal .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 } \bool_lazy_and:nnT { \tl_if_exist_p:c { opt@ zref-check.sty } } { ! \tl_if_empty_p:c { opt@ zref-check.sty } } { \msg_warning:nn { zref-check } { load-time-options } } \NewDocumentCommand \zrefchecksetup { m } { \keys_set:nn { zref-check } {#1} } \prop_new:N \g__zrefcheck_auxfile_lblseq_prop \tl_gset:Nn \g__zrefcheck_tmpa_tl { \c_sys_jobname_str .aux } \file_if_exist:nT { \g__zrefcheck_tmpa_tl } { \ior_open:Nn \g__zrefcheck_tmpa_ior { \g__zrefcheck_tmpa_tl } \group_begin: \int_zero:N \l__zrefcheck_tmpa_int \tl_clear:N \l__zrefcheck_tmpa_tl \tl_clear:N \l__zrefcheck_tmpb_tl \bool_set_false:N \l__zrefcheck_tmpa_bool \ior_map_variable:NNn \g__zrefcheck_tmpa_ior \l__zrefcheck_tmpa_tl { \tl_map_variable:NNn \l__zrefcheck_tmpa_tl \l__zrefcheck_tmpb_tl { \tl_if_eq:NnTF \l__zrefcheck_tmpb_tl { \zref@newlabel } { \bool_set_true:N \l__zrefcheck_tmpa_bool } { \bool_if:NTF \l__zrefcheck_tmpa_bool { \bool_set_false:N \l__zrefcheck_tmpa_bool \int_incr:N \l__zrefcheck_tmpa_int \prop_gput:Nee \g__zrefcheck_auxfile_lblseq_prop { \l__zrefcheck_tmpb_tl } { \int_use:N \l__zrefcheck_tmpa_int } } { \tl_map_break: } } } } \group_end: \ior_close:N \g__zrefcheck_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_protected: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:Ne #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_protected: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 { } m m } { \zref@wrapper@babel \__zrefcheck_zcheck:nnnn {#3} {#1} {#2} {#4} } \seq_new:N \l__zrefcheck_zcheck_labels_seq \int_new:N \g__zrefcheck_id_int \tl_new:N \l__zrefcheck_checkbeg_tl \tl_new:N \l__zrefcheck_link_label_tl \tl_new:N \l__zrefcheck_link_anchor_tl \bool_new:N \l__zrefcheck_link_star_bool \cs_new_protected:Npn \__zrefcheck_zcheck:nnnn #1#2#3#4 { \group_begin: \keys_set:nn { zref-check / zcheck } {#3} \seq_set_split:Nnn \l__zrefcheck_zcheck_labels_seq { , } {#1} \int_gincr:N \g__zrefcheck_id_int \tl_set:Ne \l__zrefcheck_checkbeg_tl { \__zrefcheck_check_lblfmt:n { \g__zrefcheck_id_int } } \zref@labelbylist { \l__zrefcheck_checkbeg_tl } { zrefcheck-check } \seq_get:NN \l__zrefcheck_zcheck_labels_seq \l__zrefcheck_link_label_tl \bool_set:Nn \l__zrefcheck_link_star_bool {#2} \zref@ifrefundefined { \l__zrefcheck_link_label_tl } {#4} { \bool_if:nTF { \l__zrefcheck_use_hyperref_bool && ! \l__zrefcheck_link_star_bool } { \exp_args:Ne \zrefcheck_get_astl:nnn { \l__zrefcheck_link_label_tl } { anchor } { \l__zrefcheck_link_anchor_tl } \hyperlink { \l__zrefcheck_link_anchor_tl } {#4} } {#4} } \bool_if:NT \l__zrefcheck_zcheck_end_label_bool { \zref@labelbylist { \__zrefcheck_end_lblfmt:n { \l__zrefcheck_checkbeg_tl } } { zrefcheck-end } } \seq_map_inline:Nn \l__zrefcheck_zcheck_labels_seq { \tl_if_empty:nF {##1} { \zref@refused {##1} } } \__zrefcheck_run_checks:nne { \l__zrefcheck_zcheck_checks_seq } { \l__zrefcheck_zcheck_labels_seq } { \l__zrefcheck_checkbeg_tl } \group_end: } \NewDocumentCommand \zctarget { m +m } { \group_begin: \refstepcounter { zrefcheck } \zref@wrapper@babel \zref@label {#1} #2 \tl_if_empty:nF {#2} { \zref@wrapper@babel \zref@labelbylist { \__zrefcheck_end_lblfmt:n {#1} } { zrefcheck-end } } \group_end: } \NewDocumentEnvironment {zcregion} { m } { \refstepcounter { zrefcheck } \zref@wrapper@babel \zref@label {#1} } { \zref@wrapper@babel \zref@labelbylist { \__zrefcheck_end_lblfmt:n {#1} } { zrefcheck-end } } \seq_const_from_clist:Nn \c__zrefcheck_single_label_checks_seq { thischap , prevchap , nextchap , chapsbefore , chapsafter , thissec , prevsec , nextsec , secsbefore , secsafter , manual , } \seq_new:N \l__zrefcheck_zcheck_checks_seq \bool_new:N \l__zrefcheck_zcheck_end_label_bool \keys_define:nn { } { zref-check / zcheck .inherit:n = zref-check } \clist_map_inline:nn { thispage , prevpage , nextpage , facing , otherpage , pagegap , above , below , pagesbefore , ppbefore , pagesafter , ppafter , before , after , thischap , prevchap , nextchap , chapsbefore , chapsafter , thissec , prevsec , nextsec , secsbefore , secsafter , close , far , manual , } { \keys_define:nn { zref-check / zcheck } { #1 .code:n = { \seq_put_right:Nn \l__zrefcheck_zcheck_checks_seq {#1} \seq_if_in:NnF \c__zrefcheck_single_label_checks_seq {#1} { \bool_set_true:N \l__zrefcheck_zcheck_end_label_bool } } , #1 .value_forbidden:n = true , } } \cs_new_protected:Npn \__zrefcheck_run_checks:nnn #1#2#3 { \group_begin: \seq_map_inline:Nn #2 { \seq_if_empty:NTF #1 { \__zrefcheck_message:nnnn { no-checks } { } { } { } } { \seq_map_inline:Nn #1 { \__zrefcheck_do_check:nnn {####1} {##1} {#3} } } } \group_end: } \cs_generate_variant:Nn \__zrefcheck_run_checks:nnn { nne } \bool_new:N \l__zrefcheck_passedcheck_bool \bool_new:N \l__zrefcheck_onpage_bool \bool_new:N \l__zrefcheck_empty_label_bool \seq_const_from_clist:Nn \c__zrefcheck_onpage_checks_seq { above , below , before , after } \cs_generate_variant:Nn \exp_args:Nnno { Nnoo } \cs_new_protected:Npn \__zrefcheck_do_check:nnn #1#2#3 { \group_begin: \bool_set_true:N \l__zrefcheck_passedcheck_bool \bool_set_false:N \l__zrefcheck_onpage_bool \bool_set_false:N \l__zrefcheck_empty_label_bool \cs_if_exist:cTF { __zrefcheck_check_ #1 :nnF } { \zref@ifrefundefined {#2} { \tl_if_empty:nT {#2} { \bool_set_false:N \l__zrefcheck_passedcheck_bool \bool_set_true:N \l__zrefcheck_empty_label_bool } } { % ``label beg'' vs ``reference beg''. \use:c { __zrefcheck_check_ #1 :nnF } {#2} {#3} { \bool_set_false:N \l__zrefcheck_passedcheck_bool } % ``reference end'' \emph{may} exist or not depending on the % checks. \zref@ifrefundefined { \__zrefcheck_end_lblfmt:n {#3} } { % ``label end'' \emph{may} have been created by the % target commands. \zref@ifrefundefined { \__zrefcheck_end_lblfmt:n {#2} } {} { % ``label end'' vs ``reference beg''. \exp_args:Nno \use:c { __zrefcheck_check_ #1 :nnF } { \__zrefcheck_end_lblfmt:n {#2} } {#3} { \bool_set_false:N \l__zrefcheck_passedcheck_bool } } } { % ``label beg'' vs ``reference end''. \exp_args:Nnno \use:c { __zrefcheck_check_ #1 :nnF } {#2} { \__zrefcheck_end_lblfmt:n {#3} } { \bool_set_false:N \l__zrefcheck_passedcheck_bool } % ``label end'' \emph{may} have been created by the % target commands. \zref@ifrefundefined { \__zrefcheck_end_lblfmt:n {#2} } {} { % ``label end'' vs ``reference beg''. \exp_args:Nno \use:c { __zrefcheck_check_ #1 :nnF } { \__zrefcheck_end_lblfmt:n {#2} } {#3} { \bool_set_false:N \l__zrefcheck_passedcheck_bool } % ``label end'' vs ``reference end''. \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 } \zref@ifrefundefined { \__zrefcheck_end_lblfmt:n {#3} } { \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 {#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 } } } } } } { \msg_warning:nnn { zref-check } { check-missing } {#1} } \bool_if:NTF \l__zrefcheck_passedcheck_bool { \bool_if:nT { \l__zrefcheck_msgonpage_bool && \l__zrefcheck_onpage_bool } { \__zrefcheck_message:nnne { double-check } {#1} {#2} { \zref@extractdefault {#3} {page} {'unknown'} } } } { \bool_if:NTF \l__zrefcheck_empty_label_bool { \__zrefcheck_message:nnnn { empty-label } {#1} { } { } } { \__zrefcheck_message:nnne { check-failed } {#1} {#2} { \zref@extractdefault {#3} {page} {'unknown'} } } } \group_end: } \cs_generate_variant:Nn \__zrefcheck_do_check:nnn { nnV } \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_protected_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_protected_conditional:Npnn \__zrefcheck_check_otherpage:nn #1#2 { T , F , TF } { \__zrefcheck_check_thispage:nnTF {#1} {#2} { \prg_return_false: } { \prg_return_true: } } \prg_new_protected_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_protected_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_protected_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_protected_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_protected_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_protected_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_protected_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_protected_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_protected_conditional:Npnn \__zrefcheck_check_pagegap: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 { \int_abs:n { \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_protected_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_protected_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_protected_conditional:Npnn \__zrefcheck_check_far:nn #1#2 { F } { \__zrefcheck_check_close:nnTF {#1} {#2} { \prg_return_false: } { \prg_return_true: } } \prg_new_protected_conditional:Npnn \__zrefcheck_check_thischap:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_nextchap:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_prevchap:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_chapsafter:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_chapsbefore:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_thissec:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abssec } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@abssec } { \l__zrefcheck_ref_int } \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_b_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_nextsec:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abssec } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@abssec } { \l__zrefcheck_ref_int } \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_b_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_prevsec:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abssec } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@abssec } { \l__zrefcheck_ref_int } \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_b_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_secsafter:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abssec } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@abssec } { \l__zrefcheck_ref_int } \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_b_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_secsbefore:nn #1#2 { F } { \group_begin: \bool_set_true:N \l__zrefcheck_integer_bool \zrefcheck_get_asint:nnn {#1} { zc@abssec } { \l__zrefcheck_lbl_int } \zrefcheck_get_asint:nnn {#2} { zc@abssec } { \l__zrefcheck_ref_int } \zrefcheck_get_asint:nnn {#1} { zc@abschap } { \l__zrefcheck_lbl_b_int } \zrefcheck_get_asint:nnn {#2} { zc@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_protected_conditional:Npnn \__zrefcheck_check_manual:nn #1#2 { F } { \prg_return_false: } \cs_new_protected:Npn \zrefcheck_zcref_beg_label: { \int_gincr:N \g__zrefcheck_id_int \tl_set:Ne \l__zrefcheck_checkbeg_tl { \__zrefcheck_check_lblfmt:n { \g__zrefcheck_id_int } } \zref@labelbylist { \l__zrefcheck_checkbeg_tl } { zrefcheck-check } } \cs_new_protected:Npn \zrefcheck_zcref_end_label_maybe: { \bool_if:NT \l__zrefcheck_zcheck_end_label_bool { \zref@labelbylist { \__zrefcheck_end_lblfmt:n { \l__zrefcheck_checkbeg_tl } } { zrefcheck-end } } } \cs_new_protected:Npn \zrefcheck_zcref_run_checks_on_labels:n #1 { \__zrefcheck_run_checks:nne { \l__zrefcheck_zcheck_checks_seq } {#1} { \l__zrefcheck_checkbeg_tl } } \cs_new_protected:Npn \zrefcheck_zrefvario_label: { \int_gincr:N \g__zrefcheck_id_int \tl_set:Ne \l__zrefcheck_checkbeg_tl { \__zrefcheck_check_lblfmt:n { \g__zrefcheck_id_int } } \zref@labelbylist { \l__zrefcheck_checkbeg_tl } { zrefcheck-zrefvario } } \cs_new_protected:Npn \zrefcheck_zrefvario_run_check_on_label:nn #1#2 { \__zrefcheck_do_check:nnV {#1} {#2} \l__zrefcheck_checkbeg_tl } \cs_generate_variant:Nn \zrefcheck_zrefvario_run_check_on_label:nn { Vn } %% %% %% End of file `zref-check.sty'.