diff options
author | Karl Berry <karl@freefriends.org> | 2016-03-01 23:37:32 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-03-01 23:37:32 +0000 |
commit | 2b89922d6cb784a0bcc5507ca4481aa0bbc82be8 (patch) | |
tree | fb33525658fe1e10295f92da6cd312e62e9310e8 | |
parent | 520d48c8fa8936a7a59c6155651dd84116788842 (diff) |
xassoccnt (28feb16)
git-svn-id: svn://tug.org/texlive/trunk@39911 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/xassoccnt/README | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf | bin | 285805 -> 384013 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex | 162 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf | bin | 80771 -> 80974 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf | bin | 68837 -> 68837 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty | 608 |
8 files changed, 684 insertions, 98 deletions
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/README b/Master/texmf-dist/doc/latex/xassoccnt/README index be977393375..205a70c9c44 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/README +++ b/Master/texmf-dist/doc/latex/xassoccnt/README @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 0.4 (2016/01/26 -- 10/46/26) +%% LaTeX package xassoccnt - version 0.5 (2016/02/27 -- 19/52/22) %% README file for xassoccnt.sty %% %% @@ -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/01/26 xassoccnt does not supersede the package assoccnt by the same author, however, -the older package isn't declared obsolete as of 2016/01/26 +As of 2016/02/27 xassoccnt does not supersede the package assoccnt by the same author, however, +the older package isn't declared obsolete as of 2016/02/27 diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf Binary files differindex 927a086cb3a..25cc2889f78 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex index ec06144523f..2039e39d55b 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 0.4 (2016/01/26 -- 10/46/26) +%% LaTeX package xassoccnt - version 0.5 (2016/02/27 -- 19/52/22) %% Documentation file for xassoccnt.sty %% %% @@ -19,7 +19,7 @@ %% %% -\documentclass[12pt,paper=a4]{article} +\documentclass[12pt,a4]{article} @@ -45,6 +45,8 @@ \usepackage{enumitem} \usepackage{microtype} \usepackage{caption} +\usepackage[T1]{fontenc} +%\usepackage{lucidabr} \usepackage[scaled=0.92]{helvet} \newlist{codeoptionsenum}{enumerate}{1} @@ -236,7 +238,6 @@ \newcommand{\mymailtoaddress}{% christian.hupfer@yahoo.de -% christian.hupfer@yahoo.de } @@ -282,7 +283,9 @@ pdfcreator={LaTeX} } - +\newcommand{\versionzerofourdate}{2016-01-26} +\newcommand{\currentversiondate}{2016-02-27} +\newcommand{\versionzerofivedate}{\currentversiondate} \begin{document} \mmddyyyydate @@ -1029,7 +1032,7 @@ Some notes on \refCom{SetDocumentCounter} \end{itemize} \end{docCommand}% -\begin{docCommand}{StepDownCounter}{\oarg{options}\marg{counter}}\tcbdocmarginnote{\tcbdocnew{2016-01-11}} +\begin{docCommand}{StepDownCounter}{\oarg{options}\marg{counter}}\tcbdocmarginnote{\tcbdocnew{\versionzerofourdate}} This macro subtracts the value of 1 from the counter and is the counterpart of \cs{stepcounter}. @@ -1046,7 +1049,7 @@ This macro subtracts the value of 1 from the counter and is the counterpart of \ \end{docCommand}% -\begin{docCommand}{SubtractFromCounter}{\oarg{options}\marg{counter}\marg{delta value}}\tcbdocmarginnote{\tcbdocnew{2016-01-11}} +\begin{docCommand}{SubtractFromCounter}{\oarg{options}\marg{counter}\marg{delta value}}\tcbdocmarginnote{\tcbdocnew{\versionzerofourdate}} This macro subtracts the (positive) delta value from the counter and is the counterpart of \cs{addtocounter} @@ -1152,19 +1155,73 @@ This document synchronizes the driver counter value to the associated values. It \end{itemize} \end{dispExample} +\section{Coupled counters}\label{sec::coupledcounters}\tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} + +\begin{marker} +The features described here are very experimental and not fully implemented so far. +\end{marker} + +Occasionally there are requests where the figure or table environment should use the same counter in the sense of using continued counter values, e.g figure 1 is followed by table 2, the next figure is numbered as 3 etc. + +This can be achieved with the concept of coupled counters. As usual, those counters belonging to a 'group' should be declared first in the preamble. In some sense coupled counters are similar to associated counters. + +\begin{docCommand}{DeclareCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} +\begin{codeoptionsenum} + \item \oarg{options}: As of version \packageversion, this option is not used so far. + \item \marg{counter name 1, counter name2, \dots}: The list of counters that should should be stepped together. +\end{codeoptionsenum} + +This macro is a preamble-only command. + +\end{docCommand} + +\begin{marker} +\begin{itemize} +\item As of version \packageversion\ only one coupled counter list is possible. +\item There is no \cs{ClearCoupledCounterList} macro yet. +\end{itemize} +\end{marker} + +\begin{docCommand}{RemoveCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} + +This removes the listed counter names from the coupled counter list. + +The option is not used, the counter name list has the same meaning as in \refCom{DeclareCoupledCounters}. +\end{docCommand} + +\begin{docCommand}{AddCoupledCounters}{\oarg{options}\marg{counter name1, counter name2, \dots}}\tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} + +This adds the listed counter names to coupled counter list. Please use \refCom{RemoveCoupledCounters} first, then apply \cs{AddCoupledCounters} + +\end{docCommand} + + + \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. -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. +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. \begin{marker} \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} +\begin{docCommand}{RegisterTotalDocumentCounter}{\oarg{options}\marg{total counter name}}\tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} +\begin{codeoptionsenum} + \item \oarg{options}: As of version \packageversion, only this option is used + \begin{docKey}{supertotal}{=\meta{true,false}}{false} + Set this key to switch the super total counter on or off. + \end{docKey} + \item \marg{total counter name}: The name of the total counter. This must be the same like the name of an already existing counter. Internally another counter is defined which has a prefix to prevent name clashes with counter names defined by the package \CHDocPackage{totalcount}. If the counter name does not exist, the compilation exists with an error message. +\end{codeoptionsenum} + + +\end{docCommand} + @@ -1226,14 +1283,17 @@ This macro checks if a counter is under the administration of the total counter 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. \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} \item \oarg{options}: As of version \packageversion, only this option is used - \begin{docKey}{supertotal}{=\meta{true,false}}{false} - Set this key to switch the super total counter on or off. - \end{docKey} + + \refKey{supertotal} -- this has the same meaning as in \refCom{RegisterTotalDocumentCounter} and defaults to \texttt{false}. + \item \marg{total counter name}: The name of the total counter. This must not be the same like the name of any already existing counter. Internally another counter is defined which has a prefix to prevent name clashes with counter names defined by the package \CHDocPackage{totalcount}. \end{codeoptionsenum} +If an already existing counter should be tracked with total counter features, +use \refCom{RegisterTotalDocumentCounter} instead. \end{docCommand} @@ -1268,38 +1328,60 @@ 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}. -\section{Backup and restore of counter values}\tcbdocmarginnote{\tcbdocnew{2016-01-16}} +\section[Counter backup/restoration]{Backup and restore of counter values}\tcbdocmarginnote{\tcbdocnew{\versionzerofourdate}} 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{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. - -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}. +\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. \tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} + \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.\tcbdocmarginnote{\tcbdocnew{2016-01-24}} +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.\tcbdocmarginnote{\tcbdocnew{\versionzerofourdate}} \end{marker} - -Please note: If a name does not belong to a counter register the compilation aborts with an error message! +\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}} \tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} +This macro restores all stored counter values corresponding to the counter names. -\begin{docCommand}{RestoreCounterValues}{\oarg{options}} -This macro restores the stored counter values corresponding to the counter names. Afterwards the internal backup lists are cleared. - -As of version \packageversion\ the optional argument isn't reserved for later purposes. +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,...}} \tcbdocmarginnote{\tcbdocupdated{\versionzerofivedate}} +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} @@ -1319,7 +1401,7 @@ The backup list is cleared after the restoring has been finished. Before restoring: \thefigure\ and \thetable -\RestoreCounterValues +\RestoreAllCounterValues Restored the values: \thefigure\ and \thetable @@ -1329,8 +1411,30 @@ Restored the values: \thefigure\ and \thetable \end{dispExample} +\begin{docCommand}{AddBackupCounter}{\oarg{options}\marg{counter name1,counter name2,...}} \tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} +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,...}} \tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} +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. -\subsection*{Some notes on the backup features} +\end{docCommand} + + +\begin{docCommand}{RemoveBackupCounters*}{\oarg{options}\marg{counter name}} \tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} + +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. @@ -1393,10 +1497,16 @@ write this documentation. \begin{itemize} \item +Version 0.5 +\begin{itemize}[label={$\checkmark$}] +\item Added support (very experimental!) for coupled counters, see \cref{sec::coupledcounters} about this feature! \tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} +\item Added \cs{RegisterTotalDocumentCounter} and improved \cs{TotalValue} support\tcbdocmarginnote{\tcbdocnew{\versionzerofivedate}} +\end{itemize} +\item Version 0.4 \begin{itemize}[label={$\checkmark$}] -\item Added \cs{BackupCounterValues} and \cs{RestoreCounterValues} support\tcbdocmarginnote{\tcbdocnew{2016-01-16}} -\item Added \cs{StepDownCounter} and \cs{SubtractFromCounter} macros\tcbdocmarginnote{\tcbdocnew{2016-01-11}} +\item Added \cs{BackupCounterValues} and \cs{RestoreCounterValues} support\tcbdocmarginnote{\tcbdocnew{\versionzerofourdate}} +\item Added \cs{StepDownCounter} and \cs{SubtractFromCounter} macros\tcbdocmarginnote{\tcbdocnew{\versionzerofourdate}} \end{itemize} \item Version 0.3 diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf Binary files differindex 79f867e5b2d..c11869a25a2 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex index d8faac0e3ec..477a52be0a6 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 0.4 (2016/01/26 -- 10/46/26) +%% LaTeX package xassoccnt - version 0.5 (2016/02/27 -- 19/52/22) %% Driver file for xassoccnt.sty %% %% @@ -199,7 +199,7 @@ Internal name: \TotalCounterInternalName{equations} E=mc^2 \end{equation} -\RestoreCounterValues +\RestoreAllCounterValues \chapter{Another new chapter} diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf Binary files differindex 4b00bccb27e..e82d7fe59fe 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex index 86453af56cf..549531744d3 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 0.4 (2016/01/26 -- 10/46/26) +%% LaTeX package xassoccnt - version 0.5 (2016/02/27 -- 19/52/22) %% Example file for xassoccnt.sty %% %% diff --git a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty index 7a475a6745c..1e0137d168e 100644 --- a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty +++ b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 0.4 (2016/01/26 -- 10/46/26) +%% LaTeX package xassoccnt - version 0.5 (2016/02/27 -- 19/52/22) %% Source file for xassoccnt.sty %% %% @@ -19,20 +19,15 @@ %% %% -\def\xassoccntpackageversion{0.4} +\def\xassoccntpackageversion{0.5} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{xassoccnt}[2016/01/26 - v\xassoccntpackageversion] +\ProvidesPackage{xassoccnt}[2016/02/27 - v\xassoccntpackageversion] \RequirePackage{xcolor} \RequirePackage{xparse} \RequirePackage{l3keys2e} - - - - - \ExplSyntaxOn % First some local or global values @@ -70,7 +65,12 @@ \int_new:N \l__xassoccnt_backuptmpa_int \seq_new:N \l__xassoccnt_counternamesbackup_seq \seq_new:N \l__xassoccnt_countervaluesbackup_seq -\bool_new:N \l__xassoccnt_counternamestarred_bool +\seq_new:N \l__xassoccnt_backupresetlist_seq +\bool_new:N \l__xassoccnt_counternamestarred_bool % Not needed actually + +\seq_new:N \g__xassoccnt_counternamesbackuplist_seq + + \cs_new:Nn \__xassoccnt_toggle_bool:n {% @@ -191,6 +191,12 @@ } +\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\\ } @@ -201,8 +207,11 @@ } +\msg_new:nnn{xassoccnt}{containeralreadyexists}{% + Error:~Container~named~#1~already~exists\\ +} + -%\cs_new:Nn \__xassoccnt_stpelt:n{\global\csname c@#1\endcsname\c_minus_one\xassoccnt_addtocounter{#1}{\c_one}}% \cs_new:Nn \__xassoccnt_intinc:n {\int_gincr:N \l_xassoccnt_resetlist_counter}% @@ -610,7 +619,7 @@ \seq_clear:N \l_tmpa_seq \seq_map_inline:cn {\__xassoccnt_mastercontainer:}{% \seq_if_in:cnT{\__xassoccnt_drivercontainer:n{##1}}{#2}{% - \seq_put_right:Nn \l_tmpa_seq{##1} + \seq_put_right:Nn \l_tmpa_seq {##1} }% }% \seq_if_empty:NTF \l_tmpa_seq{--}{\seq_use:Nn \l_tmpa_seq {#1}} @@ -744,40 +753,357 @@ \cs_new_nopar:Nn \__xassoccnt_translate_countername:cn {% \tl_set:cn {#1}{#2}% - \seq_if_in:NxT \g__xassoccnt_supertotalcounter_container {#2} {% + \seq_if_in:NxTF \g__xassoccnt_supertotalcounter_container {#2} {% \tl_set:cn {#1}{\__xassoccnt_expand_totalcountername:n {#2} }% + }{% + } +} + + +%%% + + +%% More generic macros (hidding the internal features of the lists) + + +\cs_new:Nn \xassoccnt_container_datatype: {seq} + + +\cs_new:Nn \__xassoccnt_construct_cs:n {% + \use:c{\xassoccnt_container_datatype:#1} +} + + + + +\cs_new:Nn \xassoccnt_container_new:N {% + \__xassoccnt_construct_cs:n{_new:N} #1 +} + + +\cs_new:Nn \xassoccnt_container_clear:N {% + \__xassoccnt_construct_cs:n{_clear:N} #1 +} + +\cs_new:Nn \xassoccnt_container_gclear:N {% + \__xassoccnt_construct_cs:n{_gclear:N} #1 +} + + + +\cs_new:Nn \xassoccnt_container_set_eq:NN {% + \__xassoccnt_construct_cs:n{_set_eq:NN} #1 #2 +} + + +\cs_new:Nn \xassoccnt_container_gset_eq:NN {% + \__xassoccnt_construct_cs:n{_gset_eq:NN} #1 #2 +} + + +\cs_new:Nn \xassoccnt_container_put_right:Nn {% + \__xassoccnt_construct_cs:n{_put_right:Nn} #1 {#2} +} + +\cs_new:Nn \xassoccnt_container_gput_right:Nn {% + \__xassoccnt_construct_cs:n{_gput_right:Nn} #1 {#2} +} + +\cs_new:Nn \xassoccnt_container_put_left:Nn {% + \__xassoccnt_construct_cs:n{_put_left:Nn} #1 {#2} +} + +\cs_new:Nn \xassoccnt_container_gput_left:Nn {% + \__xassoccnt_construct_cs:n{_gput_left:Nn} #1 {#2} +} + + +\cs_new:Nn \xassoccnt_container_get_item:Nn {% + \__xassoccnt_construct_cs:n{_get_item:Nn} #1 {#2} +} + +\cs_new:Nn \xassoccnt_container_remove_duplicates:N {% + \__xassoccnt_construct_cs:n{_remove_duplicates:N} #1 +} + +\cs_new:Nn \xassoccnt_container_gremove_duplicates:N {% + \__xassoccnt_construct_cs:n{_gremove_duplicates:N} #1 +} + +\cs_new:Nn \xassoccnt_container_remove_all:Nn {% + \__xassoccnt_construct_cs:n{_remove_all:Nn} #1 {#2} +} + +\cs_new:Nn \xassoccnt_container_gremove_all:Nn {% + \__xassoccnt_construct_cs:n{_gremove_all:Nn} #1 {#2} +} + +\cs_new:Nn \xassoccnt_container_map_inline:Nn {% + \__xassoccnt_construct_cs:n{_map_inline:Nn} #1 {#2} +} + +\cs_new:Nn \xassoccnt_container_count:N {% + \__xassoccnt_construct_cs:n{_count:N} #1 +} + +\cs_new:Nn \xassoccnt_container_set_from_clist:NN {% + \__xassoccnt_construct_cs:n{_set_from_clist:NN} #1 #2 +} + +\cs_new:Nn \xassoccnt_container_gset_from_clist:NN {% + \__xassoccnt_construct_cs:n{_gset_from_clist:NN} #1 #2 +} + +\cs_new:Nn \xassoccnt_container_remove_by_clist:Nn {% + \clist_set:Nn \l_tmpa_tl {#2} + \clist_map_inline:Nn \l_tmpa_tl { + \xassoccnt_container_remove_all:Nn #1 {##1} + } +} + + +\cs_new:Nn \xassoccnt_container_use:Nn {% + \__xassoccnt_construct_cs:n{_use:Nn} #1 {#2} +} + + + +\prg_new_conditional:Nnn \xassoccnt_container_if_exist:N {TF,T,F}% +{ + \__xassoccnt_construct_cs:n{_if_exist:NTF} #1 + {\prg_return_true:} + {\prg_return_false:} +} + + +\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:} +} + +\prg_new_conditional:Nnn \xassoccnt_container_if_empty:N {TF,T,F}% +{ + \__xassoccnt_construct_cs:n{_if_empty:NTF} + {\prg_return_true:} + {\prg_return_false:} +} + + +\prg_new_conditional:Nnn \xassoccnt_container_if_empty:c {T,F,TF} +{ + \__xassoccnt_construct_cs:n{_if_empty:cTF} + {\prg_return_true:} + {\prg_return_false:} +} + + + + +\cs_generate_variant:Nn \xassoccnt_container_new:N {c} +\cs_generate_variant:Nn \xassoccnt_container_clear:N {c} +\cs_generate_variant:Nn \xassoccnt_container_gclear:N {c} +\cs_generate_variant:Nn \xassoccnt_container_set_eq:NN {cN,Nc,cc} +\cs_generate_variant:Nn \xassoccnt_container_gset_eq:NN {cN,Nc,cc} + +\cs_generate_variant:Nn \xassoccnt_container_put_right:Nn {NV,Nv,No,Nx,cn,cV,cv,co,cx} +\cs_generate_variant:Nn \xassoccnt_container_gput_right:Nn {NV,Nv,No,Nx,cn,cV,cv,co,cx} +\cs_generate_variant:Nn \xassoccnt_container_put_left:Nn {NV,Nv,No,Nx,cn,cV,cv,co,cx} +\cs_generate_variant:Nn \xassoccnt_container_gput_left:Nn {NV,Nv,No,Nx,cn,cV,cv,co,cx} + +\cs_generate_variant:Nn \xassoccnt_container_get_item:Nn {cn} + +\cs_generate_variant:Nn \xassoccnt_container_remove_duplicates:N {c} +\cs_generate_variant:Nn \xassoccnt_container_gremove_duplicates:N {c} + +\cs_generate_variant:Nn \xassoccnt_container_remove_all:Nn {cn} +\cs_generate_variant:Nn \xassoccnt_container_gremove_all:Nn {cn} + +\cs_generate_variant:Nn \xassoccnt_container_remove_by_clist:Nn {cn,nn} + +\cs_generate_variant:Nn \xassoccnt_container_map_inline:Nn {cn} + +\cs_generate_variant:Nn \xassoccnt_container_count:N {c} + +\cs_generate_variant:Nn \xassoccnt_container_set_from_clist:NN {cN,cc,Nc,Nn,cn} +\cs_generate_variant:Nn \xassoccnt_container_gset_from_clist:NN {cN,cc,Nc,Nn,cn} + +\cs_generate_variant:Nn \xassoccnt_container_use:Nn {cn} + + +\cs_generate_variant:Nn \xassoccnt_container_if_in:NnTF {NVTF,NvTF,NoTF,NxTF,cnTF,cVTF,cvTF,coTF,cxTF} +\cs_generate_variant:Nn \xassoccnt_container_if_in:NnT {NVT,NvT,NoT,NxT,cnT,cVT,cvT,coT,cxT} +\cs_generate_variant:Nn \xassoccnt_container_if_in:NnF {NVF,NvF,NoF,NxF,cnF,cVF,cvF,coF,cxF} + +\cs_generate_variant:Nn \xassoccnt_container_if_exist:NTF {cTF} +\cs_generate_variant:Nn \xassoccnt_container_if_exist:NT {cT} +\cs_generate_variant:Nn \xassoccnt_container_if_exist:NF {cF} + +\bool_new:N \l__xassoccnt_feature_bool +\bool_new:N \l__xassoccnt_sublists_bool + +\keys_define:nn {xassoccnt_container} { + feature .bool_set:N=\l__xassoccnt_feature_bool, + sublists .bool_set:N=\l__xassoccnt_sublists_bool +} + +\seq_new:N \g__xassoccnt_feature_seq % The master control !!!! + +\seq_new:N \g__xassoccnt_sublists_seq + +\cs_new:Nn \xassoccnt_create_featurename:n { xassoccnt_feature#1 } + +\cs_new:Nn \xassoccnt_featurename:n { xassoccnt_feature#1 } + + +%% A feature is actually a super container that has sub containers (i.e. a list/seq of counters that have this feature + +%% Multiple counters may occur in the per - feature - specific container list + +\cs_new:Nn \xassoccnt_add_feature:nn {% + \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} {% + \seq_gput_right:Nn \g__xassoccnt_feature_seq {#2}% + \xassoccnt_create_container:nc {feature=true} { \xassoccnt_featurename:n { #2 } } + \bool_if:NTF \l__xassoccnt_sublists_bool { \seq_gput_right:NV \g__xassoccnt_sublists_seq {\c_one }} { \seq_gput_right:NV \g__xassoccnt_sublists_seq {\c_zero }} + }% End of \seq_if_in + } +} + + + + +\prg_new_conditional:Nnn \xassoccnt_feature_if_in:n {TF,T,F} +{ + \seq_if_in:NnTF { \g__xassoccnt_feature_seq } {#1} + {\prg_return_true:} + {\prg_return_false:} +} + +\cs_generate_variant:Nn \xassoccnt_feature_if_in:nTF {c} +\cs_generate_variant:Nn \xassoccnt_feature_if_in:nT {c} +\cs_generate_variant:Nn \xassoccnt_feature_if_in:nF {c} + +\cs_new:Nn \xassoccnt_remove_feature:nn {% + % keys from #1 to be set + + \seq_if_exist:NTF \g__xassoccnt_feature_seq {% + \seq_remove_all:Nn \g__xassoccnt_feature_seq {#2} + \cs_undefine:c { \xassoccnt_featurename:n { #2 }} % Remove the sequence as a macro + }{ + % To be done! + } +} + +\cs_new:Nn \xassoccnt_add_container_to_feature:nn {% + \xassoccnt_feature_if_in:nTF { #1 } {% + \xassoccnt_add_to_containerlist:cn { \xassoccnt_featurename:n { feature#1 }} {#2 } + }{% + % To be done + } +} + + +\cs_new:Nn \xassoccnt_create_container:nN { + \keys_set:nn {xassoccnt_container} {#1} + \xassoccnt_container_if_exist:NTF #2 {% + % A existing container must not be redefined + \msg_error:nnn{xassoccnt}{containeralreadyexists}{#2}% Error! + }{ + \xassoccnt_container_new:N {#2} + } +} + + + +\cs_generate_variant:Nn \xassoccnt_create_container:nN {nc,nx} + +\cs_new:Nn \xassoccnt_add_to_containerlist:Nn {% + \clist_set:Nx \l_tmpa_clist {#2} + \xassoccnt_container_if_exist:NTF #1 {% + \clist_map_inline:Nn \l_tmpa_clist {% + \xassoccnt_container_put_right:Nn #1 {##1}% Append data + } + }{ + \xassoccnt_create_container:nN {feature=false} #1 + \xassoccnt_container_set_from_clist:NN #1 \l_tmpa_clist } } +\cs_generate_variant:Nn \xassoccnt_add_to_containerlist:Nn {cn,nn} + + + +\NewDocumentCommand{\AddFeature}{O{sublists=false}m}{% + \xassoccnt_add_feature:nn {#1} {#2} +} + +\NewDocumentCommand{\RemoveFeature}{O{}m}{% + \xassoccnt_remove_feature:nn {#1} {#2} +} + + + +\NewDocumentCommand{\NewContainer}{m}{% + \xassoccnt_create_container:nc {feature=false} {#1} +} + + +\NewDocumentCommand{\DeclareCoupledCounters}{O{}m}{% + \xassoccnt_add_to_containerlist:cn {\xassoccnt_featurename:n {coupledcounters} } {#2}% +} + +\NewDocumentCommand{\AddCoupledCounters}{O{}m}{% + \xassoccnt_add_to_containerlist:cn {\xassoccnt_featurename:n {coupledcounters} } {#2}% +} + +\NewDocumentCommand{\RemoveCoupledCounters}{O{}m}{% + \xassoccnt_container_remove_by_clist:cn { \xassoccnt_featurename:n {coupledcounters} } {#2} +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%% Redefinition of standard counter macros \RenewDocumentCommand{\stepcounter}{m}{% \__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}% \xassoccnt_is_suspendedcounter:nF{#1}{% - \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 {% - \csname c@##1\endcsname\c_minus_one + \xassoccnt_container_if_in:cxTF { \xassoccnt_featurename:n {coupledcounters} } {#1} {% + \xassoccnt_container_map_inline:cn {\xassoccnt_featurename:n {coupledcounters} } {% \xassoccnt_standardstepcounter{##1}% } - \__xassoccnt_step_associatedcounters:n {\l_tmpa_tl} % step the remaining associated counters - }% End of not empty reset list + } + {% + \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 {% + \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{\xassoccnt_addtocounter}{mmO{}}{% % Only add to a counter if this counter isn't on the suspended counters list! \xassoccnt_is_suspendedcounter:nF{#1}{% @@ -1030,26 +1356,48 @@ { #2 } } - \NewDocumentCommand{\NewTotalDocumentCounter}{O{}m}{% \keys_set:nn {xassoccnt} {supertotal=false,#1} - \DeclareDocumentCounter[sloppy=false]{#2}% - \cs_if_exist:cF { c\__xassoccnt_expand_totalcountername:n{#2} } + \__xassoccnt_ifis_latexcounter:nF {#2} {% Define the counter + \DeclareDocumentCounter[sloppy=false]{#2}% + }% + \__xassoccnt_registertotaldocumentcounter:nn{#1}{#2} +} + +\cs_new:Nn \__xassoccnt_registertotaldocumentcounter:nn {% + \keys_set:nn {xassoccnt} {supertotal=false,#1} + \__xassoccnt_ifis_latexcounter:nF {#2} {% Counter does not exist -- do not autodefine + \msg_error:nnn{xassoccnt}{nameisnocounter}{#2}% + }% + % If the counter already exists -> check for the internal totalcounter name + \cs_if_exist:cF { c@\__xassoccnt_expand_totalcountername:n{#2} } { \DeclareDocumentCounter[sloppy=false,initial={\c_minus_one}]{\__xassoccnt_expand_totalcountername:n{#2}} - } - \seq_gput_right:Nx \g__xassoccnt_totalcounter_container {\__xassoccnt_expand_totalcountername:n{#2}} - \bool_if:NT \l__xassoccnt_is_supertotalcounter_bool {% - \__xassoccnt_add_supertotalcounter:n {#2} - } - \AtEndDocument{% - \__xassoccnt_writetotalcounters:nn {#2}{#2} + \seq_gput_right:Nx \g__xassoccnt_totalcounter_container {\__xassoccnt_expand_totalcountername:n{#2}} + \bool_if:NT \l__xassoccnt_is_supertotalcounter_bool {% + \__xassoccnt_add_supertotalcounter:n {#2} + } + \AtEndDocument{% + \__xassoccnt_writetotalcounters:nn {#2}{#2} + }% }% } +\NewDocumentCommand{\RegisterTotalDocumentCounter}{O{}m}{% + \__xassoccnt_registertotaldocumentcounter:nn{#1}{#2}% +} + \NewDocumentCommand{\TotalValue}{m}{% - \__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1} + \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:Nn \l_tmpa_tl {#1}% + } + } \number\value{\l_tmpa_tl}% } @@ -1120,6 +1468,8 @@ %%% Counter backup list features +% Those macros all deal with the global reset list% + \cs_new:Nn \__xassoccnt_renew_theHmacros:n {% \bool_if:NT \l__xassoccnt_hyperrefpackage_loaded_bool {% @@ -1137,42 +1487,59 @@ }% } -\cs_new:Nn \__xassoccnt_removestar:n {% - \tl_set:Nn \l_tmpa_tl {#1} - \tl_reverse:n \l_tmpa_tl - \tl_set_eq:NN \l_tmpb_tl \l_tmpa_tl - \tl_trim_spaces:N \l_tmpa_tl - \tl_if_in:NnT \l_tmpa_tl {*} {\tl_remove_once:Nn \l_tmpb_tl {*} } - \bool_set_true:N \l__xassoccnt_counternamestarred_bool% + +\cs_new:Nn \__xassoccnt_addcountertobackuplist_with_reset:nn {% + % Prevent multiple addition of a counter name + \seq_if_in:NnF #1 {#2} + { + \seq_gput_right:Nn \l__xassoccnt_backupresetlist_seq {\c_zero} + \seq_gput_right:Nn #1 { #2 } + } } -\seq_new:N \l__xassoccnt_backupresetlist_seq - +\cs_new:Nn \__xassoccnt_addcountertobackuplist_without_reset:nn {% + % Prevent multiple addition of a counter name + \seq_if_in:NnF #1 {#2} + { + \seq_gput_right:Nn \l__xassoccnt_backupresetlist_seq {\c_one} + \seq_gput_right:NV #1 {#2} + } +} -\NewDocumentCommand{\BackupCounterValues}{O{resetbackup=true}m}{% - \keys_set:nn{xassoccnt}{#1} - \int_incr:N \g__xassoccnt_backupcalls_int - \int_zero:N \l_tmpa_int - \clist_set:Nx \l_tmpa_clist {#2} - \seq_clear:N \l__xassoccnt_countervaluesbackup_seq - \seq_clear:N \l__xassoccnt_backupresetlist_seq + +\cs_new:Nn \__xassoccnt_removestar:n {% + \tl_clear:N \l_tmpa_tl + \clist_set:Nx \l_tmpa_clist {#1} \clist_map_inline:Nn \l_tmpa_clist {% \tl_clear:N \l_tmpa_tl% \tl_if_in:nnTF {##1} {*} { - \seq_gput_right:Nn \l__xassoccnt_backupresetlist_seq {\c_zero} \tl_set:Nn \l_tmpa_tl {##1} \tl_remove_all:Nn \l_tmpa_tl {*} - \seq_gput_right:NV \l__xassoccnt_counternamesbackup_seq { \l_tmpa_tl } - } - { - \seq_gput_right:Nn \l__xassoccnt_backupresetlist_seq {\c_one} - \seq_gput_right:Nn \l__xassoccnt_counternamesbackup_seq {##1} + \__xassoccnt_addcountertobackuplist_without_reset:nn { \l__xassoccnt_counternamesbackup_seq } {\l_tmpa_tl } + }{% + \__xassoccnt_addcountertobackuplist_with_reset:nn {\l__xassoccnt_counternamesbackup_seq} {##1} } + }% +} + +\cs_new:Nn \__xassoccnt_removestarsinglevalue:n {% + \tl_clear:N \l_tmpa_tl% + \tl_if_in:nnTF {#1} {*} + { + \tl_set:Nn \l_tmpa_tl {#1} + \tl_remove_all:Nn \l_tmpa_tl {*} + \__xassoccnt_addcountertobackuplist_without_reset:nn { \l__xassoccnt_counternamesbackup_seq } {\l_tmpa_tl } + }{% + \__xassoccnt_addcountertobackuplist_with_reset:nn {\l__xassoccnt_counternamesbackup_seq} {#1} } +} + + +\cs_new:Nn \__xassoccnt_backupcountervalues:nnn {% \seq_map_inline:Nn \l__xassoccnt_counternamesbackup_seq {% \int_incr:N \l_tmpa_int \__xassoccnt_ifis_latexcounter:nTF {##1} {% Check whether this is a counter at all! @@ -1190,24 +1557,125 @@ \msg_error:nnn{xassoccnt}{nameisnocounter}{##1}% }% }% +} - \seq_clear:N \l__xassoccnt_backupresetlist_seq% + +\cs_new:Nn \__xassoccnt_backupsinglecountervalue:n {% + \int_set:Nn \l_tmpa_int {\seq_count:N \l__xassoccnt_backupresetlist_seq}% + \__xassoccnt_ifis_latexcounter:nTF {#1} {% Check whether this is a counter at all! + % Store the old `\theH....` definition if preset + \__xassoccnt_renew_theHmacros:n { #1 } + \seq_gput_right:Nx \l__xassoccnt_countervaluesbackup_seq { \number\value{#1} } + % Check first if the counter name is starred -> no resetting then + \int_compare:nNnF { \seq_item:Nn \l__xassoccnt_backupresetlist_seq {\int_use:N \l_tmpa_int }} = { \c_zero } + {% + \bool_if:NT \l__xassoccnt_resetbackupcounters_bool {% + \setcounter{#1}{\c_zero}% + }% + }% + }{% + \msg_error:nnn{xassoccnt}{nameisnocounter}{#1}% + }% } - -\NewDocumentCommand{\RestoreCounterValues}{O{}}{% + + +\cs_new:Nn \__xassoccnt_restorecountervalues:n { \int_zero:N \l_tmpa_int % dummy 'counter' - \seq_map_inline:Nn \l__xassoccnt_counternamesbackup_seq {% + \seq_map_inline:cn {#1} {% \int_incr:N \l_tmpa_int % Increment the local 'counter' - \typeout{resetting(##1)~with~\seq_item:Nn \l__xassoccnt_countervaluesbackup_seq {\int_use:N \l_tmpa_int }} \setcounter{##1}{\seq_item:Nn \l__xassoccnt_countervaluesbackup_seq {\int_use:N \l_tmpa_int }} \__xassoccnt_restore_theHmacros:n {##1}% } +} + + +\NewDocumentCommand{\BackupCounterValues}{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 + \__xassoccnt_addbackupcounter:nnn {#1}{}{#2}% + \seq_clear:N \l__xassoccnt_backupresetlist_seq% +} + +\NewDocumentCommand{\RemoveBackupCounterInternal}{sO{}m}{% + \tl_set:Nn \l_tmpa_tl {#3} + \int_zero:N \l_tmpa_int% + \int_zero:N \l_tmpb_int% + \seq_clear:N \l_tmpa_seq% + \seq_if_in:NnT \l__xassoccnt_counternamesbackup_seq {#3} {% + \seq_map_inline:Nn \l__xassoccnt_counternamesbackup_seq + {% + \int_incr:N \l_tmpa_int + \tl_set:Nn \l_tmpb_tl {##1} + % Get the value of the current counter + \int_set:Nn \l_tmpb_int {\seq_item:Nn \l__xassoccnt_countervaluesbackup_seq {\l_tmpa_int }} + \tl_if_eq:NNTF \l_tmpa_tl \l_tmpb_tl + { % Restore the old \theH#3 definition + \__xassoccnt_restore_theHmacros:n {#3}% + \IfBooleanF{#1}{ \setcounter{#3}{\l_tmpb_int } } + }{ + \seq_put_right:NV \l_tmpa_seq { \l_tmpa_int } + }% End of \tl_if_eq:NNTF + }% End of \seq_map_inline + } % No F - Branch needed here (most likely ;-)) +} + + + + +\NewDocumentCommand{\RemoveBackupCounters}{sO{}m}{% + \clist_set:Nn \l_tmpa_clist {#3} + % Loop through the list + \clist_map_inline:Nn \l_tmpa_clist {% + \IfBooleanTF{#1}{% + \RemoveBackupCounterInternal*{##1}% + }{% + \RemoveBackupCounterInternal*{##1}% + } + } +} + +\NewDocumentCommand{\RestoreAllCounterValues}{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 } - +% \Restore is \Remove with restoring (of course) +\NewDocumentCommand{\RestoreCounterValues}{O{}m}{% + \clist_set:Nn \l_tmpa_clist {#2} + \clist_map_inline:Nn \l_tmpa_clist {% + \RemoveBackupCounterInternal{##1}% + } +} + + +\cs_new:Nn \__xassoccnt_addbackupcounter:nnn {% + % Remove first the stars from the counter names that should not be reset! + \__xassoccnt_removestar:n {#3} + % Now backup the counter values + \__xassoccnt_backupcountervalues:nnn {#3}{}{} +} + + +\NewDocumentCommand{\AddBackupCounter}{O{}m}{% + \clist_set:Nx \l_tmpa_clist {#2} + \clist_map_inline:Nn \l_tmpa_clist {% + \__xassoccnt_removestarsinglevalue:n{##1}% + \__xassoccnt_backupsinglecountervalue:n{##1}% + } +} + + + +%%%%%%%%%%%%%%%%%%%% + + + +%%%%%%%%%%%%%%%%%%%% \ExplSyntaxOff @@ -1233,8 +1701,11 @@ } \@onlypreamble{\NewTotalDocumentCounter} +\@onlypreamble{\RegisterTotalDocumentCounter} \@onlypreamble{\DeclareAssociatedCounters} \@onlypreamble{\DeclareDocumentCounter} +\@onlypreamble{\DeclareCoupledCounters} + \NewTotalDocumentCounter[supertotal=true]{numberofruns} @@ -1247,4 +1718,9 @@ \newcommand{\TotalCounterInfoColor}{violet} +\AddFeature{coupledcounters} % New style, not fully implemented so far + + +% Some more to be done + \endinput
\ No newline at end of file |