summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xassoccnt
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-11-15 23:54:09 +0000
committerKarl Berry <karl@freefriends.org>2015-11-15 23:54:09 +0000
commit3c77a0b2cd0c8da653ad55d5b6c0c44a567e249f (patch)
tree835eadf598cc1073a73d354a4e72f3a92e706710 /Master/texmf-dist/tex/latex/xassoccnt
parent3dc8864da1f30b905db0e9a10a5cad3478907bab (diff)
xassoccnt (14nov15)
git-svn-id: svn://tug.org/texlive/trunk@38868 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/xassoccnt')
-rw-r--r--Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty160
1 files changed, 111 insertions, 49 deletions
diff --git a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
index af5d532a123..2ca160fb86d 100644
--- a/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
+++ b/Master/texmf-dist/tex/latex/xassoccnt/xassoccnt.sty
@@ -1,16 +1,42 @@
-\def\xassoccntpackageversion{0.1}
+%% LaTeX package xassoccnt - version 0.2 (2015/11/14 -- 16/08/33)
+%% Source file for xassoccnt.sty
+%%
+%%
+%% -------------------------------------------------------------------------------------------
+%% Copyright (c) 2015 by Dr. Christian Hupfer <christian dot hupfer at yahoo dot de>
+%% -------------------------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%%
+%%
+%% This work has the LPPL maintenance status `author-maintained`
+%%
+%%
+
+\def\xassoccntpackageversion{0.2}
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{xassoccnt}[2015/11/07 - v\xassoccntpackageversion]
+\ProvidesPackage{xassoccnt}[2015/11/14 - v\xassoccntpackageversion]
\RequirePackage{xcolor}
\RequirePackage{xparse}
\RequirePackage{l3keys2e}
+
\ExplSyntaxOn
% First some local or global values
+\str_const:Nn \c__xassoccnt_modulename_str {xassoccnt}
+
+\bool_new:N \l__xassoccnt_calcpackage_loaded
+
\int_new:N \l__xassoccnt_initialcountervalue_int
\int_new:N \g__xassoccnt_lastcountervalue_int
@@ -29,6 +55,7 @@
\bool_new:N \l__xassoccnt_countertype_associated
+\seq_new:N \l__xassoccnt_counterreset_seq
\cs_new:Nn \__xassoccnt_toggle_bool:n {%
\bool_if:nTF{#1}{\bool_set_false:n {#1}}{\bool_set_false:n {#1}}
@@ -115,7 +142,22 @@
---~#2~---
}
-\cs_new:Nn \__xassoccnt_stpelt:n{\global\csname c@#1\endcsname \c_minus_one\xassoccnt_addtocounter{#1}{\c_one}}%
+
+\msg_new:nnn{xassoccnt}{incompatiblepackagenonfatal}{%
+ Warning:~Package~"#1"~is~loaded~--~this~is~not~recommended~for~\c__xassoccnt_modulename_str\\
+}
+
+\msg_new:nnn{xassoccnt}{packageloadedafterfatal}{%
+ Error:~Package~"#1"~is~loaded~after~\c__xassoccnt_modulename_str~\\
+ This~is~an~error!
+}
+
+
+
+\cs_new:Nn \__xassoccnt_stpelt:n{\global\csname c@#1\endcsname\c_minus_one\xassoccnt_addtocounter{#1}{\c_one}}%
+
+%\cs_new:Nn \__xassoccnt_stpelt:n{\global\csname c@#1\endcsname\c_minus_one\xassoccnt_addtocounter{#1}{\c_one}}%
+
\cs_new:Nn \__xassoccnt_intinc:n {\int_gincr:N \l_xassoccnt_resetlist_counter}%
@@ -138,6 +180,30 @@
\cs_set_eq:NN \xassoccnt_standardaddtocounter \addtocounter
\cs_set_eq:NN \xassoccnt_standardsetcounter \setcounter
+% A little patch for perpage
+
+\@ifpackageloaded{perpage}{%
+ \msg_warning:nnn{xassoccnt}{incompatiblepackagenonfatal}{perpage}% Warning
+ \def\pp@cl@end@iii\xassoccnt_standardstepcounter#1{}
+}{}
+
+\AtEndOfPackage{
+ \@ifpackageloaded{calc}{%
+ \msg_warning:nnn{xassoccnt}{incompatiblepackagenonfatal}{calc}% Warning
+ \bool_set_true:N \l__xassoccnt_calcpackage_loaded
+ }{}%
+}
+
+\AtBeginDocument{%
+ % Recheck if `calc` isn't loaded after this package
+ \@ifpackageloaded{calc}{%
+ \bool_if:nF { \l__xassoccnt_calcpackage_loaded } {%
+ \msg_error:nnn{xassoccnt}{packageloadedafterfatal}{calc}% Error!
+ }%
+ }{}%
+}
+
+
\cs_new_nopar:Nn \__xassoccnt_laststeppedcounter: {}
\cs_new_nopar:Nn \__xassoccnt_lastrefsteppedcounter: {}
\cs_new_nopar:Nn \__xassoccnt_lastaddtocounter: {}
@@ -580,31 +646,44 @@
-\RenewDocumentCommand{\stepcounter}{m}{%
+
+
+\cs_new:Nn \__xassoccnt_step_associatedcounters:n {%
+ \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#1} }
+ { \seq_map_inline:cn {\__xassoccnt_drivercontainer:n{#1} }
+ { \xassoccnt_addtocounter{##1}{\c_one} }
+ }
+ % End of \seq_if_exist
+}
+
+
+
+
+\RenewDocumentCommand{\stepcounter}{m}{%
\xassoccnt_is_suspendedcounter:nF{#1}{%
\cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {#1}%
\xassoccnt_countersinresetlist:n{#1}%
- \int_compare:nTF{%
- \l_xassoccnt_resetlist_counter > \c_zero
- }{%
- \xassoccnt_standardaddtocounter{#1}{\c_one}%
- \begingroup
- \cs_set_eq:NN \@elt \__xassoccnt_stpelt:n
- \use:c{cl@#1}
- \endgroup
- }{%
+ \__xassoccnt_getresetlist:n {#1}%
+ \seq_if_empty:NTF \l__xassoccnt_counterreset_seq
+ {%
+ \xassoccnt_standardaddtocounter{#1}{\c_one}% Use the original one!
+ \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#1}}%
+ \__xassoccnt_step_associatedcounters:n {#1}
+ }{ % reset list is not empty!
+ % This is the replacement of \csname cl@#1\endcsname
\xassoccnt_standardaddtocounter{#1}{\c_one}
- }
- \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#1}}%
- \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#1} }
- { \seq_map_inline:cn {\__xassoccnt_drivercontainer:n{#1} }
- { \xassoccnt_addtocounter{##1}{\c_one} }
- }% End of \seq_if_exist
- }%
+ \seq_map_inline:Nn \l__xassoccnt_counterreset_seq {%
+ \csname c@##1\endcsname\c_minus_one
+ \xassoccnt_standardstepcounter{##1}%{\c_one}%
+ }
+ \__xassoccnt_step_associatedcounters:n {#1} % step the remaining associated counters
+ }% End of not empty reset list
+ } % end of not suspended counter
}
+
\NewDocumentCommand{\xassoccnt_addtocounter}{mmO{}}{%
% Only add to a counter if this counter isn't on the suspended counters list!
\xassoccnt_is_suspendedcounter:nF{#1}{%
@@ -658,36 +737,18 @@
\int_zero:N \l_tmpa_int
}
-
-
-
-
-% Extended support layer for counters
-\NewDocumentCommand{\SetDocumentCounterOld}{O{associatedtoo=false}mm}{%
- \xassoccnt_standardsetcounter{#2}{#3}%
- \clist_clear:N \l__xassoccnt_onlycounters_clist
- \keys_set:nn {xassoccnt}{#1}%
- \bool_if:nTF {\l__xassoccnt_setcounter_associated } {%
- \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#2} }
- { \seq_map_inline:cn {\__xassoccnt_drivercontainer:n{#2} }
- { \xassoccnt_standardsetcounter{##1}{#3} }
- }% End of \seq_if_exist
- }{%
- % Check whether the `onlycounters` - clist is empty -- if not, loop through the list
- \clist_if_empty:NF \l__xassoccnt_onlycounters_clist {%
- \seq_if_exist:cT { \__xassoccnt_drivercontainer:n{#2} }
- {
- \clist_map_inline:Nn \l__xassoccnt_onlycounters_clist
- { % Check first if ##1 is associated to #2 at all
- \xassoccnt_is_associatedtocounter:nnT {#2} {##1} { \xassoccnt_standardsetcounter{##1}{#3} }
- }
- }
- }
- }
- \cs_gset_nopar:Nn \__xassoccnt_lastsetdocumentcounter: {#2}%
- \int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#2}}%
+\cs_new:Nn \__xassoccnt_getresetlist:n {%
+ \begingroup
+ \seq_gclear:N \l__xassoccnt_counterreset_seq
+ \def\@elt##1{\seq_gput_right:Nn \l__xassoccnt_counterreset_seq {##1} }
+ \use:c{cl@#1}
+ \endgroup
}
+\newcommand{\showresetlist}[1]{%
+ \__xassoccnt_getresetlist:n {#1}
+ \seq_use:Nn \l__xassoccnt_counterreset_seq {\par}
+}
\NewDocumentCommand{\SetDocumentCounter}{O{associatedtoo=false}mm}{%
\__xassoccnt_setdocumentcounter:nnn {#1}{#2}{#3} % copy the driver counter value to all associated counters
@@ -711,6 +772,7 @@
\RenewDocumentCommand{\refstepcounter}{m}{%
\cs_gset_nopar:Nn \__xassoccnt_lastrefsteppedcounter: {#1}
+% \stepcounter{#1}%
\xassoccnt_standardrefstepcounter{#1}%
\int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{#1}}%
}
@@ -743,7 +805,6 @@
\newcommand{\LastCounterValue}{%
-%\NewDocumentCommand{\LastCounterValue}{}{%
\int_use:N \g__xassoccnt_lastcountervalue_int
}
@@ -768,6 +829,7 @@
}
+
\newcommand{\countersresetlistcount}[1]{%
\int_zero:N \l_xassoccnt_resetlist_counter%
\xassoccnt_countersinresetlist:n{#1}%