| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: zref-vario.tex |
| 4 |
% |
| 5 |
% This file is part of the LaTeX package "zref-vario". |
| 6 |
% |
| 7 |
% Copyright (C) 2022-2023 gusbrs |
| 8 |
% |
| 9 |
% It may be distributed and/or modified under the conditions of the |
| 10 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 11 |
% license or (at your option) any later version. The latest version |
| 12 |
% of this license is in the file: |
| 13 |
% |
| 14 |
% https://www.latex-project.org/lppl.txt |
| 15 |
% |
| 16 |
% and version 1.3 or later is part of all distributions of LaTeX |
| 17 |
% version 2005/12/01 or later. |
| 18 |
% |
| 19 |
% |
| 20 |
% This work is "maintained" (as per LPPL maintenance status) by gusbrs. |
| 21 |
% |
| 22 |
% This work consists of the files zref-vario.dtx, |
| 23 |
% zref-vario.ins, |
| 24 |
% zref-vario-doc.tex, |
| 25 |
% zref-vario-code.tex, |
| 26 |
% and the files generated from them. |
| 27 |
% |
| 28 |
% The released version of this package is available from CTAN. |
| 29 |
% |
| 30 |
% ----------------------------------------------------------------------- |
| 31 |
% |
| 32 |
% The development version of the package can be found at |
| 33 |
% |
| 34 |
% https://github.com/gusbrs/zref-vario |
| 35 |
% |
| 36 |
% for those people who are interested. |
| 37 |
% |
| 38 |
% ----------------------------------------------------------------------- |
| 39 |
% |
| 40 |
% \fi |
| 41 |
|
| 42 |
\documentclass{l3doc} |
| 43 |
|
| 44 |
% The package itself *must* be loaded so that \GetFileInfo can pick up date |
| 45 |
% and version data. |
| 46 |
\usepackage{zref-vario} |
| 47 |
|
| 48 |
\usepackage[T1]{fontenc} |
| 49 |
|
| 50 |
\usepackage[sc]{mathpazo} |
| 51 |
\linespread{1.05} |
| 52 |
\usepackage[scale=.88]{tgheros} % sans |
| 53 |
\usepackage[varqu,scaled=1.03]{inconsolata} % tt |
| 54 |
|
| 55 |
\usepackage{listings} |
| 56 |
|
| 57 |
\usepackage{microtype} |
| 58 |
|
| 59 |
\hypersetup{hidelinks} |
| 60 |
|
| 61 |
\NewDocumentCommand\opt{m}{\texttt{#1}} |
| 62 |
|
| 63 |
\NewDocumentCommand\username{m}{`\texttt{#1}'} |
| 64 |
|
| 65 |
\setlength{\marginparsep}{2\labelsep} |
| 66 |
|
| 67 |
\lstdefinestyle{code}{ |
| 68 |
language=[LaTeX]TeX, |
| 69 |
% moretexcs={ |
| 70 |
% } |
| 71 |
} |
| 72 |
\lstdefinestyle{zrefvario}{ |
| 73 |
style=code, |
| 74 |
% moretexcs={ |
| 75 |
% } |
| 76 |
} |
| 77 |
\lstset{ |
| 78 |
style=zrefvario, |
| 79 |
basicstyle=\ttfamily\small, |
| 80 |
columns=fullflexible, |
| 81 |
keepspaces, |
| 82 |
xleftmargin=\leftmargin, |
| 83 |
xrightmargin=.5\leftmargin, |
| 84 |
} |
| 85 |
\lstnewenvironment{zvexample}[1][]{% |
| 86 |
\renewcommand{\lstlistingname}{Example}% |
| 87 |
\lstset{#1}% |
| 88 |
}{} |
| 89 |
|
| 90 |
\begin{document} |
| 91 |
|
| 92 |
\GetFileInfo{zref-vario.sty} |
| 93 |
|
| 94 |
\title{% |
| 95 |
The \pkg{zref-vario} package% |
| 96 |
\texorpdfstring{\\{}\medskip{}}{ - }% |
| 97 |
User manual% |
| 98 |
\texorpdfstring{\medskip{}}{}% |
| 99 |
} |
| 100 |
|
| 101 |
\author{% |
| 102 |
\texorpdfstring{\texttt{gusbrs}\\[0.8em] |
| 103 |
\url{https://github.com/gusbrs/zref-vario}\\ |
| 104 |
\url{https://www.ctan.org/pkg/zref-vario}}{gusbrs}} |
| 105 |
|
| 106 |
\date{Version \fileversion\ -- \filedate} |
| 107 |
|
| 108 |
\maketitle |
| 109 |
|
| 110 |
\begin{center} |
| 111 |
{\bfseries \abstractname\vspace{-.5em}\vspace{0pt}} |
| 112 |
\end{center} |
| 113 |
|
| 114 |
\begin{quotation} |
| 115 |
\pkg{zref-vario} offers a compatibility layer for \pkg{varioref} to be used |
| 116 |
alongside \pkg{zref-clever}. It provides |
| 117 |
``\texttt{\textbackslash{}z}\dots{}'' counterparts to \pkg{varioref}'s main |
| 118 |
reference commands, each of which essentially does some (scoped) setup for |
| 119 |
\pkg{varioref}, then calls the original one. |
| 120 |
\end{quotation} |
| 121 |
|
| 122 |
\bigskip{} |
| 123 |
|
| 124 |
\begin{center} |
| 125 |
\textbf{EXPERIMENTAL} |
| 126 |
\end{center} |
| 127 |
|
| 128 |
\tableofcontents |
| 129 |
|
| 130 |
\clearpage{} |
| 131 |
|
| 132 |
\section{Loading the package} |
| 133 |
|
| 134 |
As usual: |
| 135 |
|
| 136 |
\begin{zvexample} |
| 137 |
\usepackage{zref-vario} |
| 138 |
\end{zvexample} |
| 139 |
|
| 140 |
\pkg{zref-vario} requires \pkg{zref-clever} and \pkg{varioref}. As a result, |
| 141 |
\pkg{zref-vario} is subject to the same load order requirements as |
| 142 |
\pkg{varioref}, prominently in relation to \pkg{hyperref}. |
| 143 |
|
| 144 |
|
| 145 |
\section{Package options} |
| 146 |
|
| 147 |
Package options can be set by means of \cs{zvsetup}. |
| 148 |
|
| 149 |
\begin{function}{\zvsetup} |
| 150 |
\begin{syntax} |
| 151 |
\cs{zvsetpup}\marg{options} |
| 152 |
\end{syntax} |
| 153 |
\end{function} |
| 154 |
|
| 155 |
Available options are: |
| 156 |
|
| 157 |
\bigskip{} |
| 158 |
|
| 159 |
\DescribeOption{pageprop} % |
| 160 |
\pkg{varioref} uses the \texttt{page} field of the standard label to check |
| 161 |
whether a reference and its label are on the same page, nearby, or far away. |
| 162 |
And has no real alternative data to use for the purpose. Possibly for this |
| 163 |
reason, the basic mechanism of page comparison in \pkg{varioref} is restricted |
| 164 |
to arabic numbered pages. Any other page numbering scheme results in |
| 165 |
\pkg{varioref} making no distinction between one or many pages off. But with |
| 166 |
\pkg{zref} it is trivial to detach the printed representation of the reference |
| 167 |
and the data used to make page comparisons. And that's what the |
| 168 |
\opt{pageprop} option allows to control. It receives a \pkg{zref} property as |
| 169 |
value to be used by \pkg{zref-vario} to make page comparisons, and defaults to |
| 170 |
the \texttt{page} property, which corresponds to the usual \pkg{varioref} |
| 171 |
behavior. The property must be defined and be included in \pkg{zref}'s main |
| 172 |
list at the time the setting is performed. The natural intended use case of |
| 173 |
this option is the \texttt{abspage} property provided by the |
| 174 |
\pkg{zref-abspage} module, which already handles these two requirements. |
| 175 |
Thus, loading this module and setting \opt{pageprop} to \texttt{abspage} gives |
| 176 |
us page comparisons independent of the page numbering scheme, which works in |
| 177 |
the front matter with roman numbering, across front and main matter |
| 178 |
boundaries, etc. In sum, regardless of whether the page numbering is arabic |
| 179 |
or anything else. |
| 180 |
|
| 181 |
|
| 182 |
\section{Reference commands} |
| 183 |
|
| 184 |
\begin{function}{\zvref} |
| 185 |
\begin{syntax} |
| 186 |
\cs{zvref}\meta{*}\oarg{options}\marg{label} |
| 187 |
\end{syntax} |
| 188 |
\end{function} |
| 189 |
|
| 190 |
\begin{function}{\zvpageref} |
| 191 |
\begin{syntax} |
| 192 |
\cs{zvpageref}\meta{*}\oarg{options}\marg{label} |
| 193 |
\end{syntax} |
| 194 |
\end{function} |
| 195 |
|
| 196 |
\begin{function}{\zvrefrange} |
| 197 |
\begin{syntax} |
| 198 |
\cs{zvrefrange}\meta{*}\oarg{options}\marg{label}\marg{label} |
| 199 |
\end{syntax} |
| 200 |
\end{function} |
| 201 |
|
| 202 |
\begin{function}{\zvpagerefrange} |
| 203 |
\begin{syntax} |
| 204 |
\cs{zvpagerefrange}\meta{*}\oarg{options}\marg{label}\marg{label} |
| 205 |
\end{syntax} |
| 206 |
\end{function} |
| 207 |
|
| 208 |
\begin{function}{\zfullref} |
| 209 |
\begin{syntax} |
| 210 |
\cs{zfullref}\meta{*}\oarg{options}\marg{label} |
| 211 |
\end{syntax} |
| 212 |
\end{function} |
| 213 |
|
| 214 |
These user commands work pretty much as their \pkg{varioref} |
| 215 |
counterparts.\footnote{If you are not acquainted with them, see |
| 216 |
\pkg{varioref}'s documentation.} Indeed, they are just wrappers around |
| 217 |
them. As such, differently from \pkg{zref-clever}'s commands, these can |
| 218 |
receive single labels as arguments, not lists of them. In all of them the |
| 219 |
starred version inhibits hyperlinking, and they (locally) set \pkg{varioref}'s |
| 220 |
\opt{nospace} option, so that the this syntax can be used unambiguously. |
| 221 |
|
| 222 |
All of them have a single optional argument, which can receive any of |
| 223 |
\cs{zcref}'s options, and those are set for calls to \cs{zcref} or |
| 224 |
\cs{zpageref} which are part of the building blocks of the reference formats |
| 225 |
and strings set for \pkg{varioref}. However, there is indeed some potential |
| 226 |
friction and caveats stemming from the use of these options, which were |
| 227 |
designed to work for single calls of \cs{zcref}, to apply to \emph{pairs} of |
| 228 |
them. Hence, whether each and every of these options is meaningful, useful, |
| 229 |
or potentially harmful in this context depends on the case, and it is up to |
| 230 |
the user to make proper use of them. Of course, one can always split the pair |
| 231 |
using \cs{zcref} and then \cs{zvpageref}, \cs{zvpagerefrange}, or |
| 232 |
\cs{zcpageref}, and have more control over each part. Anyway, the package |
| 233 |
does what it says: passes the options along to the underlying call(s) to |
| 234 |
\cs{zcref}.\footnote{Note that the options given to each call of these user |
| 235 |
macros are set \emph{before} the call to the original \pkg{varioref} |
| 236 |
counterpart. This means that options given to \cs{zcref} or \cs{zpageref} |
| 237 |
in the strings and formats in \cs{zvLanguageSetup} will have precedence over |
| 238 |
the former. Which is useful, so that we can distinguish to some degree the |
| 239 |
first from the second call of \cs{zcref}/\cs{zpageref} done in the formats, |
| 240 |
but does not eliminate the limitations which arise from the underlying |
| 241 |
problem.} |
| 242 |
|
| 243 |
\DescribeOption{vcurrent} % |
| 244 |
\DescribeOption{vother} % |
| 245 |
Besides \cs{zcref}'s options, mentioned above, two other ones are provided for |
| 246 |
\pkg{zref-vario}'s reference commands, corresponding to \pkg{varioref}'s |
| 247 |
commands optional arguments: \opt{vcurrent} (the first optional argument) and |
| 248 |
\opt{vother} (the second optional argument). Of course, these are only |
| 249 |
available when the underlying \pkg{varioref} command supports them. |
| 250 |
|
| 251 |
|
| 252 |
\section{Reference format} |
| 253 |
|
| 254 |
\begin{function}{\zvLanguageSetup} |
| 255 |
\begin{syntax} |
| 256 |
\cs{zvLanguageSetup}\marg{language}\marg{options} |
| 257 |
\end{syntax} |
| 258 |
\end{function} |
| 259 |
|
| 260 |
User interface for customization of ``strings'' and ``formats'' for |
| 261 |
\meta{language}. \meta{language} must be known to \pkg{zref-clever}. The |
| 262 |
\meta{options} are familiar to users of \pkg{varioref}: |
| 263 |
\opt{reftextfaceafter}, \opt{reftextfacebefore}, \opt{reftextafter}, |
| 264 |
\opt{reftextbefore}, \opt{reftextcurrent}, \opt{reftextfaraway}, |
| 265 |
\opt{reftextpagerange}, \opt{reftextlabelrange}, \opt{vrefformat}, |
| 266 |
\opt{vrefrangeformat}, and \opt{fullrefformat}.\footnote{For details, see |
| 267 |
\pkg{varioref}'s documentation.} Their meaning is the same as the ones they |
| 268 |
have in \pkg{varioref} and, indeed, they work by setting those \pkg{varioref} |
| 269 |
macros to the values given to the corresponding options in |
| 270 |
\cs{zvLanguageSetup}. If you are setting up a language which has no built-in |
| 271 |
support, you should set at least the whole set of ``\texttt{reftext}\dots{}'' |
| 272 |
options. Language independent default values are provided for the |
| 273 |
``\dots{}\texttt{format}'' options (equivalent to the ones from |
| 274 |
\pkg{varioref}, which are adequate for most use cases), so you may omit them. |
| 275 |
But, if you need to adjust them, the default values can be overridden by |
| 276 |
setting the corresponding options in \cs{zvLanguageSetup}. |
| 277 |
\cs{zvLanguageSetup} is preamble only. |
| 278 |
|
| 279 |
\begin{function}{\zvhyperlink} |
| 280 |
\begin{syntax} |
| 281 |
\cs{zvhyperlink}\marg{text} |
| 282 |
\end{syntax} |
| 283 |
\end{function} |
| 284 |
|
| 285 |
Inside the options of \cs{zvLanguageSetup}, and also inside the \opt{vcurrent} |
| 286 |
and \opt{vother} options of \pkg{zref-vario}'s reference commands, |
| 287 |
\cs{zvhyperlink} can be used to produce a hyperlink to the label of the |
| 288 |
reference. For example, one could set \texttt{reftextafter=\{on the |
| 289 |
\cs{zvhyperlink}\{next page\}\}} to get ``next page'' hyperlinked. |
| 290 |
\cs{zvhyperlink} can be used regardless of \opt{hyperref} being enabled for |
| 291 |
\pkg{zref-clever}, it will just pass on the \meta{text} argument if it is not. |
| 292 |
On range reference commands, \cs{zvhyperlink} only produces a link when both |
| 293 |
labels fall on the same page, in which case it hyperlinks to the first label. |
| 294 |
|
| 295 |
\bigskip{} |
| 296 |
|
| 297 |
As far as \pkg{zref-vario} is concerned, \pkg{varioref}'s options are (mostly) |
| 298 |
not taken into account: the language options are disregarded (settings made |
| 299 |
with \cs{zvLanguageSetup} are used instead), the \opt{nospace} option is |
| 300 |
hard-coded (locally) for the ``\texttt{\textbackslash{}z}\dots{}'' commands, |
| 301 |
and \opt{draft} and \opt{final} are typically given to \cs{documentclass}, |
| 302 |
though they do affect \pkg{zref-vario}'s commands, just as they do with |
| 303 |
\pkg{varioref}'s. |
| 304 |
|
| 305 |
|
| 306 |
\section{Integration with \pkg{zref-check}} |
| 307 |
|
| 308 |
When package \pkg{zref-check} is loaded, \pkg{zref-vario} provides one further |
| 309 |
option to its user commands: \opt{vcheck}. The purpose of this option is to |
| 310 |
check the relative position of label and reference within the same page. It |
| 311 |
can receive two values: \texttt{above} and \texttt{below}, being those the |
| 312 |
names of the \pkg{zref-check}'s checks which are meaningful for the use case |
| 313 |
at hand. Of course, these could also be performed with \cs{zcref}'s |
| 314 |
\opt{check} option, which is available for \pkg{zref-vario}'s commands as |
| 315 |
well. The difference here is that the check specified in \opt{vcheck} is only |
| 316 |
performed when the referenced label -- or labels, in the case of a range -- |
| 317 |
fall on the same page as the reference itself.\footnote{There's another |
| 318 |
technical difference between them. \pkg{zref-check}'s checks, and hence |
| 319 |
those of the \opt{check} option, make sure the whole reference passes each |
| 320 |
check by setting labels both at the start and the end of the reference, and |
| 321 |
verifying if each one of them passes the checks. But, since \pkg{varioref} |
| 322 |
already has it's own mechanism to handle references which cross page |
| 323 |
boundaries, \opt{vcheck}'s checks set only one label, at the end of the |
| 324 |
reference, the same position \pkg{varioref} uses to check whether label and |
| 325 |
reference are on the same page.} In other words, when \opt{vcurrent} would |
| 326 |
be used (if provided). For this reason, only the commands which support |
| 327 |
\opt{vcurrent} offer \pkg{vcheck}. Also, \opt{vcheck} cannot receive |
| 328 |
\pkg{zref-check}'s options, as \opt{check} is able to, but the latter can be |
| 329 |
used for the purpose of locally controlling the behavior of the checks |
| 330 |
performed by \opt{vcheck}. Consult \pkg{zref-check}'s documentation for |
| 331 |
details and limitations of these checks and envisaged workflows for their |
| 332 |
reliable use. |
| 333 |
|
| 334 |
|
| 335 |
\section{Acknowledgments} |
| 336 |
|
| 337 |
A number of people have contributed to \pkg{zref-vario}. Suggestions, |
| 338 |
ideas, solutions to problems, bug reports or even encouragement were |
| 339 |
generously provided by (in chronological order): |
| 340 |
Matteo Ferrigato, % 'matteo339' |
| 341 |
% 2023-01-02: https://github.com/gusbrs/zref-vario/issues/1 |
| 342 |
Ulrike Fischer, |
| 343 |
% 2023-01-02: https://tex.stackexchange.com/q/670399 (comments) |
| 344 |
% 2023-08-04: https://chat.stackexchange.com/transcript/message/64125129#64125129 |
| 345 |
% and following discussion. |
| 346 |
David Carlisle, |
| 347 |
% 2023-01-02: https://chat.stackexchange.com/transcript/message/62684358#62684358 |
| 348 |
% and following discussion. |
| 349 |
% 2023-02-10: https://tex.stackexchange.com/a/674846 |
| 350 |
and Joseph Wright. |
| 351 |
% 2023-01-02: https://chat.stackexchange.com/transcript/message/62684358#62684358 |
| 352 |
% and following discussion. |
| 353 |
|
| 354 |
The package's language settings have been provided or improved thanks to: |
| 355 |
Matteo Ferrigato (Italian) % 'matteo339' |
| 356 |
% 2023-01-02: https://github.com/gusbrs/zref-vario/issues/1 |
| 357 |
and \username{Timmyfox} (Swedish). |
| 358 |
% 2024-11-25: https://github.com/gusbrs/zref-vario/issues/3 |
| 359 |
|
| 360 |
If I have inadvertently left anyone off the list I apologize, and please let |
| 361 |
me know, so that I can correct the oversight. |
| 362 |
|
| 363 |
Thank you all very much! |
| 364 |
|
| 365 |
|
| 366 |
\section{Change history} |
| 367 |
|
| 368 |
A change log with relevant changes for each version, eventual upgrade |
| 369 |
instructions, and upcoming changes, is maintained in the package's repository, |
| 370 |
at \url{https://github.com/gusbrs/zref-vario/blob/main/CHANGELOG.md}. The |
| 371 |
change log is also distributed with the package's documentation through CTAN |
| 372 |
upon release so, most likely, \texttt{texdoc zref-vario/changelog} should |
| 373 |
provide easy local access to it. An archive of historical versions of the |
| 374 |
package is also kept at \url{https://github.com/gusbrs/zref-vario/releases}. |
| 375 |
|
| 376 |
\end{document} |