summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex')
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex158
1 files changed, 158 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex
new file mode 100644
index 00000000000..c655098204b
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex
@@ -0,0 +1,158 @@
+%% Example file for xassoccnt.sty (2015/11/07)
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2015 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% -------------------------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `author-maintained'.
+%%
+%% This work consists of all files listed in README
+%%
+
+
+\documentclass[a4paper,12pt]{book}%
+
+
+% Some packages only for output and dummy pages
+\usepackage{blindtext}%
+\usepackage{forloop}%
+\usepackage[svgnames]{xcolor}%
+\usepackage{tcolorbox}
+
+\usepackage{totcount}%
+\usepackage{xassoccnt}%
+
+
+
+
+
+
+\newcounter{loopcounter}%
+
+\newcommand{\QuickSections}[2]{%
+\forloop{loopcounter}{1}{\value{loopcounter} < \numexpr #1+1}{%
+\csuse{#2}{Dummy #2 -- \theloopcounter}
+}%
+}%
+
+\newcommand{\ShowNiceCounterOutput}[6]{%
+\begin{center}%
+\begin{tabular}{lllll}%
+& & & & \tabularnewline
+& \multicolumn{4}{c}{totcount page values} \tabularnewline
+Page & \textcolor{red}{#1} & \textcolor{blue}{#2} & \textcolor{gray}{#3} & \textcolor{violet}{#4}\tabularnewline
+\thepage & \textcolor{red}{\number\totvalue{#1}} & \textcolor{blue}{\number\value{#2}} & \textcolor{gray}{\number\value{#3}} & \textcolor{violet}{\number\totvalue{#4}} \tabularnewline
+Section & \textcolor{red}{#5} & Subsection & \textcolor{blue}{#6} & \tabularnewline%
+\thesection & \textcolor{red}{\number\totvalue{#5}} & \thesubsection & \textcolor{blue}{\number\totvalue{#6}} & \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}{associatedpages}{anotherpagescounter}{yetanotherpagescounter}{associatedsections}{associatedsubsections}%
+\blindtext%
+\newpage% some pages
+}%
+}%
+
+
+
+\newcounter{associatedpages}%
+\newcounter{anotherpagescounter}%
+
+\regtotcounter{page} % Register a total value counter --> this will be the driver counter
+\newtotcounter{yetanotherpagescounter}% 3rd driven counter
+\newtotcounter{associatedsections}%
+
+\newtotcounter{associatedsubsections}%
+
+
+\DeclareAssociatedCounters{page}{associatedpages,anotherpagescounter,associatedpages,yetanotherpagescounter}% Register the driver and the driven counters
+\DeclareAssociatedCounters{section}{associatedsections}%
+\DeclareAssociatedCounters{subsection}{associatedsubsections}%
+
+
+
+
+\begin{document}
+\tableofcontents%
+
+\chapter*{Introduction}
+
+This is a dummy document -- it just shows how some of the commands work.
+In section \ref{section::query} same queries and statistics are shown.
+
+\chapter{Chapter one}
+
+\section{First}
+\QuickSections{10}{subsection}%
+
+
+\QuickOutput{10}
+% Suspend the associatedsubsections counters%
+\typeout{Hello!}
+\SuspendCounters{associatedsubsections,associatedpages}%
+
+\QuickOutput{10}
+
+\clearpage
+
+\subsection[Suspended counters checking]{Checking for suspended counters}
+
+\IsSuspendedCounter{associatedsubsections}{Yes, Counter associatedsubsections is suspended}{No!}
+
+\IsSuspendedCounter{yetanothertotalpages}{Yes}{No!}
+
+\clearpage
+
+\section{Dummy section}%
+
+\QuickSections{10}{subsection}%
+
+% Resume all counters
+\ResumeSuspendedCounters
+\QuickSections{20}{subsection}%
+
+
+
+\clearpage
+
+\section{Query routines} \label{section::query}%
+\setlength{\parindent}{0pt}%
+
+\IsAssociatedCounter{totalsections}{Yes, it's associated}{Nope, it's not associated}
+
+\IsAssociatedCounter{anotherpagescounter}{Yes, it's associated}{Nope, it's not associated}
+
+
+\hrule\par
+
+Setting counter section explicitly to another value:
+
+\setcounter{section}{12}%
+
+\hrule\par
+
+Setting counter section explicitly to another value with option enabled:
+
+\SetDocumentCounter[onlycounters={associatedpages,anotherpagescounter,gandalf}]{page}{20}%
+
+
+\AddAssociatedCounters{page}{associatedpages}%
+\AddAssociatedCounters{page}{associatedpages}%
+
+\end{document}
+