-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetavars.sty
More file actions
84 lines (72 loc) · 2.12 KB
/
metavars.sty
File metadata and controls
84 lines (72 loc) · 2.12 KB
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
\ProvidesPackage{metavars}
\RequirePackage{amsfonts}
\RequirePackage{mfirstuc}
\RequirePackage{xspace}
% Applies the default display style for meta variables.
\newcommand\@metavars@style[1]{%
#1%
}
% Defines a new meta variable with type #1 and name #2 to display as #3.
\newcommand\@metavars@add[3]{%
\ifcsname @metavars@#1@#2\endcsname
\PackageError{meta-variables}{variable "#2" already defined}{}%
\else
\expandafter\newcommand\csname @metavars@#1@#2\endcsname{#3}%
\fi%
}
% Returns the definition of a meta variable with type #1 and name #2.
\newcommand\@metavars@lookup[2]{%
\ifcsname @metavars@#1@#2\endcsname
\csname @metavars@#1@#2\endcsname%
\else
\PackageError{meta-variables}{undefined variable "#2"}{}%
\fi%
}
% Defines a new meta variable.
% The definition should include styling as no default styling is applied.
\newcommand\NewCustomMetaVariable[2]{%
\@metavars@add{meta}{#1}{#2}%
}
% Defines a new meta variable, set, and universe.
% The definition should include styling as no default styling is applied.
\newcommand\NewCustomMetaTriple[4]{%
\@metavars@add{meta}{#1}{#2}%
\@metavars@add{metaset}{#1}{#3}%
\@metavars@add{universe}{#1}{#4}%
}
% Defines a new meta variable with default styling.
\newcommand\NewMetaVariable[2]{%
\NewCustomMetaVariable%
{#1}%
{\@metavars@style{#2}}%
}
% Defines a new meta variable, set, and universe with default styling.
\newcommand\NewMetaTriple[2]{%
\NewCustomMetaTriple%
{#1}%
{\@metavars@style{#2}}%
{\@metavars@style{\makefirstuc{#2}}}%
{\mathbb{\makefirstuc{#2}}}%
}
% A meta variable that stands for a single arbitrary object.
\newcommand\meta[1]{%
\ensuremath{%
\@metavars@lookup{meta}{#1}%
}\xspace%
}
% A meta variable that stands for an arbitrary set of objects.
\newcommand\metaset[1]{%
\ensuremath{%
\@metavars@lookup{metaset}{#1}%
}\xspace%
}
% The set of all objects (of a kind).
\newcommand\universe[1]{%
\ensuremath{%
\@metavars@lookup{universe}{#1}%
}\xspace%
}
% Showcases all forms of a meta variable.
\newcommand\showcase[1]{%
\ensuremath{\meta{#1} \in \metaset{#1} \subseteq \universe{#1}}%
}