diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/xassoccnt/xassoccnt_example.tex |
Initial commit
Diffstat (limited to 'macros/latex/contrib/xassoccnt/xassoccnt_example.tex')
-rw-r--r-- | macros/latex/contrib/xassoccnt/xassoccnt_example.tex | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/macros/latex/contrib/xassoccnt/xassoccnt_example.tex b/macros/latex/contrib/xassoccnt/xassoccnt_example.tex new file mode 100644 index 0000000000..cb17a1af17 --- /dev/null +++ b/macros/latex/contrib/xassoccnt/xassoccnt_example.tex @@ -0,0 +1,156 @@ +%% LaTeX package xassoccnt - version 1.7 (2018/12/28 -- 06:45:16) +%% Example file for xassoccnt.sty +%% +%% +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2015 -- 2018 by Dr. Christian Hupfer <typography dot with dot latex at gmail dot com> +%% ------------------------------------------------------------------------------------------- +%% +%% 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` +%% +%% + +\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 +\ResumeAllSuspendedCounters +\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} + |