Debian Codegraph @

texmf-dist/doc/latex/crossreftools/crossreftools_doc.tex

raw
1 %% LaTeX package crossreftools - version 1.0 (2020/07/19 -- 11:55:58)
2 %% Documentation file for crossreftools.sty
3 %%
4 %%
5 %% -------------------------------------------------------------------------------------------
6 %% Copyright (c) 2017 -- 2020 by Dr. Christian Hupfer <dr dot christian dot hupfer at gmail dot com>
7 %% -------------------------------------------------------------------------------------------
8 %%
9 %% This work may be distributed and/or modified under the
10 %% conditions of the LaTeX Project Public License, either version 1.3
11 %% of this license or (at your option) any later version.
12 %% The latest version of this license is in
13 %% http://www.latex-project.org/lppl.txt
14 %% and version 1.3 or later is part of all distributions of LaTeX
15 %% version 2005/12/01 or later.
16 %%
17 %%
18 %% This work has the LPPL maintenance status `author-maintained`
19 %%
20 %%
21
22 \documentclass[12pt,a4paper,oneside]{article}
23
24 \usepackage[T1]{fontenc}
25 \usepackage{graphicx}%
26
27
28 \usepackage{amsmath}
29 \usepackage{amssymb}
30 \usepackage{minitoc}
31 \usepackage{tocbibind}
32
33
34
35
36
37 \usepackage[lmargin=2cm,rmargin=2cm,headheight=15pt]{geometry}
38 \usepackage{savesym}
39 \usepackage{bbding}
40 \savesymbol{Cross}
41
42 \usepackage{graphicx}
43 \usepackage{blindtext}
44 \usepackage[x11names]{xcolor}
45 \usepackage{imakeidx}
46 \usepackage{fontawesome}
47 \usepackage[tikz]{bclogo}
48 \usepackage{marginnote}
49 \usepackage{fancyhdr}
50 \usepackage{datetime}
51 \usepackage{array}
52 \usepackage{xkeyval}
53 \usepackage{xparse}
54 \usepackage{totcount}
55 \usepackage{enumitem}
56 \usepackage{caption}
57 \usepackage{microtype}
58 \usepackage[T1]{fontenc}
59 \usepackage[scaled=0.92]{helvet}
60
61 \usepackage[most,documentation]{tcolorbox}
62
63
64 \newlist{codeoptionsenum}{enumerate}{1}
65 \setlist[codeoptionsenum,1]{label={\textcolor{blue}{\#\arabic*}}}
66
67 \renewcommand{\rmdefault}{\sfdefault}
68
69 \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
70
71 \makeatletter
72 \define@key{chdoc}{packageauthor}{%
73 \def\KVchdocpackageauthor{#1}%
74 }
75
76 \define@key{chdoc}{packageauthormail}{%
77 \def\KVchdocpackageauthormail{#1}%
78 }
79
80 \define@key{chdoc}{filepurpose}{%
81 \def\KVchdocfilepurpose{#1}%
82 }
83
84
85 \newcommand{\chdocextractversion}[1]{%
86 \@nameuse{#1}%
87 }
88
89
90 \@namedef{crossreftoolsversion0.1}{v0.1 2017-10-08}
91
92 \@namedef{crossreftoolsversion0.2}{v0.2 2017-10-25}
93
94 \@namedef{crossreftoolsversion0.3}{v0.3 2017-10-29}
95
96 \@namedef{crossreftoolsversion0.4}{v0.4 2017-12-26}
97
98 \@namedef{crossreftoolsversion0.5}{v0.5 2018-02-23}
99
100 \@namedef{crossreftoolsversion0.6}{v0.6 2018-03-18}
101
102 \@namedef{crossreftoolsversion0.7}{v0.7 2018-12-28}
103
104 \@namedef{crossreftoolsversion0.8}{v0.8 2018-12-29}
105
106 \@namedef{crossreftoolsversion0.9}{v0.9 2019-01-03}
107
108 \@namedef{crossreftoolsversion1.0}{v1.0 2020-07-19}
109
110 \newcommand{\authorname}{Autor}
111
112
113 \makeatother
114
115
116
117
118
119
120 \fancypagestyle{plain}{%
121 \fancyfoot[L]{\begin{tabular}[t]{l}\PackageDocName\ \packageversion \tabularnewline \textcopyright\ Dr. Christian Hupfer\end{tabular}}%
122 \fancyfoot[C]{\thepage}%
123 \fancyfoot[R]{\today}%
124 \renewcommand{\headrule}{{\color{blue}%
125 \hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
126 \renewcommand{\footrule}{{\color{blue}\vskip-\footruleskip\vskip-\footrulewidth
127 \hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
128 \renewcommand{\footrulewidth}{2pt}
129 \renewcommand{\headrulewidth}{2pt}
130 }
131
132
133
134 \newtcolorbox{CHPackageTitleBox}[1][]{%
135 enhanced jigsaw,
136 drop lifted shadow,
137 colback=yellow!30!white,
138 width=0.8\textwidth,
139 #1
140 }
141
142 \presetkeys{chdoc}{packageauthor={Christian Hupfer}}{}%
143 \NewDocumentCommand{\CHPackageTitlePage}{O{}mO{}}{%
144 \setkeys{chdoc}{packageauthor={Christian Hupfer},filepurpose={Documentation},#1}%
145 \begin{center}
146 \begin{CHPackageTitleBox}[#3]
147 \large \bfseries%
148 \begin{center}%
149 \begin{tabular}{C{0.9\textwidth}}%
150 \scshape \PackageDocName \tabularnewline
151 \tabularnewline
152 #2 \tabularnewline
153 \tabularnewline
154 \KVchdocfilepurpose \tabularnewline
155 \tabularnewline
156 Version \packageversion \tabularnewline
157 \tabularnewline
158 \today \tabularnewline
159 \tabularnewline
160 \addtocounter{footnote}{2}
161 \authorname: \KVchdocpackageauthor\(^\mathrm{\fnsymbol{footnote}}\)
162 \tabularnewline
163 \end{tabular}
164 \end{center}
165 \end{CHPackageTitleBox}
166 \renewcommand{\thefootnote}{\fnsymbol{footnote}}%
167 \footnotetext{\mymailtoaddress}%
168 \end{center}
169 }
170
171 \newtcolorbox{docCommandArgs}[1]{colbacktitle={blue},coltitle={white},title={Description of arguments of command \cs{#1}}}
172
173
174 \newcommand{\tcolorboxdoclink}{http://mirrors.ctan.org/macros/latex/contrib/tcolorbox/tcolorbox.pdf}
175
176 % 'Stolen' from tcolorbox documentation ;-)
177
178 \newtcolorbox{marker}[1][]{enhanced,
179 before skip=2mm,after skip=3mm,
180 boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
181 colback=yellow!50,
182 colframe=yellow!20!black,
183 sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
184 underlay={%
185 \path[fill=tcbcolback!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
186 \path[draw=tcbcolframe,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
187 \path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west);
188 },
189 drop fuzzy shadow,#1}
190
191
192 %%%% Documentation macros
193
194
195 \NewDocumentCommand{\packagename}{sm}{%
196 \textcolor{blue}{\textbf{\faEnvelopeO~#2}}%
197 \IfBooleanF{#1}{%
198 \index{Package!#2}
199 }%
200 }
201
202 \NewDocumentCommand{\classname}{sm}{%
203 \textcolor{brown}{\textbf{\faBriefcase~#2}}%
204 \IfBooleanF{#1}{%
205 \index{Package!#2}%
206 }%
207 }
208
209
210 \NewDocumentCommand{\CHDocPackage}{sm}{%
211 \textcolor{blue}{\textbf{\faEnvelopeO~#2}}%
212 \IfBooleanF{#1}{%
213 \index{Package!#2}
214 }%
215 }
216
217
218
219
220 \NewDocumentCommand{\CHDocClass}{sm}{%
221 \textcolor{brown}{\textbf{\faBriefcase~#2}}%
222 \IfBooleanF{#1}{%
223 \index{Package!#2}%
224 }%
225 }
226
227 \NewDocumentCommand{\CHDocKey}{sm}{%
228 \textcolor{red}{\textbf{\faKey~#2}}%
229 \IfBooleanF{#1}{%
230 \index{Option!#2}%
231 }%
232 }
233
234 \newcommand{\handrightnote}{\tcbdocmarginnote{\ding{43}}}
235
236
237 \NewDocumentCommand{\CHDocCounter}{sm}{%
238 \textcolor{Green4}{\textbf{\faCalculator~#2}}%
239 \IfBooleanF{#1}{%
240 \index{Counter!#2}%
241 }%
242 }
243
244
245 \NewDocumentCommand{\CHDocTag}{sm}{%
246 \textcolor{violet}{\faTag~#2}%
247 \IfBooleanF{#1}{%
248 \index{Feature!#2}%
249 }%
250 }
251
252
253 \NewDocumentCommand{\CHDocFileExt}{sm}{%
254 \faFile~#2%
255 }
256
257 \NewDocumentCommand{\CHDocFiles}{sm}{%
258 \faFilesO~#2%
259 }
260
261
262 \NewDocumentCommand{\CHDocConventions}{}{%
263 \section*{\centering Typographical conventions}
264 Throughout this documentation following symbols and conventions are used:
265 \begin{itemize}
266 \item \CHDocClass*{foo} means a the class \texttt{foo}
267 \item \CHDocPackage*{foo} names a package \texttt{foo}
268 \item \CHDocCounter*{foo} indicates a counter named \texttt{foo}
269 \item \CHDocFileExt*{foo} will indicate either a file named \texttt{foo} or a file extension \texttt{foo}
270 \item \CHDocFiles*{foo} will indicate some files
271 \item \CHDocTag*{foo} names a special feature or tag \texttt{foo}
272 \item \CHDocKey*{foo} deals with a command or package option named \texttt{foo}
273 \end{itemize}
274 }
275
276
277
278 \renewcommand{\tcbdocnew}[1]{#1}%
279 \renewcommand{\tcbdocupdated}[1]{#1}%
280
281 \newcommand{\CHDocNew}[1]{%
282 \tcbdocmarginnote[doclang/new={N},
283 colframe=blue,
284 halign=left,
285 colback={blue!20!white},
286 fontupper={\tiny}
287 ]{%
288 \chdocextractversion{crossreftoolsversion#1}%
289 }%
290 }
291
292
293
294 \newcommand{\CHDocUpdate}[1]{\tcbdocmarginnote[doclang/updated={},colback={yellow},colframe={yellow!50!red}, fontupper={\tiny}
295 ]{%
296 \tcbdocupdated{\chdocextractversion{crossreftoolsversion#1}}%
297 }%
298 }
299
300
301
302 \newcommand{\CHDocFullVersion}[1]{Version \chdocextractversion{crossreftoolsversion#1}}
303
304
305 \newcommand{\CHDocExpCommand}[1][Expandable]{%
306 \tcbdocmarginnote[doclang/new={N},
307 colframe=green!50!blue,
308 halign=left,
309 colback={green!90!blue},
310 fontupper={\tiny}
311 ]{%
312 #1%
313 }%
314 }
315
316
317 \newcommand{\CHDocExperimentalFeature}[1][Experimental]{%
318 \tcbdocmarginnote[doclang/new={N},
319 colframe=yellow!50!blue,
320 halign=left,
321 colback={blue!10!yellow},
322 fontupper={\tiny}
323 ]{%
324 #1%
325 }%
326 }
327
328
329
330 \usepackage{bookmark}
331
332
333 \usepackage{cleveref}
334
335
336
337
338 \def\packageversion{1.0}
339
340 \def\hyperrefversionwithfifthargument{v6.85a}
341
342 \usepackage{url}
343
344 \setcounter{tocdepth}{3}
345 \newcommand{\PackageDocName}{crossreftools}%
346
347
348 \newcommand{\mymailtoaddress}{%
349 [email protected]%
350 }
351
352 \doparttoc
353
354 \makeindex[intoc]
355
356
357 \renewcommand{\rmdefault}{\sfdefault}
358
359
360
361 \hypersetup{breaklinks=true,
362 pdftitle={\jobname.pdf -- version \packageversion},
363 pdfauthor={Dr. Christian Hupfer},
364 pdfsubject={Documentation of \PackageDocName\ package},
365 pdfkeywords={LaTeX, cross-referencing},
366 bookmarksopen=true,
367 bookmarksopenlevel=2,
368 bookmarksnumbered=true,
369 pdfcreator={LaTeX}
370 }
371
372 % Load here!
373
374 \AtEndPreamble{
375 \usepackage{crossreftools}
376 }
377
378
379
380 \begin{document}
381
382 \yyyymmdddate
383
384
385 \setlength{\parindent}{0em}
386
387 \pagestyle{empty}%
388
389
390
391 \CHPackageTitlePage[packageauthor={Christian Hupfer}]{Expandable extraction of cleveref or cross reference data and label utilities}
392
393
394 \clearpage
395 \tableofcontents
396 \clearpage
397
398 \CHDocConventions
399 \clearpage
400
401 \crtlistoflabels
402
403
404 \pagestyle{plain}
405
406
407 \setcounter{footnote}{0}
408
409 \part{Introduction}
410
411 \parttoc
412
413 \section*{Preface}
414
415 This package provides expandable extraction of information stored in labels generated with \CHDocPackage{cleveref} and regular labels written by the usual \cs{label} macro, regardless whether \CHDocPackage{hyperref} is loaded or not. For those regular cross-reference information \CHDocPackage{\PackageDocName} works in a \CHDocPackage{refcount} - like manner.
416
417 Whereas \CHDocPackage{cleveref} provides \cs{labelcref} and other commands or \cs{ref} from standard \LaTeX2e kernel none of those are expandable and can not be used in an \cs{edef} - approach.
418
419 \begin{marker}
420 Most times class and package authors will benefit of this package, but there might be usual documents that need the features of \CHDocPackage{\PackageDocName}
421 \end{marker}
422
423 All macros from this package use the prefix \cs{crt\dots}, eg \refCom{crtrefname}.
424
425 \section{Requirements, loading and incompatibilities}%
426
427
428
429 \subsection{Required packages and \TeX\ engine}
430
431 The package does not require features from Xe\LaTeX\ or Lua\LaTeX\ but can be run with those features as well as with \LaTeX\ or pdf\LaTeX. The compilation documentation requires however pdf\LaTeX\ as of version \packageversion.
432
433 No packages are loaded by \CHDocPackage{crossreftools}, this package does neither load \CHDocPackage{hyperref} nor \CHDocPackage{cleveref} itself.
434
435
436 \subsection{Loading of the package} \label{subsection::loadingofpackage}
437
438 Loading is done with
439
440 \begin{tcolorbox}
441 \verb!\usepackage[options]{crossreftools}!
442 \end{tcolorbox}
443
444 As of version \packageversion\ \CHDocPackage{\PackageDocName} does have following option(s):
445
446 \begin{itemize}
447 \item \texttt{draft}
448
449 By default, unless specified as package or class option, \CHDocPackage{\PackageDocName} works in draft mode, i.e. \CHDocTag{List of Labels} is enabled, see \crtcrefcounter{section::listoflabels} \nameref{section::listoflabels} for more on this.
450
451 \item \texttt{final}
452
453 This disables the feature \CHDocTag{List of Labels}, see \crtcrefcounter{section::listoflabels} \nameref{section::listoflabels} for more information about this feature -- it is considered to be unnecessary having a List of Labels in a final version of document.
454
455 By default, the package works in \texttt{draft} - mode, unless the class option \texttt{final} is specified already. In this case, the package option \texttt{final} can be omitted.
456 \item \texttt{cleverefcompat}
457
458 Use this option if the \CHDocPackage{cleveref} version is older than 0.21.
459
460 \begin{marker}
461 With the release of \CHDocPackage{cleveref} version 0.21 (dating to 2018/02/08) the format of stored information by \cs{label} changed and causes wrong output of \refCom{crtcrefpage}. Since version \makeatletter\@nameuse{crossreftoolsversion0.5}\makeatother\ this change is caught with \refCom{crtcrefpage}.
462 \end{marker}
463 \end{itemize}
464
465
466
467
468 There is no loading order required. The macros related to \CHDocPackage{cleveref} expand to \makeatletter\fbox{\crt@refundefined}\makeatother\ if \CHDocPackage{cleveref} is not loaded.
469
470 \begin{marker}
471 In order to ensure that the changes to the cross referencing system introduced by \CHDocPackage{hyperref} and \CHDocPackage{cleveref} it is recommened to load \CHDocPackage{\PackageDocName} after both packages.
472 \end{marker}
473
474 \subsection{Incompatibilities}\label{subsection:incompatibilities}
475
476 \begin{itemize}
477 \item Plain \TeX:
478
479
480 As of \packageversion\ this package cannot be used with plain \TeX, since there is no real built-in support for cross-referencing in plain \TeX.
481 \item Issue with \cs{tcb@cs} from the \CHDocPackage{tcolorbox} and its \fbox{documentation} library regarding the \cs{crtlistoflabels} usage.
482
483 As of \packageversion\ this package cannot cope with labels produced from \CHDocPackage{tcolorbox} for documented code -- this inserts an unexpandable call of \cs{tcb@cs} in the label content which leaves unpleasant content in the List Of Labels (see \nameref{section::listoflabels}). As long as no other solution is available, \cs{tcb@cs} is redefined to gobble its argument only and doing nothing inside the \refCom{crtlistoflabels} macro.
484
485 \begin{marker}
486 This is the cause for the special \cs{refCom} macro provided by the documentation library from \CHDocPackage{tcolorbox}.
487 \end{marker}
488
489 \item Similarly any unexpandable content written to the \CHDocFileExt{aux} - file by redefinitions of \cs{label} or \cs{@currentlabel} etc. will cause problems.
490 \end{itemize}
491
492 \clearpage
493
494 \part{Macro descriptions}
495
496 \parttoc
497
498 \section{Indicating undefined references}
499
500 \CHDocPackage{\PackageDocName} uses the content of the internal macro \cs{crt@refundefined} which defaults to \makeatletter\crt@refundefined\makeatother.
501 Use \refCom{crtrefundefinedtext} to change the output of \cs{crt@refundefined}.
502
503 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtrefundefinedtext}{\marg{undefined reference indication text}}
504
505
506 This command sets the output of \cs{crt@refundefined} in the same manner like the standard macro \cs{title} would do for \cs{@title}.
507
508 \begin{marker}
509 \refCom{crtrefundefinedtext} is a preamble-only macro.
510 \end{marker}
511 \end{docCommand}
512
513
514 Similar to \refCom{crtrefundefinedtext} is \refCom{crtcrefundefinedcountervalue}, providing an integer value in calculation contexts with \cs{ifnum} or \cs{setcounter}.
515
516 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtcrefundefinedcountervalue}{\marg{integer value}}
517
518
519 This command sets the output of \cs{crt@crefundefinedcountervalue} in the same manner like the standard macro \cs{title} would do for \cs{@title}.
520
521 \begin{marker}
522 \refCom{crtcrefundefinedcountervalue} is a preamble-only macro.
523 \end{marker}
524 \end{docCommand}
525
526
527 \section{Extracting information from regular labels}\label{section:extractingregularlabels}
528
529 Depending on loading of \CHDocPackage{hyperref} there is some more information (properties) stored with a \cs{label} command. Common properties are \texttt{reference} and \texttt{page}, additions of \CHDocPackage{hyperref} are \texttt{name}, \texttt{anchor} and the (yet) unused 5th argument of \cs{newlabel}, the property is called \texttt{unused} as of version \packageversion.
530
531 All properties are extracted with \refCom{crtextractref}.
532
533
534
535 \begin{docCommand}[code={\CHDocExpCommand{}},
536 doc new={\chdocextractversion{crossreftoolsversion0.3}}]{crtextractref}{\marg{property}\marg{label name}}
537
538 This command will extract one of the properties \texttt{reference}, \texttt{page}, \texttt{anchor}, \texttt{name} and \texttt{unused} from the label given as the 2nd mandatory argument.
539 \end{docCommand}
540
541 For convenience, there are shortcuts to extract a specific property:
542
543 \begin{docCommand}[code={\CHDocExpCommand{}},doc new and updated={\chdocextractversion{crossreftoolsversion0.3}}{\chdocextractversion{crossreftoolsversion0.5}},after=\par]{crtcrefpage}{\marg{label name}}%
544
545 This extracts the page number that would be printed by \cs{cpageref}.
546 \end{docCommand}
547
548
549 \begin{docCommand}[code={\CHDocExpCommand{}},
550 doc new={\chdocextractversion{crossreftoolsversion0.3}}]{crtrefnumber}{\marg{label name}}
551
552 This extracts the reference value (or something that is stored by \cs{@currentlabel} belonging to a certain label name.
553 \end{docCommand}
554
555 With \CHDocPackage{hyperref} being loaded, following commands return non-empty label information, without \CHDocPackage{hyperref} they are available, but expand to nothing.
556
557 \begin{docCommand}[code={\CHDocExpCommand{}},
558 doc new={\chdocextractversion{crossreftoolsversion0.3}}]{crtrefname}{\marg{label name}}
559
560 This extracts the name of the sectioning unit or counter as being specified with \cs{nameref}.
561 \end{docCommand}
562
563 \begin{docCommand}[code={\CHDocExpCommand{}},
564 doc new={\chdocextractversion{crossreftoolsversion0.3}}]{crtrefanchor}{\marg{label name}}
565
566 This extracts the hyper target anchor of the reference in order to be used with \cs{hyperlink}.
567 \end{docCommand}
568
569 \begin{docCommand}[code={\CHDocExpCommand{}},
570 doc new={\chdocextractversion{crossreftoolsversion0.3}}]{crtrefunused}{\marg{label name}}
571
572 This extracts the yet unused 5th argument of labels generated after \CHDocPackage{hyperref} is loaded. As of version \hyperrefversionwithfifthargument\ of \CHDocPackage{hyperref}, this argument has no meaning yet. If this is going to be change in future, \refCom{crtrefunused} will probably be removed and replaced by another macro that reflects the meaning of this 5th argument.
573 \end{docCommand}
574
575 \begin{docCommand}[code={\CHDocExpCommand{}},
576 doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtrefcounter}{\marg{label name}}
577
578 This macro tries to extract the counter name related to the label assuming that the standard anchor type is used: \texttt{X.Y} where \texttt{X} stands for the counter name and \texttt{Y} is some alphanumerical value constructed from \cs{theHX}, e.g. \cs{theHchapter}. If this pattern fails, \refCom{crtrefcounter} will not compile.
579
580 \end{docCommand}
581
582
583 \section{Extracting information from cleveref}
584
585 The \CHDocPackage{cleveref} package redefines the \cs{label} macro and stores another label with the same basic name and a suffix \string @cref, so
586
587 \tcbinputlisting{breakable,listing only,listing file=labelstuff.tex}
588
589 %\begin{tcblisting}{listing only}
590 %\section{Stuff}
591 %\end{tcblisting}
592
593 would generate both the labels \verb!foo! and \verb!foo@cref!. The \CHDocPackage{cleveref} - version of a label saves basically five properties to the \CHDocFileExt{.aux} - file.
594
595
596 \begin{itemize}
597 \item \texttt{counter}
598
599 This property holds the name of the counter that was used in \cs{refstepcounter}.
600
601
602 \item \texttt{number}
603
604 This property holds the value of label, this is usually the value of a counter
605 \begin{marker}
606 Please note that this property does not mean the reference value that is displayed with \cs{cref} or \cs{Cref}.
607 \end{marker}
608 \item \texttt{result}
609
610 \item \texttt{reference}
611 This property holds the reference that is to be typeset, i.e. the content displayed with \cs{cref} or \cs{Cref}, however, without hyperlinks.
612
613 \item \texttt{page}
614 This property stores the page number of the \cs{label} usage.
615
616 \end{itemize}
617 \CHDocPackage{\PackageDocName} extracts those properties with \refCom{crtextractcref}.
618
619 \begin{docCommand}[code={\CHDocExpCommand{}},
620 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtextractcref}{\marg{property}\marg{label name}}
621
622 This command will extract one of the properties \texttt{counter}, \texttt{number}, \texttt{result}, \texttt{reference} and \texttt{page} from the label given as the 2nd mandatory argument.
623 \end{docCommand}
624
625 For convenience, there are shortcuts to extract a specific property:
626
627 \begin{docCommand}[code={\CHDocExpCommand{}},
628 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtcrefcounter}{\marg{label name}}
629
630 This extracts the counter belonging to a certain label name.
631 \end{docCommand}
632
633
634 \begin{docCommand}[code={\CHDocExpCommand{}},
635 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtcrefnumber}{\marg{label name}}
636
637 This extracts the counter value (or something that is stored by \cs{cref@currentlabel} belonging to a certain label name.
638 \end{docCommand}
639
640 \begin{docCommand}[code={\CHDocExpCommand{}},
641 doc new={\chdocextractversion{crossreftoolsversion0.8}}]{crtcrefcountervalue}{\marg{label name}}
642
643 This extracts the counter value (or something that is stored by \cs{cref@currentlabel} belonging to a certain label name and can be used in any context that requrires integer values.
644
645 If the label does not exist, the content of \cs{crt@crefundefinedcountervalue} is returned, which is by default a number, see \refCom{crtcrefundefinedcountervalue} in order how to set the return value.
646 \end{docCommand}
647
648
649 \begin{docCommand}[code={\CHDocExpCommand{}},
650 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtcrefresult}{\marg{label name}}
651
652 This extracts the result of the splitting of a counter belonging to a certain label name.
653 \end{docCommand}
654
655 \begin{docCommand}[code={\CHDocExpCommand{}},
656 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtcrefreference}{\marg{label name}}
657
658 This extracts the reference that would be printed by \cs{cref} or \cs{Cref}, without hyperlinks.
659 \end{docCommand}
660
661 \begin{docCommand}[code={\CHDocExpCommand{}},
662 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtcrefname}{\marg{counter name}}
663
664 This extracts the lower case cross reference name of a given counter.
665 \end{docCommand}
666
667 \begin{docCommand}[code={\CHDocExpCommand{}},
668 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtCrefname}{\marg{counter name}}
669
670 This extracts the upper case cross reference name of a given counter.
671 \end{docCommand}
672
673 \begin{docCommand}[code={\CHDocExpCommand{}},
674 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtcrefpluralname}{\marg{counter name}}
675
676 This extracts the lower case cross reference plural name of a given counter.
677 \end{docCommand}
678
679
680 \begin{docCommand}[code={\CHDocExpCommand{}},
681 doc new={\chdocextractversion{crossreftoolsversion0.1}}]{crtCrefpluralname}{\marg{counter name}}
682
683 This extracts the upper case cross reference plural name of a given counter.
684 \end{docCommand}
685
686 \begin{docCommand}[code={\CHDocExpCommand{}},
687 doc new and updated={\chdocextractversion{crossreftoolsversion0.1}}{\chdocextractversion{crossreftoolsversion0.2}}]
688 {crtcrefnamebylabel}{\marg{label name}}
689
690 This extracts the lower case cross reference name of a given label.
691 \end{docCommand}
692
693 \begin{docCommand}[code={\CHDocExpCommand{}},
694 doc new and updated={\chdocextractversion{crossreftoolsversion0.1}}{\chdocextractversion{crossreftoolsversion0.2}}]
695 {crtCrefnamebylabel}{\marg{label name}}
696
697 This extracts the upper case cross reference name of a given label.
698 \end{docCommand}
699
700 \begin{docCommand}[code={\CHDocExpCommand{}},
701 doc new=\chdocextractversion{crossreftoolsversion0.3}]
702 {crtcref}{\marg{label name}}
703
704 This displays the reference in the same way as \cs{cref} from \CHDocPackage{cleveref} would do in a setup without using \cs{crefformat} etc. The hyperlink is not displayed, however. This command is expandable.
705
706 For the upper case version see \refCom{crtCref}.
707 \end{docCommand}
708
709 \begin{docCommand}[code={\CHDocExpCommand{}},
710 doc new=\chdocextractversion{crossreftoolsversion0.3}]
711 {crtCref}{\marg{label name}}
712
713 This displays the reference in the same way as \cs{Cref} from \CHDocPackage{cleveref} would do in a setup without using \cs{Crefformat} etc. The hyperlink is not displayed, however. This command is expandable.
714
715 For the lower case version see \refCom{crtcref}.
716 \end{docCommand}
717
718 \subsection{Nonexpandable Commands}
719
720
721 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.3}]
722 {crthyperlink}{\marg{anchor}\marg{link text}}
723
724 This is a wrapper to the \cs{hyperlink} macro from \CHDocPackage{hyperref} to the given \marg{anchor}, displaying the \marg{link text}. If \CHDocPackage{hyperref} is not loaded, only the link text is displayed.
725 \end{docCommand}
726
727 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.3}]
728 {crthypercref}{\marg{label name}}
729
730 This generates a linked reference to a given label like \cs{cref} would do. If \CHDocPackage{hyperref} is not loaded, no link but only the reference text is displayed.
731
732 For the upper case version see \refCom{crthyperCref}.
733 \end{docCommand}
734
735 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.3}]
736 {crthyperCref}{\marg{label name}}
737
738 This generates a linked reference to a given label like \cs{Cref} would do. If \CHDocPackage{hyperref} is not loaded, no link but only the reference text is displayed.
739
740 For the lower case version see \refCom{crthypercref}.
741 \end{docCommand}
742
743 \section{Lower and upper case references}
744
745 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.6}]
746 {crtlnameref}{\marg{label name}}
747
748 This generates a linked reference to the name like \cs{nameref} would do, but the first character is used in lower case mode. % given label like \cs{Cref} would do.
749 If \CHDocPackage{hyperref} is not loaded, no link but only the reference text is displayed.
750 For the upper case version see \refCom{crtunameref}.
751 \end{docCommand}
752
753 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.6}]
754 {crtlnameref*}{\marg{label name}}
755
756 This generates a reference like \cs{nameref*} would do, but the first character is used in lower case mode -- no links are generated.
757 For the upper case version see \refCom{crtlnameref*}.
758 \end{docCommand}
759
760
761 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.6}]
762 {crtunameref}{\marg{label name}}
763
764 This generates a linked reference to the name like \cs{nameref} would do, but the first character is used in upper case mode. % given label like \cs{Cref} would do.
765 If \CHDocPackage{hyperref} is not loaded, no link but only the reference text is displayed.
766 For the lower case version see \refCom{crtlnameref}.
767 \end{docCommand}
768
769 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.6}]
770 {crtunameref*}{\marg{label name}}
771
772 This generates a reference like \cs{nameref*} would do, but the first character is used in upper case mode -- no links are generated.
773 For the lower case version see \refCom{crtlnameref*}.
774 \end{docCommand}
775
776
777 \section{Convenience macros}
778
779 In case \CHDocPackage{hyperref} shouldn't be loaded, \CHDocPackage{crossreftools} provides some convenience wrapper macros
780
781 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.6}]
782 {crtnameref}{\marg{label name}}
783
784 This generates a reference like \cs{nameref*} would do.
785 If \CHDocPackage{hyperref} is not loaded but \CHDocPackage{nameref} is used, no link is generated, so \refCom{crtnameref} acts like \refCom{crtnameref*}
786 For the unlinked version see \refCom{crtnameref*}.
787 \end{docCommand}
788
789 \begin{docCommand}[doc new=\chdocextractversion{crossreftoolsversion0.6}]
790 {crtnameref*}{\marg{label name}}
791
792 This generates a reference like \cs{nameref*} would do and does not generate a link. If neither \CHDocPackage{nameref} nor \CHDocPackage{hyperref} is used no output is generated from this macro.
793 For the linked version see \refCom{crtnameref}.
794 \end{docCommand}
795
796
797 \section{Placing more generic labels}\label{section::placing-generic-labels}
798
799 Sometimes it is necessary to refer to content that is not connected to a counter and \cs{refstepcounter}. In this case the macros \refCom{crtprovidecurrentlabel}, \refCom{crtprovidecurrentlabelname},
800
801 \refCom{crtprovidecurrentlabelinfo} and \refCom{crtcrossreflabel} may be useful.
802
803 \begin{marker}
804 None of the macros placing 'arbitrary' labels described in this section is expandable!
805 \end{marker}
806
807 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtprovidecurrentlabel}{\marg{usual label content}}
808 This sets \cs{@currentlabel} which is later on stored to be the label content with \cs{label} and being displayed with the various variants of \cs{ref} or \cs{cref} etc. from \CHDocPackage{cleveref}.
809 \end{docCommand}
810
811 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtprovidecurrentlabelname}{\marg{nameref label content}}
812 This sets \cs{@currentlabelname} which is later on stored to be the label content with \cs{label} and being displayed with the various variants of \cs{nameref} from \CHDocPackage{hyperref}.
813 \end{docCommand}
814
815 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtprovidecurrentlabelinfo}{\marg{usual label content}\marg{nameref label content}}
816 This is a convenience macro in order to provide both \cs{@currentlabel} and \cs{@currentlabelname} at once. If \CHDocPackage{hyperref} is loaded, a \cs{phantomsection} call is used before calling
817
818 \refCom{crtprovidecurrentlabel} and \refCom{crtprovidecurrentlabelname}.
819 \end{docCommand}
820
821 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtcrossreflabel}{\oarg{nameref label content}\marg{usual label content}\oarg{label name}}
822
823 This macro is an even more convenient wrapper for \refCom{crtprovidecurrentlabelinfo} by using the 2nd (mandatory) argument both for the usual label and the nameref label content if the 1st optional argument is not specified. This resembles the \cs{caption[]\textbraceleft\textbraceright} or e.g. \cs{section[]\textbraceleft\textbraceright} mechanism where the first optional argument is used for the ToC - related entries.
824
825 The 2nd optional argument is placing the \cs{label} with the relevant label name.
826
827 \begin{marker}
828 Please note that depending on the presence of the 1st optional argument either the 2nd or der 1st argument is displayed in the input stream, i.e. in the document text. If this is not requested, use the starred form \refCom{crtcrossreflabel*}.
829 \end{marker}
830
831
832 \end{docCommand}
833
834 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtcrossreflabel*}{\oarg{nameref label content}\marg{usual label content}\oarg{label name}}
835
836 This behaves like \refCom{crtcrossreflabel} but suppresses the output of the 2nd or 1st argument explicitly. Use this to place hidden labels and anchors.
837 \end{docCommand}
838
839
840 \clearpage
841 \section{Checking for label existence}\label{sec:checkinglabelexistence}
842
843 Sometimes it is necessary to check whether some label exists in order to refer to it. The macros
844
845 \begin{itemize}
846 \item \refCom{crtifdefinedlabel}
847 \item \refCom{crtcrefifdefinedlabel}
848 \end{itemize}
849
850 check for the label existence and execute the relevant true or false conditions for labels defined the usual \cs{label} macro and for their \CHDocPackage{cleveref} version.
851
852 Those macros have related commands that revert the test, i.e. they check for the non-existence of a label:
853
854 \begin{itemize}
855 \item \refCom{crtifundefinedlabel}
856 \item \refCom{crtcrefifundefinedlabel}
857 \end{itemize}
858
859
860 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.5}}]{crtifdefinedlabel}{\marg{label name}\marg{true branch}\marg{false branch}}
861 This checks whether the label 'label name' is defined and executes the true branch, otherwise the false branch.
862 \end{docCommand}
863
864
865 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.5}}]{crtifundefinedlabel}{\marg{label name}\marg{true branch}\marg{false branch}}
866 This checks whether the label 'label name' is undefined and executes the true branch, otherwise the false branch.
867 \end{docCommand}
868
869 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.5}}]{crtcrefifdefinedlabel}{\marg{label name}\marg{true branch}\marg{false branch}}
870 This checks whether the label 'label name' is defined by \CHDocPackage{cleveref} and executes the true branch, otherwise the false branch.
871 \end{docCommand}
872
873
874 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.5}}]{crtcrefifundefinedlabel}{\marg{label name}\marg{true branch}\marg{false branch}}
875 This checks whether the label 'label name' is undefined by \CHDocPackage{cleveref} and executes the true branch, otherwise the false branch.
876 \end{docCommand}
877
878
879
880 \section{Displaying label information}\label{section::listoflabels}
881
882 For some reason it might be useful to have a list of all defined labels available. Currently, the support from \CHDocPackage{crossreftools} for this limited, however.
883
884 \begin{marker}
885 \CHDocPackage{crossreftools} redefines \cs{label} at the beginning of the document body. It takes care about a potential optional argument of \cs{label} as is introduced by \CHDocPackage{cleveref}.
886 \end{marker}
887
888
889 \subsection{Useful macros for the list of labels}
890
891
892
893
894 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtlistoflabels}{}
895 This displays a list of all cross-reference labels in the order of their definition, the heading has the title \texttt{\listoflabelsname}, in order to change the title redefine \refCom{listoflabelsname}.
896
897 An ordinary entry to the list - of - labels file (default extension \CHDocFileExt{lla}) is written with \cs{addcontentsline}
898
899 \tcbinputlisting{breakable,listing only,listing file=addcontentslineforlistoflabels.tex}
900
901 where \refCom{crt@listoflabelsfileextension} and \refCom{crt@listoflabelsstructurelevel} are internal versions of \refCom{crtlistoflabelsfileextension} and
902
903 \refCom{crtlistoflabelsstructurelevel}.
904
905 This command does add an entry into the table of contents (\CHDocFileExt{toc} - file) either on chapter or on section level, depending whether the class is \CHDocClass{book} or not.
906
907 If no ToC - entry should be made, use \refCom{crtlistoflabels*}.
908
909 \begin{marker}
910 If the package (or class) option \texttt{final} is enabled, the \CHDocTag{List of Labels} feature is disabled and \refCom{crtlistoflabels} expands to nothing.
911 \end{marker}
912
913
914 \end{docCommand}
915
916
917 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtlistoflabels*}{}
918 This behaves like \refCom{crtlistoflabels} but does not generate an entry in the table of contents.
919
920 \end{docCommand}
921
922
923
924 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtlistoflabelsfileextension}{\marg{extension}}
925
926 This changes the extention of the list of labels file. The value is stored internally in
927
928 \refCom{crt@listoflabelsfileextension} which defaults to \texttt{lla}
929
930 \end{docCommand}
931
932 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crt@listoflabelsfileextension}{}
933
934 This holds the extension (without a dot in the name) of the list of labels file. Do not change this macro directly, but use \refCom{crtlistoflabelsfileextension} instead.
935
936 \end{docCommand}
937
938
939 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{listoflabelsname}{}
940 This is the title of the list of labels heading, it defaults to \texttt{\listoflabelsname}.
941
942 It can be changed with \cs{renewcommand}.
943
944 \end{docCommand}
945
946
947
948
949 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtlistoflabelsstructurelevel}{\marg{counter name}}
950
951 This changes the level of the label entries in the list of labels. The value is stored internally in \cs{crt@listoflabelsstructurelevel} which defaults to \texttt{section}
952
953 \begin{marker}
954 This is a preamble - only macro.
955 \end{marker}
956 \end{docCommand}
957
958 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crt@listoflabelsstructurelevel}{}
959
960 This holds the structure level of the list of labels entries. Do not change this macro directly, but use \refCom{crtlistoflabelsstructurelevel} instead.
961
962 \end{docCommand}
963
964
965 \subsection{Useful macros for the label command}
966
967 \CHDocPackage{crossreftools} provides two hook macros to be usable inside of the \cs{label} command
968
969 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtprelabelhook}{\marg{argument}}
970 This hook is executed before the internally stored \cs{label} is called, the argument can be 'anything'.
971
972 By default, this macro expands to nothing, but can be redefined with \cs{renewcommand}.
973
974 \end{docCommand}
975
976 \begin{docCommand}[doc new={\chdocextractversion{crossreftoolsversion0.4}}]{crtpostlabelhook}{\marg{argument}}
977 This hook is executed after the internally stored \cs{label} is called, the argument can be 'anything'.
978
979 By default, this macro expands to nothing, but can be redefined with \cs{renewcommand}.
980
981 \end{docCommand}
982
983
984 \clearpage
985 \part{Examples}
986
987 \parttoc
988
989 \section{Driver example}
990
991 \tcbinputlisting{breakable,listing only,listing file=crossreftools_driver.tex}
992
993
994
995
996 \clearpage
997 \part{Meta information}
998
999 \section{Acknowledgements} \label{section::acknowledgements}
1000
1001 I would like to thank Javier Bezos to pointing me out to an issue with \refCom{crtcrefnumber} when being used as counter value extracting and inserting it again into \cs{setcounter} or any other occurence where a number value is expected.
1002
1003 This issue is regarded fixed with \refCom{crtcrefcountervalue}.
1004
1005
1006 \section{Version history}
1007
1008
1009 \begin{itemize}[itemsep=15pt]
1010
1011 \item \CHDocFullVersion{0.9}
1012
1013 Fixed bug in \cs{crtaddlabeltotoc} macro -- it clashed in expansion contexts.
1014
1015
1016 Thanks to user \texttt{muzimuzhi-z} from \url{https://tex.stackexchange.com} who provided the bug fix in his answer to
1017 \url{https://tex.stackexchange.com/questions/554100/crossreftools-docliccense-gives-error-with-restatement-of-restatable-theorem}
1018
1019 \item \CHDocFullVersion{0.9}
1020
1021 Fixed bug in \refCom{crtCref} macro -- it didn't show the reference number.
1022
1023
1024
1025 \item \CHDocFullVersion{0.8}
1026
1027 Added \refCom{crtcrefcountervalue}, see \cref{section::acknowledgements} for some explanation.
1028
1029 \item \CHDocFullVersion{0.7}
1030
1031 Corrected two typos in \refCom{crtcref} and \refCom{crtCref}, leading to wrong reports of reference numbers.
1032
1033 \item \CHDocFullVersion{0.6}
1034 \begin{itemize}
1035 \item Corrected the typo in this manual about \refCom{crtifdefinedlabel} and \refCom{crtifundefinedlabel}
1036 \item Added the macros \refCom{crtlnameref} and \refCom{crtunameref} for providing a lower and upper case version of the first character in a \cs{nameref} - like usage.
1037 \item Provided the convenience wrappers \refCom{crtnameref} and \refCom{crtnameref*} in order to make code compilable if \CHDocPackage{hyperref} is not loaded.
1038 \end{itemize}
1039
1040 \item \CHDocFullVersion{0.5}
1041 \begin{itemize}
1042 \item Added the \texttt{cleverefcompat} option.
1043 \item Changed the internal code of \refCom{crtcrefpage} which was necessary after the update of \CHDocPackage{cleveref} to version 0.21
1044 \item Added some macros that check for label existence, see \cref{sec:checkinglabelexistence} about this.
1045 \end{itemize}
1046
1047 \item \CHDocFullVersion{0.4}
1048 \begin{itemize}
1049 \item Corrected typos in this documentation
1050 \item Added the \CHDocTag{List of Labels} feature and the relevant macros from \cref{section::listoflabels}.
1051 \item Added the \texttt{final} and \texttt{draft} package options.
1052 \item Introduced more generic label content macros.
1053 \end{itemize}
1054 \item \CHDocFullVersion{0.3}
1055
1056 Added the extraction macros for regular labels (i.e. not the \CHDocPackage{cleveref} - related ones) and convenience wrappers for generating links.
1057 \item \CHDocFullVersion{0.2}
1058
1059 Introduced a check in \refCom{crtcrefnamebylabel} and \refCom{crtCrefnamebylabel} whether given label exists
1060 \item \CHDocFullVersion{0.1}
1061
1062 First version
1063 \end{itemize}
1064
1065
1066 \printindex
1067
1068 \end{document}
1069