summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex
blob: af6e1ddd295f7bbc07fd2c6bc54604e186b2d5fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
\documentclass{book}%

\usepackage{totcount}%
\usepackage{assoccnt}%

% Some packages only for output and dummy pages
\usepackage{blindtext}%
\usepackage{forloop}%  
\usepackage{xcolor}%

\newcounter{loopcounter}%

\newcommand{\ShowNiceCounterOutput}[5]{%
\begin{center}%
\begin{tabular}{llll}%
& & & \tabularnewline 
& \multicolumn{3}{c}{totcount page values} \tabularnewline
Page & \textcolor{red}{#1} & \textcolor{blue}{#2} & \textcolor{gray}{#3} \tabularnewline
\thepage & \textcolor{red}{\number\totvalue{#1}} & \textcolor{blue}{\number\totvalue{#2}} & \textcolor{gray}{\number\totvalue{#3}} \tabularnewline
& & & \tabularnewline 
 & \multicolumn{3}{c}{totcount section values} \tabularnewline 
Section & \textcolor{red}{#4} & \textcolor{blue}{#5} \tabularnewline
\thesection & \textcolor{red}{\number\totvalue{#4}} & \textcolor{blue}{\number\totvalue{#5}} & \tabularnewline
&  & & \tabularnewline 
\end{tabular}
\end{center}%
}%


\newcommand{\QuickOutput}[1]{%
%
\forloop{loopcounter}{1}{\value{loopcounter} < \numexpr #1+1}{%
\pagenumbering{arabic}%  -> pagenumber reset to zero , on purpose inside the loop
\ShowNiceCounterOutput{page}{totalpages}{anotherpagescounter}{section}{totalsections}%
\blindtext%
\newpage%  some pages
}%
}%



\begin{document}
\regtotcounter{page} % Register a total value counter --> this will be the driver counter
\newtotcounter{totalpages}% 1st driven counter
\newtotcounter{anotherpagescounter}% 2nd driven counter 
\newtotcounter{yetanotherpagescounter}% 3rd driven counter 


\regtotcounter{section}%
\newtotcounter{totalsections}

\DeclareAssociatedCounters{page}{totalpages,anotherpagescounter}%  Register the driver and the driven counters
\DeclareAssociatedCounters{section}{section,totalsections}%  Register the driver and the driven counters for sections%
\DeclareAssociatedCounters{page}{yetanotherpagescounter}%  Register the driver and the driven counters



\pagenumbering{Roman}% 

\chapter{The first chapter}%

\section{My first section}%

% Generate dummy output
\QuickOutput{10}%


\section{My second section}%

\QuickOutput{10}%

\pagenumbering{arabic}%  -> pagenumber reset to zero 

\appendix

\chapter{First Appendix chapter}%

\section{My (only) appendix section}%


% Generate dummy output, again ;-)
\QuickOutput{10}%

% Clear the list of counters associated to page
\ClearAssociatedCountersList{page}%

% Not necessary, only for removing some counters from list
\RemoveAssociatedCounters{page}{totalpages,anotherpagescounter}%  
% Readd the counter totalpages to the list --> in this context,
% It acts, as if it has not been removed at all
\DeclareAssociatedCounters{page}{totalpages}

\QuickOutput{20}%



\end{document}