Debian Codegraph @

texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex

raw
1 %% LaTeX package xassoccnt - version 2.0 (2021/11/21 -- 12:14:58)
2 %% Documentation file for xassoccnt.sty
3 %%
4 %%
5 %% -------------------------------------------------------------------------------------------
6 %% Copyright (c) 2015 -- 2021 by Dr. Christian Hupfer <>
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 `unmaintained`
19 %%
20 %%
21
22 \documentclass[12pt,a4paper,oneside]{article}
23
24
25
26
27 \usepackage[lmargin=2cm,rmargin=2cm,headheight=15pt]{geometry}
28 \usepackage{savesym}
29 \usepackage{bbding}
30 \savesymbol{Cross}
31
32 \usepackage{graphicx}
33 \usepackage{blindtext}
34 \usepackage[x11names]{xcolor}
35 \usepackage{imakeidx}
36 \usepackage{fontawesome}
37 \usepackage[tikz]{bclogo}
38 \usepackage{marginnote}
39 \usepackage{fancyhdr}
40 \usepackage{datetime}
41 \usepackage{array}
42 \usepackage{xkeyval}
43 \usepackage{xparse}
44 \usepackage{totcount}
45 \usepackage{enumitem}
46 \usepackage{caption}
47 \usepackage{microtype}
48 \usepackage[T1]{fontenc}
49 \usepackage[scaled=0.92]{helvet}
50
51 \usepackage[most,documentation]{tcolorbox}
52
53
54 \newlist{codeoptionsenum}{enumerate}{1}
55 \setlist[codeoptionsenum,1]{label={\textcolor{blue}{\#\arabic*}}}
56
57 \renewcommand{\rmdefault}{\sfdefault}
58
59 \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
60
61 \makeatletter
62 \define@key{chdoc}{packageauthor}{%
63 \def\KVchdocpackageauthor{#1}%
64 }
65
66 \define@key{chdoc}{packageauthormail}{%
67 \def\KVchdocpackageauthormail{#1}%
68 }
69
70 \define@key{chdoc}{filepurpose}{%
71 \def\KVchdocfilepurpose{#1}%
72 }
73
74
75 \newcommand{\chdocextractversion}[1]{%
76 \@nameuse{#1}%
77 }
78
79
80 \@namedef{xassoccntversion0.1}{v0.1 2016-11-07}
81
82 \@namedef{xassoccntversion0.2}{v0.2 2016-11-14}
83
84 \@namedef{xassoccntversion0.3}{v0.3 2016-01-08}
85
86 \@namedef{xassoccntversion0.4}{v0.4 2016-01-26}
87
88 \@namedef{xassoccntversion0.5}{v0.5 2016-02-27}
89
90 \@namedef{xassoccntversion0.6}{v0.6 2016-03-05}
91
92 \@namedef{xassoccntversion0.7}{v0.7 2016-05-10}
93
94 \@namedef{xassoccntversion0.8}{v0.8 2016-06-10}
95
96 \@namedef{xassoccntversion0.9}{v0.9 2016-06-19}
97
98 \@namedef{xassoccntversion1.0}{v1.0 2016-07-28}
99
100 \@namedef{xassoccntversion1.1}{v1.1 2016-10-29}
101
102 \@namedef{xassoccntversion1.2}{v1.2 2017-03-03}
103
104 \@namedef{xassoccntversion1.3}{v1.3 2017-03-04}
105
106 \@namedef{xassoccntversion1.4}{v1.4 2017-04-30}
107
108 \@namedef{xassoccntversion1.5}{v1.5 2017-04-30}
109
110 \@namedef{xassoccntversion1.4}{v1.4 2017-05-10}
111
112 \@namedef{xassoccntversion1.5}{v1.5 2017-07-28}
113
114 \@namedef{xassoccntversion1.6}{v1.6 2018-01-03}
115
116 \@namedef{xassoccntversion1.6a}{v1.6a 2018-06-10}
117
118 \@namedef{xassoccntversion1.7}{v1.7 2018-12-28}
119
120 \@namedef{xassoccntversion1.8}{v1.8 2019-01-01}
121
122 \@namedef{xassoccntversion2.0}{v2.0 2021-11-21}
123
124 \newcommand{\authorname}{Autor}
125
126
127 \makeatother
128
129
130
131
132
133
134 \fancypagestyle{plain}{%
135 \fancyfoot[L]{\begin{tabular}[t]{l}\PackageDocName\ \packageversion \tabularnewline \textcopyright\ Dr. Christian Hupfer\end{tabular}}%
136 \fancyfoot[C]{\thepage}%
137 \fancyfoot[R]{\today}%
138 \renewcommand{\headrule}{{\color{blue}%
139 \hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
140 \renewcommand{\footrule}{{\color{blue}\vskip-\footruleskip\vskip-\footrulewidth
141 \hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
142 \renewcommand{\footrulewidth}{2pt}
143 \renewcommand{\headrulewidth}{2pt}
144 }
145
146
147
148 \newtcolorbox{CHPackageTitleBox}[1][]{%
149 enhanced jigsaw,
150 drop lifted shadow,
151 colback=yellow!30!white,
152 width=0.8\textwidth,
153 #1
154 }
155
156 \presetkeys{chdoc}{packageauthor={Christian Hupfer}}{}%
157 \NewDocumentCommand{\CHPackageTitlePage}{O{}mO{}}{%
158 \setkeys{chdoc}{packageauthor={Christian Hupfer},filepurpose={Documentation},#1}%
159 \begin{center}
160 \begin{CHPackageTitleBox}[#3]
161 \large \bfseries%
162 \begin{center}%
163 \begin{tabular}{C{0.9\textwidth}}%
164 \scshape \PackageDocName \tabularnewline
165 \tabularnewline
166 #2 \tabularnewline
167 \tabularnewline
168 \KVchdocfilepurpose \tabularnewline
169 \tabularnewline
170 Version \packageversion \tabularnewline
171 \tabularnewline
172 \today \tabularnewline
173 \tabularnewline
174 \addtocounter{footnote}{2}
175 Previous \authorname: \KVchdocpackageauthor\(^\mathrm{\fnsymbol{footnote}}\)
176 \tabularnewline
177 \end{tabular}
178 \end{center}
179 \end{CHPackageTitleBox}
180 \renewcommand{\thefootnote}{\fnsymbol{footnote}}%
181 \footnotetext{unavailable}%
182 \end{center}
183 }
184
185 \newtcolorbox{docCommandArgs}[1]{colbacktitle={blue},coltitle={white},title={Description of arguments of command \cs{#1}}}
186
187
188 \newcommand{\tcolorboxdoclink}{http://mirrors.ctan.org/macros/latex/contrib/tcolorbox/tcolorbox.pdf}
189
190 % 'Stolen' from tcolorbox documentation ;-)
191
192 \newtcolorbox{marker}[1][]{enhanced,
193 before skip=2mm,after skip=3mm,
194 boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
195 colback=yellow!50,
196 colframe=yellow!20!black,
197 sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
198 underlay={%
199 \path[fill=tcbcolback!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
200 \path[draw=tcbcolframe,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
201 \path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west);
202 },
203 drop fuzzy shadow,#1}
204
205
206 %%%% Documentation macros
207
208
209 \NewDocumentCommand{\packagename}{sm}{%
210 \textcolor{blue}{\textbf{\faEnvelopeO~#2}}%
211 \IfBooleanF{#1}{%
212 \index{Package!#2}
213 }%
214 }
215
216 \NewDocumentCommand{\classname}{sm}{%
217 \textcolor{brown}{\textbf{\faBriefcase~#2}}%
218 \IfBooleanF{#1}{%
219 \index{Package!#2}%
220 }%
221 }
222
223
224 \NewDocumentCommand{\CHDocPackage}{sm}{%
225 \textcolor{blue}{\textbf{\faEnvelopeO~#2}}%
226 \IfBooleanF{#1}{%
227 \index{Package!#2}
228 }%
229 }
230
231
232
233
234 \NewDocumentCommand{\CHDocClass}{sm}{%
235 \textcolor{brown}{\textbf{\faBriefcase~#2}}%
236 \IfBooleanF{#1}{%
237 \index{Package!#2}%
238 }%
239 }
240
241 \NewDocumentCommand{\CHDocKey}{sm}{%
242 \textcolor{red}{\textbf{\faKey~#2}}%
243 \IfBooleanF{#1}{%
244 \index{Option!#2}%
245 }%
246 }
247
248 \newcommand{\handrightnote}{\tcbdocmarginnote{\ding{43}}}
249
250
251 \NewDocumentCommand{\CHDocCounter}{sm}{%
252 \textcolor{Green4}{\textbf{\faCalculator~#2}}%
253 \IfBooleanF{#1}{%
254 \index{Counter!#2}%
255 }%
256 }
257
258
259 \NewDocumentCommand{\CHDocTag}{sm}{%
260 \textcolor{violet}{\faTag~#2}%
261 \IfBooleanF{#1}{%
262 \index{Feature!#2}%
263 }%
264 }
265
266
267 \NewDocumentCommand{\CHDocFileExt}{sm}{%
268 \faFile~#2%
269 }
270
271 \NewDocumentCommand{\CHDocFiles}{sm}{%
272 \faFilesO~#2%
273 }
274
275
276 \NewDocumentCommand{\CHDocConventions}{}{%
277 \section*{\centering Typographical conventions}
278 Throughout this documentation following symbols and conventions are used:
279 \begin{itemize}
280 \item \CHDocClass*{foo} means a the class \texttt{foo}
281 \item \CHDocPackage*{foo} names a package \texttt{foo}
282 \item \CHDocCounter*{foo} indicates a counter named \texttt{foo}
283 \item \CHDocFileExt*{foo} will indicate either a file named \texttt{foo} or a file extension \texttt{foo}
284 \item \CHDocFiles*{foo} will indicate some files
285 \item \CHDocTag*{foo} names a special feature or tag \texttt{foo}
286 \item \CHDocKey*{foo} deals with a command or package option named \texttt{foo}
287 \end{itemize}
288 }
289
290
291
292 \renewcommand{\tcbdocnew}[1]{#1}%
293 \renewcommand{\tcbdocupdated}[1]{#1}%
294
295 \newcommand{\CHDocNew}[1]{%
296 \tcbdocmarginnote[doclang/new={N},
297 colframe=blue,
298 halign=left,
299 colback={blue!20!white},
300 fontupper={\tiny}
301 ]{%
302 \chdocextractversion{xassoccntversion#1}%
303 }%
304 }
305
306
307
308 \newcommand{\CHDocUpdate}[1]{\tcbdocmarginnote[doclang/updated={},colback={yellow},colframe={yellow!50!red}, fontupper={\tiny}
309 ]{%
310 \tcbdocupdated{\chdocextractversion{xassoccntversion#1}}%
311 }%
312 }
313
314
315
316 \newcommand{\CHDocFullVersion}[1]{Version \chdocextractversion{xassoccntversion#1}}
317
318
319 \newcommand{\CHDocExpCommand}[1][Expandable]{%
320 \tcbdocmarginnote[doclang/new={N},
321 colframe=green!50!blue,
322 halign=left,
323 colback={green!90!blue},
324 fontupper={\tiny}
325 ]{%
326 #1%
327 }%
328 }
329
330
331 \newcommand{\CHDocExperimentalFeature}[1][Experimental]{%
332 \tcbdocmarginnote[doclang/new={N},
333 colframe=yellow!50!blue,
334 halign=left,
335 colback={blue!10!yellow},
336 fontupper={\tiny}
337 ]{%
338 #1%
339 }%
340 }
341
342
343 \usepackage[T1]{fontenc}
344 \usepackage{graphicx}%
345 \usepackage[autodefinecounters=true]{xassoccnt}
346 \usepackage{amsmath}
347 \usepackage{amssymb}
348 \usepackage{minitoc}
349 \usepackage{tocbibind}
350 \usepackage{bookmark}
351 \usepackage{cleveref}
352 \usetikzlibrary{mindmap}
353
354 \setcounter{tocdepth}{3}
355 \newcommand{\PackageDocName}{xassoccnt}%
356
357
358 \newcommand{\mymailtoaddress}{%
359 %
360 }
361
362 \doparttoc
363
364 \let\DeclareAssociatedCountersOrig\DeclareAssociatedCounters % -> for use in examples only
365
366 \def\packageversion{\xassoccntpackageversion}%
367
368 \makeindex[intoc]
369
370
371 \renewcommand{\rmdefault}{\sfdefault}
372
373
374 \newcounter{foobar}
375 \newtotcounter{newtotalpages}%
376 \newtotcounter{anothertotalpages}%
377
378 \newtotcounter{totalproofs}%
379 \newtotcounter{totalsections}%
380 \newtotcounter{totalequations}
381
382 \newtotcounter{totalsubsections}%
383 \newtotcounter{othertotalsubsections}%
384
385 \DeclareDocumentCounter{foocntr}%
386 \DeclareDocumentCounter{foobarcntr}%
387
388
389 %%%% Declare all the counters here --
390 \DeclareAssociatedCounters{subsection}{totalsubsections}%
391 \DeclareAssociatedCounters{equation}{totalequations}%
392 \DeclareAssociatedCounters{section}{totalsections}%
393 \DeclareAssociatedCounters{proof}{totalproofs}
394 \DeclareAssociatedCounters{page}{totalpages,anothertotalpages}%
395
396 \DeclareTotalDocumentCounter{foototal}%
397
398 \RegisterTotalDocumentCounter{section}%
399
400 \hypersetup{breaklinks=true,
401 pdftitle={\jobname.pdf -- version \packageversion},
402 pdfauthor={Dr. Christian Hupfer},
403 pdfsubject={Documentation of \PackageDocName\ package},
404 pdfkeywords={LaTeX, counters},
405 bookmarksopen=true,
406 bookmarksopenlevel=2,
407 bookmarksnumbered=true,
408 pdfcreator={LaTeX}
409 }
410
411
412
413 \begin{document}
414 \yyyymmdddate
415
416
417 \setlength{\parindent}{0em}
418
419 \pagestyle{empty}%
420
421 \begin{tikzpicture}[mindmap,concept color=red,black,scale=1]
422 \bfseries
423 \node [concept] {Counters}
424 child[concept color=red!30!yellow,grow=30] { node [concept] {Associated counters}}
425 % child[grow=85,white,concept color=red!80!blue] { node [concept] {Backup \& Restore of counters}}
426 child[grow=300,concept color=yellow!90!red] { node [concept] {Extensions to \LaTeXe} child[grow=230,concept color={yellow!20!green}] {node [concept] {Query macros}}
427 child[grow=290,concept color={yellow!30!cyan}] {node [concept] {Document counters}}
428 }
429 child[grow=-20,white] { node [concept] {Periodically resetting counters}}
430 child[grow=130,concept color=red!20!green] { node [concept] {Suspension \\ \& Resuming of counters} child[grow=160,concept color=green!10!yellow] {node[concept] {Cascaded suspension}}}
431 child[grow=170,concept color=red!30!yellow] { node [concept] {Total} child[concept color=yellow!30!,grow=150] {node[concept] {Super total counters}}}
432 child[grow=260,concept color=red!30!green] { node [concept] {Loops on counters}}
433 child[grow=200,concept color=red!30!green] { node [concept] {Counter output}}
434 child[grow=230,concept color=red!20!cyan] { node [concept] {Coupled counters} child [grow=250,concept color=cyan!50!blue] {node[concept] {Coupled counter groups}}}
435 child[grow=57,concept color=red!20!yellow] { node [concept] {Label}};
436 \end{tikzpicture}
437
438 \CHPackageTitlePage[packageauthor={Christian Hupfer}]{Associated counters stepping simultaneously\\ (and other gadgets)}
439
440
441 \clearpage
442 \tableofcontents
443 \clearpage
444
445 \CHDocConventions
446 \clearpage
447
448
449 \pagestyle{plain}
450
451
452 \setcounter{footnote}{0}
453
454 \part{Introduction}
455
456 \parttoc
457
458 \section*{Preface}
459
460 This package is the successor and a complete rewrite of \CHDocPackage{assoccnt}. Not all features of that package are implemented yet -- if some functionality of your document depends on \CHDocPackage{assoccnt}, continue using the older version and shift gradually to \CHDocPackage{\PackageDocName} please.
461
462 \begin{marker}
463 Most times class and package authors will benefit of this package, but there might be usual documents that need the features of |\PackageDocName||
464 \end{marker}
465
466 \section{Introduction}
467
468 The aim of this package is to provide some additional support for example for a package like \CHDocPackage{totcount}.
469
470 For example, the total number of pages in a document could be achieved by using
471
472 \begin{dispExample}%
473 \regtotcounter{page}
474 ...
475 The number of pages in the document is \number\totvalue{page} page(s) -- but in fact it has \total{newtotalpages} pages.
476 \end{dispExample}%
477
478 This will work, as long there is no reset of the page counter, as it might happen in the case of \cs{setcounter} or \cs{pagenumbering} being applied in the document. The result is a false page counter total value.
479
480 This package provides associate counters, i.e. counters that are increased simultaneously with a driver counter and are not influenced by a a resetting of the driver counter, as long as not being added to the reset list by definition of the counter or explicitly by \cs{@addtoreset}.
481
482 This package defines some macros to handle associated counters. The only interception to the standard behaviour is within the redefined commands \cs{addtocounter} and \cs{stepcounter}. The usual commands still work, as there is code added to their definition. In a previous version \cs{refstepcounter} was redefined, but since these use \cs{addtocounter} effectively, it was decided to use the basic command.
483
484 Internally, the associated counters are stored in one list per counter -- it is not recommended to operate on those lists directly.
485
486 Please note that this package does not provide means for simultaneous stepping of counters defined by plain \TeX{} \cs{newcount} command.\marginnote{\bcbombe}
487
488
489
490
491 \section{Requirements, loading and incompatibilities}%
492
493
494
495 \subsection{Required packages and \TeX\ engine}
496
497 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.
498
499 \begin{itemize}
500 \item \CHDocPackage{xcolor}
501 \item \CHDocPackage{xparse}
502 \item \CHDocPackage{l3keys2e}
503 \end{itemize}
504
505 The documentation file requires some more packages such as \CHDocPackage{tcolorbox} but those packages are widely available on CTAN, MikTeX and TeXLive as well.
506
507 \subsection{Loading of the package}
508
509 Loading is done with
510
511 \begin{tcblisting}{listing only}
512 \usepackage[options]{xassoccnt}
513 \end{tcblisting}
514
515 For the relevant options see \cref{subsection:packageoptions}
516
517 Concerning the packages \CHDocPackage{hyperref} and \CHDocPackage{cleveref}: The preferred loading order is the usually recommended on:
518 \begin{itemize}
519 \item other packages
520 \item \CHDocPackage{xassoccnt}
521 \item \CHDocPackage{hyperref}
522 \item \CHDocPackage{cleveref}
523 \end{itemize}
524
525 For potential problems see \cref{subsection:incompatibilities}
526
527 \subsection{Incompatibilities}\label{subsection:incompatibilities}
528
529
530
531 \begin{itemize}
532 \item This package cannot be used with plain \TeX\ and will not provide support for counters (or better counter registers) that have defined with the \TeX\ primitive \cs{countdef} directly in a \LaTeXe\ document nor will it hook into plain \TeX\ \cs{advance} commands used otherwise than in the usual \LaTeXe\ wrappers \cs{addtocounter} etc.
533
534 \item This package does not work really well with the \CHDocPackage{calc} package if that one is loaded after \CHDocPackage{\PackageDocName}. Load \CHDocPackage{calc} \textbf{before} \CHDocPackage{\PackageDocName}!
535
536 Especially the \CHDocPackage{tcolorbox} bundle loads \CHDocPackage{calc} indirectly, so placing any loading of \CHDocPackage{tcolorbox} modules before \CHDocPackage{\PackageDocName} is mandatory!
537
538
539 \begin{marker}
540 \tcbdocmarginnote{\bcbombe\tcbdocupdated{2015-11-10}}
541 As of version \packageversion\ \CHDocPackage{\PackageDocName} will abort compilation if \CHDocPackage{calc} is loaded after this package, but will issue a warning only if \CHDocPackage{calc} is loaded first.
542 \end{marker}
543
544
545 \begin{marker}
546 \CHDocUpdate{0.7}
547 Of course any package other that loads \CHDocPackage{calc} must be loaded before \PackageDocName, i.e. \CHDocPackage{mathtools}.
548 \end{marker}
549
550 \item \CHDocPackage{\PackageDocName} and \CHDocPackage{perpage} are not compatible completely. As of version \packageversion\ it is not possible to use the command \cs{AddAbsoluteCounter} from \CHDocPackage{perpage} -- this feature is provided already by this package.
551 \tcbdocmarginnote{\tcbdocnew{2015-11-10}}
552
553 \begin{marker}
554 It is not recommended to use counters under control of \CHDocPackage{perpage} with the association method!
555 \end{marker}
556
557 % is somewhat similar to \refCom{AddAssociatedCounters} from this package but unless changed manually, the values of and \texttt{perpage} - absolute counter and an associated counter by this package differ by one, since \cs{AddAbsoluteCounter} initializes the counter value to the value of 1.
558 %\item This package does not work together when the Package \CHDocPackage{xifthen} is included. As of version \packageversion~I could not figure out, where the strange behaviour comes in. It's most likely an incompatibility between \CHDocPackage{etoolbox} and \CHDocPackage{xifthen}
559 %\marginnote{\bcbombe}
560 \end{itemize}
561
562 \subsection{Package options}\label{subsection:packageoptions}
563
564 As of version \packageversion\ \CHDocPackage{\PackageDocName} supports the package options
565
566 \begin{docKey}{autodefinecounters}{=\meta{true,false}}{initially false}
567 Setting this package option to \texttt{true}, all counters used with the special package macros will be autodefined, unless disabled locally. See the commands
568 \begin{itemize}
569 \item \refCom{DeclareAssociatedCounters}
570 \item \refCom{AddAssociatedCounters}
571 \end{itemize}
572 \end{docKey}
573
574 \begin{docKey}{nonumberofruns}{}{initially not set}\CHDocNew{0.6}
575 Using this package option the super total counter \CHDocCounter{numberofruns} counter will not be defined. See \cref{subsection:numberofruns} about this feature.
576 \end{docKey}
577
578 \begin{docKey}{redefinelabel}{=\meta{true,false}}{initially \meta{true}}\CHDocNew{1.2}
579 \CHDocExperimentalFeature This is an experimental feature as of version \packageversion.
580
581 Enables the redefinition of the \refCom{label} command and takes care of the optional argument of \refCom{label} if \CHDocPackage{cleveref} is used. This will provide \refCom{label} with a final optional argument that can be used to allow labels for associated counters (either all or only a specified list of counters), for more on this see \refCom{label} in \namecref{subsec::associated_counters_experimental} \nameref{subsec::associated_counters_experimental}.
582 \end{docKey}
583
584 \begin{docKey}{standardcounterformats}{=\meta{choice=on/off}}{initially \meta{on}}\CHDocNew{1.4}
585 This key enables (\meta{on}) or disables (\meta{off}) the definition of the standard counter formats to be used in the macro \refCom{CounterFormat}.
586 \end{docKey}
587 \clearpage
588 \part{Tools for counters}
589
590 \parttoc
591
592
593 \section[Additions to standard commands]{Additions and extensions to standard counter related commands}\label{section::additions_to_l2e}
594
595 \subsection{Extension of \LaTeXe\ commands}\label{subsection::extension_of_l2e_commands}
596
597 \begin{docCommand}[before={\CHDocNew{0.9}}]{addtocounter}{\marg{counter}\marg{increment value}\oarg{options}}
598 The \refCom{addtocounter} macro behaves like the usual \cs{addtocounter} counter, but takes care to specific counter features such as \CHDocTag{periodic counters} and has an optional argument in order to perform special settings.
599
600 As of \packageversion, there is only one option used:
601 \begin{docKey}[][after={\CHDocNew{0.9}}]{wrap}{=\meta{true/false}}{initially true}
602
603 This key determines whether addition of values to a periodic counter (see \nameref{section:periodic_counters}) will lead to a modulo part addition.
604 \end{docKey}
605
606 \end{docCommand}
607
608
609 \subsection[\LaTeXe\ additions]{Additions to \LaTeXe\ commands}
610
611 \begin{docCommand}{NewDocumentCounter}{\oarg{options}\marg{counter1,counter2,\dots}\oarg{resetting counter}}
612 This command is a new interface to \cs{newcounter} and behaves effectively the same. %The first optional argument is reserved for later purposes but not used as of version \packageversion.
613
614 \begin{docKey}{initial}{=\meta{integer value}}{initially 0}
615 This is used for the start value of the new counter.
616 \end{docKey}
617
618 \CHDocUpdate{1.2}This command allows multiple counters (specified as a comma separated list) to be defined at once, but all have the same resetting counter then and initial value is the same for all those counters (if those options are given).
619
620 \end{docCommand}%
621
622 \begin{docCommand}{DeclareDocumentCounter}{\oarg{options}\marg{counter}\oarg{resetting counter}}
623 This command is the preamble-only version of \refCom{NewDocumentCounter}.
624 \CHDocUpdate{1.2}This command allows multiple counters (specified as a comma separated list) to be defined at once, but all have the same resetting counter then and initial value is the same for all those counters (if those options are given), i.e. the behaviour is like in \refCom{NewDocumentCounter}.
625 \end{docCommand}%
626
627
628 \begin{docCommand}{SetDocumentCounter}{\oarg{options}\marg{counter}\marg{counter value}}
629
630 This command behaves like the standard macro \cs{setcounter}, but has an additional optional 1st argument. %which is not used as of version \packageversion.
631 % This optional argument can be used to enable the setting of the driver counter value as well as the associated counter values at once.
632
633 \begin{docCommandArgs}{SetDocumentCounter}%
634
635
636 \begin{codeoptionsenum}
637 \item \oarg{options}: %As of version \packageversion, this option is not used% the key value argument
638
639 \begin{docKey}{associatedtoo}{=\meta{true/false}}{initially false}
640 If enabled (\meta{true}), \refCom{SetDocumentCounter} will use the counter value for \underline{all} counters associated to this driver counter as well. Initially, this option is set to \meta{false}.
641 \end{docKey}
642
643 \begin{docKey}{onlycounters}{=\meta{comma separated list of counters}}{initially empty}
644 If this key is used, only those associated counters are set as well that are given in the comma separated list.
645
646 Names, that are either not referring to counters at all or to counters that are not associated to the given driver counter will be ignored silently.
647 \end{docKey}
648
649
650
651
652
653 \item \marg{counter}
654 Holds the name of the (driver) counter to be set.
655 \item \marg{counter value}
656 Holds the value to be set
657 \end{codeoptionsenum}
658 \end{docCommandArgs}
659
660 Some notes on \refCom{SetDocumentCounter}
661 \begin{itemize}
662 \item The option keys \refKey{associatedtoo} and \refKey{onlycounters} are mutually exclusive! %
663 \item The counter to be set can be either a driver counter or an otherwise associated counter.
664 \end{itemize}
665 \end{docCommand}%
666
667 \begin{docCommand}{StepDownCounter}{\oarg{options}\marg{counter}}\CHDocNew{0.4}
668
669 This macro subtracts the value of 1 from the counter and is the counterpart of \cs{stepcounter}.
670
671 \begin{docCommandArgs}{StepDownCounter}%
672
673
674 \begin{codeoptionsenum}
675 \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
676 \item \marg{counter}
677 Holds the name of the first counter.
678 \end{codeoptionsenum}
679 \end{docCommandArgs}
680
681 \end{docCommand}%
682
683
684 \begin{docCommand}{SubtractFromCounter}{\oarg{options}\marg{counter}\marg{delta value}}\CHDocNew{0.4}
685
686 This macro subtracts the (positive) delta value from the counter and is the counterpart of \cs{addtocounter}
687
688 \begin{docCommandArgs}{SubtractFromCounter}%
689
690
691 \begin{codeoptionsenum}
692 \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
693
694 \item \marg{counter 1}
695 Holds the name of the first counter.
696 \item \marg{delta value}
697 Holds the (positive) value to be subtracted from the counter value.
698 \end{codeoptionsenum}
699 \end{docCommandArgs}
700
701 \end{docCommand}%
702
703
704 \begin{docCommand}{CopyDocumentCounters}{\oarg{options}\marg{source counter}\marg{target counter}}
705
706 This document copies the counter value from the source counter in argument 2 to the target counter in argument 3.
707
708 \begin{docCommandArgs}{CopyDocumentCounters}%
709
710
711 \begin{codeoptionsenum}
712 \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
713
714 \item \marg{source counter}
715 Holds the name of the source counter.
716 \item \marg{target counter}
717 Holds the name of the target counter.
718 \end{codeoptionsenum}
719 \end{docCommandArgs}
720
721 \end{docCommand}%
722
723
724 \begin{docCommand}{SwapDocumentCounters}{\oarg{options}\marg{counter 1}\marg{counter 2}}
725
726 This macro swaps the values of the counters given in arguments 2 and 3
727
728 \begin{docCommandArgs}{SwapDocumentCounters}%
729
730
731 \begin{codeoptionsenum}
732 \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
733
734 \item \marg{counter 1}
735 Holds the name of the first counter.
736 \item \marg{counter 2}
737 Holds the name of the second counter.
738 \end{codeoptionsenum}
739 \end{docCommandArgs}
740
741 \end{docCommand}%
742
743
744 \begin{docCommand}{SyncCounters}{\oarg{options}\marg{driver counter}}
745
746 This document synchronizes the driver counter value to the associated values. It has the same options as \refCom{SetDocumentCounter}. If the given counter is no driver counter, nothing is done.
747
748 \begin{docCommandArgs}{SyncCounters}%
749
750
751 \begin{codeoptionsenum}
752 \item \oarg{options}: see \refCom{SetDocumentCounter}
753
754 \item \marg{source counter}
755 Holds the name of the source counter.
756 \end{codeoptionsenum}
757 \end{docCommandArgs}
758
759 \end{docCommand}%
760
761 \begin{dispExample}%[breakable=true]
762 \SetDocumentCounter{foocntr}{17}
763 \SetDocumentCounter{foobarcntr}{20}
764
765 \begin{itemize}
766 \item Displaying counters
767
768 \thefoocntr\ and \thefoobarcntr
769 \item Swapping counters
770
771 \SwapDocumentCounters{foocntr}{foobarcntr}
772
773 \thefoocntr\ and \thefoobarcntr
774
775 \item Step down counters
776
777 \StepDownCounter{foocntr}
778 \StepDownCounter{foobarcntr}
779
780 \thefoocntr\ and \thefoobarcntr
781
782 \item Subtracting some value from the counters
783 \SubtractFromCounter{foocntr}{5}
784 \SubtractFromCounter{foobarcntr}{10}
785
786 \thefoocntr\ and \thefoobarcntr
787 \end{itemize}
788 \end{dispExample}
789
790
791 \subsection[\protect\cs{IfIsDocumentCounter}-Queries]{Commands checking whether a name refers to a counter}
792
793 \CHDocPackage{\PackageDocName}\ provides three commands that are quite similar -- all check whether \marg{name} is an already defined \LaTeXe\ counter (name), in good tradition with the \CHDocPackage{xparse} - syntax:
794
795 \begin{itemize}
796 \item \begin{docCommand}{IfIsDocumentCounterTF}{\oarg{}\marg{name}\marg{true branch}\marg{false branch}}
797 This macro performs the full branching
798 \end{docCommand}
799 \item
800
801 \begin{docCommand}{IfIsDocumentCounterT}{\oarg{}\marg{name}\marg{\meta{long} true branch}}
802 This command executes only if the name is a counter.
803 \end{docCommand}
804
805 \begin{docCommand}{IfIsDocumentCounterF}{\oarg{}\marg{name}\marg{true branch}}
806 This command executes only if the name is not a counter.
807 \end{docCommand}
808
809 \end{itemize}
810
811 The optional argument is not used as of version \packageversion\ for none of those three commands.
812
813
814 \subsection[Information macros]{Information on counters} \label{subsection::informationcmds}
815
816 On occasions it might be important to have some information which counter has been changed last. Since there are four commands manipulating counter values, there are four corresponding routines for this:
817
818 \begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastAddedToCounter}{}
819 This command has no arguments and expands to the name of the counter which was used last in \cs{addtocounter}. There is no further typesetting done with the countername.
820
821 \begin{dispExample}
822 \newcounter{SomeCounter}
823
824 \addtocounter{SomeCounter}{10}
825
826 The last counter something added to was \LastAddedToCounter.
827 \end{dispExample}%
828 \end{docCommand}%
829
830 \begin{marker}
831 Please note that \refCom{LastAddedToCounter} might fail!
832 \end{marker}
833
834
835 \begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastSteppedCounter}{}
836
837 This command has no arguments and expands to the name of the counter which was stepped last using \cs{stepcounter}. There is no further typesetting done with the countername.
838
839
840 \begin{dispExample}
841 \stepcounter{SomeCounter}
842 The last counter being stepped was \LastSteppedCounter.
843 \end{dispExample}%
844
845 \end{docCommand}%
846
847 \begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastRefSteppedCounter}{}
848
849 This macro gives the last counter being used in \cs{refstepcounter} and is expandable.%{\ChDocVersion{1.3}}
850
851 \begin{dispExample}
852 \begin{equation}
853 E = mc^2 \label{eq::einstein}
854 \end{equation}
855 % \stepcounter{SomeCounter}
856
857 The last counter being refstepped was \LastRefSteppedCounter.
858 \end{dispExample}%
859
860
861 \end{docCommand}%
862
863
864
865
866
867 \begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastSetCounter}{}
868 This command has no arguments and expands to the name of the counter which was set last using \cs{setcounter}. There is no further typesetting done with the countername.
869
870 \begin{dispExample}
871 \setcounter{SomeCounter}{21}%
872
873 The last counter being set was \LastSetCounter.
874 \end{dispExample}%
875
876 \end{docCommand}%
877
878
879 \begin{docCommand}{LastCounterValue}{}
880 This command has no arguments and expands to the value of the very last change of a counter, i.e. using \cs{setcounter} etc.
881
882 \begin{dispExample}
883 \setcounter{SomeCounter}{100}%
884
885 The last counter being set was \LastSetCounter and it had the value \LastCounterValue{} then, where as \stepcounter{equation} will yield \fbox{\LastSteppedCounter} and \LastCounterValue!
886 \end{dispExample}%
887
888 The usage of \refCom{LastSetCounter} is best together with one of the other \cs{Last...} macros.
889
890 \end{docCommand}%
891
892 \begin{marker}
893 All of the \cs{Last...} macros are expandable, i.e. it is possible to store the value to an macro defined with \cs{edef}
894 \end{marker}
895
896 \begin{dispExample}
897 \setcounter{SomeCounter}{50}%
898
899 \edef\lastcounterset{\LastSetCounter}
900 \edef\lastcountervalue{\LastCounterValue}
901
902 \setcounter{equation}{81}%
903
904
905 The last counter being set was \fbox{\LastSetCounter} and it had the value \LastCounterValue{} then, but we changed \lastcounterset{} earlier and it had the value \lastcountervalue{} then.
906 \end{dispExample}%
907
908 \setcounter{equation}{1}
909
910
911
912
913 \begin{marker}
914 Please note, that all of this commands are only working in the current run of compilation, i.e. \underline{after} there has been some operation on the counters. They can't be used for information on the last changed counter in a previous run.
915 \end{marker}
916
917
918
919
920
921 \section{Counter reset lists}
922
923 The package \CHDocPackage{chngcntr} offers the possibility of add or remove counters to the reset list of a driver counter with the commands \cs{counterwithin} and \cs{counterwithout}, whereas the package \CHDocPackage{remreset} provides \cs{@removefromreset} as a counterpart to the \LaTeXe\ core command \cs{@addtoreset} macro.
924
925 \subsection[Addition and Removal]{Addition and Removal of counters from the reset list}\CHDocNew{1.0}
926
927 \begin{docCommand}[before={\CHDocNew{1.0}\CHDocUpdate{1.4}}\par]{RemoveFromReset}{\marg{counter name1, counter name2,\dots}\marg{driver counter name}}
928 This macro removes the counters given in the comma separated list in the first argument from the reset list of the driver counter given in the 2nd argument.
929
930 If the 2nd argument does not point to a \LaTeXe\ counter name an error message is shipped and the compilation fails.
931 \end{docCommand}
932
933
934 \begin{docCommand}[before={\CHDocNew{1.0},\CHDocUpdate{1.4}}\par]{RemoveFromFullReset}{\marg{counter name1, counter name2,\dots}\marg{driver counter name}}
935 This macro removes the counters given in the comma separated list in the first argument and all of its own reset list from the reset list of the driver counter given in the 2nd argument.
936
937 If the 2nd argument does not point to a \LaTeXe\ counter name an error message is shipped and the compilation fails.
938 \end{docCommand}
939
940 \begin{docCommand}[before={\CHDocNew{1.4}}]{ClearCounterResetList}{\marg{driver counter name}}
941 This macro removes all counters of the given driver counter reset list. The individual counter formatting macros \cs{theX} are reset both for the driver counter as well as the counters in the reset list to use the \cs{arabic} standard output macro. \texttt{X} means some arbitray \LaTeX2e\ counter name.
942
943 If the resetting shall not be applied, use \refCom{ClearCounterResetList*} instead.
944 \end{docCommand}
945
946 \begin{docCommand}[before={\CHDocNew{1.4}}]{ClearCounterResetList*}{\marg{driver counter name}}
947 This behaves like \refCom{ClearCounterResetList} but does \textbf{not} reset the relevant \cs{theX} macros.
948 \end{docCommand}
949
950
951 \begin{docCommand}[before={\CHDocNew{1.0}\CHDocUpdate{1.4}}]{AddToReset}{\marg{counter name1, counter name2,\dots}\marg{driver counter name}}
952 This macro adds the counters given in the comma separated list in the first argument to the reset list of the driver counter given in the 2nd argument.
953
954 If the 2nd argument does not point to a \LaTeXe\ counter name an error message is shipped and the compilation fails.
955
956 An accidental specificiation of the driver counter to be added to its own reset list is ignored internally.
957 \end{docCommand}
958
959
960 \subsection[Information macros about the reset list]{Information macros about the counter reset list}
961
962 Sometimes it might be necessary or convenient to know how many counters are on a reset list of some other counters, i.e. added by \cs{newcounter}\textbraceleft counter\textbraceright[resetting counter] or \refCom{NewDocumentCounter}.
963
964 There are some macros that provide this information:
965
966 \begin{docCommand}{countersresetlistcount}{\marg{counter name}}
967 This macro determines the number of counters being in the reset list of the counter specified as mandatory argument.
968
969 Please note: This command isn't expandable. The number is stored internally to another macro, which can be accessed with \refCom{getresetlistcount}, which returns a pure integer number.
970 \end{docCommand}
971
972 \begin{docCommand}{getresetlistcount}{}
973 This macro returns the number of counters being in the reset list of the counter specified as mandatory argument. It needs a previous call of \refCom{countersresetlistcount} first!
974
975 If the counter has no other counters in its reset list, the value of 0 is returned.
976 \end{docCommand}
977
978
979 \begin{docCommand}[before={\CHDocNew{1.0}}\par]{CounterFullResetList}{\marg{counter name}}
980 This macro determines the full reset list of a counter as well of the counters being on the reset list, i.e. the list is tracked down until there are no counters left in a recursion.
981
982 The counter names are stored internally in \CHDocPackage{expl3} - \cs{seq} - variable named \cs{xy\_fullresetlist\_seq} -- the \meta{xy} is replaced by the counter name, e.g. if the counter is named \CHDocCounter*{foo}, the identifier would be \cs{foo\_fullresetlist\_seq}. Unless \CHDocTag{expl3} features are not applied, the \refCom{CounterFullResetList} is not really useful on a document or package/class developing level. However, to loop through the full reset list with some action performed on the members of the sequence, the command \refCom{LoopFullCounterResetList} may be very useful.
983
984 \begin{marker}
985 \begin{itemize}
986 \item The driver counter \CHDocCounter*{foo} is not added to the relevant sequence.
987 \item If the name given to \refCom{CounterFullResetList} does not indicate a \LaTeXe\ counter an error message is shipped and the compilation fails.
988 \end{itemize}
989 \end{marker}
990 \end{docCommand}
991
992 \begin{docCommand}{IfInResetListTF}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{true branch}\marg{false branch}}
993 This command sequence tests whether the counter \meta{reset counter} is in the reset list of \meta{resetting counter} and expands the relevant branch then.
994 See the short-circuit commands \refCom{IfInResetListT} and \refCom{IfInResetListF} as well.
995 \end{docCommand}
996
997 \begin{docCommand}{IfInResetListT}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{true branch}}
998 This command sequence tests whether the counter \meta{reset counter} is in the reset list of \meta{resetting counter} and expands to the true branch.
999 See the related commands \refCom{IfInResetListTF} and \refCom{IfInResetListF} as well.
1000 \end{docCommand}
1001
1002 \begin{docCommand}{IfInResetListF}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{false branch}}
1003 This command sequence tests whether the counter \meta{reset counter} is not in the reset list of \meta{resetting counter} and expands to the false branch.
1004 See the related commands \refCom{IfInResetListTF} and \refCom{IfInResetListT} as well.
1005 \end{docCommand}
1006
1007 \begin{docCommand}{DisplayResetList}{\oarg{separator={,}}\marg{resetting counter}}\CHDocNew{0.8}
1008
1009 This command displays the reset list of a counter as a separated list. If the counter has no resetting list, nothing is shown.
1010
1011 \begin{docCommandArgs}{DisplayResetList}%
1012
1013 \begin{codeoptionsenum}
1014 \item \oarg{separator}%
1015 This separator is used for display, it defaults to a comma character.
1016
1017 \item \marg{resetting counter}%
1018
1019 Contains the name of counter whose resetting list should be displayed.
1020 \end{codeoptionsenum}
1021 \end{docCommandArgs}
1022
1023 \end{docCommand}
1024
1025 \begin{docCommand}{ShowResetList}{\marg{resetting counter}}\CHDocNew{0.8}
1026 This command displays the reset list of a counter on the terminal as the \cs{show} command would do. This is rather useful for debugging purposes only.
1027 \end{docCommand}
1028
1029
1030 \begin{docCommand}[before={\CHDocNew{1.3}}]{GetAllResetLists}{}
1031 This determines all reset lists and stores the information internally. It should be called right before \cs{begin{document}} or at any time inside the document environment, when new counters are added there (which is not recommended)
1032
1033 The information can be retrieved with \refCom{GetParentCounter}.
1034
1035 \end{docCommand}
1036
1037 \begin{docCommand}[before={\CHDocExpCommand\par\CHDocNew{1.3}}]{GetParentCounter}{\marg{counter}}
1038 This macro tries to detect the counter that was responsible for the resetting of the counter named \marg{counter} and is expandable.
1039 In order to minimize the amount of searching and maintaining expandability, the counter reset data must be stored beforehand, i.e. with \refCom{GetAllResetLists}.
1040
1041 \begin{marker}
1042 If a counter has been added to more than one parent counter as their resetting driver counter, only the most recent addition is in action. This may be correct in some occasions but there is no guarantee that the given counter name really caused the last reset of the counter given as argument.
1043 \end{marker}
1044 \end{docCommand}
1045
1046
1047
1048 \section[Loops on multiple counters]{Performing the same action for many counters} \CHDocNew{0.7}
1049
1050 Sometimes it might be necessary to set the values of many counters at once. This can be done with consecutive \cs{setcounter} statements, for example. This poses no problem, but might become tedious if there are more than three counters or if this task occurs more than once. \CHDocPackage{\PackageDocName} provides some macros that can do the usual operations like stepping, refstepping, adding to, resetting or setting counter values.
1051
1052
1053 All macros concerning this feature use the first macro argument having a comma-separated list of counters. Whether there's a second argument depends on the specific nature of the operation that should be performed.
1054
1055 \begin{marker}
1056 \begin{itemize}
1057 \item As of version \packageversion\ \PackageDocName\ does not check whether the names given in the first argument refer to counters.
1058 \item All macros use the extended counter macros, i.e. are aware of associated counters and step them too if their driver counter is given in the argument list. If an associated counter itself is given in the list, this one is stepped or operated on too!
1059 \end{itemize}
1060 \end{marker}
1061
1062
1063 \begin{docCommand}[before={\CHDocNew{0.7}}]{LoopAddtoCounters}{\marg{counter1, counter2,\dots}\marg{counter increment/decrement}}
1064
1065 %\begin{docCommandArgs}{LoopAddToCounters}%
1066 The 2nd argument value is added (or subtracted) to the counters given in the list of the 1st argument using the \cs{addtocounter}.
1067
1068 \begin{codeoptionsenum}
1069 \item \marg{counter1, counter2,\dots}
1070 Holds the comma separated list of counter names
1071 \item \marg{counter increment/decrement}
1072 Specifies the value to be added or subtracted.
1073
1074 No check is performed whether \#2 \textbf{is} or \textbf{expands} to an integer value.
1075 \end{codeoptionsenum}
1076 %\end{docCommandArgs}
1077
1078 \end{docCommand}
1079
1080
1081 \begin{docCommand}[before={\CHDocNew{0.7}}]{LoopResetCounters}{\marg{counter1, counter2,\dots}}
1082
1083
1084 %\begin{docCommandArgs}{LoopResetCounters}%
1085 All counters given in the first argument are set to zero using the regular \cs{setcounter}. This is a shorthand version of \refCom{LoopSetCounters} for this specific case.
1086
1087
1088 \begin{codeoptionsenum}
1089 \item \marg{counter1, counter2,\dots}
1090 Holds the comma separated list of counter names
1091 \end{codeoptionsenum}
1092 %\end{docCommandArgs}
1093
1094 \end{docCommand}
1095
1096
1097 \begin{docCommand}[before={\CHDocNew{0.7}}]{LoopRefstepCounters}{\marg{counter1, counter2,\dots}}
1098
1099 %\begin{docCommandArgs}{LoopStepCounters}%
1100 All counters given in the first argument are stepped using the regular \cs{refstepcounter} to allow labels -- however, only the last counter will have the correct label reference.
1101
1102 \begin{marker}
1103 This macro is meant only to complete the number of \cs{Loop...Counters} but is not regarded as being really useful.
1104 \end{marker}
1105
1106 \begin{codeoptionsenum}
1107 \item \marg{counter1, counter2,\dots}
1108 Holds the comma separated list of counter names
1109 \end{codeoptionsenum}
1110 %\end{docCommandArgs}
1111
1112 \end{docCommand}
1113
1114
1115
1116 \begin{docCommand}[before={\CHDocNew{0.7}}]{LoopSetCounters}{\marg{counter1, counter2,\dots}\marg{new counter value}}
1117
1118 %\begin{docCommandArgs}{LoopAddToCounters}%
1119 The 2nd argument value is used as new counter value added (or subtracted) to the counters given in the list of the 1st argument using the \cs{addtocounter}.
1120
1121 \begin{codeoptionsenum}
1122 \item \marg{counter1, counter2,\dots}
1123 Holds the comma separated list of counter names
1124 \item \marg{new counter value}
1125 Specifies the value to be set.
1126
1127 No check is performed whether \textbf{is} or \textbf{expands} to an integer value.
1128 \end{codeoptionsenum}
1129 %\end{docCommandArgs}
1130
1131 \end{docCommand}
1132
1133
1134 \begin{docCommand}{LoopStepCounters}{\marg{counter1, counter2,\dots}} \CHDocNew{0.7}
1135
1136 \begin{docCommandArgs}{LoopStepCounters}%
1137 All counters given in the first argument are stepped using the regular \cs{stepcounter}.
1138
1139 \begin{codeoptionsenum}
1140 \item \marg{counter1, counter2,\dots}
1141 Holds the comma separated list of counter names
1142 \end{codeoptionsenum}
1143 \end{docCommandArgs}
1144
1145 \end{docCommand}
1146
1147
1148 A more general command for doing "arbitrary" operations with counters (and more setup, for example) is
1149
1150 \begin{docCommand}{LoopCountersFunction}{\marg{counter1, counter2,\dots}\marg{counter operation macro}} \CHDocNew{0.7}
1151
1152 \begin{docCommandArgs}{LoopAddToCounters}%
1153 The 2nd argument value should hold a macro with any number of arguments, but the last mandatory argument of this macro is reserved for counter name.
1154
1155 \begin{codeoptionsenum}
1156 \item \marg{counter1, counter2,\dots}
1157 Holds the comma separated list of counter names
1158 \item A macro name that is to be called and that operates on a counter.
1159 \end{codeoptionsenum}
1160 \end{docCommandArgs}
1161
1162 \end{docCommand}
1163
1164
1165 \begin{dispExample}
1166 % We assume we have the counters foocntr and foobarcntr
1167 \newcommand{\showcountervalues}[2]{%
1168 \textcolor{#1}{\csname the#2\endcsname}% Now, an extra empty line to show the values in rows
1169
1170 }
1171 % Note that the 2nd argument is not given here -- it's added by the \LoopCountersFunction macro
1172 \LoopCountersFunction{foocntr,foobarcntr}{\showcountervalues{blue}}
1173 \end{dispExample}
1174
1175
1176 \begin{docCommand}[before={\CHDocNew{1.4}}\par]{LoopCounterResetList}{\marg{counter name}\marg{counter operation macro}}
1177 This macro will perform the same action on the reset list of a the counter name given as first argument, the action is a control sequence name specified by the in the second mandatory argument. The loop provides all counters on the reset list of a counter.
1178
1179 As of version \packageversion\ the counter operation macro must have two mandatory arguments, the second one is meant for the current counter in the loop.
1180
1181 Do not confuse this command with \refCom{LoopFullCounterResetList} which tracks all counters recursively on the reset list, so \refCom{LoopCounterResetList} steeps only level down in the reset list hierarchy.
1182 \end{docCommand}
1183
1184 \begin{docCommand}[before={\CHDocNew{1.0}}\par]{LoopFullCounterResetList}{\marg{counter name}\marg{counter operation macro}}
1185 This macro determines the full reset list of a counter, i.e. it cascades down the reset list and tracks the reset lists of all 'sub'-counters too and performs the counter operation macro on this.
1186 \begin{codeoptionsenum}
1187 \item \marg{counter name}
1188
1189 Holds the comma separated list of counter names
1190 \item \marg{counter operation macro}
1191 A macro name that is to be called and that expects the name of a counter as the last argument.
1192 \end{codeoptionsenum}
1193
1194 See the macro \refCom{CounterFullResetList} for more information about the internal storage of the full reset list.
1195
1196 \end{docCommand}
1197
1198
1199
1200 \begin{docCommand}[before={\CHDocNew{1.4}}\par]{CounterWithin}{\marg{counter nameA, counter nameB,\dots}\marg{drivercounter}}
1201 This macro sets all counters nameA, nameB, \dots to the reset list of the \marg{drivercounter} and redefines the corresponding macros \cs{thenameA}, etc. to be prepended with \cs{thedrivercounter}, i.e. \verb!\CounterWithin{equation}{section}! would mean that \verb!\theequation! expands to \verb!\thesection.\arabic{section}!
1202
1203 The default format for the counter output is arabic numbers, i.e. \cs{arabic} will be used.
1204
1205 If the macros \cs{thenameA} etc. should not be changed, use the starred version of this command: \refCom{CounterWithin*}.
1206
1207 \begin{marker}
1208 Please note that the redefinition of \cs{thenameA} etc. is only local, i.e. it is group safe.
1209 \end{marker}
1210 \end{docCommand}
1211
1212 \begin{docCommand}[before={\CHDocNew{1.4}}\par]{CounterWithin*}{\marg{counter nameA, counter nameB,\dots}\marg{drivercounter}}
1213 This macro sets all counters nameA, nameB, \dots to the reset list of the \marg{drivercounter}, but does not change the corresponding macros \cs{thenameA}, etc. at all.
1214
1215 The default format for the counter output is arabic numbers, i.e. \cs{arabic} will be used.
1216
1217 If the macros \cs{thenameA} etc. should be changed, use non-starred version of this command: \refCom{CounterWithin}.
1218
1219 \end{docCommand}
1220
1221
1222 \begin{docCommand}[before={\CHDocNew{1.4}}\par]{CounterWithout}{\marg{counter nameA, counter nameB,\dots}\marg{drivercounter}}
1223 This macro removes all counters nameA, nameB, \dots from the reset list of the \marg{drivercounter} and redefines the corresponding macros \cs{thenameA}, etc. without \cs{thedrivercounter}, i.e. \verb!\CounterWithout{equation}{section}! would mean that \verb!\theequation! expand to \verb!\arabic{section!
1224
1225 The default format for the counter output is arabic numbers, i.e. \cs{arabic} will be used.
1226
1227 If the macros \cs{thenameA} etc. should not be changed, use the starred version of this command: \refCom{CounterWithout*}.
1228
1229 \begin{marker}
1230 Please note that the redefinition of \cs{thenameA} etc. is only local, i.e. it is group safe.
1231 \end{marker}
1232
1233 \end{docCommand}
1234
1235 \begin{docCommand}[before={\CHDocNew{1.4}}\par]{CounterWithout*}{\marg{counter nameA, counter nameB,\dots}\marg{drivercounter}}
1236 This macro removes all counters nameA, nameB, \dots from the reset list of the \marg{drivercounter}, but does not redefine the corresponding macros \cs{thenameA}, etc.
1237
1238 If the macros \cs{thenameA} etc. should be changed, use the non-starred version of this command: \refCom{CounterWithout}.
1239 \end{docCommand}
1240
1241
1242
1243
1244
1245 \section{Counter output}\CHDocNew{0.7}
1246
1247 Once in a while it might be necessary to provide counter output not only as integer numbers, letters or Roman figures but also using binary, octal or hexdecimal number output. The \CHDocPackage{fmtcount} package has support for this already -- here are some alternatives.
1248
1249 \subsection{Extra counter output types}
1250
1251
1252 \begin{marker}
1253 None of the commands checks whether the argument refers to counter name.
1254 \end{marker}
1255 \begin{docCommand}[doc new={\chdocextractversion{xassoccntversion0.7}}]{BinaryValue}{\marg{counter name}}
1256
1257 This command will print the value of the counter using binary digits.
1258
1259 \end{docCommand}
1260
1261 \begin{docCommand}{hexValue}{\marg{counter name}} \CHDocNew{0.7}
1262
1263 This command will print the value of the counter using lowercase hexadecimal digits.
1264
1265 \end{docCommand}
1266
1267 \begin{docCommand}{HexValue}{\marg{counter name}} \CHDocNew{0.7}
1268
1269 This command will print the value of the counter using uppercase hexadecimal digits.
1270
1271 \end{docCommand}
1272
1273 \begin{docCommand}{OctalValue}{\marg{counter name}} \CHDocNew{0.7}
1274
1275 This command will print the value of the counter using octal digits.
1276
1277 \end{docCommand}
1278
1279
1280 \begin{docCommand}{xalphalph}{\marg{counter name}}\CHDocNew{1.4}
1281 This is allows to use more than 26 characters for the usual alphabet and prints the counter value with style \texttt{aa} etc. in the same manner as the \CHDocPackage{alphalph} does, but with the \cs{int\_to\_alph:n} macro from the \CHDocPackage{expl3} bundle. For usage with uppercase characters see \refCom{xAlphAlph}.
1282 \end{docCommand}
1283
1284 \begin{docCommand}{xAlphAlph}{\marg{counter name}}\CHDocNew{1.4}
1285 This is allows to use more than 26 characters for the usual alphabet and prints the counter value with style \texttt{AA} etc. in the same manner as the \CHDocPackage{alphalph} does, but with the \cs{int\_to\_Alph:n} macro from the \CHDocPackage{expl3} bundle. For usage with uppercase characters see \refCom{xalphalph}.
1286 \end{docCommand}
1287
1288 \subsection{Quick counter output changes}\CHDocNew{1.4}
1289
1290
1291 \begin{docCommand}{CounterFormat}{\oarg{options}\marg{counter1!formatname1,counter2!formatname2,\dots }}\CHDocNew{1.4}
1292
1293 \begin{marker}
1294 This macro needs the package option \refKey{standardcounterformats} to be activated with \meta{standardcounterformats=on}, which is the default.
1295 \end{marker}
1296
1297 \begin{codeoptionsenum}
1298 \item \oarg{options}
1299 \begin{docKey}[][]{recursive}{=\meta{true/false}}{default: false}
1300 If this key is set, the same counter format is used for the relevant counter and its resetting counters, i.e. the macro will pursue the reset counter list chain and recursively adds \cs{the...} to the output format of \cs{thenameA} etc.
1301 \begin{marker}
1302 Since the \meta{recursive} option needs information on the parent counters, the macro \refCom{GetAllResetLists} must have been called before \refCom{CounterFormat} with this option can be applied. In order to provide the most recent information (which includes recently added counters or changed resetting levels), use \refCom{GetAllResetLists} just before \refCom{CounterFormat}.
1303 \end{marker}
1304 \end{docKey}
1305 \begin{docKey}[][]{separator}{=\meta{separator character/string}}{default: !}
1306 Specifies the separator that is used to split the counter name from the format, e.g. \meta{chapter!R} where \meta{chapter} is the counter name and \meta{R} will be recognized as a counter format, meaning \cs{Roman} here, see \cref{table--predefined-counter-formats} for a list of predefined counter formats.
1307
1308 \begin{marker}
1309 The chosen separator must be the same for all counters in the given list of the 2nd argument (see below) and mustn't occur in the counter name itself\footnote{It is not recommended to use counter names with non alphabetic characters anyway.}.
1310 \end{marker}
1311 \end{docKey}
1312 \item \marg{counter1!formatname1,counter2!formatname2,\dots}
1313 A comma separated list of counters with a given format name, each separated with a separator charactor, default is \meta{!}. If the format is omitted, the default format is \cs{arabic}, i.e. arabic numbers are used.
1314 \end{codeoptionsenum}
1315
1316 \end{docCommand}
1317
1318 \begin{table}[htpb]
1319 Currently following counter formats shorthands and their output macros are stored in \cs{AtBeginDocument} if the package option \refKey{standardcounterformats} is set to on, which is the default behaviour of the package.
1320
1321 \centering
1322 \begin{tabular}{ll}
1323 a & \cs{alph} \tabularnewline
1324 A & \cs{Alph} \tabularnewline
1325 aa & \refCom{xalphalph} \tabularnewline
1326 AA & \refCom{xAlphAlph} \tabularnewline
1327 b & \refCom{BinaryValue} \tabularnewline
1328 h & \refCom{hexValue} \tabularnewline
1329 H & \refCom{HexValue} \tabularnewline
1330 n & \cs{arabic} \tabularnewline
1331 o & \refCom{OctalValue} \tabularnewline
1332 r & \cs{roman} \tabularnewline
1333 R & \cs{Roman} \tabularnewline
1334 \end{tabular}
1335 \caption[List of predefined counter formats]{List of predefined counter format shorthands -- please note that \meta{n} has been used in order to allow \meta{a} to be used for output with lowercase characters.}\label{table--predefined-counter-formats}
1336 \end{table}
1337
1338 \begin{dispExample*}{title=Simple usages of \refCom{CounterFormat},breakable}
1339 % Assume foobar is a defined counter
1340 \setcounter{foobar}{17}
1341
1342 \CounterFormat{foobar!b}
1343 \thefoobar
1344
1345 \CounterFormat{foobar!h}
1346 \thefoobar
1347
1348
1349 \CounterFormat{foobar!H}
1350 \thefoobar
1351
1352 \CounterFormat{foobar!R}
1353 \thefoobar
1354
1355 \setcounter{foobar}{30}
1356
1357 \CounterFormat{foobar!aa}
1358 \thefoobar
1359
1360 \CounterFormat{foobar!o}
1361 \thefoobar
1362
1363 \CounterFormat{foobar!AA}
1364 \thefoobar
1365
1366
1367 \end{dispExample*}
1368
1369 \begin{dispExample*}{title={Showing the \meta{recursive} option of \refCom{CounterFormat}},breakable}
1370 % All counters are using \arabic by default from \newcounter or \NewDocumentCounter
1371 \NewDocumentCounter{foolevelzero}
1372 \NewDocumentCounter{foolevelone}[foolevelzero]
1373 \NewDocumentCounter{fooleveltwo}[foolevelone]
1374
1375 % Get the current reset lists! (Important}
1376
1377 \GetAllResetLists
1378
1379 % Now change to Hex format (!H) for all counters in the hierarchy.
1380 \CounterFormat[recursive]{fooleveltwo!H}
1381
1382 \setcounter{foolevelzero}{20}% Should be 14
1383 \setcounter{foolevelone}{15}% Should be F
1384 \setcounter{fooleveltwo}{10}% Should be A
1385
1386 \thefoolevelzero % -> 14
1387
1388 \thefoolevelone % 14.F
1389
1390 \thefooleveltwo % 14.F.A
1391
1392 \end{dispExample*}
1393
1394
1395 \begin{docCommand}{StoreCounterFormats}{\oarg{options}\marg{formatshorthandA!formatmacroA,formatshorthandB!formatmacroB,\dots}}\CHDocNew{1.4}
1396 Stores the counter formats separated by the separator charactor as given in the option to the global list. Existing formats will be overwritten if the format shorthand already exists. There is no warning about this!
1397 The only handled option is \refKey{separator} and has the same meaning as in \refCom{CounterFormat}.
1398
1399 The formatmacro must be a command sequence with exactly one mandatory argument, which may not be specified in the format storage process.
1400
1401 \begin{marker}
1402 This macro will become a preamble-only command most likely.
1403 \end{marker}
1404 \end{docCommand}
1405
1406 \begin{dispExample}
1407 \StoreCounterFormats{foo!\Roman,foobarnice!\OctalValue}
1408 \setcounter{foobar}{17}
1409 \CounterFormat{foobar!foo}
1410 \thefoobar
1411
1412 \CounterFormat{foobar!foobarnice}
1413 \thefoobar
1414 \end{dispExample}
1415
1416
1417
1418
1419 \begin{docCommand}{AddCounterFormats}{\oarg{options}\marg{formatshorthandA!formatmacroA,formatshorthandB!formatmacroB,\dots}}\CHDocNew{1.4}
1420 Adds the counter formats separated by the separator charactor as given in the option to the global list, similar to \refCom{StoreCounterFormats}. Existing formats will be overwritten if the format shorthand already exists. There is no warning about this!
1421 The only handled option is \refKey{separator} and has the same meaning as in \refCom{CounterFormat}.
1422
1423 The formatmacro must be a command sequence with exactly one mandatory argument, which may not be specified in the format storage process.
1424 \end{docCommand}
1425
1426 \begin{docCommand}{RemoveCounterFormats}{\oarg{options}\marg{formatshorthandA,formatshorthandB,\dots}}\CHDocNew{1.4}
1427 Removes the given counter formats from the global list.
1428
1429 The optional argument is ignored as of version \packageversion.
1430 \end{docCommand}
1431
1432
1433
1434
1435
1436 \clearpage
1437 \part{Features}
1438
1439 \parttoc
1440
1441 \section{Associated counters}
1442 \tcbset{color command={blue}}
1443
1444 The main purpose of this package is co-stepping of counters, but there are some helper commands in addition to macros provided \LaTeXe\ already, see section \nameref{section::additions_to_l2e}.
1445
1446 \begin{itemize}
1447 \item Section \nameref{subsection::associatedcounterscmds} describes the most important macros for setting up associated counters
1448 \item Section \nameref{subsection::drivercounterscmds} informs about the macros for setting up, removing or clearing driver counters
1449 \item Section \nameref{subsection::querycmds} deals with query command sequences about counters being a driver or an associated counters
1450 \item Section \nameref{subsection::informationcmds} contains routines that show which counters have been changed last
1451 \end{itemize}
1452
1453
1454
1455 \subsection[Association macros]{Associated counters commands}\label{subsection::associatedcounterscmds}
1456
1457 All macros have the general rule, that the driver counter is specified as 1st mandatory argument to the macro, which is in almost all cases the 2nd argument of the macro.
1458
1459
1460 \begin{docCommand}{DeclareAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
1461 This command is the main macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}. If only counter is to be associated, omit a trailing ","!
1462
1463 %\begin{docCommandArgs}{DeclareAssociatedCounters}
1464
1465 \begin{codeoptionsenum}
1466 \item \oarg{options}: %As of \packageversion, the optional argument \oarg{options} is not used so far, but is reserved for later purposes.
1467 \begin{docKey}[][]{autodefine}{=\meta{choice}}{initially none}
1468 This choice - key can be specified if the specified counters should be defined if they not already available.
1469 Possible values are
1470 \begin{itemize}
1471 \item \texttt{none} -- no counter is autodefined
1472 \item \texttt{all} -- all counters will be autodefined
1473 \item \texttt{driver} -- only driver counters will be autodefined
1474 \item \texttt{associated} -- only associated counters will be autodefined
1475 \end{itemize}
1476 \end{docKey}
1477 Default is \texttt{none}
1478 \begin{docKey}[][]{sloppy}{}{}
1479 If \refKey{autodefine} key is used, the \texttt{sloppy} key disables the check whether a counter is defined already.
1480 \end{docKey}
1481
1482 \item \marg{driver counter}
1483
1484 Holds the name of the driver counter to which the list of counters should be associated
1485 \item \marg{associated counters list}
1486
1487 A comma separated list of counter names that should be associated to the driver counter
1488 \end{codeoptionsenum}
1489 %\end{docCommandArgs}
1490
1491
1492 \begin{itemize}
1493 \item This command is a preamble command, i.e. it can be used in the preamble of the document or within other packages or class files only.
1494 \item This command should be used as early as possible, i.e. in the preamble of the document, since the driven counters are not increased as long as they are not associated to the driver counter. On the hand, it is possible or may be required to control the starting point of the association at any position in the body of the document, when the association should start later on. Use the command \refCom{AddAssociatedCounters} if counters should be associated within the document body.
1495 \end{itemize}
1496
1497
1498 % Relax for documentation purposes
1499 \renewcommand{\DeclareAssociatedCounters}[3][]{\relax}%
1500 \begin{dispExample}
1501 %%%% The association of anothertotalpages in this example just takes place here, so the stepping of the counter will start from here and providing a 'wrong' value.
1502 %%%%
1503 \DeclareAssociatedCounters{page}{totalpages,anothertotalpages}%
1504 This document has \number\totvalue{newtotalpages} (note: \number\totvalue{anothertotalpages}) pages.
1505 \end{dispExample}
1506
1507 \begin{itemize}
1508 \item Current version (\packageversion) rules:
1509 \begin{itemize}
1510 \item No checking whether the 2nd and 3rd arguments hold counter names is applied.
1511 \item Mutually cross - association of two counters is not supported! The compilation will stop on this!
1512 \CHDocUpdate{0.6}
1513
1514 A driver counter, say, \CHDocCounter{foo}) of, say \CHDocCounter{foobar} can not be an associated counter of \CHDocCounter{foobar}, which in turn can be a driver counter of other counters, of course.
1515
1516 A contrary feature are the \CHDocTag{coupled counters} -- If some counters should share a common base, i.e. increasing one arbitrary member counter of a group of counters then all should be increased, this called coupling of counters -- all group members are on an equal footing. See \cref{sec::coupledcounters} about this feature.
1517
1518 On the other side, \CHDocTag{associated counters} belong to a hierarchy. The driver counter dominates the associated counters.
1519
1520 \end{itemize}
1521 \item A self-association of the driver counter to itself is ignored internally as this would lead to inconsistent counter values.
1522 \item The order of the specification of associated counters in the 2nd arguments is of no importance.
1523 \item Specifing an associated counter name multiple times has no effect, only the first occurence of the name will be used.
1524 \end{itemize}
1525
1526 \end{docCommand}
1527
1528
1529 \begin{docCommand}{AddAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
1530 The usage of this macro is similar to \refCom{DeclareAssociatedCounters}; if it is called in the document preamble (or in package file), \refCom{AddAssociatedCounters} falls back to
1531 \begin{center}\refCom{DeclareAssociatedCounters},\end{center} having the same optional argument functionality with \refKey{autodefine} and \refKey{sloppy}; if it is called in the document body, this command adds some counters to the associated counter list for a specific driver counter -- if this list does not exists, the \LaTeX{} run will issue a warning, but add the driver counter to the driver list and the associated counters analogously.
1532 \marginnote{\bcbombe}
1533
1534 Using \refCom{AddAssociatedCounters} in the document body automated generation of counters is disabled.
1535
1536
1537
1538 \begin{docCommandArgs}{AddAssociatedCounters}
1539
1540 \begin{codeoptionsenum}
1541 \item \oarg{options}: As of version \packageversion, the optional argument \oarg{options} are the same as for \refCom{DeclareAssociatedCounters}, see \refKey{autodefine} and \refKey{sloppy}.
1542
1543 \item \marg{driver counter}
1544
1545 Holds the name of the driver counter to which the list of counters should be associated
1546 \item \marg{associated counters list}
1547
1548 A comma separated list of counter names that should be associated to the driver counter
1549 \end{codeoptionsenum}
1550 \end{docCommandArgs}
1551
1552
1553 % macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}.
1554
1555 \end{docCommand}%
1556
1557 \begin{docCommand}{RemoveAssociatedCounter}{\marg{driver counter}\marg{associated counter}}
1558 This command removes a counter from the existing list for a driver counter, i.e. the counter will not be increased any longer by \cs{stepcounter}. It can be increased however manually, of course.
1559 \end{docCommand}
1560
1561
1562
1563 \begin{dispExample}
1564 \RemoveAssociatedCounter{page}{anothertotalpages}
1565 This document has \number\totvalue{newtotalpages} (beware: \number\totvalue{anothertotalpages}) pages.
1566 \end{dispExample}
1567
1568
1569
1570 \begin{docCommand}{RemoveAssociatedCounters}{\marg{driver counter}\marg{list of associated counters}}
1571 This command removes the comma-separated-value list of counters from the existing list for a driver counter, i.e. the counters will not be increased any longer by \cs{stepcounter}. They can be increased however manually, of course.
1572
1573 Take care not to confuse the commands \refCom{RemoveAssociatedCounters}
1574 and{}\linebreak \refCom{RemoveAssociatedCounter}
1575 \end{docCommand}
1576
1577 \begin{docCommand}{ClearAssociatedCounters}{\oarg{options}\marg{driver counter}}
1578 This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically any longer.
1579
1580 The optional argument is not used as of version \packageversion.
1581
1582 Please note that the driver counter is not removed from the list of driver counters -- this simplifies reassociating of (other) counters to this one later on with the macro \refCom{AddAssociatedCounters} and suppress the relevant warning.
1583
1584 If the driver counter and all its associated counters should be removed, use \refCom{RemoveDriverCounter} instead.
1585 \end{docCommand}
1586
1587
1588 \begin{docCommand}[before={\CHDocNew{1.2}}]{DeclareTotalAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
1589 This command combines the features of \CHDocTag{associated counters} and \CHDocTag{total counters}, i.e. the associated counters are defined with \refCom{NewTotalDocumentCounter} and associated to the driver counter.
1590
1591 See \cref{sec::totalcounters} for more information on \CHDocTag{total counters}.
1592 \end{docCommand}
1593
1594
1595
1596 \clearpage
1597
1598
1599 \subsection[Driver macros]{Driver counter commands} \label{subsection::drivercounterscmds}
1600
1601
1602 \begin{docCommand}{AddDriverCounter}{\oarg{options}\marg{driver counter name}}
1603
1604 \begin{docCommandArgs}{AddDriverCounter}%
1605
1606 \begin{codeoptionsenum}
1607 \item \oarg{options}: As of \packageversion, the optional argument \oarg{options} is not used so far, but is reserved for later purposes.
1608
1609 \item \marg{driver counter name}
1610
1611 Holds the name of the driver counter that should be added to the list of driver counters.
1612 \end{codeoptionsenum}
1613 \end{docCommandArgs}
1614
1615 \end{docCommand}%
1616
1617
1618
1619 \begin{docCommand}{RemoveDriverCounter}{\oarg{options}\marg{driver counter}}
1620 This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically any longer.
1621
1622 The optional argument is not used as of version \packageversion.
1623
1624 If all driver counters should be unregistered, use \refCom{ClearDriverCounters} instead!
1625 \end{docCommand}
1626
1627
1628 \begin{docCommand}{ClearDriverCounters}{\oarg{options}}%
1629
1630 This clears completely the list of driver counters, such that no counters are regarded as being associated -- i.e. no driver is hold as being a driver counter.
1631
1632 The optional argument is not used as of version \packageversion.
1633
1634 \end{docCommand}
1635
1636
1637 \subsection[Query macros]{Commands for queries} \label{subsection::querycmds}
1638
1639 Sometimes it might be necessary to get information, whether a counter is regarded as a driver or as an associated counter. This section describes some query macros in order to obtain this information.
1640
1641
1642 \begin{docCommand}{IsAssociatedToCounter}{\marg{driver counter}\marg{associated counter}\marg{True branch}\marg{False branch}}
1643 This macro checks, whether a counter is associated to a particular given driver counter and expands the corresponding branch. If the internal driver counter list does not exist, the false branch will be used, since this also means, that the possibly associated counter is not associated at all.
1644
1645
1646
1647 \begin{docCommandArgs}{IsAssociatedToCounter}%
1648
1649 \begin{codeoptionsenum}
1650 \item \marg{driver counter}
1651
1652 Holds the name of the driver counter to which \marg{associated counter} the could possibly be associated.
1653 \item \marg{associated counter}
1654
1655 Contains the name of the possibly associated counter.
1656
1657 \item \marg{True branch}
1658
1659 This code is expanded if the counter is associated to the driver, otherwise it is ignored.
1660
1661 \item \marg{True branch}
1662
1663 This code is expanded if the counter is \textbf{not} associated to the driver, otherwise it is ignored.
1664
1665 \end{codeoptionsenum}
1666 \end{docCommandArgs}
1667
1668
1669 \begin{dispExample}
1670 % Remove associated counter first for demonstration purposes
1671 \RemoveAssociatedCounter{page}{anothertotalpages}
1672 \IsAssociatedToCounter{page}{newtotalpages}{Yes, totalpages is associated}{No, totalpages is not associated}
1673
1674 \IsAssociatedToCounter{page}{anothertotalpages}{Yes, anothertotalpages is associated}{No, anotherpages is not associated}
1675 \end{dispExample}
1676
1677 See also
1678
1679 \begin{itemize}
1680 \item \refCom{IsAssociatedCounter} for checking whether a counter is associated
1681 \item \refCom{IsDriverCounter} in order to check whether a counter is a driver.
1682 \item \refCom{GetDriverCounter} returns the driver counter name for a given associated counter name
1683 \end{itemize}
1684
1685
1686 \end{docCommand}
1687
1688
1689 \begin{docCommand}{GetDriverCounter}{\marg{counter name}}%
1690
1691 This commands returns the driver counter to which the counter name of the first argument is connected to. If the counter is not defined, the macro returns nothing.
1692
1693 \begin{itemize}
1694 \item No check whether the counter name is defined is performed
1695 \item No check whether the counter is associated at all is performed. Usage of this command in conjunction with \refCom{IsAssociatedCounter} is strongly encouraged.
1696 \end{itemize}
1697
1698
1699 \begin{dispExample}%
1700 totalpages is associated to the \textcolor{blue}{\textbf{\GetDriverCounter{newtotalpages}}} counter.
1701 % Try with an undefined counter name
1702 humptydumpty is associated to the \textcolor{blue}{\textbf{\GetDriverCounter{humptydumpty}}} counter.
1703
1704 \end{dispExample}%
1705
1706 \end{docCommand}%
1707
1708
1709 \begin{docCommand}{IsAssociatedCounter}{\marg{counter name}\marg{True branch}\marg{False branch}}%
1710
1711 This commands tests, whether a given counter name is an associated counter and expands correspondingly the true or the false branch. The command does not tell to which driver the counter it is associated -- this information can be obtained by \refCom{GetDriverCounter}.
1712
1713 \begin{docCommandArgs}{IfAssociatedCounter}%
1714
1715 \begin{codeoptionsenum}
1716 \item \marg{counter name}%
1717
1718 Contains the name of the possibly associated counter
1719
1720 \item \marg{True branch}
1721
1722 This code is expanded if the counter is associated to a driver, otherwise it is ignored
1723
1724 \item \marg{True branch}
1725
1726 This code is expanded if the counter is \textbf{not} associated a driver, otherwise it is ignored
1727
1728 \end{codeoptionsenum}
1729 \end{docCommandArgs}
1730
1731
1732 \begin{dispExample}
1733 \IsAssociatedCounter{section}{Yes, section is an associated counter}{No, section counter does not have the associated counter properties}
1734 \IsAssociatedCounter{newtotalpages}{Yes, totalpages is an associated counter}{No, totalpages counter does not have the associated counter properties}
1735 \end{dispExample}
1736
1737 \end{docCommand}%
1738
1739
1740
1741 \begin{docCommand}{IsDriverCounter}{\marg{driver counter name}\marg{True branch}\marg{False branch}}%
1742
1743 This commands tests, whether a given counter name is a driver counter and expands correspondingly the true or the false branch.
1744
1745 \begin{docCommandArgs}{IfDriverCounter}%
1746
1747 \begin{codeoptionsenum}
1748 \item \marg{driver counter name}%
1749
1750 Contains the name of the possible driver counter
1751
1752 \item \marg{True branch}
1753
1754 This code is expanded if the counter is a driver, otherwise it is ignored
1755
1756 \item \marg{True branch}
1757
1758 This code is expanded if the counter is \textbf{not} a driver, otherwise it is ignored
1759 \end{codeoptionsenum}
1760 \end{docCommandArgs}
1761
1762
1763 \begin{dispExample}
1764 \IsDriverCounter{section}{Yes, section is a driver counter}{No, section counter does not have driver properties}
1765 \end{dispExample}
1766
1767 \end{docCommand}%
1768
1769
1770 %\section{Backup and restoration features}
1771
1772 \section[Counter backup/restoration]{Backup and restore of counter values}\CHDocNew{1.0}\label{section::new_backuprestore}
1773
1774 \begin{marker}
1775 This feature is currently disabled!
1776 \end{marker}
1777
1778 \section{Coupled counters}\label{sec::coupledcounters}\CHDocNew{0.5}
1779
1780 \begin{marker}
1781 The features described here are very experimental and not fully implemented so far.
1782 \end{marker}
1783
1784 Occasionally there are requests where the figure or table environment should use the same counter in the sense of using continued counter values, e.g figure 1 is followed by table 2, the next figure is numbered as 3 etc.
1785
1786 This can be achieved with the concept of coupled counters. As usual, those counters belonging to a 'group' should be declared first in the preamble. In some sense coupled counters are similar to associated counters.
1787
1788 \subsection[Common options for coupled counters]{Common options for most of the coupled counter macros}\label{subsection:options_coupledcounters}
1789
1790 \begin{docKey}{name}{=\meta{name of a group}}{}\CHDocNew{0.6}
1791 This option has the name of the counter group that should be coupled, say ``figuretablegroup'' etc.
1792 \end{docKey}
1793
1794 \begin{docKey}{multiple}{=\meta{true,false}}{initially false}\CHDocNew{0.6}
1795 This option allows to add a counter multiple times to a counter group. In general, using this style is not recommended.
1796 \end{docKey}
1797
1798 \subsection[Macros for coupled counters]{Macros for declaring, adding and removing coupled counters}
1799
1800
1801
1802 \begin{docCommand}{DeclareCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\CHDocNew{0.5}
1803 \begin{codeoptionsenum}
1804 \item \oarg{options}: See \cref{subsection:options_coupledcounters} for a explanation about available options.
1805 \item \marg{counter name 1, counter name2, \dots}: The list of counters that should should be stepped together for the given counter group.
1806 \end{codeoptionsenum}
1807
1808 This macro is a preamble-only command.
1809
1810 \end{docCommand}
1811
1812 \begin{docCommand}{DeclareCoupledCountersGroup}{\marg{counter group name}}\CHDocNew{0.5}
1813 This macro defines a name for a counter group and allocates a new group list for the counter names. If the name already exists, nothing is done.
1814 \begin{codeoptionsenum}
1815 \item \marg{counter group name}: The name of the counter group.
1816 \end{codeoptionsenum}
1817
1818 This macro is a preamble-only command and does not add counters to the group container. Use \refCom{DeclareCoupledCounters} or \refCom{AddCoupledCounters} to add counters to the relevant group.
1819
1820 \end{docCommand}
1821
1822 \begin{docCommand}{RemoveCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\CHDocNew{0.5}
1823
1824 This removes the comma separated counter names from the coupled counter list given in the \refKey{name} option.
1825 \begin{codeoptionsenum}
1826 \item \oarg{options}: As of version \packageversion{} the only recognized option is \refKey{name}.
1827 \item \marg{counter name 1, counter name2, \dots}: The list of counters that should should removed from the given counter group.
1828 \end{codeoptionsenum}
1829
1830 \begin{marker}
1831 \begin{itemize}
1832 \item The list name itself is still available
1833 \item If the list given by the \refKey{name} option does not exist, \refCom{RemoveCoupledCounters} issues a warning on the console and ignores this list then.
1834 \end{itemize}
1835 \end{marker}
1836
1837 If all counters from a group name should be removed, this is equal to clearing -- just use \refCom{ClearCoupledCounters} for simpler usage of this feature.
1838
1839 \end{docCommand}
1840
1841 \begin{docCommand}{AddCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\CHDocNew{0.5}
1842 \CHDocUpdate{0.6}
1843 This adds the listed counter names to coupled counter list. It acts like \refCom{DeclareCoupledCounters}, but does not setup new counter groups. Please use \refCom{DeclareCoupledCounters} first, then apply \cs{AddCoupledCounters} later on.
1844
1845
1846 \begin{codeoptionsenum}
1847 \item \oarg{options}: See \cref{subsection:options_coupledcounters} for a explanation about available options.
1848 \item \marg{counter name 1, counter name2, \dots}: The list of counters that should should be stepped together for the given counter group.
1849 \end{codeoptionsenum}
1850 \begin{marker}
1851 If the list given by the \refKey{name} option does not exist, \refCom{AddCoupledCounters} issues a warning on the console and ignores this list then. The counters are not added to any list at all.
1852 \end{marker}
1853
1854
1855 \end{docCommand}
1856
1857 \begin{docCommand}{ClearCoupledCounters}{\marg{options}}\CHDocNew{0.6}
1858 This removes all names from the given name of a group of coupled counters.
1859 \begin{codeoptionsenum}
1860 \item \oarg{options}: As of version \packageversion{} the only recognized option is \refKey{name}.
1861 \end{codeoptionsenum}
1862 After clearing a list, the coupling stops for the counters on that list (unless they are part of another list, which is possible, but not recommended). using \refCom{AddCoupledCounters} with the relevant \refKey{name} option adds counters again to the list and the coupling is active again, however, for different counters (eventually).
1863
1864 In order to clear all coupled counter lists, use \refCom{ClearAllCoupledCounters} instead.
1865
1866 \begin{marker}
1867 \begin{itemize}
1868 \item The list name itself is still available
1869 \item If the list given by the \refKey{name} option does not exist, \refCom{ClearCoupledCounters} issues a warning on the console and ignores this list then.
1870 \end{itemize}
1871 \end{marker}
1872 \end{docCommand}
1873
1874
1875 \begin{docCommand}{ClearAllCoupledCounters}{}\CHDocNew{0.6}
1876 This removes all coupled counter groups, but not the group names, i.e. the list names can be used later on to add counter names again. In order to clear a specific list, use \refCom{ClearCoupledCounters}.
1877 \end{docCommand}
1878
1879
1880 \begin{docCommand}{IsCoupledCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}\CHDocNew{0.6}
1881 This macro tests if a counter is under the administration of the coupled counter commands and expands to the relevant branch then. There are two short-circuit commands \refCom{IsCoupledCounterT} and \refCom{IsCoupledCounterF}.
1882 \end{docCommand}
1883
1884 \begin{docCommand}{IsCoupledCounterT}{\marg{counter name}\marg{true branch}}\CHDocNew{0.6}
1885 This macro tests if a counter is under the administration of the coupled counter commands and executes the true branch then. There are two related commands \refCom{IsCoupledCounterTF} and \refCom{IsCoupledCounterF}.
1886 \end{docCommand}
1887
1888 \begin{docCommand}{IsCoupledCounterF}{\marg{counter name}\marg{false branch}}\CHDocNew{0.6}
1889 This macro tests if a counter is under the administration of the coupled counter commands and executes the false branch then if this is not the case. There are two related commands \refCom{IsCoupledCounterTF} and \refCom{IsCoupledCounterT}.
1890 \end{docCommand}
1891
1892 \clearpage
1893 \section{Periodic counters}\label{section:periodic_counters}\CHDocNew{0.9}
1894
1895
1896 It might be very convenient to have counters that are automatically reset not only by a driving counter such as \CHDocCounter*{chapter} but also periodically, i.e. after a certain amount of steps -- this can be achieved with the concept of periodic counters.
1897
1898 \subsection{Commands related to periodic counters setup}
1899
1900 \begin{docCommand}[before={\CHDocNew{0.9}}]{DeclarePeriodicCounter}{\oarg{}\marg{counter name}\marg{counter treshold value}}
1901 This defines the counter given in the first mandatory argument as a periodic counter and is automatically reset if the treshold value is reached.
1902
1903 \begin{marker}
1904 The command \refCom{DeclarePeriodicCounter} does not define a new counter, however but is the preamble-only version of \refCom{AddPeriodicCounter}.
1905 \end{marker}
1906
1907 Please note that in case of \cs{addtocounter} applied to a periodic counter the value to be added leads to a modulo division such that the counter might be reset if the addition would increase the counter beyond the treshold value, the module part will be added then. In order to prevent this wrapping, use the \refKey{wrap} option to \refCom{addtocounter}:
1908
1909 \begin{dispExample}
1910 \setcounter{foocntr}{3}%
1911 \AddPeriodicCounter{foocntr}{8}%
1912
1913 Value of foocntr is: \thefoocntr % Should be 3
1914
1915 \addtocounter{foocntr}{20} % Is it 23? No, it is 23 % 8 = 7
1916 Value of foocntr is \thefoocntr\ now!
1917
1918 Adding a value of 4 again:
1919 \addtocounter{foocntr}{4} % Is it 11? No, it is 11 % 8 = 3
1920 Value of foocntr is \thefoocntr\ now!
1921
1922 Now prevent the wrapping
1923 \addtocounter{foocntr}{10}[wrap=false] % Is it 13? Yes, it is!
1924 Value of foocntr is \thefoocntr\ now!
1925
1926 \end{dispExample}
1927 \end{docCommand}
1928
1929 \begin{docCommand}[before={\CHDocNew{0.9}}]{AddPeriodicCounter}{\oarg{}\marg{counter name}\marg{counter treshold value}}
1930 This defines the counter given in the first mandatory argument as a periodic counter and is automatically reset if the treshold value is reached.
1931 \end{docCommand}
1932
1933
1934 \begin{docCommand}[before={\CHDocNew{0.9}}]{RemovePeriodicCounter}{\oarg{options}\marg{counter name}}
1935 This removes the counter given in the first mandatory argument as a periodic counter. The counter is reset unless the \refKey{reset} is set to \meta{false}.
1936
1937 \begin{codeoptionsenum}
1938 \item \oarg{options}
1939
1940 As of version \packageversion, there is only one option:
1941
1942 \begin{docKey}[][before={\CHDocNew{0.9}}]{reset}{=\meta{true/false}}{initially true}
1943 Use `false` to prevent the resetting of the relevant counter after removal!
1944 \end{docKey}
1945 \item \marg{counter name} -- the name of the counter that should be no periodic counter any longer.
1946 \end{codeoptionsenum}
1947
1948 If all periodic counters should be removed, use the macro \refCom{RemoveAllPeriodicCounters} instead.
1949
1950 \end{docCommand}
1951
1952 \begin{docCommand}[before={\CHDocNew{1.0}}]{RemoveAllPeriodicCounters}{\oarg{options}}
1953 This command removes all counters given in the first mandatory argument as a periodic counter. All counters are reset unless the \refKey{reset} option is set to \meta{false}.
1954
1955 \begin{codeoptionsenum}
1956 \item \oarg{options}
1957 As of version \packageversion, there is only one option: \refKey{reset}, having the same meaning as in \refCom{RemovePeriodicCounter}.
1958 \item \marg{counter name} -- the name of the counter that should be no periodic counter any longer.
1959 \end{codeoptionsenum}
1960
1961 If only a specific counter shall be removed from the periodic counter property use the command \refCom{RemovePeriodicCounter} instead.
1962
1963 \end{docCommand}
1964
1965
1966 \begin{docCommand}[before={\CHDocNew{0.9}}]{ChangePeriodicCounterCondition}{\oarg{options}\marg{counter name}\marg{new counter treshold value}}
1967 This changes the counter treshold condition -- the counter is reset automatically if not specified otherwise with the \refKey{reset} option.
1968
1969 \begin{codeoptionsenum}
1970 \item \oarg{options}
1971
1972 As of version \packageversion, there is only one option: \refKey{reset}, which serves the same functionality as in \refCom{RemovePeriodicCounter}.
1973 \item \marg{counter name} -- the name of the counter that should be no periodic counter any longer.
1974 \item \marg{new counter value treshold} -- the new value after which an automatic resetting will occur.
1975
1976 \end{codeoptionsenum}
1977
1978 \end{docCommand}
1979
1980 \subsection{Commands to query for periodic counter feature}
1981
1982
1983 \begin{docCommand}[after={\CHDocNew{0.9}\par}]{IsPeriodicCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
1984 This macro tests if a counter is under the administration of the periodic counter commands and expands to the relevant branch then. There are two short-circuit commands: \refCom{IsPeriodicCounterT} and \refCom{IsPeriodicCounterF}.
1985 \end{docCommand}
1986
1987 \begin{docCommand}[before={\CHDocNew{0.9}}]{IsPeriodicCounterT}{\marg{counter name}\marg{true branch}}
1988 This macro tests if a counter is under the administration of the periodic counter commands and expands to the \meta{true} branch then. There are two related commands: \refCom{IsPeriodicCounterTF} and \refCom{IsPeriodicCounterF}.
1989 \end{docCommand}
1990
1991 \begin{docCommand}[before={\CHDocNew{0.9}}]{IsPeriodicCounterF}{\marg{counter name}\marg{false branch}}
1992 This macro tests if a counter is under the administration of the periodic counter commands and expands to the \meta{false} branch then if this is not the case. There are two related commands: \refCom{IsPeriodicCounterTF} and \refCom{IsPeriodicCounterT}.
1993 \end{docCommand}
1994
1995
1996
1997 \section[Suspending and Resuming]{Suspending and resuming (associated) counters}\label{section::suspendedresumedcounters}
1998
1999
2000
2001 Rather than removing an associated counter from the list, it is possible to suspend the automatic stepping for a while and then resume it (or completely drop it), for example, if the value of a counter should not be stepped within a specific chapter etc.
2002
2003
2004
2005 \begin{marker}[before=\CHDocNew{0.8}\par]
2006 Suspension and resuming counters can cause wrong hyper links if \CHDocPackage{hyperref} is used.
2007 \end{marker}
2008
2009 \subsection{Macros for suspension and resume}
2010
2011 \begin{docCommand}{SuspendCounters}{\oarg{options}\marg{counters list}}%
2012 \begin{docCommandArgs}{SuspendCounters}%
2013
2014 \begin{codeoptionsenum}
2015 \item \oarg{options}%
2016
2017 Not used so far, reserved for later usage.
2018
2019 \item \marg{counters list}%
2020
2021 Contains the name of counters to be suspended, separated by commas (CSV - list)
2022 \end{codeoptionsenum}
2023 \end{docCommandArgs}
2024 \end{docCommand}%
2025
2026 \begin{docCommand}{CascadeSuspendCounters}{\oarg{options}\marg{counters list}}\CHDocNew{0.8}
2027
2028 This macro is more powerful than \refCom{SuspendCounters}, since it tries to detect whether a counter has a reset list and 'mutes' the counters on this list as well and checks whether those counters themselves have reset lists and cascades down to the final state.
2029
2030 \begin{marker}
2031 Stated differently: All counters anyhow connected to a counter named \CHDocCounter{foo} will be suspended, e.g. for the \CHDocClass{book} class and \CHDocCounter{chapter}, this means in a standard setup, that \CHDocCounter*{section,figure,table,equation,footnote} will be suspended, as well as in consequence \CHDocCounter*{subsection,subsubsection,paragraph,subparagraph}, assuming hereby no other counters have been added to the reset lists.
2032 \end{marker}
2033
2034
2035 \begin{docCommandArgs}{CascadeSuspendCounters}%
2036
2037 \begin{codeoptionsenum}
2038 \item \oarg{options}%
2039
2040 Not used so far, reserved for later usage.
2041
2042 \item \marg{counters list}%
2043
2044 Contains the name of counters to be suspended, separated by commas (CSV - list)
2045 \end{codeoptionsenum}
2046 \end{docCommandArgs}
2047 \end{docCommand}%
2048
2049
2050 \begin{docCommand}{ResumeSuspendedCounters}{\oarg{options}\marg{counters list}}
2051 As of version \packageversion\ the optional argument is not used and reserved for later purposes.
2052 This command revokes the suspension of the counters in the \marg{counters} list.
2053 \end{docCommand}
2054
2055 \begin{docCommand}{ResumeAllSuspendedCounters}{\oarg{options}} \CHDocNew{0.8}
2056 As of version \packageversion\ the optional argument is not used and reserved for later purposes.
2057 This command revokes all suspended counters.
2058 \end{docCommand}
2059
2060
2061 \subsection{Query suspension}
2062 \begin{docCommand}[before={\CHDocNew{0.1}}\par]{IsSuspendedCounter}{\marg{counter name}\marg{true branch}\marg{false branch}}
2063 See \nameref{section::suspendedresumedcounters} on this topic.
2064
2065 This command checks, whether a counter is suspended, i.e. not updated at all and expands the corresponding branches.
2066
2067 %\begin{docCommandArgs}{IfSuspendedCounter}%
2068
2069 \begin{codeoptionsenum}
2070 \item \marg{counter name}%
2071
2072 Contains the name of counter presumed to be suspended
2073
2074 \item \marg{True branch}
2075
2076 This code is expanded if the counter is suspended, otherwise it is ignored
2077
2078 \item \marg{True branch}
2079
2080 This code is expanded if the counter is \textbf{not} suspended, otherwise it is ignored
2081
2082 \end{codeoptionsenum}
2083 %\end{docCommandArgs}
2084
2085
2086 \end{docCommand}
2087
2088
2089
2090 \begin{marker}
2091 If a driver counter is suspended, all counters associated to it are suspended too!
2092 \end{marker}
2093
2094 \setcounter{totalequations}{0}
2095 \setcounter{equation}{0}
2096 \renewcommand{\DeclareAssociatedCounters}[3][]{\relax}%
2097 \begin{dispExample}
2098 \textbf{This example shows 4 equations, but only two of them are counted}
2099
2100 \begin{equation}
2101 E_{0} = mc^2
2102 \end{equation}
2103
2104 Now suspend the equations:
2105
2106 \SuspendCounters{equation}
2107 \begin{equation}
2108 E^2 = \left({ pc}\right)^2 + E^{2}_{0}
2109 \end{equation}
2110
2111 \begin{equation}
2112 m(v) = \frac{m_{0}}{\sqrt{1-\frac{v^2}{c^2}}}
2113 \end{equation}
2114
2115 And resume it: \ResumeSuspendedCounters{equation}
2116
2117 \begin{equation}
2118 E = h \nu
2119 \end{equation}
2120
2121 There are \number\totvalue{totalequations}~equations in here!
2122
2123 \end{dispExample}
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133 \section{Total counters}\tcbdocmarginnote{\tcbdocnew{2015-11-27}}\label{sec::totalcounters}
2134
2135
2136
2137 Similarly to the package \CHDocPackage{totcount} or the features of \CHDocPackage{totalcount} by Axel Sommerfeldt this package provides the possibility of defining a counter that stores its finally value to the auxiliary file and starts from this value then, if not set otherwise to another value.
2138
2139 The declaration of a total counter is a preamble - only event and \refCom{DeclareTotalDocumentCounter} is a preamble-only command in order to prevent counter register confusion. If a certain existing counter should be treated with total counter features, use \refCom{RegisterTotalDocumentCounter} instead.
2140
2141 Use \refCom{NewTotalDocumentCounter} only in rare cases, if a total counter must be defined within the document body.
2142
2143 \begin{marker}
2144 \tcbdocmarginnote{\bcbombe}The standard \LaTeXe\ commands \cs{stepcounter}, \cs{addtocounter} and \cs{setcounter} support the specification of a total counter, but \cs{refstepcounter} will fail since the usage of a total counter for labelling purposes is most probably of no use (as of version \packageversion)
2145 \end{marker}
2146
2147 \subsection{Defining total counters}
2148
2149 \begin{docCommand}{RegisterTotalDocumentCounter}{\oarg{options}\marg{total counter name}}\CHDocNew{0.5}
2150 \begin{codeoptionsenum}
2151 \item \oarg{options}: As of version \packageversion, only this option is used
2152 \begin{docKey}{supertotal}{=\meta{true,false}}{false}
2153 Set this key to switch the super total counter on or off.
2154 \end{docKey}
2155 \item \marg{total counter name}: The name of the total counter. This must be the same like the name of an already existing counter. Internally another counter is defined which has a prefix to prevent name clashes with counter names defined by the package \CHDocPackage{totalcount}. If the counter name does not exist, the compilation exits with an error message.
2156 \end{codeoptionsenum}
2157
2158
2159 \end{docCommand}
2160
2161
2162
2163
2164 \begin{docCommand}{TotalCounterInternalName}{\marg{counter name}}
2165 This command reports the internal name of a total counter or the usual name if this counter is not a total one.
2166 \end{docCommand}
2167
2168 \begin{dispExample}
2169 \TotalCounterInternalName{chapter}
2170
2171 \TotalCounterInternalName{foototal}
2172 \end{dispExample}
2173
2174 \begin{docCommand}[before={\CHDocExpCommand\par\CHDocNew{1.0}}]{TotalCounterInternalNameExp}{\marg{counter name}}
2175 This command is the expandable version of \refCom{TotalCounterInternalName}
2176 \end{docCommand}
2177
2178
2179 \stepcounter{foototal}
2180
2181 \begin{docCommand}[before={\CHDocExpCommand}]{TotalValue}{\marg{counter name}}\CHDocUpdate{0.9}%
2182 This command prints the value of a total counter or falls back to the value of the counter if this is not a total counter.
2183
2184 \begin{dispExample}
2185 ``Total'' value of the section non-total counter: \TotalValue{section}
2186
2187 Total value of the foototal total counter: \TotalValue{foototal}
2188 \end{dispExample}
2189
2190
2191 \end{docCommand}
2192
2193 \subsection{Queries about total counters}
2194
2195 \begin{docCommand}{IsTotalCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
2196 This macro tests if a counter is under the administration of the total counter commands and expands to the relevant branch then. There are two short-circuit commands \refCom{IsTotalCounterT} and \refCom{IsTotalCounterF}.
2197 \end{docCommand}
2198
2199
2200
2201
2202 \begin{docCommand}{IsTotalCounterT}{\marg{counter name}\marg{true branch}}
2203 This macro checks if a counter is under the administration of the total counter commands and expands to the code in the second argument if this is true.
2204 \end{docCommand}
2205
2206
2207 \begin{docCommand}{IsTotalCounterF}{\marg{counter name}\marg{false branch}}
2208 This macro checks if a counter is under the administration of the total counter commands and expands to the code in the second argument if this is not the case.
2209 \end{docCommand}
2210
2211 \begin{dispExample}
2212 \IsTotalCounterTF{foototal}{Yes, this is a total counter}{No, this is no total counter}
2213
2214 \IsTotalCounterTF{section}{Yes, this is a total counter}{No, this is no total counter}
2215
2216 \IsTotalCounterT{foototal}{Yes, this is a total counter}
2217
2218 \IsTotalCounterF{page}{No, page isn't a total counter}
2219
2220 \end{dispExample}
2221
2222 \begin{marker}
2223 The features of using other \CHDocFiles{aux} files or a different external file as provided by \CHDocPackage{totcount} is not (yet) support as of version \packageversion.
2224 \end{marker}
2225
2226
2227
2228 \section{Super total counters}\label{section:supertotalcounters} \tcbdocmarginnote{\tcbdocnew{2015-11-25}}
2229 In addition to the concept of a total counter, there is also the possibility of using super total counters -- those counters survive the reset at the beginning of a compilation, i.e. the value of a super total counter might be stepped in each run and as such the number of compilation runs etc. can be tracked. The values of the last run are persistent as long as the \CHDocFileExt{.aux} file isn't deleted.
2230
2231 \subsection{Defining super total counters}
2232
2233 \begin{docCommand}{NewTotalDocumentCounter}{\oarg{options}\marg{total counter name1, total counter name2,\dots}}
2234 This macro defines a new counter (which mustn't exist before of course) and puts it under control of the total counter features.
2235 \begin{codeoptionsenum}
2236 \item \oarg{options}: As of version \packageversion, only this option is used
2237
2238 \refKey{supertotal} -- this has the same meaning as in \refCom{RegisterTotalDocumentCounter} and defaults to \texttt{false}.
2239
2240 \item \marg{total counter name1, total counter name2,\dots}: The names of the total counter, separated by a comma. This must not be the same like the name of any already existing counter. Internally another counter is defined which has a prefix to prevent name clashes with counter names defined by the package \CHDocPackage{totcount}.
2241 \end{codeoptionsenum}
2242
2243 \end{docCommand}
2244
2245 \begin{docCommand}{DeclareTotalDocumentCounter}{\oarg{options}\marg{total counter name1, total counter name2,\dots}}
2246
2247 This is the preamble - only version of \refCom{NewTotalDocumentCounter} and should be preferred in most cases over that command.
2248
2249 If an already existing counter should be tracked with total counter features,
2250 use \refCom{RegisterTotalDocumentCounter} instead.
2251
2252 \CHDocUpdate{1.2}This command allows multiple counters (specified as a comma separated list) to be defined at once.
2253
2254 \end{docCommand}
2255
2256
2257 \subsection{Queryies about super total counters}
2258
2259 \begin{docCommand}{IsSuperTotalCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
2260 This macro tests if a counter is under the administration of the super total counter commands and expands to the relevant branch then. There are two short-circuit commands \refCom{IsSuperTotalCounterT} and \refCom{IsSuperTotalCounterF}.
2261 \end{docCommand}
2262
2263
2264
2265
2266 \begin{docCommand}{IsSuperTotalCounterT}{\marg{counter name}\marg{true branch}}
2267 This macro checks if a counter is under the administration of the super total counter commands and expands to the code in the second argument if this is true.
2268 \end{docCommand}
2269
2270
2271 \begin{docCommand}{IsSuperTotalCounterF}{\marg{counter name}\marg{false branch}}
2272 This macro checks if a counter is under the administration of the super total counter commands and expands to the code in the second argument if this is not the case.
2273 \end{docCommand}
2274
2275
2276 \begin{dispExample}
2277 \IsSuperTotalCounterTF{numberofruns}{Yes, this is a super total counter}{No, this is no super total counter}
2278
2279 \IsSuperTotalCounterT{numberofruns}{Yes, this is a super total counter}
2280
2281 \IsSuperTotalCounterTF{chapter}{Yes, this is a total counter}{No, this is no super total counter}
2282 \end{dispExample}
2283
2284 \subsection{The \CHDocCounter{numberofruns} counter}\label{subsection:numberofruns}
2285
2286 This package adds a counter of its own: \CHDocCounter{numberofruns} which is a super total counter and is stepped each compilation run. It's added in \cs{AtBeginDocument} and can be retrieved with \refCom{TotalValue}. Use the \refKey{nonumberofruns} package option to prevent the definition of this counter.
2287
2288
2289
2290 \section{Experimental features}\label{subsec::associated_counters_experimental}
2291
2292
2293 \begin{marker}
2294 \marginnote{\bcbombe}
2295 The content here is only of experimental nature and there is no guarantee that the feature will be maintained in future releases.
2296 \end{marker}
2297
2298
2299 \subsection{Labels}
2300
2301
2302
2303 \begin{marker}
2304 To enable the redefined \refCom{label} macro, specify the package option \refKey{redefinelabel}
2305 \end{marker}
2306
2307
2308
2309 \begin{docCommand}[before={\CHDocNew{1.2}}]{label}{\oarg{cleveref-counter-overrule}\marg{label name}\oarg{options for associated counters}}
2310 \begin{docKey}{all}{=\meta{true,false}}{initially \meta{false}}\CHDocNew{1.2}
2311 This will enable that all associated counters to a driver counter will cause the generation of a label too. By default this option is \meta{false}.
2312 This option deliberately overrules \refKey{select}, the value of the option \refKey{prefix} is disregarded.
2313 \end{docKey}
2314 \begin{docKey}{select}{={counter1, counter2,\dots}}{initially empty}\CHDocNew{1.2}
2315 Select only some of the associated counters to be able to be labeled.
2316 As of version \packageversion{} there is no check whether the given names refer to counters at all or are associated counters to the last counter that has been used with \cs{refstepcounter}.
2317 \end{docKey}
2318 \begin{docKey}{prefix}{=\meta{text}}{initially empty}\CHDocNew{1.2}
2319 This gives the prefix of the label of the associated counter. If the option \refKey{all} is enabled, the label name is generated from the name of the associated counter, the value of \refKey{prefix-sep} and the value of the 2nd argument.
2320 \newcounter{morefoobar}
2321 \begin{dispExample*}{listing only}
2322 % Assume that some counter has the associated counters foobar, morefoobar and yetanotherfoobar
2323 \label{foo}[prefix=assoc,all]
2324 \end{dispExample*}
2325 will cause a label named \texttt{foobar::foo}, \texttt{morefoobar::foo} and \texttt{yetanotherfoobar::foo}, whereas
2326 \begin{dispExample*}{listing only}
2327 \label{foo}[prefix=assoc,select=morefoobar]
2328 \end{dispExample*}
2329 would generate the label \texttt{assocc::foobar} only and will be tied to the value of the counter \texttt{morefoobar}
2330 \end{docKey}
2331 \begin{docKey}{prefix-sep}{=\meta{text}}{initially ::}\CHDocNew{1.2}
2332 Defines the separator between the \refKey{prefix} and the label name for the driver counter, i.e. the 2nd argument of the \refCom{label} command.
2333 \end{docKey}
2334 \end{docCommand}
2335
2336
2337 \begin{marker}
2338 \marginnote{\bcbombe}
2339 If the package option \refKey{redefinelabel} is set to \meta{false}, the usage of the third optional argument will leave spurious content at the position \cs{label} was used. The reason is that the content of third optional argument with \texttt{[]} is not recognized as an argument any longer.
2340 \end{marker}
2341
2342
2343 \begin{docCommand}[before={\CHDocNew{1.3}}]{LaTeXLabel}{\oarg{cleveref-counter-overrule}\marg{label name}}
2344 This is the default label macro, either with the \CHDocPackage{cleveref} extension or the classical \LaTeX2e\ macro (eventually modified by \CHDocPackage{hyperref}) and is not modified by this package.
2345
2346
2347 The feature of label hooks from \refCom{RegisterPreLabelHook} or \refCom{RegisterPostLabelHook} is not used here.
2348 \end{docCommand}
2349
2350
2351 \subsection{Hooks}
2352
2353
2354 This feature is experimental and only realized for the modified \refCom{label} command until now. See \nolinkurl{xassoccnt_getparentcounter_example.tex} as an example of usage.
2355
2356 \begin{docCommand}[before={\CHDocNew{1.3}}]{RegisterPreLabelHook}{\marg{command name1, command name2,\dots}}
2357
2358 This macro declares a possible list of hooks (commands) that should be executed \textbf{before} the traditional \cs{label} command is applied. If the hook name refers to some unknown macro, nothing is done.
2359
2360 The hook names must be given with the \textbackslash\ as command sequence indicator, i.e. \cs{zlabel}, more than one macro name is possible by using comma as separator.
2361
2362 As of version \packageversion\ the hook macro does not allow more than one argument, which is automatically used from the surrounding \cs{label} call and is the usual label name.
2363
2364
2365 \end{docCommand}
2366
2367 \begin{docCommand}[before={\CHDocNew{1.3}}]{RegisterPostLabelHook}{\marg{command name1, command name2,\dots}}
2368
2369 This macro declares a possible list of hooks (commands) that should be executed after the traditional \cs{label} command is applied. If the hook name refers to some unknown macro, nothing is done.
2370
2371 The hook names must be given with the \textbackslash\ as command sequence indicator, i.e. \cs{zlabel}, more than one macro name is possible by using comma as separator.
2372
2373 As of version \packageversion\ the hook macro does not allow more than one argument, which is automatically used from the surrounding \cs{label} call and is the usual label name.
2374
2375 \end{docCommand}
2376
2377
2378
2379
2380
2381 \clearpage
2382 \part{Meta-Information}
2383
2384 \parttoc
2385
2386 \clearpage
2387 \section{To - Do list}
2388
2389 \begin{itemize}
2390 \item Merging of counter groups, removing counters from counter groups
2391 \item Backup and restoration of individual counters not being member of a counter group
2392 \item Switch to the container support for all features -- this is a major task and will be done in (tiny) steps.
2393 \item Better counter definition/copy counter routines \(\longrightarrow\) another package perhaps
2394 \item More examples
2395 \item Some macro names might be non-intuitive
2396 \item Improve documentation
2397 \item Hooks for conditionals on \CHDocCounter*{numberofruns} (see \cref{subsection:numberofruns})
2398
2399
2400 \end{itemize}
2401
2402 Some issues that have been addressed partially are:
2403
2404 \begin{itemize}
2405 \item \CHDocNew{1.0} Add counter group support for the \CHDocTag{backup} feature, i.e. define a symbolic name for a group of counters that should be controlled by the backup feature. This will allow multiple backup groups, which might be necessary.
2406 \end{itemize}
2407
2408
2409 If you
2410
2411 \begin{itemize}
2412 \item find bugs
2413 \item errors in the documentation
2414 \item have suggestions
2415 \item have feature requests
2416 \end{itemize}
2417
2418 don't hesitate and contact me using my mail address: \mymailtoaddress.
2419
2420 \clearpage
2421
2422 \section{Acknowledgments}
2423
2424 I would like to express my gratitudes to the developers of fine \LaTeX{} packages and of course
2425 to the users at tex.stackexchange.com, especially to
2426
2427 \begin{itemize}
2428 \item Paulo Roberto Massa Cereda
2429 \item Enrico Gregorio
2430 \item Joseph Wright
2431 \item David Carlisle
2432 \end{itemize}
2433
2434 and many others for their invaluable help on many questions on macros.
2435
2436 \vspace{2\baselineskip}
2437 \begin{marker}
2438 A special gratitude goes to Prof. Dr. Dr. Thomas Sturm for providing the wonderful \CHDocPackage{tcolorbox} package which was used to
2439 write this documentation.
2440 \end{marker}
2441
2442 \clearpage
2443
2444 \section{Version history}
2445
2446
2447 \begin{itemize}[itemsep=15pt]
2448
2449 \item \CHDocFullVersion{2.0}
2450 \begin{itemize}
2451 \item Last release due to changes in \LaTeX3-Kernel and switching to unmaintained state.
2452 \end{itemize}
2453
2454
2455 \item \CHDocFullVersion{1.8}
2456 \begin{itemize}
2457 \item Maintenance update due to updates to \CHDocPackage{expl3}.
2458
2459 Changed from \verb!\c_one! to \verb!\c_one_int! and \verb!\c_zero! to \verb!\c_zero_int!
2460 \end{itemize}
2461
2462 \item \CHDocFullVersion{1.7}
2463 \begin{itemize}
2464 \item Maintenance update due to updates to \CHDocPackage{expl3}.
2465
2466 Changed from \verb!\c_minus_one! to an explizit \texttt{-1}
2467 \end{itemize}
2468
2469
2470 \item \CHDocFullVersion{1.6}
2471 \begin{itemize}
2472 \item Maintenance update due to updates to \CHDocPackage{expl3}
2473 \item The Backup/Restore feature is currently broken and needs a thorough inspection
2474 \end{itemize}
2475
2476 \item \CHDocFullVersion{1.5}
2477
2478 Added \refCom{LastRefSteppedCounter} as dummy version which expands to nothing as long as \cs{refstepcounter} has not been called.
2479
2480 \item \CHDocFullVersion{1.4}
2481
2482 \begin{itemize}
2483 \item Improved the core macros \cs{refstepcounter} and \cs{stepcounter} in order to fit the \CHDocPackage{expl3} and \CHDocPackage{xparse} changes of Februar - April 2017.
2484 \item Added following experimental features:
2485 \item \refCom{CounterFormat} with quick and possible recursive change of the counter output
2486 \item \refCom{StoreCounterFormats}, \refCom{AddCounterFormats} and \refCom{RemoveCounterFormats} for defining own short hand counter formats.
2487 \item Provided the macros \refCom{xalphalph} and \refCom{xAlphAlph} in order to allow counter output in the same manner as the \CHDocPackage{alphalph} does.
2488 \item Added the macros \refCom{CounterWithin}, \refCom{CounterWithin*}, \refCom{CounterWithout} and \refCom{CounterWithout*} which provides a quicker access to add or remove counters from the reset list and changing the corresponding \cs{the...} macros.
2489 \item Provided the \refCom{LoopCounterResetList} to perform the same action on all counters being in the reset list of a given counter.
2490 \item New macros \refCom{ClearCounterResetList} and \refCom{ClearCounterResetList*} to remove all counters on first level of a driver counter.
2491 \item Added the explanation (missing in previous versions) to the documentation that the \refCom{AddToReset}, \refCom{RemoveFromReset} and \refCom{RemoveFromFullReset} macros actually support a comma separated list of counter names for the first argument.
2492 \end{itemize}
2493
2494 \item \CHDocFullVersion{1.3}
2495 \begin{itemize}
2496 \item Provided the \refCom{LaTeXLabel} macro to access the non-xassoccnt version of the \refCom{label} command.
2497 \item \CHDocExperimentalFeature Added the concept of label hooks, see \cref{subsec::associated_counters_experimental} for more information.
2498 \item The macros \cs{Last...} are defined with \CHDocPackage{expl3} methods.
2499 \item Added \refCom{GetAllResetLists} and \refCom{GetParentCounter} for information on parent (or driver) counters.
2500 \end{itemize}
2501
2502 \item \CHDocFullVersion{1.2}
2503 \begin{itemize}
2504 \item Corrected some typos in the manual.
2505 \item The macros \refCom{NewDocumentCounter}, \refCom{DeclareDocumentCounter} and \refCom{NewTotalDocumentCounter} allow multiple counters to be specified and defined.
2506 \item Added the macro \refCom{DeclareTotalAssociatedCounters} in order to combine total counters and the associated feature, i.e. the counters are total ones and associated to a driver counter.
2507 \item \CHDocExperimentalFeature An extended version of \refCom{label} is provided to allow labels also for associated counters during the stepping process of the driver counter.
2508 \end{itemize}
2509
2510 \item \CHDocFullVersion{1.1}
2511 \begin{itemize}
2512 \item Added some missing basic functions needed after the more restrictive \CHDocPackage{expl3} update from 2016/10/19
2513 \item Added a statement about the requirement to load \CHDocPackage{tcolorbox} before \CHDocPackage{xassoccnt} in the documentation (i.e. this file!)
2514 \end{itemize}
2515 \item \CHDocFullVersion{1.0}
2516 \begin{itemize}
2517 \item \CHDocNew{1.0} Restructured the \CHDocPackage{xassoccnt} manual file.
2518 \item \CHDocNew{1.0} Added some improvements for counter reset lists macros
2519 \item \CHDocNew{1.0} Added new backup/restore features, with cascading counters possibility -- the old backup/restore macros are still available but renamed with a prefix \cs{Former...}
2520 \item \CHDocNew{1.0} Added the \refCom{RemoveAllPeriodicCounters} -- it was missing in the \CHDocTag{periodic counter} features -- see \nameref{section:periodic_counters} for more information on this.
2521 \item \CHDocNew{1.0} Added the expandable version of \refCom{TotalCounterInternalName} named
2522
2523 \refCom{TotalCounterInternalNameExp}.
2524 \end{itemize}
2525 \item \CHDocFullVersion{0.9}
2526 \begin{itemize}
2527 \item \CHDocUpdate{0.9}\refCom{TotalValue} is an expandable command now.
2528 \item \CHDocNew{0.9} Added the \CHDocTag{periodic counter} features -- see \nameref{section:periodic_counters} for more information on this.
2529 \end{itemize}
2530 \item \CHDocFullVersion{0.8}
2531 \begin{itemize}[label={$\checkmark$}]
2532 \item \CHDocUpdate{0.8}Fixed the \refCom{SuspendCounters} and \refCom{ResumeSuspendedCounters} macros -- the comma separated list of counters was not used (contrary to the purpose and the documentation description).
2533 \item \CHDocNew{0.8}Additions of commands
2534 \begin{itemize}[label={$\triangleright$}]
2535 \item \refCom{ResumeAllSuspendedCounters}
2536 \item \refCom{CascadeSuspendCounters}
2537 \item \refCom{DisplayResetList}
2538 \item \refCom{ShowResetList}
2539 \end{itemize}
2540 \end{itemize}
2541 \item \CHDocFullVersion{0.7}
2542 \leavevmode
2543 \begin{itemize}[label={$\checkmark$}]
2544 \item\CHDocUpdate{0.7} Fixed a small bug in the \CHDocPackage{\PackageDocName} version of \cs{stepcounter}
2545 \item Added some macros that support the output of binary, octal or hexadecimal (both lower/uppercase) values of counters. \CHDocNew{0.7}
2546 \item Added the \cs{Loop...Counters} macros that perform an action in loop on all given counter names. \CHDocNew{0.7}
2547 \end{itemize}
2548
2549 \item \CHDocFullVersion{0.6}
2550 \begin{itemize}[label={$\checkmark$}]
2551 \item The coupled counters allow to specify a counter group to which all relevant counters belong, this allows several coupled counter groups then \CHDocNew{0.6}
2552 \item Fixed a small bug within backup counter support -- the resetting was not done any more \CHDocNew{0.6}
2553 \item Added the \CHDocKey{nonumberofruns}\ package option.
2554 \end{itemize}
2555 \item
2556 \CHDocFullVersion{0.5}
2557 \begin{itemize}[label={$\checkmark$}]
2558 \item Added support (very experimental!) for the \CHDocTag{coupled counters} feature, see \cref{sec::coupledcounters} about this feature! \CHDocNew{0.5}
2559 \item Added \cs{RegisterTotalDocumentCounter} and improved \cs{TotalValue} support\CHDocNew{0.5}
2560 \end{itemize}
2561 \item
2562 \CHDocFullVersion{0.4}
2563 \begin{itemize}[label={$\checkmark$}]
2564 \item Added \cs{BackupCounterValues} and \cs{RestoreCounterValues} support\CHDocNew{0.4}
2565 \item Added \cs{StepDownCounter} and \cs{SubtractFromCounter} macros\CHDocNew{0.4}
2566 \end{itemize}
2567 \item
2568 \CHDocFullVersion{0.3}\CHDocUpdate{0.3}
2569 \begin{itemize}[label={$\checkmark$}]
2570 \item Added the \CHDocTag{totalcounter} features similar to the packages \CHDocPackage{totcount} or \CHDocPackage{totalcount} \tcbdocmarginnote{\tcbdocnew{2015-11-11}}
2571 \item Added the \CHDocTag{super total counter} features \tcbdocmarginnote{\tcbdocnew{2015-25-11}}
2572 \item Added the \CHDocCounter*{numberofruns} counter \tcbdocmarginnote{\tcbdocnew{2015-25-11}}
2573 \end{itemize}
2574 \item \CHDocFullVersion{0.2}\CHDocUpdate{0.2}
2575
2576 Improved \cs{stepcounter} to remove some incompatibilities with the \CHDocPackage{perpage}. This is only partially managed so far.
2577
2578 \item
2579 \CHDocFullVersion{0.1}
2580
2581 A major bug fixed due to some error in usage together with \CHDocPackage{calc} when the driven counters are not stepped any longer.
2582 The culprit was in \CHDocPackage{assoccnt} that the counter reset list was not really disabled.
2583
2584 Thanks to this question \url{http://tex.stackexchange.com/questions/269731/calc-breaks-assoccnt} this bug was detected.
2585
2586 This however lead to some internal inconsistencies and it was decided to rewrite \CHDocPackage{assoccnt} with \CHDocPackage{expl3} and the features of the new \LaTeX\ 3 - Syntax.
2587
2588 \end{itemize}
2589 \clearpage
2590 \phantomsection
2591 \part{Appendix}\label{examplesappendix}
2592 \setcounter{section}{0}
2593 \renewcommand{\theHsection}{appendix.\thesection}
2594 \renewcommand{\thesection}{\Alph{section}}
2595
2596 Note: The \cs{DeclareAssociatedCounters} command has to be used in the preamble of the document. It's missing here for the sake of a compact example.
2597
2598
2599
2600 \section[Total number of sections]{Example: Total number of sections}
2601 In this example, all sections of this document are counted, i.e. the current one as well as all following ones.
2602 \begin{dispExample}
2603 This document has \total{totalsections} section(s)%
2604 \end{dispExample}
2605
2606
2607
2608 \section[Subsection with suspension]{Example: Total number of subsections with suspension}
2609
2610 In this example, the subsections of this document are counted but later on, the associatedcounter is removed from the list, so it is frozen.
2611
2612
2613 \begin{dispExample}
2614
2615 \subsection{First dummy subsection}
2616 SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
2617 \subsection{Second dummy subsection}
2618 SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
2619
2620 \RemoveAssociatedCounter{subsection}{totalsubsections}%
2621 \subsection{Third dummy subsection after removing the associated counter}
2622
2623 SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
2624
2625 \end{dispExample}
2626
2627
2628
2629 \subsection{Suspension of a non-associated counter}
2630 This example will show the suspension of a non-associated counter
2631
2632
2633 \begin{dispExample}
2634 \setcounter{equation}{0}%
2635 \SuspendCounters{equation}%
2636 \begin{equation}
2637 E_{0} = mc^2
2638 \end{equation}
2639
2640 \begin{equation}
2641 E^2 = \left({ pc}\right)^2 + E^{2}_{0}
2642 \end{equation}
2643
2644 \begin{equation}
2645 m(v) = \frac{m_{0}}{\sqrt{1-\frac{v^2}{c^2}}}
2646 \end{equation}
2647
2648
2649 There are \number\value{equation}~equations in here!
2650 \end{dispExample}
2651
2652
2653 \section[Former Backup/Restore Feature]{Former backup and restore of counter values}\label{section::old_backuprestore} \CHDocUpdate{1.0}
2654
2655 \subsection[Macros for backup/restoration]{Description of backup and restoring macros for counter values}
2656
2657 \begin{docCommand}{FormerBackupCounterValues}{\oarg{options}\marg{counter name1, counter name2,...}}
2658 This macro adds counter names (separated by a comma) to a list and stores the current values of the counters to another list. The values are used from the current state where this command is used, not a previous or a later state is stored.
2659
2660 \begin{itemize}
2661 \item All counters in the list will be reset to zero (after storing the values) for the next usage, unless the \refKey{resetbackup} key is set to \meta{false}.
2662 \item Multiple specification of the same counter name is possible, but only the first occurence will be regarded -- consecutive occurences of the same counter name are not taken into account. \CHDocNew{0.5}
2663 \end{itemize}
2664
2665 \begin{docKey}[][]{resetbackup}{=\meta{true/false}}{initially true}
2666 This key decides whether \textbf{all} counters in the backup list should be reset to zero or should keep the current value. The default value is \meta{true}.
2667 \end{docKey}
2668
2669 Please note: If a name does not belong to a counter register the compilation aborts with an error message!
2670
2671 Some remarks
2672
2673 \begin{marker}
2674 If a specific counter name is suffixed with an \textasteriskcentered\ at its end the resetting is disabled for this particular counter, regardless whether \refKey{resetbackup} is set to true or not.\CHDocNew{0.4}
2675 \end{marker}
2676
2677 \begin{marker}
2678 Strangely enough, a counter name like \CHDocCounter{foo*} is possible, but \cs{thefoo*} would fail. Be careful about choosing counter names for new counters -- just restrict yourself to the usual letters (and if really needed, using \makeatletter @\makeatother)
2679 \end{marker}
2680 \end{docCommand}%
2681
2682
2683 \begin{docCommand}{FormerRestoreAllCounterValues}{\oarg{options}} \CHDocNew{0.5}
2684 This macro restores all stored counter values corresponding to the counter names.
2685
2686 As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
2687
2688 The backup list is cleared after the restoring has been finished.
2689 \end{docCommand}
2690
2691 \begin{marker}
2692 The command \refCom{FormerRestoreAllCounterValues} was previously called \refCom{FormerRestoreCounterValues} -- that macro is now reserved for updating only particular
2693 counters, not all in a row.
2694 \end{marker}
2695
2696
2697
2698 \begin{docCommand}{FormerRestoreCounterValues}{\oarg{options}\marg{counter name1,counter name2,...}} \CHDocUpdate{0.5}
2699 This macro restores only the stored counter values given by the counter names.
2700 As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
2701
2702 %The backup list is cleared after the restoring has been finished.
2703 \end{docCommand}
2704
2705 \begin{dispExample}
2706
2707 \captionof{figure}{A dummy figure}
2708
2709 \captionof{table}{A dummy table}
2710
2711
2712 \FormerBackupCounterValues{figure,table*}
2713
2714 \captionof{figure}{Another dummy figure}
2715
2716 \captionof{table}{Another dummy table}
2717
2718 \captionof{figure}{Even another dummy figure}
2719
2720 \captionof{table}{Even another dummy table}
2721
2722 Before restoring: \thefigure\ and \thetable
2723
2724 \FormerRestoreAllCounterValues
2725
2726 Restored the values: \thefigure\ and \thetable
2727
2728 \captionof{figure}{Yet another dummy figure}
2729 \captionof{table}{Yet another dummy table}
2730
2731
2732 \end{dispExample}
2733
2734 \begin{docCommand}{FormerAddBackupCounter}{\oarg{options}\marg{counter name1,counter name2,...}} \CHDocNew{0.5}
2735 This is similar to \refCom{FormerBackupCounterValues}, but adds the counter names to an existing global list and can be applied after \refCom{FormerBackupCounterValues}.
2736
2737 \end{docCommand}
2738
2739
2740 \begin{docCommand}{FormerRemoveBackupCounters}{\oarg{options}\marg{counter name1, counter name2,...}} \CHDocNew{0.5}
2741 This macro removes the counters from the list of backup counters and immediately restores the counter value unless the starred version \refCom{FormerRemoveBackupCounters*} is used.
2742
2743 If the package \CHDocPackage{hyperref} is used, the macro \cs{theH...}
2744 %(see \nameref{subsec::backup_and_hyperref} on this)
2745 is restored to the original meaning.
2746
2747 As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
2748
2749 \end{docCommand}
2750
2751
2752
2753 \begin{docCommand}{FormerRemoveBackupCounters*}{\oarg{options}\marg{counter name}} \CHDocNew{0.5}
2754
2755 This command is basically similar to \refCom{FormerRemoveBackupCounters}, but does not restore the counter value right at the place the macro is used.
2756
2757 As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
2758 \end{docCommand}
2759
2760
2761
2762 \clearpage
2763 \markboth{\indexname}{\indexname}
2764 %%%% Index of commands etc.
2765 \printindex
2766
2767 \end{document}