From 80eb6890ed8748ee4e3da233c40143094c31c971 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 5 Mar 2017 21:39:46 +0000 Subject: xassoccnt (5mar17) git-svn-id: svn://tug.org/texlive/trunk@43408 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/xassoccnt/README | 8 +- .../xassoccnt/xassoccnt_backupcounters_example.pdf | Bin 84360 -> 84360 bytes .../xassoccnt/xassoccnt_backupcounters_example.tex | 2 +- .../xassoccnt_coupledcounters_example.pdf | Bin 94195 -> 94195 bytes .../xassoccnt_coupledcounters_example.tex | 2 +- .../doc/latex/xassoccnt/xassoccnt_doc.pdf | Bin 525014 -> 536451 bytes .../doc/latex/xassoccnt/xassoccnt_doc.tex | 192 ++++++++++----- .../latex/xassoccnt/xassoccnt_driver_example.pdf | Bin 81113 -> 81113 bytes .../latex/xassoccnt/xassoccnt_driver_example.tex | 2 +- .../doc/latex/xassoccnt/xassoccnt_example.pdf | Bin 68384 -> 68384 bytes .../doc/latex/xassoccnt/xassoccnt_example.tex | 2 +- .../xassoccnt_getparentcounter_example.pdf | Bin 0 -> 46915 bytes .../xassoccnt_getparentcounter_example.tex | 152 ++++++++++++ .../latex/xassoccnt/xassoccnt_label_example.pdf | Bin 42924 -> 42924 bytes .../latex/xassoccnt/xassoccnt_label_example.tex | 2 +- .../xassoccnt_periodiccounters_example.pdf | Bin 31637 -> 31637 bytes .../xassoccnt_periodiccounters_example.tex | 2 +- .../xassoccnt/xassoccnt_resetlist_example.pdf | Bin 46542 -> 64316 bytes .../xassoccnt/xassoccnt_resetlist_example.tex | 23 +- .../xassoccnt_suspendedcounters_example.pdf | Bin 60527 -> 60527 bytes .../xassoccnt_suspendedcounters_example.tex | 2 +- .../xassoccnt/xassoccnt_totalcounters_example.pdf | Bin 63550 -> 63550 bytes .../xassoccnt/xassoccnt_totalcounters_example.tex | 2 +- .../texmf-dist/tex/latex/xassoccnt/xassoccnt.sty | 257 ++++++++++++++------- 24 files changed, 497 insertions(+), 151 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_getparentcounter_example.pdf create mode 100644 Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_getparentcounter_example.tex diff --git a/Master/texmf-dist/doc/latex/xassoccnt/README b/Master/texmf-dist/doc/latex/xassoccnt/README index f31c3bbc79c..d19fd6cb79e 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/README +++ b/Master/texmf-dist/doc/latex/xassoccnt/README @@ -1,9 +1,9 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% README file for xassoccnt.sty %% %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2015 -- 2017 by Dr. Christian Hupfer +%% Copyright (c) 2017 by Dr. Christian Hupfer %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -26,7 +26,7 @@ the associated counters as well. This package can be regarded as a supplement to the totcount package by Vasileios Koutavas (http://www.ctan.org/pkg/totcount), but can be used without it too. -As of 2017/03/04 xassoccnt does not supersede the package assoccnt by the same author, however, -the older package isn't declared obsolete as of 2017/03/04 +As of 2017/03/05 xassoccnt does not supersede the package assoccnt by the same author, however, +the older package isn't declared obsolete as of 2017/03/05 diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.pdf index 690761aa73f..e9039a28add 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex index d693a185002..7f056dacc36 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_backupcounters_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Example file for backup counters file for xassoccnt.sty %% %% diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.pdf index 1fb2e41f82e..769838c75b7 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.tex index 825e748f578..68de4dc97aa 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_coupledcounters_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Example file for coupled counters file for xassoccnt.sty %% %% diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf index e921a3a58fc..1a890e51dac 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_doc.tex index 2ecf4cb802c..f2d7dfc8798 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 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Documentation file for xassoccnt.sty %% %% @@ -99,6 +99,8 @@ \@namedef{xassoccntversion1.2}{v1.2 2017-03-03} +\@namedef{xassoccntversion1.3}{v1.3 2017-03-04} + \newcommand{\authorname}{Autor} @@ -382,7 +384,7 @@ pdfsubject={Documentation of \PackageDocName\ package}, pdfkeywords={LaTeX, counters}, bookmarksopen=true, - bookmarksopenlevel=4, + bookmarksopenlevel=2, bookmarksnumbered=true, pdfcreator={LaTeX} } @@ -390,7 +392,7 @@ \begin{document} -\mmddyyyydate +\yyyymmdddate \setlength{\parindent}{0em} @@ -401,7 +403,7 @@ \bfseries \node [concept] {Counters} child[concept color=red!30!yellow,grow=30] { node [concept] {Associated counters}} - child[grow=80,white,concept color=red!80!blue] { node [concept] {Backup \& Restore of counters}} + child[grow=85,white,concept color=red!80!blue] { node [concept] {Backup \& Restore of counters}} child[grow=300,concept color=yellow!90!red] { node [concept] {Extensions to \LaTeXe} child[grow=230,concept color={yellow!20!green}] {node [concept] {Query macros}} child[grow=290,concept color={yellow!30!cyan}] {node [concept] {Document counters}} } @@ -410,7 +412,8 @@ child[grow=170,concept color=red!30!yellow] { node [concept] {Total} child[concept color=yellow!30!,grow=150] {node[concept] {Super total counters}}} child[grow=260,concept color=red!30!green] { node [concept] {Loops on counters}} child[grow=200,concept color=red!30!green] { node [concept] {Counter output}} - child[grow=230,concept color=red!20!cyan] { node [concept] {Coupled counters} child [grow=250,concept color=cyan!50!blue] {node[concept] {Coupled counter groups}}}; + child[grow=230,concept color=red!20!cyan] { node [concept] {Coupled counters} child [grow=250,concept color=cyan!50!blue] {node[concept] {Coupled counter groups}}} + child[grow=57,concept color=red!20!yellow] { node [concept] {Label}}; \end{tikzpicture} \CHPackageTitlePage[packageauthor={Christian Hupfer}]{Associated counters stepping simultaneously\\ (and other gadgets)} @@ -791,7 +794,7 @@ The optional argument is not used as of version \packageversion\ for none of tho 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}{} +\begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{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} @@ -808,18 +811,21 @@ This command has no arguments and expands to the name of the counter which was u \end{marker} -\begin{docCommand}{LastSteppedCounter}{} +\begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{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{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{LastRefSteppedCounter}{} + +This macro gives the last counter being used in \cs{refstepcounter} and is expandable.%{\ChDocVersion{1.3}} \begin{dispExample} \begin{equation} @@ -830,13 +836,14 @@ This command has no arguments and expands to the name of the counter which was s The last counter being refstepped was \LastRefSteppedCounter. \end{dispExample}% + \end{docCommand}% -\begin{docCommand}{LastSetCounter}{} +\begin{docCommand}[before={\CHDocExpCommand\par\CHDocUpdate{1.3}}]{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} @@ -986,6 +993,24 @@ This command displays the reset list of a counter on the terminal as the \cs{sho \end{docCommand} +\begin{docCommand}[before={\CHDocNew{1.3}}]{GetAllResetLists}{} + This determines all reset lists and stores the information internally. It should be called right before \cs{begin{document}} or at any time inside the document environment, when new counters are added there (which is not recommended) + +The information can be retrieved with \refCom{GetParentCounter}. + +\end{docCommand} + +\begin{docCommand}[before={\CHDocExpCommand\par\CHDocNew{1.3}}]{GetParentCounter}{\marg{counter}} +This macro tries to detect the counter that was responsible for the resetting of the counter named \marg{counter} and is expandable. +In order to minimize the amount of searching and maintaining expandability, the counter reset data must be stored beforehand, i.e. with \refCom{GetAllResetLists}. + +\begin{marker} +If a counter has been added to more than one parent counter as their resetting driver counter, only the most recent addition is in action. This may be correct in some occasions but there is no guarantee that the given counter name really caused the last reset of the counter given as argument. +\end{marker} +\end{docCommand} + + + \section[Loops on multiple counters]{Performing the same action for many counters} \CHDocNew{0.7} Sometimes it might be necessary to set the values of many counters at once. This can be done with consecutive \cs{setcounter} statements, for example. This poses no problem, but might become tedious if there are more than three counters or if this task occurs more than once. \CHDocPackage{\PackageDocName} provides some macros that can do the usual operations like stepping, refstepping, adding to, resetting or setting counter values. @@ -1495,51 +1520,6 @@ This commands tests, whether a given counter name is a driver counter and expand \end{docCommand}% -\subsection{Associated counters -- Experimental features}\label{subsec::associated_counters_experimental} -\begin{marker} -\marginnote{\bcbombe} -The content here is only of experimental nature and there is no guarantee that the feature will be maintained in future releases. -\end{marker} - -\begin{marker} -To enable the redefined \refCom{label} macro, specify the package option \refKey{redefinelabel} -\end{marker} - - - -\begin{docCommand}[before={\CHDocNew{1.2}}]{label}{\oarg{cleveref-counter-overrule}\marg{label name}\oarg{options for associated counters}} - \begin{docKey}{all}{=\meta{true,false}}{initially \meta{false}}\CHDocNew{1.2} - This will enable that all associated counters to a driver counter will cause the generation of a label too. By default this option is \meta{false}. - This option deliberately overrules \refKey{select}, the value of the option \refKey{prefix} is disregarded. - \end{docKey} - \begin{docKey}{select}{={counter1, counter2,\dots}}{initially empty}\CHDocNew{1.2} - Select only some of the associated counters to be able to be labeled. - As of version \packageversion{} there is no check whether the given names refer to counters at all or are associated counters to the last counter that has been used with \cs{refstepcounter}. - \end{docKey} - \begin{docKey}{prefix}{=\meta{text}}{initially empty}\CHDocNew{1.2} - This gives the prefix of the label of the associated counter. If the option \refKey{all} is enabled, the label name is generated from the name of the associated counter, the value of \refKey{prefix-sep} and the value of the 2nd argument. - \newcounter{morefoobar} - \begin{dispExample*}{listing only} - % Assume that some counter has the associated counters foobar, morefoobar and yetanotherfoobar - \label{foo}[prefix=assoc,all] - \end{dispExample*} - will cause a label named \texttt{foobar::foo}, \texttt{morefoobar::foo} and \texttt{yetanotherfoobar::foo}, whereas - \begin{dispExample*}{listing only} - \label{foo}[prefix=assoc,select=morefoobar] - \end{dispExample*} - would generate the label \texttt{assocc::foobar} only and will be tied to the value of the counter \texttt{morefoobar} - \end{docKey} - \begin{docKey}{prefix-sep}{=\meta{text}}{initially ::}\CHDocNew{1.2} - Defines the separator between the \refKey{prefix} and the label name for the driver counter, i.e. the 2nd argument of the \refCom{label} command. - \end{docKey} -\end{docCommand} - - -\begin{marker} -\marginnote{\bcbombe} -If the package option \refKey{redefinelabel} is set to \meta{false}, the usage of the third optional argument will leave spurious content at the position \cs{label} was used. The reason is that the content of third optional argument with \texttt{[]} is not recognized as an argument any longer. -\end{marker} - \section[Counter backup/restoration]{Backup and restore of counter values}\CHDocNew{1.0}\label{section::new_backuprestore} @@ -2281,7 +2261,99 @@ This macro checks if a counter is under the administration of the super total co This package adds a counter of its own: \CHDocCounter{numberofruns} which is a super total counter and is stepped each compilation run. It's added in \cs{AtBeginDocument} and can be retrieved with \refCom{TotalValue}. Use the \refKey{nonumberofruns} package option to prevent the definition of this counter. -\clearpage{ + +\section{Experimental features}\label{subsec::associated_counters_experimental} + + +\begin{marker} +\marginnote{\bcbombe} +The content here is only of experimental nature and there is no guarantee that the feature will be maintained in future releases. +\end{marker} + + +\subsection{Labels} + + + +\begin{marker} +To enable the redefined \refCom{label} macro, specify the package option \refKey{redefinelabel} +\end{marker} + + + +\begin{docCommand}[before={\CHDocNew{1.2}}]{label}{\oarg{cleveref-counter-overrule}\marg{label name}\oarg{options for associated counters}} + \begin{docKey}{all}{=\meta{true,false}}{initially \meta{false}}\CHDocNew{1.2} + This will enable that all associated counters to a driver counter will cause the generation of a label too. By default this option is \meta{false}. + This option deliberately overrules \refKey{select}, the value of the option \refKey{prefix} is disregarded. + \end{docKey} + \begin{docKey}{select}{={counter1, counter2,\dots}}{initially empty}\CHDocNew{1.2} + Select only some of the associated counters to be able to be labeled. + As of version \packageversion{} there is no check whether the given names refer to counters at all or are associated counters to the last counter that has been used with \cs{refstepcounter}. + \end{docKey} + \begin{docKey}{prefix}{=\meta{text}}{initially empty}\CHDocNew{1.2} + This gives the prefix of the label of the associated counter. If the option \refKey{all} is enabled, the label name is generated from the name of the associated counter, the value of \refKey{prefix-sep} and the value of the 2nd argument. + \newcounter{morefoobar} + \begin{dispExample*}{listing only} + % Assume that some counter has the associated counters foobar, morefoobar and yetanotherfoobar + \label{foo}[prefix=assoc,all] + \end{dispExample*} + will cause a label named \texttt{foobar::foo}, \texttt{morefoobar::foo} and \texttt{yetanotherfoobar::foo}, whereas + \begin{dispExample*}{listing only} + \label{foo}[prefix=assoc,select=morefoobar] + \end{dispExample*} + would generate the label \texttt{assocc::foobar} only and will be tied to the value of the counter \texttt{morefoobar} + \end{docKey} + \begin{docKey}{prefix-sep}{=\meta{text}}{initially ::}\CHDocNew{1.2} + Defines the separator between the \refKey{prefix} and the label name for the driver counter, i.e. the 2nd argument of the \refCom{label} command. + \end{docKey} +\end{docCommand} + + +\begin{marker} +\marginnote{\bcbombe} +If the package option \refKey{redefinelabel} is set to \meta{false}, the usage of the third optional argument will leave spurious content at the position \cs{label} was used. The reason is that the content of third optional argument with \texttt{[]} is not recognized as an argument any longer. +\end{marker} + + +\begin{docCommand}[before={\CHDocNew{1.3}}]{LaTeXLabel}{\oarg{cleveref-counter-overrule}\marg{label name}} + This is the default label macro, either with the \CHDocPackage{cleveref} extension or the classical \LaTeX2e\ macro (eventually modified by \CHDocPackage{hyperref}) and is not modified by this package. + + +The feature of label hooks from \refCom{RegisterPreLabelHook} or \refCom{RegisterPostLabelHook} is not used here. +\end{docCommand} + + +\subsection{Hooks} + + +This feature is experimental and only realized for the modified \refCom{label} command until now. See \nolinkurl{xassoccnt_getparentcounter_example.tex} as an example of usage. + +\begin{docCommand}[before={\CHDocNew{1.3}}]{RegisterPreLabelHook}{\marg{command name1, command name2,\dots}} + +This macro declares a possible list of hooks (commands) that should be executed \textbf{before} the traditional \cs{label} command is applied. If the hook name refers to some unknown macro, nothing is done. + +The hook names must be given with the \textbackslash as command sequence indicator, i.e. \cs{zlabel}, more than one macro name is possible by using comma as separator. + +As of version \packageversion\ the hook macro does not allow more than one argument, which is automatically used from the surrounding \cs{label} call and is the usual label name. + + +\end{docCommand} + +\begin{docCommand}[before={\CHDocNew{1.3}}]{RegisterPostLabelHook}{\marg{command name1, command name2,\dots}} + +This macro declares a possible list of hooks (commands) that should be executed after the traditional \cs{label} command is applied. If the hook name refers to some unknown macro, nothing is done. + +The hook names must be given with the \textbackslash as command sequence indicator, i.e. \cs{zlabel}, more than one macro name is possible by using comma as separator. + +As of version \packageversion\ the hook macro does not allow more than one argument, which is automatically used from the surrounding \cs{label} call and is the usual label name. + +\end{docCommand} + + + + + +\clearpage \part{Meta-Information} \parttoc @@ -2352,6 +2424,14 @@ write this documentation. \begin{itemize}[itemsep=15pt] +\item \CHDocFullVersion{1.3} +\begin{itemize} + \item Provided the \refCom{LaTeXLabel} macro to access the non-xassoccnt version of the \refCom{label} command. + \item \CHDocExperimentalFeature Added the concept of label hooks, see \cref{subsec::associated_counters_experimental} for more information. + \item The macros \cs{Last...} are defined with \CHDocPackage{expl3} methods. + \item Added \refCom{GetAllResetLists} and \refCom{GetParentCounter} for information on parent (or driver) counters. +\end{itemize} + \item \CHDocFullVersion{1.2} \begin{itemize} \item Corrected some typos in the manual. diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver_example.pdf index 12b008b3ce7..40000678198 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver_example.tex index 8cd63b0b31c..a7097a65c7c 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_driver_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Driver file for xassoccnt.sty %% %% diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf index 173d3bc2dbd..43b6bd68345 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_example.tex index 88a1d1505b2..1fb419b065d 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 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Example file for xassoccnt.sty %% %% diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_getparentcounter_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_getparentcounter_example.pdf new file mode 100644 index 00000000000..137271c11c5 Binary files /dev/null and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_getparentcounter_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_getparentcounter_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_getparentcounter_example.tex new file mode 100644 index 00000000000..93f29e8db31 --- /dev/null +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_getparentcounter_example.tex @@ -0,0 +1,152 @@ +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) +%% Example file for determing the parent counter of a counter and referring to it file for xassoccnt.sty +%% +%% +%% ------------------------------------------------------------------------------------------- +%% Copyright (c) 2017 by Dr. Christian Hupfer +%% ------------------------------------------------------------------------------------------- +%% +%% 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` +%% +%% + + +% Source was a question on TeX.SE by user gigabytes: http://tex.stackexchange.com/questions/353491/how-to-show-also-the-name-of-the-parent-counter-with-cleveref +% The provided answer by Christian Hupfer did not use xassoccnt but the features were incorporated in the package. + +\documentclass{book} +\usepackage{lipsum} +\usepackage{xassoccnt} +\usepackage{xpatch} +\usepackage{hyperref} +\usepackage[user,counter,hyperref]{zref} +\usepackage{cleveref} + +\makeatletter +\AtEndPreamble{ + \newif\if@hyperrefloaded + +\@ifpackageloaded{hyperref}{% + \@hyperrefloadedtrue +}{ + \@hyperrefloadedfalse +} +} +\makeatother + + + + +\usepackage{xparse} +\makeatletter + +\ExplSyntaxOn +\prop_new:N \g_latex_parentcounters_prop +\seq_new:N \g_latex_counters_seq + +\cs_generate_variant:Nn \str_head:n {x,o,V} +\cs_generate_variant:Nn \str_tail:n {x,o,V} +\cs_generate_variant:Nn \str_upper_case:n {x,o,V} +\cs_generate_variant:Nn \str_set:Nn {Nx,No} + +% Store all reset lists and make a property list for each counter and its possible parent counter + +% Make the first character of a word upper case +\newcommand{\FirstUpcase}[1]{% + \str_set:Nx \l_tmpa_str {#1}% + \str_upper_case:x {\str_head:N \l_tmpa_str}\str_tail:V {\l_tmpa_str}% +} + +\ExplSyntaxOff + + + + +% Define new properties +\zref@newprop{childcountervalue}{\arabic{\LastRefSteppedCounter}}% This is the naked value +\zref@newprop{parentcountervalue}{\csname the\GetParentCounter{\LastRefSteppedCounter}\endcsname} +\zref@newprop{parentcountername}{\GetParentCounter{\LastRefSteppedCounter}} + +% Add the new properties to the main property list stored with \zlabel +\zref@addprops{main}{childcountervalue,parentcountervalue,parentcountername} + +% Command for uppercase output +\NewDocumentCommand{\parentCref}{m}{% + \zref@ifrefundefined{#1}{% + \Cref{#1}% + }{% + \edef\@tmpb@{\zref@extract{#1}{parentcountervalue}}% + \edef\@tmpa@{\csname the\zref@extract{#1}{parentcountername}\endcsname}% + \ifx\@tmpb@\@tmpa@ + \Cref{#1}% + \else + \if@hyperrefloaded + \FirstUpcase{\zref@extract{#1}{counter}} \hyperlink{\zref@extract{#1}{anchor}}{\zref@extract{#1}{childcountervalue}} of \FirstUpcase{\zref@extract{#1}{parentcountername}} \hyperlink{\zref@extract{#1}{anchor}}{\zref@extract{#1}{parentcountervalue}}% + \else + \FirstUpcase{\zref@extract{#1}{counter}} \zref@extract{#1}{childcountervalue} of \FirstUpcase{\zref@extract{#1}{parentcountername}} \zref@extract{#1}{parentcountervalue}% + \fi + \fi + }% +} + +% Command for lowercase output +\NewDocumentCommand{\parentcref}{m}{% + \zref@ifrefundefined{#1}{% + \cref{#1}% + }{% + \edef\@tmpb@{\zref@extract{#1}{parentcountervalue}}% + \edef\@tmpa@{\csname the\zref@extract{#1}{parentcountername}\endcsname}% + \ifx\@tmpb@\@tmpa@ + \Cref{#1}% + \else + \if@hyperrefloaded + \zref@extract{#1}{counter} \hyperlink{\zref@extract{#1}{anchor}}{\zref@extract{#1}{childcountervalue}} of \zref@extract{#1}{parentcountername} \hyperlink{\zref@extract{#1}{anchor}}{\zref@extract{#1}{parentcountervalue}}% + \else + \zref@extract{#1}{counter} \zref@extract{#1}{childcountervalue} of \zref@extract{#1}{parentcountername} \zref@extract{#1}{parentcountervalue}% + \fi + \fi + }% +} + +\makeatother + + +\GetAllResetLists +\RegisterPostLabelHook{\zlabel} + + + +\begin{document} +\chapter{Chapter One} + Please look at \parentCref{othersection} or at \parentCref{foosubsection} or at \parentcref{foosubsection} + + + \section{Section One.One} + \label{mysection} + \lipsum + + \section{Section One.Two} + + \subsection{A subsection} \label{foosubsection} + Please ignore \parentCref{mysection}. + + \chapter{Chapter Two} + \section{Section Two.One} + + As you may have noticed, \parentCref{mysection} is useless. + + + \chapter{Chapter Three} + \section{Section Three.One} % + \section{Section Three.Two}\label{othersection} + +\end{document} \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_label_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_label_example.pdf index a729e13d57f..b35903e19a5 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_label_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_label_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_label_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_label_example.tex index 01d305561be..a3e2321d1f3 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_label_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_label_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Example file the the usage of labels with associated counters file for xassoccnt.sty %% %% diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdf index 9f2c3354fa2..4af97ba7c5c 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex index 164ad4f1e7d..827d72a1b9b 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_periodiccounters_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Example file for periodic counters file for xassoccnt.sty %% %% diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.pdf index 790e2515f55..8555d6a643b 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.tex index b480a43dd12..ff23de95e9c 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_resetlist_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Example file for reset list features file for xassoccnt.sty %% %% @@ -25,11 +25,14 @@ \usepackage{xassoccnt} +\DeclareDocumentCounter{dummyctra}[chapter] + \newcommand{\showfullresetlist}[1]{% \item Counter name: #1 \hfill \csname the#1\endcsname%\leavevmode% } \begin{document} +\tableofcontents \chapter{First} @@ -60,6 +63,7 @@ \AddToReset{section}{chapter} + \chapter{Third Chapter} \section{First section in 3rd chapter} @@ -71,5 +75,22 @@ \caption{Another dummy figure} \end{figure} +\GetAllResetLists + +\chapter[Parent counter of another counter]{Determing the parent counter of a counter} + +\section{Some dummy section} + +The last ref stepped counter is \LastRefSteppedCounter + +\fbox{\GetParentCounter{\LastRefSteppedCounter}} + +\AddToReset{dummyctra}{section} + +\GetAllResetLists +\noindent\GetParentCounter{dummyctra} + + + \end{document} \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdf index f52b8584ce6..044026ab36b 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex index c36c71f6969..be3ebae7ed7 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_suspendedcounters_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Example file for suspended counters file for xassoccnt.sty %% %% diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdf b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdf index 6e8c7a432d0..08576d9c494 100644 Binary files a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdf and b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.pdf differ diff --git a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex index 9bb7b552ce8..e3a3f2cb29f 100644 --- a/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex +++ b/Master/texmf-dist/doc/latex/xassoccnt/xassoccnt_totalcounters_example.tex @@ -1,4 +1,4 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Example file for total counters 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 26f22e893f1..628d992ce3f 100644 --- a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty +++ b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty @@ -1,9 +1,9 @@ -%% LaTeX package xassoccnt - version 1.2 (2017/03/04 -- 00:46:43) +%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47) %% Source file for xassoccnt.sty %% %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2015 -- 2017 by Dr. Christian Hupfer +%% Copyright (c) 2017 by Dr. Christian Hupfer %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -19,10 +19,10 @@ %% %% -\def\xassoccntpackageversion{1.2} +\def\xassoccntpackageversion{1.3} \NeedsTeXFormat{LaTeX2e}[1995/12/01] -\ProvidesPackage{xassoccnt}[2017/03/04 - v\xassoccntpackageversion] +\ProvidesPackage{xassoccnt}[2017/03/05 - v\xassoccntpackageversion] \RequirePackage{etoolbox} \RequirePackage{letltxmacro} \RequirePackage{xcolor} @@ -38,13 +38,14 @@ % Some variants of standard expl3 contributions \cs_generate_variant:Nn \seq_set_from_clist:Nn { Nx, cx } +\cs_generate_variant:Nn \seq_gset_from_clist:Nn { Nx, cx } \cs_generate_variant:Nn \seq_remove_all:Nn { cV, NV } \cs_generate_variant:Nn \seq_gremove_all:Nn { cV, NV } \cs_generate_variant:Nn \seq_gput_right:cn {cx} \cs_generate_variant:Nn \prop_put:Nnn {cxx} \cs_generate_variant:Nn \prop_remove:Nn {cx,Nx} -\cs_generate_variant:Nn \prop_item:Nn {NV,cV,cx} +\cs_generate_variant:Nn \prop_item:Nn {NV,cV,cx,No,co} \cs_generate_variant:Nn \int_set:Nn {NV,Nx} @@ -87,8 +88,15 @@ \bool_new:N \l_xassoccnt_resetperiodiccounters_bool \bool_new:N \l_xassoccnt_wrapperiodiccounters_bool + +% Reset of counters related 'variables' \seq_new:N \l__xassoccnt_counterreset_seq +\seq_new:N \g_xassoccnt_all_latex_counters_seq + +\prop_new:N \g_xassoccnt_latex_parentcounters_prop + + %%% \int_new:N \g__xassoccnt_backupcalls_int \int_new:N \l__xassoccnt_backuptmpa_int @@ -477,7 +485,7 @@ }{} \AtEndOfPackage{ - \PackageInfo{xassoccnt}{2017/03/04 - v\xassoccntpackageversion -- stepping counters simultaneously and other features} + \PackageInfo{xassoccnt}{2017/03/05 - v\xassoccntpackageversion -- stepping counters simultaneously and other features} \@ifpackageloaded{calc}{% \msg_warning:nnn{xassoccnt}{incompatiblepackagenonfatal}{calc}% Warning \bool_set_true:N \l__xassoccnt_calcpackage_loaded @@ -1550,7 +1558,6 @@ }{% \AddBackupCounters[#1]{#2}% } - } @@ -2167,7 +2174,8 @@ \xassoccnt_is_coupledcounter:nTF {#1} { \xassoccnt_stepcounter_coupledcounters:n{#1} } {% No, not a coupled counter! - \cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {\l_tmpa_tl}% +% \cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {\l_tmpa_tl}% + \cs_gset_nopar:Npx \LastSteppedCounter {\tl_use:N \l_tmpa_tl}% \xassoccnt_countersinresetlist:n{\l_tmpa_tl}% \__xassoccnt_getresetlist:n {\l_tmpa_tl}% \seq_if_empty:NTF \l__xassoccnt_counterreset_seq @@ -2228,7 +2236,8 @@ \xassoccnt_is_suspendedcounter:nF{#1}{% \__xassoccnt_translate_countername:cn {l_tmpb_tl} {#1}% \xassoccnt_standardaddtocounter{\l_tmpb_tl}{#2}% - \cs_gset_nopar:Nn \__xassoccnt_lastaddtocounter: {\l_tmpb_tl}% +% \cs_gset_nopar:Nn \__xassoccnt_lastaddtocounter: {\l_tmpb_tl}% Remove this + \cs_gset_nopar:Npx \LastAddedToCounter {\tl_use:N \l_tmpb_tl}% }% % Now check if #1 is a total counter and set the property correspondingly \__xassoccnt_is_totalcounter:nT {#1} {% @@ -2264,6 +2273,7 @@ } } \cs_gset_nopar:Nn \__xassoccnt_lastsetdocumentcounter: {#2}% + \cs_gset_nopar:Npx \LastSetDocumentCounter {#2}% \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{\l_tmpa_tl}}% } @@ -2326,7 +2336,8 @@ \RenewDocumentCommand{\setcounter}{mm}{% \__xassoccnt_translate_countername:cn {l_tmpb_tl}{#1}% - \cs_gset_nopar:Nn \__xassoccnt_lastsetcounter: {#1} +% \cs_gset_nopar:Nn \__xassoccnt_lastsetcounter: {#1} + \cs_gset_nopar:Npx \LastSetCounter {#1} \xassoccnt_standardsetcounter{\tl_use:N \l_tmpb_tl}{#2}% \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{\l_tmpb_tl}}% \__xassoccnt_is_totalcounter:nT {#1} {% @@ -2338,45 +2349,21 @@ \RenewDocumentCommand{\refstepcounter}{m}{% \seq_if_in:NxF \g_xassoccnt_suspendedcnt_seq {#1} {% - \cs_gset_nopar:Nx \__xassoccnt_lastrefsteppedcounter: {#1} + \cs_gset_nopar:Npx \LastRefSteppedCounter {#1} \xassoccnt_standardrefstepcounter{#1}% \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#1}}% } } -%%%% Now some expandable 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}{% \int_use:N \g__xassoccnt_lastcountervalue_int } +%%%%% Wrappers for \newcounter etc. + \NewDocumentCommand{\NewDocumentCounter}{O{initial=\c_zero}mo}{% \seq_set_from_clist:Nx \l_tmpa_seq {#2} \seq_map_inline:Nn \l_tmpa_seq {% @@ -2388,17 +2375,6 @@ } } -%\NewDocumentCommand{\NewDocumentCounters}{O{initial=\c_zero}mo}{% -% \seq_map_inline:Nn \l_tmpa_seq {% -% \IfValueTF{#3}{% -% \NewDocumentCounter[#1]{##1}[#3]% -% }{% -% \NewDocumentCounter[#1]{##1}% -% }% -% }% -%} - - \NewDocumentCommand{\CopyDocumentCounters}{O{}mm}{% \__xassoccnt_copycounters:nnn{#1}{#2}{#3}% } @@ -2454,6 +2430,35 @@ } + +\cs_new_nopar:Npn \GetAllResetLists {% + \group_begin: + \def\@elt##1{% + \seq_gput_right:Nn \g_xassoccnt_all_latex_counters_seq {##1}% +% \seq_set:c { g_latex_cntr_##1_seq } + } + \cl@@ckpt% + \seq_map_inline:Nn \g_xassoccnt_all_latex_counters_seq {% + \def\@elt####1{####1,} + \seq_set_from_clist:cx { g_latex_cntr_##1_seq } { \use:c{cl@##1} } + } + % Now fill the parent counter lists + \seq_map_inline:Nn \g_xassoccnt_all_latex_counters_seq {% + \seq_map_inline:cn { g_latex_cntr_##1_seq }{ % + \prop_gput:Nnn \g_xassoccnt_latex_parentcounters_prop {####1} {##1} + } + } + \group_end: +} + + +% Gives the parent counter of a specific counter (or nothing) +\cs_new:Npn \GetParentCounter #1{% + \prop_item:No \g_xassoccnt_latex_parentcounters_prop {#1} +} + + + % Pretty printing counters \NewDocumentCommand{\PrettyPrintCounterName}{+mm}{% @@ -2944,50 +2949,137 @@ %%% Label features --- Experimental --- from 2017/03/03 -\NewDocumentCommand{\RedefineLabelCommand}{}{% - \bool_if:NT \g__xassoccnt_redefinelabel_bool { - +\seq_new:N \g_xassoccnt_pre_label_hooks_seq +\seq_new:N \g_xassoccnt_post_label_hooks_seq + +\cs_new:Nn \__xassoccnt_register_label_hook:nn {% + \group_begin: + \seq_set_from_clist:Nn \l_tmpa_seq {#2} + \seq_map_inline:Nn \l_tmpa_seq {% + \seq_gput_right:cn {g_xassoccnt_#1_label_hooks_seq} {\cs_to_str:N ##1} + } + \seq_gremove_duplicates:c {g_xassoccnt_#1_label_hooks_seq} + \group_end: +} + +\cs_new:Nn \__xassoccnt_clear_label_hooks:n { + \seq_gclear:c {g_xassoccnt_#1_label_hooks_seq } +} + +\cs_new:Nn \__xassoccnt_remove_from_label_hook:nn {% + \seq_gremove:cn {g_xassoccnt_#1_label_hooks_seq} {#2} +} + +\NewDocumentCommand{\RegisterPreLabelHook}{m}{% + \__xassoccnt_register_label_hook:nn {pre} {#1} +} + +\NewDocumentCommand{\RegisterPostLabelHook}{m}{% + \__xassoccnt_register_label_hook:nn {post} {#1} +} + +\NewDocumentCommand{\ClearPostLabelHook}{}{% + \__xassoccnt_clear_label_hooks:n {post} +} + +\NewDocumentCommand{\ClearPreLabelHook}{}{% + \__xassoccnt_clear_label_hooks:n {post} +} + + +\NewDocumentCommand{\RunLabelHooks}{mm}{% + \seq_if_exist:cT {g_xassoccnt_#1_label_hooks_seq} { + \seq_map_inline:cn {g_xassoccnt_#1_label_hooks_seq} {% + \cs_if_exist:cT {##1} { + \use:c{##1}{#2}% + } + } + } +} + +\NewDocumentCommand{\RunPreLabelHooks}{m}{% + \seq_if_exist:NT \g_xassoccnt_pre_label_hooks_seq { + \seq_map_inline:Nn \g_xassoccnt_pre_label_hooks_seq {% + \cs_if_exist:cT {##1} { + \use:c{##1}{#1}% + } + } + } +} + +\NewDocumentCommand{\RunPostLabelHooks}{m}{% + \seq_if_exist:NT \g_xassoccnt_post_label_hooks_seq { + \seq_map_inline:Nn \g_xassoccnt_post_label_hooks_seq {% + \cs_if_exist:cT {##1} { + \use:c{##1}{#1}% + } + } + } +} + +%%% + +\NewDocumentCommand{\ProvideOriginalLabelCommands}{}{% \cs_new:Nn \__xassoccnt_internal_label:n {% - \latex@@label{##1}% + \xassoccntlatex@@label{##1}% } \cs_new:Nn \__xassoccnt_internal_label:nn {% \bool_if:NTF \l__xassoccnt_cleverefpackage_loaded_bool {% - \latex@@label[##1]{##2}% + \xassoccntlatex@@label[##1]{##2}% }{ - \latex@@label{##2}% + \xassoccntlatex@@label{##2}% } } +} - \keys_define:nn {xassoccntlabel} {% - all .bool_set:N = \l_xassoccnt_allassociatedcounters_labeled_bool, - select .code:n= { \seq_set_from_clist:Nx \l_tmpa_seq { ##1 }\bool_set_false:N \l_xassoccnt_allassociatedcounters_labeled_bool }, - prefix .code:n={ \prop_put:Nnx \l_tmpa_prop {prefix} {##1} }, - prefix-sep .code:n={ \prop_put:Nnx \l_tmpa_prop {prefix-sep} {##1} } - } - \RenewDocumentCommand{\label}{omO{}}{% - \group_begin: - \prop_clear:N \l_tmpa_prop - \seq_clear:N \l_tmpa_seq - \keys_set:nn {xassoccntlabel} {all=true,prefix-sep={\xassoccnt_extract_moduledata:n{prefix-sep}},##3}% - % - \IfValueTF{##1}{% - % Generate the regular label - \__xassoccnt_internal_label:nn {##1} {##2} - }{% - \__xassoccnt_internal_label:n {##2} + +\NewDocumentCommand{\RedefineLabelCommand}{}{% + % Do only if redefinelabel=true was set as package option + \bool_if:NT \g__xassoccnt_redefinelabel_bool { + \keys_define:nn {xassoccntlabel} {% + all .bool_set:N = \l_xassoccnt_allassociatedcounters_labeled_bool, + select .code:n= { \seq_set_from_clist:Nx \l_tmpa_seq { ##1 }\bool_set_false:N \l_xassoccnt_allassociatedcounters_labeled_bool }, + prefix .code:n={ \prop_put:Nnx \l_tmpa_prop {prefix} {##1} }, + prefix-sep .code:n={ \prop_put:Nnx \l_tmpa_prop {prefix-sep} {##1} } } - \bool_if:NT \l_xassoccnt_allassociatedcounters_labeled_bool {% - % The prefix is made from the associated counter - \prop_remove:Nn \l_tmpa_prop {prefix} - \seq_set_eq:Nc \l_tmpa_seq {\__xassoccnt_drivercontainer:n{\LastRefSteppedCounter}} + \RenewDocumentCommand{\label}{omO{}}{% + \group_begin: + \prop_clear:N \l_tmpa_prop + \seq_clear:N \l_tmpa_seq + \keys_set:nn {xassoccntlabel} {all=true,prefix-sep={\xassoccnt_extract_moduledata:n{prefix-sep}},##3}% + % + \RunLabelHooks{pre}{##2}% + \IfValueTF{##1}{% + % Generate the regular label + \__xassoccnt_internal_label:nn {##1} {##2} + }{% + \__xassoccnt_internal_label:n {##2} + } + \RunLabelHooks{post}{##2}% + \bool_if:NT \l_xassoccnt_allassociatedcounters_labeled_bool {% + % The prefix is made from the associated counter + \prop_remove:Nn \l_tmpa_prop {prefix} + \seq_set_eq:Nc \l_tmpa_seq {\__xassoccnt_drivercontainer:n{\LastRefSteppedCounter}} + } + \seq_if_empty:NF \l_tmpa_seq {% Check whether either the only - list or the driver container list is empty (i.e. it was no driver container at all + % If non-empty -> generate the labels with the given naming scheme + \__xassoccnt_generate_associated_counters_labels:Nn \l_tmpa_seq {##2} + }% End of \seq_if_empty + \group_end: + }% End of \RenewDocumentCommand{\label} + }% End of bool_if:NT \g__xassoccnt_redefinelabel_bool +} + +\NewDocumentCommand{\LaTeXLabel}{om}{% + \bool_if:NTF \l__xassoccnt_cleverefpackage_loaded_bool {% + \IfValueTF{#1}{ + \xassoccntlatex@@label[#1]{#2}% + }{ + \xassoccntlatex@@label{#2}% } - \seq_if_empty:NF \l_tmpa_seq {% Check whether either the only - list or the driver container list is empty (i.e. it was no driver container at all - % If non-empty -> generate the labels with the given naming scheme - \__xassoccnt_generate_associated_counters_labels:Nn \l_tmpa_seq {##2} - }% End of \seq_if_empty - \group_end: - }% End of \RenewDocumentCommand{\label} + }{% + \xassoccntlatex@@label{#2}% } } @@ -3020,7 +3112,8 @@ \AtEndPreamble{% \AtBeginDocument{% - \LetLtxMacro\latex@@label\label + \LetLtxMacro\xassoccntlatex@@label\label + \ProvideOriginalLabelCommands% \RedefineLabelCommand% } } -- cgit v1.2.3