summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/zref
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-11-30 03:00:45 +0000
committerNorbert Preining <norbert@preining.info>2019-11-30 03:00:45 +0000
commit763d7adeac2bc39fb895a0748f12422d5c959d4c (patch)
treeeb54a7ed141f7fd10a3bbd0f8ff7d478b22f06fc /macros/latex/contrib/zref
parentb4325b27feab3a4183f51bfe598686eb72a8c1e0 (diff)
CTAN sync 201911300300
Diffstat (limited to 'macros/latex/contrib/zref')
-rw-r--r--macros/latex/contrib/zref/README.md12
-rw-r--r--macros/latex/contrib/zref/zref.dtx6873
-rw-r--r--macros/latex/contrib/zref/zref.pdfbin0 -> 686493 bytes
3 files changed, 6885 insertions, 0 deletions
diff --git a/macros/latex/contrib/zref/README.md b/macros/latex/contrib/zref/README.md
new file mode 100644
index 0000000000..cc622b0ae3
--- /dev/null
+++ b/macros/latex/contrib/zref/README.md
@@ -0,0 +1,12 @@
+# zref
+
+zref packages for LaTeX
+
+
+Package zref tries to get rid of the restriction
+in LaTeX's reference system that only two properties are
+supported. The package implements an extensible referencing
+system, where properties are handled in a more flexible way.
+It offers an interface for macro programmers for the access
+to the system and some applications that uses the new
+reference scheme.
diff --git a/macros/latex/contrib/zref/zref.dtx b/macros/latex/contrib/zref/zref.dtx
new file mode 100644
index 0000000000..c1c76e7210
--- /dev/null
+++ b/macros/latex/contrib/zref/zref.dtx
@@ -0,0 +1,6873 @@
+% \iffalse meta-comment
+%
+% File: zref.dtx
+% Version: 2019/11/29 v2.28
+% Info: A new reference scheme for LaTeX
+%
+% Copyright (C)
+% 2006-2012 Heiko Oberdiek
+% 2016-2019 Oberdiek Package Support Group
+% https://github.com/ho-tex/zref/issues
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either
+% version 1.3c of this license or (at your option) any later
+% version. This version of this license is in
+% https://www.latex-project.org/lppl/lppl-1-3c.txt
+% and the latest version of this license is in
+% 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 has the LPPL maintenance status "maintained".
+%
+% The Current Maintainers of this work are
+% Heiko Oberdiek and the Oberdiek Package Support Group
+% https://github.com/ho-tex/zref/issues
+%
+% This work consists of the main source file zref.dtx
+% and the derived files
+% zref.sty, zref.pdf, zref.ins, zref.drv, zref-base.sty,
+% zref-abspage.sty, zref-abspos.sty, zref-counter.sty,
+% zref-dotfill.sty, zref-env.sty, zref-hyperref.sty,
+% zref-lastpage.sty, zref-marks.sty, zref-nextpage.sty,
+% zref-pageattr.sty, zref-pagelayout.sty, zref-perpage.sty,
+% zref-runs.sty, zref-savepos.sty, zref-thepage.sty,
+% zref-titleref.sty, zref-totpages.sty, zref-user.sty,
+% zref-xr.sty, zref-example.tex, zref-example-lastpage.tex,
+% zref-example-nextpage.tex, zref-test1.tex,
+% zref-test-base.tex, zref-test-runs.tex,
+% zref-test-titleref-memoir.tex.
+%
+% Distribution:
+% CTAN:macros/latex/contrib/zref/zref.dtx
+% CTAN:macros/latex/contrib/zref/zref.pdf
+%
+% Unpacking:
+% (a) If zref.ins is present:
+% tex zref.ins
+% (b) Without zref.ins:
+% tex zref.dtx
+% (c) If you insist on using LaTeX
+% latex \let\install=y\input{zref.dtx}
+% (quote the arguments according to the demands of your shell)
+%
+% Documentation:
+% (a) If zref.drv is present:
+% latex zref.drv
+% (b) Without zref.drv:
+% latex zref.dtx; ...
+% The class ltxdoc loads the configuration file ltxdoc.cfg
+% if available. Here you can specify further options, e.g.
+% use A4 as paper format:
+% \PassOptionsToClass{a4paper}{article}
+%
+% Programm calls to get the documentation (example):
+% pdflatex zref.dtx
+% makeindex -s gind.ist zref.idx
+% pdflatex zref.dtx
+% makeindex -s gind.ist zref.idx
+% pdflatex zref.dtx
+%
+% Installation:
+% TDS:tex/latex/zref/zref.sty
+% TDS:tex/latex/zref/zref-base.sty
+% TDS:tex/latex/zref/zref-abspage.sty
+% TDS:tex/latex/zref/zref-abspos.sty
+% TDS:tex/latex/zref/zref-counter.sty
+% TDS:tex/latex/zref/zref-dotfill.sty
+% TDS:tex/latex/zref/zref-env.sty
+% TDS:tex/latex/zref/zref-hyperref.sty
+% TDS:tex/latex/zref/zref-lastpage.sty
+% TDS:tex/latex/zref/zref-marks.sty
+% TDS:tex/latex/zref/zref-nextpage.sty
+% TDS:tex/latex/zref/zref-pageattr.sty
+% TDS:tex/latex/zref/zref-pagelayout.sty
+% TDS:tex/latex/zref/zref-perpage.sty
+% TDS:tex/latex/zref/zref-runs.sty
+% TDS:tex/latex/zref/zref-savepos.sty
+% TDS:tex/latex/zref/zref-thepage.sty
+% TDS:tex/latex/zref/zref-titleref.sty
+% TDS:tex/latex/zref/zref-totpages.sty
+% TDS:tex/latex/zref/zref-user.sty
+% TDS:tex/latex/zref/zref-xr.sty
+% TDS:doc/latex/zref/zref.pdf
+% TDS:doc/latex/zref/zref-example.tex
+% TDS:doc/latex/zref/zref-example-lastpage.tex
+% TDS:doc/latex/zref/zref-example-nextpage.tex
+% TDS:doc/latex/zref/test/zref-test1.tex
+% TDS:doc/latex/zref/test/zref-test-base.tex
+% TDS:doc/latex/zref/test/zref-test-runs.tex
+% TDS:doc/latex/zref/test/zref-test-titleref-memoir.tex
+% TDS:source/latex/zref/zref.dtx
+%
+%<*ignore>
+\begingroup
+ \catcode123=1 %
+ \catcode125=2 %
+ \def\x{LaTeX2e}%
+\expandafter\endgroup
+\ifcase 0\ifx\install y1\fi\expandafter
+ \ifx\csname processbatchFile\endcsname\relax\else1\fi
+ \ifx\fmtname\x\else 1\fi\relax
+\else\csname fi\endcsname
+%</ignore>
+%<*install>
+\input docstrip.tex
+\Msg{************************************************************************}
+\Msg{* Installation}
+\Msg{* Package: zref 2019/11/29 v2.28 A new reference scheme for LaTeX (HO)}
+\Msg{************************************************************************}
+
+\keepsilent
+\askforoverwritefalse
+
+\let\MetaPrefix\relax
+\preamble
+
+This is a generated file.
+
+Project: zref
+Version: 2019/11/29 v2.28
+
+Copyright (C)
+ 2006-2012 Heiko Oberdiek
+ 2016-2019 Oberdiek Package Support Group
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either
+version 1.3c of this license or (at your option) any later
+version. This version of this license is in
+ https://www.latex-project.org/lppl/lppl-1-3c.txt
+and the latest version of this license is in
+ 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 has the LPPL maintenance status "maintained".
+
+The Current Maintainers of this work are
+Heiko Oberdiek and the Oberdiek Package Support Group
+https://github.com/ho-tex/zref/issues
+
+
+This work consists of the main source file zref.dtx
+and the derived files
+ zref.sty, zref.pdf, zref.ins, zref.drv, zref-base.sty,
+ zref-abspage.sty, zref-abspos.sty, zref-counter.sty,
+ zref-dotfill.sty, zref-env.sty, zref-hyperref.sty,
+ zref-lastpage.sty, zref-marks.sty, zref-nextpage.sty,
+ zref-pageattr.sty, zref-pagelayout.sty, zref-perpage.sty,
+ zref-runs.sty, zref-savepos.sty, zref-thepage.sty,
+ zref-titleref.sty, zref-totpages.sty, zref-user.sty,
+ zref-xr.sty, zref-example.tex, zref-example-lastpage.tex,
+ zref-example-nextpage.tex, zref-test1.tex,
+ zref-test-base.tex, zref-test-runs.tex,
+ zref-test-titleref-memoir.tex.
+
+\endpreamble
+\let\MetaPrefix\DoubleperCent
+
+\generate{%
+ \file{zref.ins}{\from{zref.dtx}{install}}%
+ \file{zref.drv}{\from{zref.dtx}{driver}}%
+ \usedir{tex/latex/zref}%
+ \file{zref.sty}{\from{zref.dtx}{package}}%
+ \file{zref-base.sty}{\from{zref.dtx}{base}}%
+ \file{zref-abspage.sty}{\from{zref.dtx}{abspage}}%
+ \file{zref-abspos.sty}{\from{zref.dtx}{abspos}}%
+ \file{zref-counter.sty}{\from{zref.dtx}{counter}}%
+ \file{zref-dotfill.sty}{\from{zref.dtx}{dotfill}}%
+ \file{zref-env.sty}{\from{zref.dtx}{env}}%
+ \file{zref-hyperref.sty}{\from{zref.dtx}{hyperref}}%
+ \file{zref-lastpage.sty}{\from{zref.dtx}{lastpage}}%
+ \file{zref-marks.sty}{\from{zref.dtx}{marks}}%
+ \file{zref-nextpage.sty}{\from{zref.dtx}{nextpage}}%
+ \file{zref-pageattr.sty}{\from{zref.dtx}{pageattr}}%
+ \file{zref-pagelayout.sty}{\from{zref.dtx}{pagelayout}}%
+ \file{zref-perpage.sty}{\from{zref.dtx}{perpage}}%
+ \file{zref-runs.sty}{\from{zref.dtx}{runs}}%
+ \file{zref-savepos.sty}{\from{zref.dtx}{savepos}}%
+ \file{zref-thepage.sty}{\from{zref.dtx}{thepage}}%
+ \file{zref-titleref.sty}{\from{zref.dtx}{titleref}}%
+ \file{zref-totpages.sty}{\from{zref.dtx}{totpages}}%
+ \file{zref-user.sty}{\from{zref.dtx}{user}}%
+ \file{zref-xr.sty}{\from{zref.dtx}{xr}}%
+ \usedir{doc/latex/zref}%
+ \file{zref-example.tex}{\from{zref.dtx}{example}}%
+ \file{zref-example-lastpage.tex}{\from{zref.dtx}{example-lastpage}}%
+ \file{zref-example-nextpage.tex}{\from{zref.dtx}{example-nextpage}}%
+% \usedir{doc/latex/zref/test}%
+% \file{zref-test1.tex}{\from{zref.dtx}{test1}}%
+% \file{zref-test-base.tex}{\from{zref.dtx}{test-base}}%
+% \file{zref-test-runs.tex}{\from{zref.dtx}{test-runs}}%
+% \file{zref-test-titleref-memoir.tex}{\from{zref.dtx}{test-titleref-memoir}}%
+ \nopreamble
+ \nopostamble
+% \usedir{source/latex/zref/catalogue}%
+% \file{zref.xml}{\from{zref.dtx}{catalogue}}%
+}
+
+\catcode32=13\relax% active space
+\let =\space%
+\Msg{************************************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move the following}
+\Msg{* files into a directory searched by TeX:}
+\Msg{*}
+\Msg{* zref.sty, zref-base.sty, zref-abspage.sty, zref-abspos.sty,}
+\Msg{* zref-counter.sty, zref-dotfill.sty, zref-env.sty,}
+\Msg{* zref-hyperref.sty, zref-lastpage.sty, zref-marks.sty,}
+\Msg{* zref-nextpage.sty, zref-pageattr.sty, zref-pagelayout.sty,}
+\Msg{* zref-perpage.sty, zref-runs.sty, zref-savepos.sty,}
+\Msg{* zref-thepage.sty, zref-titleref.sty, zref-totpages.sty,}
+\Msg{* zref-user.sty, zref-xr.sty}
+\Msg{*}
+\Msg{* To produce the documentation run the file `zref.drv'}
+\Msg{* through LaTeX.}
+\Msg{*}
+\Msg{* Happy TeXing!}
+\Msg{*}
+\Msg{************************************************************************}
+
+\endbatchfile
+%</install>
+%<*ignore>
+\fi
+%</ignore>
+%<*driver>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesFile{zref.drv}%
+ [2019/11/29 v2.28 A new reference scheme for LaTeX (HO)]%
+\documentclass{ltxdoc}
+\usepackage{holtxdoc}[2011/11/22]
+\setlength{\emergencystretch}{1em}
+\begin{document}
+ \DocInput{zref.dtx}%
+\end{document}
+%</driver>
+% \fi
+%
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+% \GetFileInfo{zref.drv}
+%
+% \title{The \xpackage{zref} package}
+% \date{2019/11/29 v2.28}
+% \author{Heiko Oberdiek\thanks
+% {Please report any issues at \url{https://github.com/ho-tex/zref/issues}}}
+%
+% \maketitle
+%
+% \begin{abstract}
+% Package \xpackage{zref} tries to get rid of the restriction
+% in \hologo{LaTeX}'s reference system that only two properties are
+% supported. The package implements an extensible referencing
+% system, where properties are handled in a more flexible way.
+% It offers an interface for macro programmers for the access
+% to the system and some applications that uses the new
+% reference scheme.
+% \end{abstract}
+%
+% \tableofcontents
+%
+% \newcommand*{\metacs}[1]{\texttt{\itshape #1}}
+%
+% \newcommand{\markexp}{^^A
+% \textsuperscript{exp}^^A
+% \space
+% }
+% \newcommand{\markexptwo}{^^A
+% \textsuperscript{exp2}^^A
+% \space
+% }
+% \newcommand{\markrobust}{^^A
+% \textsuperscript{robust}^^A
+% \space
+% }
+% \newcommand{\marknowarn}{^^A
+% \textsuperscript{nowarn}^^A
+% \space
+% }
+% \newcommand{\markbabel}{^^A
+% \textsuperscript{babel}^^A
+% \space
+% }
+%
+% \section{Introduction}
+%
+% Standard \hologo{LaTeX}'s reference system with \cs{label}, \cs{ref},
+% and \cs{pageref} supports two properties, the apperance of
+% the counter that is last incremented by \cs{refstepcounter} and
+% the page with the \cs{label} command.
+%
+% Unhappily \hologo{LaTeX} does not provide an interface for adding
+% another properties. Packages such as \xpackage{hyperref},
+% \xpackage{nameref}, or \xpackage{titleref} are forced to
+% use ugly hacks to extend the reference system.
+% These ugly hacks are one of the causes for \xpackage{hyperref}'s
+% difficulty regarding compatibility with other packages.
+%
+% \subsection{Standard \hologo{LaTeX} behaviour}
+%
+% References are created by the \cs{label} command:
+% \begin{quote}
+% |\chapter{Second chapter}|\\
+% |\section{First section on page 7} % section 2.1|\\
+% |\label{myref}|
+% \end{quote}
+% Now \hologo{LaTeX} records the section number |2.1| and the page |7|
+% in the reference. Internally the reference is a list with
+% two entries:
+% \begin{quote}
+% |\r@myref| $\rightarrow$ |{2.1}{7}|
+% \end{quote}
+% The length of the list if fixed in the \hologo{LaTeX} kernel,
+% An interface for adding new properties is missing.
+%
+% There are several tries to add new properties:
+% \begin{description}
+% \item[\xpackage{hyperref}] uses a list of five
+% properties instead of the standard list with two entries.
+% This causes many compatibility problems with \hologo{LaTeX} and
+% other packages.
+% \item[\xpackage{titleref}] stores its title data into the
+% first entry in the list. \hologo{LaTeX} is happy because it
+% does only see its list with two entries. The situation
+% becomes more difficult, if more properties are added
+% this way. Then the macros form a nested structure
+% inside the first reference argument for the label.
+% Expandable extractions will then become painful.
+% \end{description}
+%
+% \subsection{Basic idea}
+%
+% Some time ago Morten H\o gholm sent me an experimental
+% cross referencing mechanism as ``expl3'' code. His
+% idea is:
+% \begin{quote}
+% |\g_xref_mylabel_plist| $\rightarrow$\\
+% \mbox{}\qquad|\xref_dance_key{salsa}\xref_name_key{Morten}|\dots
+% \end{quote}
+% The entries have the following format:
+% \begin{quote}
+% |\xref_|\meta{your key}|_key{|\meta{some text}|}|
+% \end{quote}
+% This approach is much more flexible:
+% \begin{itemize}
+% \item New properties can easily be added, just use a new key.
+% \item The length of the list is not fixed. A reference
+% can use a subset of the keys.
+% \item The order of the entries does not matter.
+% \end{itemize}
+% Unhappily I am not familiar with the experimental code
+% for \hologo{LaTeX3} that will need some time before its first release.
+% Thus I have implemented it as \hologo{LaTeXe} package without disturbing
+% the existing \hologo{LaTeX} reference system.
+%
+% \subsection{Interfaces}
+%
+% The package provides a generic \emph{interface for programmers}.
+% Commands of this interface are prefixed by \cs{zref@}.
+%
+% Option \xoption{user} enabels the \emph{user interface}.
+% Here the commands are prefixed by \cs{z} to avoid name
+% clashes with existing macros.
+%
+% Then the packages provides some \emph{modules}. They
+% are applications for the reference system and can also be
+% considered as examples how to use the reference system.
+%
+% The modules can be loaded as packages. The package
+% name is prefixed with |zref-|, for example:
+%\begin{quote}
+%\begin{verbatim}
+%\RequirePackage{zref-abspage}
+%\end{verbatim}
+%\end{quote}
+% This is the preferred way if the package is loaded from
+% within other packages to avoid option clashes.
+%
+% As alternative package |zref| can be used and the modules
+% are given as options:
+%\begin{quote}
+%\begin{verbatim}
+%\usepackage[perpage,user]{zref}
+%\end{verbatim}
+%\end{quote}
+%
+% \section{Interface for programmers}
+%
+% The user interface is described in the next section \ref{sec:user}.
+%
+% \subsection{Entities}
+%
+% \paragraph{Reference.}
+% Internally a reference is a list of key value pairs:
+% \begin{quote}
+% |\Z@R@myref| $\rightarrow$
+% |\default{2.1}\page{7}|
+% \end{quote}
+% The generic format of a entry is:
+% \begin{quote}
+% |\Z@R@|\meta{refname} $\rightarrow$
+% |\|\meta{propname}|{|\meta{value}|}|
+% \end{quote}
+% \meta{refname} is the name that denoted references
+% (the name used in \cs{label} and \cs{ref}). \meta{propname}
+% is the name of the property or key. The property key macro
+% is never executed, it is used in parameter text matching only.
+%
+% \paragraph{Property.}
+% Because the name of a property is used in a macro name
+% that must survive the \xfile{.aux} file, the name is
+% restricted to letters and `@'.
+%
+% \paragraph{Property list.}
+% Often references are used for special purposes. Thus it
+% saves memory if just the properties are used in this
+% reference that are necessary for its purpose.
+%
+% Therefore this package uses the concept of \emph{property lists}.
+% A property list is a set of properties. The set of properties
+% that is used by the default \cs{label} command is the
+% \emph{main property list}.
+%
+% \subsection{Property list}
+%
+% \markexp means that the implementation of the
+% marked macro is expandable. \markexptwo goes a step further
+% and marks the macro expandable in exact two expansion steps.
+%
+% \begin{declcs}{zref@newlist}
+% \M{listname}
+% \end{declcs}
+% Declares a new empty property list.
+%
+% \begin{declcs}{zref@addprop}
+% \M{listname} \M{propname}\\
+% \cs{zref@localaddprop} \M{listname} \M{propname}
+% \end{declcs}
+% Adds the property \meta{propname}
+% to the property list \meta{listname}.
+% The property and list must exist.
+% The addition is global by \cs{zref@addprop} and limited to
+% local scope by \cs{zref@localaddprop}.
+% Between 2010/04/19 v2.13 and 2010/10/22 v2.19 a comma separated list
+% of properties could be used as argument \meta{propname}.
+% Since 2010/10/22 v2.19 the addition of several properties
+% at once is supported by \cs{zref@addprops}.
+%
+% \begin{declcs}{zref@addprops}
+% \M{listname} \M{propname list}\\
+% \cs{zref@localaddprops} \M{listname} \M{propname list}
+% \end{declcs}
+% These macros add a comma separated list of properties
+% \meta{propname list} to list \meta{listname}.
+% \cs{zref@addprops} works globally and \cs{zref@localaddprops}
+% locally. Since 2010/10/22 v2.19.
+%
+% \begin{declcs}{zref@listexists}
+% \M{listname} \M{then}
+% \end{declcs}
+% Executes \meta{then} if the property list \meta{listname} exists
+% or raise an error otherwise.
+%
+% \begin{declcs}{zref@iflistundefined}\markexp \M{listname}
+% \M{then} \M{else}
+% \end{declcs}
+% Executes \meta{then} if the list exists or \meta{else}
+% otherwise.
+%
+% \begin{declcs}{zref@iflistcontainsprop}
+% \M{listname} \M{propname} \M{then} \M{else}
+% \end{declcs}
+% Executes \meta{then} if the property \meta{propname} is part
+% of property list \meta{listname} or otherwise it
+% runs the \meta{else} part.
+%
+% \subsection{Property}
+%
+% \begin{declcs}{zref@newprop}
+% \* \M{propname} |[|\meta{default}|]| \M{value}
+% \end{declcs}
+% This command declares and configures a new property with
+% name \meta{propname}.
+%
+% In case of unknown references
+% or the property does not exist in the reference, the
+% \meta{default} is used as value. If it is not specified
+% here, a global default is used, see \cs{zref@setdefault}.
+%
+% The correct values of some properties are not known
+% immediately but at page shipout time. Prominent example
+% is the page number. These properties are declared with
+% the star form of the command.
+%
+% \begin{declcs}{zref@setcurrent}
+% \M{propname} \M{value}
+% \end{declcs}
+% This sets the current value of the property \meta{propname}.
+% It is a generalization of setting \hologo{LaTeX}'s \cs{currentlabel}.
+%
+% \begin{declcs}{zref@getcurrent}\markexptwo
+% \M{propname}
+% \end{declcs}
+% This returns the current value of the property \meta{propname}.
+% The value may not be correct, especially if the property
+% is bound to a page (start form of \cs{zref@newprop}) and the
+% right value is only known at shipout time (e.g. property `page').
+% In case of errors (e.g. unknown property) the empty string is
+% returned.
+%
+% Since version 2010/04/22 v2.14 \cs{zref@getcurrent} supports
+% \cs{zref@wrapper@unexpanded}.
+%
+% \begin{declcs}{zref@propexists}
+% \M{propname} \M{then}
+% \end{declcs}
+% Calls \meta{then} if the property \meta{propname} is available
+% or generates an error message otherwise.
+%
+% \begin{declcs}{zref@ifpropundefined}\markexp
+% \M{propname} \M{then} \M{else}
+% \end{declcs}
+% Calls \meta{then} or \meta{else} depending on the existence
+% of property \meta{propname}.
+%
+% \subsection{Reference generation}
+%
+% \begin{declcs}{zref@label}
+% \M{refname}
+% \end{declcs}
+% This works similar to \cs{label}. The reference \meta{refname} is
+% created and put into the \xfile{.aux} file with the
+% properties of the main property list.
+%
+% \begin{declcs}{zref@labelbylist}
+% \M{refname} \M{listname}
+% \end{declcs}
+% Same as \cs{zref@label} except that the properties are
+% taken from the specified property list \meta{listname}.
+%
+% \begin{declcs}{zref@labelbyprops}
+% \M{refname} |{|\meta{propnameA}|,|\meta{propnameB}|,|\dots|}|
+% \end{declcs}
+% Same as \cs{zref@label} except that these properties
+% are used that are given as comma separated list in the
+% second argument.
+%
+% \begin{declcs}{zref@newlabel}
+% \M{refname} |{|\dots|}|
+% \end{declcs}
+% This is the macro that is used in the \xfile{.aux} file.
+% It is basically the same as \cs{newlabel} apart from
+% the format of the data in the second argument.
+%
+% \subsection{Data extraction}
+%
+% \begin{declcs}{zref@extractdefault}\markexptwo
+% \M{refname} \M{propname} \M{default}
+% \end{declcs}
+% This is the basic command that refernces the value of a
+% property \meta{propname} for the reference \meta{refname}.
+% In case of errors such as undefined reference the \meta{default}
+% is used instead.
+%
+% \begin{declcs}{zref@extract}\markexptwo
+% \M{refname} \M{propname}
+% \end{declcs}
+% The command is an abbreviation for \cs{zref@extractdefault}.
+% As default the default of the property is taken, otherwise
+% the global default.
+%
+% Example for page references:
+% \begin{quote}
+% \begin{tabular}{@{}ll}
+% \hologo{LaTeX}:& |\pageref{foobar}|\\
+% \xpackage{zref}:& |\zref@extract{foobar}{page}|
+% \end{tabular}
+% \end{quote}
+% Both \cs{zref@extract} and \cs{zref@extractdefault} are
+% expandable. That means, these macros can directly
+% be used in expandable calculations, see the example file.
+% On the other side, babel's shorthands are not supported,
+% there are no warnings in case of undefined references.
+%
+% If an user interface doesn't need expandable macros
+% then it can use \cs{zref@refused} and \cs{zref@wrapper@babel}
+% for its user macros.
+%
+% \begin{declcs}{zref@refused}
+% \M{refname}
+% \end{declcs}
+% This command is not expandable. It causes the warnings if
+% the reference \meta{refname} is not defined. Use the
+% \cs{zref@extract} commands inside expandable contexts and
+% mark their use outside by \cs{zref@refused}, see the example
+% file.
+%
+% \begin{declcs}{zref@def@extract}%
+% \M{cmd} \M{refname} \M{propname}\\
+% \cs{zref@def@extractdefault}
+% \M{cmd} \M{refname} \M{propname} \M{default}
+% \end{declcs}
+% Both macros extract the property \meta{propname} from the reference
+% \meta{refname} the same way as macros \cs{zref@extract} and
+% \cs{zref@extractdefault}. The result is stored in macro \meta{cmd}.
+% Also \cs{zref@refused} is called to notify \hologo{LaTeX} that
+% the reference \meta{refname} is used. Added in 2011/10/04 v2.22.
+%
+% \begin{declcs}{zref@ifrefundefined}\markexp
+% \M{refname} \M{then} \M{else}
+% \end{declcs}
+% Macro \cs{zref@ifrefundefined} calls arguments \meta{then} or \meta{else}
+% dependent on the existence of the reference \meta{refname}.
+%
+% \begin{declcs}{zifrefundefined}
+% \M{refname} \M{then} \M{else}
+% \end{declcs}
+% Macro \cs{zifrefundefined} calls \cs{ref@refused} before
+% executing \cs{zref@ifrefundefined}. Babel shorthands are
+% supported in \meta{refname}.
+%
+% \begin{declcs}{zref@ifrefcontainsprop}\markexp
+% \M{refname} \M{propname} \M{then} \M{else}
+% \end{declcs}
+% Test whether a reference provides a property.
+%
+% \subsection{Setup}
+%
+% \begin{declcs}{zref@default}
+% \end{declcs}
+% Holds the global default for unknown values.
+%
+% \begin{declcs}{zref@setdefault}
+% |{|\meta{value}|}|
+% \end{declcs}
+% Sets the global default for unknown values.
+% The global default is used, if a property does not specify
+% an own default and the value for a property
+% cannot be extracted. This can happen if the reference is
+% unknown or the reference does not have the property.
+%
+% \begin{declcs}{zref@setmainlist}
+% |{|\meta{value}|}|
+% \end{declcs}
+% Sets the name of the main property list. The package
+% sets and uses |main|.
+%
+% \subsection{Declared properties}
+%
+% \begin{quote}
+% \renewcommand*{\arraystretch}{1.05}
+% \setlength{\tabcolsep}{2\tabcolsep}
+% \def\VV{\vphantom{\large \"Ag}}
+% \def\EMPTY{{\itshape\textless empty\textgreater}}
+% \def\pl#1{&#1&thepage&\cs{number}\cs{#1}}
+% \begin{tabular}{@{}>{\sffamily}l|>{\ttfamily}l|>{\ttfamily}l|>{\ttfamily}l@{}}
+% \rmfamily Module&
+% \rmfamily Property&
+% \rmfamily Property list&
+% \rmfamily Default\\
+% \hline
+% (base)
+% & default & main & \EMPTY\\
+% & page & main & \EMPTY\\
+% \hline
+% abspage
+% & abspage & main & 0\\
+% \hline
+% counter
+% & counter & main & \EMPTY\\
+% \hline
+% hyperref
+% & anchor & main & \EMPTY\\
+% & url & & \EMPTY\\
+% \hline
+% pageattr
+% & pdfpageattr & thepage & \dots\\
+% & pdfpagesattr & LastPage & \dots\\
+% \hline
+% pagelayout\footnotemark
+% \pl{mag}\\
+% \pl{paperwidth}\\
+% \pl{paperheight}\\
+% \pl{stockwidth}\\
+% \pl{stockheight}\\
+% \pl{pdfpageheight}\\
+% \pl{pdfpagewidth}\\
+% \pl{pdfhorigin}\\
+% \pl{pdfvorigin}\\
+% \pl{hoffset}\\
+% \pl{voffset}\\
+% \pl{topmargin}\\
+% \pl{oddsidemargin}\\
+% \pl{evensidemargin}\\
+% \pl{textwidth}\\
+% \pl{textheight}\\
+% \pl{headheight}\\
+% \pl{headsep}\\
+% \pl{footskip}\\
+% \pl{marginparwidth}\\
+% \pl{marginparsep}\\
+% \pl{columnwidth}\\
+% \pl{columnsep}\\
+% \hline
+% perpage
+% & pagevalue & perpage & 0\\
+% & page & perpage & \EMPTY\\
+% & abspage & perpage & 0\\
+% \hline
+% savepos
+% & posx & savepos & 0\\
+% & posy & savepos & 0\\
+% \hline
+% titleref
+% & title & main & \EMPTY\\
+% \hline
+% xr
+% & anchor & & \EMPTY\\
+% & externaldocument & & \EMPTY\\
+% & theotype & & \EMPTY\\
+% & title & & \EMPTY\\
+% & url & & \EMPTY\\
+% \end{tabular}
+% \footnotetext{Module \xmodule{pagelayout} only defines properties
+% if the parameter exists.}%
+% \end{quote}
+%
+% \subsection{Wrapper for advanced situations}
+%
+% \begin{declcs}{zref@wrapper@babel}
+% |{|\dots|}| \M{name}
+% \end{declcs}
+% This macro helps to add shorthand support. The second
+% argument is protected, then the code of the first argument
+% is called with the protected name appended. Examples
+% are in the sources.
+%
+% \begin{declcs}{zref@wrapper@immediate}
+% |{|\dots|}|
+% \end{declcs}
+% There are situations where a label must be written instantly
+% to the \xfile{.aux} file, for example after the last page.
+% If the \cs{zlabel} or \cs{label} command is put inside this wrapper,
+% immediate writing is enabled. See the implementation for
+% module \xmodule{lastpage} for an example of its use.
+%
+% \begin{declcs}{zref@wrapper@unexpanded}
+% |{|\dots|}|
+% \end{declcs}
+% Assuming someone wants to extract a value for property |bar|
+% and store the result in a macro |\foo| without traces of
+% the expanding macros and without expanding the value.
+% This (theoretical?) problem can be solved by this wrapper:
+% \begin{quote}
+%\begin{verbatim}
+%\zref@wrapper@unexpanded{%
+% \edef\foo{%
+% \zref@extract{someref}{bar}%
+% }%
+%}
+%\end{verbatim}
+% \end{quote}
+% The \cs{edef} forces the expansion of \cs{zref@extract},
+% but the extraction of the value is prevented by
+% the wrapper that uses \hologo{eTeX}'\ \cs{unexpanded} for this
+% purpose. Supported macros are \cs{zref@extract}, \cs{zref@extractdefault}
+% and since version 2010/04/22 v2.14 macro \cs{zref@getcurrent}.
+%
+% \subsection{Counter for unique names}
+%
+% Some modules (\xmodule{titleref} and \xmodule{dotfillmin})
+% need unique names for automatically generated label names.
+%
+% \begin{declcs}{zref@require@unique}
+% \end{declcs}
+% This command creates the unique counter |zref@unique| if the
+% counter does not already exist.
+%
+% \begin{declcs}{thezref@unique}
+% \end{declcs}
+% This command is used to generate unique label names.
+%
+% \section{User interface}\label{sec:user}
+%
+% \subsection{Module \xmodule{user}}
+%
+% The user interface for this package and its modules
+% is enabled by \xpackage{zref}'s package option \xmodule{user}
+% or package \xpackage{zref-user}.
+% The names of user commands are prefixed by |z| in order
+% to avoid name clashes with existing macros of the same
+% functionality. Thus the package does not disturb the
+% traditional reference scheme, both can be used together.
+%
+% The syntax descriptions contain the following markers
+% that are intended as hints for programmers:
+% \begin{quote}
+% \begin{tabular}{@{}ll@{}}
+% \markbabel\unskip & Babel shorthands are allowed.\\
+% \markrobust\unskip & Robust macro.\\
+% \markexp\unskip & Expandable version:\\
+% & \textbullet\ robust,
+% unless the extracted values are fragile,\\
+% & \textbullet\ no babel shorthand suport.\\
+% \markexptwo\unskip & Expandable like \markexp and:\\
+% & \textbullet\ expandable in exact two steps.\\
+% \end{tabular}
+% \end{quote}
+%
+% The basic user interface of the package without modules
+% are commands that mimic the standard \hologo{LaTeX} behaviour
+% of \cs{label}, \cs{ref}, and \cs{pageref}:
+%
+% \begin{declcs}{zlabel}
+% \M{refname}\markbabel
+% \end{declcs}
+% Similar to \cs{label}. It generates a label with name
+% \meta{refname} in the new reference scheme.
+%
+% \begin{declcs}{zref}
+% |[|\meta{propname}|]| \M{refname}\markbabel
+% \end{declcs}
+% Without optional argument similar to \cs{ref}, it returns
+% the default reference property. This property is named
+% |default|:
+% \[
+% |\zref{|x|}| \equiv |\zref[default]{|x|}|
+% \]
+%
+% \begin{declcs}{zpageref}
+% \M{refname}\markbabel
+% \end{declcs}
+% Convenience macro, similar to \cs{pageref}.
+% \[
+% |\zpageref{|x|}| \equiv |\zref[page]{|x|}|
+% \]
+%
+% \begin{declcs}{zrefused}
+% \M{refname}\markbabel
+% \end{declcs}
+% Some of the user commands in the modules are expandable.
+% The use of such commands do not cause any undefined
+% reference warnings, because inside of expandable
+% contexts this is not possible. However, if there is
+% a place outside of expandable contexts, \cs{refused}
+% is strongly recommended. The reference \meta{refname}
+% is marked as used, undefined ones will generate
+% warnings.
+%
+% \subsection{Module \xmodule{abspage}}
+%
+% With the help of package \xpackage{atbegshi}
+% a new counter |abspage| with absolute page numbers is provided.
+% Also a new property |abspage| is defined and added to the
+% main property list. Thus you can reference the absolute
+% page number:
+% \begin{quote}
+% |Section \zref{foo} is on page \zpageref{foo}.|\\
+% |This is page \zref[abspage]{foo}|\\
+% |of \zref[abspage]{LastPage}.|
+% \end{quote}
+% The example also makes use of module \xmodule{lastpage}.
+%
+% \subsection{Module \xmodule{lastpage}}
+%
+% Provides the functionality of package \xpackage{lastpage}
+% \cite{lastpage} in the new reference scheme.
+% The label |LastPage| is put at the end of the document.
+% You can refer the last page number with:
+% \begin{quote}
+% |\zref@extract{LastPage}{page}| (+ |\zref@refused{LastPage}|)\\
+% \end{quote}
+% or
+% \begin{quote}
+% |\zpageref{LastPage}| (module \xmodule{user})
+% \end{quote}
+%
+% Since version 2008/10/01 v2.3 the module defines the list |LastPage|.
+% In addition to the properties of the main list label |LastPage| also
+% stores the properties of this list |LastPage|. The default of this
+% list is empty. The list can be used by the user to add additional
+% properties for label |LastPage|.
+%
+% \subsubsection{Tests for last page}
+%
+% Since version 2010/03/26 v2.8 the macros \cs{zref@iflastpage}
+% and \cs{ziflastpage} were added. They test the reference,
+% whether it is a reference of the last page.
+%
+% \begin{declcs}{zref@iflastpage}\markexp \M{refname} \M{then} \M{else}
+% \end{declcs}
+% Macro \cs{zref@iflastpage} compares the references \meta{refname}
+% with \meta{LastPage}. Basis of the comparison is the value of
+% property |abspage|, because the values are different for different
+% pages. This is not ensured by property |page|. Therefore module
+% \xmodule{abspage} is loaded by module \xmodule{lastpage}.
+% If both values of property |abspage| are present and match,
+% then \meta{then} is executed, otherwise code \meta{else} is called.
+% If one or both references are undefined or lack the property |abspage|,
+% then \meta{else} is executed.
+%
+% Macro \cs{zref@iflastpage} is expandable, therefore \cs{zref@refused}
+% should be called on \meta{refname} and \meta{LastPage}.
+%
+% \begin{declcs}{ziflastpage} \M{refname} \M{then} \M{else}
+% \end{declcs}
+% Macro \cs{ziflastpage} has the same function as \cs{zref@iflastpage},
+% but adds support for babel shorthands in \meta{refname} and
+% calls \cs{zref@refused}. However macro \cs{ziflastpage} is not
+% expandable.
+%
+% \subsubsection{Example}
+%
+% \begin{macrocode}
+%<*example-lastpage>
+%<<END_EXAMPLE
+\NeedsTeXFormat{LaTeX2e}
+\documentclass{report}
+
+\newcounter{foo}
+\renewcommand*{\thefoo}{\Alph{foo}}
+
+\usepackage{zref-lastpage,zref-user}[2019/11/29]
+
+\makeatletter
+\zref@newprop{thefoo}{\thefoo}
+\zref@newprop{valuefoo}{\the\value{foo}}
+\zref@newprop{chapter}{\thechapter}
+\zref@addprops{LastPage}{thefoo,valuefoo,chapter}
+\makeatother
+
+\newcommand*{\foo}{%
+ \stepcounter{foo}%
+ [Current foo: \thefoo]%
+}
+
+\begin{document}
+ \chapter{First chapter}
+ Last page is \zref{LastPage}.\\
+ Last chapter is \zref[chapter]{LastPage}.\\
+ Last foo is \zref[thefoo]{LastPage}.\\
+ Last value of foo is \zref[valuefoo]{LastPage}.\\
+ \foo
+ \chapter{Second chapter}
+ \foo\foo\foo
+ \chapter{Last chapter}
+ \foo
+\end{document}
+%END_EXAMPLE
+%</example-lastpage>
+% \end{macrocode}
+%
+% \subsection{Module \xmodule{thepage}}
+%
+% This module \xmodule{thepage} loads module \xmodule{abspage},
+% constructs a reference name using the absolute page number
+% and remembers property |page|. Other properties can be added
+% by adding them to the property list |thepage|.
+%
+% \begin{declcs}{zthepage} \M{absolute page number}\\
+% \end{declcs}
+% Macro \cs{zthepage} is basically a \cs{zpageref}. The reference
+% name is yield by the \meta{absolute page number}. If the reference
+% is not defined, then the default for property |page| is used.
+%
+% \begin{declcs}{zref@thepage@name}\markexp \M{absolute page number}
+% \end{declcs}
+% Macro \cs{zref@thepage@name} returns the internal reference
+% name that is constructed using the \meta{absolute page number}.
+% The internal reference name should not be used directly, because
+% it might change in future versions.
+%
+% \begin{declcs}{zref@thepage}\markexp \M{absolute page number}\\
+% \cs{zref@thepage@refused} \M{absolute page number}
+% \end{declcs}
+% Macro \cs{zref@thepage} returns the page number (\cs{thepage})
+% of \meta{absolute page number}. Because this macro is expandable,
+% \cs{zref@thepage@refused} is used outside an expandable context
+% to mark the reference as used.
+%
+%
+% \subsection{Module \xmodule{nextpage}}
+%
+% \begin{declcs}{znextpage}
+% \end{declcs}
+% Macro \cs{znextpage} prints \cs{thepage} of the following page.
+% It gets the current absolute page number by using a label.
+% There are three cases for the next page:
+% \begin{enumerate}
+% \item The next page is not known yet because of undefined references.
+% Then \cs{zunknownnextpagename} is used instead. The default for
+% this macro is the default of property |page|.
+% \item This page is the last page. Then \cs{znonextpagename}
+% is used. Its default is empty.
+% \item The next page is known, then \cs{thepage} of the next
+% page is used (the value of property |page| of the next page).
+% \end{enumerate}
+%
+% \subsubsection{Configuration}
+%
+% The behaviour can be configured by the following macros.
+%
+% \begin{declcs}{zunknownnextpagename}\\
+% \cs{znonextpagename}
+% \end{declcs}
+% If the next page is not known or available, then
+% \cs{znextpage} uses these name macros as default.
+% \cs{zunknownnextpagename} is used in case of undefined
+% references. Default is the value of property |page| of the
+% next page (\cs{thepage}). Module \xmodule{thepage} is used.
+%
+% Macro \cs{znonextpagename} is used, if the next page does
+% not exists. That means that the current page is last page.
+% The default is empty.
+%
+% \begin{declcs}{znextpagesetup} \M{unknown} \M{no next}
+% \M{next}
+% \end{declcs}
+% Acording to the case (see \cs{znextpage}) macro \cs{znextpage}
+% calls an internal macro with an argument. The argument is
+% either \cs{thepage} of the next page or one of \cs{zunknownnextpagename}
+% or \cs{znonextpagename}. These internal macro can be changed by
+% \cs{znextpagesetup}. It expects the definition texts for these
+% three cases of a macro with one argument.
+% The default is
+% \begin{quote}
+% |\znextpagesetup{#1}{#1}{#1}|
+% \end{quote}
+%
+% \subsubsection{Example}
+%
+% \begin{macrocode}
+%<*example-nextpage>
+%<<END_EXAMPLE
+\documentclass{book}
+
+\usepackage{zref-nextpage}[2019/11/29]
+\znextpagesetup
+ {\thepage}% next page is unknown
+ {\thepage\ (#1)}% this page is last page
+ {\thepage\ $\rightarrow$ #1}% next page is known
+\renewcommand*{\znonextpagename}{last page}
+
+\usepackage{fancyhdr}
+\pagestyle{fancy}
+\fancyhf{}
+\fancyhead[LE,RO]{\znextpage}
+\fancypagestyle{plain}{%
+ \fancyhf{}%
+ \fancyhead[LE,RO]{\znextpage}%
+}
+
+\begin{document}
+\frontmatter
+ \tableofcontents
+\mainmatter
+ \chapter{Hello World}
+ \clearpage
+ \section{Last section}
+\end{document}
+%END_EXAMPLE
+%</example-nextpage>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{totpages}}
+%
+% For the total number of pages of a document you need to
+% know the absolute page number of the last page.
+% Both modules \xmodule{abspage} and \xmodule{lastpage}
+% are necessary and automatically enabled.
+%
+% \begin{declcs}{ztotpages}\markexp
+% \end{declcs}
+% Prints the total number of pages or |0| if this
+% number is not yet known. It expands to an explicit number
+% and can also used even in expandable calculations (\cs{numexpr})
+% or counter assignments.
+%
+% \subsection{Module \xmodule{pagelayout}}
+%
+% The module defines additional properties for each parameter
+% of the page layout that is effective during page shipout.
+% The value of length parameters is given in sp without the
+% unit as plain number.
+%
+% Some parameters are specific for a class (e.g.\@ \xoption{stockwidth}
+% and \xoption{stockheight} for class \xclass{memoir}) or the
+% \hologo{TeX} engine like \hologo{pdfTeX}. If the parameter is not
+% available, then the property will not be defined. The default value
+% of the property is the current setting of the parameter.
+%
+% The module \xmodule{thepage} is loaded that generates a label
+% for each page. The properties of module \xmodule{pagelayout}
+% are added to the property list |thepage| of module \xmodule{thepage}.
+%
+% List of properties:
+% \begin{quote}
+% \def\x#1{\cs{#1}&#1}%
+% \begin{tabular}{l>{\sffamily}ll}
+% \textrm{parameter} & \textrm{property} & remarks\\
+% \hline
+% \x{mag}\\
+% \x{paperwidth}\\
+% \x{paperheight}\\
+% \x{stockwidth}& class \xclass{memoir}\\
+% \x{stockheight}& class \xclass{memoir}\\
+% \x{pdfpagewidth}& \hologo{pdfTeX}, \hologo{LuaTeX}\\
+% \x{pdfpageheight}& \hologo{pdfTeX}, \hologo{LuaTeX}\\
+% \x{pdfhorigin}& \hologo{pdfTeX}, \hologo{LuaTeX}\\
+% \x{pdfvorigin}& \hologo{pdfTeX}, \hologo{LuaTeX}\\
+% \x{hoffset}\\
+% \x{voffset}\\
+% \x{topmargin}\\
+% \x{oddsidemargin}\\
+% \x{evensidemargin}\\
+% \x{textwidth}\\
+% \x{textheight}\\
+% \x{headheight}\\
+% \x{headsep}\\
+% \x{footskip}\\
+% \x{marginparwidth}\\
+% \x{marginparsep}\\
+% \x{columnwidth}\\
+% \x{columnsep}\\
+% \end{tabular}
+% \end{quote}
+%
+% \begin{declcs}{zlistpagelayout}
+% \end{declcs}
+% At the end of document the page layout parameter for each page are
+% printed into the \xext{log} file if macro \cs{zlistpagelayout}
+% is called before |\end{document}| (preamble is a good place).
+%
+% \subsection{Module \xmodule{marks}}
+%
+% ToDo.
+%
+% \subsection{Module \xmodule{runs}}
+%
+% Module \xmodule{runs} counts the \hologo{LaTeX} runs since last
+% \xext{aux} file creation and prints the number in the
+% \xext{log} file.
+%
+% \begin{declcs}{zruns}\markexp
+% \end{declcs}
+% Prints the the total number of \hologo{LaTeX} runs including
+% the current one. It expands to an explicit number.
+% Before |begin{document}| the value is zero meaning
+% the \xext{aux} file is not read yet. If a previous
+% \xext{aux} file exists, the value found there increased
+% by one is the new number. Otherwise \cs{zruns} is set to one.
+% \hologo{LaTeX}~runs where the \xext{aux} files are not rewritten
+% are not counted (see \cs{nofiles}).
+%
+% \subsection{Module \xmodule{perpage}}
+%
+% With \cs{@addtoreset} or \cs{numberwithin} a counter can be
+% reset if another counter is incremented. This do not work
+% well if the other counter is the page counter. The page counter is
+% incremented in the output routine that is often called asynchronous
+% somewhere on the next page. A reference mechanism costs at least
+% two \hologo{LaTeX} runs, but ensures correct page counter values.
+%
+% \begin{declcs}{zmakeperpage}
+% |[|\meta{reset}|]| \M{counter}
+% \end{declcs}
+% At the of a new page counter \meta{counter} starts
+% counting with value \meta{reset} (default is \texttt{1}).
+% The macro has the same
+% syntax and semantics as \cs{MakePerPage} of package
+% \xpackage{perpage} \cite{perpage}.
+% Also \xoption{perpage} of package \xpackage{footmisc} \cite{footmisc}
+% can easily be simulated by
+% \begin{quote}
+% |\zmakeperpage{footnote}| \itshape |% \usepackage[perpage]{footmisc}|
+%\end{quote}
+% If footnote symbols are used, some people dislike the
+% first symbol \ensuremath{\dagger}. It can easily be skipped:
+% \begin{quote}
+% |\zmakeperpage[2]{footnote}|
+% \end{quote}
+%
+% \begin{declcs}{thezpage}\\
+% counter |zpage|
+% \end{declcs}
+% If the formatted counter value of the counter that is reset at
+% a new page contains the page value, then you can use \cs{thezpage},
+% the page number of the current page. Or counter |zpage| can be
+% used, if the page number should be formatted differently from
+% the current page number. Example:
+%\begin{quote}
+%\begin{verbatim}
+%\newcounter{foobar}
+%\zmakeperpage{foobar}
+%\renewcommand*{\thefoobar}{\thezpage-\arabic{foobar}}
+% % or
+%\renewcommand*{\thefoobar}{\roman{zpage}-\arabic{foobar}}
+%\end{verbatim}
+%\end{quote}
+%
+% \begin{declcs}{zunmakeperpage}
+% \M{counter}
+% \end{declcs}
+% The reset mechanism for this counter is deactivated.
+%
+%
+% \subsection{Module \xmodule{counter}}
+%
+% This option just add the property |counter| to the main
+% property list. The property stores the counter name,
+% that was responsible for the reference. This is the
+% property \xpackage{hyperref}'s \cs{autoref} feature
+% uses. Thus this property |counter| may be useful
+% for a reimplementation of the autoref feature,
+% see the section \ref{sec:todo} with the todo list.
+%
+% \subsection{Module \xmodule{titleref}}
+%
+% This option makes section and caption titles available
+% to the reference system similar to packages \xpackage{titleref}
+% or \xpackage{nameref}.
+%
+% \begin{declcs}{ztitleref}
+% \M{refname}\markbabel
+% \end{declcs}
+% Print the section or caption title of reference \meta{refname},
+% similar to \cs{nameref} or \cs{titleref}.
+%
+% \begin{declcs}{ztitlerefsetup}
+% |{|\textit{key$_1$=value$_1$, key$_2$=value$_2$, \dots}|}|
+% \end{declcs}
+% This command allows to configure the behaviour of module
+% \xmodule{titleref}. The following keys are available:
+% \begin{description}
+% \let\bfseries\relax
+% \item[\texttt{title=}\meta{value}]\mbox{}\\*
+% Sets the current title.
+% \item[\texttt{stripperiod=true\string|false}]\mbox{}\\*
+% Follow package \xpackage{nameref} that
+% removes a last period. Default: |true|.
+% \item[\texttt{expand=true\string|false}]\mbox{}\\*
+% Package \cs{titleref} expands the title first. This way
+% garbage and dangerous commands can be removed, e.g.
+% \cs{label}, \cs{index}\dots. See implementation section
+% for more details. Default is |false|.
+% \item[\texttt{cleanup=\{}\textrm{\dots}\texttt{\}}]\mbox{}\\*
+% Hook to add own cleanup code, if method |expand| is used.
+% See implementation section for more details.
+% \end{description}
+%
+% \subsection{Module \xmodule{savepos}}
+%
+% This option supports a feature that \pdfTeX\ provides
+% (and \hologo{XeTeX}).
+% \pdfTeX\ is able to tell the current position on the
+% page. The page position is not instantly known. First the
+% page must be constructed by \hologo{TeX}'s asynchronous output
+% routine. Thus the time where the position is known is
+% the page shipout time. Thus a reference system where the
+% information is recorded in the first run and made available
+% for use in the second run comes in handy.
+%
+% \begin{declcs}{zsavepos}
+% \M{refname}
+% \end{declcs}
+% It generates a reference with name \meta{refname}.
+% The reference stores the location where \cs{zsavepos}
+% is executed in properties |posx| and |posy|.
+%
+% \begin{declcs}{zsaveposx}
+% \M{refname}\\
+% \cs{zsaveposy}
+% \M{refname}
+% \end{declcs}
+% Same as \cs{zsavepos} except that only the |x| or |y| component
+% of the position is stored. Since 2011/12/05 v2.23.
+%
+% \begin{declcs}{zposx}\markexp
+% \M{refname}\\
+% \SpecialUsageIndex{\zposy}\cs{zposy}\markexp \M{refname}
+% \end{declcs}
+% Get the position as number. Unit is sp. Horizontal
+% positions by \cs{zposx} increase from left to right.
+% Vertical positions by \cs{zposy} from bottom to top.
+%
+% Do not rely on absolute page numbers. Because of problems
+% with the origin the numbers may differ in DVI or PDF mode
+% of \pdfTeX. Therefore work with relative values by comparisons.
+%
+% Both \cs{zposx} and \cs{zposy} are expandable and can be
+% used inside calculations (\cs{setcounter}, \cs{addtocounter},
+% package \xpackage{calc}, \cs{numexpr}). However this property
+% prevents from notifying \hologo{LaTeX} that the reference is actually
+% used (the notifying is not expandable). Therefore you should
+% mark the reference as used by \cs{zrefused}.
+%
+% This module uses \pdfTeX's \cs{pdfsavepos}, \cs{pdflastxpos},
+% and \cs{pdflastypos}. They are available in PDF mode and
+% since version 1.40.0 also in DVI mode.
+%
+% \begin{declcs}{zref@savepos}
+% \end{declcs}
+% Macro \cs{zref@savepos} performs the first part of \cs{zsavepos}
+% by calling \cs{pdfsavepos} (if \xext{aux} files are writable).
+%
+% Thus \cs{zsavepos} is basically \cs{zref@savepos} followed
+% by |\zref@labelbylist{|\texttt{\meta{refname}}|}{savepos}|.
+% If \cs{TeXXeTstate} is detected and enabled, \cs{savepos}
+% also adds \cs{zref@savepos} at the end to support \cs{beginR}
+% where the whatits are processed in reverse order.
+% The property list |savepos| contains the properties |posx|
+% and |posy|.
+%
+% \subsection{Module \xmodule{dotfill}}
+%
+% \begin{declcs}{zdotfill}
+% \end{declcs}
+% This package provides the command \cs{zdotfill} that works
+% similar to \cs{dotfill}, but can be configured. Especially
+% it suppresses the dots if a minimum number of dots cannot be set.
+%
+% \begin{declcs}{zdotfillsetup}
+% |{|\textit{key$_1$=value$_1$, key$_2$=value$_2$, \dots}|}|
+% \end{declcs}
+% This command allows to configure the behaviour of \cs{zdotfill}.
+% The following keys are available:
+% \begin{description}
+% \let\bfseries\relax
+% \item[\texttt{min=}\meta{count value}]\mbox{}\\*
+% If the actual number of dots are smaller than \meta{count value},
+% then the dots are suppressed. Default: |2|.
+% \item[\texttt{unit=}\meta{dimen value}]\mbox{}\\*
+% The width of a dot unit is given by \meta{dimen value}.
+% Default: |0.44em| (same as the unit in \cs{dotfill}).
+% \item[\texttt{dot=}\meta{value}]\mbox{}\\*
+% The dot itself is given by \meta{value}. Default: |.| (dot, same as
+% the dot in \cs{dotfill}).
+% \end{description}
+%
+% \subsection{Module \xmodule{env}}
+%
+% This module defines two properties |envname| and |envline|. They
+% remember the name of the environment and the line number at
+% the start of the environment.
+%
+% \subsection{Module \xmodule{xr}}
+%
+% This package provides the functionality of package \xpackage{xr},
+% see \cite{xr}. It also supports the syntax of \xpackage{xr-hyper}.
+%
+% \begin{declcs}{zexternaldocument}
+% \* |[|\meta{prefix}|]|\markbabel \M{external document}
+% |[|\meta{url}|]|
+% \end{declcs}
+% See \cs{externaldocument} for a description of this option.
+% The found labels also get a property |externaldocument| that
+% remembers \meta{external document}.
+% The standard reference scheme and the scheme of this
+% package use different name spaces for reference names.
+% If the external document uses both systems. Then one
+% import statement would put the names in one namespace
+% and probably causing problems with multiple references
+% of the same name. Thus the star form only looks for
+% \cs{newlabel} in the \xfile{.aux} files, whereas without
+% star only \cs{zref@newlabel}s are used.
+%
+% In the star form it tries to detect labels from
+% \xpackage{hyperref}, \xpackage{titleref}, and \xpackage{ntheorem}.
+% If such an extended property from the packages before cannot
+% be found or are empty, they are not included in the
+% imported reference.
+%
+% Warnings are given if a reference name is already in use
+% and the item is ignored. Unknown properties will automatically
+% be declared.
+%
+% If the external references contain |anchor| properties,
+% then we need also a url to be able to address the external
+% file. As default the filename is taken with a default
+% extension.
+%
+% \begin{declcs}{zxrsetup}
+% |{|\textit{key$_1$=value$_1$, key$_2$=value$_2$, \dots}|}|
+% \end{declcs}
+% The following setup options are available:
+% \begin{description}
+% \item[\xoption{ext}:] It sets the default extension.
+% \item[\xoption{tozreflabel}:] Boolean option. The found references
+% are imported as zref labels. This is enabled by default.
+% \item[\xoption{toltxlabel}:] Boolean option. The found references
+% are imported as \hologo{LaTeX} labels. Packages \xpackage{nameref},
+% \xpackage{titleref} and class \xclass{memoir} are supported.
+% \item[\xoption{urluse}:] Boolean option. If enabled, then a URL
+% is stored in a macro and the macro is put in property `urluse'.
+% The URL is not put in property `url'.
+% The purpose is to save \hologo{TeX} memory.
+% \item[\xoption{verbose}:] Boolean option. List the imported labels in the
+% \xext{log} file. Default is |false|.
+% \end{description}
+%
+% \begin{declcs}{zref@xr@ext}
+% \end{declcs}
+% If the \meta{url} is not specified in \cs{zref@externaldocument},
+% then the url will be constructed with the file name and
+% this macro as extension. \cs{XR@ext} is used if
+% \xpackage{hyperref} is loaded, otherwise |pdf|.
+%
+% \section{ToDo}\label{sec:todo}
+%
+% Among other things the following issues are left for future work:
+% \begin{itemize}
+% \item Other applications: autoref, hyperref, \dots
+% \end{itemize}
+%
+% \section{Example}
+%
+% \begin{macrocode}
+%<*example>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\documentclass{book}
+
+\usepackage[ngerman]{babel}%
+
+\usepackage[savepos,totpages,titleref,dotfill,counter,user]{zref}
+
+% \end{macrocode}
+%
+% Chapters are wrapped inside \cs{ChapterStart} and
+% \cs{ChapterStop}. The first argument \verb|#1| of \cs{ChapterStart}
+% is used to form a label id \verb|chap:#1|. At the end of
+% the chapter another label is set by \cs{zref@wrapper@immediate}, because
+% otherwise at the end of document a deferred write would not
+% be written, because there is no page for shipout.
+%
+% Also this example shows how chapter titles can be recorded.
+% A new property \verb|chaptitle| is declared and added to the
+% main property list. In \cs{ChapterStart} the current value
+% of the property is updated.
+% \begin{macrocode}
+\makeatletter
+\zref@newprop{chaptitle}{}
+\zref@addprop{main}{chaptitle}
+
+\newcommand*{\ChapterStart}[2]{%
+ \cleardoublepage
+ \def\current@chapid{#1}%
+ \zref@setcurrent{chaptitle}{#2}%
+ \chapter{#2}%
+ \zlabel{chap:#1}%
+}
+\newcommand*{\ChapterStop}{%
+ \cleardoublepage
+ \zref@wrapper@immediate{%
+ \zref@labelbyprops{chapend:\current@chapid}{abspage}%
+ }%
+}
+% \end{macrocode}
+% \cs{ChapterPages} calculates and returns the number of pages of the
+% referenced chapter.
+% \begin{macrocode}
+\newcommand*{\ChapterPages}[1]{%
+ \zrefused{chap:#1}%
+ \zrefused{chapend:#1}%
+ \number\numexpr
+ \zref@extract{chapend:#1}{abspage}%
+ -\zref@extract{chap:#1}{abspage}%
+ +1\relax
+}
+\makeatother
+% \end{macrocode}
+% \begin{macrocode}
+\begin{document}
+% \end{macrocode}
+% As exception we use \cs{makeatletter} here, because
+% this is just an example file that also should show some of
+% programmer's interface.
+% \begin{macrocode}
+\makeatletter
+
+\frontmatter
+\zlabel{documentstart}
+
+\begin{itemize}
+\item
+ The frontmatter part has
+ \number\numexpr\zref@extract{chap:first}{abspage}-1\relax
+ ~pages.
+\item
+ Chapter \zref{chap:first} has \ChapterPages{first} page(s).
+\item
+ Section \zref{hello} is on the
+ \ifcase\numexpr
+ \zref@extractdefault{hello}{page}{0}%
+ -\zref@extractdefault{chap:first}{page}{0}%
+ +1\relax
+ ??\or first\or second\or third\or forth\fi
+ ~page inside its chapter.
+\item
+ The document has
+ \zref[abspage]{LastPage} pages.
+ This number is \ifodd\ztotpages odd\else even\fi.
+\item
+ The last page is labeled with \zpageref{LastPage}.
+\item
+ The title of chapter \zref{chap:next} %
+ is ``\zref[chaptitle]{chap:next}''.
+\end{itemize}
+
+\tableofcontents
+
+\mainmatter
+\ChapterStart{first}{First chapter}
+
+% \end{macrocode}
+% The user level commands should protect babel shorthands
+% where possible. On the other side, expandable extracting
+% macros are useful in calculations, see above the
+% examples with \cs{numexpr}.
+% \begin{macrocode}
+\section{Test}
+\zlabel{a"o}
+Section \zref{a"o} on page
+\zref@wrapper@babel\zref@extract{a"o}{page}.
+
+Text.
+\newpage
+
+\section{Hello World}
+\zlabel{hello}
+
+\ChapterStop
+
+\ChapterStart{next}{Next chapter with \emph{umlauts}: "a"o"u"s}
+
+% \end{macrocode}
+%
+% Here an example follows that makes use of \pdfTeX's ``savepos''
+% feature. The position on the page is not known before the
+% page is constructed and shipped out. Therefore the position
+% ist stored in references and are available for calculations
+% in the next \hologo{LaTeX} compile run.
+% \begin{macrocode}
+The width of the first column is
+ \the\dimexpr \zposx{secondcol}sp - \zposx{firstcol}sp\relax,\\
+the height difference of the two baselines is
+ \the\dimexpr \zposy{firstcol}sp - \zposy{secondline}sp\relax:\\
+\begin{tabular}{ll}
+ \zsavepos{firstcol}Hello&\zsavepos{secondcol}World\\
+ \zsavepos{secondline}Second line&foobar\\
+\end{tabular}
+
+% \end{macrocode}
+% With \cs{zrefused} \hologo{LaTeX} is notified, if the references
+% are not yet available and \hologo{LaTeX} can generate the rerun
+% hint.
+% \begin{macrocode}
+\zrefused{firstcol}
+\zrefused{secondcol}
+\zrefused{secondline}
+
+\ChapterStop
+% \end{macrocode}
+% Test for module \cs{dotfill}.
+% \begin{macrocode}
+\ChapterStart{dotfill}{Test for dotfill feature}
+\newcommand*{\dftest}[1]{%
+ #1&
+ [\makebox[{#1}]{\dotfill}]&
+ [\makebox[{#1}]{\zdotfill}]\\
+}
+\begin{tabular}{rll}
+& [\verb|\dotfill|] & [\verb|\zdotfill|]\\
+\dftest{0.43em}
+\dftest{0.44em}
+\dftest{0.45em}
+\dftest{0.87em}
+\dftest{0.88em}
+\dftest{0.89em}
+\dftest{1.31em}
+\dftest{1.32em}
+\dftest{1.33em}
+\end{tabular}
+\ChapterStop
+\end{document}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</example>
+% \end{macrocode}
+%
+% \StopEventually{
+% }
+%
+% \section{Implementation}
+%
+% \subsection{Package \xpackage{zref}}
+%
+% \subsubsection{Identification}
+%
+% \begin{macrocode}
+%<*package>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref}
+ [2019/11/29 v2.28 A new reference scheme for LaTeX (HO)]%
+% \end{macrocode}
+%
+% \subsubsection{Load basic module}
+%
+% \begin{macrocode}
+\RequirePackage{zref-base}[2019/11/29]
+% \end{macrocode}
+% Abort package loading if \xpackage{zref-base} could not be
+% loaded successfully.
+% \begin{macrocode}
+\@ifundefined{ZREF@base@ok}{\endinput}{}
+% \end{macrocode}
+%
+% \subsubsection{Process options}
+%
+% Known modules are loaded and the release date is checked.
+% \begin{macrocode}
+\def\ZREF@temp#1{%
+ \DeclareOption{#1}{%
+ \AtEndOfPackage{%
+ \RequirePackage{zref-#1}[2019/11/29]%
+ }%
+ }%
+}
+\ZREF@temp{abspage}
+\ZREF@temp{counter}
+\ZREF@temp{dotfill}
+\ZREF@temp{hyperref}
+\ZREF@temp{lastpage}
+\ZREF@temp{marks}
+\ZREF@temp{nextpage}
+\ZREF@temp{pageattr}
+\ZREF@temp{pagelayout}
+\ZREF@temp{perpage}
+\ZREF@temp{runs}
+\ZREF@temp{savepos}
+\ZREF@temp{thepage}
+\ZREF@temp{titleref}
+\ZREF@temp{totpages}
+\ZREF@temp{user}
+\ZREF@temp{xr}
+% \end{macrocode}
+% \begin{macrocode}
+\ProcessOptions\relax
+%</package>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{base}}
+%
+% \subsubsection{Prefixes}
+%
+% This package uses the following prefixes for macro names:
+% \begin{description}
+% \item[\cs{zref@}:] Macros of the programmer's interface.
+% \item[\cs{ZREF@}:] Internal macros.
+% \item[\cs{Z@L@}\metacs{listname}:]
+% The properties of the list \meta{listname}.
+% \item[\cs{Z@D@}\metacs{propname}:]
+% The default value for property \meta{propname}.
+% \item[\cs{Z@E@}\metacs{propname}:]
+% Extract function for property \meta{propname}.
+% \item[\cs{Z@X@}\metacs{propname}:]
+% Information whether a property value for property
+% \meta{propname} is expanded
+% immediately or at shipout time.
+% \item[\cs{Z@C@}\metacs{propname}:]
+% Current value of the property \meta{propname}.
+% \item[\cs{Z@R@}\metacs{labelname}:]
+% Data for reference \meta{labelname}.
+% \item[\cs{ZREF@org@}:] Original versions of patched commands.
+% \item[\cs{z}:] For macros in user land, defined if
+% module \xmodule{user} is set.
+% \end{description}
+% The following family names are used for keys defined
+% according to the \xpackage{keyval} package:
+% \begin{description}
+% \item[\texttt{ZREF@TR}:] Setup for module \xmodule{titleref}.
+% \end{description}
+%
+% \subsubsection{Identification}
+%
+% \begin{macrocode}
+%<*base>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-base}%
+ [2019/11/29 v2.28 Module base for zref (HO)]%
+% \end{macrocode}
+%
+% \subsubsection{Utilities}
+%
+% \begin{macrocode}
+\RequirePackage{ltxcmds}[2010/12/02]
+\RequirePackage{infwarerr}[2010/04/08]
+\RequirePackage{kvsetkeys}[2010/03/01]
+\RequirePackage{kvdefinekeys}[2010/03/01]
+\RequirePackage{pdftexcmds}[2010/04/01]
+% \end{macrocode}
+%
+% \begin{macro}{\ZREF@name}
+% Several times the package name is used, thus we store it
+% in \cmd{\ZREF@name}.
+% \begin{macrocode}
+\def\ZREF@name{zref}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\ltx@IfUndefined{protected}{%
+ \RequirePackage{makerobust}[2006/03/18]%
+% \end{macrocode}
+% \begin{macro}{\ZREF@Robust}
+% \begin{macrocode}
+ \def\ZREF@Robust#1#2{%
+ \def\ZREF@temp{\MakeRobustcommand#2}%
+ \afterassignment\ZREF@temp
+ #1#2%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+}{%
+% \end{macrocode}
+% \begin{macro}{\ZREF@Robust}
+% \begin{macrocode}
+ \def\ZREF@Robust#1{%
+ \protected#1%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+}
+% \end{macrocode}
+% \begin{macro}{\ZREF@IfDefinable}
+% \begin{macrocode}
+\def\ZREF@IfDefinable#1#2#3{%
+ \@ifdefinable{#1}{%
+ \ZREF@Robust{#2}#1#3%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@UpdatePdfTeX}
+% \cs{ZREF@UpdatePdfTeX} is used as help message text in
+% error messages.
+% \begin{macrocode}
+\def\ZREF@UpdatePdfTeX{Update pdfTeX.}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifZREF@found}
+% The following switch is usded in list processing.
+% \begin{macrocode}
+\newif\ifZREF@found
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@patch}
+% Macro \cs{ZREF@patch} first checks the existence of
+% the command and safes it.
+% \begin{macrocode}
+\def\ZREF@patch#1{%
+ \ltx@IfUndefined{#1}{%
+ \ltx@gobble
+ }{%
+ \expandafter\let\csname ZREF@org@#1\expandafter\endcsname
+ \csname #1\endcsname
+ \ltx@firstofone
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Check for \hologo{eTeX}}
+%
+% The use of \hologo{eTeX} should be standard nowadays for \hologo{LaTeX}.
+% We test for \hologo{eTeX} in order to use its features later.
+% \begin{macrocode}
+\ltx@IfUndefined{eTeXversion}{%
+ \PackageError\ZREF@name{%
+ Missing support for eTeX; package is abandoned%
+ }{%
+ Use a TeX compiler that support eTeX and enable eTeX %
+ in the format.%
+ }%
+ \endinput
+}{}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{etexcmds}[2007/09/09]
+\ifetex@unexpanded
+\else
+ \PackageError\ZREF@name{%
+ Missing e-TeX's \string\unexpanded.\MessageBreak
+ Add \string\RequirePackage\string{etexcmds\string} before %
+ \string\documentclass%
+ }{%
+ Probably you are using some package (e.g. ConTeXt) that %
+ redefines \string\unexpanded%
+ }%
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \subsubsection{Auxiliary file stuff}
+%
+% We are using some commands in the \xfile{.aux} files.
+% However sometimes these auxiliary files are interpreted
+% by \hologo{LaTeX} processes that haven't loaded this package
+% (e.g. package \xpackage{xr}).
+% Therefore we provide dummy definitions.
+% \begin{macrocode}
+\RequirePackage{auxhook}
+\AddLineBeginAux{%
+ \string\providecommand\string\zref@newlabel[2]{}%
+}
+% \end{macrocode}
+% \begin{macro}{\ZREF@RefPrefix}
+% \begin{macrocode}
+\def\ZREF@RefPrefix{Z@R}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@newlabel}
+% For the implementation of \cs{zref@newlabel} we call
+% the same internal macro \cs{@newl@bel} that is used
+% in \cs{newlabel}. Thus we have for free:
+% \begin{itemize}
+% \item \cs{Z@R@}\metacs{labelname} is defined.
+% \item \hologo{LaTeX}'s check for multiple references.
+% \item \hologo{LaTeX}'s check for changed references.
+% \end{itemize}
+% \begin{macrocode}
+\ZREF@Robust\edef\zref@newlabel{%
+ \noexpand\@newl@bel{\ZREF@RefPrefix}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Property lists}
+%
+% \begin{macro}{\zref@newlist}
+% Property lists are stored as list of property names
+% enclosed in curly braces. \cs{zref@newlist}
+% creates a new list as empty list. Assignments to
+% property lists are global.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@newlist#1{%
+ \zref@iflistundefined{#1}{%
+ \@ifdefinable{Z@L@#1}{%
+ \global\expandafter\let\csname Z@L@#1\endcsname\ltx@empty
+ \PackageInfo\ZREF@name{New property list: #1}%
+ }%
+ }{%
+ \PackageError\ZREF@name{%
+ Property list `#1' already exists%
+ }\@ehc
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@iflistundefined}
+% \cs{zref@iflistundefined} checks the existence of the
+% property list \verb|#1|. If the property list is present,
+% then \verb|#2| is executed and \verb|#3| otherwise.
+% \begin{macrocode}
+\def\zref@iflistundefined#1{%
+ \ltx@ifundefined{Z@L@#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@listexists}
+% \cs{zref@listexists} only executes \verb|#2| if the
+% property list \verb|#1| exists and raises an error
+% message otherwise.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@listexists#1{%
+ \zref@iflistundefined{#1}{%
+ \PackageError\ZREF@name{%
+ Property list `#1' does not exist%
+ }\@ehc
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@iflistcontainsprop}
+% \cs{zref@iflistcontainsprop} checks, whether a property \verb|#2| is
+% already present in a property list \verb|#1|.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@iflistcontainsprop#1#2{%
+ \zref@iflistundefined{#1}{%
+ \ltx@secondoftwo
+ }{%
+ \begingroup\expandafter\endgroup
+ \expandafter\in@
+ \csname#2\expandafter\expandafter\expandafter\endcsname
+ \expandafter\expandafter\expandafter{\csname Z@L@#1\endcsname}%
+ \csname ltx@\ifin@ first\else second\fi oftwo\endcsname
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@listforloop}
+% \begin{macrocode}
+\def\zref@listforloop#1#2{%
+ \zref@listexists{#1}{%
+ \expandafter\expandafter\expandafter\@tfor
+ \expandafter\expandafter\expandafter\zref@prop
+ \expandafter\expandafter\expandafter:%
+ \expandafter\expandafter\expandafter=%
+ \csname Z@L@#1\endcsname
+ \do{%
+ \begingroup
+ \escapechar=-1 %
+ \edef\x{\endgroup
+ \def\noexpand\zref@prop{%
+ \expandafter\string\zref@prop
+ }%
+ }%
+ \x
+ #2\zref@prop
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@addprops}
+% \cs{zref@addprop} adds the properties \verb|#2| to the property
+% list \verb|#1|, if the property is not already in the list.
+% Otherwise a warning is given.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@addprops#1#2{%
+ \zref@listexists{#1}{%
+ \comma@parse{#2}{%
+ \zref@propexists\comma@entry{%
+ \zref@iflistcontainsprop{#1}\comma@entry{%
+ \PackageWarning\ZREF@name{%
+ Property `\comma@entry' is already in list `#1'%
+ }%
+ }{%
+ \begingroup\expandafter\endgroup
+ \expandafter\g@addto@macro
+ \csname Z@L@#1\expandafter\endcsname
+ \expandafter{\csname\comma@entry\endcsname}%
+ }%
+ }%
+ \ltx@gobble
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@addprop}
+% \cs{zref@addprop} adds the property \verb|#2| to the property
+% list \verb|#1|, if the property is not already in the list.
+% Otherwise a warning is given.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@addprop#1#2{%
+ \zref@listexists{#1}{%
+ \zref@propexists{#2}{%
+ \zref@iflistcontainsprop{#1}{#2}{%
+ \PackageWarning\ZREF@name{%
+ Property `#2' is already in list `#1'%
+ }%
+ }{%
+ \begingroup\expandafter\endgroup
+ \expandafter\g@addto@macro
+ \csname Z@L@#1\expandafter\endcsname
+ \expandafter{\csname#2\endcsname}%
+ }%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@localaddprops}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@localaddprops#1#2{%
+ \zref@listexists{#1}{%
+ \comma@parse{#2}{%
+ \zref@propexists\comma@entry{%
+ \zref@iflistcontainsprop{#1}\comma@entry{%
+ \PackageWarning\ZREF@name{%
+ Property `\comma@entry' is already in list `#1'%
+ }%
+ }{%
+ \begingroup\expandafter\endgroup
+ \expandafter\ltx@LocalAppendToMacro
+ \csname Z@L@#1\expandafter\endcsname
+ \expandafter{\csname\comma@entry\endcsname}%
+ }%
+ }%
+ \ltx@gobble
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@localaddprop}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@localaddprop#1#2{%
+ \zref@listexists{#1}{%
+ \zref@propexists{#2}{%
+ \zref@iflistcontainsprop{#1}{#2}{%
+ \PackageWarning\ZREF@name{%
+ Property `#2' is already in list `#1'%
+ }%
+ }{%
+ \begingroup\expandafter\endgroup
+ \expandafter\ltx@LocalAppendToMacro
+ \csname Z@L@#1\expandafter\endcsname
+ \expandafter{\csname#2\endcsname}%
+ }%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\ltx@IfUndefined{pdf@strcmp}{%
+% \end{macrocode}
+% \begin{macro}{\zref@delprop}
+% \begin{macrocode}
+ \ZREF@Robust\def\zref@delprop{%
+ \ZREF@delprop\gdef
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@localdelprop}
+% \begin{macrocode}
+ \ZREF@Robust\def\zref@localdelprop{%
+ \ZREF@delprop\def
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@delprop}
+% \begin{macrocode}
+ \def\ZREF@delprop#1#2#3{%
+ \zref@listexists{#2}{%
+ \begingroup
+ \escapechar=-1 %
+ \def\ZREF@param{#3}%
+ \@onelevel@sanitize\ZREF@param
+ \toks@{}%
+ \expandafter\expandafter\expandafter\ZREF@@delprop
+ \csname Z@L@#2\endcsname!%
+ \expandafter\endgroup
+ \expandafter#1\csname Z@L@#2\expandafter\endcsname
+ \expandafter{%
+ \the\toks@
+ }%
+ }%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@@delprop}
+% \begin{macrocode}
+ \def\ZREF@@delprop#1{%
+ \expandafter\ZREF@@@delprop\expandafter{\string#1}#1%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@@@delprop}
+% \begin{macrocode}
+ \def\ZREF@@@delprop#1#2{%
+ \ifx#2!%
+ \else
+ \def\ZREF@temp{#1}%
+ \@onelevel@sanitize\ZREF@temp
+ \ifx\ZREF@param\ZREF@temp
+ \else
+ \toks@\expandafter{%
+ \the\expandafter\toks@\csname#1\endcsname
+ }%
+ \fi
+ \expandafter\ZREF@@delprop
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+}{%
+% \end{macrocode}
+% \begin{macro}{\zref@delprop}
+% \begin{macrocode}
+ \ZREF@Robust\def\zref@delprop{%
+ \ZREF@delprop\xdef
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@localdelprop}
+% \begin{macrocode}
+ \ZREF@Robust\def\zref@localdelprop{%
+ \ZREF@delprop\edef
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@delprop}
+% \begin{macrocode}
+ \def\ZREF@delprop#1#2#3{%
+ \zref@listexists{#2}{%
+ \def\ZREF@param{#3}%
+ \edef\ZREF@SavedEscapechar{\the\escapechar}%
+ \escapechar=-1 %
+ \expandafter#1\csname Z@L@#2%
+ \expandafter\expandafter\expandafter\endcsname{%
+ \expandafter\expandafter\expandafter\ZREF@@delprop
+ \csname Z@L@#2\endcsname!%
+ }%
+ \escapechar=\ZREF@SavedEscapechar\relax
+ }%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@@delprop}
+% Caution: |#1| might be an \cs{if} or similar token.
+% \begin{macrocode}
+ \def\ZREF@@delprop#1{%
+ \expandafter\ZREF@@@delprop\expandafter{\string#1}#1%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@@@delprop}
+% \begin{macrocode}
+ \def\ZREF@@@delprop#1#2{%
+ \ifx#2!%
+ \else
+ \ifnum\pdf@strcmp{#1}{\ZREF@param}=\ltx@zero
+ \else
+ \expandafter\noexpand\csname#1\endcsname
+ \fi
+ \expandafter\ZREF@@delprop
+ \fi
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+}
+% \end{macrocode}
+%
+% \subsubsection{Properties}
+%
+% \begin{macro}{\zref@ifpropundefined}
+% \cs{zref@ifpropundefined} checks the existence of the
+% property \verb|#1|. If the property is present,
+% then \verb|#2| is executed and \verb|#3| otherwise.
+% \begin{macrocode}
+\def\zref@ifpropundefined#1{%
+ \ltx@ifundefined{Z@E@#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@propexists}
+% Some macros rely on the existence of a property.
+% \cs{zref@propexists} only executes \verb|#2| if the
+% property \verb|#1| exists and raises an error
+% message otherwise.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@propexists#1{%
+ \zref@ifpropundefined{#1}{%
+ \PackageError\ZREF@name{%
+ Property `#1' does not exist%
+ }\@ehc
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@newprop}
+% A new property is declared by \cs{zref@newprop}, the
+% property name \meta{propname} is given in \verb|#1|. The
+% property is created and configured. If the star form
+% is given, then the expansion of the property value
+% is delayed to page shipout time, when the reference
+% is written to the \xfile{.aux} file.
+% \begin{description}
+% \item[\cs{Z@D@}\metacs{propname}:]
+% Stores the default value for this property.
+% \item[\cs{Z@E@}\metacs{propname}:]
+% Extract function.
+% \item[\cs{Z@X@}\metacs{propname}:]
+% Information whether the expansion of the property value
+% is delayed to shipout time.
+% \item[\cs{Z@C@}\metacs{propname}:]
+% Current value of the property.
+% \end{description}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@newprop{%
+ \@ifstar{%
+ \let\ZREF@X\noexpand
+ \ZREF@newprop
+ }{%
+ \let\ZREF@X\ltx@empty
+ \ZREF@newprop
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@newprop}
+% \begin{macrocode}
+\def\ZREF@newprop#1{%
+ \edef\ZREF@P{#1}%
+ \@onelevel@sanitize\ZREF@P
+ \begingroup
+ \ifx\ZREF@P\ZREF@par
+ \@PackageError\ZREF@name{%
+ Invalid property name `\ZREF@P'%
+ }{%
+ The property name `par' is not allowed %
+ because of internal reasons.%
+ \MessageBreak
+ \@ehc
+ }%
+ \def\ZREF@@newprop[##1]##2{\endgroup}%
+ \else
+ \zref@ifpropundefined\ZREF@P{%
+ \endgroup
+ \PackageInfo\ZREF@name{%
+ New property: \ZREF@P
+ }%
+ }{%
+ \@PackageError\ZREF@name{%
+ Property `\ZREF@P' already exists%
+ }\@ehc
+ \def\ZREF@@newprop[##1]##2{\endgroup}%
+ }%
+ \fi
+ \@ifnextchar[\ZREF@@newprop{\ZREF@@newprop[\zref@default]}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@par}
+% \begin{macrocode}
+\def\ZREF@par{par}
+\@onelevel@sanitize\ZREF@par
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@@newprop}
+% \begin{macrocode}
+\def\ZREF@@newprop[#1]{%
+ \global\@namedef{Z@D@\ZREF@P}{#1}%
+ \global\expandafter\let\csname Z@X@\ZREF@P\endcsname\ZREF@X
+ \begingroup\expandafter\endgroup
+ \expandafter\ZREF@@@newprop\csname\ZREF@P\endcsname
+ \expandafter\gdef\csname Z@C@\ZREF@P\endcsname{}%
+ \zref@setcurrent\ZREF@P
+}
+\def\ZREF@@@newprop#1{%
+ \expandafter
+ \gdef\csname Z@E@\ZREF@P\endcsname##1#1##2##3\ZREF@nil{##2}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@showprop}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@showprop#1{%
+ \zref@ifpropundefined{#1}{%
+ \@PackageInfoNoLine{\ZREF@name}{%
+ Show property `#1': <undefined>%
+ }%
+ }{%
+ \begingroup
+ \toks@\expandafter\expandafter\expandafter{%
+ \csname Z@C@#1\endcsname
+ }%
+ \edef\ZREF@value{\the\toks@}%
+ \ltx@onelevel@sanitize\ZREF@value
+ \toks@\expandafter\expandafter\expandafter{%
+ \csname Z@D@#1\endcsname
+ }%
+ \edef\ZREF@default{\the\toks@}%
+ \ltx@onelevel@sanitize\ZREF@default
+ \@PackageInfoNoLine{\ZREF@name}{%
+ Show property `#1':\MessageBreak
+ \expandafter\ifx\csname Z@X@#1\endcsname\ltx@empty
+ Immediate %
+ \else
+ Delayed %
+ \fi
+ value: [\ZREF@value]\MessageBreak
+ Default: [\ZREF@default]%
+ }%
+ \endgroup
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@setcurrent}
+% \cs{zref@setcurrent} sets the current value for a property.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@setcurrent#1#2{%
+ \zref@propexists{#1}{%
+ \expandafter\def\csname Z@C@#1\endcsname{#2}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@getcurrent}
+% \cs{zref@getcurrent} gets the current value for a property.
+% \begin{macrocode}
+\def\ZREF@getcurrent#1{%
+ \romannumeral0%
+ \ltx@ifundefined{Z@C@#1}{%
+ \ltx@space
+ }{%
+ \expandafter\expandafter\expandafter\ltx@space
+ \csname Z@C@#1\endcsname
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@u@getcurrent}
+% \begin{macrocode}
+\def\ZREF@wu@getcurrent#1{%
+ \etex@unexpanded\expandafter\expandafter\expandafter{%
+ \ZREF@getcurrent{#1}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@getcurrent}
+% \begin{macrocode}
+\let\zref@getcurrent\ZREF@getcurrent
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Reference generation}
+%
+% \begin{macro}{\zref@label}
+% Label macro that uses the main property list.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@label#1{%
+ \zref@labelbylist{#1}\ZREF@mainlist
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@labelbylist}
+% Label macro that stores the properties, specified in the
+% property list \verb|#2|.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@labelbylist#1#2{%
+ \@bsphack
+ \zref@listexists{#2}{%
+ \expandafter\expandafter\expandafter\ZREF@label
+ \expandafter\expandafter\expandafter{%
+ \csname Z@L@#2\endcsname
+ }{#1}%
+ }%
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@labelbyprops}
+% The properties are directly specified in a comma separated list.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@labelbyprops#1#2{%
+ \@bsphack
+ \begingroup
+ \toks@{}%
+ \comma@parse{#2}{%
+ \zref@ifpropundefined\comma@entry{%
+ \PackageWarning\ZREF@name{%
+ Property `\comma@entry' is not known%
+ }%
+ }{%
+ \toks@\expandafter{%
+ \the\expandafter\toks@\csname\comma@entry\endcsname
+ }%
+ }%
+ \ltx@gobble
+ }%
+ \expandafter\endgroup
+ \expandafter\ZREF@label\expandafter{\the\toks@}{#1}%
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@labelbykv}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@labelbykv#1#2{%
+ \@bsphack
+ \begingroup
+ \let\Z@L@ZREF@temp\ltx@empty
+ \kvsetkeys{ZREF@LABEL}{#1}%
+ \ifZREF@immediate
+ \expandafter\zref@wrapper@immediate\expandafter{%
+ \expandafter\ZREF@label\expandafter{\Z@L@ZREF@temp}{#2}%
+ }%
+ \else
+ \expandafter\ZREF@label\expandafter{\Z@L@ZREF@temp}{#2}%
+ \fi
+ \endgroup
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\kv@define@key{ZREF@LABEL}{prop}{%
+ \edef\ZREF@param{#1}%
+ \zref@propexists\ZREF@param{%
+ \zref@iflistcontainsprop{ZREF@temp}\ZREF@param{}{%
+ \begingroup\expandafter\endgroup
+ \expandafter\ltx@LocalAppendToMacro
+ \expandafter\Z@L@ZREF@temp
+ \expandafter{\csname\ZREF@param\endcsname}%
+ }%
+ }%
+}
+\kv@define@key{ZREF@LABEL}{list}{%
+ \zref@listforloop{#1}{%
+ \zref@iflistcontainsprop{ZREF@temp}\zref@prop{}{%
+ \begingroup\expandafter\endgroup
+ \expandafter\ltx@LocalAppendToMacro
+ \expandafter\Z@L@ZREF@temp
+ \expandafter{\csname\zref@prop\endcsname}%
+ }%
+ \ltx@gobble
+ }%
+}
+\kv@define@key{ZREF@LABEL}{delprop}{%
+ \zref@propexists{#1}{%
+ \zref@localdelprop{ZREF@temp}{#1}%
+ }%
+}
+\kv@define@key{ZREF@LABEL}{immediate}[true]{%
+ \edef\ZREF@param{#1}%
+ \ifx\ZREF@param\ZREF@true
+ \ZREF@immediatetrue
+ \else
+ \ifx\ZREF@param\ZREF@false
+ \ZREF@immediatefalse
+ \else
+ \PackageWarning\ZREF@name{%
+ Option `immediate' expects `true' or `false'.\MessageBreak
+ Ignoring invalid value `\ZREF@param'%
+ }%
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \begin{macro}{\ZREF@false}
+% \begin{macrocode}
+\def\ZREF@false{false}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@true}
+% \begin{macrocode}
+\def\ZREF@true{true}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\kv@define@key{ZREF@LABEL}{values}[]{%
+ \kv@parse{#1}{%
+ \ifx\kv@value\relax
+ \@PackageWarning\ZREF@name{%
+ Missing value for property `\kv@key'%
+ }%
+ \expandafter\ltx@gobbletwo
+ \else
+ \expandafter\zref@setcurrent
+ \fi
+ }%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\ifZREF@immediate}
+% The switch \cs{ifZREF@immediate} tells us, whether the
+% label should be written immediately or at page shipout time.
+% \cs{ZREF@label} need to be notified about this, because
+% it must disable the deferred execution of property values,
+% if the label is written immediately.
+% \begin{macrocode}
+\newif\ifZREF@immediate
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@wrapper@immediate}
+% The argument of \cs{zref@wrapper@immediate} is executed inside
+% a group where \cs{write} is redefined by adding
+% \cs{immediate} before its execution. Also \cs{ZREF@label}
+% is notified via the switch \cs{ifZREF@immediate}.
+% \begin{macrocode}
+\ZREF@Robust{\long\def}\zref@wrapper@immediate#1{%
+ \begingroup
+ \ZREF@immediatetrue
+ \let\ZREF@org@write\write
+ \def\write{\immediate\ZREF@org@write}%
+ #1%
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@label}
+% \cs{ZREF@label} writes the data in the \xfile{.aux} file.
+% \verb|#1| contains the list of valid properties,
+% \verb|#2| the name of the reference. In case of immediate
+% writing, the deferred execution of property values is
+% disabled. Also \thepage is made expandable in this case.
+% \begin{macrocode}
+\def\ZREF@label#1#2{%
+ \if@filesw
+ \begingroup
+ \ifZREF@immediate
+ \let\ZREF@org@thepage\thepage
+ \fi
+ \protected@write\@auxout{%
+ \ifZREF@immediate
+ \let\thepage\ZREF@org@thepage
+ \fi
+ \let\ZREF@temp\ltx@empty
+ \@tfor\ZREF@P:=#1\do{%
+ \begingroup
+ \escapechar=-1 %
+ \edef\x{\endgroup
+ \def\noexpand\ZREF@P{%
+ \expandafter\string\ZREF@P
+ }%
+ }%
+ \x
+ \expandafter\ifx
+ \csname
+ \ifZREF@immediate
+ relax%
+ \else
+ Z@X@\ZREF@P%
+ \fi
+ \endcsname
+ \noexpand
+ \expandafter\let\csname Z@C@\ZREF@P\endcsname\relax
+ \fi
+ \toks@\expandafter{\ZREF@temp}%
+ \edef\ZREF@temp{%
+ \the\toks@
+ \ltx@backslashchar\ZREF@P{%
+ \expandafter\noexpand\csname Z@C@\ZREF@P\endcsname
+ }%
+ }%
+ }%
+ }{%
+ \string\zref@newlabel{#2}{\ZREF@temp}%
+ }%
+ \endgroup
+ \fi
+}
+\def\ZREF@addtoks#1{%
+ \toks@\expandafter\expandafter\expandafter{%
+ \expandafter\the\expandafter\toks@#1%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Reference querying and extracting}
+%
+% Design goal for the extracting macros is that the extraction
+% process is full expandable. Thus these macros can be used
+% in expandable contexts. But there are problems that cannot
+% be solved by full expandable macros:
+% \begin{itemize}
+% \item In standard \hologo{LaTeX} undefined references sets a flag
+% and generate a warning. Both actions are not expandable.
+% \item Babel's support for its shorthand uses commands that
+% use non-expandable assignments. However currently there
+% is hope, that primitives are added to \pdfTeX\ that
+% allows the detection of contexts. Then the shorthand
+% can detect, if they are executed inside \cs{csname}
+% and protect themselves automatically.
+% \end{itemize}
+% \begin{macro}{\zref@ifrefundefined}
+% If a reference \verb|#1| is undefined, then macro
+% \cs{zref@ifrefundefined} calls \verb|#2| and \verb|#3| otherwise.
+% \begin{macrocode}
+\def\zref@ifrefundefined#1{%
+ \ltx@ifundefined{Z@R@#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zifrefundefined}
+% If a reference \verb|#1| is undefined, then macro
+% \cs{zref@ifrefundefined} calls \verb|#2| and \verb|#3| otherwise.
+% Also the reference is marked used.
+% \begin{macrocode}
+\ZREF@IfDefinable\zifrefundefined\def{%
+ #1{%
+ \zref@wrapper@babel\ZREF@ifrefundefined{#1}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@ifrefundefined}
+% \begin{macrocode}
+\def\ZREF@ifrefundefined#1{%
+ \zref@refused{#1}%
+ \zref@ifrefundefined{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@refused}
+% The problem with undefined references is addressed by
+% the macro \cs{zref@refused}. This can be used outside
+% the expandable context. In case of an undefined reference
+% the flag is set to notify \hologo{LaTeX} and a warning is given.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@refused#1{%
+ \zref@wrapper@babel\ZREF@refused{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@refused}
+% \begin{macrocode}
+\def\ZREF@refused#1{%
+ \zref@ifrefundefined{#1}{%
+ \protect\G@refundefinedtrue
+ \@latex@warning{%
+ Reference `#1' on page \thepage \space undefined%
+ }%
+ }{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@ifrefcontainsprop}
+% \cs{zref@ifrefcontainsprop} looks, if the reference \verb|#1|
+% has the property \verb|#2| and calls then \verb|#3| and
+% \verb|#4| otherwise.
+% \begin{macrocode}
+\def\zref@ifrefcontainsprop#1#2{%
+ \zref@ifrefundefined{#1}{%
+ \ltx@secondoftwo
+ }{%
+ \expandafter\ZREF@ifrefcontainsprop
+ \csname Z@E@#2\expandafter\endcsname
+ \csname#2\expandafter\expandafter\expandafter\endcsname
+ \expandafter\expandafter\expandafter{%
+ \csname Z@R@#1\endcsname
+ }%
+ }%
+}
+\def\ZREF@ifrefcontainsprop#1#2#3{%
+ \expandafter\ifx\expandafter\ZREF@novalue
+ #1#3#2\ZREF@novalue\ZREF@nil\ltx@empty
+ \expandafter\ltx@secondoftwo
+ \else
+ \expandafter\ltx@firstoftwo
+ \fi
+}
+\def\ZREF@novalue{\ZREF@NOVALUE}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@extract}
+% \cs{zref@extract} is an abbreviation for the case
+% that the default of the property is used as default
+% value.
+% \begin{macrocode}
+\def\ZREF@extract#1#2{%
+ \romannumeral0%
+ \ltx@ifundefined{Z@D@#2}{%
+ \expandafter\ltx@space\zref@default
+ }{%
+ \expandafter\expandafter\expandafter\ZREF@@extract
+ \expandafter\expandafter\expandafter{%
+ \csname Z@D@#2\endcsname
+ }{#1}{#2}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@@extract}
+% \begin{macrocode}
+\def\ZREF@@extract#1#2#3{%
+ \expandafter\expandafter\expandafter\ltx@space
+ \zref@extractdefault{#2}{#3}{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@wu@extract}
+% \begin{macrocode}
+\def\ZREF@wu@extract#1#2{%
+ \etex@unexpanded\expandafter\expandafter\expandafter{%
+ \ZREF@extract{#1}{#2}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@extract}
+% \begin{macrocode}
+\let\zref@extract\ZREF@extract
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@extractdefault}
+% The basic extracting macro is \cs{zref@extractdefault} with
+% the reference name in \verb|#1|, the property in \verb|#2| and
+% the default value in \verb|#3| in case for problems.
+% \begin{macrocode}
+\def\ZREF@extractdefault#1#2#3{%
+ \romannumeral0%
+ \zref@ifrefundefined{#1}\ltx@firstoftwo{%
+ \zref@ifpropundefined{#2}\ltx@firstoftwo\ltx@secondoftwo
+ }{%
+ \ltx@space
+ #3%
+ }{%
+ \expandafter\expandafter\expandafter\ltx@space
+ \csname Z@E@#2\expandafter\expandafter\expandafter\endcsname
+ \csname Z@R@#1\expandafter\endcsname
+ \csname#2\endcsname{#3}\ZREF@nil
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@wu@extractdefault}
+% \begin{macrocode}
+\def\ZREF@wu@extractdefault#1#2#3{%
+ \etex@unexpanded\expandafter\expandafter\expandafter{%
+ \ZREF@extractdefault{#1}{#2}{#3}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@extractdefault}
+% \begin{macrocode}
+\let\zref@extractdefault\ZREF@extractdefault
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@def@extract}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@def@extract#1{%
+ \zref@wrapper@babel{\ZREF@def@extract{#1}}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@def@extract}
+% \begin{macrocode}
+\def\ZREF@def@extract#1#2#3{%
+ \zref@refused{#2}%
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter#1%
+ \expandafter\expandafter\expandafter{%
+ \zref@extract{#2}{#3}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@def@extractdefault}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@def@extractdefault#1{%
+ \zref@wrapper@babel{\ZREF@def@extractdefault{#1}}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@def@extractdefault}
+% \begin{macrocode}
+\def\ZREF@def@extractdefault#1#2#3#4{%
+ \zref@refused{#2}%
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter#1%
+ \expandafter\expandafter\expandafter{%
+ \zref@extractdefault{#2}{#3}{#4}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@wrapper@unexpanded}
+% \begin{macrocode}
+\ZREF@Robust{\long\def}\ZREF@wrapper@unexpanded#1{%
+ \let\zref@wrapper@unexpanded\ltx@firstofone
+ \let\zref@getcurrent\ZREF@wu@getcurrent
+ \let\zref@extractdefault\ZREF@wu@extractdefault
+ \let\zref@extract\ZREF@wu@extract
+ #1%
+ \let\zref@wrapper@unexpanded\ZREF@wrapper@unexpanded
+ \let\zref@getcurrent\ZREF@getcurrent
+ \let\zref@extractdefault\ZREF@extractdefault
+ \let\zref@extract\ZREF@extract
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@wrapper@unexpanded}
+% \begin{macrocode}
+\ltx@IfUndefined{etex@unexpanded}{%
+ \let\zref@wrapper@unexpanded\ltx@firstofone
+}{%
+ \let\zref@wrapper@unexpanded\ZREF@wrapper@unexpanded
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Compatibility with \xpackage{babel}}
+%
+% \begin{macro}{\zref@wrapper@babel}
+% \begin{macrocode}
+\ZREF@Robust{\long\def}\zref@wrapper@babel#1#2{%
+ \ifcsname if@safe@actives\endcsname
+ \expandafter\ltx@firstofone
+ \else
+ \expandafter\ltx@secondoftwo
+ \fi
+ {%
+ \if@safe@actives
+ \expandafter\ltx@secondoftwo
+ \else
+ \expandafter\ltx@firstoftwo
+ \fi
+ {%
+ \begingroup
+ \csname @safe@activestrue\endcsname
+ \edef\x{#2}%
+ \expandafter\endgroup
+ \expandafter\ZREF@wrapper@babel\expandafter{\x}{#1}%
+ }%
+ }{%
+ #1{#2}%
+ }%
+}
+\long\def\ZREF@wrapper@babel#1#2{%
+ #2{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Unique counter support}
+%
+% \begin{macro}{\zref@require@unique}
+% Generate the counter |zref@unique| if the counter does not
+% already exist.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@require@unique{%
+ \@ifundefined{c@zref@unique}{%
+ \begingroup
+ \let\@addtoreset\ltx@gobbletwo
+ \newcounter{zref@unique}%
+ \endgroup
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\thezref@unique}
+% \cs{thezref@unique} is used for automatically generated unique
+% labelnames.
+% \begin{macrocode}
+ \renewcommand*{\thezref@unique}{%
+ zref@\number\c@zref@unique
+ }%
+ }{}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Utilities}
+%
+% \begin{macro}{\ZREF@number}
+% \begin{macrocode}
+\ltx@IfUndefined{numexpr}{%
+ \def\ZREF@number#1{\number#1}%
+}{%
+ \def\ZREF@number#1{\the\numexpr(#1)\relax}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Setup}
+%
+% \begin{macro}{\zref@setdefault}
+% Standard \hologo{LaTeX} prints ``??'' in bold face if a reference
+% is not known. \cs{zref@default} holds the text that is
+% printed in case of unknown references and is used, if
+% the default was not specified during the definition
+% of the new property by \cs{ref@newprop}.
+% The global default value can be set by \cs{zref@setdefault}.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@setdefault#1{%
+ \def\zref@default{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@default}
+% Now we initialize \cs{zref@default} with the same value
+% that \hologo{LaTeX} uses for its undefined references.
+% \begin{macrocode}
+\zref@setdefault{%
+ \nfss@text{\reset@font\bfseries ??}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Main property list.}
+%
+% \begin{macro}{\zref@setmainlist}
+% The name of the default property list is stored in
+% \cs{ZREF@mainlist} and can be set by \cs{zref@setmainlist}.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@setmainlist#1{%
+ \def\ZREF@mainlist{#1}%
+}
+\zref@setmainlist{main}
+% \end{macrocode}
+% \end{macro}
+% Now we create the list.
+% \begin{macrocode}
+\zref@newlist\ZREF@mainlist
+% \end{macrocode}
+%
+% \paragraph{Main properties.}
+%
+% The two properties \texttt{default} and \texttt{page}
+% are created and added to the main property list.
+% They store the data that
+% standard \hologo{LaTeX} uses in its references created by
+% \cs{label}.
+% \begin{description}
+% \item[\texttt{default}] the apperance of the latest
+% counter that is incremented by \cs{refstepcounter}
+% \item[\texttt{page}] the apperance of the page counter
+% \end{description}
+% \begin{macrocode}
+\zref@newprop{default}{\@currentlabel}
+\zref@newprop*{page}{\thepage}
+\zref@addprops\ZREF@mainlist{default,page}
+% \end{macrocode}
+%
+% \paragraph{Properties}
+%
+% \begin{macro}{\ZREF@NewPropAnchor}
+% \begin{macrocode}
+\def\ZREF@NewPropAnchor{%
+ \zref@newprop{anchor}{%
+ \ltx@ifundefined{@currentHref}{}{\@currentHref}%
+ }%
+ \global\let\ZREF@NewPropAnchor\relax
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@titleref@current}
+% Later we will redefine the section and caption macros
+% to catch the current title and remember the value in
+% \cs{zref@titleref@current}.
+% \begin{macro}{\ZREF@NewPropTitle}
+% \begin{macrocode}
+\def\ZREF@NewPropTitle{%
+ \gdef\zref@titleref@current{}%
+ \zref@newprop{title}{\zref@titleref@current}%
+ \global\let\ZREF@NewPropTitle\relax
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\ZREF@NewPropTheotype}
+% \begin{macrocode}
+\def\ZREF@NewPropTheotype{%
+ \zref@newprop{theotype}{}%
+ \global\let\ZREF@NewPropTheotype\relax
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@NewPropPageValue}
+% \begin{macrocode}
+\def\ZREF@NewPropPageValue{%
+ \zref@newprop*{pagevalue}[0]{\number\c@page}%
+ \global\let\ZREF@NewPropPageValue\relax
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{Mark successful loading}
+%
+% \begin{macrocode}
+\let\ZREF@base@ok=Y
+%</base>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{user}}
+%
+% \begin{macrocode}
+%<*user>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-user}%
+ [2019/11/29 v2.28 Module user for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% Module \xmodule{user} enables a small user interface.
+% All macros are prefixed by \cs{z}.
+%
+% First we define the pendants to the standard \hologo{LaTeX} referencing
+% commands \cs{label}, \cs{ref}, and \cs{pageref}.
+%
+% \begin{macro}{\zlabel}
+% Similar to \cs{label} the macro \cs{zlabel} writes a reference
+% entry in the \xfile{.aux} file. The main property list is used.
+% Also we add the babel patch. The \cs{label} command can also be
+% used inside section titles, but it must not go into the
+% table of contents. Therefore we have to check this situation.
+% \begin{macrocode}
+\newcommand*\zlabel{%
+ \ifx\label\ltx@gobble
+ \expandafter\ltx@gobble
+ \else
+ \expandafter\zref@wrapper@babel\expandafter\zref@label
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zkvlabel}
+% \begin{macrocode}
+\newcommand*{\zkvlabel}[1]{%
+ \ifx\label\ltx@gobble
+ \expandafter\ltx@gobblethree
+ \fi
+ \zref@wrapper@babel{\zref@labelbykv{#1}}%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref}
+% Macro \cs{zref} is the corresponding macro for \cs{ref}.
+% Also it provides an optional argument in order to
+% select another property.
+% \begin{macrocode}
+\newcommand*{\zref}[2][default]{% robust because of optional argument
+ \zref@propexists{#1}{%
+ \zref@wrapper@babel\ZREF@zref{#2}{#1}%
+ }%
+}%
+\def\ZREF@zref#1{%
+ \zref@refused{#1}%
+ \zref@extract{#1}%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zpageref}
+% For macro \cs{zpageref} we just call \cs{zref}
+% with property \verb|page|.
+% \begin{macrocode}
+\ZREF@IfDefinable\zpageref\def{%
+ {\zref[page]}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zrefused}
+% For the following expandible user macros \cs{zrefused}
+% should be used to notify \hologo{LaTeX} in case of undefined
+% references.
+% \begin{macrocode}
+\ZREF@IfDefinable\zrefused\def{%
+ {\zref@refused}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</user>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{abspage}}
+%
+% \begin{macrocode}
+%<*abspage>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-abspage}%
+ [2019/11/29 v2.28 Module abspage for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% Module \xmodule{abspage} adds a new property \verb|abspage|
+% to the \verb|main| property list for absolute page numbers.
+% These are recorded by the help of package \xpackage{atbegshi}.
+% \begin{macrocode}
+\RequirePackage{atbegshi}[2011/10/05]%
+% \end{macrocode}
+% The counter \verb|abspage| must not go in the clear list
+% of \verb|@ckpt| that is used to set counters in
+% \xfile{.aux} files of included \hologo{TeX} files.
+% \begin{macrocode}
+\begingroup
+ \let\@addtoreset\ltx@gobbletwo
+ \newcounter{abspage}%
+\endgroup
+\setcounter{abspage}{0}%
+\AtBeginShipout{%
+ \stepcounter{abspage}%
+}%
+\zref@newprop*{abspage}[0]{\the\c@abspage}%
+\zref@addprop\ZREF@mainlist{abspage}%
+% \end{macrocode}
+% Note that counter \verb|abspage| shows the
+% previous page during page processing. Before
+% shipout the counter is incremented.
+% Thus the property is correctly written with
+% deferred writing. If the counter is written
+% using \cs{zref@wrapper@immediate}, then the number
+% is too small by one.
+%
+% \begin{macrocode}
+%</abspage>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{counter}}
+%
+% \begin{macrocode}
+%<*counter>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-counter}%
+ [2019/11/29 v2.28 Module counter for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% For features such as \xpackage{hyperref}'s \cs{autoref}
+% we need the name of the counter. The property
+% \verb|counter| is defined and added to the main property
+% list.
+% \begin{macrocode}
+\zref@newprop{counter}{}
+\zref@addprop\ZREF@mainlist{counter}
+% \end{macrocode}
+%
+% \cs{refstepcounter} is the central macro where we know
+% which counter is responsible for the reference.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \ZREF@patch{refstepcounter}{%
+ \def\refstepcounter#1{%
+ \zref@setcurrent{counter}{#1}%
+ \ZREF@org@refstepcounter{#1}%
+ }%
+ }%
+}
+% \end{macrocode}
+% \begin{macrocode}
+%</counter>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{lastpage}}
+%
+% \begin{macrocode}
+%<*lastpage>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-lastpage}%
+ [2019/11/29 v2.28 Module lastpage for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\RequirePackage{zref-abspage}[2019/11/29]
+\RequirePackage{atveryend}[2009/12/07]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% The module \xmodule{lastpage} implements the service
+% of package \xpackage{lastpage} by setting a reference
+% \verb|LastPage| at the end of the document.
+% If module \xmodule{abspage} is given, also the absolute
+% page number is available, because the properties of
+% the main property list are used.
+% \begin{macrocode}
+\zref@newlist{LastPage}
+\AfterLastShipout{%
+ \if@filesw
+ \begingroup
+ \advance\c@page\m@ne
+ \toks@\expandafter\expandafter\expandafter{%
+ \expandafter\Z@L@main
+ \Z@L@LastPage
+ }%
+ \expandafter\zref@wrapper@immediate\expandafter{%
+ \expandafter\ZREF@label\expandafter{\the\toks@}{LastPage}%
+ }%
+ \endgroup
+ \fi
+}
+% \end{macrocode}
+% \begin{macro}{\zref@iflastpage}
+% \begin{macrocode}
+\def\zref@iflastpage#1{%
+ \ifnum\zref@extractdefault{#1}{abspage}{-1}=%
+ \zref@extractdefault{LastPage}{abspage}{-2} %
+ \expandafter\ltx@firstoftwo
+ \else
+ \expandafter\ltx@secondoftwo
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ziflastpage}
+% \begin{macrocode}
+\ZREF@IfDefinable\ziflastpage\def{%
+ {\zref@wrapper@babel\ZREF@iflastpage}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{ZREF@iflastpage}
+% \begin{macrocode}
+\def\ZREF@iflastpage#1{%
+ \zref@refused{LastPage}%
+ \zref@refused{#1}%
+ \zref@iflastpage{#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+%</lastpage>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{thepage}}
+%
+% \begin{macrocode}
+%<*thepage>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-thepage}%
+ [2019/11/29 v2.28 Module thepage for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{atbegshi}[2011/10/05]
+\RequirePackage{zref-abspage}[2019/11/29]
+% \end{macrocode}
+% \begin{macrocode}
+\zref@newlist{thepage}
+\zref@addprop{thepage}{page}
+\ZREF@NewPropPageValue
+% \end{macrocode}
+% \begin{macro}{\zref@thepage@atbegshi@hook}
+% \begin{macrocode}
+\let\zref@thepage@atbegshi@hook\ltx@empty
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\zref@addprop{thepage}{pagevalue}
+\AtBeginShipout{%
+ \AtBeginShipoutAddToBox{%
+ \zref@thepage@atbegshi@hook
+ \zref@labelbylist{thepage\the\value{abspage}}{thepage}%
+ }%
+}
+% \end{macrocode}
+% \begin{macro}{\zref@thepage@name}
+% \begin{macrocode}
+\ltx@IfUndefined{numexpr}{%
+ \def\zref@thepage@name#1{thepage\number#1}%
+}{%
+ \def\zref@thepage@name#1{thepage\the\numexpr#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@thepage}
+% \begin{macrocode}
+\def\zref@thepage#1{%
+ \zref@extract{\zref@thepage@name{#1}}{page}%
+}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@thepage@refused}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@thepage@refused#1{%
+ \zref@refused{\zref@thepage@name{#1}}%
+}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zthepage}
+% \begin{macrocode}
+\ZREF@IfDefinable\zthepage\def{%
+ #1{%
+ \zref@thepage@refused{#1}%
+ \zref@thepage{#1}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+%</thepage>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{nextpage}}
+%
+% \begin{macrocode}
+%<*nextpage>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-nextpage}%
+ [2019/11/29 v2.28 Module nextpage for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{zref-abspage}[2019/11/29]
+\RequirePackage{zref-thepage}[2019/11/29]
+\RequirePackage{zref-lastpage}[2019/11/29]
+\RequirePackage{uniquecounter}[2009/12/18]
+% \end{macrocode}
+% \begin{macrocode}
+\UniqueCounterNew{znextpage}
+
+\newcommand*{\znextpagesetup}{%
+ \afterassignment\ZREF@np@setup@i
+ \def\ZREF@np@call@unknown##1%
+}
+\def\ZREF@np@setup@i{%
+ \afterassignment\ZREF@np@setup@ii
+ \def\ZREF@np@call@nonext##1%
+}
+\def\ZREF@np@setup@ii{%
+ \def\ZREF@np@call@next##1%
+}
+\def\ZREF@np@call@unknown#1{#1}
+\def\ZREF@np@call@nonext#1{#1}
+\def\ZREF@np@call@next#1{#1}
+\ZREF@IfDefinable\znextpage\def{%
+ {\UniqueCounterCall{znextpage}{\ZREF@nextpage}}%
+}%
+\newcommand*{\znonextpagename}{}
+\newcommand*{\zunknownnextpagename}{\Z@D@page}
+\def\ZREF@nextpage#1{%
+ \begingroup
+ \def\ZREF@refname@this{zref@np#1}%
+ \zref@labelbyprops\ZREF@refname@this{abspage}%
+ \chardef\ZREF@call=0 % unknown
+ \ZREF@ifrefundefined\ZREF@refname@this{%
+ }{%
+ \edef\ZREF@pagenum@this{%
+ \zref@extractdefault\ZREF@refname@this{abspage}{0}%
+ }%
+ \edef\ZREF@refname@next{%
+ \zref@thepage@name{%
+ \the\numexpr\ZREF@pagenum@this+1%
+ }%
+ }%
+ \ifnum\ZREF@pagenum@this>0 %
+ \ZREF@ifrefundefined{LastPage}{%
+ \zref@ifrefundefined\ZREF@refname@next{%
+ }{%
+ \chardef\ZREF@call=2 % next page
+ }%
+ }{%
+ \edef\ZREF@pagenum@last{%
+ \zref@extractdefault{LastPage}{abspage}{0}%
+ }%
+ \ifnum\ZREF@pagenum@this<\ZREF@pagenum@last\ltx@space
+ \ZREF@ifrefundefined\ZREF@refname@next{%
+ }{%
+ \chardef\ZREF@call=2 % next page
+ }%
+ \else
+ \ifnum\ZREF@pagenum@this=\ZREF@pagenum@this\ltx@space
+ \chardef\ZREF@call=1 % no next page
+ \fi
+ \fi
+ }%
+ \fi
+ }%
+ \edef\x{%
+ \endgroup
+ \ifcase\ZREF@call
+ \noexpand\ZREF@np@call@unknown{%
+ \noexpand\zunknownnextpagename
+ }%
+ \or
+ \noexpand\ZREF@np@call@nonext{%
+ \noexpand\znonextpagename
+ }%
+ \else
+ \noexpand\ZREF@np@call@next{%
+ \noexpand\zref@extract{\ZREF@refname@next}{page}%
+ }%
+ \fi
+ }%
+ \x
+}
+% \end{macrocode}
+% \begin{macrocode}
+%</nextpage>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{totpages}}
+%
+% \begin{macrocode}
+%<*totpages>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-totpages}%
+ [2019/11/29 v2.28 Module totpages for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% The absolute page number of the last page is the total
+% page number.
+% \begin{macrocode}
+\RequirePackage{zref-abspage}[2019/11/29]
+\RequirePackage{zref-lastpage}[2019/11/29]
+% \end{macrocode}
+%
+% \begin{macro}{\ztotpages}
+% Macro \cs{ztotpages} contains the number of pages. It can be
+% used inside expandable calculations. It expands to zero if
+% the reference is not yet available.
+% \begin{macrocode}
+\newcommand*{\ztotpages}{%
+ \zref@extractdefault{LastPage}{abspage}{0}%
+}
+% \end{macrocode}
+% \end{macro}
+% Also we mark the reference |LastPage| as used:
+% \begin{macrocode}
+\AtBeginDocument{%
+ \zref@refused{LastPage}%
+}
+% \end{macrocode}
+% \begin{macrocode}
+%</totpages>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{pagelayout}}
+%
+% \begin{macrocode}
+%<*pagelayout>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-pagelayout}%
+ [2019/11/29 v2.28 Module pagelayout for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{zref-thepage}[2019/11/29]
+\RequirePackage{iftex}[2019/11/07]%
+\RequirePackage{atveryend}[2010/03/24]
+% \end{macrocode}
+%
+% \subsubsection{Support for \hologo{LuaTeX}}
+%
+% \begin{macrocode}
+\ifluatex
+ \ifnum\luatexversion<39 %
+ \else
+ \begingroup
+ \escapechar=-1 %
+ \def\ZREF@temp#1{%
+ \ltx@IfUndefined{\string#1}{%
+ \let#1\ltx@undefined
+ \directlua{%
+ if tex.enableprimitives then %
+ tex.enableprimitives('', {'\string#1'})%
+ end%
+ }%
+ \ltx@ifundefined{\string#1}{%
+ }{%
+ \global#1=#1%
+ \@PackageInfoNoLine{zref-pagelayout}{%
+ \string#1 enabled%
+ }%
+ }%
+ }{}%
+ }%
+ \ZREF@temp\pdfpagewidth
+ \ZREF@temp\pdfpageheight
+ \ZREF@temp\pdfhorigin
+ \ZREF@temp\pdfvorigin
+ \endgroup
+ \fi
+\fi
+% \end{macrocode}
+%
+% \subsubsection{Define layout properties}
+%
+% \begin{macrocode}
+\def\ZREF@temp#1{%
+ \begingroup
+ \escapechar=-1 %
+ \ltx@ifundefined{\string#1}{\endgroup}{%
+ \edef\x{%
+ \endgroup
+ \noexpand\zref@newprop*{\string#1}%
+ [\noexpand\number\noexpand#1]% hash-ok
+ {\noexpand\number\noexpand#1}%
+ \noexpand\zref@addprop{thepage}{\string#1}%
+ }%
+ \x
+ }%
+}
+\ZREF@temp\mag
+\ZREF@temp\paperwidth
+\ZREF@temp\paperheight
+\ZREF@temp\stockwidth % memoir.cls, crop.sty
+\ZREF@temp\stockheight % memoir.cls, crop.sty
+\ZREF@temp\mediawidth % VTeX
+\ZREF@temp\mediaheight % VTeX
+\ZREF@temp\pdfpagewidth
+\ZREF@temp\pdfpageheight
+\ZREF@temp\pdfhorigin
+\ZREF@temp\pdfvorigin
+\ZREF@temp\hoffset
+\ZREF@temp\voffset
+\ZREF@temp\topmargin
+\ZREF@temp\oddsidemargin
+\ZREF@temp\evensidemargin
+\ZREF@temp\textwidth
+\ZREF@temp\textheight
+\ZREF@temp\headheight
+\ZREF@temp\headsep
+\ZREF@temp\footskip
+\ZREF@temp\marginparwidth
+\ZREF@temp\marginparsep
+\ZREF@temp\columnwidth
+\ZREF@temp\columnsep
+\ZREF@temp\trimedge % memoir.cls
+\ZREF@temp\spinemargin % memoir.cls
+\ZREF@temp\foremargin % memoir.cls
+\ZREF@temp\trimtop % memoir.cls
+\ZREF@temp\uppermargin % memoir.cls
+\ZREF@temp\headmargin % memoir.cls
+% \end{macrocode}
+%
+% \begin{macrocode}
+\zref@newprop*{outputboxwd}[0pt]{\AtBeginShipoutBoxWidth}
+% \end{macrocode}
+% \begin{macrocode}
+\zref@newprop*{outputboxht}[0pt]{\AtBeginShipoutBoxHeight}
+% \end{macrocode}
+% \begin{macrocode}
+\zref@newprop*{outputboxdp}[0pt]{\AtBeginShipoutBoxDepth}
+% \end{macrocode}
+% \begin{macrocode}
+\zref@addprops{thepage}{outputboxwd,outputboxht,outputboxdp}
+% \end{macrocode}
+%
+% \begin{macro}{\ifZREF@pl@list}
+% \begin{macrocode}
+\ltx@newif\ifZREF@pl@list
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@listpagelayout}
+% \begin{macrocode}
+\ZREF@IfDefinable\zlistpagelayout\def{%
+ {\global\ZREF@pl@listtrue}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@pl@AfterLastShipout}
+% \begin{macrocode}
+\def\ZREF@pl@AfterLastShipout{%
+ \ifZREF@pl@list
+ \edef\ZREF@page@max{\the\value{abspage}}%
+ \ltx@ifundefined{ZREF@org@testdef}{%
+ \let\ZREF@org@testdef\@testdef
+ \def\@testdef##1##2##3{%
+ \ZREF@org@testdef{##1}{##2}{##3}%
+ \def\ZREF@temp{##1}%
+ \ifx\ZREF@temp\ZREF@RefPrefix
+ \expandafter\gdef\csname##1@##2\endcsname{##3}%
+ \fi
+ }%
+ }{}%
+ \AtVeryEndDocument{\ZREF@pl@AtVeryEnd}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@pl@AtVeryEnd}
+% \begin{macrocode}
+\def\ZREF@pl@AtVeryEnd{%
+ \begingroup
+ \toks@{Page layout parameters:\MessageBreak}%
+ \count@=1 %
+ \ZREF@pl@ListPage
+ \edef\x{\endgroup
+ \noexpand\@PackageInfoNoLine{zref-pagelayout}{\the\toks@}%
+ }%
+ \x
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@pl@ListPage}
+% \begin{macrocode}
+\def\ZREF@pl@ListPage{%
+ \edef\x{%
+ \toks@={%
+ \the\toks@
+ Page \the\count@:\noexpand\MessageBreak
+ \zref@ifrefundefined{thepage\the\count@}{}{%
+ \ltx@space\ltx@space mag = %
+ \zref@extract{thepage\the\count@}{mag}%
+ \noexpand\MessageBreak
+ \ZREF@pl@ListEntry{paperwidth}%
+ \ZREF@pl@ListEntry{paperheight}%
+ \ZREF@pl@ListEntry{stockwidth}%
+ \ZREF@pl@ListEntry{stockheight}%
+ \ZREF@pl@ListEntry{mediawidth}%
+ \ZREF@pl@ListEntry{mediaheight}%
+ \ZREF@pl@ListEntry{pdfpagewidth}%
+ \ZREF@pl@ListEntry{pdfpageheight}%
+ \ZREF@pl@ListEntry{pdfhorigin}%
+ \ZREF@pl@ListEntry{pdfvorigin}%
+ \ZREF@pl@ListEntry{hoffset}%
+ \ZREF@pl@ListEntry{voffset}%
+ \ZREF@pl@ListEntry{topmargin}%
+ \ZREF@pl@ListEntry{oddsidemargin}%
+ \ZREF@pl@ListEntry{evensidemargin}%
+ \ZREF@pl@ListEntry{textwidth}%
+ \ZREF@pl@ListEntry{textheight}%
+ \ZREF@pl@ListEntry{headheight}%
+ \ZREF@pl@ListEntry{headsep}%
+ \ZREF@pl@ListEntry{footskip}%
+ \ZREF@pl@ListEntry{marginparwidth}%
+ \ZREF@pl@ListEntry{marginparsep}%
+ \ZREF@pl@ListEntry{columnwidth}%
+ \ZREF@pl@ListEntry{columnsep}%
+ \ZREF@pl@ListEntry{trimedge}%
+ \ZREF@pl@ListEntry{spinemargin}%
+ \ZREF@pl@ListEntry{foremargin}%
+ \ZREF@pl@ListEntry{trimtop}%
+ \ZREF@pl@ListEntry{uppermargin}%
+ \ZREF@pl@ListEntry{headmargin}%
+ }%
+ }%
+ }\x
+ \ifnum\ZREF@page@max>\count@
+ \advance\count@ by\ltx@one
+ \else
+ \expandafter\ltx@gobble
+ \fi
+ \ZREF@pl@ListPage
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@pl@ListEntry}
+% \begin{macrocode}
+\def\ZREF@pl@ListEntry#1{%
+ \zref@ifpropundefined{#1}{%
+ }{%
+ \zref@ifrefcontainsprop{thepage\the\count@}{#1}{%
+ \ltx@space\ltx@space#1 = %
+ \zref@extract{thepage\the\count@}{#1}sp = %
+ \the\dimexpr\zref@extract{thepage\the\count@}{#1}sp\relax
+ \noexpand\MessageBreak
+ }{}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\AfterLastShipout{%
+ \ZREF@pl@AfterLastShipout
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</pagelayout>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{pageattr}}
+%
+% \begin{macrocode}
+%<*pageattr>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-pageattr}%
+ [2019/11/29 v2.28 Module pageattr for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{iftex}[2019/11/07]%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ifluatex
+ \ifnum\luatexversion<39 %
+ \else
+ \begingroup
+ \escapechar=-1 %
+ \def\ZREF@temp#1{%
+ \ltx@IfUndefined{\string#1}{%
+ \let#1\ltx@undefined
+ \directlua{%
+ if tex.enableprimitives then %
+ tex.enableprimitives('', {'\string#1'})%
+ end%
+ }%
+ \ltx@ifundefined{\string#1}{%
+ }{%
+ \global#1=#1%
+ \@PackageInfoNoLine{zref-pageattr}{%
+ \string#1 enabled%
+ }%
+ }%
+ }{}%
+ }%
+ \ZREF@temp\pdfpageattr
+ \ZREF@temp\pdfpagesattr
+ \endgroup
+ \fi
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\let\ZREF@temp=N%
+\ltx@IfUndefined{pdfpageattr}{%
+ \@PackageInfoNoLine{zref-pageattr}{%
+ \string\pdfpageattr\space is not available%
+ }%
+ \def\zref@pdfpageattr#1{}%
+ \def\zref@pdfpageattr@used#1{}%
+}{%
+ \RequirePackage{zref-thepage}[2019/11/29]%
+ \zref@newprop*{pdfpageattr}[]{\zref@hex{\the\pdfpageattr}}%
+ \zref@addprop{thepage}{pdfpageattr}%
+ \let\ZREF@temp=Y%
+}
+\ltx@IfUndefined{pdfpagesattr}{%
+ \@PackageInfoNoLine{zref-pageattr}{%
+ \string\pdfpagesattr\space is not available%
+ }%
+ \def\zref@pdfpagesattr{}%
+ \def\zref@pdfpagesattr@used{}%
+}{%
+ \RequirePackage{zref-lastpage}[2019/11/29]%
+ \zref@newprop*{pdfpagesattr}[]{\zref@hex{\the\pdfpagesattr}}%
+ \zref@addprop{LastPage}{pdfpagesattr}%
+ \let\ZREF@temp=Y%
+}%
+% \end{macrocode}
+% \begin{macrocode}
+\ifx\ZREF@temp N%
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+% \begin{macrocode}
+\RequirePackage{zref-abspage}[2019/11/29]
+\RequirePackage{atveryend}[2010/03/24]
+\RequirePackage{pdftexcmds}[2010/04/01]
+\let\ZREF@temp=Y%
+\ltx@IfUndefined{pdf@escapehex}{\let\ZREF@temp=N}{}
+\ltx@IfUndefined{pdf@unescapehex}{\let\ZREF@temp=N}{}
+\ifx\ZREF@temp N%
+ \let\zref@hex\ltx@firstofone
+ \let\zref@unhex\ltx@firstofone
+\else
+ \let\zref@hex\pdf@escapehex
+ \let\zref@unhex\pdf@unescapehex
+\fi
+% \end{macrocode}
+%
+% \begin{macro}{\ifZREF@pa@list}
+% \begin{macrocode}
+\ltx@newif\ifZREF@pa@list
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@listpageattr}
+% \begin{macrocode}
+\ZREF@IfDefinable\zlistpageattr\def{%
+ {\ZREF@pa@listtrue}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@pa@AfterLastShipout}
+% \begin{macrocode}
+\def\ZREF@pa@AfterLastShipout{%
+ \ifZREF@pa@list
+ \edef\ZREF@page@max{\the\value{abspage}}%
+ \ltx@ifundefined{ZREF@org@testdef}{%
+ \let\ZREF@org@testdef\@testdef
+ \def\@testdef##1##2##3{%
+ \ZREF@org@testdef{##1}{##2}{##3}%
+ \def\ZREF@temp{##1}%
+ \ifx\ZREF@temp\ZREF@RefPrefix
+ \expandafter\xdef\csname##1@##2\endcsname{##3}%
+ \fi
+ }%
+ }{}%
+ \AtVeryEndDocument{\ZREF@pa@AtVeryEnd}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@pa@AtVeryEnd}
+% \begin{macrocode}
+\ltx@IfUndefined{pdfpageattr}{%
+ \def\ZREF@pa@AtVeryEnd{}%
+}{%
+ \def\ZREF@pa@AtVeryEnd{%
+ \begingroup
+ \toks@{List of \ltx@backslashchar pdfpageattr:\MessageBreak}%
+ \count@=1 %
+ \ZREF@pa@ListPage
+ \edef\x{\endgroup
+ \noexpand\@PackageInfoNoLine{zref-pageattr}{%
+ \the\toks@
+ }%
+ }%
+ \x
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@pageattr}
+% \begin{macrocode}
+\def\zref@pageattr#1{%
+ \zref@unhex{%
+ \zref@extract{thepage\ZREF@number{#1}}{pdfpageattr}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@pageattr@used}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@pageattr@used#1{%
+ \zref@refused{thepage\ZREF@number{#1}}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@pa@ListPage}
+% \begin{macrocode}
+ \def\ZREF@pa@ListPage{%
+ \edef\x{%
+ \toks@={%
+ \the\toks@
+ Page \the\count@:%
+ \noexpand\MessageBreak
+ \zref@ifrefundefined{thepage\the\count@}{}{%
+ <<\zref@pdfpageattr\count@>>%
+ \noexpand\MessageBreak
+ }%
+ }%
+ }\x
+ \ifnum\ZREF@page@max>\count@
+ \advance\count@ by\ltx@one
+ \else
+ \expandafter\ltx@gobble
+ \fi
+ \ZREF@pa@ListPage
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\ltx@IfUndefined{pdfpagesattr}{%
+}{%
+% \end{macrocode}
+% \begin{macro}{\zref@pdfpagesattr}
+% \begin{macrocode}
+ \def\zref@pdfpagesattr{%
+ \zref@unhex{%
+ \zref@extract{LastPage}{pdfpagesattr}%
+ }%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@pdfpagesattr@used}
+% \begin{macrocode}
+ \ZREF@Robust\def\zref@pdfpagesattr@used{%
+ \zref@refused{LastPage}%
+ }%
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+ \ltx@LocalAppendToMacro\ZREF@pa@AtVeryEnd{%
+ \@PackageInfoNoLine{zref-pageattr}{%
+ \ltx@backslashchar pdfpagesattr:\MessageBreak
+ <<\zref@pdfpagesattr>>%
+ \MessageBreak
+ }%
+ }%
+}
+\AfterLastShipout{%
+ \ZREF@pa@AfterLastShipout
+}
+% \end{macrocode}
+% \begin{macrocode}
+%</pageattr>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{marks}}
+%
+% \begin{macrocode}
+%<*marks>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-marks}%
+ [2019/11/29 v2.28 Module marks for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\newcommand*{\zref@marks@register}[3][]{%
+ \edef\ZREF@TempName{#1}%
+ \edef\ZREF@TempNum{\ZREF@number{#2}}%
+ \ifnum\ZREF@TempNum<\ltx@zero %
+ \PackageError\ZREF@name{%
+ \string\zref@marks@register\ltx@space is called with invalid%
+ \MessageBreak
+ marks register number (\ZREF@TempNum)%
+ }{%
+ Use `0' or the command, defined by \string\newmarks.\MessageBreak
+ \@ehc
+ }%
+ \else
+ \ifx\ZREF@TempName\ltx@empty
+ \edef\ZREF@TempName{mark\romannumeral\ZREF@TempNum}%
+ \else
+ \edef\ZREF@TempName{marks\ZREF@TempName}%
+ \fi
+ \ZREF@MARKS@DefineProp{top}%
+ \ZREF@MARKS@DefineProp{first}%
+ \ZREF@MARKS@DefineProp{bot}%
+ \kv@parse{#3}{%
+ \ifx\kv@value\relax
+ \def\kv@value{top,first,bot}%
+ \fi
+ \edef\ZREF@temp{\expandafter\ltx@car\kv@key X\@nil}%
+ \ifx\ZREF@temp\ZREF@STAR
+ \edef\kv@key{\expandafter\ltx@cdr\kv@key\@nil}%
+ \zref@newlist\kv@key
+ \fi
+ \expandafter\comma@parse\expandafter{\kv@value}{%
+ \ifcase0\ifx\comma@entry\ZREF@NAME@top 1\else
+ \ifx\comma@entry\ZREF@NAME@first 1\else
+ \ifx\comma@entry\ZREF@NAME@bot 1\fi\fi\fi\ltx@space
+ \PackageWarning{zref-marks}{%
+ Use `top', `first' or `bot' for the list values%
+ \MessageBreak
+ in the third argument of \string\zref@marks@register.%
+ \MessageBreak
+ Ignoring unkown value `\comma@entry'%
+ }%
+ \else
+ \zref@addprop{\kv@key}{\comma@entry\ZREF@TempName}%
+ \fi
+ \ltx@gobble
+ }%
+ \ltx@gobbletwo
+ }%
+ \fi
+}
+\def\ZREF@STAR{*}
+\def\ZREF@NAME@top{top}
+\def\ZREF@NAME@first{first}
+\def\ZREF@NAME@bot{bot}
+\def\ZREF@MARKS@DefineProp#1{%
+ \zref@ifpropundefined{#1\ZREF@TempName}{%
+ \ifnum\ZREF@TempNum=\ltx@zero
+ \begingroup
+ \edef\x{\endgroup
+ \noexpand\zref@newprop*{#1\ZREF@TempName}[]{%
+ \expandafter\noexpand\csname#1mark\endcsname
+ }%
+ }%
+ \x
+ \else
+ \begingroup
+ \edef\x{\endgroup
+ \noexpand\zref@newprop*{#1\ZREF@TempName}[]{%
+ \expandafter\noexpand\csname#1marks\endcsname
+ \ZREF@TempNum
+ }%
+ }%
+ \x
+ \fi
+ }{%
+ \PackageWarning{zref-marks}{%
+ \string\zref@marks@register\ltx@space does not generate the%
+ \MessageBreak
+ new property `#1\ZREF@TempName', because\MessageBreak
+ it is already defined%
+ }%
+ }%
+}
+% \end{macrocode}
+% \begin{macrocode}
+%</marks>
+% \end{macrocode}
+%
+% \subsection{Module \xmodule{runs}}
+%
+% This module does not use the label-reference-system.
+% The reference changes with each \hologo{LaTeX}~run and would
+% force a rerun warning always.
+% \begin{macrocode}
+%<*runs>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-runs}%
+ [2019/11/29 v2.28 Module runs for zref (HO)]%
+% \end{macrocode}
+%
+% \begin{macro}{\zruns}
+% \begin{macrocode}
+\providecommand*{\zruns}{0}%
+\AtBeginDocument{%
+ \edef\zruns{\number\numexpr\zruns+1}%
+ \begingroup
+ \def\on@line{}%
+ \PackageInfo{zref-runs}{LaTeX runs: \zruns}%
+ \if@filesw
+ \immediate\write\@mainaux{%
+ \string\gdef\string\zruns{\zruns}%
+ }%
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</runs>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{perpage}}
+%
+% \begin{macrocode}
+%<*perpage>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-perpage}%
+ [2019/11/29 v2.28 Module perpage for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% This module resets a counter at page boundaries.
+% Because of the asynchronous output routine
+% page counter properties cannot be asked directly,
+% references are necessary.
+%
+% For detecting changed pages module \xmodule{abspage}
+% is loaded.
+% \begin{macrocode}
+\RequirePackage{zref-abspage}[2019/11/29]
+% \end{macrocode}
+%
+% We group the properties for the needed references
+% in the property list |perpage|. The property |pagevalue|
+% records the correct value of the page counter.
+% \begin{macrocode}
+\ZREF@NewPropPageValue
+\zref@newlist{perpage}
+\zref@addprops{perpage}{abspage,page,pagevalue}
+% \end{macrocode}
+% The page value, known by the reference mechanism, will be
+% stored in counter |zpage|.
+% \begin{macrocode}
+\newcounter{zpage}
+% \end{macrocode}
+% Counter |zref@unique| helps in generating unique reference
+% names.
+% \begin{macrocode}
+\zref@require@unique
+% \end{macrocode}
+% In order to be able to reset the counter, we hook here
+% into \cs{stepcounter}. In fact two nested hooks are used
+% to allow other packages to use the first hook at the beginning
+% of \cs{stepcounter}.
+% \begin{macrocode}
+\let\ZREF@org@stepcounter\stepcounter
+\def\stepcounter#1{%
+ \ifcsname @stepcounterhook@#1\endcsname
+ \csname @stepcounterhook@#1\endcsname
+ \fi
+ \ZREF@org@stepcounter{#1}%
+}
+% \end{macrocode}
+% \cs{@stpelt} must be adapted due to the change in latex
+% 2015-01, see https://github.com/ho-tex/zref/issues/26
+% \begin{macrocode}
+\let\ZREF@org@@stpelt\@stpelt
+\def\@stpelt#1{%
+ \ifcsname ZREF@perpage@#1\endcsname
+ \begingroup
+ \let\stepcounter\ZREF@org@stepcounter
+ \ZREF@org@@stpelt{#1}%
+ \endgroup
+ \expandafter\ltx@gobbletwo
+ \fi
+ \ZREF@org@@stpelt{#1}%
+}
+% \end{macrocode}
+%
+% \begin{macro}{\zmakeperpage}
+% Makro \cs{zmakeperpage} resets a counter at each page
+% break. It uses the same syntax and semantics as
+% \cs{MakePerPage} from package \xpackage{perpage} \cite{perpage}.
+% The initial start value can be given by the optional
+% argument. Default is one that means after the first
+% \cs{stepcounter} on a new page the counter starts with
+% one.
+% \begin{macrocode}
+\ZREF@IfDefinable\zmakeperpage\def{%
+ {%
+ \@ifnextchar[\ZREF@makeperpage@opt{\ZREF@@makeperpage[\ltx@zero]}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% We hook before the counter is incremented in \cs{stepcounter},
+% package \xpackage{perpage} afterwards. Thus a little
+% calculation is necessary.
+% \begin{macrocode}
+\def\ZREF@makeperpage@opt[#1]{%
+ \begingroup
+ \edef\x{\endgroup
+ \noexpand\ZREF@@makeperpage[\number\numexpr#1-1\relax]%
+ }%
+ \x
+}
+% \end{macrocode}
+% \begin{macrocode}
+\def\ZREF@@makeperpage[#1]#2{%
+ \@ifundefined{@stepcounterhook@#2}{%
+ \expandafter\gdef\csname @stepcounterhook@#2\endcsname{}%
+ }{}%
+ \expandafter\gdef\csname ZREF@perpage@#2\endcsname{%
+ \ZREF@@perpage@step{#2}{#1}%
+ }%
+ \expandafter\g@addto@macro\csname @stepcounterhook@#2\endcsname{%
+ \ifcsname ZREF@perpage@#2\endcsname
+ \csname ZREF@perpage@#2\endcsname
+ \fi
+ }%
+}
+% \end{macrocode}
+% \begin{macro}{\ZREF@@perpage@step}
+% The heart of this module follows.
+% \begin{macrocode}
+\def\ZREF@@perpage@step#1#2{%
+% \end{macrocode}
+% First the reference is generated.
+% \begin{macrocode}
+ \global\advance\c@zref@unique\ltx@one
+ \begingroup
+ \expandafter
+ \zref@labelbylist\expandafter{\thezref@unique}{perpage}%
+% \end{macrocode}
+% The \cs{expandafter} commands are necessary, because \cs{ZREF@temp}
+% is also used inside of \cs{zref@labelbylist}.
+%
+% The evaluation of the reference follows. If the reference
+% is not yet kwown, we use the page counter as approximation.
+% \begin{macrocode}
+ \zref@ifrefundefined\thezref@unique{%
+ \global\c@zpage=\c@page
+ \global\let\thezpage\thepage
+ \expandafter\xdef\csname ZREF@abspage@#1\endcsname{%
+ \number\c@abspage
+ }%
+ }{%
+% \end{macrocode}
+% The reference is used to set \cs{thezpage} and counter |zpage|.
+% \begin{macrocode}
+ \global\c@zpage=\zref@extract\thezref@unique{pagevalue}\relax
+ \xdef\thezpage{\noexpand\zref@extract{\thezref@unique}{page}}%
+ \expandafter\xdef\csname ZREF@abspage@#1\endcsname{%
+ \zref@extractdefault\thezref@unique
+ {abspage}{\number\c@abspage}%
+ }%
+ }%
+% \end{macrocode}
+% Page changes are detected by a changed absolute page number.
+% \begin{macrocode}
+ \expandafter\ifx\csname ZREF@abspage@#1\expandafter\endcsname
+ \csname ZREF@currentabspage@#1\endcsname
+ \else
+ \global\csname c@#1\endcsname=#2\relax
+ \global\expandafter\let
+ \csname ZREF@currentabspage@#1\expandafter\endcsname
+ \csname ZREF@abspage@#1\endcsname
+ \fi
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zunmakeperpage}
+% Macro \cs{zunmakeperpage} cancels the effect of \cs{zmakeperpage}.
+% \begin{macrocode}
+\ZREF@IfDefinable\zunmakeperpage\def{%
+ #1{%
+ \global\expandafter
+ \let\csname ZREF@perpage@#1\endcsname\@undefined
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</perpage>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{titleref}}
+%
+% \begin{macrocode}
+%<*titleref>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-titleref}%
+ [2019/11/29 v2.28 Module titleref for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+\RequirePackage{gettitlestring}[2009/12/08]
+% \end{macrocode}
+%
+% \subsubsection{Implementation}
+% \begin{macrocode}
+\RequirePackage{keyval}
+% \end{macrocode}
+%
+% This module makes section and caption titles available
+% for the reference system. It uses some of the ideas
+% of package \xpackage{nameref} and \xpackage{titleref}.
+%
+% Now we can add the property \verb|title| is added to
+% the main property list.
+% \begin{macrocode}
+\ZREF@NewPropTitle
+\zref@addprop\ZREF@mainlist{title}%
+% \end{macrocode}
+%
+% The title strings go into the \xfile{.aux} file, thus
+% they need some kind of protection.
+% Package \xpackage{titleref} uses a protected expansion
+% method. The advantage is that this can be used to
+% cleanup the string and to remove \cs{label}, \cs{index}
+% and other macros unwanted for referencing.
+% But there is the risk that fragile stuff can break.
+%
+% Therefore package \xpackage{nameref} does not expand
+% the string. Thus the entries can safely be written to
+% the \xfile{.aux} file. But potentially dangerous
+% macros such as \cs{label} remain in the string and
+% can cause problems when using the string in references.
+%
+% \begin{macro}{\ifzref@titleref@expand}
+% The switch \cs{ifzref@titleref@expand} distinguishes
+% between the both methods. Package \xpackage{nameref}'s
+% behaviour is achieved by setting the switch to false,
+% otherwise \xpackage{titleref}'s expansion is used.
+% Default is false.
+% \begin{macrocode}
+\newif\ifzref@titleref@expand
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@titleref@hook}
+% The hook \cs{ZREF@titleref@hook} allows to extend
+% the cleanup for the expansion method. Thus
+% unnecessary macros can be removed or dangerous commands
+% removed. The hook is executed before the expansion of
+% \cs{zref@titleref@current}.
+% \begin{macrocode}
+\let\ZREF@titleref@hook\ltx@empty
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zref@titleref@cleanup}
+% The hook should not be used directly, instead we provide the
+% macro \cs{zref@titleref@cleanup} to add stuff to the hook
+% and prevents that a previous non-empty content is not discarded
+% accidently.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@titleref@cleanup#1{%
+ \begingroup
+ \toks@\expandafter{%
+ \ZREF@titleref@hook
+ #1%
+ }%
+ \expandafter\endgroup
+ \expandafter\def\expandafter\ZREF@titleref@hook\expandafter{%
+ \the\toks@
+ }%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ifzref@titleref@stripperiod}
+% Sometimes a title contains a period at the end.
+% Package \xpackage{nameref} removes this. This behaviour
+% is controlled by the switch \cs{ifzref@titleref@stripperiod}
+% and works regardless of the setting of option \xoption{expand}.
+% Period stripping is the default.
+% \begin{macrocode}
+\newif\ifzref@titleref@stripperiod
+\zref@titleref@stripperiodtrue
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@titleref@setcurrent}
+% Macro \cs{zref@titleref@setcurrent} sets a new current title
+% stored in \cs{zref@titleref@current}. Some cleanup and
+% expansion is performed that can be controlled by the
+% previous switches.
+% \begin{macrocode}
+\ZREF@Robust\def\zref@titleref@setcurrent#1{%
+ \ifzref@titleref@expand
+ \GetTitleStringExpand{#1}%
+ \else
+ \GetTitleStringNonExpand{#1}%
+ \fi
+ \edef\zref@titleref@current{%
+ \detokenize\expandafter{\GetTitleStringResult}%
+ }%
+ \ifzref@titleref@stripperiod
+ \edef\zref@titleref@current{%
+ \expandafter\ZREF@stripperiod\zref@titleref@current
+ \ltx@empty.\ltx@empty\@nil
+ }%
+ \fi
+}%
+\GetTitleStringDisableCommands{%
+ \ZREF@titleref@hook
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@stripperiod}
+% If \cs{ZREF@stripperiod} is called, the argument consists of
+% space tokens and tokens with catcode 12 (other), because
+% of \hologo{eTeX}'s \cs{detokenize}.
+% \begin{macrocode}
+\def\ZREF@stripperiod#1.\ltx@empty#2\@nil{#1}%
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{User interface}
+%
+% \begin{macro}{\ztitlerefsetup}
+% The behaviour of module \xmodule{titleref} is controlled
+% by switches and a hook. They can be set by \cs{ztitlerefsetup}
+% with a key value interface, provided by package \xpackage{keyval}.
+% Also the current title can be given explicitly by the key
+% \verb|title|.
+% \begin{macrocode}
+\define@key{ZREF@TR}{expand}[true]{%
+ \csname zref@titleref@expand#1\endcsname
+}%
+\define@key{ZREF@TR}{stripperiod}[true]{%
+ \csname zref@titleref@stripperiod#1\endcsname
+}%
+\define@key{ZREF@TR}{cleanup}{%
+ \zref@titleref@cleanup{#1}%
+}%
+\define@key{ZREF@TR}{title}{%
+ \def\zref@titleref@current{#1}%
+}%
+\ZREF@IfDefinable\ztitlerefsetup\def{%
+ {\kvsetkeys{ZREF@TR}}%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ztitleref}
+% The user command \cs{ztitleref} references the title.
+% For safety \cs{label} is disabled to prevent multiply
+% defined references.
+% \begin{macrocode}
+\ZREF@IfDefinable\ztitleref\def{%
+ {\zref@wrapper@babel\ZREF@titleref}%
+}%
+\def\ZREF@titleref#1{%
+ \begingroup
+ \zref@refused{#1}%
+ \let\label\ltx@gobble
+ \zref@extract{#1}{title}%
+ \endgroup
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Patches for section and caption commands}
+%
+% The section and caption macros are patched to extract the
+% title data.
+%
+% Captions of figures and tables.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \ZREF@patch{@caption}{%
+ \long\def\@caption#1[#2]{%
+ \zref@titleref@setcurrent{#2}%
+ \ZREF@org@@caption{#1}[{#2}]%
+ }%
+ }%
+% \end{macrocode}
+%
+% Section commands without star. The title version for the
+% table of contents is used because it is usually shorter and
+% more robust.
+% \begin{macrocode}
+ \ZREF@patch{@part}{%
+ \def\@part[#1]{%
+ \zref@titleref@setcurrent{#1}%
+ \ZREF@org@@part[{#1}]%
+ }%
+ }%
+ \ZREF@patch{@chapter}{%
+ \def\@chapter[#1]{%
+ \zref@titleref@setcurrent{#1}%
+ \ZREF@org@@chapter[{#1}]%
+ }%
+ }%
+ \ZREF@patch{@sect}{%
+ \def\@sect#1#2#3#4#5#6[#7]{%
+ \zref@titleref@setcurrent{#7}%
+ \ZREF@org@@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]%
+ }%
+ }%
+% \end{macrocode}
+% The star versions of the section commands.
+% \begin{macrocode}
+ \ZREF@patch{@spart}{%
+ \def\@spart#1{%
+ \zref@titleref@setcurrent{#1}%
+ \ZREF@org@@spart{#1}%
+ }%
+ }%
+ \ZREF@patch{@schapter}{%
+ \def\@schapter#1{%
+ \zref@titleref@setcurrent{#1}%
+ \ZREF@org@@schapter{#1}%
+ }%
+ }%
+ \ZREF@patch{@ssect}{%
+ \def\@ssect#1#2#3#4#5{%
+ \zref@titleref@setcurrent{#5}%
+ \ZREF@org@@ssect{#1}{#2}{#3}{#4}{#5}%
+ }%
+ }%
+% \end{macrocode}
+%
+% \subsubsection{Environment \textsf{description}}
+%
+% \begin{macrocode}
+ \ZREF@patch{descriptionlabel}{%
+ \def\descriptionlabel#1{%
+ \zref@titleref@setcurrent{#1}%
+ \ZREF@org@descriptionlabel{#1}%
+ }%
+ }%
+% \end{macrocode}
+%
+% \subsubsection{Class \xclass{memoir}}
+%
+% \begin{macrocode}
+ \@ifclassloaded{memoir}{%
+ \ltx@IfUndefined{ifheadnameref}{}{%
+ \def\@chapter[#1]#2{%
+ \ltx@IfUndefined{ch@pt@c}{%
+ \zref@titleref@setcurrent{#1}%
+ }{%
+ \ifx\ch@pt@c\ltx@empty
+ \zref@titleref@setcurrent{#2}%
+ \else
+ \def\NR@temp{#1}%
+ \ifx\NR@temp\ltx@empty
+ \expandafter\zref@titleref@setcurrent
+ \expandafter{\ch@pt@c}%
+ \else
+ \ifheadnameref
+ \zref@titleref@setcurrent{#1}%
+ \else
+ \expandafter\zref@titleref@setcurrent
+ \expandafter{\ch@pt@c}%
+ \fi
+ \fi
+ \fi
+ }%
+ \ZREF@org@@chapter[{#1}]{#2}%
+ }%
+ \ZREF@patch{M@sect}{%
+ \def\M@sect#1#2#3#4#5#6[#7][#8]{%
+ \ifheadnameref
+ \zref@titleref@setcurrent{#8}%
+ \else
+ \zref@titleref@setcurrent{#7}%
+ \fi
+ \ZREF@org@M@sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}][{#8}]%
+ }%
+ }%
+ }%
+ }{}%
+% \end{macrocode}
+%
+% \subsubsection{Class \xclass{beamer}}
+%
+% \begin{macrocode}
+ \@ifclassloaded{beamer}{%
+ \ZREF@patch{beamer@section}{%
+ \long\def\beamer@section[#1]{%
+ \zref@titleref@setcurrent{#1}%
+ \ZREF@org@beamer@section[{#1}]%
+ }%
+ }%
+ \ZREF@patch{beamer@subsection}{%
+ \long\def\beamer@subsection[#1]{%
+ \zref@titleref@setcurrent{#1}%
+ \ZREF@org@beamer@subsection[{#1}]%
+ }%
+ }%
+ \ZREF@patch{beamer@subsubsection}{%
+ \long\def\beamer@subsubsection[#1]{%
+ \zref@titleref@setcurrent{#1}%
+ \ZREF@org@beamer@subsubsection[{#1}]%
+ }%
+ }%
+ }{}%
+% \end{macrocode}
+%
+% \subsubsection{Package \xpackage{titlesec}}
+%
+% \begin{macrocode}
+ \@ifpackageloaded{titlesec}{%
+ \ZREF@patch{ttl@sect@i}{%
+ \def\ttl@sect@i#1#2[#3]#4{%
+ \zref@titleref@setcurrent{#4}%
+ \ZREF@org@ttl@sect@i{#1}{#2}[{#3}]{#4}%
+ }%
+ }%
+ \ZREF@patch{ttl@straight@i}{%
+ \def\ttl@straight@i#1[#2]#3{%
+ \def\ZREF@temp{#2}%
+ \ifx\ZREF@temp\ltx@empty
+ \zref@titleref@setcurrent{#3}%
+ \else
+ \zref@titleref@setcurrent{#2}%
+ \fi
+ \ZREF@org@ttl@straight@i{#1}[{#2}]{#3}%
+ }%
+ }%
+ }{}%
+% \end{macrocode}
+%
+% \subsubsection{Package \xpackage{longtable}}
+%
+% Package \xpackage{longtable}: some support for its \cs{caption}.
+% However \cs{label} inside the caption is not supported.
+% \begin{macrocode}
+ \@ifpackageloaded{longtable}{%
+ \ZREF@patch{LT@c@ption}{%
+ \def\LT@c@ption#1[#2]#3{%
+ \ZREF@org@LT@c@ption{#1}[{#2}]{#3}%
+ \zref@titleref@setcurrent{#2}%
+ }%
+ }%
+ }{}%
+% \end{macrocode}
+%
+% \subsubsection{Package \xpackage{listings}}
+%
+% Package \xpackage{listings}: support for its caption.
+% \begin{macrocode}
+ \@ifpackageloaded{listings}{%
+ \ZREF@patch{lst@MakeCaption}{%
+ \def\lst@MakeCaption{%
+ \ifx\lst@label\ltx@empty
+ \else
+ \expandafter\zref@titleref@setcurrent\expandafter{%
+ \lst@@caption
+ }%
+ \fi
+ \ZREF@org@lst@MakeCaption
+ }%
+ }%
+ }{}%
+% \end{macrocode}
+%
+% \subsubsection{Theorems}
+%
+% \begin{macrocode}
+ \ZREF@patch{@opargbegintheorem}{%
+ \def\@opargbegintheorem#1#2#3{%
+ \zref@titleref@setcurrent{#3}%
+ \ZREF@org@@opargbegintheorem{#1}{#2}{#3}%
+ }%
+ }%
+ \@ifpackageloaded{amsthm}{%
+ \begingroup
+ \edef\x{macro:\string#1\string#2[\string#3]}%
+ \@onelevel@sanitize\x
+ \def\y#1->#2\@nil{#1}%
+ \edef\z{\expandafter\y\meaning\@begintheorem->\@nil}%
+ \@onelevel@sanitize\z
+ \expandafter\endgroup
+ \ifx\x\z
+ \ZREF@patch{@begintheorem}{%
+ \def\@begintheorem#1#2[#3]{%
+ \zref@titleref@setcurrent{#3}%
+ \ZREF@org@@begintheorem{#1}{#2}[{#3}]%
+ }%
+ }%
+ \fi
+ }{}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+}
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</titleref>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{xr}}
+%
+% \begin{macrocode}
+%<*xr>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-xr}%
+ [2019/11/29 v2.28 Module xr for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+% \begin{macrocode}
+\RequirePackage{keyval}
+\RequirePackage{kvoptions}[2010/02/22]
+% \end{macrocode}
+%
+% We declare property |url|, because this is added,
+% if a reference is imported and has not already set this field.
+% Or if |hyperref| is used, then this property can be asked.
+% \begin{macrocode}
+\zref@newprop{url}{}%
+\zref@newprop{urluse}{}%
+% \end{macrocode}
+% \begin{macrocode}
+\zref@newprop{externaldocument}{}%
+% \end{macrocode}
+%
+% Most code, especially the handling of the \xfile{.aux}
+% files are taken from David Carlisle's \xpackage{xr} package.
+% Therefore I drop the documentation for these macros here.
+%
+% \begin{macro}{\zref@xr@ext}
+% If the URL is not specied, then assume
+% processed file with a guessed extension.
+% Use the setting of \xpackage{hyperref} if available.
+% \begin{macrocode}
+\providecommand*{\zref@xr@ext}{%
+ \ltx@ifundefined{XR@ext}{pdf}{\XR@ext}%
+}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ifZREF@xr@zreflabel}
+% The use of the star form of \cs{zexternaldocument}
+% is remembered in the switch \cs{ifZREF@xr@zreflabel}.
+% \begin{macrocode}
+\newif\ifZREF@xr@zreflabel
+% \end{macrocode}
+% \end{macro}
+% \begin{macrocode}
+\SetupKeyvalOptions{%
+ family=ZREF@XR,%
+ prefix=ZREF@xr@%
+}
+\DeclareBoolOption[true]{tozreflabel}
+\DeclareBoolOption[false]{toltxlabel}
+\DeclareBoolOption{verbose}
+\define@key{ZREF@XR}{ext}{%
+ \def\zref@xr@{#1}%
+}
+\DeclareBoolOption[false]{urluse}
+% \end{macrocode}
+% \begin{macro}{\zxrsetup}
+% \begin{macrocode}
+\newcommand*{\zxrsetup}{%
+ \kvsetkeys{ZREF@XR}%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@xr@URL}
+% \begin{macrocode}
+\newcount\ZREF@xr@URL
+\ZREF@xr@URL=\ltx@zero
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@xr@AddURL}
+% \begin{macrocode}
+\def\ZREF@xr@AddURL#1{%
+ \begingroup
+ \def\ZREF@temp{#1}%
+ \count@=\ltx@one
+ \ZREF@xr@@AddUrl
+ \endgroup
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@xr@@AddUrl}
+% \begin{macrocode}
+\def\ZREF@xr@@AddUrl{%
+ \ifnum\count@>\ZREF@xr@URL
+ \global\advance\ZREF@xr@URL by\ltx@one
+ \xdef\ZREF@xr@theURL{\romannumeral\ZREF@xr@URL}%
+ \global\expandafter\let
+ \csname Z@U@\ZREF@xr@theURL\endcsname\ZREF@temp
+ \@PackageInfo{zref-xr}{%
+ \ltx@backslashchar Z@U@\ZREF@xr@theURL:\MessageBreak
+ \ZREF@temp\MessageBreak
+ }%
+ \else
+ \expandafter
+ \ifx\csname Z@U@\romannumeral\count@\endcsname\ZREF@temp
+ \xdef\ZREF@xr@theURL{\romannumeral\count@}%
+ \else
+ \expandafter\expandafter\expandafter\ZREF@xr@@AddUrl
+ \fi
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zexternaldocument}
+% In its star form it looks for \cs{newlabel},
+% otherwise for \cs{zref@newlabel}.
+% Later we
+% will read \xfile{.aux} files that expects
+% |@| to have catcode 11 (letter).
+% \begin{macrocode}
+\ZREF@IfDefinable\zexternaldocument\def{%
+ {%
+ \ZREF@NewPropAnchor
+ \ZREF@NewPropTitle
+ \begingroup
+ \csname @safe@actives@true\endcsname
+ \makeatletter
+ \@ifstar{%
+ \ZREF@xr@zreflabelfalse
+ \@testopt\ZREF@xr@externaldocument{}%
+ }{%
+ \ZREF@xr@zreflabeltrue
+ \@testopt\ZREF@xr@externaldocument{}%
+ }%
+ }%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% If the \cs{include} featuer was used, there can be
+% several \xfile{.aux} files. These files are read
+% one after another, especially they are not recursively
+% read in order to save read registers. Thus it can
+% happen that the read order of the newlabel commands
+% differs from \hologo{LaTeX}'s order using \cs{input}.
+%
+% \begin{macro}{\ZREF@xr@externaldocument}
+% It reads the remaining arguments. \cs{newcommand}
+% comes in handy for the optional argument.
+% \begin{macrocode}
+\def\ZREF@xr@externaldocument[#1]#2{%
+ \def\ZREF@xr@prefix{#1}%
+ \let\ZREF@xr@filelist\ltx@empty
+ \edef\ZREF@xr@externalfile{#2}%
+ \edef\ZREF@xr@file{\ZREF@xr@externalfile.aux}%
+ \filename@parse{#2}%
+ \@testopt\ZREF@xr@graburl{#2.\zref@xr@ext}%
+}%
+\def\ZREF@xr@graburl[#1]{%
+ \edef\ZREF@xr@url{#1}%
+ \ifZREF@xr@urluse
+ \expandafter\ZREF@xr@AddURL\expandafter{\ZREF@xr@url}%
+ \expandafter\def\expandafter\ZREF@xr@url
+ \expandafter{\csname Z@U@\ZREF@xr@theURL\endcsname}%
+ \fi
+ \ZREF@xr@checkfile
+ \endgroup
+}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@xr@processfile}
+% We follow \xpackage{xr} here, \cs{IfFileExists} offers
+% a nicer test, but we have to open the file anyway.
+% \begin{macrocode}
+\def\ZREF@xr@checkfile{%
+ \openin\@inputcheck\ZREF@xr@file\relax
+ \ifeof\@inputcheck
+ \PackageWarning{zref-xr}{%
+ File `\ZREF@xr@file' not found or empty,\MessageBreak
+ labels not imported%
+ }%
+ \else
+ \PackageInfo{zref-xr}{%
+ Label \ifZREF@xr@zreflabel (zref) \fi
+ import from `\ZREF@xr@file'%
+ }%
+ \def\ZREF@xr@found{0}%
+ \def\ZREF@xr@ignored@empty{0}%
+ \def\ZREF@xr@ignored@zref{0}%
+ \def\ZREF@xr@ignored@ltx{0}%
+ \ZREF@xr@processfile
+ \closein\@inputcheck
+ \begingroup
+ \let\on@line\ltx@empty
+ \PackageInfo{zref-xr}{%
+ Statistics for `\ZREF@xr@file':\MessageBreak
+ \ZREF@xr@found\space
+ \ifZREF@xr@zreflabel zref\else LaTeX\fi\space
+ label(s) found%
+ \ifnum\ZREF@xr@ignored@empty>0 %
+ ,\MessageBreak
+ \ZREF@xr@ignored@empty\space empty label(s) ignored%
+ \fi
+ \ifnum\ZREF@xr@ignored@zref>0 %
+ ,\MessageBreak
+ \ZREF@xr@ignored@zref\space
+ duplicated zref label(s) ignored%
+ \fi
+ \ifnum\ZREF@xr@ignored@ltx>0 %
+ ,\MessageBreak
+ \ZREF@xr@ignored@ltx\space
+ duplicated latex label(s) ignored%
+ \fi
+ }%
+ \endgroup
+ \fi
+ \ifx\ZREF@xr@filelist\ltx@empty
+ \else
+ \edef\ZREF@xr@file{%
+ \expandafter\ltx@car\ZREF@xr@filelist\@nil
+ }%
+ \edef\ZREF@xr@filelist{%
+ \expandafter\ltx@cdr\ZREF@xr@filelist\ltx@empty\@nil
+ }%
+ \expandafter\ZREF@xr@checkfile
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@xr@processfile}
+% \begin{macrocode}
+\def\ZREF@xr@processfile{%
+ \read\@inputcheck to\ZREF@xr@line
+ \expandafter\ZREF@xr@processline\ZREF@xr@line..\ZREF@nil
+ \ifeof\@inputcheck
+ \else
+ \expandafter\ZREF@xr@processfile
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@xr@processline}
+% The most work must be done for analyzing the
+% arguments of \cs{newlabel}.
+% \begin{macrocode}
+\long\def\ZREF@xr@processline#1#2#3\ZREF@nil{%
+ \def\x{#1}%
+ \toks@{#2}%
+ \ifZREF@xr@zreflabel
+ \ifx\x\ZREF@xr@zref@newlabel
+ \expandafter
+ \ZREF@xr@process@zreflabel\ZREF@xr@line...\ZREF@nil
+ \fi
+ \else
+ \ifx\x\ZREF@xr@newlabel
+ \expandafter
+ \ZREF@xr@process@label\ZREF@xr@line...[]\ZREF@nil
+ \fi
+ \fi
+ \ifx\x\ZREF@xr@@input
+ \edef\ZREF@xr@filelist{%
+ \etex@unexpanded\expandafter{\ZREF@xr@filelist}%
+ {\filename@area\the\toks@}%
+ }%
+ \fi
+}%
+\def\ZREF@xr@process@zreflabel\zref@newlabel#1#2#3\ZREF@nil{%
+ \edef\ZREF@xr@refname{Z@R@\ZREF@xr@prefix#1}%
+ \edef\ZREF@xr@found{\the\numexpr\ZREF@xr@found+1\relax}%
+ \def\x{#2}%
+ \edef\ZREF@xr@tempname{$temp$}%
+ \edef\ZREF@xr@temprefname{Z@R@\ZREF@xr@tempname}%
+ \let\ZREF@xr@list\x
+ \ifx\ZREF@xr@list\ltx@empty
+ \PackageWarningNoLine{zref-xr}{%
+ Label `#1' without properties ignored\MessageBreak
+ in file `\ZREF@xr@file'%
+ }%
+ \edef\ZREF@xr@ignored@empty{%
+ \the\numexpr\ZREF@xr@ignored@empty+1\relax
+ }%
+ \else
+ \expandafter\ZREF@xr@checklist\x\ZREF@nil
+ \expandafter\let\csname\ZREF@xr@temprefname\endcsname\x
+ \expandafter\ltx@LocalAppendToMacro
+ \csname\ZREF@xr@temprefname\expandafter\endcsname
+ \expandafter{%
+ \expandafter\externaldocument\expandafter{%
+ \ZREF@xr@externalfile
+ }%
+ }%
+ \ZREF@xr@urlcheck\ZREF@xr@tempname
+ \ifZREF@xr@tozreflabel
+ \@ifundefined{\ZREF@xr@refname}{%
+ \ifZREF@xr@verbose
+ \PackageInfo{zref-xr}{%
+ Import to zref label `\ZREF@xr@tempname#1'%
+ }%
+ \fi
+ \global\expandafter
+ \let\csname\ZREF@xr@refname\expandafter\endcsname
+ \csname\ZREF@xr@temprefname\endcsname
+ }{%
+ \ZREF@xr@zref@ignorewarning{\ZREF@xr@prefix#1}%
+ }%
+ \fi
+ \ifZREF@xr@toltxlabel
+ \ZREF@xr@tolabel{\ZREF@xr@tempname}{\ZREF@xr@prefix#1}%
+ \fi
+ \fi
+}%
+\def\ZREF@xr@process@label\newlabel#1#2#3[#4]#5\ZREF@nil{%
+ \def\ZREF@xr@refname{Z@R@\ZREF@xr@prefix#1}%
+ \edef\ZREF@xr@found{\the\numexpr\ZREF@xr@found+1\relax}%
+ \def\x{#2}%
+ \edef\ZREF@xr@tempname{$temp$}%
+ \edef\ZREF@xr@temprefname{Z@R@\ZREF@xr@tempname}%
+ \expandafter\ZREF@xr@scanparams
+ \csname\ZREF@xr@temprefname\expandafter\endcsname
+ \x{}{}{}{}{}\ZREF@nil
+ \ifx\\#4\\%
+ \else
+ % ntheorem knows an optional argument at the end of \newlabel
+ \ZREF@NewPropTheotype
+ \expandafter\ltx@LocalAppendToMacro
+ \csname\ZREF@xr@temprefname\endcsname{\theotype{#4}}%
+ \fi
+ \expandafter\ltx@LocalAppendToMacro
+ \csname\ZREF@xr@temprefname\expandafter\endcsname\expandafter{%
+ \expandafter\externaldocument\expandafter{%
+ \ZREF@xr@externalfile
+ }%
+ }%
+ \ZREF@xr@urlcheck\ZREF@xr@tempname
+ \ifZREF@xr@tozreflabel
+ \@ifundefined{\ZREF@xr@refname}{%
+ \ifZREF@xr@verbose
+ \PackageInfo{zref-xr}{%
+ Import to zref label `\ZREF@xr@prefix#1'%
+ }%
+ \fi
+ \global\expandafter
+ \let\csname\ZREF@xr@refname\expandafter\endcsname
+ \csname\ZREF@xr@temprefname\endcsname
+ }{%
+ \ZREF@xr@zref@ignorewarning{\ZREF@xr@prefix#1}%
+ }%
+ \fi
+ \ifZREF@xr@toltxlabel
+ \ZREF@xr@tolabel{\ZREF@xr@tempname}{\ZREF@xr@prefix#1}%
+ \fi
+}
+\def\ZREF@xr@zref@newlabel{\zref@newlabel}%
+\def\ZREF@xr@newlabel{\newlabel}%
+\def\ZREF@xr@@input{\@input}%
+\def\ZREF@xr@relax{\relax}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@xr@tolabel}
+% \begin{macrocode}
+\def\ZREF@xr@tolabel#1#2{%
+ \ifZREF@xr@verbose
+ \PackageInfo{zref-xr}{%
+ Import to LaTeX label `#2'%
+ }%
+ \fi
+ \zref@wrapper@unexpanded{%
+ \expandafter\xdef\csname r@#2\endcsname{%
+ {%
+ \ltx@ifundefined{M@TitleReference}{%
+ \ltx@ifundefined{TR@TitleReference}{%
+ \zref@extractdefault{#1}{default}{}%
+ }{%
+ \noexpand\TR@TitleReference
+ {\zref@extractdefault{#1}{default}{}}%
+ {\zref@extractdefault{#1}{title}{}}%
+ }%
+ }{%
+ \noexpand\M@TitleReference
+ {\zref@extractdefault{#1}{default}{}}%
+ {\zref@extractdefault{#1}{title}{}}%
+ }%
+ }%
+ {\zref@extractdefault{#1}{page}{}}%
+ \ltx@ifpackageloaded{nameref}{%
+ {\zref@extractdefault{#1}{title}{}}%
+ {\zref@extractdefault{#1}{anchor}{}}%
+ \zref@ifrefcontainsprop{#1}{urluse}{%
+ {\zref@extractdefault{#1}{urluse}{}}%
+ }{%
+ {\zref@extractdefault{#1}{url}{}}%
+ }%
+ }{}%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@xr@zref@ignorewarning}
+% \begin{macrocode}
+\def\ZREF@xr@zref@ignorewarning#1{%
+ \PackageWarningNoLine{zref-xr}{%
+ Zref label `#1' is already in use\MessageBreak
+ in file `\ZREF@xr@file'%
+ }%
+ \edef\ZREF@xr@ignored@zref{%
+ \the\numexpr\ZREF@xr@ignored@zref+1%
+ }%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@xr@ltx@ignorewarning}
+% \begin{macrocode}
+\def\ZREF@xr@ltx@ignorewarning#1{%
+ \PackageWarningNoLine{zref-xr}{%
+ LaTeX label `#1' is already in use\MessageBreak
+ in file `\ZREF@xr@file'%
+ }%
+ \edef\ZREF@xr@ignored@ltx{%
+ \the\numexpr\ZREF@xr@ignored@ltx+1%
+ }%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@xr@checklist}
+% \begin{macrocode}
+\def\ZREF@xr@checklist#1#2#3\ZREF@nil{%
+ \ifx\@undefined#1\relax
+ \expandafter\ZREF@xr@checkkey\string#1\@nil
+ \fi
+ \ifx\\#3\\%
+ \else
+ \ltx@ReturnAfterFi{%
+ \ZREF@xr@checklist#3\ZREF@nil
+ }%
+ \fi
+}%
+\def\ZREF@xr@checkkey#1#2\@nil{%
+ \zref@ifpropundefined{#2}{%
+ \zref@newprop{#2}{}%
+ }{}%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@xr@scanparams}
+% \begin{macrocode}
+\def\ZREF@xr@scanparams#1#2#3#4#5#6#7\ZREF@nil{%
+ \let#1\ltx@empty
+ \ZREF@foundfalse
+ \ZREF@xr@scantitleref#1#2\TR@TitleReference{}{}\ZREF@nil
+ \ifZREF@found
+ \else
+ \ltx@LocalAppendToMacro#1{\default{#2}}%
+ \fi
+ % page
+ \ltx@LocalAppendToMacro#1{\page{#3}}%
+ % nameref title
+ \ifZREF@found
+ \else
+ \ifx\\#4\\%
+ \else
+ \def\ZREF@xr@temp{#4}%
+ \ifx\ZREF@xr@temp\ZREF@xr@relax
+ \else
+ \ltx@LocalAppendToMacro#1{\title{#4}}%
+ \fi
+ \fi
+ \fi
+ % anchor
+ \ifx\\#5\\%
+ \else
+ \ltx@LocalAppendToMacro#1{\anchor{#5}}%
+ \fi
+ \ifx\\#6\\%
+ \else
+ \ifZREF@xr@urluse
+ \ZREF@xr@AddURL{#6}%
+ \expandafter\ltx@LocalAppendToMacro\expandafter#1%
+ \expandafter{%
+ \expandafter\urluse\expandafter{%
+ \csname Z@U@\ZREF@xr@theURL\endcsname
+ }%
+ }%
+ \else
+ \ltx@LocalAppendToMacro#1{\url{#6}}%
+ \fi
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@xr@scantitleref}
+% \begin{macrocode}
+\def\ZREF@xr@scantitleref#1#2\TR@TitleReference#3#4#5\ZREF@nil{%
+ \ifx\\#5\\%
+ \else
+ \ltx@LocalAppendToMacro#1{%
+ \default{#3}%
+ \title{#4}%
+ }%
+ \ZREF@foundtrue
+ \fi
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@xr@urlcheck}%
+% \begin{macrocode}
+\def\ZREF@xr@urlcheck#1{%
+ \zref@ifrefcontainsprop{#1}{anchor}{%
+ \zref@ifrefcontainsprop{#1}{url}{%
+ }{%
+ \expandafter
+ \ltx@LocalAppendToMacro\csname Z@R@#1\expandafter\endcsname
+ \expandafter{%
+ \csname url\ifZREF@xr@urluse use\fi
+ \expandafter\endcsname\expandafter{\ZREF@xr@url}%
+ }%
+ }%
+ }{%
+ }%
+}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</xr>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{hyperref}}
+%
+% UNFINISHED :-(
+%
+% \begin{macrocode}
+%<*hyperref>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-hyperref}%
+ [2019/11/29 v2.28 Module hyperref for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ZREF@NewPropAnchor
+\zref@addprop\ZREF@mainlist{anchor}%
+% \end{macrocode}
+%
+% \begin{macrocode}
+%</hyperref>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{savepos}}
+%
+% Module \xmodule{savepos} provides an interface for
+% \pdfTeX's \cmd{\pdfsavepos}, see the manual for
+% \pdfTeX.
+%
+% \subsubsection{Identification}
+%
+% \begin{macrocode}
+%<*savepos>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-savepos}%
+ [2019/11/29 v2.28 Module savepos for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+% LuaTeX compatibility
+% \begin{macrocode}
+\ifx\pdfsavepos\@undefined
+ \let\pdfsavepos \savepos
+ \let\pdflastxpos \lastxpos
+ \let\pdflastypos \lastypos
+\fi
+% \end{macrocode}
+%
+% \subsubsection{Availability}
+%
+% First we check, whether the feature is available.
+% \begin{macrocode}
+\ltx@IfUndefined{pdfsavepos}{%
+ \PackageError\ZREF@name{%
+ \string\pdfsavepos\space is not supported.\MessageBreak
+ It is provided by pdfTeX (1.40) or XeTeX%
+ }\ZREF@UpdatePdfTeX
+ \endinput
+}{}%
+% \end{macrocode}
+% In PDF mode we are done. However support for DVI mode
+% was added later in version 1.40.0. In earlier versions
+% \cs{pdfsavepos} is defined, but its execution raises
+% an error. Note that \hologo{XeTeX} also provides \cs{pdfsavepos}.
+% \begin{macrocode}
+\RequirePackage{ifpdf}
+\ifpdf
+\else
+ \ltx@IfUndefined{pdftexversion}{%
+ }{%
+ \ifnum\pdftexversion<140 %
+ \PackageError\ZREF@name{%
+ \string\pdfsavepos\space is not supported in DVI mode%
+ \MessageBreak
+ of this pdfTeX version%
+ }\ZREF@UpdatePdfTeX
+ \expandafter\expandafter\expandafter\endinput
+ \fi
+ }%
+\fi
+% \end{macrocode}
+%
+% \subsubsection{Setup}
+%
+% \begin{macrocode}
+\zref@newlist{savepos}
+\zref@newprop*{posx}[0]{\the\pdflastxpos}
+\zref@newprop*{posy}[0]{\the\pdflastypos}
+\zref@addprops{savepos}{posx,posy}
+% \end{macrocode}
+%
+% \subsubsection{User macros}
+%
+% \begin{macro}{\zref@savepos}
+% \begin{macrocode}
+\def\zref@savepos{%
+ \if@filesw
+ \pdfsavepos
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@zsavepos}
+% \begin{macrocode}
+\def\ZREF@zsavepos#1#2#3{%
+ \@bsphack
+ \if@filesw
+ \zref@savepos
+ #1{#3}{#2}%
+ \ltx@IfUndefined{TeXXeTstate}{%
+ }{%
+ \ifnum\TeXXeTstate=\ltx@zero
+ \else
+ \zref@savepos
+ \fi
+ }%
+ \fi
+ \@esphack
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zsavepos}
+% The current location is stored in a reference with the
+% given name.
+% \begin{macrocode}
+\ZREF@IfDefinable\zsavepos\def{%
+ {%
+ \ZREF@zsavepos\zref@labelbylist{savepos}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zsaveposx}
+% \begin{macrocode}
+\ZREF@IfDefinable\zsaveposx\def{%
+ {%
+ \ZREF@zsavepos\zref@labelbyprops{posx}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\zsaveposy}
+% \begin{macrocode}
+\ZREF@IfDefinable\zsaveposy\def{%
+ {%
+ \ZREF@zsavepos\zref@labelbyprops{posy}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zposx}
+% \begin{macro}{\zposy}
+% The horizontal and vertical position are available by
+% \cs{zposx} and \cs{zposy}. Do not rely on absolute
+% positions. They differ in DVI and PDF mode of \pdfTeX.
+% Use differences instead. The unit of the position numbers
+% is sp.
+% \begin{macrocode}
+\newcommand*{\zposx}[1]{%
+ \zref@extract{#1}{posx}%
+}%
+\newcommand*{\zposy}[1]{%
+ \zref@extract{#1}{posy}%
+}%
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% Typically horizontal and vertical positions are used
+% inside calculations. Therefore the extracting macros
+% should be expandable and babel's patch is not applyable.
+%
+% Also it is in the responsibility of the user to marked
+% used positions by \cs{zrefused}
+% in order to notify \hologo{LaTeX} about undefined references.
+%
+% \begin{macro}{\ZREF@savepos@ok}
+% \begin{macrocode}
+\let\ZREF@savepos@ok=Y
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</savepos>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{abspos}}
+%
+% \subsubsection{Identification}
+%
+% \begin{macrocode}
+%<*abspos>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-abspos}%
+ [2019/11/29 v2.28 Module abspos for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{zref-savepos}[2019/11/29]
+\ifx\ZREF@savepos@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+% \begin{macrocode}
+\RequirePackage{zref-pagelayout}[2019/11/29]
+\zref@addprop{savepos}{abspage}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\RequirePackage{ifpdf}[2010/09/13]
+% \end{macrocode}
+%
+% \begin{macro}{\zref@absposx}
+% \begin{macrocode}
+\newcommand*{\zref@absposx}[3]{%
+ \number
+ \expandafter\zref@absposnumx\expandafter{%
+ \number\zref@extractdefault{#1}{abspage}{0}%
+ }{#2}{#3}%
+ \ltx@space
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@absposy}
+% \begin{macrocode}
+\newcommand*{\zref@absposy}[3]{%
+ \number
+ \expandafter\zref@absposnumy\expandafter{%
+ \number\zref@extractdefault{#1}{abspage}{0}%
+ }{#2}{#3}%
+ \ltx@space
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@absposnumx}
+% \begin{macrocode}
+\newcommand*{\zref@absposnumx}[3]{%
+ \number
+% \ifnum#1>\ltx@zero
+% \zref@ifrefundefined{thepage#1}{%
+% 0%
+% }{%
+ \numexpr\ZREF@absposnum{thepage#1}{#2}{x}{#3}\relax
+% }%
+% \else
+% 0%
+% \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@absposnumy}
+% \begin{macrocode}
+\newcommand*{\zref@absposnumy}[3]{%
+ \number
+% \ifnum#1>\ltx@zero
+% \zref@ifrefundefined{thepage#1}{%
+% 0%
+% }{%
+ \numexpr\ZREF@absposnum{thepage#1}{#2}{y}{#3}\relax
+% }%
+% \else
+% 0%
+% \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@absposnum}
+% \begin{macrocode}
+\def\ZREF@absposnum#1#2#3#4{%
+ \ltx@ifundefined{ZREF@abspos@#2@#3@#4}{%
+ 0%
+ }{%
+ \csname ZREF@abspos@#2@#3@#4\endcsname{#1}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@def@absposx}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@def@absposx#1{%
+ \zref@wrapper@babel{\ZREF@def@abspos{#1}\zref@absposx}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@def@absposy}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@def@absposy#1{%
+ \zref@wrapper@babel{\ZREF@def@abspos{#1}\zref@absposy}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@def@absposnumx}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@def@absposnumx#1{%
+ \zref@wrapper@babel{\ZREF@def@abspos{#1}\zref@absposnumx}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@def@absposnumy}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@def@absposnumy#1{%
+ \zref@wrapper@babel{\ZREF@def@abspos{#1}\zref@absposnumy}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@def@abspos}
+% \begin{macrocode}
+\def\ZREF@def@absposnumy#1#2#3#4#5{%
+ \edef#1{#2{#3}{#4}{#5}}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@absposused}
+% \begin{macrocode}
+\ZREF@Robust\def\zref@absposused{%
+ \zref@wrapper@babel\ZREF@abspos@used
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@used}
+% \begin{macrocode}
+\def\ZREF@abspos@used#1{%
+ \zref@refused{#1}%
+ \zref@ifrefundefined{#1}{%
+ }{%
+ \begingroup
+ \edef\ZREF@temp{%
+ \zref@extractdefault{#1}{abspage}{0}%
+ }%
+ \ifnum\ZREF@temp>\ltx@zero
+ \zref@refused{thepage\ZREF@temp}%
+ \else
+ \@PackageError{zref-abspos}{%
+ \string\zref@pos@label@used\ltx@space
+ needs property `abspage'\MessageBreak
+ in label `#1'%
+ }\@ehc
+ \fi
+ \endgroup
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@absposnumused}
+% \begin{macrocode}
+\newcommand*{\zref@absposnumused}[1]{%
+ \ifnum#1>\ltx@zero
+ \zref@refused{thepage\number#1}%
+ \else
+ \@PackageError{zref-abspos}{%
+ Invalid absolute page number (#1)\MessageBreak
+ for \string\zref@pos@num@used.\MessageBreak
+ A positive integer is expected%
+ }\@ehc
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@ifabsposundefined}
+% \begin{macrocode}
+\def\zref@ifabsposundefined#1{%
+ \zref@ifrefundefined{#1}\ltx@firsttwo{%
+ \expandafter\zref@ifabsposnumundefined\expandafter{%
+ \number\zref@extractdefault{#1}{abspage}{0}%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zref@ifabsposnumundefined}
+% \begin{macrocode}
+\def\zref@ifabsposnumundefined#1{%
+ \ifnum\ZREF@number{#1}>\ltx@zero
+ \zref@ifrefundefined{thepage#1}%
+ \ltx@firstoftwo\ltx@secondoftwo
+ \else
+ \expandafter\ltx@firstoftwo
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Media}
+%
+% \begin{macro}{\ZREF@abspos@media@width}
+% \begin{macrocode}
+\edef\ZREF@abspos@media@width{%
+ \ltx@ifundefined{pdfpagewidth}{%
+ \ltx@ifundefined{mediawidth}{%
+ \ltx@ifundefined{stockwidth}{%
+ paperwidth%
+ }{%
+ stockwidth%
+ }%
+ }{%
+ mediawidth%
+ }%
+ }{%
+ pdfpagewidth%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@media@height}
+% \begin{macrocode}
+\edef\ZREF@abspos@media@height{%
+ \ltx@ifundefined{pdfpageheight}{%
+ \ltx@ifundefined{mediaheight}{%
+ \ltx@ifundefined{stockheight}{%
+ paperheight%
+ }{%
+ stockheight%
+ }%
+ }{%
+ mediaheight%
+ }%
+ }{%
+ \noexpand\ifcase\pdfpageheight
+ \ltx@ifundefined{stockheight}{%
+ paperheight%
+ }{%
+ stockheight%
+ }%
+ \noexpand\else
+ pdfpageheight%
+ \noexpand\fi
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@abspos@media@x@left}
+% \begin{macrocode}
+\def\ZREF@abspos@media@x@left#1{%
+ 0%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@media@x@right}
+% \begin{macrocode}
+\def\ZREF@abspos@media@x@right#1{%
+ \zref@extract{#1}\ZREF@abspos@media@width
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@media@x@center}
+% \begin{macrocode}
+\def\ZREF@abspos@media@x@center#1{%
+ \ZREF@abspos@media@x@left{#1}%
+ +\zref@extract{#1}\ZREF@abspos@media@width/2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@abspos@media@y@top}
+% \begin{macrocode}
+\def\ZREF@abspos@media@y@top#1{%
+ \zref@extract{#1}\ZREF@abspos@media@height
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@media@y@bottom}
+% \begin{macrocode}
+\def\ZREF@abspos@media@y@bottom#1{%
+ 0%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@media@y@center}
+% \begin{macrocode}
+\def\ZREF@abspos@media@y@center#1{%
+ \zref@extract{#1}\ZREF@abspos@media@height/2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Paper}
+%
+% \begin{macro}{\ZREF@abspos@paper@x@left}
+% \begin{macrocode}
+\def\ZREF@abspos@paper@x@left#1{%
+ 0%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@paper@x@right}
+% \begin{macrocode}
+\def\ZREF@abspos@paper@x@right#1{%
+ \zref@extract{#1}{paperwidth}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@paper@x@center}
+% \begin{macrocode}
+\def\ZREF@abspos@paper@x@center#1{%
+ \zref@extract{#1}{paperwidth}/2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@abspos@paper@y@top}
+% \begin{macrocode}
+\let\ZREF@abspos@paper@y@top\ZREF@abspos@media@y@top
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@paper@y@bottom}
+% \begin{macrocode}
+\def\ZREF@abspos@paper@y@bottom#1{%
+ \ZREF@abspos@paper@y@top{#1}%
+ -\zref@extract{#1}{paperheight}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@paper@y@center}
+% \begin{macrocode}
+\def\ZREF@abspos@paper@y@center#1{%
+ \ZREF@abspos@paper@y@top{#1}%
+ -\zref@extract{#1}{paperheight}/2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Origin}
+%
+% \begin{macro}{\ZREF@abspos@origin@x}
+% \begin{macrocode}
+\let\ZREF@temp\ltx@two
+\ltx@IfUndefined{pdfhorigin}{}{%
+ \ifpdf
+ \let\ZREF@temp\ltx@zero
+ \fi
+}
+\ifx\ZREF@temp\ltx@two
+ \ifnum\mag=1000 %
+ \let\ZREF@temp\ltx@one
+ \fi
+\fi
+\ifcase\ZREF@temp
+ \def\ZREF@abspos@origin@x#1{%
+ \zref@extract{#1}{pdfhorigin}%
+ }%
+\or
+ \def\ZREF@abspos@origin@x#1{%
+ 4736286%
+ }%
+\or
+ \def\ZREF@abspos@origin@x#1{%
+ \numexpr\mag/1000*\dimexpr 1truein\relax\relax
+ }%
+\fi
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@origin@y}
+% \begin{macrocode}
+\let\ZREF@temp\ltx@two
+\ltx@IfUndefined{pdfvorigin}{}{%
+ \ifpdf
+ \let\ZREF@temp\ltx@zero
+ \fi
+}
+\ifx\ZREF@temp\ltx@two
+ \ifnum\mag=1000 %
+ \let\ZREF@temp\ltx@one
+ \fi
+\fi
+\ifcase\ZREF@temp
+ \def\ZREF@abspos@origin@y#1{%
+ \zref@extract{#1}{pdfvorigin}%
+ }%
+\or
+ \def\ZREF@abspos@origin@y#1{%
+ 4736286%
+ }%
+\or
+ \def\ZREF@abspos@origin@y#1{%
+ \numexpr\mag/1000*\dimexpr 1truein\relax\relax
+ }%
+\fi
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Header}
+%
+% \begin{macro}{\ZREF@abspos@head@x@left}
+% \begin{macrocode}
+\def\ZREF@abspos@head@x@left#1{%
+ \ZREF@abspos@paper@x@left{#1}%
+ +\ZREF@abspos@origin@x{#1}%
+ +\zref@extract{#1}{hoffset}%
+ +\ifodd\zref@extractdefault{#1}{pagevalue}{\number\c@page} %
+ \zref@extract{#1}{oddsidemargin}%
+ \else
+ \zref@extract{#1}{evensidemargin}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@head@x@right}
+% \begin{macrocode}
+\def\ZREF@abspos@head@x@right#1{%
+ \ZREF@abspos@head@x@left{#1}%
+ +\zref@extract{#1}{textwidth}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@head@x@center}
+% \begin{macrocode}
+\def\ZREF@abspos@head@x@center#1{%
+ \ZREF@abspos@head@x@left{#1}%
+ +\zref@extract{#1}{textwidth}/2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@abspos@head@y@top}
+% \begin{macrocode}
+\def\ZREF@abspos@head@y@top#1{%
+ \ZREF@abspos@paper@y@top{#1}%
+ -\ZREF@abspos@origin@y{#1}%
+ -\zref@extract{#1}{voffset}%
+ -\zref@extract{#1}{topmargin}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@head@y@bottom}
+% \begin{macrocode}
+\def\ZREF@abspos@head@y@bottom#1{%
+ \ZREF@abspos@head@y@top{#1}%
+ -\zref@extract{#1}{headheight}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@head@y@center}
+% \begin{macrocode}
+\def\ZREF@abspos@head@y@center#1{%
+ \ZREF@abspos@head@y@top{#1}%
+ -\zref@extract{#1}{headheight}/2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Body}
+%
+% \begin{macro}{\ZREF@abspos@body@x@left}
+% \begin{macrocode}
+\let\ZREF@abspos@body@x@left\ZREF@abspos@head@x@left
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@body@x@right}
+% \begin{macrocode}
+\let\ZREF@abspos@body@x@right\ZREF@abspos@head@x@right
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@body@x@center}
+% \begin{macrocode}
+\let\ZREF@abspos@body@x@center\ZREF@abspos@head@x@center
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@abspos@body@y@top}
+% \begin{macrocode}
+\def\ZREF@abspos@body@y@top#1{%
+ \ZREF@abspos@head@y@bottom{#1}%
+ -\zref@extract{#1}{headsep}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@body@y@bottom}
+% \begin{macrocode}
+\def\ZREF@abspos@body@y@bottom#1{%
+ \ZREF@abspos@body@y@top{#1}%
+ -\zref@extract{#1}{textheight}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@body@y@center}
+% \begin{macrocode}
+\def\ZREF@abspos@body@y@center#1{%
+ \ZREF@abspos@body@y@top{#1}%
+ -\zref@extract{#1}{textheight}/2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Footer}
+%
+% \begin{macro}{\ZREF@abspos@foot@x@left}
+% \begin{macrocode}
+\let\ZREF@abspos@foot@x@left\ZREF@abspos@head@x@left
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@foot@x@right}
+% \begin{macrocode}
+\let\ZREF@abspos@foot@x@right\ZREF@abspos@head@x@right
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@foot@x@center}
+% \begin{macrocode}
+\let\ZREF@abspos@foot@x@center\ZREF@abspos@head@x@center
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@abspos@foot@y@bottom}
+% \begin{macrocode}
+\def\ZREF@abspos@foot@y@bottom#1{%
+ \ZREF@abspos@body@y@bottom{#1}%
+ -\zref@extract{#1}{footskip}%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Marginal notes}
+%
+% \begin{macro}{\ZREF@abspos@marginpar@x@left}
+% \begin{macrocode}
+\def\ZREF@abspos@marginpar@x@left#1{%
+ \ifodd\zref@extractdefault{#1}{pagevalue}{\number\c@page} %
+ \ZREF@abspos@body@x@right{#1}%
+ +\zref@extract{#1}{marginparsep}%
+ \else
+ \ZREF@abspos@body@x@left{#1}%
+ -\zref@extract{#1}{marginparsep}%
+ -\zref@extract{#1}{marginparwidth}%
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@marginpar@x@right}
+% \begin{macrocode}
+\def\ZREF@abspos@marginpar@x@right#1{%
+ \ZREF@abspos@marginpar@x@left{#1}%
+ +\zref@extract{#1}{marginparwidth}%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@marginpar@x@center}
+% \begin{macrocode}
+\def\ZREF@abspos@marginpar@x@center#1{%
+ \ZREF@abspos@marginpar@x@left{#1}%
+ +\zref@extract{#1}{marginparwidth}/2%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@abspos@marginpar@y@top}
+% \begin{macrocode}
+\let\ZREF@abspos@marginpar@y@top\ZREF@abspos@body@y@top
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@marginpar@y@bottom}
+% \begin{macrocode}
+\let\ZREF@abspos@marginpar@y@bottom\ZREF@abspos@body@y@bottom
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@marginpar@y@center}
+% \begin{macrocode}
+\let\ZREF@abspos@marginpar@y@center\ZREF@abspos@body@y@center
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Stock paper}
+%
+% \begin{macro}{\ZREF@abspos@stock@x@left}
+% \begin{macrocode}
+\let\ZREF@abspos@stock@x@left\ZREF@abspos@paper@x@left
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@stock@x@right}
+% \begin{macrocode}
+\let\ZREF@abspos@stock@x@right\ZREF@abspos@paper@x@right
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@stock@x@center}
+% \begin{macrocode}
+\let\ZREF@abspos@stock@x@center\ZREF@abspos@paper@x@center
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\ZREF@abspos@stock@y@top}
+% \begin{macrocode}
+\let\ZREF@abspos@stock@y@top\ZREF@abspos@paper@y@top
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@stock@y@bottom}
+% \begin{macrocode}
+\let\ZREF@abspos@stock@y@bottom\ZREF@abspos@paper@y@bottom
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@abspos@stock@y@center}
+% \begin{macrocode}
+\let\ZREF@abspos@stock@y@center\ZREF@abspos@paper@y@center
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</abspos>
+% \end{macrocode}
+%
+%
+% \subsection{Module \xmodule{dotfill}}
+%
+% \begin{macrocode}
+%<*dotfill>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-dotfill}%
+ [2019/11/29 v2.28 Module dotfill for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% For measuring the width of \cs{zdotfill} we use the features
+% provided by module \xmodule{savepos}.
+% \begin{macrocode}
+\RequirePackage{zref-savepos}[2019/11/29]
+% \end{macrocode}
+% For automatically generated label names we use the unique
+% counter of module \xmodule{base}.
+% \begin{macrocode}
+\zref@require@unique
+% \end{macrocode}
+% Configuration is done by the key value interface of package
+% \xpackage{keyval}.
+% \begin{macrocode}
+\RequirePackage{keyval}
+% \end{macrocode}
+% The definitions of the keys follow.
+% \begin{macrocode}
+\define@key{ZREF@DF}{unit}{%
+ \def\ZREF@df@unit{#1}%
+}
+\define@key{ZREF@DF}{min}{%
+ \def\ZREF@df@min{#1}%
+}
+\define@key{ZREF@DF}{dot}{%
+ \def\ZREF@df@dot{#1}%
+}
+% \end{macrocode}
+% Defaults are set, see user interface.
+% \begin{macrocode}
+\providecommand\ZREF@df@min{2}
+\providecommand\ZREF@df@unit{.44em}
+\providecommand\ZREF@df@dot{.}
+% \end{macrocode}
+% \begin{macro}{\zdotfillsetup}
+% Configuration of \cs{zdotfill} is done by \cs{zdotfillsetup}.
+% \begin{macrocode}
+\newcommand*{\zdotfillsetup}{\kvsetkeys{ZREF@DF}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\zdotfill}
+% \cs{zdotfill} sets labels at the left and the right to get
+% the horizontal position. \cs{zsavepos} is not used, because
+% we do not need the vertical position.
+% \begin{macrocode}
+\ZREF@IfDefinable\zdotfill\def{%
+ {%
+ \leavevmode
+ \global\advance\c@zref@unique\ltx@one
+ \begingroup
+ \def\ZREF@temp{zref@\number\c@zref@unique}%
+ \pdfsavepos
+ \zref@labelbyprops{\thezref@unique L}{posx}%
+ \setlength{\dimen@}{\ZREF@df@unit}%
+ \zref@ifrefundefined{\thezref@unique R}{%
+ \ZREF@dotfill
+ }{%
+ \ifnum\numexpr\zposx{\thezref@unique R}%
+ -\zposx{\thezref@unique L}\relax
+ <\dimexpr\ZREF@df@min\dimen@\relax
+ \hfill
+ \else
+ \ZREF@dotfill
+ \fi
+ }%
+ \pdfsavepos
+ \zref@labelbyprops{\thezref@unique R}{posx}%
+ \endgroup
+ \kern\z@
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@dotfill}
+% Help macro that actually sets the dots.
+% \begin{macrocode}
+\def\ZREF@dotfill{%
+ \cleaders\hb@xt@\dimen@{\hss\ZREF@df@dot\hss}\hfill
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</dotfill>
+% \end{macrocode}
+%
+% \subsection{Module \xmodule{env}}
+%
+% \begin{macrocode}
+%<*env>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{zref-env}%
+ [2019/11/29 v2.28 Module env for zref (HO)]%
+\RequirePackage{zref-base}[2019/11/29]
+\ifx\ZREF@base@ok Y%
+\else
+ \expandafter\endinput
+\fi
+% \end{macrocode}
+%
+% \begin{macrocode}
+\zref@newprop{envname}[]{\@currenvir}
+\zref@newprop{envline}[]{\zref@env@line}
+% \end{macrocode}
+%
+% \begin{macro}{\zref@env@line}
+% Macro \cs{zref@env@line} extracts the line number
+% from \cs{@currenvline}.
+% \begin{macrocode}
+\def\zref@env@line{%
+ \ifx\@currenvline\ltx@empty
+ \else
+ \expandafter
+ \ZREF@ENV@line\@currenvline\ltx@empty line \ltx@empty\@nil
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ZREF@ENV@line}
+% \begin{macrocode}
+\def\ZREF@ENV@line#1line #2\ltx@empty#3\@nil{#2}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</env>
+% \end{macrocode}
+%
+%
+% \section{Test}
+%
+% \subsection{\cs{zref@localaddprop}}
+%
+% \begin{macrocode}
+%<*test1>
+\NeedsTeXFormat{LaTeX2e}
+\nofiles
+\documentclass{article}
+\usepackage{zref-base}[2019/11/29]
+\usepackage{qstest}
+\IncludeTests{*}
+\LogTests{log}{*}{*}
+
+\makeatletter
+\def\ExpectList#1#2{%
+ \expandafter\expandafter\expandafter\Expect
+ \expandafter\expandafter\expandafter{\csname Z@L@#1\endcsname}{#2}%
+}
+\begin{qstest}{localaddprop}{localaddprop}
+ \ExpectList{main}{\default\page}%
+ \Expect{undefined}*{\meaning\foobar}%
+ \zref@newprop{foobar}{FOO}%
+ \Expect{undefined}*{\meaning\foobar}%
+ \zref@newlist{alist}%
+ \ExpectList{alist}{}%
+ \begingroup
+ \zref@localaddprop{main}{foobar}%
+ \Expect{undefined}*{\meaning\foobar}%
+ \ExpectList{main}{\default\page\foobar}%
+ \zref@localaddprop{alist}{page}%
+ \ExpectList{alist}{\page}%
+ \endgroup
+ \ExpectList{main}{\default\page}%
+ \ExpectList{alist}{}%
+ \zref@addprop{alist}{foobar}%
+ \ExpectList{alist}{\foobar}%
+ \Expect{undefined}*{\meaning\foobar}%
+\end{qstest}
+\@@end
+%</test1>
+% \end{macrocode}
+%
+% \subsection{Module \xmodule{base}}
+%
+% \begin{macrocode}
+%<*test-base>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass{article}
+\usepackage{zref-base,zref-titleref}[2019/11/29]
+\usepackage{qstest}
+\IncludeTests{*}
+\LogTests{log}{*}{*}
+
+\makeatletter
+\newcommand*{\DefExpand}[2]{%
+ \expandafter\expandafter\expandafter\def
+ \expandafter\expandafter\expandafter#1%
+ \expandafter\expandafter\expandafter{#2}%
+ \@onelevel@sanitize#1%
+}
+\newcommand*{\Test}[3]{%
+ \Expect{#2}*{#1}%
+ \zref@wrapper@unexpanded{%
+ \Expect*{#3}*{#1}%
+ }%
+ \DefExpand\x{#1}%
+ \Expect*{#3}*{\x}%
+}
+\makeatother
+
+\begin{document}
+\section{\textit{Hello} \textbf{World}}
+\label{sec:hello}
+\makeatletter
+\zref@newprop{foo}[\@empty D\@empty efault]{\@empty V\@empty alue}
+\begin{qstest}{getcurrent}{getcurrent}
+ \Test{\zref@getcurrent{foo}}%
+ {Value}{\noexpand\@empty V\noexpand\@empty alue}%
+ \Test{\zref@getcurrent{xy}}{}{}%
+\end{qstest}
+\begin{qstest}{extract}{extract}
+ \def\textbf#1{<#1>}%
+ \def\textit#1{[#1]}% hash-ok
+ \Test{\zref@extractdefault{xy}{page}{\@empty D\@empty efault}}%
+ {Default}{\noexpand\@empty D\noexpand\@empty efault}%
+ \Test{\zref@extractdefault{sec:hello}{foo}{\@empty A\@empty B}}%
+ {AB}{\noexpand\@empty A\noexpand\@empty B}%
+ \Test{\zref@extract{sec:hello}{foo}}%
+ {Default}{\noexpand\@empty D\noexpand\@empty efault}%
+ \zref@ifrefundefined{sec:hello}{%
+ }{%
+ \Test{\zref@extract{sec:hello}{default}}{1}{1}%
+ \Test{\zref@extract{sec:hello}{title}}%
+ {[Hello] <World>}%
+ {\noexpand\textit{Hello} \noexpand\textbf{World}}%
+ }%
+\end{qstest}
+\end{document}
+%</test-base>
+% \end{macrocode}
+%
+% \subsection{Module \xmodule{runs}}
+%
+% \begin{macrocode}
+%<*test-runs>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass{article}
+\usepackage{zref-runs}[2019/11/29]
+\usepackage{qstest}
+\IncludeTests{*}
+\LogTests{log}{*}{*}
+
+\begin{qstest}{zruns-preamble}{zruns-preamble}
+ \Expect{0}*{\zruns}%
+\end{qstest}
+
+\AtBeginDocument{%
+ \begin{qstest}{zruns-atbegindocument}{zruns-atbegindocument}%
+ \Expect*{\number\ExpectRuns}*{\zruns}%
+ \end{qstest}%
+}
+
+\begin{document}
+\begin{qstest}{zruns-document}{zruns-document}
+ \Expect*{\number\ExpectRuns}*{\zruns}%
+\end{qstest}
+\end{document}
+%</test-runs>
+% \end{macrocode}
+%
+% \subsection{Module \xmodule{titleref}}
+%
+% \begin{macrocode}
+%<*test-titleref-memoir>
+\NeedsTeXFormat{LaTeX2e}
+\documentclass{memoir}
+\usepackage{zref-titleref}[2019/11/29]
+\usepackage{qstest}
+\IncludeTests{*}
+\LogTests{log}{*}{*}
+\begin{document}
+\makeatletter
+\def\List{}
+\def\Label#1{%
+ \zref@label{#1}%
+ \g@addto@macro\List{%
+ \par
+ #1: [\ztitleref{#1}]%
+ }%
+ \mbox{}%
+ \zref@refused{#1}%
+ \zref@ifrefundefined{#1}{%
+ }{%
+ \begingroup
+ \edef\x{\zref@extract{#1}{title}}%
+ \Expect{OK/}*{\expandafter\ltx@carthree\x{}{}{}\@nil}%
+ \endgroup
+ }%
+}
+\def\Test#1{%
+ \csname#1\endcsname*{OK/#1}%
+ \Label{#1*}%
+ \csname#1\endcsname{OK/#1}%
+ \Label{#1}%
+ \csname#1\endcsname[OK/#1-toc]%
+ {WRONG-in-titleref/#1-toc-2}%
+ \Label{#1-toc}%
+ \expandafter\ifx\csname#1\endcsname\part
+ \else
+ \headnamereffalse
+ \csname#1\endcsname[OK/#1-th-toc]%
+ [WRONG-in-titleref/#1-th-toc-2]%
+ {WRONG-in-titleref/#1-th-toc-3}%
+ \Label{#1-th-toc}%
+ \headnamereftrue
+ \csname#1\endcsname[WRONG-in-titleref/#1-th-head-1]%
+ [OK/#1-th-head]%
+ {WRONG-in-titleref/#1-th-head-3}%
+ \Label{#1-th-head}%
+ \fi
+}
+\begin{qstest}{section}{section}
+ \@for\x:=part,chapter,section,subsection,subsubsection\do{%
+ \expandafter\Test\expandafter{\x}%
+ }%
+\end{qstest}
+\newpage
+\List
+\end{document}
+%</test-titleref-memoir>
+% \end{macrocode}
+%
+% \section{Installation}
+%
+% \subsection{Download}
+%
+% \paragraph{Package.} This package is available on
+% CTAN\footnote{\CTANpkg{zref}}:
+% \begin{description}
+% \item[\CTAN{macros/latex/contrib/zref/zref.dtx}] The source file.
+% \item[\CTAN{macros/latex/contrib/zref/zref.pdf}] Documentation.
+% \end{description}
+%
+%
+% \paragraph{Bundle.} All the packages of the bundle `zref'
+% are also available in a TDS compliant ZIP archive. There
+% the packages are already unpacked and the documentation files
+% are generated. The files and directories obey the TDS standard.
+% \begin{description}
+% \item[\CTANinstall{install/macros/latex/contrib/zref.tds.zip}]
+% \end{description}
+% \emph{TDS} refers to the standard ``A Directory Structure
+% for \TeX\ Files'' (\CTANpkg{tds}). Directories
+% with \xfile{texmf} in their name are usually organized this way.
+%
+% \subsection{Bundle installation}
+%
+% \paragraph{Unpacking.} Unpack the \xfile{zref.tds.zip} in the
+% TDS tree (also known as \xfile{texmf} tree) of your choice.
+% Example (linux):
+% \begin{quote}
+% |unzip zref.tds.zip -d ~/texmf|
+% \end{quote}
+%
+%
+% \subsection{Package installation}
+%
+% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
+% \docstrip\ archive. The files are extracted by running the
+% \xfile{.dtx} through \plainTeX:
+% \begin{quote}
+% \verb|tex zref.dtx|
+% \end{quote}
+%
+% \paragraph{TDS.} Now the different files must be moved into
+% the different directories in your installation TDS tree
+% (also known as \xfile{texmf} tree):
+% \begin{quote}
+% \def\t{^^A
+% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
+% zref.sty & tex/latex/zref/zref.sty\\
+% zref-base.sty & tex/latex/zref/zref-base.sty\\
+% zref-abspage.sty & tex/latex/zref/zref-abspage.sty\\
+% zref-abspos.sty & tex/latex/zref/zref-abspos.sty\\
+% zref-counter.sty & tex/latex/zref/zref-counter.sty\\
+% zref-dotfill.sty & tex/latex/zref/zref-dotfill.sty\\
+% zref-env.sty & tex/latex/zref/zref-env.sty\\
+% zref-hyperref.sty & tex/latex/zref/zref-hyperref.sty\\
+% zref-lastpage.sty & tex/latex/zref/zref-lastpage.sty\\
+% zref-marks.sty & tex/latex/zref/zref-marks.sty\\
+% zref-nextpage.sty & tex/latex/zref/zref-nextpage.sty\\
+% zref-pageattr.sty & tex/latex/zref/zref-pageattr.sty\\
+% zref-pagelayout.sty & tex/latex/zref/zref-pagelayout.sty\\
+% zref-perpage.sty & tex/latex/zref/zref-perpage.sty\\
+% zref-runs.sty & tex/latex/zref/zref-runs.sty\\
+% zref-savepos.sty & tex/latex/zref/zref-savepos.sty\\
+% zref-thepage.sty & tex/latex/zref/zref-thepage.sty\\
+% zref-titleref.sty & tex/latex/zref/zref-titleref.sty\\
+% zref-totpages.sty & tex/latex/zref/zref-totpages.sty\\
+% zref-user.sty & tex/latex/zref/zref-user.sty\\
+% zref-xr.sty & tex/latex/zref/zref-xr.sty\\
+% zref.pdf & doc/latex/zref/zref.pdf\\
+% zref-example.tex & doc/latex/zref/zref-example.tex\\
+% zref-example-lastpage.tex & doc/latex/zref/zref-example-lastpage.tex\\
+% zref-example-nextpage.tex & doc/latex/zref/zref-example-nextpage.tex\\
+% test/zref-test1.tex & doc/latex/zref/test/zref-test1.tex\\
+% test/zref-test-base.tex & doc/latex/zref/test/zref-test-base.tex\\
+% test/zref-test-runs.tex & doc/latex/zref/test/zref-test-runs.tex\\
+% test/zref-test-titleref-memoir.tex & doc/latex/zref/test/zref-test-titleref-memoir.tex\\
+% zref.dtx & source/latex/zref/zref.dtx\\
+% \end{tabular}^^A
+% }^^A
+% \sbox0{\t}^^A
+% \ifdim\wd0>\linewidth
+% \begingroup
+% \advance\linewidth by\leftmargin
+% \advance\linewidth by\rightmargin
+% \edef\x{\endgroup
+% \def\noexpand\lw{\the\linewidth}^^A
+% }\x
+% \def\lwbox{^^A
+% \leavevmode
+% \hbox to \linewidth{^^A
+% \kern-\leftmargin\relax
+% \hss
+% \usebox0
+% \hss
+% \kern-\rightmargin\relax
+% }^^A
+% }^^A
+% \ifdim\wd0>\lw
+% \sbox0{\small\t}^^A
+% \ifdim\wd0>\linewidth
+% \ifdim\wd0>\lw
+% \sbox0{\footnotesize\t}^^A
+% \ifdim\wd0>\linewidth
+% \ifdim\wd0>\lw
+% \sbox0{\scriptsize\t}^^A
+% \ifdim\wd0>\linewidth
+% \ifdim\wd0>\lw
+% \sbox0{\tiny\t}^^A
+% \ifdim\wd0>\linewidth
+% \lwbox
+% \else
+% \usebox0
+% \fi
+% \else
+% \lwbox
+% \fi
+% \else
+% \usebox0
+% \fi
+% \else
+% \lwbox
+% \fi
+% \else
+% \usebox0
+% \fi
+% \else
+% \lwbox
+% \fi
+% \else
+% \usebox0
+% \fi
+% \else
+% \lwbox
+% \fi
+% \else
+% \usebox0
+% \fi
+% \end{quote}
+% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
+% TDS installing feature, then some files can already be in the right
+% place, see the documentation of \docstrip.
+%
+% \subsection{Refresh file name databases}
+%
+% If your \TeX~distribution
+% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
+% these. For example, \TeX\,Live\ users run \verb|texhash| or
+% \verb|mktexlsr|.
+%
+% \subsection{Some details for the interested}
+%
+% \paragraph{Unpacking with \LaTeX.}
+% The \xfile{.dtx} chooses its action depending on the format:
+% \begin{description}
+% \item[\plainTeX:] Run \docstrip\ and extract the files.
+% \item[\LaTeX:] Generate the documentation.
+% \end{description}
+% If you insist on using \LaTeX\ for \docstrip\ (really,
+% \docstrip\ does not need \LaTeX), then inform the autodetect routine
+% about your intention:
+% \begin{quote}
+% \verb|latex \let\install=y\input{zref.dtx}|
+% \end{quote}
+% Do not forget to quote the argument according to the demands
+% of your shell.
+%
+% \paragraph{Generating the documentation.}
+% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
+% the documentation. The process can be configured by the
+% configuration file \xfile{ltxdoc.cfg}. For instance, put this
+% line into this file, if you want to have A4 as paper format:
+% \begin{quote}
+% \verb|\PassOptionsToClass{a4paper}{article}|
+% \end{quote}
+% An example follows how to generate the
+% documentation with pdf\LaTeX:
+% \begin{quote}
+%\begin{verbatim}
+%pdflatex zref.dtx
+%makeindex -s gind.ist zref.idx
+%pdflatex zref.dtx
+%makeindex -s gind.ist zref.idx
+%pdflatex zref.dtx
+%\end{verbatim}
+% \end{quote}
+%
+% \begin{thebibliography}{99}
+% \bibpackage{footmisc}{Robin Fairbairns}{2004/01/23 v5.3a}
+% {\CTANpkg{footmisc}}
+% \bibpackage{hyperref}{Sebastian Rahtz, Heiko Oberdiek}{2006/08/16 v6.75c}
+% {\CTANpkg{hyperref}}
+% \bibpackage{lastpage}{Jeff Goldberg}{1994/06/25 v0.1b}
+% {\CTANpkg{lastpage}}
+% \bibpackage{nameref}{Sebastian Rahtz, Heiko Oberdiek}{2006/02/12 v2.24}
+% {\CTANpkg{nameref}}
+% \bibpackage{perpage}{David Kastrup}{2002/12/20 v1.0}
+% {\CTANpkg{perpage}}
+% \bibpackage{titleref}{Donald Arsenau}{2001/04/05 v3.1}
+% {\CTANpkg{titleref}}
+% \bibpackage{totpages}{Wilhelm M\"uller}{1999/07/14 v1.00}
+% {\CTANpkg{totpages}}
+% \bibpackage{xr}{David Carlisle}{1994/05/28 v5.02}
+% {\CTANpkg{xr}}
+% \bibpackage{xr-hyper}{David Carlisle}{2000/03/22 v6.00beta4}
+% {\CTANpkg{xr-hyper}}
+% \end{thebibliography}
+%
+% \begin{History}
+% \begin{Version}{2006/02/20 v1.0}
+% \item
+% First version.
+% \end{Version}
+% \begin{Version}{2006/05/03 v1.1}
+% \item
+% Module \xmodule{perpage} added.
+% \item
+% Module redesign as packages.
+% \end{Version}
+% \begin{Version}{2006/05/25 v1.2}
+% \item
+% Module \xmodule{dotfillmin} added.
+% \item
+% Module \xmodule{base}: macros \cs{zref@require@uniqe}
+% and \cs{thezref@unique} added
+% (used by modules \xmodule{titleref} and \xmodule{dotfillmin}).
+% \end{Version}
+% \begin{Version}{2006/09/08 v1.3}
+% \item
+% Typo fixes and English cleanup by Per Starback.
+% \end{Version}
+% \begin{Version}{2007/01/23 v1.4}
+% \item
+% Typo in macro name fixed in documentation.
+% \end{Version}
+% \begin{Version}{2007/02/18 v1.5}
+% \item
+% \cs{zref@getcurrent} added (suggestion of Igor Akkerman).
+% \item
+% Module \xmodule{savepos} also supports \hologo{XeTeX}.
+% \end{Version}
+% \begin{Version}{2007/04/06 v1.6}
+% \item
+% Fix in modules \xmodule{abspage} and \xmodule{base}:
+% Now counter |abspage| and |zref@unique|
+% are not remembered by \cs{include}.
+% \item
+% Beamer support for module \xmodule{titleref}.
+% \end{Version}
+% \begin{Version}{2007/04/17 v1.7}
+% \item
+% Package \xpackage{atbegshi} replaces \xpackage{everyshi}.
+% \end{Version}
+% \begin{Version}{2007/04/22 v1.8}
+% \item
+% \cs{zref@wrapper@babel} and \cs{zref@refused} are now expandable
+% if babel is not used or \cs{if@safe@actives} is already set to true.
+% (Feature request of Josselin Noirel)
+% \end{Version}
+% \begin{Version}{2007/05/02 v1.9}
+% \item
+% Module \xmodule{titleref}: Some support for \cs{caption} of package
+% \xpackage{longtable}, but only if \cs{label} is given after
+% \cs{caption}.
+% \end{Version}
+% \begin{Version}{2007/05/06 v2.0}
+% \item
+% Uses package \xpackage{etexcmds} for accessing \hologo{eTeX}'s \cs{unexpanded}.
+% \end{Version}
+% \begin{Version}{2007/05/28 v2.1}
+% \item
+% Module \xmodule{titleref} supports caption of package \xpackage{listings}.
+% \item
+% Fixes in module \xmodule{titleref} for support
+% of packages \xpackage{titlesec} and \xpackage{longtable}.
+% \end{Version}
+% \begin{Version}{2008/09/21 v2.2}
+% \item
+% Module \xmodule{base}: \cs{zref@iflistcontainsprop} is documented, but
+% a broken \cs{zref@listcontainsprop} implemented. Name and
+% implementation fixed (thanks Ohad Kammar).
+% \end{Version}
+% \begin{Version}{2008/10/01 v2.3}
+% \item
+% \cs{zref@localaddprop} added (feature request of Ohad Kammar).
+% \item
+% Module \xmodule{lastpage}: list `LastPage' added. Label `LastPage' will use
+% the properties of this list (default is empty) along with the
+% properties of the main list.
+% \end{Version}
+% \begin{Version}{2009/08/07 v2.4}
+% \item
+% Module \xmodule{runs} added.
+% \end{Version}
+% \begin{Version}{2009/12/06 v2.5}
+% \item
+% Module \xmodule{lastpage}: Uses package \xpackage{atveryend}.
+% \item
+% Module \xmodule{titleref}: Further commands are disabled
+% during string expansion, imported from package \xpackage{nameref}.
+% \end{Version}
+% \begin{Version}{2009/12/07 v2.6}
+% \item
+% Version date added for package \xpackage{atveryend}.
+% \end{Version}
+% \begin{Version}{2009/12/08 v2.7}
+% \item
+% Module \xmodule{titleref}: Use of package \xpackage{gettitlestring}.
+% \end{Version}
+% \begin{Version}{2010/03/26 v2.8}
+% \item
+% \cs{zifrefundefined} added.
+% \item
+% Module \xmodule{lastpage}: Macros \cs{zref@iflastpage}
+% and \cs{ziflastpage} added.
+% \item
+% Module \xmodule{thepage} added.
+% \item
+% Module \xmodule{nextpage} added.
+% \end{Version}
+% \begin{Version}{2010/03/29 v2.9}
+% \item
+% Module \xmodule{marks} added (without documentation).
+% \item
+% \cs{zref@addprop} now adds expanded property to list.
+% \item
+% Useless \cs{ZREF@ErrorNoLine} removed.
+% \end{Version}
+% \begin{Version}{2010/04/08 v2.10}
+% \item
+% Module \xmodule{xr} remembers the external document name
+% in property `externaldocument'.
+% \end{Version}
+% \begin{Version}{2010/04/15 v2.11}
+% \item
+% Module \xmodule{titleref}: Better support of class \xclass{memoir}.
+% \item
+% Module \xmodule{titleref}: Support of theorems.
+% \end{Version}
+% \begin{Version}{2010/04/17 v2.12}
+% \item
+% Module \xmodule{base}: \cs{zref@newprop} ensures global
+% empty default.
+% \item
+% Module \xmodule{xr}: Setup options \xoption{tozreflabel}
+% and \xoption{toltxlabel} added.
+% \end{Version}
+% \begin{Version}{2010/04/19 v2.13}
+% \item
+% \cs{zref@setcurrent} throws an error if the property
+% does not exist (Florent Chervet).
+% \item
+% \cs{zref@getcurrent} the documentation is fixed (Florent Chervet).
+% Also it returns the empty string in case of errors.
+% \item
+% \cs{zref@addprop} and \cs{zref@localaddprop} now take a list of
+% property names (feature request of Florent Chervet).
+% \item
+% Example for \cs{zref@wrapper@unexpanded} corrected (Florent Chervet).
+% \end{Version}
+% \begin{Version}{2010/04/22 v2.14}
+% \item
+% Bug fix for \cs{zref@getcurrent} second argument wasn't eaten in
+% case of unknown property.
+% \item
+% \cs{zref@getcurrent} supports \cs{zref@wrapper@unexpanded}.
+% \item
+% \cs{zref@wrapper@unexpanded} added for \cs{ZREF@xr@tolabel}.
+% \item
+% \cs{zref@extract}, \cs{zref@extractdefault}, \cs{zref@getcurrent}
+% are expandable in exact two steps
+% except inside \cs{zref@wrapper@unexpanded}.
+% \end{Version}
+% \begin{Version}{2010/04/23 v2.15}
+% \item
+% \cs{zexternaldocument} fixed for property `url' when
+% importing \cs{new@label} (bug found by Victor Ivrii).
+% \item
+% Two expansion steps also in \cs{zref@wrapper@unexpanded}.
+% \item
+% Nested calls of \cs{zref@wrapper@unexpanded} possible.
+% \end{Version}
+% \begin{Version}{2010/04/28 v2.16}
+% \item
+% More consequent use of package `ltxcmds' and `hologo'.
+% \item
+% Module \xmodule{pagelayout} added.
+% \item
+% Module \xmodule{pageattr} added.
+% \item
+% Robustness introduced for non-expandable interface macros.
+% \item
+% Internal change of the data format of property lists
+% (suggestion of Florent Chervet).
+% \item
+% Module \xmodule{titleref}: Support of environment \textsf{description}.
+% \end{Version}
+% \begin{Version}{2010/05/01 v2.17}
+% \item
+% \cs{zref@newprop} throws an error if the property already exists.
+% \item
+% Module \xmodule{xr}: Bug fix for the case of several \xext{aux} files
+% (bug found by Victor Ivrii).
+% \item
+% Module \xmodule{xr}: Property `urluse' and option \xoption{urluse} added.
+% \end{Version}
+% \begin{Version}{2010/05/13 v2.18}
+% \item
+% Module \xmodule{env} added.
+% \item
+% Module \xmodule{savepos}: \cs{zref@savepos} added.
+% \end{Version}
+% \begin{Version}{2010/10/22 v2.19}
+% \item
+% \cs{zref@addprop} and \cs{zref@localaddprop} are limited
+% to one property only
+% (incompatibility to versions v2.13 to v2.18).
+% \item
+% \cs{zref@addprops} and \cs{zref@localaddprops} added.
+% \item
+% \cs{zref@delprop} and \cs{zref@localdelprop} added.
+% \item
+% \cs{zref@labelbykv} and \cs{zkvlabel} (module \xmodule{user})
+% with keys \xoption{prop}, \xoption{list}, \xoption{delprop},
+% \xoption{immediate}, \xoption{values} added.
+% \end{Version}
+% \begin{Version}{2011/02/12 v2.20}
+% \item
+% Fix for warning in \xpackage{zref-xr}.
+% \end{Version}
+% \begin{Version}{2011/03/18 v2.21}
+% \item
+% Fix in module \xmodule{pagelayout} for \cs{zlistpagelayout}.
+% \item
+% Fix for \cs{zref@localaddprop} (probably since v2.19).
+% \end{Version}
+% \begin{Version}{2011/10/05 v2.22}
+% \item
+% Documentation fixed for \cs{zref@(local)addprop(s)}.
+% \item
+% Module \xmodule{base}: \cs{zref@def@extract}, \cs{zref@def@extractdefault}
+% added.
+% \item
+% Fix in module \xmodule{pagelayout}: Because of missing \cs{noexpand}
+% commands the values of the pagelayout properties on all pages were
+% the values at package loading.
+% \item
+% Module \xmodule{base}: \cs{zref@showprop} added.
+% \end{Version}
+% \begin{Version}{2011/12/05 v2.23}
+% \item
+% Module \xmodule{savepos}: \cs{zsaveposx} and \cs{zsaveposy} added.
+% \end{Version}
+% \begin{Version}{2012/04/04 v2.24}
+% \item
+% Module \xmodule{titleref}, package \xpackage{titlesec}:
+% some support for class `straight' (\cs{ttl@straight@i}) added.
+% \end{Version}
+% \begin{Version}{2016/05/16 v2.25}
+% \item
+% Documentation updates.
+% \end{Version}
+% \begin{Version}{2016/05/21 v2.26}
+% \item
+% update zref-savepos for new luatex
+% \end{Version}
+% \begin{Version}{2018/11/21 v2.27}
+% \item
+% adapted zref-perpage, see issue https://github.com/ho-tex/zref/issues/2
+% \end{Version}
+% \begin{Version}{2019/11/29 v2.28}
+% \item
+% Documentation updates.
+% \item
+% Use \xpackage{iftex} directly.
+% \end{Version}
+% \end{History}
+%
+% \PrintIndex
+%
+% \Finale
+\endinput
diff --git a/macros/latex/contrib/zref/zref.pdf b/macros/latex/contrib/zref/zref.pdf
new file mode 100644
index 0000000000..fee81c695c
--- /dev/null
+++ b/macros/latex/contrib/zref/zref.pdf
Binary files differ