summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xassoccnt
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-04-30 20:33:07 +0000
committerKarl Berry <karl@freefriends.org>2017-04-30 20:33:07 +0000
commit5fd760969b1a06d4ef546ad1e06439f3ba3661dc (patch)
treef0f8e341a1767c6ae6d7833392f3edbea2dc53fd /Master/texmf-dist/tex/latex/xassoccnt
parentbd0a657da5b75949dc7a2dfdf2047b3b477ded45 (diff)
xassoccnt (30apr17)
git-svn-id: svn://tug.org/texlive/trunk@44127 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/xassoccnt')
-rw-r--r--Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty874
1 files changed, 803 insertions, 71 deletions
diff --git a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
index 628d992ce3f..932f421190f 100644
--- a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
+++ b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
@@ -1,4 +1,4 @@
-%% LaTeX package xassoccnt - version 1.3 (2017/03/05 -- 18:08:47)
+%% LaTeX package xassoccnt - version 1.4 (2017/04/30 -- 00:47:05)
%% Source file for xassoccnt.sty
%%
%%
@@ -19,10 +19,10 @@
%%
%%
-\def\xassoccntpackageversion{1.3}
+\def\xassoccntpackageversion{1.4}
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
-\ProvidesPackage{xassoccnt}[2017/03/05 - v\xassoccntpackageversion]
+\ProvidesPackage{xassoccnt}[2017/04/30 - v\xassoccntpackageversion]
\RequirePackage{etoolbox}
\RequirePackage{letltxmacro}
\RequirePackage{xcolor}
@@ -33,27 +33,51 @@
\ExplSyntaxOn
\newif\ifexplversionnew
-\explversionnewfalse
+\explversionnewtrue
% 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_set_split:Nnn {Nxn,cxn,Nxx,cxx,cox,Nox,Non,con}
\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_put:Nnn {cxx,nxx,nxn,cxn,Nxx,Nxn}
+\cs_generate_variant:Nn \prop_gput:Nnn {cxx,nxx,nxn,cxn,Nxx,Nxn,NVx,Nvn,cVn,cVx}
\cs_generate_variant:Nn \prop_remove:Nn {cx,Nx}
-\cs_generate_variant:Nn \prop_item:Nn {NV,cV,cx,No,co}
-\cs_generate_variant:Nn \int_set:Nn {NV,Nx}
+\cs_generate_variant:Nn \prop_gremove:Nn {Nx,cx,No,co,NV,cV}
+\cs_generate_variant:Nn \prop_item:Nn {NV,cV,cx,No,co,Nx,nx}
+\cs_generate_variant:Nn \int_set:Nn {NV,Nx,Nx,cx}
+\cs_generate_variant:Nn \cs_gset:Npn {NpV,Npv,cpV,cpv,cpo,Npo}
+\cs_generate_variant:Nn \tl_set:Nn {No,Nx,NV}
% First some local or global values
+% global/local scratch variables
+\seq_new:N \l__xassoccnt_tmpa_seq
+
+\tl_new:N \l__xassoccnt_tmpa_tl
+\tl_new:N \l__xassoccnt_tmpb_tl
+
+\tl_new:N \g__xassoccnt_tmpa_tl
+\tl_new:N \g__xassoccnt_tmpb_tl
+
+\prop_new:N \l__xassoccnt_tmpa_prop
+\prop_new:N \g__xassoccnt_tmpa_prop
+
+\int_new:N \g__xassoccnt_tmpa_int
+\int_new:N \l__xassoccnt_tmpa_int
+
+
+\bool_new:N \l__xassoccnt_alphalphpackage_loaded_bool
\bool_new:N \l__xassoccnt_hyperrefpackage_loaded_bool
\bool_new:N \l__xassoccnt_cleverefpackage_loaded_bool
+\prop_new:N \g__xassoccnt_loadedpackages_prop
+
\ifexplversionnew
\str_const:Nn \c__xassoccnt_modulename_str {xassoccnt}
\else
@@ -62,6 +86,9 @@
\bool_new:N \l__xassoccnt_calcpackage_loaded
+\int_const:Nn \c_xassoccnt_false_int {0}
+\int_const:Nn \c_xassoccnt_true_int {1}
+
\int_new:N \l__xassoccnt_initialcountervalue_int
\int_new:N \g__xassoccnt_lastcountervalue_int
@@ -90,13 +117,21 @@
% Reset of counters related 'variables'
+
+\seq_new:N \g_xassoccnt_reset_seq
\seq_new:N \l__xassoccnt_counterreset_seq
+% All counters
\seq_new:N \g_xassoccnt_all_latex_counters_seq
\prop_new:N \g_xassoccnt_latex_parentcounters_prop
+% Counter formats
+
+\prop_new:N \l_xassoccnt_counter_format_prop
+\prop_new:N \g_xassoccnt_counter_formatdata_prop
+
%%%
\int_new:N \g__xassoccnt_backupcalls_int
\int_new:N \l__xassoccnt_backuptmpa_int
@@ -104,7 +139,6 @@
\seq_new:N \l__xassoccnt_countervaluesbackup_seq
\seq_new:N \l__xassoccnt_backupresetlist_seq
\bool_new:N \l__xassoccnt_counternamestarred_bool % Not needed actually
-
\seq_new:N \g__xassoccnt_counternamesbackuplist_seq
@@ -137,6 +171,7 @@
\prop_gput:Nnn \g_xassoccnt_module_data_prop {scratchname} {scratch}
\prop_gput:Nnn \g_xassoccnt_module_data_prop {backupfeaturename} {backupcounters}
+\prop_gput:NnV \g_xassoccnt_module_data_prop {standardcounterformats} {\c_xassoccnt_true_int}
\prop_gput:Nnn \g_xassoccnt_module_data_prop {prefix-sep} {::}
@@ -145,6 +180,12 @@
}
+\cs_new:Npn \xasdata #1{%
+ \xassoccnt_extract_moduledata:n {#1}%
+}
+
+
+
\keys_define:nn {xassoccnt}
{
initial .code:n={ \int_set:Nn \l__xassoccnt_initialcountervalue_int {#1}},
@@ -208,9 +249,13 @@
supertotal .bool_set:N={\l__xassoccnt_is_supertotalcounter_bool },
- resetbackup .bool_set:N={\l__xassoccnt_resetbackupcounters_bool },
- redefinelabel .bool_set:N= { \g__xassoccnt_redefinelabel_bool }
-
+ resetbackup .bool_set:N=\l__xassoccnt_resetbackupcounters_bool ,
+ standardcounterformats .choice:,
+ standardcounterformats /on .code:n={\prop_gput:NnV \g_xassoccnt_module_data_prop {standardcounterformats} {\c_xassoccnt_true_int}},
+ standardcounterformats /off .code:n={\prop_gput:NnV \g_xassoccnt_module_data_prop {standardcounterformats} {\c_xassoccnt_false_int}},
+ redefinelabel .bool_set:N= { \g__xassoccnt_redefinelabel_bool },
+ map-name .code:n= { \prop_put:Nnn \g_xassoccnt_module_data_prop {map-name} {#1}},
+ counter-name .code:n= { \prop_put:Nnn \g_xassoccnt_module_data_prop {counter-name} {#1}}
}
\keys_define:nn {xassoccnt_periodiccounter} {%
@@ -229,7 +274,7 @@
}
-\keys_set:nn{xassoccnt}{nonumberofruns, redefinelabel=true}
+\keys_set:nn{xassoccnt}{nonumberofruns, redefinelabel=true,standardcounterformats=on}
\ProcessKeysOptions{xassoccnt}
@@ -242,6 +287,9 @@
Error:~Entity~#1~does~not~name~a~counter\\
}
+%Messages related to Counter formats
+\msg_new:nnn {xassoccnt} {counterformatnotdefined} {The~counter~format~"#1"~is~not~defined~for~counter~"#2"}
+\msg_new:nnn {xassoccnt} {counterformatwrongortooshort} {The~counter~format~for~"#1"~is~wrong~or~the~separator~is~missing}
\msg_new:nnn{xassoccnt}{crossassociation}{%
@@ -339,12 +387,100 @@
This~is~an~error!
}
+\msg_new:nnn{xassoccnt}{packagenotloadedfatal}{%
+ Error:~Package~"#1"~is~not~loaded~but~required~\\
+ This~is~an~error!
+}
+
+
\msg_new:nnn{xassoccnt}{containeralreadyexists}{%
Error:~Container~named~#1~already~exists\\
}
+\msg_new:nnn{xassoccnt}{languagemappingalreadyexists}{%
+ Warning:~Language~mapping~#1~already~exists!\\
+}
+
+
+\msg_new:nnn{xassoccnt}{undefinedlanguagemapping}{%
+ Error:~Language~mapping~#1~is~undefined!\\
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%
+
+\cs_new:Nn \xassoccnt_trackloadedpackages:n {%
+ \seq_set_from_clist:Nn \l_tmpa_seq {#1}
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \@ifpackageloaded{##1}{%
+ \prop_gput:Nnn \g__xassoccnt_loadedpackages_prop {##1} {\c_one}
+ }{%
+ \prop_gput:Nnn \g__xassoccnt_loadedpackages_prop {##1} {\c_zero}
+ }
+ }
+}
+
+\prg_new_conditional:Nnn \xassoccnt_package_loaded:n {T,F,TF}{%
+ \prop_if_in:NnTF \g__xassoccnt_loadedpackages_prop {#1} {%
+ \int_compare:nNnTF {\prop_item:Nn \g__xassoccnt_loadedpackages_prop {#1}} = {\c_zero } {\prg_return_false:} {\prg_return_true:}%
+ }{%
+ \prg_return_false:
+ }
+}
+
+\prg_new_conditional:Nnn \xassoccnt_package_notloaded:n {T,F,TF}{%
+ \prop_if_in:NnTF \g__xassoccnt_loadedpackages_prop {#1} {%
+ \int_compare:nNnTF {\prop_item:Nn \g__xassoccnt_loadedpackages_prop {#1}} = {\c_zero } {\prg_return_true:} {\prg_return_false:}%
+ }{%
+ \prg_return_true:
+ }
+}
+
+\prg_new_conditional:Nnn \__xassoccnt_package_notloaded_fatal:n {T,F,TF}{%
+ \xassoccnt_package_notloaded:nTF{#1}{%
+ \msg_error:nnn{xassoccnt}{packagenotloadedfatal}{#1}
+ }{%
+ \prg_return_true:
+ }
+}
+
+\cs_new:Nn \xassoccnt_package_notloaded_fatal:nn {%
+ \__xassoccnt_package_notloaded_fatal:nF {#1} {#2}
+}
+
+
+\NewDocumentCommand{\IfPackageLoadedT}{m+m}{%
+ \xassoccnt_package_loaded:nT {#1}{#2}
+}
+
+\NewDocumentCommand{\IfPackageLoadedF}{m+m}{%
+ \xassoccnt_package_loaded:nF {#1}{#2}
+}
+
+\NewDocumentCommand{\IfPackageLoadedTF}{m+m+m}{%
+ \xassoccnt_package_loaded:nTF {#1}{#2}{#3}
+}
+
+
+\NewDocumentCommand{\IfNotPackageLoadedTF}{m+m+m}{%
+ \xassoccnt_package_notloaded:nTF {#1}{#2}{#3}
+}
+
+\NewDocumentCommand{\IfNotPackageLoadedT}{m+m}{%
+ \xassoccnt_package_notloaded:nT {#1}{#2}
+}
+
+\NewDocumentCommand{\IfNotPackageLoadedF}{m+m}{%
+ \xassoccnt_package_notloaded:nF {#1}{#2}
+}
+
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%
+
\cs_new:Nn \__xassoccnt_intinc:n {\int_gincr:N \l_xassoccnt_resetlist_counter}%
@@ -366,17 +502,17 @@
\cs_new:Nn \xassoccnt_bootstrap_fullreset_list:n {%
- \begingroup
+ \group_begin:
\def\@elt##1{\seq_gput_right:cn {#1_fullresetlist_seq} {##1}}
\use:c{cl@#1}
- \endgroup
+ \group_end:
}
\cs_new:Nn \xassoccnt_local_list:nn {%
- \begingroup
+ \group_begin:
\def\@elt##1{\seq_gput_right:cn {#1} {##1}}
\use:c{cl@#2}
- \endgroup
+ \group_end:
}
@@ -413,8 +549,27 @@
}
+\NewDocumentCommand{\ClearCounterResetList}{sm}{%
+ \cs_if_exist:cT {cl@#2} {%
+ \seq_clear:N \l__xassoccnt_tmpa_seq
+ \xassoccnt_local_list:nn {l__xassoccnt_tmpa_seq} {#2}
+ \seq_map_inline:Nn \l__xassoccnt_tmpa_seq {
+ \IfBooleanTF{#1}{%
+ \CounterWithout*{##1}{#2}%
+ }{%
+ \CounterWithout{##1}{#2}%
+ }%
+ }
+ \IfBooleanF{#1}{%
+ \xassoccnt_default_counterformat:n{#2}
+ }%
+ \cs_gset_eq:cc {cl@#2} {relax}%
+ }
+}
+
\NewDocumentCommand{\RemoveFromReset}{mm}{%
+ \seq_clear:N \l_tmpa_seq
\xassoccnt_local_list:nn {l_tmpa_seq} {#2}
\seq_set_from_clist:Nn \l_tmpb_seq {#1}
\seq_map_inline:Nn \l_tmpb_seq {%
@@ -446,13 +601,63 @@
\__xassoccnt_latexcounter_exists:nTF {#2} {
\seq_set_from_clist:Nn \l_tmpa_seq {#1}
\seq_map_inline:Nn \l_tmpa_seq {%
- \@addtoreset{##1}{#2}%
- }
+ \__xassoccnt_ifinresetlist:nnF{##1}{#2}{%
+ % Do not add the master counter to its own reset list!
+ \tl_if_eq:nnF { ##1 } {#2} {%
+ \@addtoreset{##1}{#2}%
+ }%
+ }
+ }% End of \seq_map_inline
}{%
\msg_fatal:nnn{xassoccnt}{nameisnocounter}{#1}%
}%
}
+
+
+
+%%%% CounterWithin - Features
+
+
+\NewDocumentCommand{\CounterWithin}{smm}{%
+ \__xassoccnt_latexcounter_exists:nTF {#3} {%
+ \seq_set_from_clist:Nn \l_tmpa_seq {#2} %
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \__xassoccnt_ifinresetlist:nnF{##1}{#3}{%
+ % Do not add the master counter to its own reset list!
+ \tl_if_eq:nnF { ##1 } {#3} {%
+ \@addtoreset{##1}{#3}%
+ }%
+ \IfBooleanF{#1}{%
+ % Needs overhaul!
+ \cs_set:cpn {the##1} {\csname the#3\endcsname.\arabic{##1}}
+ }
+ }
+ }% End of \seq_map_inline
+ }{%
+ \msg_fatal:nnn{xassoccnt}{nameisnocounter}{#2}%
+ }%
+}
+
+
+\NewDocumentCommand{\CounterWithout}{smm}{%
+ \seq_clear:N \l_tmpa_seq
+ \xassoccnt_local_list:nn {l_tmpa_seq} {#3}
+ \seq_set_from_clist:Nn \l_tmpb_seq {#2}
+ \seq_map_inline:Nn \l_tmpb_seq {%
+ \IfBooleanF{#1}{%
+ \cs_set:cpn {the##1} {\arabic{##1}}%
+ }
+ \seq_remove_all:Nn \l_tmpa_seq {##1}%
+ }%
+ \cs_set:cpx {cl@#3}{\empty}
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \@addtoreset{##1}{#3}%
+ }
+}
+
+
+
%%%% The original counter related routines!
@@ -465,14 +670,24 @@
% Needed for Backup/Restore features
-%\AtBeginDocument{%
+
\AtEndPreamble{
+ \@ifpackageloaded{alphalph}{%
+ \bool_gset_true:N \l__xassoccnt_alphalphpackage_loaded_bool%
+ }{}%
\@ifpackageloaded{hyperref}{%
\bool_gset_true:N \l__xassoccnt_hyperrefpackage_loaded_bool%
}{}%
\@ifpackageloaded{cleveref}{%
\bool_gset_true:N \l__xassoccnt_cleverefpackage_loaded_bool%
}{}
+ \xassoccnt_trackloadedpackages:n{alphalph,calc,cleveref,hyperref}
+}
+
+\AtEndOfPackage{%
+ \@ifpackageloaded{alphalph}{%
+ \bool_gset_true:N \l__xassoccnt_alphalphpackage_loaded_bool%
+ }{}%
}
@@ -485,7 +700,8 @@
}{}
\AtEndOfPackage{
- \PackageInfo{xassoccnt}{2017/03/05 - v\xassoccntpackageversion -- stepping counters simultaneously and other features}
+ \PackageInfo{xassoccnt}{2017/04/30 - v\xassoccntpackageversion -- stepping counters simultaneously and other features}
+ \xassoccnt_trackloadedpackages:n{alphalph,calc,cleveref,hyperref}
\@ifpackageloaded{calc}{%
\msg_warning:nnn{xassoccnt}{incompatiblepackagenonfatal}{calc}% Warning
\bool_set_true:N \l__xassoccnt_calcpackage_loaded
@@ -609,7 +825,7 @@
}
\cs_new:Nn \__xassoccnt_autodefine_associatedcounters:nn {%
- \bool_if:nTF{ \g__xassoccnt_autodefine_counters }{%
+ \bool_if:NTF \g__xassoccnt_autodefine_counters {%
\seq_map_inline:Nn #2 { \__xassoccnt_newcounter_ltx:nnn {sloppy}{##1}{} }
}{%
\keys_set:nn{xassoccnt}{#1}
@@ -694,7 +910,9 @@
\cs_new:Nn \__xassoccnt_newcounter_ltx:nn{%
+ \group_begin:
\keys_set:nn {xassoccnt}{sloppy=false,initial=\c_zero,#1}
+% \__xassoccnt_declare_language_map:nn {\prop_item:Nn \g_xassoccnt_module_data_prop {map-name} }{#2;;\prop_item:Nn \g_xassoccnt_module_data_prop {counter-name}}
\cs_if_exist:cTF{c@#2}{%
\bool_if:nF {\l__xassoccnt_sloppy_newcounter }{
\msg_error:nnn{xassoccnt}{counteralreadyexists}{#2}% Warning
@@ -703,12 +921,14 @@
\newcounter{#2}%
\xassoccnt_standardsetcounter{#2}{\l__xassoccnt_initialcountervalue_int}
}%
+ \group_end:
}
\ifexplversionnew
\cs_new:Nn \__xassoccnt_newcounter_ltx:nnn{%
- \keys_set:nn {xassoccnt}{sloppy=false,initial=\c_zero,#1}
+ \group_begin:
+ \keys_set:nn {xassoccnt}{map-name=default,counter-name=#2,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 }{%
@@ -722,6 +942,7 @@
}%
\xassoccnt_standardsetcounter{#2}{\l__xassoccnt_initialcountervalue_int}%
}
+ \group_end:
}
\else
\cs_new:Nn \__xassoccnt_newcounter_ltx:nnn{%
@@ -745,27 +966,6 @@
-\cs_new:Nn \xassoccnt_declareassociatedcounters_old: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}
-}
-
-
-
\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
@@ -1855,7 +2055,7 @@
\NewDocumentCommand{\ClearBackupState}{O{}m}{%
\keys_set:nn {xassoccnt_container} {backup-id={},#1}
\xassoccnt_backup_clear_backupstate:nn { \__xassoccnt_backup_id_tl } {#2}
- \prop_map_inline:cn {\xassoccnt_backup_subproplist:n{#2}} {##1->##2\par}%
+ %\prop_map_inline:cn {\xassoccnt_backup_subproplist:n{#2}} {##1->##2\par}%
}
@@ -2135,7 +2335,6 @@
\NewDocumentCommand{\RemoveAllPeriodicCounters}{O{}}{%
\seq_map_inline:Nn \g_xassoccnt_periodiccounter_container_seq {\xassoccnt_remove_periodiccounter:nn {#1} {##1}}
-% \cs_new:Nn \xassoccnt_remove_periodiccounter:nn {%
\seq_gclear:N \g_xassoccnt_periodiccounter_container_seq
\prop_gclear:N \g_xassoccnt_periodiccounter_prop
}
@@ -2165,9 +2364,9 @@
%%%% Redefinition of standard counter macros
+\cs_set:Npn \stepcounter #1{%
-
-\RenewDocumentCommand{\stepcounter}{m}{%
+%\def\stepcounter#1{%
\__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}%
\xassoccnt_is_suspendedcounter:nF{#1}{%
\xassoccnt_stepcounter_periodiccounter:n {#1}%
@@ -2203,6 +2402,7 @@
}
}
+
\RenewDocumentCommand{\addtocounter}{mmO{}}{%
\xassoccnt_is_periodiccounter:nTF {#1}{%
\xassoccnt_addtocounter_periodiccounter:nnn {#1} {#2} {#3}%
@@ -2212,12 +2412,7 @@
}
-
-
-
-
-
-\NewDocumentCommand{\xassoccnt_addtocounter}{mmO{}}{%
+\NewDocumentCommand{\xassoccnt_addtocounterfoo}{mmO{}}{%
% Only add to a counter if this counter isn't on the suspended counters list!
\xassoccnt_is_suspendedcounter:nF{#1}{%
\__xassoccnt_translate_countername:cn {l_tmpb_tl} {#1}%
@@ -2231,12 +2426,11 @@
}
-\RenewDocumentCommand{\xassoccnt_addtocounter}{mmO{}}{%
+\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_translate_countername:cn {l_tmpb_tl} {#1}%
\xassoccnt_standardaddtocounter{\l_tmpb_tl}{#2}%
-% \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
@@ -2334,6 +2528,7 @@
}
+
\RenewDocumentCommand{\setcounter}{mm}{%
\__xassoccnt_translate_countername:cn {l_tmpb_tl}{#1}%
% \cs_gset_nopar:Nn \__xassoccnt_lastsetcounter: {#1}
@@ -2346,8 +2541,7 @@
}
-
-\RenewDocumentCommand{\refstepcounter}{m}{%
+\cs_set:Npn \refstepcounter #1 {%
\seq_if_in:NxF \g_xassoccnt_suspendedcnt_seq {#1} {%
\cs_gset_nopar:Npx \LastRefSteppedCounter {#1}
\xassoccnt_standardrefstepcounter{#1}%
@@ -2356,7 +2550,6 @@
}
-
\newcommand{\LastCounterValue}{%
\int_use:N \g__xassoccnt_lastcountervalue_int
}
@@ -2365,6 +2558,7 @@
%%%%% Wrappers for \newcounter etc.
\NewDocumentCommand{\NewDocumentCounter}{O{initial=\c_zero}mo}{%
+ \group_begin:
\seq_set_from_clist:Nx \l_tmpa_seq {#2}
\seq_map_inline:Nn \l_tmpa_seq {%
\IfValueTF{#3}{%
@@ -2373,6 +2567,7 @@
\__xassoccnt_newcounter_ltx:nnn{#1}{##1}{}
}
}
+ \group_end:
}
\NewDocumentCommand{\CopyDocumentCounters}{O{}mm}{%
@@ -2429,13 +2624,10 @@
\__xassoccnt_ifinresetlist:nnF{#2}{#3}{#4}%
}
-
-
\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 {%
@@ -2448,13 +2640,74 @@
\prop_gput:Nnn \g_xassoccnt_latex_parentcounters_prop {####1} {##1}
}
}
+ % \prop_show:N \g_xassoccnt_latex_parentcounters_prop %\g_latex_cntr_subsubsection_seq
\group_end:
}
+\cs_new:Nn \xassoccnt_full_reset_list_recursive_other:nn {
+ \seq_clear:N \l_tmpa_seq
+ \xassoccnt_local_list:nn {l_tmpa_seq} {#2}
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \seq_gput_right:cn {#1_fullresetlist_seq} {##1}%
+ \seq_remove_duplicates:c {#1_fullresetlist_seq } % Remove the duplicates
+ \xassoccnt_full_reset_list_recursive:nn {#1} {##1}% Recursive call
+ }
+}
+
+
% Gives the parent counter of a specific counter (or nothing)
\cs_new:Npn \GetParentCounter #1{%
- \prop_item:No \g_xassoccnt_latex_parentcounters_prop {#1}
+ \prop_if_in:NoT \g_xassoccnt_latex_parentcounters_prop {#1} {%
+ \prop_item:No \g_xassoccnt_latex_parentcounters_prop {#1}
+ }
+}
+
+
+
+
+\cs_new:Nn \__xassoccnt_parent_counter_chain:n {%
+ \int_gincr:N \g__xassoccnt_tmpa_int
+ \tl_set:Nx \l_tmpa_tl {#1}
+ \tl_set:Nx \l_tmpb_tl {\GetParentCounter{#1}}
+% \seq_show:N \l__xassoccnt_tmpa_seq
+ \seq_gput_right:Nx \l__xassoccnt_tmpa_seq {\GetParentCounter{#1}}
+ \seq_remove_duplicates:N \l__xassoccnt_tmpa_seq
+ \tl_set:Nx \l_tmpb_tl {\GetParentCounter{\l_tmpa_tl}}
+ \int_compare:nNnF{\tl_count:N \l_tmpb_tl } = {0} {
+ \__xassoccnt_parent_counter_chain:V{\l_tmpb_tl}
+ }
+}
+
+
+\cs_new:Nn \xassoccnt_parent_counter_chain:n {%
+ \prop_if_exist:cTF {g_xassoccnt_#1_counter_chain_prop}{
+ \prop_gclear:c {g_xassoccnt_#1_counter_chain_prop}
+ }{
+ \prop_new:c {g_xassoccnt_#1_counter_chain_prop}
+ }
+ \seq_if_exist:cTF {g_xassoccnt_#1_counter_chain_seq} {
+ \seq_gclear:c {g_xassoccnt_#1_counter_chain_seq}
+ }{
+ \seq_new:c {g_xassoccnt_#1_counter_chain_seq}
+ }
+ \prop_clear:N \g__xassoccnt_tmpa_prop
+ \seq_clear:N \l__xassoccnt_tmpa_seq
+
+ \int_gzero:N \g__xassoccnt_tmpa_int
+ \prop_gput:NVx \g__xassoccnt_tmpa_prop {\g__xassoccnt_tmpa_int} {#1}
+ \seq_gput_right:Nx \l__xassoccnt_tmpa_seq {#1}%
+ \__xassoccnt_parent_counter_chain:x{#1}
+ \seq_gset_eq:cN {g_xassoccnt_#1_counter_chain_seq} \l__xassoccnt_tmpa_seq
+ \seq_pop_right:cN {g_xassoccnt_#1_counter_chain_seq} \l_tmpa_tl
+ \prop_gset_eq:cN {g_xassoccnt_#1_counter_chain_prop} \l__xassoccnt_tmpa_prop
+}
+
+\cs_generate_variant:Nn \xassoccnt_parent_counter_chain:n {x,V}
+\cs_generate_variant:Nn \__xassoccnt_parent_counter_chain:n {x,V}
+
+\NewDocumentCommand{\GetParentCounterChain}{m}{%
+ \xassoccnt_parent_counter_chain:n{#1}
}
@@ -2515,11 +2768,25 @@
}
+\NewDocumentCommand{\DeclareTotalDocumentCounter}{O{}m}{%
+ \keys_set:nn {xassoccnt} {supertotal=false,#1}
+ \seq_set_from_clist:Nn \l_tmpa_seq {#2}
+ \seq_map_inline:Nn \l_tmpa_seq {
+ \__xassoccnt_ifis_latexcounter:nF {##1} {% Define the counter
+ \xassoccnt_declaredocumentcounter:nn{sloppy=false}{##1}%
+ }%
+ \__xassoccnt_registertotaldocumentcounter:nn{#1}{##1}
+ }
+}
+
+
+
\cs_new:Nn \__xassoccnt_store_totalcounter_value:n {%
- \prop_put:Nnn \g_xassoccnt_totalcounter_prop {#1} {\number\value{\__xassoccnt_expand_totalcountername:n{#1}}}
- \prop_put:Nnn \g_xassoccnt_totalcounter_prop {#1name} {\__xassoccnt_expand_totalcountername:n{#1}}
+ \prop_gput:Nnn \g_xassoccnt_totalcounter_prop {#1} {\number\value{\__xassoccnt_expand_totalcountername:n{#1}}}
+ \prop_gput:Nnn \g_xassoccnt_totalcounter_prop {#1name} {\__xassoccnt_expand_totalcountername:n{#1}}
+ \prop_gput:Nxx \g_xassoccnt_totalcounter_prop {\__xassoccnt_expand_totalcountername:n{#1}} {#1}% back reference
}
\cs_new:Nn \__xassoccnt_registertotaldocumentcounter:nn {%
@@ -2536,23 +2803,27 @@
\bool_if:NT \l__xassoccnt_is_supertotalcounter_bool {%
\__xassoccnt_add_supertotalcounter:n {#2}
}
- \AtEndDocument{%
- \__xassoccnt_writetotalcounters:nn {#2}{#2}
- }%
+% Removed on 2017/03/12
+% \AtEndDocument{%
+% \__xassoccnt_writetotalcounters:nn {#2}{#2}
+% }%
}%
}
+\cs_generate_variant:Nn \__xassoccnt_registertotaldocumentcounter:nn {nx}
+
\NewDocumentCommand{\RegisterTotalDocumentCounter}{O{}m}{%
\__xassoccnt_registertotaldocumentcounter:nn{#1}{#2}%
}
% Expandable version
-\newcommand{\TotalValue}[1]{%
+\cs_new:Npn \TotalValue #1{%
\prop_item:Nn \g_xassoccnt_totalcounter_prop {#1}%
}
-\cs_new:Nn \__xassoccnt_writetotalcounters:nn {%
+
+\cs_new:Nn \__xassoccnt_writetotalcounters_old:nn {%
\immediate\write\@mainaux {%
\string\IfIsDocumentCounterF\expandafter{\__xassoccnt_expand_totalcountername:n{#1}}{\string\DeclareDocumentCounter\expandafter{\__xassoccnt_expand_totalcountername:n{#1}}}
}
@@ -2567,6 +2838,33 @@
}
}
+\cs_generate_variant:Nn \__xassoccnt_writetotalcounters_old:nn {nx,xx}
+
+
+\cs_new_nopar:Nn \__xassoccnt_writetotalcounters_atend: {%
+ \seq_map_inline:Nn \g__xassoccnt_totalcounter_container {
+ \immediate\write\@mainaux{%
+ \string\IfIsDocumentCounterF{##1}{\string\DeclareDocumentCounter{##1}}^^J
+ }
+ \seq_if_in:NnTF \g__xassoccnt_supertotalcounter_container {##1} {%
+ \immediate\write\@mainaux{%
+ \string\setcounter{\__xassoccnt_expand_totalcountername:n{##1}}{\number\value{\__xassoccnt_expand_totalcountername:n{##1}}}%
+ }
+ }{%
+ \immediate\write\@mainaux{%
+ \string\setcounter{##1}{\number\value{\prop_item:Nn \g_xassoccnt_totalcounter_prop {##1}}}
+ }
+ }
+ }
+}
+
+\NewDocumentCommand{\WriteCountersAtEnd}{}{%
+ \__xassoccnt_writetotalcounters_atend:%
+}
+
+
+
+
\NewDocumentCommand{\TotalCounterInternalNameExp}{m}{%
\prop_item:Nn \g_xassoccnt_totalcounter_prop {#1name}%
}
@@ -2875,6 +3173,24 @@
}
+\NewDocumentCommand{\LoopCounterResetList}{mm}{%
+ \seq_gclear:N \g_xassoccnt_reset_seq
+ \group_begin:
+ \cs_if_exist:cT {cl@#1} {%
+ \def\@elt##1{%
+ \seq_gput_right:Nn \g_xassoccnt_reset_seq {##1}
+ }
+ \use:c{cl@#1}% Fill the list
+ }
+ \group_end:
+ \seq_map_inline:Nn \g_xassoccnt_reset_seq {%
+ \use:c{\cs_to_str:N #2}{#1}{##1}
+ }
+}
+
+
+
+
%%%%
%% Counter-Values-Mapping-To-Something-Different - Macros
@@ -2913,6 +3229,211 @@
}
+\cs_generate_variant:Nn \xassoccnt_declaredocumentcounter:nn {nx}
+
+
+%%% Counter Output
+
+
+\cs_new:Npn \BinaryValue#1{%
+ \int_to_bin:n{\number\value{#1}}%
+}
+
+\cs_new:Npn \hexValue#1{%
+ \int_to_hex:n{\number\value{#1}}%
+}
+
+\cs_new:Npn \HexValue#1{%
+ \int_to_Hex:n{\number\value{#1}}%
+}
+
+\cs_new:Npn \OctalValue#1{%
+ \int_to_oct:n{\number\value{#1}}%
+}
+
+
+\cs_new:Npn \xalphalph #1 {%
+ \int_to_alph:n{\number\value{#1}}
+}
+
+\cs_new:Npn \xAlphAlph #1 {%
+ \int_to_Alph:n{\number\value{#1}}
+}
+
+
+\cs_new:Nn \xassoccnt_default_counterformat:n{%
+ \arabic{#1}%
+}
+
+\cs_new:Nn \xassoccnt_alphalph_wrapper:n{%
+ \xassoccnt_package_notloaded:nTF {alphalph}{%
+ \cs_set:cpn {the#1}{\int_to_alph:n{\number\value{#1}}}
+ }{%
+ \cs_set:cpn {the#1}{\alphalph{\value{#1}}}
+ }
+}
+
+\cs_new:Nn \xassoccnt_AlphAlph_wrapper:n{%
+ \xassoccnt_package_notloaded:nTF {alphalph}{%
+ \cs_set:cpn {the#1}{\int_to_Alph:n{\number\value{#1}}}
+ }{%
+ \cs_set:cpn {the#1}{\AlphAlph{\value{#1}}}
+ }
+}
+
+
+\NewDocumentCommand{\alphalphinternal}{m}{%
+ \xassoccnt_alphalph_wrapper:n{#1}
+}
+
+\NewDocumentCommand{\AlphAlphinternal}{m}{%
+ \xassoccnt_AlphAlph_wrapper:n{#1}
+}
+
+
+
+
+\keys_define:nn {xassoccnt(COUNTERFORMAT)} {
+ separator .initial:n={!},
+ separator .code:n={\prop_put:Nnn \l__xassoccnt_tmpa_prop {counterformatseparator} {#1}},
+ recursive .bool_set:N=\l_tmpa_bool
+}
+
+
+\cs_new:Nn \__xassoccnt_add_counter_formats:nn {%
+ \group_begin:
+ \seq_set_from_clist:Nn \l_tmpa_seq {#2}
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \seq_set_split:Nxn \l_tmpb_seq {#1} {##1}
+ \int_compare:nNnTF {\seq_count:N \l_tmpb_seq } > {1} {
+ \prop_gput:Nxx \g_xassoccnt_counter_formatdata_prop {\seq_item:Nn \l_tmpb_seq {1}} { \seq_item:Nn \l_tmpb_seq {2} }
+ }{
+ \msg_fatal:nnx {xassoccnt}{counterformatwrongortooshort}{\seq_item:Nn \l_tmpb_seq {1}}
+ }
+ }
+ \group_end:
+}
+
+\cs_new:Nn \__xassoccnt_remove_counter_formats:nn {%
+ \seq_set_from_clist:Nn \l_tmpa_seq {#2}
+ \seq_map_inline:Nn \l_tmpa_seq {
+ \prop_gremove:Nx \g_xassoccnt_counter_formatdata_prop {##1}
+ }
+}
+
+
+
+\NewDocumentCommand{\StoreCounterFormats}{O{}m}{%
+ \group_begin:
+ \keys_set:nn {xassoccnt(COUNTERFORMAT)}{separator=!,#1}
+ \__xassoccnt_add_counter_formats:nn {\prop_item:Nn \l__xassoccnt_tmpa_prop {counterformatseparator}}{#2}
+ \group_end:
+}
+
+\NewDocumentCommand{\AddCounterFormats}{O{}m}{%
+ \group_begin:
+ \keys_set:nn {xassoccnt(COUNTERFORMAT)}{separator={!},#1}
+ \__xassoccnt_add_counter_formats:nn {\prop_item:Nn \l__xassoccnt_tmpa_prop {counterformatseparator}}{#2}
+ \group_end:
+}
+
+\NewDocumentCommand{\RemoveCounterFormats}{O{}m}{%
+ % First optional arg is reserved for later purposes
+ \__xassoccnt_remove_counter_formats:nn {}{#2}
+}
+
+\NewDocumentCommand{\ClearCounterFormats}{}{%
+ \prop_gclear:N \g_xassoccnt_counter_formatdata_prop
+}
+
+\NewDocumentCommand{\ShowCounterFormats}{}{%
+ \prop_map_inline:Nn \g_xassoccnt_counter_formatdata_prop {##1~uses~\cs_to_str:N ##2\par}
+}
+
+
+
+
+% \seq_item 1 / seq_item 2
+\cs_new:Nn \__xassoccnt_set_counterformat:nnn{%
+ \group_begin:
+ \tl_clear:N \l_tmpb_tl
+ \int_compare:nNnTF {#1} > {1} {%
+ \tl_set:Nx \l_tmpb_tl {#3}
+ }{% Only one or less arguments -> use \arabic as counter format}
+ \tl_set:Nn \l_tmpb_tl {n} % Arabic counter format (ar)
+ }
+ \prop_if_in:NVTF \g_xassoccnt_counter_formatdata_prop {\l_tmpb_tl} {%
+ \tl_clear:N \l_tmpa_tl
+ \tl_put_right:Nx \l_tmpa_tl { \prop_item:NV \g_xassoccnt_counter_formatdata_prop {\l_tmpb_tl}{#2}}
+ \cs_gset:cpV {the #2} {\l_tmpa_tl}
+ }{%
+ \msg_fatal:nnxx {xassoccnt}{counterformatnotdefined}{\tl_use:N \l_tmpb_tl}{#2}
+ }
+ \group_end:
+}
+
+
+\cs_new:Nn \xassoccnt_set_counterformat:n {%
+ \seq_set_split:Nxn \l_tmpb_seq {\prop_item:Nn \l__xassoccnt_tmpa_prop {counterformatseparator}} {#1}
+
+ \__xassoccnt_set_counterformat:nnn { \seq_count:N \l_tmpb_seq }{ \seq_item:Nn \l_tmpb_seq {1}} { \seq_item:Nn \l_tmpb_seq {2} }
+}
+
+
+
+
+
+\NewDocumentCommand{\CounterFormat}{O{}m}{%
+ \group_begin:
+ \keys_set:nn {xassoccnt(COUNTERFORMAT)}{recursive=false,separator={!},#1}
+ \bool_if:NTF \l_tmpa_bool {%
+ \xassoccnt_recursive_counter_format:n{#2}
+ }{%
+ \seq_set_from_clist:Nx \l_tmpa_seq {#2}
+ \seq_map_inline:Nn \l_tmpa_seq {%
+ \xassoccnt_set_counterformat:n {##1}
+ }
+ }
+ \group_end:
+}
+
+\cs_new:Nn \__xassoccnt_recursive_counter_format:nn {%
+ \tl_set:Nx \l__xassoccnt_tmpb_tl {#2}%
+ \xassoccnt_parent_counter_chain:n {#1}
+ \seq_if_exist:cT {g_xassoccnt_#1_counter_chain_seq}{
+ \seq_map_inline:cn {g_xassoccnt_#1_counter_chain_seq } {%
+ \int_incr:N \l__xassoccnt_tmpa_int
+ \int_compare:nNnTF{ \l__xassoccnt_tmpa_int} < {\seq_count:c {g_xassoccnt_#1_counter_chain_seq}} {%
+ \int_set:NV \l_tmpa_int { \l__xassoccnt_tmpa_int }
+ \int_incr:N \l_tmpa_int
+ \tl_set:Nn \l_tmpa_tl {\csname}
+ \tl_put_right:Nx \l_tmpa_tl {the\seq_item:cn {g_xassoccnt_#1_counter_chain_seq} {\l_tmpa_int}}
+ \tl_put_right:Nn \l_tmpa_tl {\endcsname.}
+ \tl_put_right:NV \l_tmpa_tl {\l__xassoccnt_tmpb_tl{##1}}
+ }{%
+ % Last element of the list, must only have its own representation usually, say \arabic{
+ \tl_clear:N \l_tmpa_tl
+ \tl_put_right:NV \l_tmpa_tl {\l__xassoccnt_tmpb_tl{##1}}
+ }
+ \cs_gset:cpV {the##1} {\l_tmpa_tl}
+ }
+ }% End of \seq_if_exist:cT
+}
+
+\cs_new:Nn \xassoccnt_recursive_counter_format:n {%
+ \group_begin:
+ \seq_set_split:Nxn \l_tmpb_seq {\prop_item:Nn \l__xassoccnt_tmpa_prop {counterformatseparator}} {#1}
+ % Get format
+ \tl_clear:N \l_tmpb_tl
+ \int_compare:nNnTF {\seq_count:N \l_tmpb_seq} > {1} {%
+ \tl_set:Nx \l_tmpb_tl {\seq_item:Nn \l_tmpb_seq {2}}
+ }{% Only one or less arguments -> use \arabic as counter format}
+ \tl_set:Nn \l_tmpb_tl {n} % Arabic counter format (n)
+ }
+ \__xassoccnt_recursive_counter_format:nn {\seq_item:Nn \l_tmpb_seq {1}}{\prop_item:NV \g_xassoccnt_counter_formatdata_prop {\l_tmpb_tl}}
+ \group_end:
+}
+
%%%%%%%%%%%%%%%%%%%%
@@ -3084,6 +3605,212 @@
}
+%%%%%%%%%%%%%%%%%%%%
+
+%%% Counter names to human language maps
+
+\seq_new:N \g_xassoccnt_language_map_seq
+
+
+\cs_new:Nn \__xassoccnt_declare_language_map:n {%
+ \seq_set_from_clist:Nx \l_tmpa_seq {#1}
+ \seq_map_inline:Nn \l_tmpa_seq {
+ \seq_gput_right:Nn \g_xassoccnt_language_map_seq {##1}
+ \prop_if_exist:cF {g_xassoccnt_language_map_##1_prop } {
+ \prop_new:c { g_xassoccnt_language_map_##1_prop }
+ }
+ }
+}
+
+\cs_new:Nn \__xassoccnt_new_language_mapping:n {
+ \seq_if_in:NnTF \g_xassoccnt_language_map_seq {#1} {
+ \msg_warning:nnn{xassoccnt}{languagemappingalreadyexists} {#1}
+ }{
+ \__xassoccnt_declare_language_map:n {#1}
+ }
+}
+
+
+\cs_new:Nn \__xassoccnt_declare_language_map:nn {
+ \__xassoccnt_new_language_mapping:n {#1 }
+ \__xassoccnt_add_language_mappings:nn {#1} {#2}
+% \seq_set_from_clist:Nx \l_tmpa_seq {#2}
+% \seq_new:c { g_xassoccnt_language_map_#1_seq }
+% \seq_map_inline:Nn \l_tmpa_seq {
+% \__xassoccnt_split_mapping_sequence:nn {#1} {##1}
+% }
+% \prop_log:c {g_xassoccnt_language_map_#1_prop }
+
+}
+
+\cs_new:Nn \__xassoccnt_add_language_mappings:nn {%
+ \group_begin:
+ \seq_set_from_clist:Nx \l_tmpa_seq {#2}
+ \seq_if_exist:cF { g_xassoccnt_language_map_#1_seq } {
+ \seq_new:c { g_xassoccnt_language_map_#1_seq }
+ }
+ \seq_map_inline:Nn \l_tmpa_seq {
+ \__xassoccnt_split_mapping_sequence:nn {#1} {##1}
+ }
+ \group_end:
+}
+
+
+\cs_new:Nn \__xassoccnt_use_if_empty:nn {%
+ \int_compare:nNnTF {\tl_count:n {#2} } = {0} {
+ #1
+ }{%
+ #2
+ }
+}
+
+\cs_generate_variant:Nn \__xassoccnt_use_if_empty:nn {nx,no,xx,xn}
+
+
+\cs_new:Nn \prop_put_uppercase_first:Nnn {
+ \prop_put:Nnn #1 {#2} {\__xassoccnt_uppercase_first:n {#3}}
+}
+
+\cs_new:Nn \prop_gput_uppercase_first:Nnn {%
+ \typeout{Content~is~#3}
+ \tl_set:Nn \l_tmpa_tl {#3}
+ %\__xassoccnt_uppercase_first:n {
+ \typeout{Content is \tl_use:N \l_tmpa_tl}
+ \prop_gput:NnV #1 {#2} {\l_tmpa_tl }
+}
+
+
+\cs_new:Nn \prop_gput_uppercase_first:Nnnn {%
+ \tl_if_empty:nTF {#4} {
+ \prop_gput:Nnx #1 {#2} {\__xassoccnt_uppercase_first:n {#3}}
+ }{
+ \prop_gput:NnV #1 {#2} {\__xassoccnt_uppercase_first:n {#4}}
+ }
+% \tl_set:Nn \l_tmpa_tl {#3}
+% %\__xassoccnt_uppercase_first:n {
+% \typeout{Content is \tl_use:N \l_tmpa_tl}
+% \prop_gput:NnV #1 {#2} {\l_tmpa_tl }
+}
+
+
+\cs_new:Nn \__xassoccnt_uppercase_first:n {%
+ \tl_upper_case:n {\tl_head:n{#1}}\tl_tail:n{#1}
+% \typeout{ \tl_upper_case:n {\tl_head:n{#1}}\tl_tail:n{#1}}%
+% \typeout{ \tl_upper_case:n {\tl_head:n{#1}}\tl_tail:n{#1}}
+}
+
+\cs_generate_variant:Nn \__xassoccnt_uppercase_first:n {x,o,c,V}
+
+\cs_generate_variant:Nn \prop_put_uppercase_first:Nnn {Nxx,Nnx,Nno,Nxn, cxn, cno,cxx,cnn}
+\cs_generate_variant:Nn \prop_gput_uppercase_first:Nnn {Nxx,Nnx,Nno,Nxn, cxn, cno,cxx,cnn}
+
+\cs_generate_variant:Nn \prop_gput_uppercase_first:Nnnn {Nxxx,Nnxx,cxxx,cnnn}
+
+
+
+
+\cs_new:Nn \__xassoccnt_split_mapping_sequence:nn {%
+ \group_begin:
+ \seq_set_split:Nnn \l_tmpb_seq {;;} {#2}
+ \seq_gput_right:cx {g_xassoccnt_language_map_#1_seq } { \seq_item:Nn \l_tmpb_seq {1}}
+ \int_compare:nNnT { \seq_count:N \l_tmpb_seq } = { \c_one }
+ {
+ % Append the first element to be the reference entry
+ \seq_put_right:Nx \l_tmpb_seq { \seq_item:Nn \l_tmpb_seq {1} }
+ }
+% \seq_map_inline:Nn \l_tmpb_seq {\typeout{##1~}}
+ \typeout{Checking arg 2}
+ \prop_gput:cxx { g_xassoccnt_language_map_#1_prop } {\seq_item:Nn \l_tmpb_seq {1}-singular} {\__xassoccnt_use_if_empty:xn{\seq_item:Nn \l_tmpb_seq {2}}{\seq_item:Nn \l_tmpb_seq {2}}}
+ \typeout{Checking arg 3}
+ \prop_gput:cxx { g_xassoccnt_language_map_#1_prop } {\seq_item:Nn \l_tmpb_seq {1}-plural} {\__xassoccnt_use_if_empty:xn{\seq_item:Nn \l_tmpb_seq {2}}{\seq_item:Nn \l_tmpb_seq {3}}}
+ \typeout{Checking arg 4}
+% \prop_gput_uppercase_first:cxx { g_xassoccnt_language_map_#1_prop } {\seq_item:Nn \l_tmpb_seq {1}-uppercase-singular} {\__xassoccnt_use_if_empty:xn{\seq_item:Nn \l_tmpb_seq {2}}{\seq_item:Nn \l_tmpb_seq {4}}}
+
+ \prop_gput_uppercase_first:cxxx { g_xassoccnt_language_map_#1_prop } {\seq_item:Nn \l_tmpb_seq {1}-uppercase-singular} {\seq_item:Nn \l_tmpb_seq {2}}{\seq_item:Nn \l_tmpb_seq {4}}
+
+ \prop_gput_uppercase_first:cxxx { g_xassoccnt_language_map_#1_prop } {\seq_item:Nn \l_tmpb_seq {1}-uppercase-plural} {\seq_item:Nn \l_tmpb_seq {2}}{\seq_item:Nn \l_tmpb_seq {5}}
+
+
+% \prop_gput:cxx { g_xassoccnt_language_map_#1_prop } {\seq_item:Nn \l_tmpb_seq {1}-uppercase-singular} {\__xassoccnt_uppercase_first:x{\__xassoccnt_use_if_empty:nn{\seq_item:Nn \l_tmpb_seq {2}}{\seq_item:Nn \l_tmpb_seq {4}}}}
+% \prop_gput:cxx { g_xassoccnt_language_map_#1_prop } {\seq_item:Nn \l_tmpb_seq {1}-uppercase-plural} {\__xassoccnt_uppercase_first:x{\__xassoccnt_use_if_empty:nn{\seq_item:Nn \l_tmpb_seq {2}s}{\seq_item:Nn \l_tmpb_seq {5}}}}
+% \prop_show:c { g_xassoccnt_language_map_#1_prop }
+ \group_end:
+}
+
+
+
+% \seq_show:N \l_tmpb_seq
+% \prop_gput:cxx { g_xassoccnt_language_map_#1_prop } {\seq_item:Nn \l_tmpb_seq {1}} {\__xassoccnt_use_if_empty:xn{\seq_item:Nn \l_tmpb_seq {2}}{\seq_item:Nn \l_tmpb_seq {1}}}
+
+
+\cs_generate_variant:Nn \__xassoccnt_declare_language_map:nn {nx,xx}
+\cs_generate_variant:Nn \__xassoccnt_declare_language_map:n {x}
+
+
+\NewDocumentCommand{\DeclareLanguageMap}{m}{%
+ \__xassoccnt_declare_language_map:n {#1}
+}
+
+\NewDocumentCommand{\DeclareLanguageMappings}{m+m}{%
+ \__xassoccnt_declare_language_map:nn {#1}{#2}
+}
+
+\NewDocumentCommand{\AddLanguageMappings}{m+m}{%
+ \__xassoccnt_add_language_mappings:nn{#1}{#2}%
+}
+
+
+
+\cs_generate_variant:Nn \prop_map_inline:Nn {Nx,cx}
+
+\NewDocumentCommand{\ShowLanguageMappings}{m}{%
+ \seq_map_inline:cn {g_xassoccnt_language_map_#1_seq }{%
+ ##1 ~ \prop_item:cx { g_xassoccnt_language_map_#1_prop } { ##1-singular } ~ \prop_item:cx { g_xassoccnt_language_map_#1_prop } { ##1-plural } ~ \prop_item:cx { g_xassoccnt_language_map_#1_prop } { ##1-uppercase-singular } ~ \prop_item:cx { g_xassoccnt_language_map_#1_prop } { ##1-uppercase-plural } \par
+ }
+ %\prop_map_inline:cn {g_xassoccnt_language_map_#1_prop }{#1 ~ ##1 ~ ##2 \par}
+}
+
+
+\cs_new:Npn \RetrieveCounterSingularName #1#2{%
+ \prop_item:cn {g_xassoccnt_language_map_#1_prop }{#2-singular}
+}
+
+\cs_new:Npn \SetLanguageMapping #1 {%
+ \seq_if_in:NnTF \g_xassoccnt_language_map_seq {#1} {
+ \prop_gput:Nnn \g_xassoccnt_module_data_prop {currentlanguage} {#1}
+ }{% Begin of False
+ \msg_error:nnn{xassoccnt}{undefinedlanguagemapping}{#1}
+ }% End of False
+}
+
+\cs_new:Npn \GetLanguageMapping {%
+ \prop_item:Nn \g_xassoccnt_module_data_prop {currentlanguage}
+}
+
+
+
+\cs_new:Npn \xassingularname #1#2 {%
+ \prop_item:cn {g_xassoccnt_language_map_#1_prop }{#2-singular}
+}
+
+\cs_new:Npn \xaspluralname #1#2 {%
+ \prop_item:cn {g_xassoccnt_language_map_#1_prop }{#2-plural}
+}
+
+
+%%%%%%%%%%%%%%%%%%%
+
+% This is ad-hoc code for a yet - to be defined bool <-> prop list matching code
+
+\cs_new:Npn \PropertyHasValueTF #1#2#3#4 {%
+ \int_compare:nNnTF {\prop_item:Nn \g_xassoccnt_module_data_prop {#1}} = {#2} {
+ #3
+ }{%
+ #4
+ }
+}
+
+
\ExplSyntaxOff
\EnableNumberofrunsTF{%
@@ -3103,7 +3830,7 @@
-\@onlypreamble{\NewTotalDocumentCounter}
+\@onlypreamble{\DeclareTotalDocumentCounter}
\@onlypreamble{\RegisterTotalDocumentCounter}
\@onlypreamble{\DeclareAssociatedCounters}
\@onlypreamble{\DeclareTotalAssociatedCounters}
@@ -3119,9 +3846,15 @@
}
\AtBeginDocument{%
+ \PropertyHasValueTF{standardcounterformats} {1} {%
+ \StoreCounterFormats{n!\arabic, b!\BinaryValue,h!\hexValue,H!\HexValue,r!\roman,R!\Roman,A!\Alph,a!\alph,aa!\xalphalph,o!\OctalValue,AA!\xAlphAlph}%
+ }{}
\DeclareBackupCountersGroupName{scratch}%
}
+\AtEndDocument{%
+ \WriteCountersAtEnd%
+}
%%% Colour output routines
@@ -3131,7 +3864,6 @@
\newcommand{\TotalCounterInfoColor}{violet}
-
\AddFeature[sublists=true,publicname={Coupled Counters Feature}]{coupledcounters}
\AddFeature[sublists=true,publicname={Backup Counters Feature}]{backupcounters} % New style, not fully implemented so far