summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/caption/totalcount.sty
blob: a4bbd5786a5f22975d8262dbe0042694537f3ac4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
%%
%% This is file `totalcount.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% totalcount.dtx  (with options: `package')
%% 
%% Copyright (C) 1994-2020 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
%% 
%% https://gitlab.com/axelsommerfeldt/caption
%% 
%% --------------------------------------------------------------------------
%% 
%% 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 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Axel Sommerfeldt.
%% 
%% This work consists of the files
%%   caption.ins, caption.dtx, caption2.dtx, caption3.dtx,
%%   bicaption.dtx, ltcaption.dtx, subcaption.dtx, totalcount.dtx,
%% the derived files
%%   caption.sty, caption2.sty, caption3.sty,
%%   bicaption.sty, ltcaption.sty, subcaption.sty, totalcount.sty,
%% and the user manuals
%%   caption-deu.tex, caption-eng.tex, caption-rus.tex.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{totalcount}[2018/01/21 v1.0a Total values of counters (AR)]
\newcommand*\DeclareTotalCounter[1]{%
  \newcounter{totalcount@#1}%
  \@namedef{total#1s}{\nfss@text{\reset@font\bfseries ??}}%
  \@namedef{total#1es}{\@nameuse{total#1s}}%
  \expandafter\newif\csname iftotal#1s\endcsname
  \@namedef{iftotal#1es}{\@nameuse{iftotal#1s}}%
  \AtBeginDocument{\@ifundefined{c@#1}%
    {\PackageError{totalcount}{Undefined counter `#1'}\@ehc}%
    {\@cons\totalcount@counters{{#1}}}}}
\@onlypreamble\DeclareTotalCounter
\let\totalcount@counters\@empty
\newcommand*\totalcount@xspace{}
\DeclareOption{xspace}{\renewcommand*\totalcount@xspace{\xspace}}
\DeclareOption*{\expandafter\DeclareTotalCounter\expandafter{\CurrentOption}}
\ProcessOptions\relax
\ifx\totalcount@xspace\@empty\else
  \RequirePackage{xspace}
\fi
\newcommand*\totalcount@addtocounter[1]{%
  \@ifundefined{c@totalcount@#1}{}{%
    \addtocounter{totalcount@#1}{\value{#1}}}}
\let\totalcount@stpelt@ORI\@stpelt
\renewcommand*\@stpelt[1]{%
  \totalcount@addtocounter{#1}%
  \totalcount@stpelt@ORI{#1}}
\newcommand*\totalcount@set[2]{%
  \@ifundefined{c@totalcount@#1}%
    {}%
    {\global\@namedef{total#1s}{#2\totalcount@xspace}%
     \ifnum#2<1\relax \else
       \global\@nameuse{total#1strue}%
     \fi}}
\AtBeginDocument{\AtEndDocument{%
  \begingroup
    \@tempswafalse
    \if@filesw
      \immediate\write\@mainaux{%
        \string\providecommand\string\totalcount@set[2]{}}%
    \fi
    \def\@elt#1{%
      \totalcount@addtocounter{#1}%
      \edef\totalcount@tempa{\the\value{totalcount@#1}}%
      \expandafter\let\expandafter\totalcount@tempb\csname total#1s\endcsname
      \@expandtwoargs\totalcount@set{#1}{\totalcount@tempa}%
      \expandafter\ifx\csname total#1s\endcsname\totalcount@tempb \else
        \@tempswatrue
      \fi
      \if@filesw
        \immediate\write\@mainaux{%
          \string\totalcount@set{#1}{\totalcount@tempa}}%
      \fi}%
    \totalcount@counters
    \if@tempswa
      \PackageWarningNoLine{totalcount}{%
        Total counter(s) have changed.\MessageBreak
        Rerun to get them right}%
    \fi
  \endgroup}}%
\endinput
%%
%% End of file `totalcount.sty'.