summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-03-05 21:39:46 +0000
committerKarl Berry <karl@freefriends.org>2017-03-05 21:39:46 +0000
commit80eb6890ed8748ee4e3da233c40143094c31c971 (patch)
tree57023688fe2bc5c84e2ca687959c4b14dd1050d4 /Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
parentb285d50cc7e7b5dd13f1ba3f1859b9f6dc5abb02 (diff)
xassoccnt (5mar17)
git-svn-id: svn://tug.org/texlive/trunk@43408 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty')
-rw-r--r--Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty257
1 files changed, 175 insertions, 82 deletions
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 <typography dot with dot latex at gmail dot com>
+%% Copyright (c) 2017 by Dr. Christian Hupfer <typography dot with dot latex at gmail dot com>
%% -------------------------------------------------------------------------------------------
%%
%% 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%
}
}