1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% $Date: 2014-08-21 18:12:22 +0200 (Thu, 21 Aug 2014) $
%
% $Revision: 55 $
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,12pt]{book}%
% Some packages only for output and dummy pages
\usepackage{blindtext}%
\usepackage{forloop}%
\usepackage[svgnames]{xcolor}%
\usepackage{tcolorbox}
\usepackage{totcount}%
\usepackage{assoccnt}%
\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\value{#2}} & \textcolor{gray}{\number\value{#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
}%
}%
\newcounter{totalpages}
\newtotcounter{totalsections}%
\newcounter{anotherpagescounter}%
\regtotcounter{page} % Register a total value counter --> this will be the driver counter
\newtotcounter{yetanotherpagescounter}% 3rd driven counter
\DeclareAssociatedCounters{page}{totalpages,anotherpagescounter,totalpages}% Register the driver and the driven counters
\DeclareAssociatedCounters{totalpages}{anotherpagescounter}% Register the driver and the driven counters
\DeclareAssociatedCounters{section}{totalsections}%
\begin{document}
\tableofcontents%
\chapter{Chapter one}
\section{First}
\QuickOutput{10}
\section{Query routines}%
\IsAssociatedCounter{totalsections}{Yes, it's associated}{Nope, it's not associated}
\IsAssociatedCounter{anotherpagescounter}{Yes, it's associated}{Nope, it's not associated}
\AssociationStatistics%
\IsDriverCounter{section}{Yes, it's a driver counter}{No, it does not have this feature}%
\ClearAssociatedCountersList{section}
\IsDriverCounter{section}{Yes, it's a driver counter}{No, it does not have this feature}%
\AssociationStatistics%
Clearing the counters:
\ClearDriverCountersList
Show Statistics%
\AssociationStatistics%
\end{document}
|