summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-07-30 23:08:03 +0000
committerKarl Berry <karl@freefriends.org>2016-07-30 23:08:03 +0000
commit3fd588bb279cdfa2a5b61892ebe94ada81d07fbe (patch)
tree09ea2fcfbb8c68491d962ad314adb69ce5c8339c /Master/texmf-dist
parent525ac53a88fd99baae49fee0cafb38d995aaaace (diff)
xassoccnt (29jul16)
git-svn-id: svn://tug.org/texlive/trunk@41767 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/README8
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.pdfbin0 -> 84360 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex331
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.pdf (renamed from Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters.pdf)bin94195 -> 94256 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.tex (renamed from Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters.tex)2
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdfbin462941 -> 533167 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex1754
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdfbin80724 -> 77742 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex21
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdfbin68384 -> 68384 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex5
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdfbin28017 -> 31637 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex13
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.pdfbin0 -> 46542 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.tex75
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdfbin60527 -> 60527 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex2
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdfbin63245 -> 63550 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex7
-rw-r--r--Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty881
20 files changed, 2238 insertions, 861 deletions
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/README b/Master/texmf-dist/doc/latex/xassoccnt/README
index eebc964da38..a0d3f99da59 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/README
+++ b/Master/texmf-dist/doc/latex/xassoccnt/README
@@ -1,9 +1,9 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% README file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
-%% Copyright (c) 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% Copyright (c) 2015 -- 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
@@ -26,7 +26,7 @@ the associated counters as well. This package can be regarded as a supplement
to the totcount package by Vasileios Koutavas (http://www.ctan.org/pkg/totcount), but
can be used without it too.
-As of 2016/06/19 xassoccnt does not supersede the package assoccnt by the same author, however,
-the older package isn't declared obsolete as of 2016/06/19
+As of 2016/07/28 xassoccnt does not supersede the package assoccnt by the same author, however,
+the older package isn't declared obsolete as of 2016/07/28
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.pdf
new file mode 100644
index 00000000000..4d3cd64eb03
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex
new file mode 100644
index 00000000000..40a7a63fd19
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex
@@ -0,0 +1,331 @@
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
+%% Example file for backup counters file for xassoccnt.sty
+%%
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2016 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`
+%%
+%%
+
+\documentclass{book}
+
+\usepackage{xassoccnt}
+\usepackage{blindtext}
+%\usepackage[T1]{fontenc}
+%\usepackage[utf8]{inputenc}
+\usepackage{hyperref}
+
+\DeclareBackupCountersGroupName{sectiontree}
+\DeclareBackupCountersGroupName{chaptertree}
+
+\AssignBackupCounters[name=chaptertree,cascading=true]{chapter} % Use all counters in the chapter counter driver reset list
+
+
+\newcommand{\outputit}[1]{\csname the#1\endcsname\par}
+
+\begin{document}
+Checking for existence of a backup counter group:
+
+
+\IsBackupCounterGroupTF{chaptertree}{Yes, \fbox{chaptertree} is a backup counter group}{no, \fbox{chaptertree} is no backup counter group}
+
+\IsBackupCounterGroupT{chaptertree}{Yes, \fbox{chaptertree} is a backup counter group}
+
+\IsBackupCounterGroupF{foochaptertree}{No, \fbox{foochaptertree} is no backup counter group}
+
+\IsBackupCounterGroupTF{secondchaptertree}{Yes, \fbox{secondchaptertree} is a backup counter group}{no, \fbox{secondchaptertree} is no backup counter group}
+\clearpage
+\tableofcontents
+\listoffigures
+
+\chapter{First regular chapter}
+
+\section{First section in first regular chapter}
+
+\subsection{First subsection in first regular section}
+
+
+
+\begin{figure}
+\caption{My nice figure in 1st regular chapter}
+\end{figure}
+
+
+\begin{figure}
+\caption{My other nice figure in 1st regular chapter}
+\end{figure}
+
+
+
+\chapter{Second regular chapter}
+
+\section{First section in 2nd regular chapter}
+
+\subsection{1st subsection in 1st regular section of 2nd regular chapter}
+
+
+\begin{figure}
+\caption{My nice figure in 2nd regular chapter}
+\end{figure}
+
+
+\begin{figure}
+\caption{My other nice figure in 2nd regular chapter}
+\end{figure}
+
+
+
+
+
+\chapter{Third regular chapter}
+
+\section{1st section in 3rd regular chapter}
+
+\subsection{1st subsection in 1st regular section of 2nd regular chapter}
+\subsection{2nd subsection in 1st regular section of 2nd regular chapter}
+
+\section{2nd section in 3rd regular chapter}
+
+\subsection{1st subsection in 2nd regular section of 2nd regular chapter}
+\subsection{2nd subsection in 2nd regular section of 2nd regular chapter}
+
+\chapter{Fourth regular chapter}
+
+
+
+\BackupCounterGroup[backup-id={firstchaptertree},cascading=true]{chaptertree}
+
+\chapter{First chapter after backup command}
+
+\section{1st section in 1st backup chapter}
+
+\subsection{1st subsection in 1st regular section of 1st backup chapter}
+\subsection{2nd subsection in 1st regular section of 1st backup chapter}
+
+\section{2nd section in 1st backup chapter}
+
+\subsection{1st subsection in 2nd regular section of 1st backup chapter}
+\subsection{2nd subsection in 2nd regular section of 1st backup chapter}
+
+
+\begin{figure}
+\caption{My nice figure in 1st backup chapter}
+\end{figure}
+
+
+\begin{figure}
+\caption{My other nice figure in 1st backup chapter}
+\end{figure}
+
+
+
+
+
+\chapter{Second chapter after backup command}
+
+\section{1st section in 2nd backup chapter}
+
+\subsection{1st subsection in 1st regular section of 2nd backup chapter}
+\subsection{2nd subsection in 1st regular section of 2nd backup chapter}
+
+\section{2nd section in 2nd backup chapter}
+
+\subsection{1st subsection in 2nd regular section of 2nd backup chapter}
+\subsection{2nd subsection in 2nd regular section of 2nd backup chapter}
+
+
+\chapter{Third chapter after first backup command}
+
+
+
+\BackupCounterGroup[backup-id={secondchaptertree}]{chaptertree}
+
+\chapter{First chapter after second backup command}
+
+% Now restore the full chaptertree command with the backup id firstchaptertree, but don't keep the state afterwards.
+
+Checking the backup state: \IsBackupStateTF{chaptertree}{firstchaptertree}{Yes}{No}
+
+Checking the backup state again: \IsBackupStateT{chaptertree}{firstchaptertree}{Yes}
+
+Checking the backup state again: \IsBackupStateF{chaptertree}{foochaptertree}{No, it's no backup state}
+
+
+\RestoreBackupCounterGroup[keep-after-restore=false,backup-id={firstchaptertree}]{chaptertree}
+
+Now checking after restore with `keep-after-restore=false`:
+
+Checking the backup state: \IsBackupStateTF{chaptertree}{firstchaptertree}{Yes}{No}
+
+Checking the backup state again: \IsBackupStateT{chaptertree}{firstchaptertree}{Yes}
+
+Checking the backup state again: \IsBackupStateF{chaptertree}{foochaptertree}{No, it's no backup state}
+
+
+
+
+
+\chapter{First chapter after restoring of first backup}
+
+
+\section{1st section in 1st backup chapter of 2nd backup}
+
+\subsection{1st subsection in 1st regular section of 2nd backup chapter}
+\subsection{2nd subsection in 1st regular section of 2nd backup chapter}
+
+\section{2nd section in 2nd backup chapter of 2nd backup}
+
+\subsection{1st subsection in 2nd regular section of 2nd backup chapter}
+\subsection{2nd subsection in 2nd regular section of 2nd backup chapter}
+
+
+\chapter{Another chapter after restoring}
+
+% Now let us restore only some of the counters
+
+
+\section{First section of another chapter}
+
+\begin{figure}
+\caption{My nice figure}
+\end{figure}
+
+\begin{figure}
+\caption{My very nice figure}
+\end{figure}
+
+
+\subsection{First subsection of 1st section of another chapter}
+
+\section{Now another section}
+
+
+\RestoreBackupCounterGroup[keep-after-restore=true,backup-id={secondchaptertree}]{chaptertree}
+
+
+\chapter{Another chapter after restoring with secondchaptertree}
+
+% Now let us restore only some of the counters
+
+
+\section{First section of another chapter}
+
+\begin{figure}
+\caption{My nice figure}
+\end{figure}
+
+\begin{figure}
+\caption{My very nice figure}
+\end{figure}
+
+
+\subsection{First subsection of 1st section of another chapter}
+
+\section{Now another section}
+
+
+\RestoreBackupCounterGroup[keep-after-restore=true,backup-id={secondchaptertree},restore-id=first]{chaptertree}
+
+
+\chapter{Another chapter after restoring, secondchaptertree,other restore-id}
+
+% Now let us restore only some of the counters
+
+
+\section{First section of another chapter}
+
+\begin{figure}
+\caption{My nice figure}
+\end{figure}
+
+\begin{figure}
+\caption{My very nice figure}
+\end{figure}
+
+
+\subsection{First subsection of 1st section of another chapter}
+
+\section{Now another section}
+
+\RestoreBackupCounterGroup[keep-after-restore=true,backup-id={secondchaptertree},restore-id=newrestore]{chaptertree}
+
+
+\chapter{Another chapter after restoring, secondchaptertree, yet another restore-id}
+
+% Now let us restore only some of the counters
+
+
+\section{First section of another chapter}
+
+\begin{figure}
+\caption{My nice figure}
+\end{figure}
+
+\begin{figure}
+\caption{My very nice figure}
+\end{figure}
+
+
+\subsection{First subsection of 1st section of another chapter}
+
+\section{Now another section}
+
+
+%%%%%
+
+
+%\ClearBackupCounterGroups{chaptertree}
+
+%\DeleteBackupCounterGroups{chaptertree}
+
+
+\RemoveCountersFromBackupGroup{chaptertree}{section}
+
+
+
+
+\RestoreBackupCounterGroup[keep-after-restore=true,backup-id={secondchaptertree},restore-id=renewrestore]{chaptertree}
+
+%\chapter{Another chapter after restoring, secondchaptertree, yet another restore-id}
+
+
+
+Removing a specific backup-id
+
+%\ClearCounterBackupState[backup-id=secondchaptertree]{chaptertree}{chapter}
+
+
+\ClearBackupState[backup-id=secondchaptertree]{chaptertree}
+
+
+
+\section{First section of another chapter}
+
+\begin{figure}
+\caption{My nice figure}
+\end{figure}
+
+\begin{figure}
+\caption{My very nice figure}
+\end{figure}
+
+
+\subsection{First subsection of 1st section of another chapter}
+
+\section{Now another section}
+
+
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.pdf
index eca5594bc28..d22985a9876 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters.pdf
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.tex
index 4f1417e5c1f..54bf7bb03b1 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters.tex
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.tex
@@ -1,4 +1,4 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% Example file for coupled counters file for xassoccnt.sty
%%
%%
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf
index 6f13d5f9c54..45cedfbe713 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex
index fbe9a1f4777..4fc5cf8a3da 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex
@@ -1,9 +1,9 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% Documentation file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
-%% Copyright (c) 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% Copyright (c) 2015 -- 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
@@ -19,7 +19,7 @@
%%
%%
-\documentclass[12pt,a4paper]{article}
+\documentclass[12pt,a4paper,oneside]{article}
@@ -75,9 +75,9 @@
}
-\@namedef{xassoccntversion0.1}{v0.1 2016-11-07}
+\@namedef{xassoccntversion0.1}{v0.1 2015-11-07}
-\@namedef{xassoccntversion0.2}{v0.2 2016-11-14}
+\@namedef{xassoccntversion0.2}{v0.2 2015-11-14}
\@namedef{xassoccntversion0.3}{v0.3 2016-01-08}
@@ -91,7 +91,10 @@
\@namedef{xassoccntversion0.8}{v0.8 2016-06-10}
-\@namedef{xassoccntversion0.9}{v0.9 2016-06-18}
+\@namedef{xassoccntversion0.9}{v0.9 2016-06-19}
+
+
+\@namedef{xassoccntversion1.0}{v1.0 2016-07-28}
\makeatother
@@ -302,10 +305,13 @@
\usepackage[autodefinecounters=true]{xassoccnt}
\usepackage{amsmath}
\usepackage{amssymb}
+\usepackage{minitoc}
+\usepackage{tocbibind}
\usepackage{bookmark}
\usepackage{cleveref}
\usetikzlibrary{mindmap}
+\setcounter{tocdepth}{3}
\newcommand{\PackageDocName}{xassoccnt}%
@@ -313,6 +319,7 @@
christian.hupfer@yahoo.de
}
+\doparttoc
\let\DeclareAssociatedCountersOrig\DeclareAssociatedCounters % -> for use in examples only
@@ -355,6 +362,9 @@
pdfauthor={PACKAGEAUTHOR},
pdfsubject={Documentation of \PackageDocName\ package},
pdfkeywords={LaTeX, counters},
+ bookmarksopen=true,
+ bookmarksopenlevel=4,
+ bookmarksnumbered=true,
pdfcreator={LaTeX}
}
@@ -384,7 +394,7 @@
child[grow=230,concept color=red!20!cyan] { node [concept] {Coupled counters} child [grow=250,concept color=cyan!50!blue] {node[concept] {Coupled counter groups}}};
\end{tikzpicture}
-\CHPackageTitlePage[packageauthor={Christian Hupfer}]{Associated counters stepping simultaneously}
+\CHPackageTitlePage[packageauthor={Christian Hupfer}]{Associated counters stepping simultaneously\\ (and other gadgets)}
\clearpage
@@ -400,6 +410,10 @@
\setcounter{footnote}{0}
+\part{Introduction}
+
+\parttoc
+
\section*{Preface}
This package is the successor and a complete rewrite of \CHDocPackage{assoccnt}. Not all features of that package are implemented yet -- if some functionality of your document depends on \CHDocPackage{assoccnt}, continue using the older version and shift gradually to \CHDocPackage{\PackageDocName} please.
@@ -518,379 +532,360 @@ As of version \packageversion\ \CHDocPackage{\PackageDocName} supports the packa
\end{docKey}
-\section{Documentation of Macros}
-\tcbset{color command={blue}}
+\clearpage
+\part{Tools for counters}
-The main purpose of this package is co-stepping of counters, but there are some helper commands in addition to macros provided \LaTeXe\ already, see section \nameref{section::additions_to_l2e}.
+\parttoc
-\begin{itemize}
- \item Section \nameref{subsection::associatedcounterscmds} describes the most important macros for setting up associated counters
- \item Section \nameref{subsection::drivercounterscmds} informs about the macros for setting up, removing or clearing driver counters
- \item Section \nameref{subsection::querycmds} deals with query command sequences about counters being a driver or an associated counters
- \item Section \nameref{subsection::informationcmds} contains routines that show which counters have been changed last
-\end{itemize}
+\section[Additions to standard commands]{Additions and extensions to standard counter related commands}\label{section::additions_to_l2e}
+\subsection{Extension of \LaTeXe\ commands}\label{subsection::extension_of_l2e_commands}
-\subsection[Association macros]{Associated counters commands}\label{subsection::associatedcounterscmds}
+\begin{docCommand}[before={\CHDocNew{0.9}}]{addtocounter}{\marg{counter}\marg{increment value}\oarg{options}}
+ The \refCom{addtocounter} macro behaves like the usual \cs{addtocounter} counter, but takes care to specific counter features such as \CHDocTag{periodic counters} and has an optional argument in order to perform special settings.
-All macros have the general rule, that the driver counter is specified as 1st mandatory argument to the macro, which is in almost all cases the 2nd argument of the macro.
+As of \packageversion, there is only one option used:
+\begin{docKey}[][after={\CHDocNew{0.9}}]{wrap}{=\meta{true/false}}{initially true}
+ This key determines whether addition of values to a periodic counter (see \nameref{section:periodic_counters}) will lead to a modulo part addition.
+\end{docKey}
-\begin{docCommand}{DeclareAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
-This command is the main macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}. If only counter is to be associated, omit a trailing ","!
+\end{docCommand}
+
-%\begin{docCommandArgs}{DeclareAssociatedCounters}
+\subsection[\LaTeXe\ additions]{Additions to \LaTeXe\ commands}
-\begin{codeoptionsenum}
- \item \oarg{options}: %As of \packageversion, the optional argument \oarg{options} is not used so far, but is reserved for later purposes.
- \begin{docKey}[][]{autodefine}{=\meta{choice}}{initially none}
- This choice - key can be specified if the specified counters should be defined if they not already available.
- Possible values are
- \begin{itemize}
- \item \texttt{none} -- no counter is autodefined
- \item \texttt{all} -- all counters will be autodefined
- \item \texttt{driver} -- only driver counters will be autodefined
- \item \texttt{associated} -- only associated counters will be autodefined
- \end{itemize}
- \end{docKey}
- Default is \texttt{none}
- \begin{docKey}[][]{sloppy}{}{}
- If \refKey{autodefine} key is used, the \texttt{sloppy} key disables the check whether a counter is defined already.
- \end{docKey}
+\begin{docCommand}{NewDocumentCounter}{\oarg{options}\marg{counter}\oarg{resetting counter}}
+ This command is a new interface to \cs{newcounter} and behaves effectively the same. %The first optional argument is reserved for later purposes but not used as of version \packageversion.
+
+ \begin{docKey}{initial}{=\meta{integer value}}{initially 0}
+ This is used for the start value of the new counter.
+ \end{docKey}
- \item \marg{driver counter}
+\end{docCommand}%
- Holds the name of the driver counter to which the list of counters should be associated
-\item \marg{associated counters list}
+\begin{docCommand}{DeclareDocumentCounter}{\oarg{options}\marg{counter}\oarg{resetting counter}}
+ This command is the preamble-only version of \refCom{NewDocumentCounter}.
+\end{docCommand}%
- A comma separated list of counter names that should be associated to the driver counter
-\end{codeoptionsenum}
-%\end{docCommandArgs}
+\begin{docCommand}{SetDocumentCounter}{\oarg{options}\marg{counter}\marg{counter value}}
-\begin{itemize}
-\item This command is a preamble command, i.e. it can be used in the preamble of the document or within other packages or class files only.
-\item This command should be used as early as possible, i.e. in the preamble of the document, since the driven counters are not increased as long as they are not associated to the driver counter. On the hand, it is possible or may be required to control the starting point of the association at any position in the body of the document, when the association should start later on. Use the command \refCom{AddAssociatedCounters} if counters should be associated within the document body.
-\end{itemize}
+This command behaves like the standard macro \cs{setcounter}, but has an additional optional 1st argument. %which is not used as of version \packageversion.
+% This optional argument can be used to enable the setting of the driver counter value as well as the associated counter values at once.
+\begin{docCommandArgs}{SetDocumentCounter}%
-% Relax for documentation purposes
-\renewcommand{\DeclareAssociatedCounters}[3][]{\relax}%
-\begin{dispExample}
-%%%% The association of anothertotalpages in this example just takes place here, so the stepping of the counter will start from here and providing a 'wrong' value.
-%%%%
-\DeclareAssociatedCounters{page}{totalpages,anothertotalpages}%
-This document has \number\totvalue{totalpages} (note: \number\totvalue{anothertotalpages}) pages.
-\end{dispExample}
-\begin{itemize}
- \item Current version (\packageversion) rules:
- \begin{itemize}
- \item No checking whether the 2nd and 3rd arguments hold counter names is applied.
- \item Mutually cross - association of two counters is not supported! The compilation will stop on this!
- \CHDocUpdate{0.6}
+\begin{codeoptionsenum}
+ \item \oarg{options}: %As of version \packageversion, this option is not used% the key value argument
- A driver counter, say, \CHDocCounter{foo}) of, say \CHDocCounter{foobar} can not be an associated counter of \CHDocCounter{foobar}, which in turn can be a driver counter of other counters, of course.
+ \begin{docKey}{associatedtoo}{=\meta{true/false}}{initially false}
+ If enabled (\meta{true}), \refCom{SetDocumentCounter} will use the counter value for \underline{all} counters associated to this driver counter as well. Initially, this option is set to \meta{false}.
+ \end{docKey}
+
+ \begin{docKey}{onlycounters}{=\meta{comma separated list of counters}}{initially empty}
+ If this key is used, only those associated counters are set as well that are given in the comma separated list.
+
+ Names, that are either not referring to counters at all or to counters that are not associated to the given driver counter will be ignored silently.
+ \end{docKey}
- A contrary feature are the \CHDocTag{coupled counters} -- If some counters should share a common base, i.e. increasing one arbitrary member counter of a group of counters then all should be increased, this called coupling of counters -- all group members are on an equal footing. See \cref{sec::coupledcounters} about this feature.
+
- On the other side, \CHDocTag{associated counters} belong to a hierarchy. The driver counter dominates the associated counters.
-
- \end{itemize}
- \item A self-association of the driver counter to itself is ignored internally as this would lead to inconsistent counter values.
- \item The order of the specification of associated counters in the 2nd arguments is of no importance.
- \item Specifing an associated counter name multiple times has no effect, only the first occurence of the name will be used.
-\end{itemize}
-\end{docCommand}
+ \item \marg{counter}
+ Holds the name of the (driver) counter to be set.
+ \item \marg{counter value}
+ Holds the value to be set
+ \end{codeoptionsenum}
+\end{docCommandArgs}
-\begin{docCommand}{AddAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
-The usage of this macro is similar to \refCom{DeclareAssociatedCounters}; if it is called in the document preamble (or in package file), \refCom{AddAssociatedCounters} falls back to
-\begin{center}\refCom{DeclareAssociatedCounters},\end{center} having the same optional argument functionality with \refKey{autodefine} and \refKey{sloppy}; if it is called in the document body, this command adds some counters to the associated counter list for a specific driver counter -- if this list does not exists, the \LaTeX{} run will issue a warning, but add the driver counter to the driver list and the associated counters analogously.
-\marginnote{\bcbombe}
+Some notes on \refCom{SetDocumentCounter}
+\begin{itemize}
+ \item The option keys \refKey{associatedtoo} and \refKey{onlycounters} are mutually exclusive! %
+ \item The counter to be set can be either a driver counter or an otherwise associated counter.
+\end{itemize}
+\end{docCommand}%
-Using \refCom{AddAssociatedCounters} in the document body automated generation of counters is disabled.
+\begin{docCommand}{StepDownCounter}{\oarg{options}\marg{counter}}\CHDocNew{0.4}
-% You have to use \refCom{DeclareAssociatedCounters} first, to set up the driver counter hook.
+This macro subtracts the value of 1 from the counter and is the counterpart of \cs{stepcounter}.
+\begin{docCommandArgs}{StepDownCounter}%
-\begin{docCommandArgs}{AddAssociatedCounters}
\begin{codeoptionsenum}
- \item \oarg{options}: As of version \packageversion, the optional argument \oarg{options} are the same as for \refCom{DeclareAssociatedCounters}, see \refKey{autodefine} and \refKey{sloppy}.
-
- \item \marg{driver counter}
-
- Holds the name of the driver counter to which the list of counters should be associated
- \item \marg{associated counters list}
-
- A comma separated list of counter names that should be associated to the driver counter
-\end{codeoptionsenum}
+ \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
+ \item \marg{counter}
+ Holds the name of the first counter.
+ \end{codeoptionsenum}
\end{docCommandArgs}
-
-% macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}.
-
\end{docCommand}%
-\begin{docCommand}{RemoveAssociatedCounter}{\marg{driver counter}\marg{associated counter}}
-This command removes a counter from the existing list for a driver counter, i.e. the counter will not be increased any longer by \cs{stepcounter}. It can be increased however manually, of course.
-\end{docCommand}
-
-
-
-\begin{dispExample}
-\RemoveAssociatedCounter{page}{anothertotalpages}
-This document has \number\totvalue{totalpages} (beware: \number\totvalue{anothertotalpages}) pages.
-\end{dispExample}
-
-
-\begin{docCommand}{RemoveAssociatedCounters}{\marg{driver counter}\marg{list of associated counters}}
-This command removes the comma-separated-value list of counters from the existing list for a driver counter, i.e. the counters will not be increased any longer by \cs{stepcounter}. They can be increased however manually, of course.
-
-Take care not to confuse the commands \refCom{RemoveAssociatedCounters}
-and{}\linebreak \refCom{RemoveAssociatedCounter}
-\end{docCommand}
+\begin{docCommand}{SubtractFromCounter}{\oarg{options}\marg{counter}\marg{delta value}}\CHDocNew{0.4}
-\begin{docCommand}{ClearAssociatedCounters}{\oarg{options}\marg{driver counter}}
-This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically any longer.
+This macro subtracts the (positive) delta value from the counter and is the counterpart of \cs{addtocounter}
-The optional argument is not used as of version \packageversion.
+\begin{docCommandArgs}{SubtractFromCounter}%
-Please note that the driver counter is not removed from the list of driver counters -- this simplifies reassociating of (other) counters to this one later on with the macro \refCom{AddAssociatedCounters} and suppress the relevant warning.
-If the driver counter and all its associated counters should be removed, use \refCom{RemoveDriverCounter} instead.
-\end{docCommand}
+\begin{codeoptionsenum}
+ \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
+ \item \marg{counter 1}
+ Holds the name of the first counter.
+ \item \marg{delta value}
+ Holds the (positive) value to be subtracted from the counter value.
+ \end{codeoptionsenum}
+\end{docCommandArgs}
-\clearpage
+\end{docCommand}%
-\subsection[Driver macros]{Driver counter commands} \label{subsection::drivercounterscmds}
+\begin{docCommand}{CopyDocumentCounters}{\oarg{options}\marg{source counter}\marg{target counter}}
+This document copies the counter value from the source counter in argument 2 to the target counter in argument 3.
-\begin{docCommand}{AddDriverCounter}{\oarg{options}\marg{driver counter name}}
+\begin{docCommandArgs}{CopyDocumentCounters}%
-\begin{docCommandArgs}{AddDriverCounter}%
\begin{codeoptionsenum}
-\item \oarg{options}: As of \packageversion, the optional argument \oarg{options} is not used so far, but is reserved for later purposes.
-
- \item \marg{driver counter name}
+ \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
- Holds the name of the driver counter that should be added to the list of driver counters.
-\end{codeoptionsenum}
+ \item \marg{source counter}
+ Holds the name of the source counter.
+ \item \marg{target counter}
+ Holds the name of the target counter.
+ \end{codeoptionsenum}
\end{docCommandArgs}
\end{docCommand}%
+\begin{docCommand}{SwapDocumentCounters}{\oarg{options}\marg{counter 1}\marg{counter 2}}
-\begin{docCommand}{RemoveDriverCounter}{\oarg{options}\marg{driver counter}}
-This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically any longer.
-
-The optional argument is not used as of version \packageversion.
+This macro swaps the values of the counters given in arguments 2 and 3
-If all driver counters should be unregistered, use \refCom{ClearDriverCounters} instead!
-\end{docCommand}
+\begin{docCommandArgs}{SwapDocumentCounters}%
-\begin{docCommand}{ClearDriverCounters}{\oarg{options}}%
+\begin{codeoptionsenum}
+ \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
-This clears completely the list of driver counters, such that no counters are regarded as being associated -- i.e. no driver is hold as being a driver counter.
+ \item \marg{counter 1}
+ Holds the name of the first counter.
+ \item \marg{counter 2}
+ Holds the name of the second counter.
+ \end{codeoptionsenum}
+\end{docCommandArgs}
-The optional argument is not used as of version \packageversion.
+\end{docCommand}%
-\end{docCommand}
+\begin{docCommand}{SyncCounters}{\oarg{options}\marg{driver counter}}
-\subsection[Query macros]{Commands for queries} \label{subsection::querycmds}
+This document synchronizes the driver counter value to the associated values. It has the same options as \refCom{SetDocumentCounter}. If the given counter is no driver counter, nothing is done.
-Sometimes it might be necessary to get information, whether a counter is regarded as a driver or as an associated counter. This section describes some query macros in order to obtain this information.
+\begin{docCommandArgs}{SyncCounters}%
-\begin{docCommand}{IsAssociatedToCounter}{\marg{driver counter}\marg{associated counter}\marg{True branch}\marg{False branch}}
-This macro checks, whether a counter is associated to a particular given driver counter and expands the corresponding branch. If the internal driver counter list does not exist, the false branch will be used, since this also means, that the possibly associated counter is not associated at all.
+\begin{codeoptionsenum}
+ \item \oarg{options}: see \refCom{SetDocumentCounter}
+ \item \marg{source counter}
+ Holds the name of the source counter.
+ \end{codeoptionsenum}
+\end{docCommandArgs}
+\end{docCommand}%
-\begin{docCommandArgs}{IsAssociatedToCounter}%
+\begin{dispExample}%[breakable=true]
+ \SetDocumentCounter{foocntr}{17}
+ \SetDocumentCounter{foobarcntr}{20}
-\begin{codeoptionsenum}
- \item \marg{driver counter}
+\begin{itemize}
+\item Displaying counters
- Holds the name of the driver counter to which \marg{associated counter} the could possibly be associated.
-\item \marg{associated counter}
+ \thefoocntr\ and \thefoobarcntr
+\item Swapping counters
- Contains the name of the possibly associated counter.
+ \SwapDocumentCounters{foocntr}{foobarcntr}
-\item \marg{True branch}
+ \thefoocntr\ and \thefoobarcntr
- This code is expanded if the counter is associated to the driver, otherwise it is ignored.
+\item Step down counters
-\item \marg{True branch}
+\StepDownCounter{foocntr}
+\StepDownCounter{foobarcntr}
- This code is expanded if the counter is \textbf{not} associated to the driver, otherwise it is ignored.
+ \thefoocntr\ and \thefoobarcntr
-\end{codeoptionsenum}
-\end{docCommandArgs}
+\item Subtracting some value from the counters
+ \SubtractFromCounter{foocntr}{5}
+ \SubtractFromCounter{foobarcntr}{10}
+ \thefoocntr\ and \thefoobarcntr
+\end{itemize}
+\end{dispExample}
-\begin{dispExample}
-% Remove associated counter first for demonstration purposes
-\RemoveAssociatedCounter{page}{anothertotalpages}
-\IsAssociatedToCounter{page}{totalpages}{Yes, totalpages is associated}{No, totalpages is not associated}
-\IsAssociatedToCounter{page}{anothertotalpages}{Yes, anothertotalpages is associated}{No, anotherpages is not associated}
-\end{dispExample}
+\subsection[\protect\cs{IfIsDocumentCounter}-Queries]{Commands checking whether a name refers to a counter}
-See also
+\CHDocPackage{\PackageDocName}\ provides three commands that are quite similar -- all check whether \marg{name} is an already defined \LaTeXe\ counter (name), in good tradition with the \CHDocPackage{xparse} - syntax:
\begin{itemize}
- \item \refCom{IsAssociatedCounter} for checking whether a counter is associated
- \item \refCom{IsDriverCounter} in order to check whether a counter is a driver.
- \item \refCom{GetDriverCounter} returns the driver counter name for a given associated counter name
-\end{itemize}
+\item \begin{docCommand}{IfIsDocumentCounterTF}{\oarg{}\marg{name}\marg{true branch}\marg{false branch}}
+This macro performs the full branching
+\end{docCommand}
+\item
+\begin{docCommand}{IfIsDocumentCounterT}{\oarg{}\marg{name}\marg{\meta{long} true branch}}
+This command executes only if the name is a counter.
+\end{docCommand}
+\begin{docCommand}{IfIsDocumentCounterF}{\oarg{}\marg{name}\marg{true branch}}
+This command executes only if the name is not a counter.
\end{docCommand}
+\end{itemize}
-\begin{docCommand}{GetDriverCounter}{\marg{counter name}}%
+The optional argument is not used as of version \packageversion\ for none of those three commands.
-This commands returns the driver counter to which the counter name of the first argument is connected to. If the counter is not defined, the macro returns nothing.
-\begin{itemize}
- \item No check whether the counter name is defined is performed
- \item No check whether the counter is associated at all is performed. Usage of this command in conjunction with \refCom{IsAssociatedCounter} is strongly encouraged.
-\end{itemize}
+\subsection[Information macros]{Information on counters} \label{subsection::informationcmds}
+On occasions it might be important to have some information which counter has been changed last. Since there are four commands manipulating counter values, there are four corresponding routines for this:
-\begin{dispExample}%
-totalpages is associated to the \textcolor{blue}{\textbf{\GetDriverCounter{totalpages}}} counter.
-% Try with an undefined counter name
-humptydumpty is associated to the \textcolor{blue}{\textbf{\GetDriverCounter{humptydumpty}}} counter.
+\begin{docCommand}{LastAddedToCounter}{}
+This command has no arguments and expands to the name of the counter which was used last in \cs{addtocounter}. There is no further typesetting done with the countername.
-\end{dispExample}%
+\begin{dispExample}
+ \newcounter{SomeCounter}
+
+ \addtocounter{SomeCounter}{10}
+ The last counter something added to was \LastAddedToCounter.
+\end{dispExample}%
\end{docCommand}%
+\begin{marker}
+ Please note that \refCom{LastAddedToCounter} might fail!
+\end{marker}
-\begin{docCommand}{IsAssociatedCounter}{\marg{counter name}\marg{True branch}\marg{False branch}}%
-
-This commands tests, whether a given counter name is an associated counter and expands correspondingly the true or the false branch. The command does not tell to which driver the counter it is associated -- this information can be obtained by \refCom{GetDriverCounter}.
-\begin{docCommandArgs}{IfAssociatedCounter}%
+\begin{docCommand}{LastSteppedCounter}{}
+This command has no arguments and expands to the name of the counter which was stepped last using \cs{stepcounter}. There is no further typesetting done with the countername.
-\begin{codeoptionsenum}
-\item \marg{counter name}%
+\begin{dispExample}
+ \stepcounter{SomeCounter}
- Contains the name of the possibly associated counter
+ The last counter being stepped was \LastSteppedCounter.
+\end{dispExample}%
-\item \marg{True branch}
+\end{docCommand}%
- This code is expanded if the counter is associated to a driver, otherwise it is ignored
+\begin{docCommand}{LastRefSteppedCounter}{}
-\item \marg{True branch}
+\begin{dispExample}
+ \begin{equation}
+ E = mc^2 \label{eq::einstein}
+ \end{equation}
+ % \stepcounter{SomeCounter}
- This code is expanded if the counter is \textbf{not} associated a driver, otherwise it is ignored
+ The last counter being refstepped was \LastRefSteppedCounter.
+\end{dispExample}%
-\end{codeoptionsenum}
-\end{docCommandArgs}
+\end{docCommand}%
-\begin{dispExample}
-\IsAssociatedCounter{section}{Yes, section is an associated counter}{No, section counter does not have the associated counter properties}
-\IsAssociatedCounter{totalpages}{Yes, totalpages is an associated counter}{No, totalpages counter does not have the associated counter properties}
-\end{dispExample}
-\end{docCommand}%
+\begin{docCommand}{LastSetCounter}{}
+This command has no arguments and expands to the name of the counter which was set last using \cs{setcounter}. There is no further typesetting done with the countername.
-\begin{docCommand}{IsDriverCounter}{\marg{driver counter name}\marg{True branch}\marg{False branch}}%
+\begin{dispExample}
+ \setcounter{SomeCounter}{21}%
-This commands tests, whether a given counter name is a driver counter and expands correspondingly the true or the false branch.
+ The last counter being set was \LastSetCounter.
+\end{dispExample}%
-\begin{docCommandArgs}{IfDriverCounter}%
+\end{docCommand}%
-\begin{codeoptionsenum}
-\item \marg{driver counter name}%
- Contains the name of the possible driver counter
+\begin{docCommand}{LastCounterValue}{}
+This command has no arguments and expands to the value of the very last change of a counter, i.e. using \cs{setcounter} etc.
-\item \marg{True branch}
+\begin{dispExample}
+ \setcounter{SomeCounter}{100}%
- This code is expanded if the counter is a driver, otherwise it is ignored
+ The last counter being set was \LastSetCounter and it had the value \LastCounterValue{} then, where as \stepcounter{equation} will yield \fbox{\LastSteppedCounter} and \LastCounterValue!
+\end{dispExample}%
-\item \marg{True branch}
+The usage of \refCom{LastSetCounter} is best together with one of the other \cs{Last...} macros.
- This code is expanded if the counter is \textbf{not} a driver, otherwise it is ignored
-\end{codeoptionsenum}
-\end{docCommandArgs}
+\end{docCommand}%
+\begin{marker}
+All of the \cs{Last...} macros are expandable, i.e. it is possible to store the value to an macro defined with \cs{edef}
+\end{marker}
\begin{dispExample}
-\IsDriverCounter{section}{Yes, section is a driver counter}{No, section counter does not have driver properties}
-\end{dispExample}
-
-\end{docCommand}%
+ \setcounter{SomeCounter}{50}%
-\begin{docCommand}{IsSuspendedCounter}{\marg{counter name}\marg{true branch}\marg{false branch}}
-See \nameref{section::suspendedresumedcounters} on this topic.
+ \edef\lastcounterset{\LastSetCounter}
+ \edef\lastcountervalue{\LastCounterValue}
+
+ \setcounter{equation}{81}%
-This command checks, whether a counter is suspended, i.e. not updated at all and expands the corresponding branches.
-%\begin{docCommandArgs}{IfSuspendedCounter}%
+ The last counter being set was \fbox{\LastSetCounter} and it had the value \LastCounterValue{} then, but we changed \lastcounterset{} earlier and it had the value \lastcountervalue{} then.
+\end{dispExample}%
-\begin{codeoptionsenum}
-\item \marg{counter name}%
+\setcounter{equation}{1}
- Contains the name of counter presumed to be suspended
-\item \marg{True branch}
- This code is expanded if the counter is suspended, otherwise it is ignored
-\item \marg{True branch}
+\begin{marker}
+Please note, that all of this commands are only working in the current run of compilation, i.e. \underline{after} there has been some operation on the counters. They can't be used for information on the last changed counter in a previous run.
+\end{marker}
- This code is expanded if the counter is \textbf{not} suspended, otherwise it is ignored
-\end{codeoptionsenum}
-%\end{docCommandArgs}
-\end{docCommand}
+\section{Counter reset lists}
+The package \CHDocPackage{chngcntr} offers the possibility of add or remove counters to the reset list of a driver counter with the commands \cs{counterwithin} and \cs{counterwithout}, whereas the package \CHDocPackage{remreset} provides \cs{@removefromreset} as a counterpart to the \LaTeXe\ core command \cs{@addtoreset} macro.
-\subsubsection[\cs{IfIsDocumentCounter}-Queries]{Commands checking whether a name refers to a counter}
+\subsection[Addition and Removal]{Addition and Removal of counters from the reset list}\CHDocNew{1.0}
-\CHDocPackage{\PackageDocName}\ provides three commands that are quite similar -- all check whether \marg{name} is an already defined \LaTeXe\ counter (name), in good tradition with the \CHDocPackage{xparse} - syntax:
+\begin{docCommand}[before={\CHDocNew{1.0}}\par]{RemoveFromReset}{\marg{counter name}\marg{driver counter name}}
+This macro removes the counter given in the first argument from the reset list of the driver counter given in the 2nd argument.
-\begin{itemize}
-\item \begin{docCommand}{IfIsDocumentCounterTF}{\oarg{}\marg{name}\marg{true branch}\marg{false branch}}
-This macro performs the full branching
+If the 2nd argument does not point to a LaTeXe\ counter name an error message is shipped and the compilation fails.
\end{docCommand}
-\item
-\begin{docCommand}{IfIsDocumentCounterT}{\oarg{}\marg{name}\marg{\meta{long} true branch}}
-This command executes only if the name is a counter.
-\end{docCommand}
-\begin{docCommand}{IfIsDocumentCounterF}{\oarg{}\marg{name}\marg{true branch}}
-This command executes only if the name is not a counter.
+\begin{docCommand}[before={\CHDocNew{1.0}}]{RemoveFromFullReset}{\marg{counter name}\marg{driver counter name}}
+This macro removes the counter given in the first argument and all of its own reset list from the reset list of the driver counter given in the 2nd argument.
+
+If the 2nd argument does not point to a LaTeXe\ counter name an error message is shipped and the compilation fails.
\end{docCommand}
-\end{itemize}
+\begin{docCommand}[before={\CHDocNew{1.0}}]{AddToReset}{\marg{counter name}\marg{driver counter name}}
+This macro adds the counter given in the first argument to the reset list of the driver counter given in the 2nd argument.
-The optional argument is not used as of version \packageversion\ for none of those three commands.
+If the 2nd argument does not point to a LaTeXe\ counter name an error message is shipped and the compilation fails.
+\end{docCommand}
-\subsection[Macros about the reset list]{Information macros about the counter reset list}
+\subsection[Information macros about the reset list]{Information macros about the counter reset list}
Sometimes it might be necessary or convenient to know how many counters are on a reset list of some other counters, i.e. added by \cs{newcounter}\textbraceleft counter\textbraceright[resetting counter] or \refCom{NewDocumentCounter}.
@@ -908,6 +903,20 @@ This macro returns the number of counters being in the reset list of the counter
If the counter has no other counters in its reset list, the value of 0 is returned.
\end{docCommand}
+
+\begin{docCommand}[before={\CHDocNew{1.0}}\par]{CounterFullResetList}{\marg{counter name}}
+ This macro determines the full reset list of a counter as well of the counters being on the reset list, i.e. the list is tracked down until there are no counters left in a recursion.
+
+ The counter names are stored internally in \CHDocPackage{expl3} - \cs{seq} - variable named \cs{xy\_fullresetlist\_seq} -- the \meta{xy} is replaced by the counter name, e.g. if the counter is named \CHDocCounter*{foo}, the identifier would be \cs{foo\_fullresetlist\_seq}. Unless \CHDocTag{expl3} features are not applied, the \refCom{CounterFullResetList} is not really useful on a document or package/class developing level. However, to loop through the full reset list with some action performed on the members of the sequence, the command \refCom{LoopFullCounterResetList} may be very useful.
+
+\begin{marker}
+\begin{itemize}
+\item The driver counter \CHDocCounter*{foo} is not added to the relevant sequence.
+\item If the name given to \refCom{CounterFullResetList} does not indicate a \LaTeXe\ counter an error message is shipped and the compilation fails.
+\end{itemize}
+\end{marker}
+\end{docCommand}
+
\begin{docCommand}{IfInResetListTF}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{true branch}\marg{false branch}}
This command sequence tests whether the counter \meta{reset counter} is in the reset list of \meta{resetting counter} and expands the relevant branch then.
See the short-circuit commands \refCom{IfInResetListT} and \refCom{IfInResetListF} as well.
@@ -946,528 +955,748 @@ This command displays the reset list of a counter on the terminal as the \cs{sho
\end{docCommand}
+\section[Loops on multiple counters]{Performing the same action for many counters} \CHDocNew{0.7}
+Sometimes it might be necessary to set the values of many counters at once. This can be done with consecutive \cs{setcounter} statements, for example. This poses no problem, but might become tedious if there are more than three counters or if this task occurs more than once. \CHDocPackage{\PackageDocName} provides some macros that can do the usual operations like stepping, refstepping, adding to, resetting or setting counter values.
-\subsection[Information macros]{Information on counters} \label{subsection::informationcmds}
-On occasions it might be important to have some information which counter has been changed last. Since there are four commands manipulating counter values, there are four corresponding routines for this:
+All macros concerning this feature use the first macro argument having a comma-separated list of counters. Whether there's a second argument depends on the specific nature of the operation that should be performed.
-\begin{docCommand}{LastAddedToCounter}{}
-This command has no arguments and expands to the name of the counter which was used last in \cs{addtocounter}. There is no further typesetting done with the countername.
+\begin{marker}
+\begin{itemize}
+\item As of version \packageversion\ \PackageDocName\ does not check whether the names given in the first argument refer to counters.
+\item All macros use the extended counter macros, i.e. are aware of associated counters and step them too if their driver counter is given in the argument list. If an associated counter itself is given in the list, this one is stepped or operated on too!
+\end{itemize}
+\end{marker}
-\begin{dispExample}
- \newcounter{SomeCounter}
-
- \addtocounter{SomeCounter}{10}
- The last counter something added to was \LastAddedToCounter.
-\end{dispExample}%
-\end{docCommand}%
+\begin{docCommand}[before={\CHDocNew{0.7}}]{LoopAddtoCounters}{\marg{counter1, counter2,\dots}\marg{counter increment/decrement}}
+
+%\begin{docCommandArgs}{LoopAddToCounters}%
+The 2nd argument value is added (or subtracted) to the counters given in the list of the 1st argument using the \cs{addtocounter}.
+
+\begin{codeoptionsenum}
+ \item \marg{counter1, counter2,\dots}
+ Holds the comma separated list of counter names
+ \item \marg{counter increment/decrement}
+ Specifies the value to be added or subtracted
+
+ No check is performed whether \textbf{is} or \textbf{expands} to an integer value.
+ \end{codeoptionsenum}
+%\end{docCommandArgs}
+
+\end{docCommand}
+
+
+\begin{docCommand}[before={\CHDocNew{0.7}}]{LoopResetCounters}{\marg{counter1, counter2,\dots}}
+
+
+%\begin{docCommandArgs}{LoopResetCounters}%
+All counters given in the first argument are set to zero using the regular \cs{setcounter}. This is a shorthand version of \refCom{LoopSetCounters} for this specific case.
+
+
+\begin{codeoptionsenum}
+ \item \marg{counter1, counter2,\dots}
+ Holds the comma separated list of counter names
+ \end{codeoptionsenum}
+%\end{docCommandArgs}
+
+\end{docCommand}
+
+
+\begin{docCommand}[before={\CHDocNew{0.7}}]{LoopRefstepCounters}{\marg{counter1, counter2,\dots}}
+
+%\begin{docCommandArgs}{LoopStepCounters}%
+All counters given in the first argument are stepped using the regular \cs{refstepcounter} to allow labels -- however, only the last counter will have the correct label reference.
\begin{marker}
- Please note that \refCom{LastAddedToCounter} might fail!
+ This macro is meant only to complete the number of \cs{Loop...Counters} but is not regarded as being really useful.
\end{marker}
+\begin{codeoptionsenum}
+ \item \marg{counter1, counter2,\dots}
+ Holds the comma separated list of counter names
+ \end{codeoptionsenum}
+%\end{docCommandArgs}
-\begin{docCommand}{LastSteppedCounter}{}
-This command has no arguments and expands to the name of the counter which was stepped last using \cs{stepcounter}. There is no further typesetting done with the countername.
+\end{docCommand}
-\begin{dispExample}
- \stepcounter{SomeCounter}
- The last counter being stepped was \LastSteppedCounter.
-\end{dispExample}%
-\end{docCommand}%
+\begin{docCommand}[before={\CHDocNew{0.7}}]{LoopSetCounters}{\marg{counter1, counter2,\dots}\marg{new counter value}}
-\begin{docCommand}{LastRefSteppedCounter}{}
+%\begin{docCommandArgs}{LoopAddToCounters}%
+The 2nd argument value is used as new counter value added (or subtracted) to the counters given in the list of the 1st argument using the \cs{addtocounter}.
-\begin{dispExample}
- \begin{equation}
- E = mc^2 \label{eq::einstein}
- \end{equation}
- % \stepcounter{SomeCounter}
+\begin{codeoptionsenum}
+ \item \marg{counter1, counter2,\dots}
+ Holds the comma separated list of counter names
+ \item \marg{new counter value}
+ Specifies the value to be set.
- The last counter being refstepped was \LastRefSteppedCounter.
-\end{dispExample}%
+ No check is performed whether \textbf{is} or \textbf{expands} to an integer value.
+ \end{codeoptionsenum}
+%\end{docCommandArgs}
-\end{docCommand}%
+\end{docCommand}
+\begin{docCommand}{LoopStepCounters}{\marg{counter1, counter2,\dots}} \CHDocNew{0.7}
+\begin{docCommandArgs}{LoopStepCounters}%
+All counters given in the first argument are stepped using the regular \cs{stepcounter}.
+\begin{codeoptionsenum}
+ \item \marg{counter1, counter2,\dots}
+ Holds the comma separated list of counter names
+ \end{codeoptionsenum}
+\end{docCommandArgs}
-\begin{docCommand}{LastSetCounter}{}
-This command has no arguments and expands to the name of the counter which was set last using \cs{setcounter}. There is no further typesetting done with the countername.
+\end{docCommand}
-\begin{dispExample}
- \setcounter{SomeCounter}{21}%
- The last counter being set was \LastSetCounter.
-\end{dispExample}%
+A more general command for doing "arbitrary" operations with counters (and more setup, for example) is
-\end{docCommand}%
+\begin{docCommand}{LoopCountersFunction}{\marg{counter1, counter2,\dots}\marg{counter operation macro}} \CHDocNew{0.7}
+\begin{docCommandArgs}{LoopAddToCounters}%
+The 2nd argument value should hold a macro with any number of arguments, but the last mandatory argument of this macro is reserved for counter name.
+
+\begin{codeoptionsenum}
+ \item \marg{counter1, counter2,\dots}
+ Holds the comma separated list of counter names
+ \item A macro name that is to be called and that operates on a counter.
+ \end{codeoptionsenum}
+\end{docCommandArgs}
+
+\end{docCommand}
-\begin{docCommand}{LastCounterValue}{}
-This command has no arguments and expands to the value of the very last change of a counter, i.e. using \cs{setcounter} etc.
\begin{dispExample}
- \setcounter{SomeCounter}{100}%
+ % We assume we have the counters foocntr and foobarcntr
+ \newcommand{\showcountervalues}[2]{%
+ \textcolor{#1}{\csname the#2\endcsname}% Now, an extra empty line to show the values in rows
+
+ }
+ % Note that the 2nd argument is not given here -- it's added by the \LoopCountersFunction macro
+ \LoopCountersFunction{foocntr,foobarcntr}{\showcountervalues{blue}}
+\end{dispExample}
- The last counter being set was \LastSetCounter and it had the value \LastCounterValue{} then, where as \stepcounter{equation} will yield \fbox{\LastSteppedCounter} and \LastCounterValue!
-\end{dispExample}%
-The usage of \refCom{LastSetCounter} is best together with one of the other \cs{Last...} macros.
+\begin{docCommand}[before={\CHDocNew{1.0}}\par]{LoopFullCounterResetList}{\marg{counter name}\marg{counter operation macro}}
+This macro determines the full reset list of a counter, i.e. it cascades down the reset list and tracks the reset lists of all 'sub'-counters too and performs the counter operation macro on this.
+\begin{codeoptionsenum}
+ \item \marg{counter name}
-\end{docCommand}%
+ Holds the comma separated list of counter names
+ \item \marg{counter operation macro}
+ A macro name that is to be called and that expects the name of a counter as the last argument.
+ \end{codeoptionsenum}
+
+See the macro \refCom{CounterFullResetList} for more information about the internal storage of the full reset list.
+
+\end{docCommand}
+
+
+\section{Counter output}\CHDocNew{0.7}
+
+Once in a while it might be necessary to provide counter output not only as integer numbers, letters or Roman figures but also using binary, octal or hexdecimal number output. The \CHDocPackage{fmtcount} package has support for this already -- here are some alternatives
\begin{marker}
-All of the \cs{Last...} macros are expandable, i.e. it is possible to store the value to an macro defined with \cs{edef}
+None of the commands checks whether the argument refers to counter name.
\end{marker}
+\begin{docCommand}[doc new={\chdocextractversion{xassoccntversion0.7}}]{BinaryValue}{\marg{counter name}}% \CHDocNew{0.7}
-\begin{dispExample}
- \setcounter{SomeCounter}{50}%
+This command will print the value of the counter using binary digits.
- \edef\lastcounterset{\LastSetCounter}
- \edef\lastcountervalue{\LastCounterValue}
-
- \setcounter{equation}{81}%
+\end{docCommand}
+\begin{docCommand}{hexValue}{\marg{counter name}} \CHDocNew{0.7}
- The last counter being set was \fbox{\LastSetCounter} and it had the value \LastCounterValue{} then, but we changed \lastcounterset{} earlier and it had the value \lastcountervalue{} then.
-\end{dispExample}%
+This command will print the value of the counter using lowercase hexadecimal digits.
-\setcounter{equation}{1}
+\end{docCommand}
+\begin{docCommand}{HexValue}{\marg{counter name}} \CHDocNew{0.7}
+This command will print the value of the counter using uppercase hexadecimal digits.
+\end{docCommand}
-\begin{marker}
-Please note, that all of this commands are only working in the current run of compilation, i.e. \underline{after} there has been some operation on the counters. They can't be used for information on the last changed counter in a previous run.
-\end{marker}
+\begin{docCommand}{OctalValue}{\marg{counter name}} \CHDocNew{0.7}
+This command will print the value of the counter using uppercase hexadecimal digits.
+\end{docCommand}
-\section[Suspending and Resuming]{Suspending and resuming (associated) counters}\label{section::suspendedresumedcounters}
+\clearpage
+\part{Features}
+\parttoc
-Rather than removing an associated counter from the list, it is possible to suspend the automatic stepping for a while and then resume it (or completely drop it), for example, if the value of a counter should not be stepped within a specific chapter etc.
+\section{Associated counters}
+\tcbset{color command={blue}}
-\CHDocNew{0.8}
-\begin{marker}
- Suspension and resuming counters can cause wrong hyper links if \CHDocPackage{hyperref} is used.
-\end{marker}
+The main purpose of this package is co-stepping of counters, but there are some helper commands in addition to macros provided \LaTeXe\ already, see section \nameref{section::additions_to_l2e}.
-\begin{docCommand}{SuspendCounters}{\oarg{options}\marg{counters list}}%
-\begin{docCommandArgs}{SuspendCounters}%
+\begin{itemize}
+ \item Section \nameref{subsection::associatedcounterscmds} describes the most important macros for setting up associated counters
+ \item Section \nameref{subsection::drivercounterscmds} informs about the macros for setting up, removing or clearing driver counters
+ \item Section \nameref{subsection::querycmds} deals with query command sequences about counters being a driver or an associated counters
+ \item Section \nameref{subsection::informationcmds} contains routines that show which counters have been changed last
+\end{itemize}
+
+
+
+\subsection[Association macros]{Associated counters commands}\label{subsection::associatedcounterscmds}
+
+All macros have the general rule, that the driver counter is specified as 1st mandatory argument to the macro, which is in almost all cases the 2nd argument of the macro.
+
+
+\begin{docCommand}{DeclareAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
+This command is the main macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}. If only counter is to be associated, omit a trailing ","!
+
+%\begin{docCommandArgs}{DeclareAssociatedCounters}
\begin{codeoptionsenum}
-\item \oarg{options}%
-
- Not used so far, reserved for later usage.
+ \item \oarg{options}: %As of \packageversion, the optional argument \oarg{options} is not used so far, but is reserved for later purposes.
+ \begin{docKey}[][]{autodefine}{=\meta{choice}}{initially none}
+ This choice - key can be specified if the specified counters should be defined if they not already available.
+ Possible values are
+ \begin{itemize}
+ \item \texttt{none} -- no counter is autodefined
+ \item \texttt{all} -- all counters will be autodefined
+ \item \texttt{driver} -- only driver counters will be autodefined
+ \item \texttt{associated} -- only associated counters will be autodefined
+ \end{itemize}
+ \end{docKey}
+ Default is \texttt{none}
+ \begin{docKey}[][]{sloppy}{}{}
+ If \refKey{autodefine} key is used, the \texttt{sloppy} key disables the check whether a counter is defined already.
+ \end{docKey}
-\item \marg{counters list}%
+ \item \marg{driver counter}
- Contains the name of counters to be suspended, separated by commas (CSV - list)
+ Holds the name of the driver counter to which the list of counters should be associated
+\item \marg{associated counters list}
+
+ A comma separated list of counter names that should be associated to the driver counter
\end{codeoptionsenum}
-\end{docCommandArgs}
-\end{docCommand}%
+%\end{docCommandArgs}
-\begin{docCommand}{CascadeSuspendCounters}{\oarg{options}\marg{counters list}}\CHDocNew{0.8}
-This macro is more powerful than \refCom{SuspendCounters}, since it tries to detect whether a counter has a reset list and 'mutes' the counters on this list as well and checks whether those counters themselves have reset lists and cascades down to the final state.
+\begin{itemize}
+\item This command is a preamble command, i.e. it can be used in the preamble of the document or within other packages or class files only.
+\item This command should be used as early as possible, i.e. in the preamble of the document, since the driven counters are not increased as long as they are not associated to the driver counter. On the hand, it is possible or may be required to control the starting point of the association at any position in the body of the document, when the association should start later on. Use the command \refCom{AddAssociatedCounters} if counters should be associated within the document body.
+\end{itemize}
-\begin{marker}
- Stated differently: All counters anyhow connected to a counter named \CHDocCounter{foo} will be suspended, e.g. for the \CHDocClass{book} class and \CHDocCounter{chapter}, this means in a standard setup, that \CHDocCounter*{section,figure,table,equation,footnote} will be suspended, as well as in consequence \CHDocCounter*{subsection,subsubsection,paragraph,subparagraph}, assuming hereby no other counters have been added to the reset lists.
-\end{marker}
+% Relax for documentation purposes
+\renewcommand{\DeclareAssociatedCounters}[3][]{\relax}%
+\begin{dispExample}
+%%%% The association of anothertotalpages in this example just takes place here, so the stepping of the counter will start from here and providing a 'wrong' value.
+%%%%
+\DeclareAssociatedCounters{page}{totalpages,anothertotalpages}%
+This document has \number\totvalue{totalpages} (note: \number\totvalue{anothertotalpages}) pages.
+\end{dispExample}
-\begin{docCommandArgs}{CascadeSuspendCounters}%
+\begin{itemize}
+ \item Current version (\packageversion) rules:
+ \begin{itemize}
+ \item No checking whether the 2nd and 3rd arguments hold counter names is applied.
+ \item Mutually cross - association of two counters is not supported! The compilation will stop on this!
+ \CHDocUpdate{0.6}
+
+ A driver counter, say, \CHDocCounter{foo}) of, say \CHDocCounter{foobar} can not be an associated counter of \CHDocCounter{foobar}, which in turn can be a driver counter of other counters, of course.
+
+ A contrary feature are the \CHDocTag{coupled counters} -- If some counters should share a common base, i.e. increasing one arbitrary member counter of a group of counters then all should be increased, this called coupling of counters -- all group members are on an equal footing. See \cref{sec::coupledcounters} about this feature.
+
+ On the other side, \CHDocTag{associated counters} belong to a hierarchy. The driver counter dominates the associated counters.
+
+ \end{itemize}
+ \item A self-association of the driver counter to itself is ignored internally as this would lead to inconsistent counter values.
+ \item The order of the specification of associated counters in the 2nd arguments is of no importance.
+ \item Specifing an associated counter name multiple times has no effect, only the first occurence of the name will be used.
+\end{itemize}
+
+\end{docCommand}
+
+
+\begin{docCommand}{AddAssociatedCounters}{\oarg{options}\marg{driver counter}\marg{associated counters list}}
+The usage of this macro is similar to \refCom{DeclareAssociatedCounters}; if it is called in the document preamble (or in package file), \refCom{AddAssociatedCounters} falls back to
+\begin{center}\refCom{DeclareAssociatedCounters},\end{center} having the same optional argument functionality with \refKey{autodefine} and \refKey{sloppy}; if it is called in the document body, this command adds some counters to the associated counter list for a specific driver counter -- if this list does not exists, the \LaTeX{} run will issue a warning, but add the driver counter to the driver list and the associated counters analogously.
+\marginnote{\bcbombe}
+
+Using \refCom{AddAssociatedCounters} in the document body automated generation of counters is disabled.
+
+% You have to use \refCom{DeclareAssociatedCounters} first, to set up the driver counter hook.
+
+
+\begin{docCommandArgs}{AddAssociatedCounters}
\begin{codeoptionsenum}
-\item \oarg{options}%
+ \item \oarg{options}: As of version \packageversion, the optional argument \oarg{options} are the same as for \refCom{DeclareAssociatedCounters}, see \refKey{autodefine} and \refKey{sloppy}.
- Not used so far, reserved for later usage.
+ \item \marg{driver counter}
-\item \marg{counters list}%
+ Holds the name of the driver counter to which the list of counters should be associated
+ \item \marg{associated counters list}
- Contains the name of counters to be suspended, separated by commas (CSV - list)
+ A comma separated list of counter names that should be associated to the driver counter
\end{codeoptionsenum}
\end{docCommandArgs}
-\end{docCommand}%
-\begin{docCommand}{ResumeSuspendedCounters}{\oarg{options}\marg{counters list}}
- As of version \packageversion\ the optional argument is not used and reserved for later purposes.
- This command revokes the suspension of the counters in the \marg{counters} list.
-\end{docCommand}
+% macro of the package. It declares the counter names being specified in comma - separated - list (CSV) which should be stepped simultaneously when the driver counter is increased by \cs{stepcounter}.
-\begin{docCommand}{ResumeAllSuspendedCounters}{\oarg{options}} \CHDocNew{0.8}
- As of version \packageversion\ the optional argument is not used and reserved for later purposes.
- This command revokes all suspended counters.
+\end{docCommand}%
+
+\begin{docCommand}{RemoveAssociatedCounter}{\marg{driver counter}\marg{associated counter}}
+This command removes a counter from the existing list for a driver counter, i.e. the counter will not be increased any longer by \cs{stepcounter}. It can be increased however manually, of course.
\end{docCommand}
-\begin{marker}
-If a driver counter is suspended, all counters associated to it are suspended too!
-\end{marker}
-\setcounter{totalequations}{0}
-\setcounter{equation}{0}
-\renewcommand{\DeclareAssociatedCounters}[3][]{\relax}%
\begin{dispExample}
-\textbf{This example shows 4 equations, but only two of them are counted}
+\RemoveAssociatedCounter{page}{anothertotalpages}
+This document has \number\totvalue{totalpages} (beware: \number\totvalue{anothertotalpages}) pages.
+\end{dispExample}
-\begin{equation}
-E_{0} = mc^2
-\end{equation}
-Now suspend the equations:
-\SuspendCounters{equation}
-\begin{equation}
-E^2 = \left({ pc}\right)^2 + E^{2}_{0}
-\end{equation}
+\begin{docCommand}{RemoveAssociatedCounters}{\marg{driver counter}\marg{list of associated counters}}
+This command removes the comma-separated-value list of counters from the existing list for a driver counter, i.e. the counters will not be increased any longer by \cs{stepcounter}. They can be increased however manually, of course.
-\begin{equation}
- m(v) = \frac{m_{0}}{\sqrt{1-\frac{v^2}{c^2}}}
-\end{equation}
+Take care not to confuse the commands \refCom{RemoveAssociatedCounters}
+and{}\linebreak \refCom{RemoveAssociatedCounter}
+\end{docCommand}
-And resume it: \ResumeSuspendedCounters{equation}
+\begin{docCommand}{ClearAssociatedCounters}{\oarg{options}\marg{driver counter}}
+This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically any longer.
-\begin{equation}
- E = h \nu
-\end{equation}
+The optional argument is not used as of version \packageversion.
-There are \number\totvalue{totalequations}~equations in here!
+Please note that the driver counter is not removed from the list of driver counters -- this simplifies reassociating of (other) counters to this one later on with the macro \refCom{AddAssociatedCounters} and suppress the relevant warning.
-\end{dispExample}
+If the driver counter and all its associated counters should be removed, use \refCom{RemoveDriverCounter} instead.
+\end{docCommand}
+\clearpage
-\section[Additions and extensions to standard commands]{Additions and extensions to standard counter related commands}\label{section::additions_to_l2e}
-\subsection{Extension of \LaTeXe\ commands}\label{subsection::extension_of_l2e_commands}
+\subsection[Driver macros]{Driver counter commands} \label{subsection::drivercounterscmds}
-\begin{docCommand}[before={\CHDocNew{0.9}}]{addtocounter}{\marg{counter}\marg{increment value}\oarg{options}}
- The \refCom{addtocounter} macro behaves like the usual \cs{addtocounter} counter, but takes care to specific counter features such as \CHDocTag{periodic counters} and has an optional argument in order to perform special settings.
-As of \packageversion, there is only one option used:
-\begin{docKey}[][after={\CHDocNew{0.9}}]{wrap}{=\meta{true/false}}{initially true}
+\begin{docCommand}{AddDriverCounter}{\oarg{options}\marg{driver counter name}}
- This key determines whether addition of values to a periodic counter (see \nameref{section:periodic_counters}) will lead to a modulo part addition.
-\end{docKey}
+\begin{docCommandArgs}{AddDriverCounter}%
-\end{docCommand}
-
+\begin{codeoptionsenum}
+\item \oarg{options}: As of \packageversion, the optional argument \oarg{options} is not used so far, but is reserved for later purposes.
-\subsection{Additions to \LaTeXe\ commands}
+ \item \marg{driver counter name}
-\begin{docCommand}{NewDocumentCounter}{\oarg{options}\marg{counter}\oarg{resetting counter}}
- This command is a new interface to \cs{newcounter} and behaves effectively the same. %The first optional argument is reserved for later purposes but not used as of version \packageversion.
-
- \begin{docKey}{initial}{=\meta{integer value}}{initially 0}
- This is used for the start value of the new counter.
- \end{docKey}
+ Holds the name of the driver counter that should be added to the list of driver counters.
+\end{codeoptionsenum}
+\end{docCommandArgs}
\end{docCommand}%
-\begin{docCommand}{DeclareDocumentCounter}{\oarg{options}\marg{counter}\oarg{resetting counter}}
- This command is the preamble-only version of \refCom{NewDocumentCounter}.
-\end{docCommand}%
-\begin{docCommand}{SetDocumentCounter}{\oarg{options}\marg{counter}\marg{counter value}}
+\begin{docCommand}{RemoveDriverCounter}{\oarg{options}\marg{driver counter}}
+This command clears the internal list for all counters associated to the \marg{driver counter}. The counters will not be increased automatically any longer.
+
+The optional argument is not used as of version \packageversion.
+
+If all driver counters should be unregistered, use \refCom{ClearDriverCounters} instead!
+\end{docCommand}
+
+
+\begin{docCommand}{ClearDriverCounters}{\oarg{options}}%
+
+This clears completely the list of driver counters, such that no counters are regarded as being associated -- i.e. no driver is hold as being a driver counter.
+
+The optional argument is not used as of version \packageversion.
+
+\end{docCommand}
+
+
+\subsection[Query macros]{Commands for queries} \label{subsection::querycmds}
+
+Sometimes it might be necessary to get information, whether a counter is regarded as a driver or as an associated counter. This section describes some query macros in order to obtain this information.
+
+
+\begin{docCommand}{IsAssociatedToCounter}{\marg{driver counter}\marg{associated counter}\marg{True branch}\marg{False branch}}
+This macro checks, whether a counter is associated to a particular given driver counter and expands the corresponding branch. If the internal driver counter list does not exist, the false branch will be used, since this also means, that the possibly associated counter is not associated at all.
-This command behaves like the standard macro \cs{setcounter}, but has an additional optional 1st argument. %which is not used as of version \packageversion.
-% This optional argument can be used to enable the setting of the driver counter value as well as the associated counter values at once.
-\begin{docCommandArgs}{SetDocumentCounter}%
+\begin{docCommandArgs}{IsAssociatedToCounter}%
\begin{codeoptionsenum}
- \item \oarg{options}: %As of version \packageversion, this option is not used% the key value argument
+ \item \marg{driver counter}
- \begin{docKey}{associatedtoo}{=\meta{true/false}}{initially false}
- If enabled (\meta{true}), \refCom{SetDocumentCounter} will use the counter value for \underline{all} counters associated to this driver counter as well. Initially, this option is set to \meta{false}.
- \end{docKey}
+ Holds the name of the driver counter to which \marg{associated counter} the could possibly be associated.
+\item \marg{associated counter}
- \begin{docKey}{onlycounters}{=\meta{comma separated list of counters}}{initially empty}
- If this key is used, only those associated counters are set as well that are given in the comma separated list.
-
- Names, that are either not referring to counters at all or to counters that are not associated to the given driver counter will be ignored silently.
- \end{docKey}
+ Contains the name of the possibly associated counter.
-
+\item \marg{True branch}
+ This code is expanded if the counter is associated to the driver, otherwise it is ignored.
+\item \marg{True branch}
- \item \marg{counter}
- Holds the name of the (driver) counter to be set.
- \item \marg{counter value}
- Holds the value to be set
- \end{codeoptionsenum}
+ This code is expanded if the counter is \textbf{not} associated to the driver, otherwise it is ignored.
+
+\end{codeoptionsenum}
\end{docCommandArgs}
-Some notes on \refCom{SetDocumentCounter}
+
+\begin{dispExample}
+% Remove associated counter first for demonstration purposes
+\RemoveAssociatedCounter{page}{anothertotalpages}
+\IsAssociatedToCounter{page}{totalpages}{Yes, totalpages is associated}{No, totalpages is not associated}
+
+\IsAssociatedToCounter{page}{anothertotalpages}{Yes, anothertotalpages is associated}{No, anotherpages is not associated}
+\end{dispExample}
+
+See also
+
\begin{itemize}
- \item The option keys \refKey{associatedtoo} and \refKey{onlycounters} are mutually exclusive! %
- \item The counter to be set can be either a driver counter or an otherwise associated counter.
+ \item \refCom{IsAssociatedCounter} for checking whether a counter is associated
+ \item \refCom{IsDriverCounter} in order to check whether a counter is a driver.
+ \item \refCom{GetDriverCounter} returns the driver counter name for a given associated counter name
\end{itemize}
-\end{docCommand}%
-\begin{docCommand}{StepDownCounter}{\oarg{options}\marg{counter}}\CHDocNew{0.4}
-This macro subtracts the value of 1 from the counter and is the counterpart of \cs{stepcounter}.
+\end{docCommand}
-\begin{docCommandArgs}{StepDownCounter}%
+\begin{docCommand}{GetDriverCounter}{\marg{counter name}}%
-\begin{codeoptionsenum}
- \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
- \item \marg{counter}
- Holds the name of the first counter.
- \end{codeoptionsenum}
-\end{docCommandArgs}
+This commands returns the driver counter to which the counter name of the first argument is connected to. If the counter is not defined, the macro returns nothing.
-\end{docCommand}%
+\begin{itemize}
+ \item No check whether the counter name is defined is performed
+ \item No check whether the counter is associated at all is performed. Usage of this command in conjunction with \refCom{IsAssociatedCounter} is strongly encouraged.
+\end{itemize}
-\begin{docCommand}{SubtractFromCounter}{\oarg{options}\marg{counter}\marg{delta value}}\CHDocNew{0.4}
+\begin{dispExample}%
+totalpages is associated to the \textcolor{blue}{\textbf{\GetDriverCounter{totalpages}}} counter.
+% Try with an undefined counter name
+humptydumpty is associated to the \textcolor{blue}{\textbf{\GetDriverCounter{humptydumpty}}} counter.
-This macro subtracts the (positive) delta value from the counter and is the counterpart of \cs{addtocounter}
+\end{dispExample}%
-\begin{docCommandArgs}{SubtractFromCounter}%
+\end{docCommand}%
-\begin{codeoptionsenum}
- \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
+\begin{docCommand}{IsAssociatedCounter}{\marg{counter name}\marg{True branch}\marg{False branch}}%
- \item \marg{counter 1}
- Holds the name of the first counter.
- \item \marg{delta value}
- Holds the (positive) value to be subtracted from the counter value.
- \end{codeoptionsenum}
-\end{docCommandArgs}
+This commands tests, whether a given counter name is an associated counter and expands correspondingly the true or the false branch. The command does not tell to which driver the counter it is associated -- this information can be obtained by \refCom{GetDriverCounter}.
-\end{docCommand}%
+\begin{docCommandArgs}{IfAssociatedCounter}%
+\begin{codeoptionsenum}
+\item \marg{counter name}%
-\begin{docCommand}{CopyDocumentCounters}{\oarg{options}\marg{source counter}\marg{target counter}}
+ Contains the name of the possibly associated counter
-This document copies the counter value from the source counter in argument 2 to the target counter in argument 3.
+\item \marg{True branch}
-\begin{docCommandArgs}{CopyDocumentCounters}%
+ This code is expanded if the counter is associated to a driver, otherwise it is ignored
+\item \marg{True branch}
-\begin{codeoptionsenum}
- \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
+ This code is expanded if the counter is \textbf{not} associated a driver, otherwise it is ignored
- \item \marg{source counter}
- Holds the name of the source counter.
- \item \marg{target counter}
- Holds the name of the target counter.
- \end{codeoptionsenum}
+\end{codeoptionsenum}
\end{docCommandArgs}
+
+\begin{dispExample}
+\IsAssociatedCounter{section}{Yes, section is an associated counter}{No, section counter does not have the associated counter properties}
+\IsAssociatedCounter{totalpages}{Yes, totalpages is an associated counter}{No, totalpages counter does not have the associated counter properties}
+\end{dispExample}
+
\end{docCommand}%
-\begin{docCommand}{SwapDocumentCounters}{\oarg{options}\marg{counter 1}\marg{counter 2}}
-This macro swaps the values of the counters given in arguments 2 and 3
+\begin{docCommand}{IsDriverCounter}{\marg{driver counter name}\marg{True branch}\marg{False branch}}%
-\begin{docCommandArgs}{SwapDocumentCounters}%
+This commands tests, whether a given counter name is a driver counter and expands correspondingly the true or the false branch.
+\begin{docCommandArgs}{IfDriverCounter}%
\begin{codeoptionsenum}
- \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
+\item \marg{driver counter name}%
- \item \marg{counter 1}
- Holds the name of the first counter.
- \item \marg{counter 2}
- Holds the name of the second counter.
- \end{codeoptionsenum}
+ Contains the name of the possible driver counter
+
+\item \marg{True branch}
+
+ This code is expanded if the counter is a driver, otherwise it is ignored
+
+\item \marg{True branch}
+
+ This code is expanded if the counter is \textbf{not} a driver, otherwise it is ignored
+\end{codeoptionsenum}
\end{docCommandArgs}
+
+\begin{dispExample}
+\IsDriverCounter{section}{Yes, section is a driver counter}{No, section counter does not have driver properties}
+\end{dispExample}
+
\end{docCommand}%
-\begin{docCommand}{SyncCounters}{\oarg{options}\marg{driver counter}}
-This document synchronizes the driver counter value to the associated values. It has the same options as \refCom{SetDocumentCounter}. If the given counter is no driver counter, nothing is done.
+\section[Counter backup/restoration]{Backup and restore of counter values}\label{section::new_backuprestore}\CHDocNew{1.0}
-\begin{docCommandArgs}{SyncCounters}%
+It might be necessary to interrupt the current sectioning, e.g. including another document's structure (an external paper, for example) such that the counting should start again and after finishing of the external structure the old values should be restored.
-\begin{codeoptionsenum}
- \item \oarg{options}: see \refCom{SetDocumentCounter}
+\begin{marker}
+ Since version \CHDocFullVersion{1.0} the commands and feature behaviour of backup and restoration of counter values has changed.
- \item \marg{source counter}
- Holds the name of the source counter.
- \end{codeoptionsenum}
-\end{docCommandArgs}
+ The old behaviour is still available using the macros \cs{Former...} prefixed macros, see \cref{section::old_backuprestore} for this.
+\end{marker}
-\end{docCommand}%
+\subsection{Key philosophy in backup/restore}
-\begin{dispExample}%[breakable=true]
- \SetDocumentCounter{foocntr}{17}
- \SetDocumentCounter{foobarcntr}{20}
+The basic idea is to provide a scheme that allows easy storage and restoration of counter values. For a single counter this is quite easy, using some other temporary counter, storing the old value there and copy the values back at the right position -- if many counters should be controlled to have a backup this procedure might get tedious, however.
-\begin{itemize}
-\item Displaying counters
+\CHDocPackage{xassoccnt} provides some tools to define groups of counters that should be under control of backup and restoration. A backup counter group can be used multiple times, each using an individual ID, this allows maintaining 'complete' counter states and reinjecting them at any position later on.
- \thefoocntr\ and \thefoobarcntr
-\item Swapping counters
+Those are the basic steps (in pseudo code) to use the backup feature:
- \SwapDocumentCounters{foocntr}{foobarcntr}
+\begin{enumerate}
+ \item Define a symbolic backup counter group name
- \thefoocntr\ and \thefoobarcntr
+ Note that counter group names are providing something like a namespace. A group of coupled counters (see \namecref{sec::coupledcounters} \nameref{sec::coupledcounters}) may have the same name as a group of counters designed to be backed up -- however, each feature has its own namespace. In each namespace there can be only one counter group with a specific name, duplicates are not allowed within the same feature namespace.
+ \item Populate the counter group name with counter names
+ \item Define a backup state and a corresponding id
+ \item Restore at any place
+\end{enumerate}
-\item Step down counters
+\subsection{The default counter group "scratch"}
-\StepDownCounter{foocntr}
-\StepDownCounter{foobarcntr}
+There is a default counter group for backup named "scratch", if no specific counter group name is given using the \refKey{name} option (see \cref{subsubsec::common_options_backuprestore} for a detailed description of available backup/restore options).
- \thefoocntr\ and \thefoobarcntr
+\subsection{Description of basic backup/restore macros}
-\item Subtracting some value from the counters
- \SubtractFromCounter{foocntr}{5}
- \SubtractFromCounter{foobarcntr}{10}
+\subsubsection{Common options to (most) of the backup/restore macros} \label{subsubsec::common_options_backuprestore}
- \thefoocntr\ and \thefoobarcntr
+\begin{itemize}
+\item
+ \begin{docKey}[][]{resetbackup}{=\meta{true/false}}{initially true}
+ This key decides whether \textbf{all} counters in the backup list should be reset to zero or should keep the current value when the backup command is given. The default value is \meta{true}.
+ \end{docKey}
+\item \begin{docKey}[][]{cascading}{=\meta{true/false}}{initially false}
+ This key decides whether all counters in the reset list of a driver counter shall be added to the counter group -- the driver counter is added itself too. If the driver counter has no reset list, it is added nevertheless.
+
+ Please note that the reset lists of the individual counters are tracked as well -- this is done recursively.
+
+ This provides a very convenient feature to backup and restore the value of a certain sectioning level, say \cs{chapter}. Using \refKey{cascading} this would mean\footnote{Assuming \CHDocClass{book} is used, for example!} that \CHDocCounter{chapter}, \CHDocCounter{section}, \CHDocCounter{subsection},\CHDocCounter{subsubsection}, \CHDocCounter{paragraph}, \CHDocCounter{subparagraph}, \CHDocCounter{equation}, \CHDocCounter{figure} and \CHDocCounter{table} would be added to the counter group.
+ \end{docKey}
+ \item \begin{docKey}[][]{backup-id}{=string}{no default value}
+ This key declares a string-like backup id under which the backup of a certain group is stored and can be retrieved later on. The id should be a string containing only alphanumeric characters.
+ \end{docKey}
+\item
+ \begin{docKey}[][]{restore-id}{=string}{no default value}
+ This key declares a string-like restore id for unique \CHDocPackage{hyperref} names. The id should be a string containing only alphanumeric characters. \end{docKey}
+ This key is only needed if the same backup-id should be restored more than once and the package \CHDocPackage{hyperref} is used in order to provide unique hyper anchors.
+ \item \begin{docKey}[][]{keep-after-restore}{=\meta{true/false}}{initially false}
+ This key decides whether the values of a certain backup id (see \refKey{backup-id}) shall be kept after a restore has been issued. The default operation is to remove the \refKey{backup-id} and the values of the counters belonging to the given \refKey{backup-id}.
+
+ This option is useful if the same backup state (i.e. \refKey{backup-id}) is to be used more than once.
+
+ Reusing the same counter group for restore after having restored them already with the \refKey{keep-after-restore} option being false will be ignored, i.e. the counter values are not changed.
+\end{docKey}
+
+\item \refKey{name}
+ The meaning of this key is basically the same as for the \nameref{sec::coupledcounters} feature. However, depending on the stage of the backup/restore process the precise action differs:
+ \begin{itemize}
+ \item If \refKey{name} is used in \refCom{AssignBackupCounters} the counters are added to group indicated by the value of \refKey{name}.
+ \item If \refKey{name} is used either for \refCom{BackupCounterGroup} or in \refCom{RestoreBackupCounterGroup} to indicate the counter group for a certain backup state, either for storing or restoring.
+ \end{itemize}
\end{itemize}
-\end{dispExample}
-\section[Loops on multiple counter]{Performing the same action for many counters} \CHDocNew{0.7}
+\subsubsection{Core backup/restore macros}
-Sometimes it might be necessary to set the values of many counters at once. This can be done with consecutive \cs{setcounter} statements, for example. This poses no problem, but might become tedious if there are more than three counters or if this task occurs more than once. \CHDocPackage{\PackageDocName} provides some macros that can do the usual operations like stepping, refstepping, adding to, resetting or setting counter values.
+\begin{docCommand}[before={\CHDocNew{1.0}}]{BackupCounterGroup}{\oarg{options}\marg{counter group name}}
+ Concerning the backup feature this performs the storing of counter values at the position where the command is expanded!
+ A backup operation needs
+ \begin{itemize}
+ \item \refKey{backup-id} to be able to refer to a certain backup state
+ \item \refKey{name} to identify the group of counters
+ \end{itemize}
+\end{docCommand}
+\begin{docCommand}[before={\CHDocNew{1.0}}]{RestoreBackupCounterGroup}{\oarg{options}\marg{counter group name}}
+ This command restores the value of the given counter group.
+ Useful options are (see \nameref{subsubsec::common_options_backuprestore})
+ \begin{itemize}
+ \item \refKey{backup-id}
+ \item \refKey{keep-after-restore}
+ \item \refKey{restore-id}
+ \item \refKey{name}
+ \end{itemize}
+\end{docCommand}
-All macros concerning this feature use the first macro argument having a comma-separated list of counters. Whether there's a second argument depends on the specific nature of the operation that should be performed.
-\begin{marker}
-\begin{itemize}
-\item As of version \packageversion\ \PackageDocName\ does not check whether the names given in the first argument refer to counters.
-\item All macros use the extended counter macros, i.e. are aware of associated counters and step them too if their driver counter is given in the argument list. If an associated counter itself is given in the list, this one is stepped or operated on too!
-\end{itemize}
-\end{marker}
+\subsubsection{Declaring counter groups}
+\begin{docCommand}[before={\CHDocNew{1.0}}]{DeclareBackupCountersGroupName}{\oarg{}\marg{counter group name}}
+ This command declares (better: reserves a name for a backup counter group) -- the name has to be specified as first mandatory argument.
-\begin{docCommand}{LoopAddtoCounters}{\marg{counter1, counter2,\dots}\marg{counter increment/decrement}} \CHDocNew{0.7}
+ A counter group name consists of alphanumeric characters, special symbols etc. are not allowed. The name must not contain commas!
+
+ As of version \packageversion\ the optional argument is not used and reserved for later purposes.
+\end{docCommand}
-\begin{docCommandArgs}{LoopAddToCounters}%
-The 2nd argument value is added (or subtracted) to the counters given in the list of the 1st argument using the \cs{addtocounter}.
+\subsubsection{Populating counter groups}
-\begin{codeoptionsenum}
- \item \marg{counter1, counter2,\dots}
- Holds the comma separated list of counter names
- \item \marg{counter increment/decrement}
- Specifies the value to be added or subtracted
+\begin{docCommand}[before={\CHDocNew{1.0}}]{AssignBackupCounters}{\oarg{options}\marg{counter name1,counter name2,\dots}}
+ This macro populates the counter group (given as optional key - value \refKey{name}) with the comma separated list of counters from the first mandatory argument. The meaning of \refKey{name} is the same as in \nameref{sec::coupledcounters}, but the counter group names are not related to that feature -- the namespace is safe then.
+
+ Some important notes about the behaviour of \refCom{AssignBackupCounters}
+ \begin{itemize}
+ \item If \refKey{name} is not given or empty, the default counter group "scratch" is used.
+
+ \item If the counter group given to \refKey{name} does not exist, it will be created automatically.
+ \end{itemize}
+
+\end{docCommand}
- No check is performed whether \textbf{is} or \textbf{expands} to an integer value.
- \end{codeoptionsenum}
-\end{docCommandArgs}
+\begin{docCommand}[before={\CHDocNew{1.0}}]{AddBackupCounter}{\oarg{options}\marg{counter name1,counter name2,\dots}}
+ This command is similar to \refCom{AssignBackupCounters}, adding counters to a counter group named by \refKey{name} option. If the counter group name does not exist, no action is performed, i.e. the adding operation is ignored.
\end{docCommand}
-\begin{docCommand}{LoopResetCounters}{\marg{counter1, counter2,\dots}} \CHDocNew{0.7}
+\subsubsection[Clearing backup states]{Clearing backup states}\label{subsubsec::clearingbackupstates}
+It might be necessary to remove a certain backup state, i.e. a collection of counter values to be referred to with a \refKey{backup-id}. This can be done either for a certain counter (with \refCom{ClearCounterBackupState}) in a counter group only or for all counters in group (with \refCom{ClearBackupState}).
-\begin{docCommandArgs}{LoopResetCounters}%
-All counters given in the first argument are set to zero using the regular \cs{setcounter}. This is a shorthand version of \refCom{LoopSetCounters} for this specific case.
+\begin{docCommand}[before={\CHDocNew{1.0}}]{ClearCounterBackupState}{\oarg{options}\marg{countergroup name}\marg{counter name}}
+ This macro removes the given backup-id state value for a specific counter only. Use the \refKey{backup-id} option in the first optional argument to specify which backup-id should be cleared.
+ \begin{itemize}
+ \item If the backup-id does not exist, the operation is ignored silently.
+ \item The counter is still part of the group, but can't be restored to the previous state that was identified with \refKey{backup-id}.
+ \end{itemize}
+
+ \marginnote{\bcbombe}Use this macro with care!
+ \smallskip
+\end{docCommand}
-\begin{codeoptionsenum}
- \item \marg{counter1, counter2,\dots}
- Holds the comma separated list of counter names
- \end{codeoptionsenum}
-\end{docCommandArgs}
+\begin{docCommand}[before={\CHDocNew{1.0}}]{ClearBackupState}{\oarg{options}\marg{countergroup name}}
+ This macro removes the given backup-id state value for a whole counter group. Use the \refKey{backup-id} option in the first optional argument to specify which backup-id should be cleared.
+
+ \begin{itemize}
+ \item If the backup-id does not exist, the operation is ignored silently.
+ \item The \refKey{backup-id} is removed from the list of possible backup-ids for the relevant countergroup.
+ \end{itemize}
\end{docCommand}
-\begin{docCommand}{LoopRefstepCounters}{\marg{counter1, counter2,\dots}} \CHDocNew{0.7}
-\begin{docCommandArgs}{LoopStepCounters}%
-All counters given in the first argument are stepped using the regular \cs{refstepcounter} to allow labels -- however, only the last counter will have the correct label reference.
+\subsubsection[Clearing backup groups]{Clearing and deleting backup counter groups}\label{subsubsec::clearingdeletingbackupcountergroups}
-\begin{marker}
- This macro is meant only to complete the number of \cs{Loop...Counters} but is not regarded as being really useful.
-\end{marker}
+From time to time it might be necessary to remove counters from a group or to clear the whole group or remove even the whole group. Those operations can be achieved with \refCom{RemoveCountersFromBackupGroup}, \refCom{ClearBackupCounterGroups} and \refCom{DeleteBackupCounterGroups}. All macros remove at least all stored values belonging to a counter group. A \refCom{RestoreBackupCounterGroup} call does nothing after any of the mentioned macros have been issued.
-\begin{codeoptionsenum}
- \item \marg{counter1, counter2,\dots}
- Holds the comma separated list of counter names
- \end{codeoptionsenum}
-\end{docCommandArgs}
+\begin{docCommand}[before={\CHDocNew{1.0}}]{RemoveCountersFromBackupGroup}{\oarg{options}\marg{countergroup name}\marg{counter name 1, counter name 2,\dots}}
+ This command removes the given counter names from a counter group. The stored values are deleted completely and are lost afterwards. A non-existing counter group name is ignored as well as counters that do not belong to the given group name.
+
+ As of version \packageversion\ the optional argument is not used and reserved for later purposes.
+
+ If complete counter groups shall be deleted and be unavailable afterwards, use
+
+\refCom{DeleteBackupCounterGroups} instead.
+\end{docCommand}
+
+
+\begin{docCommand}[before={\CHDocNew{1.0}}]{ClearBackupCounterGroups}{\oarg{options}\marg{countergroup name 1, countergroup name 2,\dots}}
+ This command removes all names of the counter groups given as comma separated list in the 2nd argument, the internal storage of counter values is removed as well, i.e. older counter values aren't available any longer. The counter group names remain valid, any subsequent call to \refCom{BackupCounterGroup} or \refCom{RestoreBackupCounterGroup} with one of the provided group names will be ignored.
+
+ As of version \packageversion\ the optional argument is not used and reserved for later purposes.
+ If counter groups shall be deleted and be unavailable, use \refCom{DeleteBackupCounterGroups}.
\end{docCommand}
+\begin{docCommand}[before={\CHDocNew{1.0}}]{DeleteBackupCounterGroups}{\oarg{options}\marg{countergroup name 1, countergroup name 2,\dots}}
+ This command clears the counter groups given as comma separated list in the 2nd argument with \refCom{ClearBackupCounterGroups} and removes the names as well, i.e. those names are not available any longer.
+
+ As of version \packageversion\ the optional argument is not used and reserved for later purposes.
+\end{docCommand}
-\begin{docCommand}{LoopSetCounters}{\marg{counter1, counter2,\dots}\marg{new counter value}} \CHDocNew{0.7}
-\begin{docCommandArgs}{LoopAddToCounters}%
-The 2nd argument value is used as new counter value added (or subtracted) to the counters given in the list of the 1st argument using the \cs{addtocounter}.
+\subsection{Query for backup features}\label{subsec::querybackupmacros}\CHDocNew{1.0}
-\begin{codeoptionsenum}
- \item \marg{counter1, counter2,\dots}
- Holds the comma separated list of counter names
- \item \marg{new counter value}
- Specifies the value to be set.
+As usual, some macros to ask whether a certain counter is under backup control or whether a certain \refKey{backup-id} exists might be useful!
- No check is performed whether \textbf{is} or \textbf{expands} to an integer value.
- \end{codeoptionsenum}
-\end{docCommandArgs}
+\subsubsection{Querying for backup counter group existence}\label{subsec::querybackupcountergroup}
+
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterGroupTF}{\marg{counter group name}\marg{true branch}\marg{false branch}}
+This macro tests if the given name is a backup counter group and expands to the \meta{true}/\meta{false} branch accordingly. There are two short-circuit commands: \refCom{IsBackupCounterGroupT} and \refCom{IsBackupCounterGroupF}.
\end{docCommand}
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterGroupT}{\marg{counter group name}\marg{true branch}}
+This macro tests if the given name is a backup counter group and expands to the \meta{true} branch accordingly. There are two related macros: \refCom{IsBackupCounterGroupF} and \refCom{IsBackupCounterGroupTF}.
+\end{docCommand}
-\begin{docCommand}{LoopStepCounters}{\marg{counter1, counter2,\dots}} \CHDocNew{0.7}
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterGroupF}{\marg{counter group name}\marg{false branch}}
+This macro tests if the given name is a backup counter group and expands to the \meta{false} branch accordingly. There are two related macros: \refCom{IsBackupCounterGroupT} and \refCom{IsBackupCounterGroupTF}.
+\end{docCommand}
-\begin{docCommandArgs}{LoopStepCounters}%
-All counters given in the first argument are stepped using the regular \cs{stepcounter}.
-\begin{codeoptionsenum}
- \item \marg{counter1, counter2,\dots}
- Holds the comma separated list of counter names
- \end{codeoptionsenum}
-\end{docCommandArgs}
+\subsubsection{Querying for backup counter entity}\label{subsec::querybackupmacros}
+
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
+This macro tests if a counter is under the administration of the backup counter commands and expands to the relevant \meta{true}/\meta{false} branch then. There are two short-circuit commands: \refCom{IsBackupCounterT} and \refCom{IsBackupCounterF}.
\end{docCommand}
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterT}{\marg{counter name}\marg{true branch}}
+This macro tests if a counter is under the administration of the backup counter commands and expands to the \meta{true} branch then. There are related commands: \refCom{IsBackupCounterTF} and \refCom{IsBackupCounterF}.
+\end{docCommand}
-A more general command for doing "arbitrary" operations with counters (and more setup, for example) is
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupCounterF}{\marg{counter name}\marg{false branch}}
+This macro tests if a counter is under the administration of the backup counter commands and expands to the \meta{false} branch if this not the case. There are related commands: \refCom{IsBackupCounterTF} and \refCom{IsBackupCounterT}.
+\end{docCommand}
-\begin{docCommand}{LoopCountersFunction}{\marg{counter1, counter2,\dots}\marg{counter operation macro}} \CHDocNew{0.7}
-\begin{docCommandArgs}{LoopAddToCounters}%
-The 2nd argument value should hold a macro with any number of arguments, but the last mandatory argument of this macro is reserved for counter name.
+\subsubsection{Querying for backup state entity}\label{subsec::querybackupstate}
-\begin{codeoptionsenum}
- \item \marg{counter1, counter2,\dots}
- Holds the comma separated list of counter names
- \item A macro name that is to be called and that operates on a counter.
- \end{codeoptionsenum}
-\end{docCommandArgs}
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupStateTF}{\marg{counter group name}\marg{counter backup-id}\marg{true branch}\marg{false branch}}
+This macro tests if the backup-id exists for the given counter group and executes the relevant \meta{true}/\meta{false} branch accordingly. There are two short-circuit commands: \refCom{IsBackupStateT} and \refCom{IsBackupStateF}.
+\end{docCommand}
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupStateT}{\marg{counter group name}\marg{counter backup-id}\marg{true branch}}
+This macro tests if the backup-id exists for the given counter group and executes the relevant \meta{true} branch accordingly. There are two related: \refCom{IsBackupStateTF} and \refCom{IsBackupStateF}.
\end{docCommand}
+\begin{docCommand}[after={\CHDocNew{1.0}\par}]{IsBackupStateF}{\marg{counter group name}\marg{counter backup-id}\marg{false branch}}
+This macro tests if the backup-id exists for the given counter group and executes the relevant \meta{false} branch accordingly. There are two related: \refCom{IsBackupStateTF} and \refCom{IsBackupStateT}.
+\end{docCommand}
-\begin{dispExample}
- % We assume we have the counters foocntr and foobarcntr
- \newcommand{\showcountervalues}[2]{%
- \textcolor{#1}{\csname the#2\endcsname}% Now, an extra empty line to show the values in rows
-
- }
- % Note that the 2nd argument is not given here -- it's added by the \LoopCountersFunction macro
- \LoopCountersFunction{foocntr,foobarcntr}{\showcountervalues{blue}}
-\end{dispExample}
+\subsection{Some notes on the backup features} \label{subsec::backup_and_hyperref}
+
+Principally backing up counter values and restoring them later on is not really difficult -- with one exception: If the \CHDocPackage{hyperref} package is used, the counter values form up the hypertarget anchors, for example \texttt{chapter.1} for the first chapter. If the chapter counter is reset, there would be a chapter with number one again and as well an anchor name \texttt{chapter.1} -- \packagename{hyperref} will complain 'only' about this but it will put the wrong hyperlink as well, for example for the table of contents and the bookmarks -- this is an undesirable feature.
+
+However, there is a solution to this problem: The hypertarget anchors are built up from the specifications of a macro \cs{theH...} where the ellipses stands for the counter name. If for example \cs{theHchapter} is changed after a counter was reset the hypertargets will again be correct, since this will provide a different target name. \refCom{BackupCounterGroup} does this resetting automatically in an unique way and \refCom{RestoreBackupCounterGroup} restores as well the old \cs{theH...} macros of all counters that are in the backup list. It tracks the number of calls to \refCom{BackupCounterGroup} and changes the relevant \cs{theH...} macro definitions to use unique anchor names then -- this way multiple \refCom{BackupCounterGroup} calls are possible without destroying the hyperlink facilities with \CHDocPackage{hyperref}.
\section{Coupled counters}\label{sec::coupledcounters}\CHDocNew{0.5}
@@ -1482,7 +1711,7 @@ This can be achieved with the concept of coupled counters. As usual, those count
\subsection[Common options for coupled counters]{Common options for most of the coupled counter macros}\label{subsection:options_coupledcounters}
-\begin{docKey}{name}{=\meta{name of a list}}{}\CHDocNew{0.6}
+\begin{docKey}{name}{=\meta{name of a group}}{}\CHDocNew{0.6}
This option has the name of the counter group that should be coupled, say ``figuretablegroup'' etc.
\end{docKey}
@@ -1626,21 +1855,38 @@ This defines the counter given in the first mandatory argument as a periodic cou
\end{docCommand}
-\begin{docCommand}[before={\CHDocNew{0.9}}]{RemovePeriodicCounter}{\oarg{options}\marg{counter name}\marg{counter treshold value}}
-This defines the counter given in the first mandatory argument as a periodic counter and is automatically reset if the treshold value is reached.
+\begin{docCommand}[before={\CHDocNew{0.9}}]{RemovePeriodicCounter}{\oarg{options}\marg{counter name}}
+This removes the counter given in the first mandatory argument as a periodic counter. The counter is reset unless the \refKey{reset} is set to \meta{false}.
\begin{codeoptionsenum}
\item \oarg{options}
As of version \packageversion, there is only one option:
+
\begin{docKey}[][before={\CHDocNew{0.9}}]{reset}{=\meta{true/false}}{initially true}
Use `false` to prevent the resetting of the relevant counter after removal!
\end{docKey}
\item \marg{counter name} -- the name of the counter that should be no periodic counter any longer.
\end{codeoptionsenum}
+If all periodic counters should be removed, use the macro \refCom{RemoveAllPeriodicCounters} instead.
+
\end{docCommand}
+\begin{docCommand}[before={\CHDocNew{1.0}}]{RemoveAllPeriodicCounters}{\oarg{options}}
+ This command removes all counters given in the first mandatory argument as a periodic counter. All counters are reset unless the \refKey{reset} option is set to \meta{false}.
+
+\begin{codeoptionsenum}
+\item \oarg{options}
+ As of version \packageversion, there is only one option: \refKey{reset}, having the same meaning as in \refCom{RemovePeriodicCounter}.
+\item \marg{counter name} -- the name of the counter that should be no periodic counter any longer.
+\end{codeoptionsenum}
+
+If only a specific counter shall be removed from the periodic counter property use the command \refCom{RemovePeriodicCounter} instead.
+
+\end{docCommand}
+
+
\begin{docCommand}[before={\CHDocNew{0.9}}]{ChangePeriodicCounterCondition}{\oarg{options}\marg{counter name}\marg{new counter treshold value}}
This changes the counter treshold condition -- the counter is reset automatically if not specified otherwise with the \refKey{reset} option.
@@ -1670,11 +1916,148 @@ This macro tests if a counter is under the administration of the periodic counte
This macro tests if a counter is under the administration of the periodic counter commands and expands to the \meta{false} branch then if this is not the case. There are two related commands: \refCom{IsPeriodicCounterTF} and \refCom{IsPeriodicCounterT}.
\end{docCommand}
+
+\section[Suspending and Resuming]{Suspending and resuming (associated) counters}\label{section::suspendedresumedcounters}
+
+
+
+Rather than removing an associated counter from the list, it is possible to suspend the automatic stepping for a while and then resume it (or completely drop it), for example, if the value of a counter should not be stepped within a specific chapter etc.
+
+
+
+\begin{marker}[before=\CHDocNew{0.8}\par]
+ Suspension and resuming counters can cause wrong hyper links if \CHDocPackage{hyperref} is used.
+\end{marker}
+
+\subsection{Macros for suspension and resume}
+
+\begin{docCommand}{SuspendCounters}{\oarg{options}\marg{counters list}}%
+\begin{docCommandArgs}{SuspendCounters}%
+
+\begin{codeoptionsenum}
+\item \oarg{options}%
+
+ Not used so far, reserved for later usage.
+
+\item \marg{counters list}%
+
+ Contains the name of counters to be suspended, separated by commas (CSV - list)
+\end{codeoptionsenum}
+\end{docCommandArgs}
+\end{docCommand}%
+
+\begin{docCommand}{CascadeSuspendCounters}{\oarg{options}\marg{counters list}}\CHDocNew{0.8}
+
+This macro is more powerful than \refCom{SuspendCounters}, since it tries to detect whether a counter has a reset list and 'mutes' the counters on this list as well and checks whether those counters themselves have reset lists and cascades down to the final state.
+
+\begin{marker}
+ Stated differently: All counters anyhow connected to a counter named \CHDocCounter{foo} will be suspended, e.g. for the \CHDocClass{book} class and \CHDocCounter{chapter}, this means in a standard setup, that \CHDocCounter*{section,figure,table,equation,footnote} will be suspended, as well as in consequence \CHDocCounter*{subsection,subsubsection,paragraph,subparagraph}, assuming hereby no other counters have been added to the reset lists.
+\end{marker}
+
+
+\begin{docCommandArgs}{CascadeSuspendCounters}%
+
+\begin{codeoptionsenum}
+\item \oarg{options}%
+
+ Not used so far, reserved for later usage.
+
+\item \marg{counters list}%
+
+ Contains the name of counters to be suspended, separated by commas (CSV - list)
+\end{codeoptionsenum}
+\end{docCommandArgs}
+\end{docCommand}%
+
+
+\begin{docCommand}{ResumeSuspendedCounters}{\oarg{options}\marg{counters list}}
+ As of version \packageversion\ the optional argument is not used and reserved for later purposes.
+ This command revokes the suspension of the counters in the \marg{counters} list.
+\end{docCommand}
+
+\begin{docCommand}{ResumeAllSuspendedCounters}{\oarg{options}} \CHDocNew{0.8}
+ As of version \packageversion\ the optional argument is not used and reserved for later purposes.
+ This command revokes all suspended counters.
+\end{docCommand}
+
+
+\subsection{Query suspension}
+\begin{docCommand}[before={\CHDocNew{0.1}}\par]{IsSuspendedCounter}{\marg{counter name}\marg{true branch}\marg{false branch}}
+See \nameref{section::suspendedresumedcounters} on this topic.
+
+This command checks, whether a counter is suspended, i.e. not updated at all and expands the corresponding branches.
+
+%\begin{docCommandArgs}{IfSuspendedCounter}%
+
+\begin{codeoptionsenum}
+\item \marg{counter name}%
+
+ Contains the name of counter presumed to be suspended
+
+\item \marg{True branch}
+
+ This code is expanded if the counter is suspended, otherwise it is ignored
+
+\item \marg{True branch}
+
+ This code is expanded if the counter is \textbf{not} suspended, otherwise it is ignored
+
+\end{codeoptionsenum}
+%\end{docCommandArgs}
+
+
+\end{docCommand}
+
+
+
+\begin{marker}
+If a driver counter is suspended, all counters associated to it are suspended too!
+\end{marker}
+
+\setcounter{totalequations}{0}
+\setcounter{equation}{0}
+\renewcommand{\DeclareAssociatedCounters}[3][]{\relax}%
+\begin{dispExample}
+\textbf{This example shows 4 equations, but only two of them are counted}
+
+\begin{equation}
+E_{0} = mc^2
+\end{equation}
+
+Now suspend the equations:
+
+\SuspendCounters{equation}
+\begin{equation}
+E^2 = \left({ pc}\right)^2 + E^{2}_{0}
+\end{equation}
+
+\begin{equation}
+ m(v) = \frac{m_{0}}{\sqrt{1-\frac{v^2}{c^2}}}
+\end{equation}
+
+And resume it: \ResumeSuspendedCounters{equation}
+
+\begin{equation}
+ E = h \nu
+\end{equation}
+
+There are \number\totvalue{totalequations}~equations in here!
+
+\end{dispExample}
+
+
+
+
+
+
+
+
+
\section{Total counters}\tcbdocmarginnote{\tcbdocnew{2015-11-27}}
-Similarly to the package \CHDocPackage{totcount} or the features of \CHDocPackage{totalcount} by Axel Sommerfeldt this package provides the possibility of defining a counter that stores its finally value to the auxiliary file and starts from this value then, if not set otherwise to another value.
-%In order to prevent namespace pollution, the counters have a different name internally, it's possible to have a counter of the name \texttt{foo} and a total counter named \texttt{foo} under the control of the total counter macros.
+
+Similarly to the package \CHDocPackage{totcount} or the features of \CHDocPackage{totalcount} by Axel Sommerfeldt this package provides the possibility of defining a counter that stores its finally value to the auxiliary file and starts from this value then, if not set otherwise to another value.
The declaration of a total counter is a preamble - only event and \refCom{NewTotalDocumentCounter} is a preamble-only command in order to prevent counter register confusion. If a certain existing counter should be treated with total counter features, use \refCom{RegisterTotalDocumentCounter} instead.
@@ -1682,6 +2065,7 @@ The declaration of a total counter is a preamble - only event and \refCom{NewTot
\tcbdocmarginnote{\bcbombe}The standard \LaTeXe\ commands \cs{stepcounter}, \cs{addtocounter} and \cs{setcounter} support the specification of a total counter, but \cs{refstepcounter} will fail since the usage of a total counter for labelling purposes is most probably of no use (as of version \packageversion)
\end{marker}
+\subsection{Defining total counters}
\begin{docCommand}{RegisterTotalDocumentCounter}{\oarg{options}\marg{total counter name}}\CHDocNew{0.5}
\begin{codeoptionsenum}
@@ -1708,6 +2092,10 @@ This command reports the internal name of a total counter or the usual name if t
\TotalCounterInternalName{foototal}
\end{dispExample}
+\begin{docCommand}[before={\CHDocExpCommand\par\CHDocNew{1.0}}]{TotalCounterInternalNameExp}{\marg{counter name}}
+This command is the expandable version of \refCom{TotalCounterInternalName}
+\end{docCommand}
+
\stepcounter{foototal}
@@ -1723,6 +2111,8 @@ Total value of the foototal total counter: \TotalValue{foototal}
\end{docCommand}
+\subsection{Queries about total counters}
+
\begin{docCommand}{IsTotalCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
This macro tests if a counter is under the administration of the total counter commands and expands to the relevant branch then. There are two short-circuit commands \refCom{IsTotalCounterT} and \refCom{IsTotalCounterF}.
\end{docCommand}
@@ -1756,6 +2146,8 @@ This macro checks if a counter is under the administration of the total counter
\section{Super total counters}\label{section:supertotalcounters} \tcbdocmarginnote{\tcbdocnew{2015-11-25}}
In addition to the concept of a total counter, there is also the possibility of using super total counters -- those counters survive the reset at the beginning of a compilation, i.e. the value of a super total counter might be stepped in each run and as such the number of compilation runs etc. can be tracked. The values of the last run are persistent as long as the \CHDocFileExt{.aux} file isn't deleted.
+\subsection{Defining super total counters}
+
\begin{docCommand}{NewTotalDocumentCounter}{\oarg{options}\marg{total counter name}}
This macro defines a new counter (which mustn't exist before of course) and puts it under control of the total counter features.
\begin{codeoptionsenum}
@@ -1772,6 +2164,7 @@ use \refCom{RegisterTotalDocumentCounter} instead.
\end{docCommand}
+\subsection{Queryies about super total counters}
\begin{docCommand}{IsSuperTotalCounterTF}{\marg{counter name}\marg{true branch}\marg{false branch}}
This macro tests if a counter is under the administration of the super total counter commands and expands to the relevant branch then. There are two short-circuit commands \refCom{IsSuperTotalCounterT} and \refCom{IsSuperTotalCounterF}.
@@ -1801,164 +2194,34 @@ This macro checks if a counter is under the administration of the super total co
This package adds a counter of its own: \CHDocCounter{numberofruns} which is a super total counter and is stepped each compilation run. It's added in \cs{AtBeginDocument} and can be retrieved with \refCom{TotalValue}. Use the \refKey{nonumberofruns} package option to prevent the definition of this counter.
+\clearpage{
+\part{Meta-Information}
-\section[Counter backup/restoration]{Backup and restore of counter values}\CHDocNew{0.4}
-
-It might be necessary to interrupt the current sectioning, e.g. including another document's structure (an external paper, for example) such that the counting should start again and after finishing of the external structure the old values should be restored.
-
-\subsection[Macros for backup/restoration]{Description of backup and restoring macros for counter values}
-
-\begin{docCommand}{BackupCounterValues}{\oarg{options}\marg{counter name1, counter name2,...}}
- This macro adds counter names (separated by a comma) to a list and stores the current values of the counters to another list. The values are used from the current state where this command is used, not a previous or a later state is stored.
-
- \begin{itemize}
- \item All counters in the list will be reset to zero (after storing the values) for the next usage, unless the \refKey{resetbackup} key is set to \meta{false}.
- \item Multiple specification of the same counter name is possible, but only the first occurence will be regarded -- consecutive occurences of the same counter name are not taken into account. \CHDocNew{0.5}
- \end{itemize}
-
-\begin{docKey}[][]{resetbackup}{=\meta{true/false}}{initially true}
-This key decides whether \textbf{all} counters in the backup list should be reset to zero or should keep the current value. The default value is \meta{true}.
-\end{docKey}
-
-Please note: If a name does not belong to a counter register the compilation aborts with an error message!
-
-Some remarks
-
-\begin{marker}
-If a specific counter name is suffixed with an \textasteriskcentered\ at its end the resetting is disabled for this particular counter, regardless whether \refKey{resetbackup} is set to true or not.\CHDocNew{0.4}
-\end{marker}
-
-\begin{marker}
- Strangely enough, a counter name like \CHDocCounter{foo*} is possible, but \cs{thefoo*} would fail. Be careful about choosing counter names for new counters -- just restrict yourself to the usual letters (and if really needed, using \makeatletter @\makeatother)
-\end{marker}
-\end{docCommand}%
-
-
-\begin{docCommand}{RestoreAllCounterValues}{\oarg{options}} \CHDocNew{0.5}
-This macro restores all stored counter values corresponding to the counter names.
-
-As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
-
-The backup list is cleared after the restoring has been finished.
-\end{docCommand}
-
-\begin{marker}
-The \refCom{RestoreAllCounterValues} was previously called \refCom{RestoreCounterValues} -- that macro is now reserved for updating only particular
-counters, not all in a row.
-\end{marker}
-
-
-
-\begin{docCommand}{RestoreCounterValues}{\oarg{options}\marg{counter name1,counter name2,...}} \CHDocUpdate{0.5}
-This macro restores only the stored counter values given by the counter names.
-As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
-
-%The backup list is cleared after the restoring has been finished.
-\end{docCommand}
-
-\begin{dispExample}
-
- \captionof{figure}{A dummy figure}
-
- \captionof{table}{A dummy table}
-
-
-\BackupCounterValues{figure,table*}
-
- \captionof{figure}{Another dummy figure}
-
- \captionof{table}{Another dummy table}
-
- \captionof{figure}{Even another dummy figure}
-
- \captionof{table}{Even another dummy table}
-
-Before restoring: \thefigure\ and \thetable
-
-\RestoreAllCounterValues
-
-Restored the values: \thefigure\ and \thetable
-
-\captionof{figure}{Yet another dummy figure}
-\captionof{table}{Yet another dummy table}
-
-
-\end{dispExample}
-
-\begin{docCommand}{AddBackupCounter}{\oarg{options}\marg{counter name1,counter name2,...}} \CHDocNew{0.5}
-This is similar to \refCom{BackupCounterValues}, but adds the counter names to an existing global list and can be applied after \refCom{BackupCounterValues}.
-
-\end{docCommand}
-
-
-\begin{docCommand}{RemoveBackupCounters}{\oarg{options}\marg{counter name1, counter name2,...}} \CHDocNew{0.5}
-This macro removes the counters from the list of backup counters and immediately restores the counter value unless the starred version \refCom{RemoveBackupCounters*} is used.
-
-If the package \CHDocPackage{hyperref} is used, the macro \cs{theH...} (see \nameref{subsec::backup_and_hyperref} on this) is restored to the original meaning.
-
-As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
-
-\end{docCommand}
-
-
-\begin{docCommand}{RemoveBackupCounters*}{\oarg{options}\marg{counter name}} \CHDocNew{0.5}
-
-This command is basically similar to \refCom{RemoveBackupCounters}, but does not restore the counter value right at the place the macro is used.
-
-As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
-\end{docCommand}
-
-\subsection{Some notes on the backup features} \label{subsec::backup_and_hyperref}
-
-Principally backing up counter values and restoring them later on is not really difficult -- with one exception: If the \packagename{hyperref} package is used, the counter values form up the hypertarget anchors, for example \texttt{chapter.1} for the first chapter. If the chapter counter is reset, there would be a chapter with number one again and as well an anchor name \texttt{chapter.1} -- \packagename{hyperref} will complain 'only' about this but it will put the wrong hyperlink as well, for example for the table of contents and the bookmarks -- this is an undesirable feature.
-
-However, there is a solution to this problem: The hypertarget anchors are built up from the specifications of a macro \cs{theH...} where the ellipses stands for the counter name. If for example \cs{theHchapter} is changed after a counter was reset the hypertargets will again be correct, since this will provide a different target name. \cs{BackupCounterValues} does this resetting automatically in an unique way and \cs{RestoreCounterValues} restores as well the old \cs{theH...} macros of all counters that are in the backup list. It tracks the number of calls to \cs{BackupCounterValues} and changes the relevant \cs{theH...} macro definitions to use unique anchor names then -- this way multiple \cs{BackupCounterValues} calls are possible without destroying the hyperlink facicilities with \packagename{hyperref}.
-
-\section{Counter output} \CHDocNew{0.7}
-
-Once in a while it might be necessary to provide counter output not only as integer numbers, letters or Roman figures but also using binary, octal or hexdecimal number output. The \CHDocPackage{fmtcount} package has support for this already -- here are some alternatives
-
-\begin{marker}
-None of the commands checks whether the argument refers to counter name.
-\end{marker}
-\begin{docCommand}[doc new={\chdocextractversion{xassoccntversion0.7}}]{BinaryValue}{\marg{counter name}}% \CHDocNew{0.7}
-
-This command will print the value of the counter using binary digits.
-
-\end{docCommand}
-
-\begin{docCommand}{hexValue}{\marg{counter name}} \CHDocNew{0.7}
-
-This command will print the value of the counter using lowercase hexadecimal digits.
-
-\end{docCommand}
-
-\begin{docCommand}{HexValue}{\marg{counter name}} \CHDocNew{0.7}
-
-This command will print the value of the counter using uppercase hexadecimal digits.
-
-\end{docCommand}
-
-\begin{docCommand}{OctalValue}{\marg{counter name}} \CHDocNew{0.7}
-
-This command will print the value of the counter using uppercase hexadecimal digits.
-
-\end{docCommand}
-
+\parttoc
\clearpage
\section{To - Do list}
\begin{itemize}
+\item Merging of counter groups, removing counters from counter groups
+\item Backup and restoration of individual counters not being member of a counter group
\item Switch to the container support for all features -- this is a major task and will be done in (tiny) steps.
-\item Add counter group support for the \CHDocTag{backup} feature, i.e. define a symbolic name for a group of counters that should be controlled by the backup feature. This will allow multiple backup groups, which might be necessary.
\item Better counter definition/copy counter routines \(\longrightarrow\) another package perhaps
\item More examples
\item Some macro names might be non-intuitive
\item Improve documentation
\item Hooks for conditionals on \CHDocCounter*{numberofruns} (see \cref{subsection:numberofruns})
+
+
\end{itemize}
+Some issues that have been addressed partially are:
+
+\begin{itemize}
+\item \CHDocNew{1.0} Add counter group support for the \CHDocTag{backup} feature, i.e. define a symbolic name for a group of counters that should be controlled by the backup feature. This will allow multiple backup groups, which might be necessary.
+\end{itemize}
+
+
If you
\begin{itemize}
@@ -2000,9 +2263,19 @@ write this documentation.
\section{Version history}
\begin{itemize}[itemsep=15pt]
+\item \CHDocFullVersion{1.0a}
+\begin{itemize}
+\item \CHDocNew{1.0} Restructured the \CHDocPackage{xassoccnt} manual file.
+\item \CHDocNew{1.0} Added some improvements for counter reset lists macros
+\item \CHDocNew{1.0} Added new backup/restore features, with cascading counters possibility -- the old backup/restore macros are still available but renamed with a prefix \cs{Former...}
+\item \CHDocNew{1.0} Added the \refCom{RemoveAllPeriodicCounters} -- it was missing in the \CHDocTag{periodic counter} features -- see \nameref{section:periodic_counters} for more information on this.
+\item \CHDocNew{1.0} Added the expandable version of \refCom{TotalCounterInternalName} named
+
+ \refCom{TotalCounterInternalNameExp}.
+\end{itemize}
\item \CHDocFullVersion{0.9}
\begin{itemize}
- \item \CHDocUpdate{0.9}\refCom{TotalValue} is an expandable command now.
+ \item \CHDocUpdate{0.9}\refCom{TotalValue} is an expandable command now.
\item \CHDocNew{0.9} Added the \CHDocTag{periodic counter} features -- see \nameref{section:periodic_counters} for more information on this.
\end{itemize}
\item \CHDocFullVersion{0.8}
@@ -2067,11 +2340,15 @@ Improved \cs{stepcounter} to remove some incompatibilities with the \CHDocPackag
\end{itemize}
\clearpage
\phantomsection
-\appendix\label{examplesappendix}
+\part{Appendix}\label{examplesappendix}
+\setcounter{section}{0}
+\renewcommand{\theHsection}{appendix.\thesection}
+\renewcommand{\thesection}{\Alph{section}}
Note: The \cs{DeclareAssociatedCounters} command have to be used in the preamble of the document. It's missing here for the sake of a compact example.
+
\section[Total number of sections]{Example: Total number of sections}
In this example, all sections of this document are counted, i.e. the current one as well as all following ones.
\begin{dispExample}
@@ -2125,6 +2402,113 @@ There are \number\value{equation}~equations in here!
\end{dispExample}
+\section[Former Backup/Restore Feature]{Former backup and restore of counter values}\label{section::old_backuprestore} \CHDocUpdate{1.0}
+
+\subsection[Macros for backup/restoration]{Description of backup and restoring macros for counter values}
+
+\begin{docCommand}{FormerBackupCounterValues}{\oarg{options}\marg{counter name1, counter name2,...}}
+ This macro adds counter names (separated by a comma) to a list and stores the current values of the counters to another list. The values are used from the current state where this command is used, not a previous or a later state is stored.
+
+ \begin{itemize}
+ \item All counters in the list will be reset to zero (after storing the values) for the next usage, unless the \refKey{resetbackup} key is set to \meta{false}.
+ \item Multiple specification of the same counter name is possible, but only the first occurence will be regarded -- consecutive occurences of the same counter name are not taken into account. \CHDocNew{0.5}
+ \end{itemize}
+
+\begin{docKey}[][]{resetbackup}{=\meta{true/false}}{initially true}
+This key decides whether \textbf{all} counters in the backup list should be reset to zero or should keep the current value. The default value is \meta{true}.
+\end{docKey}
+
+Please note: If a name does not belong to a counter register the compilation aborts with an error message!
+
+Some remarks
+
+\begin{marker}
+If a specific counter name is suffixed with an \textasteriskcentered\ at its end the resetting is disabled for this particular counter, regardless whether \refKey{resetbackup} is set to true or not.\CHDocNew{0.4}
+\end{marker}
+
+\begin{marker}
+ Strangely enough, a counter name like \CHDocCounter{foo*} is possible, but \cs{thefoo*} would fail. Be careful about choosing counter names for new counters -- just restrict yourself to the usual letters (and if really needed, using \makeatletter @\makeatother)
+\end{marker}
+\end{docCommand}%
+
+
+\begin{docCommand}{FormerRestoreAllCounterValues}{\oarg{options}} \CHDocNew{0.5}
+This macro restores all stored counter values corresponding to the counter names.
+
+As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
+
+The backup list is cleared after the restoring has been finished.
+\end{docCommand}
+
+\begin{marker}
+The command \refCom{FormerRestoreAllCounterValues} was previously called \refCom{FormerRestoreCounterValues} -- that macro is now reserved for updating only particular
+counters, not all in a row.
+\end{marker}
+
+
+
+\begin{docCommand}{FormerRestoreCounterValues}{\oarg{options}\marg{counter name1,counter name2,...}} \CHDocUpdate{0.5}
+This macro restores only the stored counter values given by the counter names.
+As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
+
+%The backup list is cleared after the restoring has been finished.
+\end{docCommand}
+
+\begin{dispExample}
+
+ \captionof{figure}{A dummy figure}
+
+ \captionof{table}{A dummy table}
+
+
+\FormerBackupCounterValues{figure,table*}
+
+ \captionof{figure}{Another dummy figure}
+
+ \captionof{table}{Another dummy table}
+
+ \captionof{figure}{Even another dummy figure}
+
+ \captionof{table}{Even another dummy table}
+
+Before restoring: \thefigure\ and \thetable
+
+\FormerRestoreAllCounterValues
+
+Restored the values: \thefigure\ and \thetable
+
+\captionof{figure}{Yet another dummy figure}
+\captionof{table}{Yet another dummy table}
+
+
+\end{dispExample}
+
+\begin{docCommand}{FormerAddBackupCounter}{\oarg{options}\marg{counter name1,counter name2,...}} \CHDocNew{0.5}
+This is similar to \refCom{FormerBackupCounterValues}, but adds the counter names to an existing global list and can be applied after \refCom{FormerBackupCounterValues}.
+
+\end{docCommand}
+
+
+\begin{docCommand}{FormerRemoveBackupCounters}{\oarg{options}\marg{counter name1, counter name2,...}} \CHDocNew{0.5}
+This macro removes the counters from the list of backup counters and immediately restores the counter value unless the starred version \refCom{FormerRemoveBackupCounters*} is used.
+
+If the package \CHDocPackage{hyperref} is used, the macro \cs{theH...} (see \nameref{subsec::backup_and_hyperref} on this) is restored to the original meaning.
+
+As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
+
+\end{docCommand}
+
+
+
+\begin{docCommand}{FormerRemoveBackupCounters*}{\oarg{options}\marg{counter name}} \CHDocNew{0.5}
+
+This command is basically similar to \refCom{FormerRemoveBackupCounters}, but does not restore the counter value right at the place the macro is used.
+
+As of version \packageversion\ the optional argument isn't used and reserved for later purposes.
+\end{docCommand}
+
+
+
\clearpage
\markboth{\indexname}{\indexname}
%%%% Index of commands etc.
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf
index 50209f1e1c4..38795f5406f 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex
index 615e49406d4..c463401af5d 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex
@@ -1,9 +1,9 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% Driver file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
-%% Copyright (c) 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% Copyright (c) 2015 -- 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
@@ -21,7 +21,6 @@
\documentclass{book}
-\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{totcount}
\usepackage{calc}
@@ -192,22 +191,6 @@ Internal name: \TotalCounterInternalName{equations}
\end{table}
-\BackupCounterValues{chapter,section,equation}
-
-\chapter{A new chapter}
-
-\begin{equation}
- E=mc^2
-\end{equation}
-
-\RestoreAllCounterValues
-
-\chapter{Another new chapter}
-
-\begin{equation}
- E=mc^2
-\end{equation}
-
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf
index 788ce9bac06..718f8cfafd7 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex
index f5d9fd41a1f..2045a13e5ba 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex
@@ -1,9 +1,9 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% Example file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
-%% Copyright (c) 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% Copyright (c) 2015 -- 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
@@ -43,7 +43,6 @@
% Some packages only for output and dummy pages
-\usepackage{graphicx}
\usepackage{blindtext}
\usepackage{forloop}
\usepackage[svgnames]{xcolor}
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdf
index c5e1e356251..e4e8a5292d0 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdf
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex
index fa40a6e109a..3d73c470b9a 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex
@@ -1,4 +1,4 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% Example file for periodic counters file for xassoccnt.sty
%%
%%
@@ -56,7 +56,6 @@ Value of foocntr is \thefoocntr\ now!
\section{My nice section \x}
}
-%\RemovePeriodicCounter[resetperiodic=false]{section}
\clearpage
@@ -74,5 +73,15 @@ Value of foocntr is \thefoocntr\ now!
}
+\clearpage
+
+Now removing all periodic counters, but don't reset them
+\RemoveAllPeriodicCounters[reset=false]%
+
+\foreach \x in {1,...,22} {%
+ \section{Section after removing periodic counters \x}
+}
+
+
\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.pdf
new file mode 100644
index 00000000000..0beff930ee2
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.tex
new file mode 100644
index 00000000000..800a130d827
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.tex
@@ -0,0 +1,75 @@
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
+%% Example file for reset list features file for xassoccnt.sty
+%%
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2016 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`
+%%
+%%
+
+\documentclass{book}
+
+\usepackage{chngcntr}
+
+\usepackage{xassoccnt}
+
+\newcommand{\showfullresetlist}[1]{%
+\item Counter name: #1 \hfill \csname the#1\endcsname%\leavevmode%
+}
+
+\begin{document}
+
+\chapter{First}
+
+\section{First section}
+\begin{itemize}
+ \LoopFullCounterResetList{chapter}{\showfullresetlist}
+\end{itemize}
+
+\begin{figure}
+\caption{A dummy figure}
+\end{figure}
+
+\RemoveFromFullReset{section}{chapter}
+
+
+\chapter{Second Chapter}
+
+\section{First section in 2nd chapter}
+\begin{itemize}
+ \LoopFullCounterResetList{chapter}{\showfullresetlist}
+\end{itemize}
+
+\begin{figure}
+\caption{Another dummy figure}
+\end{figure}
+
+
+\AddToReset{section}{chapter}
+
+
+\chapter{Third Chapter}
+
+\section{First section in 3rd chapter}
+\begin{itemize}
+ \LoopFullCounterResetList{chapter}{\showfullresetlist}
+\end{itemize}
+
+\begin{figure}
+\caption{Another dummy figure}
+\end{figure}
+
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdf
index 81e04e2f750..0a21b82596a 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdf
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex
index 7eb2cfaf3a8..3be58383f1d 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex
@@ -1,4 +1,4 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% Example file for suspended counters file for xassoccnt.sty
%%
%%
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdf
index ea8135abd0a..bce7c3f905c 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdf
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex
index 16d895b7701..058fed07182 100644
--- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex
@@ -1,9 +1,9 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% Example file for total counters file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
-%% Copyright (c) 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% Copyright (c) 2015 -- 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
@@ -31,6 +31,9 @@
The total value of section is \TotalValue{section}
+The real name is \TotalCounterInternalNameExp{section}%
+
+
\ifnum\TotalValue{section} > 1\relax Hooray \else only one section found\fi
\blinddocument
diff --git a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
index db0ebec8c2f..63119ca1d62 100644
--- a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
+++ b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
@@ -1,9 +1,9 @@
-%% LaTeX package xassoccnt - version 0.9 (2016/06/19 -- 08/11/05)
+%% LaTeX package xassoccnt - version 1.0 (2016/07/28 -- 21/05/18)
%% Source file for xassoccnt.sty
%%
%%
%% -------------------------------------------------------------------------------------------
-%% Copyright (c) 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% Copyright (c) 2015 -- 2016 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
@@ -19,22 +19,40 @@
%%
%%
-\def\xassoccntpackageversion{0.9}
+\def\xassoccntpackageversion{1.0}
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
-\ProvidesPackage{xassoccnt}[2016/06/19 - v\xassoccntpackageversion]
-\RequirePackage{graphicx}
+\ProvidesPackage{xassoccnt}[2016/07/28 - v\xassoccntpackageversion]
\RequirePackage{xcolor}
\RequirePackage{xparse}
\RequirePackage{l3keys2e}
+
\ExplSyntaxOn
+\newif\ifexplversionnew
+\explversionnewfalse
+
+% Some variants of standard expl3 contributions
+
+\cs_generate_variant:Nn \seq_remove_all:Nn { cV, NV }
+\cs_generate_variant:Nn \seq_gremove_all:Nn { cV, NV }
+\cs_generate_variant:Nn \seq_gput_right:cn {cx}%
+\cs_generate_variant:Nn \prop_put:Nnn {cxx}
+\cs_generate_variant:Nn \prop_remove:Nn {cx,Nx}
+\cs_generate_variant:Nn \prop_item:Nn {NV,cV,cx}
+\cs_generate_variant:Nn \int_set:Nn {NV,Nx}
+
+
% First some local or global values
\bool_new:N \l__xassoccnt_hyperrefpackage_loaded_bool
+\ifexplversionnew
\str_const:Nn \c__xassoccnt_modulename_str {xassoccnt}
+\else
+\tl_const:Nn \c__xassoccnt_modulename_str {xassoccnt} % Only a wrapper
+\fi
\bool_new:N \l__xassoccnt_calcpackage_loaded
@@ -102,6 +120,15 @@
}
+\prop_new:N \g_xassoccnt_module_data_prop
+
+\prop_put:Nnn \g_xassoccnt_module_data_prop {scratchname} {scratch}
+\prop_put:Nnn \g_xassoccnt_module_data_prop {backupfeaturename} {backupcounters}
+
+\cs_new:Nn \xassoccnt_extract_moduledata:n {%
+ \prop_item:Nn \g_xassoccnt_module_data_prop {#1}
+}
+
\keys_define:nn {xassoccnt}
{
@@ -168,7 +195,6 @@
resetbackup .bool_set:N={\l__xassoccnt_resetbackupcounters_bool },
-% resetperiodic .bool_set:N={ \l_xassoccnt_resetperiodiccounters_bool }
}
\keys_define:nn {xassoccnt_periodiccounter} {%
@@ -176,6 +202,17 @@
wrap .bool_set:N={ \l_xassoccnt_wrapperiodiccounters_bool }
}
+
+\cs_new:Nn \generate_unique_countergroup_value:n {%
+ \seq_set_from_clist:Nn \l_tmpa_seq {#1}
+ \tl_clear:N \l_tmpa_tl%
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \tl_put_right:Nn \l_tmpa_tl {\use:c{the##1}:}%
+ }%
+ \prop_put:NnV \g_xassoccnt_module_data_prop {currentid} {\l_tmpa_tl}
+}
+
+
\keys_set:nn{xassoccnt}{nonumberofruns}
\ProcessKeysOptions{xassoccnt}
@@ -214,6 +251,9 @@
---~#1~---
}
+
+
+
\msg_new:nnn{xassoccnt}{clearcoupledcountergroupundefined}{%
Warning:~There~is~no~coupled~counter~group~named~#2~\\
The~clearing~operation~is~ignored!\\
@@ -228,14 +268,52 @@
}
+\msg_new:nnn{xassoccnt}{emptybackupcountergroup}{%
+ Warning:~The~backup~counter~group~name~is~empty!\\
+ Using~the~default~name:~"\xassoccnt_extract_moduledata:n{scratchname}"!\\
+ ---~#1~---
+}
+
+
+\msg_new:nnn{xassoccnt}{addbackupcountergroupundefined}{%
+ Warning:~There~is~no~backup~counter~group~named~#2~\\
+ The~addition~operation~is~ignored!\\
+ ---~#1~---
+}
+
+\msg_new:nnn{xassoccnt}{backupcountergroupundefined}{%
+ Warning:~There~is~no~backup~counter~group~named~#2~\\
+ The~restore~operation~is~ignored!\\
+ ---~#1~---
+}
+
+
+\msg_new:nnn{xassoccnt}{restorebackupcountergroupundefined}{%
+ Warning:~There~is~no~backup~counter~group~named~#2~\\
+ The~restoring~operation~is~ignored!\\
+ ---~#1~---
+}
+
+\msg_new:nnn{xassoccnt}{nobackupid}{%
+ Error:~Backup~ID~for~group~"#1"~not~given!\\
+ ---~#2~---
+}
+
+\msg_new:nnn{xassoccnt}{norestoreid}{%
+ Error:~Restore~ID~for~group~"#1"~not~given!\\
+ ---~#2~---
+}
+\msg_new:nnn{xassoccnt}{duplicatebackupid}{%
+ Error:~Backup~ID~"#1"~for~group~"#2"~is~already~defined!\\
+ ---~#3~---
+}
\msg_new:nnn{xassoccnt}{backupcollectionundefined}{%
Error:~Backup~collection~#1~not~defined\\
Use~\DeclareBackupCollection~to~define~the~collection
}
-
\msg_new:nnn{xassoccnt}{incompatiblepackagenonfatal}{%
Warning:~Package~"#1"~is~loaded~--~this~is~not~recommended~for~\c__xassoccnt_modulename_str\\
}
@@ -270,6 +348,98 @@
}
+
+\cs_new:Nn \xassoccnt_bootstrap_fullreset_list:n {%
+ \begingroup
+ \def\@elt##1{\seq_gput_right:cn {#1_fullresetlist_seq} {##1}}
+ \use:c{cl@#1}
+ \endgroup
+}
+
+\cs_new:Nn \xassoccnt_local_list:nn {%
+ \begingroup
+ \def\@elt##1{\seq_gput_right:cn {#1} {##1}}
+ \use:c{cl@#2}
+ \endgroup
+}
+
+
+\cs_new:Nn \xassoccnt_full_reset_list_recursive:nn {
+ \seq_clear:N \l_tmpa_seq
+ \xassoccnt_local_list:nn {l_tmpa_seq} {#2}
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \seq_gput_right:cn {#1_fullresetlist_seq} {##1}%
+ \seq_remove_duplicates:c {#1_fullresetlist_seq } % Remove the duplicates
+ \xassoccnt_full_reset_list_recursive:nn {#1} {##1}% Recursive call
+ }
+}
+
+
+\cs_new:Nn \__xassoccnt_get_full_reset_list:n{%
+ \cs_if_exist:cTF {c@#1} {%
+ \seq_if_exist:cTF {#1_fullresetlist_seq} {%
+ \seq_gclear:c {#1_fullresetlist_seq}
+ }{%
+ \seq_new:c {#1_fullresetlist_seq}%
+ }%
+ \xassoccnt_bootstrap_fullreset_list:n {#1}
+ \seq_map_inline:cn {#1_fullresetlist_seq} {%
+ \xassoccnt_full_reset_list_recursive:nn {#1}{##1}%
+ }%
+ }{%
+ \msg_fatal:nnn{xassoccnt}{nameisnocounter}{#1}%
+ }%
+}
+
+
+\NewDocumentCommand{\CounterFullResetList}{m}{%
+ \__xassoccnt_get_full_reset_list:n{#1}%
+}
+
+
+
+\NewDocumentCommand{\RemoveFromReset}{mm}{%
+ \xassoccnt_local_list:nn {l_tmpa_seq} {#2}
+ \seq_set_from_clist:Nn \l_tmpb_seq {#1}
+ \seq_map_inline:Nn \l_tmpb_seq {%
+ \seq_remove_all:Nn \l_tmpa_seq {##1}%
+ }%
+ \expandafter\xdef\csname cl@#2\endcsname{\empty}%
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \@addtoreset{##1}{#2}%
+ }
+}
+
+\NewDocumentCommand{\RemoveFromFullReset}{mm}{%
+ \__xassoccnt_get_full_reset_list:n{#2}%
+ \seq_set_from_clist:Nn \l_tmpb_seq {#1}
+ \seq_map_inline:Nn \l_tmpb_seq {%
+ \__xassoccnt_get_full_reset_list:n{##1}%
+ \seq_map_inline:cn {##1_fullresetlist_seq } {%
+ \seq_gremove_all:cn {#2_fullresetlist_seq} {####1}%
+ }
+ \seq_gremove_all:cn {#2_fullresetlist_seq} {##1}%
+ }%
+ \expandafter\xdef\csname cl@#2\endcsname{\empty}%
+ \seq_map_inline:cn {#2_fullresetlist_seq} {%
+ \@addtoreset{##1}{#2}%
+ }%
+}
+
+\NewDocumentCommand{\AddToReset}{mm}{%
+ \__xassoccnt_latexcounter_exists:nTF {#2} {
+ \seq_set_from_clist:Nn \l_tmpa_seq {#1}
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \@addtoreset{##1}{#2}%
+ }
+ }{%
+ \msg_fatal:nnn{xassoccnt}{nameisnocounter}{#1}%
+ }%
+}
+
+%%%% The original counter related routines!
+
+
\cs_set_eq:NN \xassoccnt_standardstepcounter \stepcounter
\cs_set_eq:NN \xassoccnt_standardrefstepcounter \refstepcounter
\cs_set_eq:NN \xassoccnt_standardaddtocounter \addtocounter
@@ -295,7 +465,7 @@
}{}
\AtEndOfPackage{
- \PackageInfo{xassoccnt}{2016/06/19 - v\xassoccntpackageversion -- stepping counters simultaneously and other features}
+ \PackageInfo{xassoccnt}{2016/07/28 - v\xassoccntpackageversion -- stepping counters simultaneously and other features}
\@ifpackageloaded{calc}{%
\msg_warning:nnn{xassoccnt}{incompatiblepackagenonfatal}{calc}% Warning
\bool_set_true:N \l__xassoccnt_calcpackage_loaded
@@ -328,19 +498,30 @@
g_xassoccnt_#1cnt_seq%
}
+\clist_new:N \__g_xassoccnt_countercontainer_clist
+
+\ifexplversionnew
+
\str_const:Nn \c_xassoccnt_undefined_str {undefined}
\str_const:Nn \c_xassoccnt_mastername_str {master}
\str_const:Nn \c_xassoccnt_associatedname_str {associated}
\str_const:Nn \c_xassoccnt_suspendedname_str {suspended}
-\clist_new:N \__g_xassoccnt_countercontainer_clist
-\clist_set:Nn \__g_xassoccnt_countercontainer_clist {%
+\else
+\tl_const:Nn \c_xassoccnt_mastername_str {master}%
+\tl_const:Nn \c_xassoccnt_associatedname_str {associated}%
+\tl_const:Nn \c_xassoccnt_suspendedname_str {suspended}%
+\tl_const:Nn \c_xassoccnt_undefined_str {undefined}%
+\fi
+
+\clist_gset:Nn \__g_xassoccnt_countercontainer_clist {%
\c_xassoccnt_undefined_str,
\c_xassoccnt_mastername_str,
\c_xassoccnt_associatedname_str,
\c_xassoccnt_suspendedname_str
}
+
% Now generate the containers and the accessing functions
\clist_map_function:NN \__g_xassoccnt_countercontainer_clist \xassoccnt_counter_container:n
@@ -504,11 +685,13 @@
}%
}
+
+\ifexplversionnew
\cs_new:Nn \__xassoccnt_newcounter_ltx:nnn{%
\keys_set:nn {xassoccnt}{sloppy=false,initial=\c_zero,#1}
- \str_set:Nx \l_tmpa_str {#3}
+ \str_set:Nx \l_tmpa_str {#3}%
\__xassoccnt_latexcounter_exists:nTF{#2}{%
- \bool_if:nF {\l__xassoccnt_sloppy_newcounter }{
+ \bool_if:nF {\l__xassoccnt_sloppy_newcounter }{%
\msg_error:nnn{xassoccnt}{counteralreadyexists}{#2}% Warning
}
}{%
@@ -517,10 +700,27 @@
}{%
\newcounter{#2}[#3]%
}%
+ \xassoccnt_standardsetcounter{#2}{\l__xassoccnt_initialcountervalue_int}%
+ }
+}
+\else
+\cs_new:Nn \__xassoccnt_newcounter_ltx:nnn{%
+ \keys_set:nn {xassoccnt}{sloppy=false,initial=\c_zero,#1}
+ \tl_set:Nx \l_tmpa_tl {#3}
+ \__xassoccnt_latexcounter_exists:nTF{#2}{%
+ \bool_if:nF {\l__xassoccnt_sloppy_newcounter }{
+ \msg_error:nnn{xassoccnt}{counteralreadyexists}{#2}% Warning
+ }
+ }{%
+ \tl_if_empty:NTF \l_tmpa_tl {%
+ \newcounter{#2}%
+ }{%
+ \newcounter{#2}[#3]%
+ }%
\xassoccnt_standardsetcounter{#2}{\l__xassoccnt_initialcountervalue_int}
}
}
-
+\fi
@@ -863,12 +1063,11 @@
}
-%%%
-
-
%% More generic macros (hidding the internal features of the lists)
+\prop_new:N \g_xassoccnt_feature_prop
+
\cs_new_nopar:Nn \xassoccnt_container_property: {prop}
\cs_new_nopar:Nn \xassoccnt_container_datatype: {seq}
@@ -961,7 +1160,7 @@
\cs_new:Nn \xassoccnt_container_remove_by_clist:Nn {%
\clist_set:Nn \l_tmpa_tl {#2}
- \clist_map_inline:Nn \l_tmpa_tl {
+ \clist_map_inline:Nn \l_tmpa_tl {%
\xassoccnt_container_remove_all:Nn #1 {##1}
}
}
@@ -988,7 +1187,6 @@
\prg_new_conditional:Nnn \xassoccnt_container_if_exist:N {TF,T,F}%
{
-% \__xassoccnt_construct_cs:n{_if_exist:NTF} #1
\seq_if_exist:NTF #1
{\prg_return_true:}
{\prg_return_false:}
@@ -996,7 +1194,6 @@
\prg_new_conditional:Nnn \xassoccnt_container_if_exist:c {TF,T,F}%
{
-% \__xassoccnt_construct_cs:n{_if_exist:NTF} #1
\seq_if_exist:cTF {#1}
{\prg_return_true:}
{\prg_return_false:}
@@ -1006,7 +1203,6 @@
\prg_new_conditional:Nnn \xassoccnt_container_if_in:Nn {TF,T,F}%
{
- % \seq_if_in:NnTF #1 {#2}
\__xassoccnt_construct_cs:n{_if_in:NnTF} #1 {#2}
{\prg_return_true:}
{\prg_return_false:}
@@ -1074,14 +1270,42 @@
\bool_new:N \l__xassoccnt_feature_bool
\bool_new:N \l__xassoccnt_sublists_bool
+\bool_new:N \xassoccnt_cascading_bool
+
+\bool_new:N \xassoccnt_keep_after_restore_bool
+
+\tl_new:N \__xassoccnt_featurename_tl
+
+\tl_new:N \__xassoccnt_backup_id_tl
+\tl_new:N \__xassoccnt_restore_id_tl
+
+\cs_new_nopar:Nn \xassoccnt_featurename_prop:{%
+ xassoccnt_feature_\__xassoccnt_featurename_tl _prop%
+}
+
+\cs_new:Nn \xassoccnt_feature_prop_setkey:nn {%
+ \prop_gput:cnn {\xassoccnt_featurename_prop:} {#1} {#2}%
+}
+
\keys_define:nn {xassoccnt_container} {
feature .bool_set:N=\l__xassoccnt_feature_bool,
sublists .bool_set:N=\l__xassoccnt_sublists_bool,
name .tl_set:N=\l__xassoccnt_countergroup_name_tl,
+
multiple .bool_set:N=\l__xassoccnt_multiple_bool,
- featurename .tl_set:N=\l__xassoccnt_feature_name_tl
+ featurename .tl_set:N=\l__xassoccnt_feature_name_tl,
+ .code:n={ \xassoccnt_feature_prop_setkey:nn{featurename}{##1}},
+ publicname .code:n={\xassoccnt_feature_prop_setkey:nn{publicname}{##1}},
+ cascading .bool_set:N={\xassoccnt_cascading_bool},
+ resetbackup .bool_set:N={ \l__xassoccnt_resetbackupcounters_bool },
+ backup-id .tl_set:N={ \__xassoccnt_backup_id_tl },
+ restore-id .tl_set:N={ \__xassoccnt_restore_id_tl },
+ keep-after-restore .bool_set:N= {\xassoccnt_keep_after_restore_bool }
}
+
+
+
\seq_new:N \g__xassoccnt_feature_seq % The master control !!!!
\seq_new:N \g__xassoccnt_sublists_seq
@@ -1102,6 +1326,8 @@
%% Multiple counters may occur in the per - feature - specific container list
\cs_new:Nn \xassoccnt_add_feature:nn {%
+ \tl_set:Nn \__xassoccnt_featurename_tl {#2}%
+ \prop_clear_new:c {\xassoccnt_featurename_prop:}%
\keys_set:nn {xassoccnt_container} {#1}
\seq_if_exist:NT \g__xassoccnt_feature_seq {% Unique addition of a feature only!
\seq_if_in:NnF \g__xassoccnt_feature_seq {#2} {%
@@ -1177,14 +1403,13 @@
\cs_new:Nn \xassoccnt_feature_add_to_subcontainer:nnn {%
\keys_set:nn{xassoccnt_container} {multiple=false,#1}
\clist_set:Nx \l_tmpa_clist {#3}
-
\clist_map_inline:Nn \l_tmpa_clist {%
\xassoccnt_container_if_in:cnTF {\xassoccnt_feature_subcontainer:nn{\l__xassoccnt_feature_name_tl}{#2}} {##1}
{%
\bool_if:NT \l__xassoccnt_multiple_bool {% Add only if `multiple=true` was specified
\xassoccnt_container_put_right:cn {\xassoccnt_feature_subcontainer:nn{\l__xassoccnt_feature_name_tl}{#2}} {##1}
}
- }{ %
+ }{%
\xassoccnt_container_put_right:cn {\xassoccnt_feature_subcontainer:nn{\l__xassoccnt_feature_name_tl}{#2}} {##1}
}
} % End of map_inline
@@ -1216,17 +1441,461 @@
\xassoccnt_remove_feature:nn {#1} {#2}
}
+\NewDocumentCommand{\NewContainer}{m}{%
+ \xassoccnt_create_container:nc {feature=false} {#1}
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%% New Backup Counter features
-\NewDocumentCommand{\NewContainer}{m}{%
- \xassoccnt_create_container:nc {feature=false} {#1}
+
+\cs_new:Nn \xassoccnt_backup_id_seq:n {%
+ l_backupcounters_#1_id_seq%
+}
+
+\cs_new:Nn \__xassoccnt_declare_countergroupname:nn {%
+ \xassoccnt_container_if_exist:cF { \xassoccnt_feature_group_container:n{#1}{#2} }
+ {%
+ \xassoccnt_feature_add_to_group_container:nn{multiple=false,featurename=#1}{#2}%
+ \seq_new:c { l_#1_#2_id_seq}%
+ \prop_new:c { l_#1_#2_prop }% Setup a feature property sub list for values
+ }
}
+\cs_new:Nn \xassoccnt_declare_backupcountersgroupname:n {%
+ \xassoccnt_container_if_exist:cF { \xassoccnt_feature_group_container:n{backupcounters}{#1} }
+ {
+ \prop_new:c { l_backupcounters_#1_prop }
+ \seq_new:c { \xassoccnt_backup_id_seq:n{#1}} %
+ \xassoccnt_feature_add_to_group_container:nn{multiple=false,featurename=backupcounters}{#1}%
+ }
+}
-\bool_new:N \l__xassoccnt_is_coupledcounter_bool
+
+\NewDocumentCommand{\DeclareBackupCountersGroupName}{m}{%
+ \__xassoccnt_declare_countergroupname:nn{backupcounters}{#1}%
+}
+
+\cs_new:Nn \xassoccnt_assign_backupcounters_to_group:nn {%
+ \keys_set:nn {xassoccnt_container} {name={},multiple=false,#1}
+ \tl_if_empty:NT \l__xassoccnt_countergroup_name_tl {%
+ \msg_warning:nnn{xassoccnt}{emptybackupcountergroup}{xassoccnt_assign_backupcounters_to_group}{}%
+ \keys_set:nn {xassoccnt_container} {multiple=false,#1,name={\xassoccnt_extract_moduledata:n{scratchname}}}
+ }
+ % Check first if the counter group name is already registered
+ \xassoccnt_container_if_exist:cF { \xassoccnt_feature_subcontainer:nn{backupcounters}{\l__xassoccnt_countergroup_name_tl} }
+ {%
+ \xassoccnt_declare_backupcountersgroupname:n{\l__xassoccnt_countergroup_name_tl}%
+ }%
+ \xassoccnt_feature_add_to_subcontainer:nnn{multiple=false,#1,featurename=backupcounters}{\l__xassoccnt_countergroup_name_tl}{#2}%
+}
+
+
+% This macro assigns counters to a backup group%
+\NewDocumentCommand{\AssignBackupCounters}{O{}m}{%
+ \keys_set:nn{xassoccnt_container} {#1}
+ \xassoccnt_assign_backupcounters_to_group:nn {#1}{#2}%
+ \bool_if:NTF \xassoccnt_cascading_bool {%
+ % Set the starter counter name to the list defined by `name=...`
+ \AddBackupCounters[#1]{#2}%
+ % Ok, let's get the all counters in the reset list of #2
+ \CounterFullResetList{#2}%
+ \seq_if_empty:cF {#2_fullresetlist_seq} {%
+ \seq_map_inline:cn { #2_fullresetlist_seq} {\AddBackupCounters[#1]{##1} }%
+ }%
+ }{%
+ \AddBackupCounters[#1]{#2}%
+ }
+
+}
+\NewDocumentCommand{\AddBackupCounters}{O{}m}{%
+ \keys_set:nn {xassoccnt_container} {multiple=false,#1}
+ \xassoccnt_container_if_exist:cTF { \xassoccnt_feature_subcontainer:nn{backupcounters}{\l__xassoccnt_countergroup_name_tl } } {%
+ \xassoccnt_feature_add_to_subcontainer:nnn{#1,featurename=backupcounters}{\l__xassoccnt_countergroup_name_tl}{#2}%
+ }{%
+ \msg_warning:nnxx{xassoccnt}{addbackupcountergroupundefined}{AddBackupCounters}{\l__xassoccnt_countergroup_name_tl}% Warning about undefined counter group
+ }%
+}
+
+
+
+\bool_new:N \l__xassoccnt_is_backupcounter_bool
+
+\prg_new_conditional:Nnn \__xassoccnt_is_backupcounter:n {TF,T,F} {%
+ \xassoccnt_container_map_inline:cn { \xassoccnt_feature_group_container:n{backupcounters} } {%
+ \bool_set_false:N \l__xassoccnt_is_backupcounter_bool
+ \xassoccnt_container_if_in:cxT { \xassoccnt_feature_subcontainer:nn{backupcounters}{##1} } {#1}
+ {
+ \bool_set_true:N \l__xassoccnt_is_backupcounter_bool
+ \xassoccnt_container_map_break:
+ }
+ }
+ \bool_if:NTF \l__xassoccnt_is_backupcounter_bool
+ {\prg_return_true:}
+ {\prg_return_false:}
+}
+
+
+
+\cs_generate_variant:Nn \__xassoccnt_is_backupcounter:nTF {c }
+\cs_generate_variant:Nn \__xassoccnt_is_backupcounter:nT { c }
+\cs_generate_variant:Nn \__xassoccnt_is_backupcounter:nF { c }
+
+\cs_new:Nn \xassoccnt_is_backupcounter:nTF { %
+ \__xassoccnt_is_backupcounter:nTF {#1} {#2} {#3}
+}
+
+\cs_new:Nn \xassoccnt_is_backupcounter:nT { %
+ \__xassoccnt_is_backupcounter:nT {#1} {#2}%
+}
+
+\cs_new:Nn \xassoccnt_is_backupcounter:nF { %
+ \__xassoccnt_is_backupcounter:nF {#1} {#2}%
+}
+
+
+
+%%%%
+
+\cs_new:Nn \__xassoccnt_backup_renew_theHmacros:nn {%
+ \bool_if:NT \l__xassoccnt_hyperrefpackage_loaded_bool {%
+ \cs_if_exist:cT {theH#1} {%
+ \cs_gset_eq:cc {xassoccnt_#2_theH#1} {theH#1}%
+ \expandafter\renewcommand\csname theH#1\endcsname{xassoccnt.#1_#2.\use:c{the#1}}%
+ }%
+ }
+}
+\cs_new:Nn \__xassoccnt_backup_restore_theHmacros:nn {%
+ \bool_if:NT \l__xassoccnt_hyperrefpackage_loaded_bool {%
+ \cs_if_exist:cT {theH#1} {%
+ \expandafter\renewcommand\csname theH#1\endcsname{xassoccnt.#1_#2.\use:c{the#1}}%
+ }%
+ }%
+}
+
+
+
+
+
+\cs_new:Nn \__xassoccnt_prepare_backupid:nn{%
+ #1#2
+}
+
+\cs_new:Nn \__xassoccnt_prepare_backupid:nnn{%
+ #1#2#3
+}
+
+\cs_new:Nn \xassoccnt_feature_subproplist:nn {%
+ l_#1_#2_prop%
+}
+
+
+\cs_new:Nn \xassoccnt_backup_subproplist:n {%
+ l_\xassoccnt_extract_moduledata:n{backupfeaturename}_#1_prop%
+}
+
+
+
+\cs_new:Nn \xassoccnt_backupstore_property:cnn{%
+ \prop_gput:cnn {\xassoccnt_feature_subproplist:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#1}} { #2 } {#3}% Must be expanded
+}
+
+
+
+\cs_generate_variant:Nn \xassoccnt_backup_subproplist:n {V}
+\cs_generate_variant:Nn \xassoccnt_backupstore_property:cnn {cxx} %
+\cs_generate_variant:Nn \__xassoccnt_backup_restore_theHmacros:nn {nx,cn,cx}
+
+
+\NewDocumentCommand{\BackupCounterValues}{O{}m}{%
+ \keys_set:nn {xassoccnt_container} {backup-id={},
+ restore_id={},
+ resetbackup=true,
+ cascading=false,
+ multiple=false,
+ name={\xassoccnt_extract_moduledata:n {scratchname}},
+ #1
+ }
+ \tl_if_empty:NT \__xassoccnt_backup_id_tl {%
+ \msg_fatal:nnxx{xassoccnt}{nobackupid}{\l__xassoccnt_countergroup_name_tl}{BackupCounterValues}% Fatal Error
+ }
+ \tl_if_empty:NT \__xassoccnt_restore_id_tl {%
+ \msg_fatal:nnxx{xassoccnt}{nobackupid}{\l__xassoccnt_countergroup_name_tl}{BackupCounterValues}% Fatal Error
+ }
+ % Prevent multiple usages of the same backup id per counter group
+ \seq_if_in:cVTF {\xassoccnt_backup_id_seq:n{\l__xassoccnt_countergroup_name_tl}} { \__xassoccnt_backup_id_tl } {%
+ \msg_fatal:nnxxx{xassoccnt}{duplicatebackupid}{\__xassoccnt_backup_id_tl}{\l__xassoccnt_countergroup_name_tl}{BackupCounterValues}% Fatal Error
+ }{%
+ \seq_put_right:cV {\xassoccnt_backup_id_seq:n{\l__xassoccnt_countergroup_name_tl}} { \__xassoccnt_backup_id_tl }%
+ \seq_remove_duplicates:c {\xassoccnt_backup_id_seq:n{\l__xassoccnt_countergroup_name_tl}}
+ }
+ \bool_if:NTF \xassoccnt_cascading_bool {%
+ % Set the starter counter name to the list defined by `name=...`
+ \AddBackupCounters[#1]{#2}%
+ % Ok, let's get the all counters in the reset list of #2
+ \CounterFullResetList{#2}%
+ \seq_if_empty:cF {#2_fullresetlist_seq} {%
+ \seq_map_inline:cn { #2_fullresetlist_seq} {\AddBackupCounters[#1]{##1} }%
+ }%
+ }{%
+ \AddBackupCounters[#1]{#2}%
+ }
+ \seq_map_inline:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{\l__xassoccnt_countergroup_name_tl }} {%
+ \xassoccnt_backupstore_property:cxx {\l_xassoccnt_countergroup_name_tl}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}} {\number\value{##1}}% Must be expanded!
+ \__xassoccnt_backup_renew_theHmacros:nn {##1}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}}%
+ \bool_if:NT \l__xassoccnt_resetbackupcounters_bool {%
+ \setcounter{##1}{\c_zero}%
+ }
+ }%
+}
+
+
+\NewDocumentCommand{\BackupCounterGroup}{O{}m}{%
+ \keys_set:nn {xassoccnt_container} {backup-id={},
+ restore-id={},
+ resetbackup=true,
+ cascading=false,
+ multiple=false,
+ name={},
+ #1
+ }
+ \tl_if_empty:NT \__xassoccnt_backup_id_tl {%
+ \msg_fatal:nnxx{xassoccnt}{nobackupid}{#2}{BackupCounterGroup}% Fatal Error
+ }
+ % Prevent multiple usages of the same backup id per counter group
+ \seq_if_in:cVTF {\xassoccnt_backup_id_seq:n{#2}} { \__xassoccnt_backup_id_tl } {%
+ \msg_fatal:nnxxx{xassoccnt}{duplicatebackupid}{\__xassoccnt_backup_id_tl}{#2}{BackupCounterGroup}% Fatal Error
+ }{%
+ \seq_put_right:cV {\xassoccnt_backup_id_seq:n{#2}} { \__xassoccnt_backup_id_tl }%
+ \seq_remove_duplicates:c {\xassoccnt_backup_id_seq:n{#2}}
+ }
+ \seq_map_inline:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2}} {%
+ \xassoccnt_backupstore_property:cxx {#2}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}} {\number\value{##1}}% Must be expanded!
+ \__xassoccnt_backup_renew_theHmacros:nn {##1}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}}%
+ \bool_if:NT \l__xassoccnt_resetbackupcounters_bool {%
+ \setcounter{##1}{\c_zero}%
+ }%
+ }%
+}
+
+
+
+
+\NewDocumentCommand{\RestoreBackupCounterGroup}{O{}m}{%
+ \keys_set:nn {xassoccnt_container} {keep-after-restore=false,backup-id={},restore-id={},multiple=false,#1}
+ %
+ % Test whether counter group #2 exists:
+ \seq_if_in:cnTF {\xassoccnt_feature_group_container:n{\xassoccnt_extract_moduledata:n{backupfeaturename}}} {#2} {%
+ \tl_if_empty:NT \__xassoccnt_backup_id_tl {%
+ \msg_error:nnxx{xassoccnt}{nobackupid}{\l__xassoccnt_countergroup_name_tl}{RestoreBackupCounterGroup}% Fatal Error
+ }%
+ \tl_if_empty:NT \__xassoccnt_restore_id_tl {%
+ \tl_set_eq:NN \__xassoccnt_restore_id_tl \__xassoccnt_backup_id_tl
+ }
+ % Test first if the backup id is valid!
+ \seq_if_in:cVT {\xassoccnt_backup_id_seq:n{#2}} { \__xassoccnt_backup_id_tl } {%
+ \seq_map_inline:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2 }} {%
+ \__xassoccnt_backup_restore_theHmacros:nx {##1}{\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_restore_id_tl}}%\__xassoccnt_restore_id_tl}}%
+ \tl_set:Nx \l_tmpa_tl {\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}}
+ \int_set:Nx \l_tmpa_int {\prop_item:cV {\xassoccnt_backup_subproplist:n{#2} } {\l_tmpa_tl}}%
+ \setcounter{##1}{\int_use:N \l_tmpa_int}%
+ }
+ \bool_if:NF \xassoccnt_keep_after_restore_bool {%
+ \seq_gremove_all:cV {\xassoccnt_backup_id_seq:n{#2}} { \__xassoccnt_backup_id_tl }
+ \seq_map_inline:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2}} {%
+ \prop_remove:cx { \xassoccnt_backup_subproplist:n{#2} } {\__xassoccnt_prepare_backupid:nn{##1}{\__xassoccnt_backup_id_tl}}%
+ }
+ }
+ }
+ }{%
+ \msg_warning:nnxx{xassoccnt}{backupcountergroupundefined}{RestoreBackupCounterGroup}{#2}% Warning, rest is ignored!
+ }%
+}
+
+
+%%%% Clearing, removing counters from a group and deleting the counter group
+
+
+\cs_new:Nn \xassoccnt_backup_removecounter_from_group:nnn {%
+ % Check whether the counter group #2 exists
+ \seq_set_from_clist:Nn \l_tmpa_seq {#3}%
+ \xassoccnt_container_if_in:cnT {\xassoccnt_feature_group_container:n{\xassoccnt_extract_moduledata:n{backupfeaturename}}} {#2} {%
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ % Remove the property value(s) connected with this counter! -> must loop over all backup-ids
+ \seq_if_exist:cT {\xassoccnt_backup_id_seq:n{#2}} {%
+ \seq_map_inline:cn { \xassoccnt_backup_id_seq:n{#2} } {%
+ \prop_remove:cx { \xassoccnt_backup_subproplist:n{#2}} {\__xassoccnt_prepare_backupid:nn{##1}{####1} }
+ }%
+ }%
+ % Remove the name ##1 from the counter group #2
+ \xassoccnt_container_gremove_all:cn {\xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2}} {##1}
+ }%
+ }%
+}
+
+
+
+\cs_new:Nn \xassoccnt_backup_clear_countergroup:nn {%
+ \seq_if_exist:cT {\xassoccnt_backup_id_seq:n{#2}} {%
+ \seq_clear:c {\xassoccnt_backup_id_seq:n{#2}}%
+ \cs_undefine:c {\xassoccnt_backup_id_seq:n{#2}}%
+ }
+ % Delete the property list connected to the current counter group
+ \prop_clear:c { \xassoccnt_backup_subproplist:n{#2} }
+ % Remove the names from the counter group%
+ \xassoccnt_container_clear:c { \xassoccnt_feature_subcontainer:nn{\xassoccnt_extract_moduledata:n{backupfeaturename}}{#2} }
+}
+
+
+\cs_new:Nn \xassoccnt_backup_delete_countergroup:nn{%
+ \xassoccnt_backup_clear_countergroup:nn{#1}{#2}%
+ \xassoccnt_container_remove_all:cn {\xassoccnt_feature_group_container:n{backupcounters}}{#2}%
+}
+
+\cs_new:Nn \__xassoccnt_backup_remove_prop_value:nn {
+ \prop_remove:Nn #1 {#2}
+}
+
+
+
+\cs_new:Nn \xassoccnt_backup_clear_counterbackupstate:nnn {%
+ \xassoccnt_container_if_exist:cT { \xassoccnt_feature_subcontainer:nn{backupcounters}{#2} }
+ {% Is it a valid backup-id at all? -> check
+ \seq_if_exist:cT {\xassoccnt_backup_id_seq:n{#2} }
+ {%
+ \seq_if_in:cVT { \xassoccnt_backup_id_seq:n{#2}} {#1}
+ {%
+ \prop_remove:cx { \xassoccnt_backup_subproplist:n{#2} } {\__xassoccnt_prepare_backupid:nn{#3}{#1} }%
+ }%
+ }%
+ }%
+}
+
+
+\cs_new:Nn \xassoccnt_backup_clear_backupstate:nn {%
+ \xassoccnt_container_if_exist:cT { \xassoccnt_feature_subcontainer:nn{backupcounters}{#2} }
+ {% Is it a valid backup-id at all? -> check
+ \seq_if_exist:cT {\xassoccnt_backup_id_seq:n{#2} }
+ {%
+ \seq_if_in:cVT { \xassoccnt_backup_id_seq:n{#2}} {#1}
+ {%
+ \seq_map_inline:cn { \xassoccnt_feature_subcontainer:nn{backupcounters}{#2} } {%
+ \prop_remove:cx { \xassoccnt_backup_subproplist:n{#2} } {\__xassoccnt_prepare_backupid:nn{##1}{#1} }
+ }%
+ \seq_remove_all:cV { \xassoccnt_backup_id_seq:n{#2} } {#1}%
+ }%
+ }%
+ }%
+}
+
+
+
+\NewDocumentCommand{\ClearCounterBackupState}{O{}mm}{%
+ \keys_set:nn {xassoccnt_container} {backup-id={},#1}
+ \xassoccnt_backup_clear_counterbackupstate:nnn {\__xassoccnt_backup_id_tl} { #2 } { #3 }
+}
+
+
+\NewDocumentCommand{\ClearBackupState}{O{}m}{%
+ \keys_set:nn {xassoccnt_container} {backup-id={},#1}
+ \xassoccnt_backup_clear_backupstate:nn { \__xassoccnt_backup_id_tl } {#2}
+ \prop_map_inline:cn {\xassoccnt_backup_subproplist:n{#2}} {##1->##2\par}%
+}
+
+
+
+\NewDocumentCommand{\ClearBackupCounterGroups}{O{}m}{%
+ \seq_set_from_clist:Nn \l_tmpa_seq {#2}%
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \xassoccnt_backup_clear_countergroup:nn{#1}{##1}%
+ }%
+}
+
+\NewDocumentCommand{\RemoveCountersFromBackupGroup}{O{}mm}{%
+ \xassoccnt_backup_removecounter_from_group:nnn {#1} {#2} {#3}%
+}
+
+\NewDocumentCommand{\DeleteBackupCounterGroups}{O{}m}{%
+ \seq_set_from_clist:Nn \l_tmpa_seq {#2}%
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \xassoccnt_backup_delete_countergroup:nn {#1} {##1}%
+ }%
+}
+
+
+
+
+%%% Query routines
+
+\prg_new_conditional:Nnn \__xassoccnt_is_backupcountergroup:n {TF,T,F} {%
+ \xassoccnt_container_if_in:cnTF { \xassoccnt_feature_group_container:n{\xassoccnt_extract_moduledata:n{backupfeaturename}} } {#1}
+ {\prg_return_true:}
+ {\prg_return_false:}
+}
+
+\prg_new_conditional:Nnn \__xassoccnt_is_backupstate:nn {TF,T,F} {%
+ \xassoccnt_container_if_exist:cTF { \xassoccnt_feature_subcontainer:nn{backupcounters}{#1} }
+ {% Is it a valid backup-id at all? -> check
+ \seq_if_exist:cTF {\xassoccnt_backup_id_seq:n{#1} }
+ {%
+ \seq_if_in:cnTF { \xassoccnt_backup_id_seq:n{#1}} {#2}
+ {\prg_return_true:}
+ {\prg_return_false:}
+ }{\prg_return_false:}
+ }{\prg_return_false:}
+}
+
+
+\NewDocumentCommand{\IsBackupCounterGroupTF}{m+m+m}{%
+ \__xassoccnt_is_backupcountergroup:nTF {#1} {#2} {#3}%
+}
+
+\NewDocumentCommand{\IsBackupCounterGroupT}{m+m}{%
+ \__xassoccnt_is_backupcountergroup:nT {#1} {#2}
+}
+
+\NewDocumentCommand{\IsBackupCounterGroupF}{m+m}{%
+ \__xassoccnt_is_backupcountergroup:nF {#1} {#2}%
+}
+
+
+\NewDocumentCommand{\IsBackupStateTF}{mm+m+m}{%
+ \__xassoccnt_is_backupstate:nnTF {#1} {#2} {#3} {#4}%
+}
+
+\NewDocumentCommand{\IsBackupStateT}{mm+m}{%
+ \__xassoccnt_is_backupstate:nnT {#1} {#2} {#3}%
+}
+
+\NewDocumentCommand{\IsBackupStateF}{mm+m}{%
+ \__xassoccnt_is_backupstate:nnF {#1} {#2} {#3}%
+}
+
+
+\NewDocumentCommand{\IsBackupCounterTF}{m+m+m}{%
+ \xassoccnt_is_backupcounter:nTF {#1} {#2} {#3}
+}
+
+\NewDocumentCommand{\IsBackupCounterT}{m+m}{%
+ \xassoccnt_is_backupcounter:nT {#1} {#2}
+}
+
+\NewDocumentCommand{\IsBackupCounterF}{m+m}{%
+ \xassoccnt_is_backupcounter:nF {#1} {#2}
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%% Coupled Counter features
+
+\bool_new:N \l__xassoccnt_is_coupledcounter_bool
+
\prg_new_conditional:Nnn \__xassoccnt_is_coupledcounter:n {TF,T,F}
{
\xassoccnt_container_map_inline:cn { \xassoccnt_feature_group_container:n{coupledcounters} } {%
@@ -1259,12 +1928,6 @@
}
-
-\cs_generate_variant:Nn \xassoccnt_is_coupledcounter:nTF { c }
-\cs_generate_variant:Nn \xassoccnt_is_coupledcounter:nT { c }
-\cs_generate_variant:Nn \xassoccnt_is_coupledcounter:nF { c }
-
-
% Declaring a new coupled counters group
\cs_new:Nn \xassoccnt_declare_coupledcountersgroup:n {%
\xassoccnt_container_if_exist:cF { \xassoccnt_feature_group_container:n{coupledcounters}{#1} }
@@ -1417,6 +2080,15 @@
\xassoccnt_remove_periodiccounter:nn{#1} {#2}
}
+
+\NewDocumentCommand{\RemoveAllPeriodicCounters}{O{}}{%
+ \seq_map_inline:Nn \g_xassoccnt_periodiccounter_container_seq {\xassoccnt_remove_periodiccounter:nn {#1} {##1}}
+% \cs_new:Nn \xassoccnt_remove_periodiccounter:nn {%
+ \seq_gclear:N \g_xassoccnt_periodiccounter_container_seq
+ \prop_gclear:N \g_xassoccnt_periodiccounter_prop
+}
+
+
\NewDocumentCommand{\AddPeriodicCounter}{O{}mm}{%
\xassoccnt_add_periodiccounter:nnn {#1} {#2} {#3}
}
@@ -1442,73 +2114,6 @@
-\NewDocumentCommand{\stepcounteroldnototal}{m}{%
- \__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}%
- \xassoccnt_is_suspendedcounter:nF{#1}{%
- \xassoccnt_is_coupledcounter:nTF {#1}
- { \xassoccnt_stepcounter_coupledcounters:n{#1} }
- {% No, not a coupled counter!
- \cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {\l_tmpa_tl}%
- \xassoccnt_countersinresetlist:n{\l_tmpa_tl}%
- \__xassoccnt_getresetlist:n {\l_tmpa_tl}%
- \seq_if_empty:NTF \l__xassoccnt_counterreset_seq
- {%
- \xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one}% Use the original one!
- \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{\l_tmpa_tl}}%
- \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl}
- }{ % reset list is not empty!
- % This is the replacement of \csname cl@#1\endcsname
- \xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one}
- \seq_map_inline:Nn \l__xassoccnt_counterreset_seq {%
- \xassoccnt_is_drivercounter:nTF{##1}{%
- \csname c@##1\endcsname\c_zero % Reset but do not increase
- }{%
- \csname c@##1\endcsname\c_minus_one
- \xassoccnt_standardstepcounter{##1}%
- }
- }
- \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl} % step the remaining associated counters
- }% End of not empty reset list
- }% End of coupled counters
- } % end of not suspended counter
-}
-
-
-
-\NewDocumentCommand{\stepcounterTotal}{m}{%
- \__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}%
- \xassoccnt_is_suspendedcounter:nF{#1}{%
- \xassoccnt_is_coupledcounter:nTF {#1}
- { \xassoccnt_stepcounter_coupledcounters:n{#1} }
- {% No, not a coupled counter!
- \cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {\l_tmpa_tl}%
- \xassoccnt_countersinresetlist:n{\l_tmpa_tl}%
- \__xassoccnt_getresetlist:n {\l_tmpa_tl}%
- \seq_if_empty:NTF \l__xassoccnt_counterreset_seq
- {%
- \xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one}% Use the original one!
- \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{\l_tmpa_tl}}%
- \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl}
- }{ % reset list is not empty!
- % This is the replacement of \csname cl@#1\endcsname
- \xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one}
- \seq_map_inline:Nn \l__xassoccnt_counterreset_seq {%
- \xassoccnt_is_drivercounter:nTF{##1}{%
- \csname c@##1\endcsname\c_zero % Reset but do not increase
- }{%
- \csname c@##1\endcsname\c_minus_one
- \xassoccnt_standardstepcounter{##1}%
- }
- }
- \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl} % step the remaining associated counters
- }% End of not empty reset list
- }% End of coupled counters
- } % end of not suspended counter
- \__xassoccnt_is_totalcounter:nT {#1} {%
- \__xassoccnt_store_totalcounter_value:n {#1}%
- }
-}
-
\RenewDocumentCommand{\stepcounter}{m}{%
\__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}%
@@ -1728,9 +2333,6 @@
}
-
-
-
\NewDocumentCommand{\NewDocumentCounter}{O{initial=\c_zero}mo}{%
\IfValueTF{#3}{%
\__xassoccnt_newcounter_ltx:nnn{#1}{#2}{#3}
@@ -1739,8 +2341,6 @@
}
}
-
-
\NewDocumentCommand{\CopyDocumentCounters}{O{}mm}{%
\__xassoccnt_copycounters:nnn{#1}{#2}{#3}%
}
@@ -1749,7 +2349,7 @@
\__xassoccnt_swapcounters:nnn{#1}{#2}{#3}%
}
-
+%%%%%%%%%%%%%%% Reset list related stuff
\newcommand{\countersresetlistcount}[1]{%
\int_zero:N \l_xassoccnt_resetlist_counter%
@@ -1850,6 +2450,7 @@
\cs_new:Nn \__xassoccnt_store_totalcounter_value:n {%
\prop_put:Nnn \g_xassoccnt_totalcounter_prop {#1} {\number\value{\__xassoccnt_expand_totalcountername:n{#1}}}
+ \prop_put:Nnn \g_xassoccnt_totalcounter_prop {#1name} {\__xassoccnt_expand_totalcountername:n{#1}}
}
\cs_new:Nn \__xassoccnt_registertotaldocumentcounter:nn {%
@@ -1878,28 +2479,11 @@
}
+% Expandable version
\newcommand{\TotalValue}[1]{%
-% \seq_use:Nn \g__xassoccnt_totalcounter_container {\par}%
- \tl_set:Nx \l_tmpa_tl {\__xassoccnt_expand_totalcountername:n{#1}}
- \tl_set:Nx \l_tmpb_tl {#1}%
- \seq_if_in:NnTF \g__xassoccnt_supertotalcounter_container {\l_tmpb_tl }{%
- \tl_set:Nx \l_tmpa_tl {\__xassoccnt_expand_totalcountername:n{#1}}
- }{%
- \seq_if_in:NVF \g__xassoccnt_totalcounter_container {\l_tmpa_tl }{%
- \tl_set:NV \l_tmpa_tl {#1}%
- }
- }
- \number\value{\tl_use:N \l_tmpa_tl}%
-}
-
-\renewcommand{\TotalValue}[1]{%
\prop_item:Nn \g_xassoccnt_totalcounter_prop {#1}%
}
-%\newcommand{\loadstore}
-
-
-
\cs_new:Nn \__xassoccnt_writetotalcounters:nn {%
\immediate\write\@mainaux {%
\string\IfIsDocumentCounterF\expandafter{\__xassoccnt_expand_totalcountername:n{#1}}{\string\DeclareDocumentCounter\expandafter{\__xassoccnt_expand_totalcountername:n{#1}}}
@@ -1915,6 +2499,10 @@
}
}
+\NewDocumentCommand{\TotalCounterInternalNameExp}{m}{%
+ \prop_item:Nn \g_xassoccnt_totalcounter_prop {#1name}%
+}
+
\NewDocumentCommand{\TotalCounterInternalName}{m}{%
@@ -2088,17 +2676,17 @@
}
-\NewDocumentCommand{\BackupCounterValues}{O{resetbackup=true}m}{%
- \keys_set:nn{xassoccnt}{#1}
+\NewDocumentCommand{\FormerBackupCounterValues}{O{resetbackup=true}m}{%
+ \keys_set:nn{xassoccnt}{#1}%
\int_incr:N \g__xassoccnt_backupcalls_int
\int_zero:N \l_tmpa_int
- \seq_clear:N \l__xassoccnt_countervaluesbackup_seq
- \seq_clear:N \l__xassoccnt_backupresetlist_seq
+ \seq_gclear:N \l__xassoccnt_countervaluesbackup_seq
+ \seq_gclear:N \l__xassoccnt_backupresetlist_seq
\__xassoccnt_addbackupcounter:nnn {#1}{}{#2}%
- \seq_clear:N \l__xassoccnt_backupresetlist_seq%
+ \seq_gclear:N \l__xassoccnt_backupresetlist_seq%
}
-\NewDocumentCommand{\RemoveBackupCounterInternal}{sO{}m}{%
+\NewDocumentCommand{\FormerRemoveBackupCounterInternal}{sO{}m}{%
\tl_set:Nn \l_tmpa_tl {#3}
\int_zero:N \l_tmpa_int%
\int_zero:N \l_tmpb_int%
@@ -2125,19 +2713,19 @@
-\NewDocumentCommand{\RemoveBackupCounters}{sO{}m}{%
+\NewDocumentCommand{\FormerRemoveBackupCounters}{sO{}m}{%
\clist_set:Nn \l_tmpa_clist {#3}
% Loop through the list
\clist_map_inline:Nn \l_tmpa_clist {%
\IfBooleanTF{#1}{%
- \RemoveBackupCounterInternal*{##1}%
+ \FormerRemoveBackupCounterInternal*{##1}%
}{%
- \RemoveBackupCounterInternal*{##1}%
+ \FormerRemoveBackupCounterInternal{##1}%
}
}
}
-\NewDocumentCommand{\RestoreAllCounterValues}{O{}}{%
+\NewDocumentCommand{\FormerRestoreAllCounterValues}{O{}}{%
\__xassoccnt_restorecountervalues:n {l__xassoccnt_counternamesbackup_seq }
\seq_clear:N \l__xassoccnt_countervaluesbackup_seq % clear the value list
\seq_clear:N \l__xassoccnt_counternamesbackup_seq % clear the name list
@@ -2145,7 +2733,7 @@
% \Restore is \Remove with restoring (of course)
-\NewDocumentCommand{\RestoreCounterValues}{O{}m}{%
+\NewDocumentCommand{\FormerRestoreCounterValues}{O{}m}{%
\clist_set:Nn \l_tmpa_clist {#2}
\clist_map_inline:Nn \l_tmpa_clist {%
\RemoveBackupCounterInternal{##1}%
@@ -2161,7 +2749,7 @@
}
-\NewDocumentCommand{\AddBackupCounter}{O{}m}{%
+\NewDocumentCommand{\FormerAddBackupCounter}{O{}m}{%
\clist_set:Nx \l_tmpa_clist {#2}
\clist_map_inline:Nn \l_tmpa_clist {%
\__xassoccnt_removestarsinglevalue:n{##1}%
@@ -2202,16 +2790,21 @@
\clist_map_inline:Nn \l_tmpa_clist { #2{##1} }
}
-
+\NewDocumentCommand{\LoopFullCounterResetList}{m+m}{%
+ \__xassoccnt_get_full_reset_list:n {#1}%
+ \seq_if_exist:cT {#1_fullresetlist_seq } {
+ \seq_map_inline:cn {#1_fullresetlist_seq} {%
+ #2{##1}%
+ }
+ }%
+}
%%%%
%% Counter-Values-Mapping-To-Something-Different - Macros
-
-
-
+%%% To be done!
%%%%%%%%%%%%%%%%%%%%
@@ -2248,7 +2841,6 @@
}{#2}
}
-
\NewDocumentCommand{\DeclareDocumentCounter}{O{initial={0}}mo}{%
\IfValueTF{#3}{%
\xassoccnt_declaredocumentcounteropt:nnn{#1}{#2}{#3}%
@@ -2259,8 +2851,6 @@
\ExplSyntaxOff
-
-
\EnableNumberofrunsTF{%
\NewTotalDocumentCounter[supertotal=true]{numberofruns}
\AtBeginDocument{%
@@ -2284,6 +2874,9 @@
\@onlypreamble{\DeclareDocumentCounter}
\@onlypreamble{\DeclareCoupledCounters}
+\AtBeginDocument{%
+ \DeclareBackupCountersGroupName{scratch}%
+}
%%% Colour output routines
@@ -2297,8 +2890,8 @@
-\AddFeature[sublists=true]{coupledcounters} % New style, not fully implemented so far
-\AddFeature[sublists=false]{periodiccounters} % New style, not fully implemented so far
+\AddFeature[sublists=true,publicname={Coupled Counters Feature}]{coupledcounters}
+\AddFeature[sublists=true,publicname={Backup Counters Feature}]{backupcounters} % New style, not fully implemented so far
% Some more to be done