Ian Jauslin
summaryrefslogtreecommitdiff
blob: d15deb57247779163eec8e34e90db85a26c46736 (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
%%
%% constants package:
%%   automatically numbered constants
%%

%% TeX format
\NeedsTeXFormat{LaTeX2e}[1995/12/01]

%% package name
\ProvidesPackage{constants}[2016/11/19]

%% declare new constant
\def\cst#1#2{%
  % check whether the constant was defined
  \ifcsname cst@#1@#2\endcsname%
    #1_{\csname cst@#1@#2\endcsname}%
  \else%
    % check whether this character has a counter associated to it
    \ifcsname thecst@#1@@count\endcsname%
    \else%
      \newcounter{cst@#1@@count}%
    \fi%
    % increment counter
    \stepcounter{cst@#1@@count}%
    \expandafter\xdef\csname cst@#1@#2\endcsname{\csname thecst@#1@@count\endcsname}#1_{\csname thecst@#1@@count\endcsname}%
  \fi
}


%% end
\endinput