Debian Codegraph @

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

raw
1 %% LaTeX package xassoccnt - version 2.0 (2021/11/21 -- 12:14:58)
2 %% Example file for periodic counters file for xassoccnt.sty
3 %%
4 %%
5 %% -------------------------------------------------------------------------------------------
6 %% Copyright (c) 2016 -- 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{article}
23
24 \usepackage{xassoccnt}
25
26 \usepackage{blindtext}
27
28 \usepackage{pgffor}
29
30 \DeclarePeriodicCounter{section}{10}
31
32 \newcounter{foocntr}
33
34 \begin{document}
35
36
37 \setcounter{foocntr}{3}%
38 \AddPeriodicCounter{foocntr}{8}%
39
40 Value of foocntr is: \thefoocntr % Should be 3
41
42 \addtocounter{foocntr}{20} % Is it 23? No, it is 23 % 8 = 7
43 Value of foocntr is \thefoocntr\ now!
44
45 Adding a value of 4 again:
46 \addtocounter{foocntr}{4} % Is it 11? No, it is 11 % 8 = 3
47 Value of foocntr is \thefoocntr\ now!
48
49 Now prevent the wrapping
50 \addtocounter{foocntr}{10}[wrap=false] % Is it 13? Yes, it is, since wrapping is prevented.
51 Value of foocntr is \thefoocntr\ now!
52
53
54
55 \foreach \x in {1,...,22} {%
56 \section{My nice section \x}
57 }
58
59 \clearpage
60
61 \ChangePeriodicCounterCondition[reset=false]{section}{5}%
62
63 \foreach \x in {1,...,22} {%
64 \section{My nice section \x}
65 }
66 \clearpage
67
68 \ChangePeriodicCounterCondition{section}{7}%
69
70 \foreach \x in {1,...,22} {%
71 \section{My nice section \x}
72 }
73
74
75 \clearpage
76
77 Now removing all periodic counters, but don't reset them
78 \RemoveAllPeriodicCounters[reset=false]%
79
80 \foreach \x in {1,...,22} {%
81 \section{Section after removing periodic counters \x}
82 }
83
84
85
86 \end{document}