summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-11-07 23:20:16 +0000
committerKarl Berry <karl@freefriends.org>2015-11-07 23:20:16 +0000
commit62343452c8e0aff0f46aa81463462fa3fa98f579 (patch)
treeffe7f69205ac58ca166847e9719c0147df350013
parent7997142fbde257d4323fb42fbd6704735854bd8c (diff)
xassoccnt (7nov15)
git-svn-id: svn://tug.org/texlive/trunk@38795 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/README54
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdfbin0 -> 220014 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex1068
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdfbin0 -> 63062 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex139
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdfbin0 -> 68837 bytes
-rw-r--r--Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex158
-rw-r--r--Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty835
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rw-r--r--Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/xassoccnt.tlpsrc0
11 files changed, 2256 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/README b/Master/texmf-dist/doc/latex/xassoccnt/README
new file mode 100644
index 00000000000..7d638ee2d5b
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/README
@@ -0,0 +1,54 @@
+%% LaTeX package xassoccnt - version 0.1 (2015/11/07)
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2015 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% ------------------------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% This work consists of all files listed in README
+%%
+
+
+The package xassoccnt provides a way of associating counters to an
+existing driver counter, such incrementing the driver counter will increase
+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 2015/11/07 xassoccnt does not supersedes the package assoccnt by the same author, however,
+the older package isn't declared obsolete as of 2015/11/07.
+
+
+This first version provides a complete rewrite using `expl3` features
+
+-- better handling of options (compared to assoccnt) and more macros
+-- prevention of cross-association of driver and (already) associated counters
+-- disabled self-association of a counter
+-- better checking if the macro arguments are counters
+-- an autodefinition of counters if needed
+-- improved suspension and resuming of counters
+-- syncing of driver counters and associated counters after some special change
+-- Improved documentation (compared to assoccnt)
+
+Some notes:
+
+-- calc and xassoccnt work together only if calc is loaded before `xassoccnt`
+-- The `\PrettyCounterInfo` macros etc. has been removed.
+
+
+Directory listing:
+
+ xassoccnt_driver.pdf 63062 11/07/15 02:16:55
+ xassoccnt_driver.tex 3352 11/07/15 02:16:22
+ xassoccnt_example.pdf 68837 11/07/15 02:16:51
+ xassoccnt_example.tex 4390 11/07/15 02:16:22
+ xassoccnt.sty 25921 11/07/15 02:16:56
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf
new file mode 100644
index 00000000000..53681d349e4
--- /dev/null
+++ 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
new file mode 100644
index 00000000000..955eb7aed63
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex
@@ -0,0 +1,1068 @@
+%% LaTeX package assoccnt - version 0.1 (2015/11/07)
+%% Documentation for assoccnt.sty
+%%
+%%
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2015 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% -------------------------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `author-maintained'.
+%%
+%% This work consists of all files listed in README
+%%
+
+
+\documentclass[12pt,paper=a4]{article}
+
+
+\usepackage[lmargin=2cm,rmargin=2cm,headheight=15pt]{geometry}
+\usepackage{savesym}%
+\usepackage{bbding}%
+\savesymbol{Cross}%
+
+\usepackage{blindtext}%
+\usepackage[x11names]{xcolor}%
+\usepackage{imakeidx}%
+
+\usepackage[all]{tcolorbox}
+
+% 'Stolen' from tcolorbox documentation ;-)
+\newtcolorbox{marker}[1][]{enhanced,
+ before skip=2mm,after skip=3mm,
+ boxrule=0.4pt,left=5mm,right=2mm,top=1mm,bottom=1mm,
+ colback=yellow!50,
+ colframe=yellow!20!black,
+ sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
+ underlay={%
+ \path[fill=tcbcol@back!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
+ \path[draw=tcbcol@frame,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
+ \path[fill=yellow!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west);
+ },
+ drop fuzzy shadow,#1}
+
+
+
+\usepackage[tikz]{bclogo}
+\usepackage{marginnote}
+\usepackage{fancyhdr}
+\usepackage{datetime}%
+
+
+\usepackage{array}%
+
+
+
+\usepackage{amsmath}%
+\usepackage{amsthm}%
+
+\usepackage{calc} % Only for testing
+\usepackage{totcount}%
+\usepackage{enumitem}%
+\usepackage{microtype}
+\usepackage[scaled=0.92]{helvet}
+\usepackage[autodefinecounters=true]{xassoccnt}%
+
+\hypersetup{breaklinks=true,
+ pdftitle={xassoccnt_doc.pdf},
+ pdfauthor={Dr. Christian Hupfer},
+ pdfsubject={Documentation of xassoccnt package},
+ pdfkeywords={LaTeX, counters}
+}
+\usepackage{bookmark}%
+\usepackage{cleveref}
+
+
+\newlist{codeoptionsenum}{enumerate}{1}
+\setlist[codeoptionsenum,1]{label={\textcolor{blue}{\#\arabic*}}}
+
+\renewcommand{\rmdefault}{\sfdefault}
+
+\newcommand{\packagename}[1]{\textcolor{blue}{\textbf{\Envelope~#1}}\index{Package!#1}}%
+\newcommand{\mymailtoaddress}{%
+ christian.hupfer@yahoo.de
+}
+
+
+\newcommand{\MarkupPackageName}[2][lightgray]{%
+\colorbox{#1}{\textcolor{black}{#2}}%
+}%
+
+\newcommand{\MarkupCounterName}[2][yellow]{%
+\colorbox{#1}{\textcolor{black}{\texttt{#2}}}%
+}%
+
+
+\let\DeclareAssociatedCountersOrig\DeclareAssociatedCounters
+
+
+\newtcolorbox{docCommandArgs}[1]{colbacktitle={blue},coltitle={white},title={Description of arguments of command \cs{#1}}}
+
+
+\def\packageversion{\xassoccntpackageversion}%
+
+
+\makeindex[intoc]
+
+\newcommand{\PackageDocName}{xassoccnt}%
+
+
+\newtotcounter{totalpages}%
+\newtotcounter{anothertotalpages}%
+
+\newtotcounter{totalproofs}%
+\newtotcounter{totalsections}%
+\newtotcounter{totalequations}
+
+\newtotcounter{totalsubsections}%
+\newtotcounter{othertotalsubsections}%
+
+
+%%%% Declare all the counters here --
+\DeclareAssociatedCounters{subsection}{totalsubsections}%
+\DeclareAssociatedCounters{equation}{totalequations}%
+\DeclareAssociatedCounters{section}{totalsections}%
+\DeclareAssociatedCounters{proof}{totalproofs}
+\DeclareAssociatedCounters{page}{totalpages,anothertotalpages}%
+
+
+
+\begin{document}
+\mmddyyyydate
+
+
+\setlength{\parindent}{0pt}
+
+\thispagestyle{empty}%
+
+\begin{center}
+\begin{tcolorbox}[enhanced jigsaw,drop lifted shadow,colback=yellow!30!white,width=0.8\textwidth]
+\large \bfseries%
+\begin{center}%
+\begin{tabular}{c}%
+\textsc{\PackageDocName} \tabularnewline
+\tabularnewline
+Associated counters stepping simultaneously \tabularnewline
+\tabularnewline
+Version \packageversion \tabularnewline
+\tabularnewline
+\today \tabularnewline
+\tabularnewline
+\addtocounter{footnote}{2}
+Author: Christian Hupfer\(^\mathrm{\fnsymbol{footnote}}\)
+\tabularnewline
+\end{tabular}
+\end{center}
+\end{tcolorbox}
+\makeatletter
+\renewcommand{\thefootnote}{\fnsymbol{footnote}}%
+\footnotetext{\mymailtoaddress}%
+\makeatother
+
+\end{center}
+
+\tableofcontents
+\clearpage
+
+
+
+
+\fancypagestyle{plain}{%
+\fancyfoot[L]{\begin{tabular}[t]{l}\PackageDocName\ \packageversion \tabularnewline \textcopyright\ Dr. Christian Hupfer\end{tabular}}%
+\fancyfoot[C]{\thepage}%
+\fancyfoot[R]{\today}%
+\renewcommand{\headrule}{{\color{blue}%
+\hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
+\renewcommand{\footrule}{{\color{blue}\vskip-\footruleskip\vskip-\footrulewidth
+\hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
+\renewcommand{\footrulewidth}{2pt}
+\renewcommand{\headrulewidth}{2pt}
+}
+
+\pagestyle{plain}
+
+
+\setcounter{footnote}{0}
+
+\section*{Preface}
+
+This package is the successor and a complete rewrite of \packagename{assoccnt}. Not all features of that package are implemented yet -- if some functionality of your document depends on \packagename{assoccnt}, continue using the older version and shift gradually to \packagename{xassoccnt} please.
+
+\begin{marker}
+Most times class and package authors will benefit of this package, but there might be usual documents that need the features of |xassoccnt|
+\end{marker}
+
+\section{Introduction}
+
+The aim of this package is to provide some additional support for example for a package like \packagename{totcount}.
+
+For example, the total number of pages in a document could be achieved by using
+
+\begin{dispExample}%
+\regtotcounter{page}
+...
+The number of pages in the document is \number\totvalue{page} page(s) -- but in fact it has \total{totalpages} pages.
+\end{dispExample}%
+
+This will work, as long there is no reset of the page counter, as it might happen in the case of \cs{setcounter} or \cs{pagenumbering} being applied in the document. The result is a false page counter total value.
+
+This package provides associate counters, i.e. counters that are increased simultaneously with a driver counter and are not influenced by a a resetting of the driver counter, as long as not being added to the reset list by definition of the counter or explicitly by \cs{@addtoreset}.
+
+This package defines some macros to handle associated counters. The only interception to the standard behaviour is within the redefined commands \cs{addtocounter} and \cs{stepcounter}. The usual commands still work, as there is code added to their definition. In a previous version \cs{refstepcounter} was redefined, but since these use \cs{addtocounter} effectively, it was decided to use the basic command.
+
+Internally, the associated counters are stored in one list per counter -- it is not recommended to operate on those lists directly.
+
+Please note, that this package does not provide means for simultaneous stepping of counters defined by plain \TeX{} \cs{newcount} command.\marginnote{\bcbombe}
+
+
+
+
+\section{Requirements and incompatibilities}%
+
+\subsection{Required packages}
+
+\begin{itemize}
+\item \packagename{xcolor}
+\item \packagename{xparse}
+\item \packagename{l3keys2e}
+\end{itemize}
+
+\subsection{Incompatibilities}
+
+
+\begin{itemize}
+\item This package does not work really well with the \packagename{calc} package if that one is loaded after \packagename{\PackageDocName}. Load \packagename{calc} \textbf{before} \packagename{\PackageDocName}! \marginnote{\bcbombe}
+%\item This package does not work together when the Package \packagename{xifthen} is included. As of version \packageversion~I could not figure out, where the strange behaviour comes in. It's most likely an incompatibility between \packagename{etoolbox} and \packagename{xifthen}
+%\marginnote{\bcbombe}
+\end{itemize}
+
+\subsection{Package options}
+
+As of version \packageversion\ \packagename{\PackageDocName} supports the option
+
+\begin{docKey}{autodefinecounters}{=\meta{true,false}}{initially false}
+ Setting this package option to \texttt{true}, all counters used with the special package macros will be autodefined, unless disabled locally. See the commands
+\begin{itemize}
+\item \refCom{DeclareAssociatedCounters}
+\item \refCom{AddAssociatedCounters}
+\end{itemize}
+\end{docKey}
+
+
+
+\section{Documentation of Macros}
+\tcbset{color command={blue}}
+
+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{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 case 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}: %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{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}
+%\end{docCommandArgs}
+
+
+\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}
+
+
+% 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 state:
+ \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!
+ \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}: 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}
+\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}{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.
+
+The optional argument is not used as of version \packageversion.
+
+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}
+
+
+\clearpage
+
+
+\subsection[Driver macros]{Driver counter commands} \label{subsection::drivercounterscmds}
+
+
+\begin{docCommand}{AddDriverCounter}{\oarg{options}\marg{driver counter name}}
+
+\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}
+
+ 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}{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.
+
+
+
+\begin{docCommandArgs}{IsAssociatedToCounter}%
+
+\begin{codeoptionsenum}
+ \item \marg{driver counter}
+
+ Holds the name of the driver counter to which \marg{associated counter} the could possibly be associated.
+\item \marg{associated counter}
+
+ 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}
+
+ This code is expanded if the counter is \textbf{not} associated to the driver, otherwise it is ignored.
+
+\end{codeoptionsenum}
+\end{docCommandArgs}
+
+
+\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 \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}{GetDriverCounter}{\marg{counter name}}%
+
+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}
+
+
+\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.
+
+\end{dispExample}%
+
+\end{docCommand}%
+
+
+\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{codeoptionsenum}
+\item \marg{counter name}%
+
+ Contains the name of the possibly associated counter
+
+\item \marg{True branch}
+
+ This code is expanded if the counter is associated to a driver, otherwise it is ignored
+
+\item \marg{True branch}
+
+ This code is expanded if the counter is \textbf{not} associated a driver, otherwise it is ignored
+
+\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}{IsDriverCounter}{\marg{driver counter name}\marg{True branch}\marg{False branch}}%
+
+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 \marg{driver counter name}%
+
+ 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}{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}
+
+
+\subsubsection[\cs{IfIsDocumentCounter}-Queries]{Commands checking whether a name refers to a counter}
+
+\packagename{\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 \packagename{xparse} - syntax:
+
+\begin{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}
+
+The optional argument is not used as of version \packageversion\ for none of those three commands.
+
+
+\subsection[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}.
+
+There are some macros that provide this information:
+
+\begin{docCommand}{countersresetlistcount}{\marg{counter name}}
+This macro determines the number of counters being in the reset list of the counter specified as mandatory argument.
+
+Please note: This command isn't expandable. The number is stored internally to another macro, which can be accessed with \refCom{getresetlistcount}, which returns a pure integer number.
+\end{docCommand}
+
+\begin{docCommand}{getresetlistcount}{}
+This macro returns the number of counters being in the reset list of the counter specified as mandatory argument. It needs a previous call of \refCom{countersresetlistcount} first!
+
+If the counter has no other counters in its reset list, the value of 0 is returned.
+\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.
+\end{docCommand}
+
+\begin{docCommand}{IfInResetListT}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{true branch}}
+This command sequence tests whether the counter \meta{reset counter} is in the reset list of \meta{resetting counter} and expands to the true branch.
+See the related commands \refCom{IfInResetListTF} and \refCom{IfInResetListF} as well.
+\end{docCommand}
+
+\begin{docCommand}{IfInResetListF}{\oarg{}\marg{resetting counter}\marg{reset counter}\marg{false branch}}
+This command sequence tests whether the counter \meta{reset counter} is not in the reset list of \meta{resetting counter} and expands to the false branch.
+See the related commands \refCom{IfInResetListTF} and \refCom{IfInResetListT} as well.
+\end{docCommand}
+
+\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{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{dispExample}
+ \newcounter{SomeCounter}
+
+ \addtocounter{SomeCounter}{10}
+
+ The last counter something added to was \LastAddedToCounter.
+\end{dispExample}%
+\end{docCommand}%
+
+\begin{marker}
+ Please note that |LastAddedToCounter| might fail!
+\end{marker}
+
+
+\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{dispExample}
+ \stepcounter{SomeCounter}
+
+ The last counter being stepped was \LastSteppedCounter.
+\end{dispExample}%
+
+\end{docCommand}%
+
+\begin{docCommand}{LastRefSteppedCounter}{}
+
+\begin{dispExample}
+ \begin{equation}
+ E = mc^2 \label{eq::einstein}
+ \end{equation}
+ % \stepcounter{SomeCounter}
+
+ The last counter being refstepped was \LastRefSteppedCounter.
+\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{dispExample}
+ \setcounter{SomeCounter}{21}%
+
+ The last counter being set was \LastSetCounter.
+\end{dispExample}%
+
+\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}%
+
+ 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.
+
+\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}
+ \setcounter{SomeCounter}{50}%
+
+ \edef\lastcounterset{\LastSetCounter}
+ \edef\lastcountervalue{\LastCounterValue}
+
+ \setcounter{equation}{81}%
+
+
+ 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}%
+
+\setcounter{equation}{1}
+
+
+
+
+\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}
+
+
+
+\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{docCommand}{SuspendCounters}{\oarg{options}\marg{counters list}}%
+\begin{docCommandArgs}{SuspendCounters}%
+
+\begin{codeoptionsenum}
+\item \oarg{options}%
+
+ Not used so far, reserved for later usages
+
+\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}}
+ This command revokes the suspension of the counters in the \marg{counters} list.
+\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 totalequations:
+
+\SuspendCounters{totalequations}
+\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{totalequations}
+
+\begin{equation}
+ E = h \nu
+\end{equation}
+
+There are \number\totvalue{totalequations}~equations in here!
+
+%\end{document}
+\end{dispExample}
+
+
+
+\section{Additions to standard commands}\label{section::additions_to_l2e}
+
+\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}
+
+\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}}
+
+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{codeoptionsenum}
+ \item \oarg{options}: %As of version \packageversion, this option is not used% the key value argument
+
+ \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}
+
+
+
+
+
+ \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}
+
+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}%
+
+
+\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{docCommandArgs}{CopyDocumentCounters}%
+
+
+\begin{codeoptionsenum}
+ \item \oarg{options}: As of version \packageversion, this option is not used% the key value argument
+
+ \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}}
+
+This macro swaps the values of the counters given in arguments 2 and 3
+
+\begin{docCommandArgs}{SwapDocumentCounters}%
+
+
+\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{counter 2}
+ Holds the name of the second counter.
+ \end{codeoptionsenum}
+\end{docCommandArgs}
+
+\end{docCommand}%
+
+
+\begin{docCommand}{SyncCounters}{\oarg{options}\marg{driver counter}}
+
+This document synchronizes the driver counter value to the associated values. It has the some options as \refCom{SetDocumentCounter}. If the given counter is no driver counter, nothing is done.
+
+\begin{docCommandArgs}{SyncCounters}%
+
+
+\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}%
+
+
+
+\clearpage
+\section{To - Do list}
+
+\begin{itemize}
+\item Better counter definition/copy counter routines \(\longrightarrow\) another package perhaps
+\item Check the existence of driver and associated counters
+\item More examples
+\item Provide a better internal list organization
+\item Some macro names might be non-intuitive
+\item Improve documentation
+%\item Allow for specific counter to be resumed from suspension instead of resuming all
+%\item Allow for an associated counter to have multiple masters
+%\item Complete redesign and rewrite with \packagename{expl3} -- this will provide better list features
+\end{itemize}
+
+If you
+
+\begin{itemize}
+ \item find bugs
+ \item errors in the documentation
+ \item have suggestions
+ \item have feature requests
+\end{itemize}
+
+don't hesitate and contact me using my mail address: \mymailtoaddress.
+
+\clearpage
+
+\section{Acknowledgments}
+
+I would like to express my gratitudes to the developpers of fine \LaTeX{} packages and of course
+to the users at tex.stackexchange.com, especially to
+
+\begin{itemize}
+ \item Paulo Roberto Massa Cereda
+ \item Enrico Gregorio
+ \item Joseph Wright
+ \item David Carlisle
+ \item Werner
+ \item Gonzalo Medina
+ \item Cosmo Huber (for providing the bug report with the \packagename{calc} package.)
+\end{itemize}
+
+for their invaluable help on many questions on macros.
+
+\vspace{2\baselineskip}
+\begin{marker}
+A special gratitude goes to Prof. Dr. Dr. Thomas Sturm for providing the wonderful \packagename{tcolorbox} package which was used to
+write this documentation.
+\end{marker}
+
+\clearpage
+
+\section{Version history}
+
+Version: 0.1
+
+ A major bug fixed due to some error in usage together with \packagename{calc} when the driven counters are not stepped any longer.
+ The culprit was in \packagename{assoccnt} that the counter reset list was not really disabled.
+
+ Thanks to this question \url{http://tex.stackexchange.com/questions/269731/calc-breaks-assoccnt} this bug was detected.
+
+ This however lead to some internal inconsistencies and it was decided to rewrite \packagename{assoccnt} with \packagename{expl3} and the features of the new \LaTeX\ 3 - Syntax.
+
+
+\clearpage
+\phantomsection
+\appendix\label{examplesappendix}
+
+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}
+This document has \total{totalsections} section(s)%
+\end{dispExample}
+
+
+
+\section[Subsection with suspension]{Example: Total number of subsections with suspension}
+
+In this example, the subsections of this document are counted but later on, the associatedcounter is removed from the list, so it is frozen.
+
+
+\begin{dispExample}
+
+\subsection{First dummy subsection}
+SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
+\subsection{Second dummy subsection}
+SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
+
+\RemoveAssociatedCounter{subsection}{totalsubsections}%
+\subsection{Third dummy subsection after removing the associated counter}
+
+SubSection counter: \thesubsection~-- \number\totvalue{totalsubsections}
+
+\end{dispExample}
+
+
+
+\subsection{Suspension of a non-associated counter}
+This example will show the suspension of a non-associated counter
+
+
+\begin{dispExample}
+\setcounter{equation}{0}%
+\SuspendCounters{equation}%
+\begin{equation}
+E_{0} = mc^2
+\end{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}
+
+
+There are \number\value{equation}~equations in here!
+\end{dispExample}
+
+
+\clearpage
+\markboth{\indexname}{\indexname}
+%%%% Index of commands etc.
+\printindex
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.pdf
new file mode 100644
index 00000000000..ca264e0755f
--- /dev/null
+++ 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
new file mode 100644
index 00000000000..3a5b64b14dc
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver.tex
@@ -0,0 +1,139 @@
+%% LaTeX package xassoccnt driver file - version 0.1 (2015/11/07)
+%%
+%%
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2015 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% -------------------------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `author-maintained'.
+%%
+%% This work consists of all files listed in README
+%%
+
+
+\documentclass{book}
+
+\usepackage{xcolor}
+
+\usepackage{calc}
+\usepackage[autodefinecounters=true]{xassoccnt}
+
+\usepackage{totcount}
+\usepackage{hyperref}
+\usepackage{cleveref}
+
+
+\newcounter{totalpages}
+\newtotcounter{totalsections}
+\newcounter{othersections}
+
+
+
+\DeclareAssociatedCounters[autodefine=none]{section}{totalsections,othersections}
+\AddAssociatedCounters[autodefine=associated]{section}{totalsections}
+
+
+\DeclareAssociatedCounters{page}{totalpages}
+\DeclareAssociatedCounters[autodefine=associated,sloppy=false]{table}{totaltables}
+
+
+
+\begin{document}
+
+
+\chapter{First}
+
+In \cref{section::dummylabel} we will see that
+
+\section{First}
+
+\begin{table}
+\caption{table}
+\end{table}
+
+
+
+\section{Other}
+\section{Third}
+
+\begin{table}
+\caption{Other table}
+\end{table}
+
+\begin{equation}
+ E=mc^2
+\end{equation}
+
+\begin{equation}
+ E=mc^2
+\end{equation}
+
+
+\chapter{Second chapter}
+
+\section{First section of 2nd chapter} \label{section::dummylabel}
+
+\thesection\ \total{totalsections}\ \theothersections\ \thetotaltables\
+
+
+\IsSuspendedCounter{totalsections}{Yes, it's suspended}{Nope, it's not suspended}
+
+\IsAssociatedCounter{totalsections}{Yes, it's associated}{Nope, it's not associated}
+
+\IsSuspendedCounter{equation}{Yes, it's suspended}{Nope, it's not suspended}
+
+\IsAssociatedCounter{equation}{Yes, it's associated}{Nope, it's not associated}
+
+
+\SetDocumentCounter[associatedtoo=true,onlycounters={totalsections,gandalf},associatedtoo=true]{section}{17}
+
+\SetDocumentCounter{section}{28}
+
+\SetDocumentCounter{totalsections}{100}
+
+\NewDocumentCounter[initial=151]{counterother}[section]
+
+
+
+Value of counterother: \thecounterother
+
+\section{Another one}
+
+Value of counterother: \thecounterother
+
+
+
+
+
+\thesection\ \thetotalsections\ \theothersections\ \thetotaltables\
+
+\SyncCounters[onlycounters={totalsections}]{section}
+
+
+\IfIsDocumentCounterTF{section}{%
+ Yes, it's a counter
+}{%
+ No, it's no counter
+}
+
+
+\countersresetlistcount{chapter}
+\SetDocumentCounter{counterother}{\getresetlistcount}
+
+\begin{itemize}
+ \item There are \getresetlistcount\ counters in the reset list of chapter
+ \item \IfInResetListTF{chapter}{figure}{Yes, figure is in the reset list of chapter}{No, figure is not in the reset list of chapter}
+ \item \IfInResetListTF{chapter}{page}{Yes, page is in the reset list of chapter}{No, page is not in the reset list of chapter}
+ \item Values: \thesection\ \thetotalsections\ \theothersections\ \thetotaltables\ \thecounterother.
+\end{itemize}
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf
new file mode 100644
index 00000000000..75a1fa5699d
--- /dev/null
+++ 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
new file mode 100644
index 00000000000..c655098204b
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex
@@ -0,0 +1,158 @@
+%% Example file for xassoccnt.sty (2015/11/07)
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2015 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% -------------------------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status `author-maintained'.
+%%
+%% This work consists of all files listed in README
+%%
+
+
+\documentclass[a4paper,12pt]{book}%
+
+
+% Some packages only for output and dummy pages
+\usepackage{blindtext}%
+\usepackage{forloop}%
+\usepackage[svgnames]{xcolor}%
+\usepackage{tcolorbox}
+
+\usepackage{totcount}%
+\usepackage{xassoccnt}%
+
+
+
+
+
+
+\newcounter{loopcounter}%
+
+\newcommand{\QuickSections}[2]{%
+\forloop{loopcounter}{1}{\value{loopcounter} < \numexpr #1+1}{%
+\csuse{#2}{Dummy #2 -- \theloopcounter}
+}%
+}%
+
+\newcommand{\ShowNiceCounterOutput}[6]{%
+\begin{center}%
+\begin{tabular}{lllll}%
+& & & & \tabularnewline
+& \multicolumn{4}{c}{totcount page values} \tabularnewline
+Page & \textcolor{red}{#1} & \textcolor{blue}{#2} & \textcolor{gray}{#3} & \textcolor{violet}{#4}\tabularnewline
+\thepage & \textcolor{red}{\number\totvalue{#1}} & \textcolor{blue}{\number\value{#2}} & \textcolor{gray}{\number\value{#3}} & \textcolor{violet}{\number\totvalue{#4}} \tabularnewline
+Section & \textcolor{red}{#5} & Subsection & \textcolor{blue}{#6} & \tabularnewline%
+\thesection & \textcolor{red}{\number\totvalue{#5}} & \thesubsection & \textcolor{blue}{\number\totvalue{#6}} & \tabularnewline
+& & & & \tabularnewline
+\end{tabular}
+\end{center}%
+}%
+
+
+\newcommand{\QuickOutput}[1]{%
+%
+\forloop{loopcounter}{1}{\value{loopcounter} < \numexpr #1+1}{%
+\pagenumbering{arabic}% -> pagenumber reset to zero , on purpose inside the loop
+\ShowNiceCounterOutput{page}{associatedpages}{anotherpagescounter}{yetanotherpagescounter}{associatedsections}{associatedsubsections}%
+\blindtext%
+\newpage% some pages
+}%
+}%
+
+
+
+\newcounter{associatedpages}%
+\newcounter{anotherpagescounter}%
+
+\regtotcounter{page} % Register a total value counter --> this will be the driver counter
+\newtotcounter{yetanotherpagescounter}% 3rd driven counter
+\newtotcounter{associatedsections}%
+
+\newtotcounter{associatedsubsections}%
+
+
+\DeclareAssociatedCounters{page}{associatedpages,anotherpagescounter,associatedpages,yetanotherpagescounter}% Register the driver and the driven counters
+\DeclareAssociatedCounters{section}{associatedsections}%
+\DeclareAssociatedCounters{subsection}{associatedsubsections}%
+
+
+
+
+\begin{document}
+\tableofcontents%
+
+\chapter*{Introduction}
+
+This is a dummy document -- it just shows how some of the commands work.
+In section \ref{section::query} same queries and statistics are shown.
+
+\chapter{Chapter one}
+
+\section{First}
+\QuickSections{10}{subsection}%
+
+
+\QuickOutput{10}
+% Suspend the associatedsubsections counters%
+\typeout{Hello!}
+\SuspendCounters{associatedsubsections,associatedpages}%
+
+\QuickOutput{10}
+
+\clearpage
+
+\subsection[Suspended counters checking]{Checking for suspended counters}
+
+\IsSuspendedCounter{associatedsubsections}{Yes, Counter associatedsubsections is suspended}{No!}
+
+\IsSuspendedCounter{yetanothertotalpages}{Yes}{No!}
+
+\clearpage
+
+\section{Dummy section}%
+
+\QuickSections{10}{subsection}%
+
+% Resume all counters
+\ResumeSuspendedCounters
+\QuickSections{20}{subsection}%
+
+
+
+\clearpage
+
+\section{Query routines} \label{section::query}%
+\setlength{\parindent}{0pt}%
+
+\IsAssociatedCounter{totalsections}{Yes, it's associated}{Nope, it's not associated}
+
+\IsAssociatedCounter{anotherpagescounter}{Yes, it's associated}{Nope, it's not associated}
+
+
+\hrule\par
+
+Setting counter section explicitly to another value:
+
+\setcounter{section}{12}%
+
+\hrule\par
+
+Setting counter section explicitly to another value with option enabled:
+
+\SetDocumentCounter[onlycounters={associatedpages,anotherpagescounter,gandalf}]{page}{20}%
+
+
+\AddAssociatedCounters{page}{associatedpages}%
+\AddAssociatedCounters{page}{associatedpages}%
+
+\end{document}
+
diff --git a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
new file mode 100644
index 00000000000..af5d532a123
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
@@ -0,0 +1,835 @@
+\def\xassoccntpackageversion{0.1}
+\NeedsTeXFormat{LaTeX2e}
+
+\ProvidesPackage{xassoccnt}[2015/11/07 - v\xassoccntpackageversion]
+
+\RequirePackage{xcolor}
+\RequirePackage{xparse}
+\RequirePackage{l3keys2e}
+
+\ExplSyntaxOn
+
+% First some local or global values
+
+\int_new:N \l__xassoccnt_initialcountervalue_int
+\int_new:N \g__xassoccnt_lastcountervalue_int
+
+\bool_new:N \g__xassoccnt_autodefine_counters % --> global document option
+
+\clist_new:N \l__xassoccnt_exclude_clist % clist for
+\clist_new:N \l__xassoccnt_onlycounters_clist % clist for the \SetDocumentCounter command
+
+\bool_new:N \l__xassoccnt_autodefine_none
+\bool_new:N \l__xassoccnt_autodefine_drivercounter
+\bool_new:N \l__xassoccnt_autodefine_allcounters
+\bool_new:N \l__xassoccnt_autodefine_associatedcounter
+
+\bool_new:N \l__xassoccnt_countertype_general
+\bool_new:N \l__xassoccnt_countertype_driver
+\bool_new:N \l__xassoccnt_countertype_associated
+
+
+
+\cs_new:Nn \__xassoccnt_toggle_bool:n {%
+ \bool_if:nTF{#1}{\bool_set_false:n {#1}}{\bool_set_false:n {#1}}
+}
+
+\cs_generate_variant:Nn \__xassoccnt_toggle_bool:n { c }
+
+
+\cs_new:Nn \__xassoccnt_toggle_autodefine:n {%
+ \clist_set:Nn \l_tmpa_clist {#1}
+ \clist_map_inline:Nn \l_tmpa_clist {\__xassoccnt_toggle_bool:c {l__xassoccnt_autodefine_##1} }
+}
+
+\cs_new:Nn \__xassoccnt_set_false:n {%
+ \clist_set:Nn \l_tmpa_clist {#1}
+ \clist_map_inline:Nn \l_tmpa_clist {\bool_set_false:c {##1} }
+}
+
+\cs_new:Nn \__xassoccnt_set_true:n {%
+ \clist_set:Nn \l_tmpa_clist {#1}
+ \clist_map_inline:Nn \l_tmpa_clist {\bool_set_true:c {##1} }
+}
+
+
+
+\keys_define:nn {xassoccnt}
+{
+ initial .code:n={ \int_set:Nn \l__xassoccnt_initialcountervalue_int {#1}},
+ sloppy .bool_set:N=\l__xassoccnt_sloppy_newcounter,
+ autodefinecounters .bool_set:N=\g__xassoccnt_autodefine_counters,
+ % Choice keys
+ autodefine .choice:,
+ autodefine / all .code:n= {\bool_set_true:N \l__xassoccnt_autodefine_allcounters
+ \__xassoccnt_set_true:n {l__xassoccnt_autodefine_drivercounter,
+ l__xassoccnt_autodefine_associateddrivercounter }
+ \bool_set_false:N \l__xassoccnt_autodefine_none },
+ autodefine / driver .code:n= {\bool_set_true:N \l__xassoccnt_autodefine_drivercounter},
+ autodefine / associated .code:n= {\bool_set_true:N \l__xassoccnt_autodefine_associatedcounter
+ \__xassoccnt_set_false:n {l__xassoccnt_autodefine_allcounters,l__xassoccnt_autodefine_none}},
+ autodefine / none .code:n= {\bool_set_true:N \l__xassoccnt_autodefine_none
+ \__xassoccnt_set_false:n {l__xassoccnt_autodefine_allcounters,
+ l__xassoccnt_autodefine_associatedcounter,
+ l__xassoccnt_autodefine_drivercounter}},
+ autodefine .initial:n= {none}, % No autodefinition by default
+
+ associatedtoo .code:n={ \clist_clear:N \l__xassoccnt_onlycounters_clist},
+ associatedtoo .bool_set:N={\l__xassoccnt_setcounter_associated},
+ associatedtoo .initial:n={false},
+ onlycounters .code:n={\bool_set_false:N \l__xassoccnt_setcounter_associated
+ \clist_set:Nn \l__xassoccnt_onlycounters_clist {#1} },
+
+ exclude .clist_set:N=\l__xassoccnt_exclude_clist,
+
+%% For later purposes
+ countertype .choice:,
+ countertype / general .code:n= {\bool_set_true:N \l__xassoccnt_countertype_general },
+ countertype / driver .code:n= {\bool_set_true:N \l__xassoccnt_countertype_driver },
+ countertype / associated .code:n= {\bool_set_true:N \l__xassoccnt_countertype_associated },
+ countertype .initial:n={ general }
+}
+
+\ProcessKeysOptions{xassoccnt}
+
+
+\msg_new:nnn{xassoccnt}{counteralreadyexists}{%
+ Error:~Counter~#1~already~exists\\
+}
+
+
+\msg_new:nnn{xassoccnt}{crossassociation}{%
+ Error:~You~can't~cross-associate~two~counters\\
+ Here:~The~counters~#1~and~#2~should~not~be~associated~to~each~other~since~one~is~already~associated~to~the~other~one%
+}
+
+\msg_new:nnn{xassoccnt}{selfassociation}{%
+ Warning:~An~accidental(?)~self-association~of~counter~"#1"~was~detected\\
+ This~will~be~ignored!
+}
+
+
+\msg_new:nnn{xassoccnt}{addwithoutdeclaration}{%
+ Warning:~An~accidental(?)~addition~of~associated~counter(s)~without~DeclareAssociatedCounters~was~detected~for\\
+ the~driver~counter~"#1"~and~following~driven~counters:\\
+ ---~#2~---
+}
+
+\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}%
+
+\int_new:N \l_xassoccnt_resetlist_counter
+
+\cs_new:Nn \xassoccnt_countersinresetlist:n {%
+ \begingroup
+ \int_zero:N \l_xassoccnt_resetlist_counter
+ \cs_set_eq:NN \@elt \__xassoccnt_intinc:n
+% \def\@elt##1{\int_gincr:N \l_xassoccnt_resetlist_counter}% Increase the 'counter' globally
+ \use:c{ cl@#1 }
+ \endgroup
+}
+
+
+
+\cs_set_eq:NN \xassoccnt_standardstepcounter \stepcounter
+\cs_set_eq:NN \xassoccnt_standardrefstepcounter \refstepcounter
+\cs_set_eq:NN \xassoccnt_standardaddtocounter \addtocounter
+\cs_set_eq:NN \xassoccnt_standardsetcounter \setcounter
+
+\cs_new_nopar:Nn \__xassoccnt_laststeppedcounter: {}
+\cs_new_nopar:Nn \__xassoccnt_lastrefsteppedcounter: {}
+\cs_new_nopar:Nn \__xassoccnt_lastaddtocounter: {}
+\cs_new_nopar:Nn \__xassoccnt_lastsetcounter: {}
+\cs_new_nopar:Nn \__xassoccnt_lastsetdocumentcounter: {}
+
+
+\cs_new:Nn \xassoccnt_counter_container:n {%
+ \seq_new:c{\__xassoccnt_generate_countercontainername:n{#1}}%
+ \cs_new_nopar:cn {__xassoccnt_#1container:} {\__xassoccnt_generate_countercontainername:n{#1}}%
+}
+
+\cs_new:Nn \__xassoccnt_generate_countercontainername:n {%
+ g_xassoccnt_#1cnt_seq%
+}
+
+\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 {%
+ \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
+
+\cs_new:Nn \__xassoccnt_drivercontainer:n {g_xassoccnt_#1cnt_seq}
+
+\cs_new:Nn \__xassoccnt_containerremoveduplicates:N { \seq_gremove_duplicates:N #1 }
+
+\cs_generate_variant:Nn \__xassoccnt_containerremoveduplicates:N { c }
+
+\cs_new_nopar:Nn \__xassoccnt_container_removeduplicates:n { \seq_gremove_duplicates:c{\__xassoccnt_generate_countercontainername:n{#1}}}
+\cs_new_nopar:Nn \__xassoccnt_container_removecounter:nn { \seq_gremove_all:cn{\__xassoccnt_generate_countercontainername:n{#1}}{#2} }
+\cs_new_nopar:Nn \__xassoccnt_container_putright:nn { \seq_put_right:cn{\__xassoccnt_generate_countercontainername:n{#1}}{#2} }
+\cs_new_nopar:Nn \__xassoccnt_container_removeassociated:nn { \seq_gremove_all:cn{\__xassoccnt_drivercontainer:n{#1}}{#2}}
+\cs_new_nopar:Nn \__xassoccnt_container_gclear:n {\seq_gclear:N #1 }
+\cs_new_nopar:Nn \__xassoccnt_container_clear:n {\seq_clear:N #1 }
+
+
+
+\cs_new_nopar:Nn \__xassoccnt_container_perdriver_new:n {
+ \seq_if_exist:cF{ \__xassoccnt_drivercontainer:n {#1} }
+ { % Generate only if there is no driver container sequence so far!
+ \seq_new:c{\__xassoccnt_drivercontainer:n{#1} }
+ }
+}
+
+
+\cs_generate_variant:Nn \__xassoccnt_container_gclear:n { c }
+\cs_generate_variant:Nn \__xassoccnt_container_clear:n { c }
+
+\cs_new:Nn \__xassoccnt_container_set_from_clist:NN {\seq_set_from_clist:NN #1 #2}
+\cs_generate_variant:Nn \__xassoccnt_container_set_from_clist:NN { cN, cc, Nc }
+
+\cs_new:Nn \__xassoccnt_gcombine_container:NN {%
+ \seq_concat:NNN \l_tmpb_seq #1 #2
+ \seq_gset_eq:NN #1 \l_tmpb_seq
+}
+
+\cs_generate_variant:Nn \__xassoccnt_gcombine_container:NN { cc }
+
+\cs_new:Nn \__xassoccnt_gcombineunique_container:NN {%
+ \__xassoccnt_gcombine_container:NN #1 #2
+ \__xassoccnt_containerremoveduplicates:N #1
+}
+
+\cs_generate_variant:Nn \__xassoccnt_gcombineunique_container:NN { cc }
+
+\cs_new:Nn \__xassoccnt_adddrivercounter:nn{ %
+ \__xassoccnt_setupcontainers:n{#2}%
+}
+
+
+\cs_new:Nn \__xassoccnt_removedrivercounter:nn{%
+ \__xassoccnt_container_gclear:c{\__xassoccnt_drivercontainer:n{#2}} % Clear the per-counter container first
+ \__xassoccnt_container_removecounter:nn{\c_xassoccnt_mastername_str}{#2} % Remove the counter #2 from the master container
+ \cs_undefine:c{\__xassoccnt_drivercontainer:n{#2}}
+}
+
+\cs_new:Nn \__xassoccnt_autodefine_associatedcounters:nn {%
+ \bool_if:nTF{ \g__xassoccnt_autodefine_counters }{%
+ \seq_map_inline:Nn #2 { \__xassoccnt_newcounter_ltx:nnn {sloppy}{##1}{} }
+ }{%
+ \keys_set:nn{xassoccnt}{#1}
+ \bool_if:nF{ \l__xassoccnt_autodefine_none }{%
+ % No, some autodefine key has been specified
+ \bool_if:nTF { \l__xassoccnt_autodefine_allcounters }
+ {%
+ \seq_map_inline:Nn #2 { \__xassoccnt_newcounter_ltx:nnn {sloppy}{##1}{} } %loop through the list and do not complain if the counter ##1 already exists
+ }{%
+ \bool_if:nT { \l__xassoccnt_autodefine_associatedcounter }{%
+ \seq_map_inline:Nn #2 { \__xassoccnt_newcounter_ltx:nnn {sloppy}{##1}{}}
+ }
+ }
+ }
+ }
+}
+
+\cs_new:Nn \__xassoccnt_autodefine_drivercounter:nn {%
+ \keys_set:nn{ xassoccnt } {#1}
+ \bool_if:nTF{ \g__xassoccnt_autodefine_counters }{%
+ \__xassoccnt_newcounter_ltx:nnn{#1,sloppy}{#2}{}%
+ }{%
+ \bool_if:nT {\l__xassoccnt_autodefine_drivercounter || \l__xassoccnt_autodefine_allcounters } {%
+ \__xassoccnt_newcounter_ltx:nnn{#1}{#2}{}
+ }
+ }
+}
+
+
+
+
+\cs_new:Nn \__xassoccnt_addassociatedcounters:nnn {%
+ \keys_set:nn{xassoccnt}{#1}
+ \clist_set:Nx \l_tmpa_clist {#3}%
+ \clist_if_in:NnT \l_tmpa_clist{#2}{% Prevent self-association
+ \msg_warning:nnn{xassoccnt}{selfassociation}{#2}% Warning
+ \clist_gremove_all:Nn \l_tmpa_clist {#2}%
+ }%
+ \clist_remove_duplicates:N \l_tmpa_clist%
+ \__xassoccnt_container_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
+ \seq_if_in:cnF{\__xassoccnt_mastercontainer:}{#2}{%
+ \__xassoccnt_adddrivercounter:nn{#1}{#2}% Generate the driver counter container
+ \msg_warning:nnnn{xassoccnt}{addwithoutdeclaration}{#2}{#3} % Warning --> associated some counter without declaring in the preamble
+ }%
+ \__xassoccnt_gcombineunique_container:cc{\__xassoccnt_drivercontainer:n{#2}}{l_tmpa_seq}
+ \__xassoccnt_gcombineunique_container:cc{\__xassoccnt_generate_countercontainername:n{\c_xassoccnt_associatedname_str}}{l_tmpa_seq}
+ % Do only define if really needed
+ \__xassoccnt_autodefine_associatedcounters:nn {#1} {\l_tmpa_seq }
+}
+
+
+\cs_new:Nn \xassoccnt_removesuspendedcounters:nn{%
+ \seq_if_exist:cTF{\__xassoccnt_suspendedcontainer:}{%
+ \seq_if_in:cnT{\__xassoccnt_suspendedcontainer:}{#2}{%
+ \__xassoccnt_container_removecounters:nn{suspended}{#2}
+ }%
+ }%
+}
+
+
+\cs_new:Nn \__xassoccnt_setupcontainers:n{%
+ \__xassoccnt_container_putright:nn{master}{#1}
+ \__xassoccnt_container_removeduplicates:n{master}%
+ \__xassoccnt_container_perdriver_new:n{#1}%
+}
+
+
+\cs_new:Nn \__xassoccnt_newcounter_ltx:nn{%
+ \keys_set:nn {xassoccnt}{sloppy=false,initial=\c_zero,#1}
+ \cs_if_exist:cTF{c@#2}{%
+ \bool_if:nF {\l__xassoccnt_sloppy_newcounter }{
+ \msg_error:nnn{xassoccnt}{counteralreadyexists}{#2}% Warning
+ }
+ }{%
+ \newcounter{#2}%
+ \xassoccnt_standardsetcounter{#2}{\l__xassoccnt_initialcountervalue_int}
+ }%
+}
+
+\cs_new:Nn \__xassoccnt_newcounter_ltx:nnn{%
+ \keys_set:nn {xassoccnt}{sloppy=false,initial=\c_zero,#1}
+ \str_set:Nx \l_tmpa_str {#3}
+ \__xassoccnt_latexcounter_exists:nTF{#2}{%
+ \bool_if:nF {\l__xassoccnt_sloppy_newcounter }{
+ \msg_error:nnn{xassoccnt}{counteralreadyexists}{#2}% Warning
+ }
+ }{%
+ \str_if_empty:NTF \l_tmpa_str {%
+ \newcounter{#2}%
+ }{%
+ \newcounter{#2}[#3]%
+ }%
+ \xassoccnt_standardsetcounter{#2}{\l__xassoccnt_initialcountervalue_int}
+ }
+}
+
+
+
+
+\cs_new:Nn \xassoccnt_declareassociatedcounters:nnn {%
+ \__xassoccnt_container_if_in:cnTF{\__xassoccnt_generate_countercontainername:n{\c_xassoccnt_mastername_str}:}{#2}{%
+ % Not contained in the driver counter list
+ \__xassoccnt_addassociatedcounters:nnn{#1}{#2}{#3}%
+ }{%
+ % Check first if there is a potential cross association
+ \__xassoccnt_adddrivercounter:nn{#1}{#2}%
+ \xassoccnt_is_associatedtocounter:nnTF{#3}{#2}{%
+ \msg_fatal:nnnn{xassoccnt}{crossassociation}{#2}{#3}% Fatal message
+ % Not necessary unless the fatal message above is removed
+ \__xassoccnt_container_removecounter:cn{\__xassoccnt_generate_countercontainername:n{\c_xassoccnt_mastername_str}:}{#2}
+ }{% No, we don't try to cross-associate two counters
+ \__xassoccnt_addassociatedcounters:nnn{#1}{#2}{#3}%
+ }%
+ }%
+ \__xassoccnt_container_removeduplicates:n{\__xassoccnt_drivercontainer:n{#2}}
+ \__xassoccnt_autodefine_drivercounter:nn { }{#2}
+}
+
+
+
+
+
+\prg_new_conditional:Nnn \xassoccnt_is_drivercounter:n {T,F,TF}
+{
+ \seq_if_in:cnTF{\__xassoccnt_mastercontainer:}{#1}{%
+ \prg_return_true:
+ }{
+ \prg_return_false:
+ }
+}
+
+
+\prg_new_conditional:Nnn \__xassoccnt_container_if_in:Nn { T, F, TF }
+{
+ \seq_if_in:NnTF #1 {#2}{%
+ \prg_return_true:
+ }{
+ \prg_return_false:
+ }
+}
+
+\cs_generate_variant:Nn \__xassoccnt_container_if_in:NnTF { cnTF }
+\cs_generate_variant:Nn \__xassoccnt_container_if_in:NnT { cnT }
+\cs_generate_variant:Nn \__xassoccnt_container_if_in:NnF { cnF }
+
+\prg_new_conditional:Nnn \xassoccnt_is_associatedcounter:n {T,F,TF}
+{
+ \__xassoccnt_container_if_in:cnTF{\__xassoccnt_generate_countercontainername:n{\c_xassoccnt_associatedname_str}}{#1}{%
+ \prg_return_true:
+ }{
+ \prg_return_false:
+ }
+}
+
+\prg_new_conditional:Nnn \xassoccnt_is_suspendedcounter:n {TF,T,F}
+{%
+ \__xassoccnt_container_if_in:cnTF{\__xassoccnt_generate_countercontainername:n{\c_xassoccnt_suspendedname_str}}{#1}{%
+ \prg_return_true:
+ }{%
+ \prg_return_false:
+ }%
+}
+
+
+
+\prg_new_conditional:Nnn \xassoccnt_is_associatedtocounter:nn {T,F,TF}
+{
+ \xassoccnt_is_drivercounter:nTF{#1}{%
+ \seq_if_in:cnTF{\__xassoccnt_drivercontainer:n{#1}}{#2}{%
+ \prg_return_true:
+ }{%
+ \prg_return_false:
+ }%
+ }{%
+ \prg_return_false:
+ }%
+}
+
+%% Clearing functions
+
+\cs_new:Nn \xassoccnt_remove_associatedcounter:nnn
+{
+ \__xassoccnt_container_removeassociated:nn{#2}{#3}
+ \__xassoccnt_container_removecounter:nn{\c_xassoccnt_associatedname_str}{#3}%
+}
+
+\cs_new:Nn \xassoccnt_remove_associatedcounters:nnn
+{%
+ \clist_set:Nx \l_tmpa_clist {#3}
+ \seq_set_from_clist:NN \l_tmpa_seq \l_tmpa_clist
+ \seq_map_inline:Nn \l_tmpa_seq { \xassoccnt_remove_associatedcounter:nnn{#1}{#2}{##1} } % Remove one counter after another one!
+}
+
+
+\cs_new:Nn \xassoccnt_gclear_associatedcounters:nn {%
+ \seq_map_inline:cn {\__xassoccnt_drivercontainer:n{#2}} { \__xassoccnt_container_removecounter:nn{\c_xassoccnt_associatedname_str}{##1} }% Remove from associated list container
+ \__xassoccnt_container_gclear:c {\__xassoccnt_drivercontainer:n{#2} }
+}
+%%%%%%%%%%%%%%%%%%%%% User interface routines
+
+
+\NewDocumentCommand{\SuspendCounters}{O{}m}{%
+ \keys_set:nn { xassoccnt }{#1}%
+% \clist_if_empty:NF \l__xassoccnt_onlycounters_clist {%
+ \__xassoccnt_container_putright:nn{\c_xassoccnt_suspendedname_str}{#2}
+}
+
+
+\NewDocumentCommand{\ResumeSuspendedCounters}{O{}m}{%
+ \__xassoccnt_container_removecounter:nn{\c_xassoccnt_suspendedname_str}{#2}
+}
+
+
+\NewDocumentCommand{\DeclareAssociatedCounters}{omm}{%
+ \IfValueTF{#1}{%
+ \keys_set:nn {xassoccnt} {#1}
+ \xassoccnt_declareassociatedcounters:nnn{#1}{#2}{#3}%
+ }{%
+ % Disable the automated definition of counters explicitly
+ \xassoccnt_declareassociatedcounters:nnn{autodefine=none}{#2}{#3}%
+ }
+}
+
+
+\NewDocumentCommand{\AddDriverCounter}{O{}m}{%
+ \xassoccnt_adddrivercounter:nn{#1}{#2}
+}
+
+\NewDocumentCommand{\AddAssociatedCounters}{O{}mm}{%
+ %Check first if we are in document or in preamble:
+ \ifx\@onlypreamble\@notprerr
+ % Explicitly disable autodefinition of counters
+ \__xassoccnt_addassociatedcounters:nnn{#1,autodefine=none}{#2}{#3}%
+ \else
+ % No, it's the preamble, fall back to `\DeclareAssociatedCounters
+ \DeclareAssociatedCounters[#1]{#2}{#3}
+ \fi
+}
+
+\NewDocumentCommand{\RemoveDriverCounter}{O{}m}{%
+ \__xassoccnt_removedrivercounter:nn{#1}{#2}%
+}
+
+\NewDocumentCommand{\GetDriverCounter}{O{,}m}{%
+ \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_if_empty:NTF \l_tmpa_seq{--}{\seq_use:Nn \l_tmpa_seq {#1}}
+}
+
+
+
+\prg_new_conditional:Nnn \__xassoccnt_ifis_latexcounter:n {T,F,TF}
+{%
+ \cs_if_exist:cTF {c@#1}{%
+ \prg_return_true:
+ }{%
+ \prg_return_false:
+ }%
+}
+
+\prg_new_conditional:Nnn \__xassoccnt_latexcounter_exists:n {T,F,TF}
+{%
+ \cs_if_exist:cTF {c@#1}{%
+ \prg_return_true:
+ }{%
+ \prg_return_false:
+ }%
+}
+
+
+\NewDocumentCommand{\IfIsDocumentCounterTF}{om+m+m}{%
+ \__xassoccnt_ifis_latexcounter:nTF {#2}{ #3 } { #4 }
+}
+
+\NewDocumentCommand{\IfIsDocumentCounterT}{om+m}{%
+ \__xassoccnt_ifis_latexcounter:nT {#2}{ #3 }
+}
+
+
+\NewDocumentCommand{\IfIsDocumentCounterF}{om+m}{%
+ \__xassoccnt_ifis_latexcounter:nF {#2}{ #3 }
+}
+
+
+\NewDocumentCommand{\IsDriverCounter}{O{}mmm}{%
+ \xassoccnt_is_drivercounter:nTF{#2}{#3}{#4}%
+}
+
+\NewDocumentCommand{\IsAssociatedToCounter}{O{}mmmm}{%
+ \xassoccnt_is_associatedtocounter:nnTF{#2}{#3}{%
+ #4%
+ }{%
+ #5%
+ }%
+}
+
+\NewDocumentCommand{\IsAssociatedCounter}{O{}mmm}{%
+ \xassoccnt_is_associatedcounter:nTF{#2}{#3}{#4}%
+}
+
+
+\NewDocumentCommand{\IsSuspendedCounter}{O{}mmm}{%
+ \xassoccnt_is_suspendedcounter:nTF{#2}{#3}{#4}%
+}
+
+
+
+\NewDocumentCommand{\IfExistsDriverCounterList}{mmm}{%
+ \seq_if_exist:cTF{\__xassoccnt_drivercontainer:n{#1}}{%
+ #2%
+ }{%
+ #3%
+ }%
+}
+
+\NewDocumentCommand{\RemoveAssociatedCounters}{O{}mm}{%
+ \xassoccnt_remove_associatedcounters:nnn{#1}{#2}{#3}
+}
+
+\NewDocumentCommand{\RemoveAssociatedCounter}{O{}mm}{%
+ \xassoccnt_remove_associatedcounter:nnn{#1}{#2}{#3}
+}
+
+\NewDocumentCommand{\ClearAssociatedCounters}{O{}m}{%
+ \xassoccnt_gclear_associatedcounters:nn{#1}{#2}%
+}
+
+
+
+\NewDocumentCommand{\ShowAssociatedCountersList}{m}{%
+ {\color{red}%
+ \fbox{#1}~has~\seq_use:cn {\__xassoccnt_drivercontainer:n{#1}}{\par\noindent}
+ }
+}
+
+\NewDocumentCommand{\ShowAllAssociatedCounters}{}{%
+ {\color{brown}%
+ \seq_use:cn {\__xassoccnt_associatedcontainer:}{\par\noindent}
+ }
+}
+
+
+\NewDocumentCommand{\ShowDriverCounterList}{}{%
+ {\color{blue}%
+ \seq_use:cn{\__xassoccnt_mastercontainer:}{\par\bigskip\noindent}
+ }%
+}
+
+
+
+\RenewDocumentCommand{\stepcounter}{m}{%
+ \xassoccnt_is_suspendedcounter:nF{#1}{%
+ \cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {#1}%
+ \xassoccnt_countersinresetlist:n{#1}%
+ \int_compare:nTF{%
+ \l_xassoccnt_resetlist_counter > \c_zero
+ }{%
+ \xassoccnt_standardaddtocounter{#1}{\c_one}%
+ \begingroup
+ \cs_set_eq:NN \@elt \__xassoccnt_stpelt:n
+ \use:c{cl@#1}
+ \endgroup
+ }{%
+ \xassoccnt_standardaddtocounter{#1}{\c_one}
+ }
+ \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#1}}%
+ \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#1} }
+ { \seq_map_inline:cn {\__xassoccnt_drivercontainer:n{#1} }
+ { \xassoccnt_addtocounter{##1}{\c_one} }
+ }% End of \seq_if_exist
+ }%
+}
+
+
+
+\NewDocumentCommand{\xassoccnt_addtocounter}{mmO{}}{%
+ % Only add to a counter if this counter isn't on the suspended counters list!
+ \xassoccnt_is_suspendedcounter:nF{#1}{%
+ \xassoccnt_standardaddtocounter{#1}{#2}%
+ \cs_gset_nopar:Nn \__xassoccnt_lastaddtocounter: {#1}%
+ }%
+}
+
+
+\cs_new:Nn \__xassoccnt_setdocumentcounter:nnn {
+ \xassoccnt_standardsetcounter{#2}{#3}%
+ \clist_clear:N \l__xassoccnt_onlycounters_clist
+ \keys_set:nn {xassoccnt}{#1}%
+ \bool_if:nTF {\l__xassoccnt_setcounter_associated } {%
+ \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#2} }
+ { \seq_map_inline:cn {\__xassoccnt_drivercontainer:n{#2} }
+ { \xassoccnt_standardsetcounter{##1}{#3} }
+ }% End of \seq_if_exist
+ }{%
+ % Check whether the `onlycounters` - clist is empty -- if not, loop through the list
+ \clist_if_empty:NF \l__xassoccnt_onlycounters_clist {%
+ \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#2} }
+ {
+ \clist_map_inline:Nn \l__xassoccnt_onlycounters_clist
+ { % Check first if ##1 is associated to #2 at all
+ \xassoccnt_is_associatedtocounter:nnT {#2} {##1} { \xassoccnt_standardsetcounter{##1}{#3} }
+ }
+ }
+ }
+ }
+ \cs_gset_nopar:Nn \__xassoccnt_lastsetdocumentcounter: {#2}%
+ \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#2}}%
+}
+
+
+\cs_new:Nn \__xassoccnt_synccounters:nn {%
+ \int_set:Nn \l_tmpa_int {\value{#2}}
+ \__xassoccnt_setdocumentcounter:nnn {associatedtoo=true,#1}{#2}{\l_tmpa_int} % copy the driver counter value to all associated counters
+ \int_zero:N \l_tmpa_int
+}
+
+\cs_new:Nn \__xassoccnt_copycounters:nnn {%
+ \xassoccnt_standardsetcounter{#3}{\value{#2}}
+}
+
+
+\cs_new:Nn \__xassoccnt_swapcounters:nnn {%
+ \int_set:Nn \l_tmpa_int {\value{#2}}%
+ \xassoccnt_standardsetcounter{#2}{\value{#3}}
+ \xassoccnt_standardsetcounter{#3}{\l_tmpa_int}
+ \int_zero:N \l_tmpa_int
+}
+
+
+
+
+
+% Extended support layer for counters
+\NewDocumentCommand{\SetDocumentCounterOld}{O{associatedtoo=false}mm}{%
+ \xassoccnt_standardsetcounter{#2}{#3}%
+ \clist_clear:N \l__xassoccnt_onlycounters_clist
+ \keys_set:nn {xassoccnt}{#1}%
+ \bool_if:nTF {\l__xassoccnt_setcounter_associated } {%
+ \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#2} }
+ { \seq_map_inline:cn {\__xassoccnt_drivercontainer:n{#2} }
+ { \xassoccnt_standardsetcounter{##1}{#3} }
+ }% End of \seq_if_exist
+ }{%
+ % Check whether the `onlycounters` - clist is empty -- if not, loop through the list
+ \clist_if_empty:NF \l__xassoccnt_onlycounters_clist {%
+ \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#2} }
+ {
+ \clist_map_inline:Nn \l__xassoccnt_onlycounters_clist
+ { % Check first if ##1 is associated to #2 at all
+ \xassoccnt_is_associatedtocounter:nnT {#2} {##1} { \xassoccnt_standardsetcounter{##1}{#3} }
+ }
+ }
+ }
+ }
+ \cs_gset_nopar:Nn \__xassoccnt_lastsetdocumentcounter: {#2}%
+ \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#2}}%
+}
+
+
+\NewDocumentCommand{\SetDocumentCounter}{O{associatedtoo=false}mm}{%
+ \__xassoccnt_setdocumentcounter:nnn {#1}{#2}{#3} % copy the driver counter value to all associated counters
+}
+
+\NewDocumentCommand{\SyncCounters}{om}{%
+ \IfValueTF{#1}{%
+ \__xassoccnt_synccounters:nn {#1}{#2}
+ }{%
+ \__xassoccnt_synccounters:nn {}{#2}
+ }
+}
+
+
+\RenewDocumentCommand{\setcounter}{mm}{%
+ \cs_gset_nopar:Nn \__xassoccnt_lastsetcounter: {#1}
+ \xassoccnt_standardsetcounter{#1}{#2}%
+ \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#1}}%
+}
+
+
+\RenewDocumentCommand{\refstepcounter}{m}{%
+ \cs_gset_nopar:Nn \__xassoccnt_lastrefsteppedcounter: {#1}
+ \xassoccnt_standardrefstepcounter{#1}%
+ \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#1}}%
+}
+
+%%%% Now some wrapper macros for information on the last counter changed
+
+\newcommand{\LastSteppedCounter}{%
+ \__xassoccnt_laststeppedcounter:
+}
+
+
+\newcommand{\LastRefSteppedCounter}{%
+ \__xassoccnt_lastrefsteppedcounter:
+}
+
+\newcommand{\LastAddedToCounter}{%
+ \__xassoccnt_lastaddtocounter:
+}
+
+\newcommand{\LastSetCounter}{%
+ \__xassoccnt_lastsetcounter:
+}
+
+\newcommand{\LastSetDocumentCounter}{%
+ \__xassoccnt_lastsetdocumentcounter:
+}
+
+
+%%%%%%%%%
+
+
+\newcommand{\LastCounterValue}{%
+%\NewDocumentCommand{\LastCounterValue}{}{%
+ \int_use:N \g__xassoccnt_lastcountervalue_int
+}
+
+
+
+\NewDocumentCommand{\NewDocumentCounter}{O{initial=\c_zero}mo}{%
+ \IfValueTF{#3}{%
+ \__xassoccnt_newcounter_ltx:nnn{#1}{#2}{#3}
+ }{%
+ \__xassoccnt_newcounter_ltx:nnn{#1}{#2}{}
+ }
+}
+
+
+
+\NewDocumentCommand{\CopyDocumentCounters}{O{}mm}{%
+ \__xassoccnt_copycounters:nnn{#1}{#2}{#3}%
+}
+
+\NewDocumentCommand{\SwapDocumentCounters}{O{}mm}{%
+ \__xassoccnt_swapcounters:nnn{#1}{#2}{#3}%
+}
+
+
+\newcommand{\countersresetlistcount}[1]{%
+ \int_zero:N \l_xassoccnt_resetlist_counter%
+ \xassoccnt_countersinresetlist:n{#1}%
+}
+
+\newcommand{\getresetlistcount}{%
+ \int_use:N \l_xassoccnt_resetlist_counter
+}
+
+\bool_new:N \l__xassoccnt_isinresetlist_bool
+
+
+\prg_new_conditional:Nnn \__xassoccnt_ifinresetlist:nn {T,F,TF}
+{%
+ \bool_set_false:N \l__xassoccnt_isinresetlist_bool
+ \cs_set:Nn \l__tmpa_cs: {#2}
+ \def\@elt##1{% Can't use \cs_new:Nn here :-(
+ \cs_set:Nn \l__tmpb_cs: {##1}
+ % Check if \l__tmpa_cs: and \l__tmpb_cs: are equal
+ \cs_if_eq:NNT \l__tmpa_cs: \l__tmpb_cs: {
+ \bool_set_true:N \l__xassoccnt_isinresetlist_bool
+ }
+ }
+ \use:c{ cl@#1 }
+ \bool_if:nTF {\l__xassoccnt_isinresetlist_bool}{%
+ \prg_return_true:
+ }{%
+ \prg_return_false:
+ }
+}
+
+\NewDocumentCommand{\IfInResetListTF}{omm+m+m}{%
+ \bool_set_true:N \l__xassoccnt_isinresetlist_bool
+ \__xassoccnt_ifinresetlist:nnTF{#2}{#3}{#4}{#5}%
+}
+
+\NewDocumentCommand{\IfInResetListT}{omm+m}{%
+ \__xassoccnt_ifinresetlist:nnT{#2}{#3}{#4}%
+}
+
+\NewDocumentCommand{\IfInResetListF}{omm+m}{%
+ \__xassoccnt_ifinresetlist:nnF{#2}{#3}{#4}%
+}
+
+
+\ExplSyntaxOff
+
+
+%%%%%%%%%%%
+
+% Extended interface functions
+
+
+\NewDocumentCommand{\DeclareDocumentCounter}{O{initial={0}}mo}{%
+ \IfValueTF{#3}{%
+ \NewDocumentCounter[#1]{#2}[#3]%
+ }{%
+ \NewDocumentCounter[#1]{#2}%
+ }%
+}
+
+\@onlypreamble{\DeclareAssociatedCounters}
+\@onlypreamble{\DeclareDocumentCounter}
+
+\endinput \ No newline at end of file
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index 58e9f3bc88a..fe00ad27e45 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -593,7 +593,7 @@ my @TLP_working = qw(
widetable williams withargs
wnri wnri-latex wordlike
wrapfig wsemclassic wsuipa
- xargs xcharter xcite xcjk2uni xcolor xcolor-solarized
+ xargs xassoccnt xcharter xcite xcjk2uni xcolor xcolor-solarized
xcomment xcookybooky xdoc
xebaposter xecjk xecolor xecyr xeindex xellipsis
xepersian xesearch xespotcolor
diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
index e3b46f5335e..370788bdc63 100644
--- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
@@ -1034,6 +1034,7 @@ depend withargs
depend wordlike
depend wrapfig
depend xargs
+depend xassoccnt
depend xcolor-solarized
depend xcomment
depend xdoc
diff --git a/Master/tlpkg/tlpsrc/xassoccnt.tlpsrc b/Master/tlpkg/tlpsrc/xassoccnt.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/xassoccnt.tlpsrc