summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/zref-clever/zref-clever.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/zref-clever/zref-clever.dtx')
-rw-r--r--macros/latex/contrib/zref-clever/zref-clever.dtx135
1 files changed, 69 insertions, 66 deletions
diff --git a/macros/latex/contrib/zref-clever/zref-clever.dtx b/macros/latex/contrib/zref-clever/zref-clever.dtx
index 5464fb5575..79eb3dd285 100644
--- a/macros/latex/contrib/zref-clever/zref-clever.dtx
+++ b/macros/latex/contrib/zref-clever/zref-clever.dtx
@@ -24,7 +24,7 @@
% zref-clever.ins,
% zref-clever.tex,
% zref-clever-code.tex,
-% and the files listed in MANIFEST.md.
+% and the files generated from them.
%
% The released version of this package is available from CTAN.
%
@@ -46,7 +46,10 @@
% Have \GetFileInfo pick up date and version data and used in the
% documentation.
-\usepackage[cap,nameinlink=false,check,titleref]{zref-clever}
+\usepackage{zref-clever}
+\zcsetup{cap,nameinlink=false}
+\usepackage{zref-check}
+\usepackage{zref-titleref}
\begin{document}
@@ -162,7 +165,7 @@
%
% Identify the package.
% \begin{macrocode}
-\ProvidesExplPackage {zref-clever} {2022-02-11} {0.2.2-alpha}
+\ProvidesExplPackage {zref-clever} {2022-04-22} {0.3.0}
{Clever LaTeX cross-references based on zref}
% \end{macrocode}
%
@@ -176,7 +179,6 @@
\RequirePackage { zref-base }
\RequirePackage { zref-user }
\RequirePackage { zref-abspage }
-\RequirePackage { l3keys2e }
\RequirePackage { ifdraft }
% \end{macrocode}
%
@@ -453,20 +455,18 @@
% luckily however, we have \texttt{abspage} which solves this problem. But we
% can decide whether two labels can be compressed into a range or not based on
% this format: if they are identical, we can compress them, otherwise, we
-% can't. To do so, we locally redefine \cs{c@page} to return ``1'', thus
-% avoiding any global spillovers of this trick. Since this operation is not
-% expandable we cannot run it directly from the property definition. Hence,
-% we use a shipout hook, and set \cs{g_@@_page_format_tl}, which can then be
-% retrieved by the starred definition of
-% \texttt{\cs{zref@newprop}*\{zc@pgfmt\}}.
+% can't. To do so, we locally set \cs{c@page} to ``1'', thus avoiding any
+% global spillovers of this trick. Since this operation is not expandable we
+% cannot run it directly from the property definition. Hence, we use a
+% shipout hook, and set \cs{g_@@_page_format_tl}, which can then be retrieved
+% by the starred definition of \texttt{\cs{zref@newprop}*\{zc@pgfmt\}}.
%
% \begin{macrocode}
\tl_new:N \g_@@_page_format_tl
-\cs_new_protected:Npx \@@_page_format_aux: { \int_eval:n { 1 } }
\AddToHook { shipout / before }
{
\group_begin:
- \cs_set_eq:NN \c@page \@@_page_format_aux:
+ \int_set:Nn \c@page { 1 }
\tl_gset:Nx \g_@@_page_format_tl { \thepage }
\group_end:
}
@@ -620,11 +620,6 @@
}
\msg_new:nnn { zref-clever } { missing-hyperref }
{ Missing~'hyperref'~package.~Setting~'hyperref=false'. }
-\msg_new:nnn { zref-clever } { titleref-preamble-only }
- {
- Option~'titleref'~only~available~in~the~preamble~\msg_line_context:.~
- Did~you~mean~'ref=title'?.
- }
\msg_new:nnn { zref-clever } { option-preamble-only }
{ Option~'#1'~only~available~in~the~preamble~\msg_line_context:. }
\msg_new:nnn { zref-clever } { unknown-compat-module }
@@ -665,6 +660,11 @@
Option~'#1'~has~been~deprecated~\msg_line_context:.\iow_newline:
Use~'#2'~instead.
}
+\msg_new:nnn { zref-clever } { load-time-options }
+ {
+ 'zref-clever'~does~not~accept~load-time~options.~
+ To~configure~package~options,~use~'\iow_char:N\\zcsetup'.
+ }
% \end{macrocode}
%
%
@@ -3626,17 +3626,8 @@
% \end{macrocode}
%
%
-%
% \subsubsection*{\opt{font} option}
%
-% \opt{font} \emph{can't be used as a package option}, since the options get
-% expanded by \LaTeX{} before being passed to the package (see
-% \url{https://tex.stackexchange.com/a/489570}). It can be set in \cs{zcref}
-% and, for global settings, with \cs{zcsetup}. Note that, technically, the
-% ``raw'' options are already available as \cs{@raw@opt@\meta{package}.sty}
-% (helpful comment by \contributor{David Carlisle} at
-% \url{https://tex.stackexchange.com/a/618439}).
-%
% \begin{macrocode}
\tl_new:N \l_@@_ref_typeset_font_tl
\keys_define:nn { zref-clever/reference }
@@ -3644,22 +3635,17 @@
% \end{macrocode}
%
%
-%
% \subsubsection*{\opt{titleref} option}
%
% \begin{macrocode}
\keys_define:nn { zref-clever/reference }
{
- titleref .code:n = { \RequirePackage { zref-titleref } } ,
- titleref .value_forbidden:n = true ,
- }
-\AddToHook { begindocument }
- {
- \keys_define:nn { zref-clever/reference }
+ titleref .code:n =
{
- titleref .code:n =
- { \msg_warning:nn { zref-clever } { titleref-preamble-only } }
- }
+ % NOTE Option deprecated in 2022-04-22 for 0.3.0.
+ \msg_warning:nnxx { zref-clever }{ option-deprecated } { titleref }
+ { \iow_char:N\\usepackage\iow_char:N\{zref-titleref\iow_char:N\} }
+ } ,
}
% \end{macrocode}
%
@@ -3669,19 +3655,12 @@
% \begin{macrocode}
\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 =
{
- vario .code:n =
- {
- \msg_warning:nnn { zref-clever }
- { option-preamble-only } { vario }
- }
- }
+ % NOTE Option deprecated in 2022-04-22 for 0.3.0.
+ \msg_warning:nnxx { zref-clever }{ option-deprecated } { vario }
+ { \iow_char:N\\usepackage\iow_char:N\{zref-vario\iow_char:N\} }
+ } ,
}
% \end{macrocode}
%
@@ -3707,8 +3686,8 @@
\bool_new:N \l_@@_zcref_with_check_bool
\keys_define:nn { zref-clever/reference }
{
- check .code:n = { \RequirePackage { zref-check } } ,
- check .value_forbidden:n = true ,
+ check .code:n =
+ { \msg_warning:nnn { zref-clever } { option-document-only } { check } } ,
}
\AddToHook { begindocument }
{
@@ -4116,8 +4095,8 @@
% potentially apply them selectively to different contexts: \texttt{label} and
% \texttt{reference}. Currently, the only use of this selection is the
% ability to exclude label related options from \cs{zcref}'s options. Anyway,
-% for load-time package options and for \cs{zcsetup} we want the whole set, so
-% we aggregate the two into \texttt{zref-clever/zcsetup}, and use that here.
+% for package options (\cs{zcsetup}) we want the whole set, so we aggregate
+% the two into \texttt{zref-clever/zcsetup}, and use that here.
%
% \begin{macrocode}
\keys_define:nn { }
@@ -4131,14 +4110,20 @@
% \end{macrocode}
%
%
-% Process load-time package options
-% (\url{https://tex.stackexchange.com/a/15840}).
+% \pkg{zref-clever} does not accept load-time options. Despite the tradition
+% of so doing, Joseph Wright has a point in recommending otherwise at
+% \url{https://chat.stackexchange.com/transcript/message/60360822#60360822}:
+% separating ``loading the package'' from ``configuring the package'' grants
+% less trouble with ``option clashes'' and with expansion of options at
+% load-time.
% \begin{macrocode}
-\ProcessKeysOptions { zref-clever/zcsetup }
+\bool_lazy_and:nnT
+ { \tl_if_exist_p:c { opt@ zref-clever.sty } }
+ { ! \tl_if_empty_p:c { opt@ zref-clever.sty } }
+ { \msg_warning:nn { zref-clever } { load-time-options } }
% \end{macrocode}
%
%
-%
% \section{Configuration}
%
% \subsection{\cs{zcsetup}}
@@ -6461,8 +6446,7 @@
{
\exp_not:N \group_begin:
\exp_not:V \l_@@_namefont_tl
- % It's two `@s', but escaped for DocStrip.
- \exp_not:N \hyper@@@@link
+ \@@_hyperlink:nnn
{
\@@_extract_url_unexp:V
\l_@@_type_first_label_tl
@@ -6800,6 +6784,10 @@
}
}
}
+ % We just closed a range, reset `range_beg_is_first' in case a
+ % second range for the same type occurs, in which case its
+ % `range_beg' will no longer be `first'.
+ \bool_set_false:N \l_@@_range_beg_is_first_bool
% Reset counters.
\int_zero:N \l_@@_range_count_int
\int_zero:N \l_@@_range_same_count_int
@@ -6877,8 +6865,7 @@
\exp_not:N \group_begin:
\exp_not:V \l_@@_reffont_tl
\seq_item:Nn #2 { 1 }
- % It's two `@s', but escaped for DocStrip.
- \exp_not:N \hyper@@@@link
+ \@@_hyperlink:nnn
{ \@@_extract_url_unexp:n {#1} }
{ \@@_extract_unexp:nnn {#1} { anchor } { } }
{
@@ -6927,8 +6914,7 @@
\exp_not:N \group_begin:
\exp_not:V \l_@@_reffont_tl
\seq_item:Nn #3 { 1 }
- % It's two `@s', but escaped for DocStrip.
- \exp_not:N \hyper@@@@link
+ \@@_hyperlink:nnn
{ \@@_extract_url_unexp:n {#1} }
{ \@@_extract_unexp:nnn {#1} { anchor } { } }
{
@@ -6978,8 +6964,7 @@
{ \l_@@_ref_property_tl }
{
\exp_not:N \group_begin:
- % It's two `@s', but escaped for DocStrip.
- \exp_not:N \hyper@@@@link
+ \@@_hyperlink:nnn
{
\@@_extract_url_unexp:V
\l_@@_type_first_label_tl
@@ -7045,8 +7030,7 @@
\exp_not:V \l_@@_reffont_tl
\seq_item:Nn
\l_@@_type_first_refbounds_seq { 1 }
- % It's two `@s', but escaped for DocStrip.
- \exp_not:N \hyper@@@@link
+ \@@_hyperlink:nnn
{
\@@_extract_url_unexp:V
\l_@@_type_first_label_tl
@@ -7341,6 +7325,25 @@
% \end{macro}
%
%
+% \begin{macro}{\@@_hyperlink:nnn}
+% This avoids using the internal \cs[replace=false]{hyper@@link}, using only
+% public \pkg{hyperref} commands (see
+% \url{https://github.com/latex3/hyperref/issues/229#issuecomment-1093870142},
+% thanks \contributor{Ulrike Fisher}).
+% \begin{syntax}
+% \cs{@@_hyperlink:nnn} \Arg{url/file} \Arg{anchor} \Arg{text}
+% \end{syntax}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_hyperlink:nnn #1#2#3
+ {
+ \tl_if_empty:nTF {#1}
+ { \hyperlink {#2} {#3} }
+ { \hyper@linkfile {#3} {#1} {#2} }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macro}{\@@_extract_url_unexp:n}
% A convenience auxiliary function for extraction of the \texttt{url} /
% \texttt{urluse} property, provided by the \pkg{zref-xr} module. Ensure