summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/constants/constants.sty
blob: d4ee664be289f5802af268d050416d71a904cb43 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
%%
%% This is file `constants.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% constants.dtx  (with options: `package')
%%  ----------------------------------------------------------------
%%  The constants package --- Automatic labelling of constants
%%  Maintained by Antoine Lejay
%%  Based on ltxref.dtx of the Latex Kernel (Copyright the LaTeX 3 project).
%%  Released under the LaTeX Project Public License v1.3c or later
%%  See http://www.latex-project.org/lppl.txt
%%  ----------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{constants}%
  [2008/03/25 v.1 Labeling and numbering constants]
\PackageInfo{constants}
  {This package aims to label et number constants in a mathematical proof.}
\RequirePackage{keyval}
\def\@if@constant@exists#1#2#3{\@ifundefined{cst@family@#1}{#3}{#2}}
\global\@namedef{cst@family@normal}{}
\newcounter{cst@counter@normal}
\def\cst@format@normal#1{\arabic{#1}}
\def\cst@symbol@normal{C}
\newcommand{\newconstantfamily}[2]{
\@if@constant@exists{#1}{%
\PackageError{constants}{The family of constants '#1' already exists}{%
Use \protect\renewconstantfamily\space to override}}%
{%
\expandafter\def\csname cst@family@#1\endcsname{}
\expandafter\def\csname cst@format@#1\endcsname{\cst@format@normal}
\expandafter\def\csname cst@symbol@#1\endcsname{\cst@symbol@normal}
\expandafter\newcounter{cst@counter@#1}
\define@key{constants}{format}%
{\expandafter\def\csname cst@format@#1\endcsname{##1}}
\define@key{constants}{symbol}%
{\expandafter\def\csname cst@symbol@#1\endcsname{##1}}
\define@key{constants}{reset}{\@addtoreset{cst@counter@#1}{##1}}
\setkeys{constants}{#2}
}}
\newcommand{\renewconstantfamily}[2]{
\@if@constant@exists{#1}{
\define@key{constants}{format}{%
\expandafter\def\csname cst@format@#1\endcsname{##1}}
\define@key{constants}{symbol}{%
\expandafter\def\csname cst@symbol@#1\endcsname{##1}}
\define@key{constants}{reset}{\@addtoreset{cst@counter@#1}{##1}}
\setkeys{constants}{#2}
}{%
\PackageError{constants}{The family of constants '#1' already exists}{%
Use \protect\renewconstantfamily\space to override}}%
}
\@onlypreamble\newconstantfamily
\@onlypreamble\renewconstantfamily
\def\G@refundefinedconstanttrue{%
  \gdef\@refundefinedconstant{%
    \@latex@warning@no@line{%
There were undefined references to constants}}}
\let\@refundefinedconstant\relax
\def\cst@tmp@format{cst@undefined@format}
\def\cst@tmp@symbol{cst@undefined@symbol}
\long\def\@firstofthree#1#2#3{#1}
\long\def\@secondofthree#1#2#3{#2}
\long\def\@thirdofthree#1#2#3{#3}
\def\cst@undefined@format#1{}
\def\cst@undefined@symbol{%
\nfss@text{\reset@font\textrm{C\textsuperscript{st}\textbf{??}}}}
\def\@setrefconstant#1#2#3{%
  \ifx#1\relax
   \protect\G@refundefinedconstanttrue
   \nfss@text{\reset@font\bfseries ??}%
   \@latex@warning{Reference to constant `#3' on page \thepage \space
             undefined}%
  \else
   \expandafter#2#1\null
  \fi}
\def\@setfamconstant#1#2#3{%
\ifx#1\relax%
\def\cst@tmp@format{cst@undefined@format}\null
\def\cst@tmp@symbol{cst@undefined@symbol}\null
\else%
\def\cst@tmp@format{cst@format@\expandafter#2#1}\null
\def\cst@tmp@symbol{cst@symbol@\expandafter#2#1}\null
\fi}
\newcounter{cst@tmp@counter}
\def\@setcounterconstant#1#2#3{%
  \ifx#1\relax
   \protect\G@refundefinedconstanttrue
   \@latex@warning{Reference to constant `#3' on page \thepage \space
             undefined}%
  \else
    \setcounter{cst@tmp@counter}{\expandafter#2#1}\null
\fi}
\def\refconstant#1{%
\expandafter\@setrefconstant\csname cstr@#1\endcsname\@firstofthree{#1}}
\def\familyconstant#1{%
\expandafter\@setfamconstant\csname cstr@#1\endcsname\@thirdofthree{#1}}
\def\counterconstant#1{%
\expandafter\@setcounterconstant%
\csname cstr@#1\endcsname\@firstofthree{#1}}
\newcommand{\Cr}[1]{%
\counterconstant{#1}%
\familyconstant{#1}%
{\@nameuse{\cst@tmp@symbol}}_{\@nameuse{\cst@tmp@format}{cst@tmp@counter}}}
\newcommand{\C}[1][normal]{%
\@if@constant@exists{#1}{%
\expandafter\refstepcounterconstant{cst@counter@#1}%
{\@nameuse{cst@symbol@#1}}_{\@nameuse{cst@format@#1}{cst@counter@#1}}}%
{\PackageError{constants}{Family for constants '#1' not defined}{
Check the name or use \protect\newconstantfamily}}%
}
\newcommand{\Cl}[2][normal]{\C[#1]\labelconstant{#2}{\string #1}}
\def\pagerefconstant#1{%
\expandafter\@setrefconstant\csname cstr@#1\endcsname
   \@secondofthree{#1}}
\def\refstepcounterconstant#1{\stepcounter{#1}%
    \protected@edef\@currentlabelconstant
       {\csname p@#1\endcsname\csname the#1\endcsname}%
}
\def\@newl@belconstant#1#2#3{{%
  \@ifundefined{#1@#2}%
    \relax
    {\gdef \@multiplelabelsconstant {%
       \@latex@warning@no@line{%
There were multiply-defined labels for constants}}%
     \@latex@warning@no@line{Label for constant `#2' multiply defined}}%
  \global\@namedef{#1@#2}{#3}
}}
\def\@currentlabelconstant{}
\def\newlabelconstant{\@newl@belconstant{cstr}}
\@onlypreamble\@newl@belconstant
\let \@multiplelabelsconstant \relax
\def\labelconstant#1#2{\@bsphack
  \protected@write\@auxout{}%
 {\string\newlabelconstant{#1}{{\@currentlabelconstant}{\thepage}{#2}}}%
  \@esphack}
\AtEndDocument{
\clearpage
\let\@newl@belconstant\@empty
\begingroup
     \if@filesw
       \immediate\closeout\@mainaux
       \let\@setckpt\@gobbletwo
       \let\@newl@belconstant\@testdef
       \let\@newl@bel\@testdef
       \@tempswafalse
       \makeatletter \input\jobname.aux
     \fi
\@refundefinedconstant
     \if@filesw
       \ifx \@multiplelabelsconstant \relax
         \if@tempswa
           \@latex@warning@no@line{%
Label(s) for constants may have changed.
                Rerun to get cross-references right}%
         \fi
       \else
         \@multiplelabelsconstant
       \fi
     \fi
\endgroup
\deadcycles\z@\@@end
}
\newcommand{\resetconstant}[1][normal]{%
\@if@constant@exists{#1}{%
\setcounter{cst@counter@#1}{0}}{%
{\PackageError{constants}{Family for constants '#1' not defined}{%
Check the name or use \protect\newconstantfamily}}%
}}
\endinput
%%
%% End of file `constants.sty'.