summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/zref-vario/zref-vario.tex
blob: a4ef370837674de797d4afc3eba7920ff193e9e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
% \iffalse meta-comment
%
% File: zref-vario.tex
%
% This file is part of the LaTeX package "zref-vario".
%
% Copyright (C) 2022  Gustavo Barros
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version.  The latest version
% of this license is in the file:
%
%    https://www.latex-project.org/lppl.txt
%
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
%
% This work is "maintained" (as per LPPL maintenance status) by
% Gustavo Barros.
%
% This work consists of the files zref-vario.dtx,
%                                 zref-vario.ins,
%                                 zref-vario.tex,
%                                 zref-vario-code.tex,
%         and the files listed in MANIFEST.md.
%
% The released version of this package is available from CTAN.
%
% -----------------------------------------------------------------------
%
% The development version of the package can be found at
%
%    https://github.com/gusbrs/zref-vario
%
% for those people who are interested.
%
% -----------------------------------------------------------------------
%
% \fi

\documentclass{l3doc}

% The package itself *must* be loaded so that \GetFileInfo can pick up date
% and version data.
\usepackage{zref-vario}

\usepackage[T1]{fontenc}

\usepackage[sc]{mathpazo}
\linespread{1.05}
\usepackage[scale=.88]{tgheros} % sans
\usepackage[varqu,scaled=1.03]{inconsolata} % tt

\usepackage{listings}

\usepackage{microtype}

\hypersetup{hidelinks}

\NewDocumentCommand\opt{m}{\texttt{#1}}

\lstdefinestyle{code}{
  language=[LaTeX]TeX,
  % moretexcs={
  % }
}
\lstdefinestyle{zrefvario}{
  style=code,
  % moretexcs={
  % }
}
\lstset{
  style=zrefvario,
  basicstyle=\ttfamily\small,
  columns=fullflexible,
  keepspaces,
  xleftmargin=\leftmargin,
  xrightmargin=.5\leftmargin,
}
\lstnewenvironment{zvexample}[1][]{%
  \renewcommand{\lstlistingname}{Example}%
  \lstset{#1}%
}{}

\begin{document}

\GetFileInfo{zref-vario.sty}

\title{%
  The \pkg{zref-vario} package%
  \thanks{This file describes \fileversion, released \filedate.}%
  \texorpdfstring{\\{}\medskip{}}{ - }%
  User manual%
  \texorpdfstring{\medskip{}}{}%
}

\author{%
  Gustavo Barros%
  \thanks{\url{https://github.com/gusbrs/zref-vario}}%
}

\date{\filedate}

\maketitle

\begin{center}
  {\bfseries \abstractname\vspace{-.5em}\vspace{0pt}}
\end{center}

\begin{quotation}
  \pkg{zref-vario} offers a compatibility layer for \pkg{varioref} to be used
  alongside \pkg{zref-clever}.  It provides
  ``\texttt{\textbackslash{}z}\dots{}'' counterparts to \pkg{varioref}'s main
  reference commands, each of which essentially does some (scoped) setup for
  \pkg{varioref}, then calls the original one.
\end{quotation}

\bigskip{}

\begin{center}
  \textbf{EXPERIMENTAL}
\end{center}

\tableofcontents

\clearpage{}

\section{Loading the package}

As usual:

\begin{zvexample}
\usepackage{zref-vario}
\end{zvexample}

\pkg{zref-vario} will load \pkg{varioref} and \pkg{zref-clever} at
\texttt{begindocument/before}, if they have not already been loaded.  However,
considering \pkg{varioref} has known load order interaction with other
packages, prominently with \pkg{hyperref}, you may wish to load it explicitly
to ensure its load order requirements are met.


\section{Dependencies}

\pkg{zref-vario} requires \pkg{varioref} and \pkg{zref-clever}.


\section{User interface}

\begin{function}{\zvref}
  \begin{syntax}
    \cs{zvref}\meta{*}\oarg{options}\marg{label}
  \end{syntax}
\end{function}

\begin{function}{\zvpageref}
  \begin{syntax}
    \cs{zvpageref}\meta{*}\oarg{options}\marg{label}
  \end{syntax}
\end{function}

\begin{function}{\zvrefrange}
  \begin{syntax}
    \cs{zvrefrange}\meta{*}\oarg{options}\marg{label}\marg{label}
  \end{syntax}
\end{function}

\begin{function}{\zvpagerefrange}
  \begin{syntax}
    \cs{zvpagerefrange}\meta{*}\oarg{options}\marg{label}\marg{label}
  \end{syntax}
\end{function}

\begin{function}{\zfullref}
  \begin{syntax}
    \cs{zfullref}\meta{*}\oarg{options}\marg{label}
  \end{syntax}
\end{function}

These user commands work pretty much as their \pkg{varioref}
counterparts.\footnote{If you are not acquainted with them, see
  \pkg{varioref}'s documentation.}  Indeed, they are just wrappers around
them.  As such, differently from \pkg{zref-clever}'s commands, these can
receive single labels as arguments, not lists of them.  In all of them the
starred version inhibits hyperlinking, and they (locally) set \pkg{varioref}'s
\opt{nospace} option, so that the this syntax can be used unambiguously.

All of them have a single optional argument, which can receive any of
\cs{zcref}'s options, and those are set for calls to \cs{zcref} or
\cs{zpageref} which are part of the building blocks of the reference formats
and strings set for \pkg{varioref}.  However, there is indeed some potential
friction and caveats stemming from the use of these options, which were
designed to work for single calls of \cs{zcref}, to apply to \emph{pairs} of
them.  Hence, whether each and every of these options is meaningful, useful,
or potentially harmful in this context depends on the case, and it is up to
the user to make proper use of them.  Of course, one can always split the pair
using \cs{zcref} and then \cs{zvpageref}, \cs{zvpagerefrange}, or
\cs{zcpageref}, and have more control over each part.  Anyway, the package
does what it says: passes the options along to the underlying call(s) to
\cs{zcref}.\footnote{Note that the options given to each call of these user
  macros are set \emph{before} the call to the original \pkg{varioref}
  counterpart.  This means that options given to \cs{zcref} or \cs{zpageref}
  in the strings and formats in \cs{zvLanguageSetup} will have precedence over
  the former.  Which is useful, so that we can distinguish to some degree the
  first from the second call of \cs{zcref}/\cs{zpageref} done in the formats,
  but does not eliminate the limitations which arise from the underlying
  problem.}

Besides these options, two other are provided corresponding to
\pkg{varioref}'s commands' optional arguments: \opt{vcurrent} (the first
optional argument) and \opt{vother} (the second optional argument).  Of
course, these are only available when the underlying \pkg{varioref} command
supports them.

\section{Customization}

\begin{function}{\zvLanguageSetup}
  \begin{syntax}
    \cs{zvLanguageSetup}\marg{language}\marg{options}
  \end{syntax}
\end{function}

User interface for customization of ``strings'' and ``formats'' for
\meta{language}.  \meta{language} must be known to \pkg{zref-clever}.  The
\meta{options} are familiar to users of \pkg{varioref}:
\opt{reftextfaceafter}, \opt{reftextfacebefore}, \opt{reftextafter},
\opt{reftextbefore}, \opt{reftextcurrent}, \opt{reftextfaraway},
\opt{reftextpagerange}, \opt{reftextlabelrange}, \opt{vrefformat},
\opt{vrefrangeformat}, and \opt{fullrefformat}.\footnote{For details, see
  \pkg{varioref}'s documentation.}  Their meaning is the same as the ones they
have in \pkg{varioref} and, indeed, they work by setting those \pkg{varioref}
macros to the values given to the corresponding options in
\cs{zvLanguageSetup}.  If you are setting up a language which has no built-in
support, you should set at least the whole set of ``\texttt{reftext}\dots{}''
options.  Language independent default values are provided for the
``\dots{}\texttt{format}'' options (equivalent to the ones from
\pkg{varioref}, which are adequate for most use cases), so you may omit them.
But, if you need to adjust them, the default values can be overridden by
setting the corresponding options in \cs{zvLanguageSetup}.

As far as \pkg{zref-vario} is concerned, \pkg{varioref}'s options are (mostly)
not taken into account: the language options are disregarded (settings made
with \cs{zvLanguageSetup} are used instead), the \opt{nospace} option is
hard-coded (locally) for the ``\texttt{\textbackslash{}z}\dots{}'' commands,
and \opt{draft} and \opt{final} are typically given to \cs{documentclass},
though they do affect \pkg{zref-vario}'s commands, just as they do with
\pkg{varioref}'s.


\section{Integration with \pkg{zref-check}}

When package \pkg{zref-check} is loaded, \pkg{zref-vario} provides one further
option to its user commands: \opt{vcheck}.  The purpose of this option is to
check the relative position of label and reference within the same page.  It
can receive two values: \texttt{above} and \texttt{below}, being those the
names of the \pkg{zref-check}'s checks which are meaningful for the use case
at hand.  Of course, these could also be performed with \cs{zcref}'s
\opt{check} option, which is available for \pkg{zref-vario}'s commands as
well.  The difference here is that the check specified in \opt{vcheck} is only
performed when the referenced label -- or labels, in the case of a range --
fall on the same page as the reference itself.\footnote{There's another
  technical difference between them.  \pkg{zref-check}'s checks, and hence
  those of the \opt{check} option, make sure the whole reference passes each
  check by setting labels both at the start and the end of the reference, and
  verifying if each one of them passes the checks.  But, since \pkg{varioref}
  already has it's own mechanism to handle references which cross page
  boundaries, \opt{vcheck}'s checks set only one label, at the end of the
  reference, the same position \pkg{varioref} uses to check whether label and
  reference are on the same page.}  In other words, when \opt{vcurrent} would
be used (if provided).  For this reason, only the commands which support
\opt{vcurrent} offer \pkg{vcheck}.  Also, \opt{vcheck} cannot receive
\pkg{zref-check}'s options, as \opt{check} is able to, but the latter can be
used for the purpose of locally controlling the behavior of the checks
performed by \opt{vcheck}.  Consult \pkg{zref-check}'s documentation for
details and limitations of these checks and envisaged workflows for their
reliable use.


% \section{Acknowledgments}
%
% A number of people have contributed to \pkg{zref-vario}.  Suggestions,
% ideas, solutions to problems, bug reports or even encouragement were
% generously provided by (in chronological order):
%
% The package's language settings have been provided or improved thanks to:
%
% If I have inadvertently left anyone off the list I apologize, and please let
% me know, so that I can correct the oversight.
%
% Thank you all very much!


\section{Change history}

A change log with relevant changes for each version, eventual upgrade
instructions, and upcoming changes, is maintained in the package's repository,
at \url{https://github.com/gusbrs/zref-vario/blob/main/CHANGELOG.md}.  An
archive of historical versions of the package is also kept at
\url{https://github.com/gusbrs/zref-vario/releases}.

\end{document}