summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-08-14 22:03:52 +0000
committerKarl Berry <karl@freefriends.org>2014-08-14 22:03:52 +0000
commit3cff191286e3cb279c738c8a68cec641bb61effd (patch)
tree0bda4daf5266ba412a200313641dde191df3f40d /Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex
parent4a8be113ce277ee7326c01599b3b4fac3c677e87 (diff)
assoccnt (14aug14)
git-svn-id: svn://tug.org/texlive/trunk@34934 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex')
-rw-r--r--Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex97
1 files changed, 97 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex
new file mode 100644
index 00000000000..af6e1ddd295
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/assoccnt/assoccnt_example.tex
@@ -0,0 +1,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} \ No newline at end of file