| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: zref-check.tex |
| 4 |
% |
| 5 |
% This file is part of the LaTeX package "zref-check". |
| 6 |
% |
| 7 |
% Copyright (C) 2021-2022 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-check.dtx, |
| 23 |
% zref-check.ins, |
| 24 |
% zref-check-doc.tex, |
| 25 |
% zref-check-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-check |
| 35 |
% |
| 36 |
% for those people who are interested. |
| 37 |
% |
| 38 |
% ----------------------------------------------------------------------- |
| 39 |
% |
| 40 |
% \fi |
| 41 |
|
| 42 |
\documentclass{l3doc} |
| 43 |
|
| 44 |
% Have \GetFileInfo pick up date and version data |
| 45 |
\usepackage{zref-check} |
| 46 |
|
| 47 |
\setlength{\marginparsep}{2\labelsep} |
| 48 |
|
| 49 |
\NewDocumentCommand\opt{m}{\texttt{#1}} |
| 50 |
|
| 51 |
\makeatletter |
| 52 |
\newcommand{\zcrequiredkernel}{\zrefcheck@required@kernel} |
| 53 |
\makeatother |
| 54 |
|
| 55 |
\begin{document} |
| 56 |
|
| 57 |
\GetFileInfo{zref-check.sty} |
| 58 |
|
| 59 |
\title{% |
| 60 |
The \pkg{zref-check} package% |
| 61 |
\texorpdfstring{\\{}\medskip{}}{ - }% |
| 62 |
User manual% |
| 63 |
\texorpdfstring{\medskip{}}{}% |
| 64 |
} |
| 65 |
|
| 66 |
\author{% |
| 67 |
\texorpdfstring{\texttt{gusbrs}\\[0.8em] |
| 68 |
\url{https://github.com/gusbrs/zref-check}\\ |
| 69 |
\url{https://www.ctan.org/pkg/zref-check}}{gusbrs}} |
| 70 |
|
| 71 |
\date{Version \fileversion\ -- \filedate} |
| 72 |
|
| 73 |
\maketitle |
| 74 |
|
| 75 |
\begin{abstract} |
| 76 |
\pkg{zref-check} provides an user interface for making \LaTeX{} |
| 77 |
cross-references flexibly, while allowing to have them checked for |
| 78 |
consistency with the document structure as typeset. Statements such as |
| 79 |
``above'', ``on the next page'', ``previously'', ``as will be discussed'', |
| 80 |
``on the previous chapter'' and so on can be given to \cs{zcheck} in |
| 81 |
free-form, and a set of ``checks'' can be specified to be run against a |
| 82 |
given \texttt{label}, which will result in a warning at compilation time if |
| 83 |
any of these checks fail. \cs{zctarget} and the \texttt{zcregion} |
| 84 |
environment are also defined as a means to easily set label targets to |
| 85 |
arbitrary places in the text which can be referred to by \cs{zcheck}. |
| 86 |
\end{abstract} |
| 87 |
|
| 88 |
\tableofcontents |
| 89 |
|
| 90 |
|
| 91 |
\section{Introduction} |
| 92 |
|
| 93 |
The \pkg{zref-check} package provides an user interface for making \LaTeX{} |
| 94 |
cross-references exploiting document contextual information to enrich the way |
| 95 |
the reference can be rendered, but at the same time ensuring the means that |
| 96 |
these cross-references can be done consistently with the document structure. |
| 97 |
|
| 98 |
The usual \LaTeX{} cross-reference is done by referring to a \texttt{label}, |
| 99 |
associated with one or another document structural element, and this reference |
| 100 |
will typeset for you some content based on the information which is stored in |
| 101 |
that label. \cs{zcheck}, the main user command of \pkg{zref-check}, has a |
| 102 |
somewhat different concept. Instead of trying to provide the text to be |
| 103 |
typeset based on the contextual information, \cs{zcheck} lets the user supply |
| 104 |
an arbitrary text and specify one or more checks to be done on the label(s) |
| 105 |
being referred to. If any of the checks fails, a warning is issued upon |
| 106 |
compilation, so that the user can go back to that cross-reference and correct |
| 107 |
it as needed, without having to rely on burdensome and error prone manual |
| 108 |
proof-reading. |
| 109 |
|
| 110 |
This grants a much increased flexibility for the cross-reference text, which |
| 111 |
means in practice that the writing style, the variety of expressions you may |
| 112 |
use for similar situations, does not need to be sacrificed for the |
| 113 |
convenience. \cs{zcheck}'s cross-references do not need to ``feel'' automated |
| 114 |
to be consistently checked. Localization is also not an issue, since the |
| 115 |
cross-reference text is provided directly by the user. Separating |
| 116 |
``typesetting'' from ``checking'' also means there is a lot of document |
| 117 |
context we can leverage for this purpose (see Section~\ref{sec:checks}). |
| 118 |
|
| 119 |
A standard \LaTeX{} cross-reference is made to refer to specific numbered |
| 120 |
document elements -- chapters, sections, figures, tables, equations, etc. The |
| 121 |
cross-reference will normally produce that number (which is the element's |
| 122 |
``id'') and, eventually, its ``type'' (the counter). We may also refer to the |
| 123 |
page that element occurs and even its ``title'' (in which case, atypically, we |
| 124 |
may even get to refer to an unnumbered section, provided we also implicitly |
| 125 |
supply by some means the ``id''). |
| 126 |
|
| 127 |
For references to these usual specific document elements, \pkg{zref-check} |
| 128 |
caters for a particular kind of cross-reference which is common: |
| 129 |
\emph{relational} statements based on them. \cs{zcheck} can typeset and |
| 130 |
meaningfully check cross-references such as ``above'', ``on the next page'', |
| 131 |
``on the facing page'', ``on the previous section'', ``later on this chapter'' |
| 132 |
and so on. After all, if your reference is being made on page 2 and refers to |
| 133 |
something on the same page, ``on this page'' reads much better than ``on |
| 134 |
page~2''. If you are writing chapter~4, ``on the previous chapter'' sounds |
| 135 |
nicer than ``on chapter~3''. |
| 136 |
|
| 137 |
However, there is yet another kind of ``looser'' cross-reference we routinely |
| 138 |
do in our documents. Expressions such as ``previously'', ``as mentioned |
| 139 |
before'', ``as will be discussed'', and so on, are a powerful discursive |
| 140 |
instrument, which enriches the text, by offering hints to the arguments' |
| 141 |
threads, without necessarily pressing them too hard onto the reader. So, we |
| 142 |
might not want to say ``on footnote 57, pag.~34'', but prefer ``previously'', |
| 143 |
not ``on Section 3.4'', but rather ``below'', or ``later on''. Besides, we |
| 144 |
also may refer to certain passages in the text in this way, rather than to |
| 145 |
numbered document elements. And this kind of reference is not only hard to |
| 146 |
check and find, but also to fix. After all, if you are making one such |
| 147 |
reference, you are taking that statement as a premisse at the current point in |
| 148 |
the text. So, if that reference is missing, or relocated, you may need to |
| 149 |
bring in the support to the premisse for your argument to close, rather than |
| 150 |
just ``adjust the reference text''. \pkg{zref-check} also provides support |
| 151 |
for this kind of cross-reference, allowing for them to be consistently |
| 152 |
verified. |
| 153 |
|
| 154 |
|
| 155 |
\section{Loading the package} |
| 156 |
\label{sec:loading-package} |
| 157 |
|
| 158 |
\pkg{zref-check} can be loaded with the usual: |
| 159 |
|
| 160 |
\begin{syntax} |
| 161 |
\cs{usepackage}|{zref-check}| |
| 162 |
\end{syntax} |
| 163 |
|
| 164 |
The package does not accept load-time options, package options must be set |
| 165 |
using \cs{zrefchecksetup} (see Section~\ref{sec:user-interface}). |
| 166 |
|
| 167 |
|
| 168 |
\section{Dependencies} |
| 169 |
|
| 170 |
\pkg{zref} is required, of course, but in particular, its modules |
| 171 |
\pkg{zref-user} and \pkg{zref-abspage} are loaded by default. \pkg{ifdraft} |
| 172 |
(from the \pkg{oberdiek} bundle) is also loaded by default. A \LaTeX{} kernel |
| 173 |
later than \zcrequiredkernel{} is required as well. If \pkg{hyperref} is |
| 174 |
loaded and option \pkg{hyperref} is given, \pkg{zref-check} makes use of it, |
| 175 |
but it does not load the package for you. |
| 176 |
|
| 177 |
|
| 178 |
\section{User interface} |
| 179 |
\label{sec:user-interface} |
| 180 |
|
| 181 |
\begin{function}{\zcheck} |
| 182 |
\begin{syntax} |
| 183 |
\cs{zcheck}\oarg{checks/options}\marg{labels}\marg{text} |
| 184 |
\end{syntax} |
| 185 |
Typesets \meta{text}, as given, while performing a list of \meta{checks} on |
| 186 |
each of the \meta{labels}. When \pkg{hyperref} support is enabled, |
| 187 |
\meta{text} will be made a hyperlink to \emph{the first} \meta{label} in |
| 188 |
\meta{labels}. The starred version of the command does the same as the |
| 189 |
plain one, just does not form a link. The \meta{options} are (mostly) the |
| 190 |
same as those of the package, and can be given to local effect. |
| 191 |
\meta{checks} and \meta{options} can be given side by side as a comma |
| 192 |
separated list in the optional argument. \meta{labels} is also a comma |
| 193 |
separated list. |
| 194 |
\end{function} |
| 195 |
|
| 196 |
\begin{function}{\zctarget} |
| 197 |
\begin{syntax} |
| 198 |
\cs{zctarget}\marg{label}\marg{text} |
| 199 |
\end{syntax} |
| 200 |
Typesets \meta{text}, as given, and places a pair of \texttt{zlabel}s, one |
| 201 |
at the start of \meta{text}, using \meta{label} as label name, another one |
| 202 |
(internal) at the end of \meta{text}. |
| 203 |
\end{function} |
| 204 |
|
| 205 |
|
| 206 |
\begin{function}{zcregion} |
| 207 |
\begin{syntax} |
| 208 |
|\begin{zcregion}|\marg{label} |
| 209 |
| ...| |
| 210 |
|\end{zcregion}| |
| 211 |
\end{syntax} |
| 212 |
An environment that does the same as \cs{zctarget}, for cases of longer |
| 213 |
stretches of text. |
| 214 |
\end{function} |
| 215 |
|
| 216 |
|
| 217 |
\begin{function}{\zrefchecksetup} |
| 218 |
\begin{syntax} |
| 219 |
\cs{zrefchecksetup}\marg{options} |
| 220 |
\end{syntax} |
| 221 |
Sets \pkg{zref-check}'s options (see Section~\ref{sec:options}). |
| 222 |
\end{function} |
| 223 |
|
| 224 |
\bigskip{} |
| 225 |
|
| 226 |
All user commands of \pkg{zref-check} have their \marg{label} arguments |
| 227 |
protected for \pkg{babel} active characters using \pkg{zref}'s |
| 228 |
\cs{zref@wrapper@babel}, so that we should have equivalent support in that |
| 229 |
regard, as \pkg{zref} itself does. \pkg{zref-check} depends on \pkg{zref}, as |
| 230 |
the name entails, which means it is able to work with \pkg{zref} labels, in |
| 231 |
general created by \cs{zlabel}, but also with \cs{zctarget} and the |
| 232 |
\texttt{zcregion} environment provided by this package. |
| 233 |
|
| 234 |
|
| 235 |
\section{Checks} |
| 236 |
\label{sec:checks} |
| 237 |
|
| 238 |
\pkg{zref-check} provides several ``checks'' to be used with \cs{zcheck}. The |
| 239 |
checks may be combined in a \cs{zcheck} call, e.g.\ \opt{[close, after]}, or |
| 240 |
\opt{[thischap, before]}. In this case, each check in \meta{checks} is |
| 241 |
performed against each of the \meta{labels}. This is done independently for |
| 242 |
each check, which means, in practice, that the checks bear a logical |
| 243 |
\texttt{AND} relation to the others. Whether the combination is meaningful, |
| 244 |
is up to the user. As is the correspondence between the \meta{checks} and the |
| 245 |
\meta{text} in \cs{zcheck}. |
| 246 |
|
| 247 |
The use of checks which perform ``within the page'' comparisons -- namely |
| 248 |
\opt{above} and \opt{below} and, through them, \opt{before} and \opt{after} -- |
| 249 |
comes with some caveats you should be acquainted with. |
| 250 |
Section~\ref{sec:within-page-checks} discusses their limitations and expands |
| 251 |
on the expected workflow for their use to ensure reliable results. |
| 252 |
|
| 253 |
Note that the naming convention of the checks adopts the perspective of |
| 254 |
\cs{zcheck}. That is, the name of the check describes the position of the |
| 255 |
label being referred to, relative to the \cs{zcheck} call being made. For |
| 256 |
example, the \opt{before} check should issue no message if |
| 257 |
\cs{ztarget}|{mylabel}{...}| occurs before |
| 258 |
\cs{zcheck}|[before]{mylabel}{...}|. |
| 259 |
|
| 260 |
The available checks are the following: |
| 261 |
|
| 262 |
\begin{description}[leftmargin=0pt, itemindent=0pt, align=right, labelsep=1em, |
| 263 |
font=\MacroFont] |
| 264 |
|
| 265 |
\item[thispage] \meta{label} occurs on the same page as \cs{zcheck}. |
| 266 |
|
| 267 |
\item[prevpage] \meta{label} occurs on the previous page relative to |
| 268 |
\cs{zcheck}. |
| 269 |
|
| 270 |
\item[nextpage] \meta{label} occurs on the next page relative to \cs{zcheck}. |
| 271 |
|
| 272 |
\item[otherpage] \meta{label} occurs on a page different from that of |
| 273 |
\cs{zcheck}, that is, it does \emph{not} occur on \opt{thispage}. |
| 274 |
|
| 275 |
\item[pagegap] There is a page gap between \meta{label} and \cs{zcheck}, in |
| 276 |
other words, \meta{label} does \emph{not} occur on \opt{thispage}, |
| 277 |
\opt{prevpage} or \opt{nextpage}. |
| 278 |
|
| 279 |
\item[facing] On a \texttt{twoside} document, both \meta{label} and |
| 280 |
\cs{zcheck} fall onto a double spread, each on one of the two facing pages. |
| 281 |
|
| 282 |
\item[above] \meta{label} and \cs{zcheck} are both on the same page, and |
| 283 |
\meta{label} occurs ``above'' \cs{zcheck}. |
| 284 |
|
| 285 |
\item[below] \meta{label} and \cs{zcheck} are both on the same page, and |
| 286 |
\meta{label} occurs ``below'' \cs{zcheck}. |
| 287 |
|
| 288 |
\item[pagesbefore] \meta{label} occurs on any page before the one of |
| 289 |
\cs{zcheck}. |
| 290 |
|
| 291 |
\item[ppbefore] Convenience alias for \opt{pagesbefore}. |
| 292 |
|
| 293 |
\item[pagesafter] \meta{label} occurs on any page after the one of |
| 294 |
\cs{zcheck}. |
| 295 |
|
| 296 |
\item[ppafter] Convenience alias for \opt{pagesafter}. |
| 297 |
|
| 298 |
\item[before] Either \opt{above} or \opt{pagesbefore}. |
| 299 |
|
| 300 |
\item[after] Either \opt{below} or \opt{pagesafter}. |
| 301 |
|
| 302 |
\item[thischap] \meta{label} occurs on the same chapter as \cs{zcheck}. |
| 303 |
|
| 304 |
\item[prevchap] \meta{label} occurs on the previous chapter relative to the |
| 305 |
one of \cs{zcheck}. |
| 306 |
|
| 307 |
\item[nextchap] \meta{label} occurs on the next chapter relative to the one of |
| 308 |
\cs{zcheck}. |
| 309 |
|
| 310 |
\item[chapsbefore] \meta{label} occurs on any chapter before the one of |
| 311 |
\cs{zcheck}. |
| 312 |
|
| 313 |
\item[chapsafter] \meta{label} occurs on any chapter after the one of |
| 314 |
\cs{zcheck}. |
| 315 |
|
| 316 |
\item[thissec] \meta{label} occurs on the same section as \cs{zcheck}. |
| 317 |
|
| 318 |
\item[prevsec] \meta{label} occurs on the previous section (of the same |
| 319 |
chapter) relative to the one of \cs{zcheck}. |
| 320 |
|
| 321 |
\item[nextsec] \meta{label} occurs on the next section (of the same chapter) |
| 322 |
relative to the one of \cs{zcheck}. |
| 323 |
|
| 324 |
\item[secsbefore] \meta{label} occurs on any section (of the same chapter) |
| 325 |
before the one of \cs{zcheck}. |
| 326 |
|
| 327 |
\item[secsafter] \meta{label} occurs on any section (of the same chapter) |
| 328 |
after the one of \cs{zcheck}. |
| 329 |
|
| 330 |
\item[close] \meta{label} occurs within a page range from \opt{closerange} |
| 331 |
pages before the one of \cs{zcheck} to \opt{closerange} pages after it |
| 332 |
(about the \opt{closerange} option, see Section~\ref{sec:options}). |
| 333 |
|
| 334 |
\item[far] Not \opt{close}. |
| 335 |
|
| 336 |
\item[manual] A check which always fails. Can be used to keep track of |
| 337 |
relations not covered by the other regular checks. |
| 338 |
|
| 339 |
\end{description} |
| 340 |
|
| 341 |
|
| 342 |
\section{Options} |
| 343 |
\label{sec:options} |
| 344 |
|
| 345 |
Options are a standard \texttt{key=value} comma separated list, and can be set |
| 346 |
globally either as \cs{usepackage}\oarg{options} at load-time (see |
| 347 |
Section~\ref{sec:loading-package}), or by means of \cs{zrefchecksetup} (see |
| 348 |
Section~\ref{sec:user-interface}) in the preamble. Most options can also be |
| 349 |
used with local effects, through the optional argument of \cs{zcheck}. |
| 350 |
|
| 351 |
\DescribeOption{hyperref} % |
| 352 |
Controls the use of \pkg{hyperref} by \pkg{zref-check} and takes values |
| 353 |
\opt{auto}, \opt{true}, \opt{false}. The default value, \opt{auto}, makes |
| 354 |
\pkg{zref-check} use \pkg{hyperref} if it is loaded, meaning \cs{zcheck} can |
| 355 |
be hyperlinked to the \emph{first label} in \meta{labels}. \opt{true} does |
| 356 |
the same thing, but warns if \pkg{hyperref} is not loaded (\pkg{hyperref} is |
| 357 |
never loaded for you). In either of these cases, if \pkg{hyperref} is loaded, |
| 358 |
module \pkg{zref-hyperref} is also loaded by \pkg{zref-check}. \opt{false} |
| 359 |
means not to use \pkg{hyperref} regardless of its availability. This is a |
| 360 |
preamble only option, but \cs{zcheck} provides granular control of |
| 361 |
hyperlinking by means of its starred version. |
| 362 |
|
| 363 |
|
| 364 |
\DescribeOption{msglevel} % |
| 365 |
Sets the level of messages issued by \cs{zcheck} failed checks and takes |
| 366 |
values \opt{warn}, \opt{info}, \opt{none}, \opt{infoifdraft}, |
| 367 |
\opt{warniffinal}. The default value, \opt{warn}, issues messages both to the |
| 368 |
terminal and to the log file, \opt{info} issues messages to the log file only, |
| 369 |
\opt{none} suppresses all messages. \opt{infoifdraft} corresponds to |
| 370 |
\opt{info} if option \opt{draft} is passed to \cs{documentclass}, and to |
| 371 |
\opt{warn} otherwise. \opt{warniffinal} corresponds to \opt{warn} if option |
| 372 |
\opt{final} is (explicitly) passed to \cs{documentclass} and \opt{info} |
| 373 |
otherwise. \opt{ignore} and \opt{ok} are provided as convenience aliases for |
| 374 |
\opt{msglevel=none} for local use only. This option only affects the messages |
| 375 |
related to the checks in \cs{zcheck}, not other messages or warnings of the |
| 376 |
package. In particular, it does not affect warnings issued for undefined |
| 377 |
labels, which just use \cs{zref@refused} and thus are the same as standard |
| 378 |
\LaTeX{} ones for this purpose. |
| 379 |
|
| 380 |
|
| 381 |
\DescribeOption{onpage} % |
| 382 |
Allows to control the messaging style for ``within page checks'', and takes |
| 383 |
values \opt{labelseq}, \opt{msg}, \opt{labelseqifdraft}, \opt{msgiffinal}. |
| 384 |
The default, \opt{labelseq}, uses the labels' shipout sequence, as retrieved |
| 385 |
from the \file{.aux} file, to infer relative position within the page. |
| 386 |
\opt{msg} also uses the same method for checking relative position, but issues |
| 387 |
a (different) message \emph{even if the check passes}, to provide a simple |
| 388 |
workflow for robust checking of ``false negatives'', considering the label |
| 389 |
sequence is not fool proof (for details and workflow recommendations, see |
| 390 |
Section~\ref{sec:within-page-checks}). \opt{msg} also issues its messages at |
| 391 |
the same level defined in \opt{msglevel}. \opt{labelseqifdraft} corresponds |
| 392 |
to \opt{labelseq} if option \opt{draft} is passed to \cs{documentclass} and to |
| 393 |
\opt{msg} otherwise. \opt{msgiffinal} corresponds to \opt{msg} if option |
| 394 |
\opt{final} is (explicitly) passed to \cs{documentclass}, and to |
| 395 |
\opt{labelseq} otherwise. |
| 396 |
|
| 397 |
|
| 398 |
\DescribeOption{closerange} % |
| 399 |
Defines the width of the range of pages, relative to the reference, that are |
| 400 |
considered ``close'' by the \opt{close} check. Takes a positive integer as |
| 401 |
value, with default 5. |
| 402 |
|
| 403 |
|
| 404 |
\section{Limitations} |
| 405 |
|
| 406 |
There are three qualitatively different kinds of checks being used by |
| 407 |
\cs{zcheck}, according to the source and reliability of the information they |
| 408 |
mobilize: page number checks, within page checks, and sectioning checks. |
| 409 |
|
| 410 |
\subsection{Page number checks} |
| 411 |
|
| 412 |
Page number checks -- \opt{thispage}, \opt{prevpage}, \opt{nextpage}, |
| 413 |
\opt{pagesbefore}, \opt{pagesafter}, \opt{facing} -- use the \texttt{abspage} |
| 414 |
property provided by the \pkg{zref-abspage} module. This is a solid piece of |
| 415 |
information, on which we can rely upon. However, despite that, page number |
| 416 |
checks may still become ill-defined, if the \meta{text} argument in |
| 417 |
\cs{zcheck}, when typeset, crosses page boundaries, starting in one page, and |
| 418 |
finishing in another. The same can happen with the text in \cs{zctarget} and |
| 419 |
the \texttt{zcregion} environment. |
| 420 |
|
| 421 |
This is why the user commands of this package set a pair or labels around |
| 422 |
\meta{text}. So, when checking \cs{zcheck} against a regular \texttt{zlabel} |
| 423 |
both the start and the end of the \meta{text} are checked against the label, |
| 424 |
and the check fails if either of them fails. When checking \cs{zcheck} |
| 425 |
against a \cs{zctarget} or a \texttt{zcregion}, both beginnings and ends are |
| 426 |
checked against each other two by two, and if any of them fails, the check |
| 427 |
fails. In other words, if a page number checks passes, we know that the |
| 428 |
entire \meta{text} arguments pass it. |
| 429 |
|
| 430 |
This is a corner case (albeit relevant) which must be taken care of, and it is |
| 431 |
possible to do so robustly. Hence, we can expect reliable results in these |
| 432 |
tests. |
| 433 |
|
| 434 |
|
| 435 |
\subsection{Within page checks} |
| 436 |
\label{sec:within-page-checks} |
| 437 |
|
| 438 |
When both label and reference fall on the same page things become much |
| 439 |
trickier. This is basically the case of the checks \opt{above} and |
| 440 |
\opt{below} (and, through them, \opt{before} and \opt{after}). There is no |
| 441 |
equally reliable information (that I know of) as we have for the page number |
| 442 |
checks for this, especially when floats come into play. Which, of course, is |
| 443 |
the interesting case to handle. |
| 444 |
|
| 445 |
To infer relative position of label and reference on the same page, |
| 446 |
\pkg{zref-check} uses the labels' shipout sequence, which is retrieved at |
| 447 |
load-time from the order in which the labels occur in the \file{.aux} file. |
| 448 |
Indeed, \pkg{zref} writes labels to the \file{.aux} file at shipout (and, |
| 449 |
hence, in shipout order), and needs to do so, because a number of its |
| 450 |
properties are only available at that point. |
| 451 |
|
| 452 |
However, even if this method will buy us a correct check for a regular float |
| 453 |
on a regular page (which, to be fair, is a good result), it is not difficult |
| 454 |
do conceive situations in which this sequence may not be meaningful, or even |
| 455 |
correct, for the case. A number of cases which may do so are: two column |
| 456 |
documents, text wrapping, scaling, overlays, etc. (I don't know if those make |
| 457 |
the method fail, I just don't know if they don't). Therefore, the |
| 458 |
\texttt{labelseq} should be taken as a \emph{proxy} and not fully reliable, |
| 459 |
meaning that the user should be watchful of its results. |
| 460 |
|
| 461 |
For this reason, \pkg{zref-check} provides an easy way to do so, by allowing |
| 462 |
specific control of the messaging style of the checks which do within page |
| 463 |
comparisons though the option \opt{onpage}. The concern is not really with |
| 464 |
false positives (getting a warning when it was not due), but with false |
| 465 |
negatives (not getting a warning when it was due). Hence, setting |
| 466 |
\opt{onpage} to \opt{msg} at a final typesetting stage (or just set it to |
| 467 |
\opt{labelseqifdraft} or \opt{msgiffinal} if that's part of your workflow) |
| 468 |
provides a way to easily identify all cases of such checks (failing or |
| 469 |
passing), and double-check them. In case the test is passing though, the |
| 470 |
message is different from that of a failing check, to quickly convey why you |
| 471 |
are getting the message. This option can also be set at the local level, if |
| 472 |
the page in question is known to be problematic, or just atypical. |
| 473 |
|
| 474 |
|
| 475 |
\subsection{Sectioning checks} |
| 476 |
|
| 477 |
The information used by sectioning checks is provided by means of dedicated |
| 478 |
counters for chapters and sections, similarly as standard counters for them, |
| 479 |
but which are stepped and reset regardless of whether these sectioning |
| 480 |
commands are numbered or not (that is, starred or not). And this for two |
| 481 |
reasons. First, we don't need the absolute counter value to be able to make |
| 482 |
the kind of relative statement we want to do here. Second, this allows us to |
| 483 |
have these checks work for numbered and unnumbered sectioning commands without |
| 484 |
having to worry about how those are used within the document. |
| 485 |
|
| 486 |
The caveat is that the package does this by hooking into \cs{chapter} and |
| 487 |
\cs{section}, which poses two restrictions for the proper working of these |
| 488 |
checks. First, we are using the new hook system for this, as provided by |
| 489 |
\pkg{ltcmdhooks}, which means a \LaTeX{} kernel later than 2021-06-01 is |
| 490 |
required. Second, since we are hooking into \cs{chapter} and \cs{section}, |
| 491 |
these checks presume these commands are being used by the document class for |
| 492 |
this purpose (either directly, or internally as, for example, KOMA-Script's |
| 493 |
\cs{addchap} and \cs{addsec} do). If that's not the case, additional setup |
| 494 |
may be needed for these checks to work as expected. |
| 495 |
|
| 496 |
|
| 497 |
\section{Change history} |
| 498 |
|
| 499 |
A change log with relevant changes for each version, eventual upgrade |
| 500 |
instructions, and upcoming changes, is maintained in the package's repository, |
| 501 |
at \url{https://github.com/gusbrs/zref-check/blob/main/CHANGELOG.md}. The |
| 502 |
change log is also distributed with the package's documentation through CTAN |
| 503 |
upon release so, most likely, \texttt{texdoc zref-check/changelog} should |
| 504 |
provide easy local access to it. An archive of historical versions of the |
| 505 |
package is also kept at \url{https://github.com/gusbrs/zref-check/releases}. |
| 506 |
|
| 507 |
|
| 508 |
\end{document} |