-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunimath-addn.tex
124 lines (94 loc) · 2.69 KB
/
unimath-addn.tex
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
% Families
\cs_new_protected_nopar:Nn \um_new_unsafe_family:nnN {
\um_if_overwrite:nNT { family } #3 {
\um_declare_family:nN { #1 } #3
}
}
\cs_new_protected_nopar:Nn \um_new_safe_family:nnN {
\um_declare_family:nn { #1 } #3
}
\cs_new_protected_nopar:Nn \um_declare_family:nN {
\exp_args:Nc \um_declare_family:NN { g_um_ #1 _fam }
}
\cs_new_protected_nopar:Nn \um_declare_family:NN {
\chk_if_free_cs:N #1
\newfam #1
\DeclareDocumentCommand #2 { m } {
\c_group_begin_token:
\um_switch_to_default_mapping:
\fam #1
##1
\c_group_end_token:
}
}
\cs_new_protected_nopar:Nn \um_set_default_family:n {
\int_set_eq:Nc \g_um_default_fam { g_um_ #1 _fam }
}
\int_new:N \g_um_default_fam
% Mappings
\cs_new_protected_nopar:Nn \um_new_unsafe_mapping:nnN {
\um_if_overwrite:nNT { mapping } #3 {
\um_declare_mapping:nN { #1 } { #2 } #3
}
}
\cs_new_protected_nopar:Nn \um_new_safe_mapping:nnN {
\um_declare_mapping:nN { #1 } { #2 } #3
}
\cs_new_protected_nopar:Nn \um_declare_mapping:nnN {
\exp_args:Ncc \um_declare_mapping:NNN { um_switch_to_ #1 : } { bool_set_ #2 :N } #3
}
\cs_new_protected_nopar:Nn \um_declare_mapping:NNN {
\chk_if_free_cs:N #1
\DeclareDocumentCommand #3 { m } {
\c_group_begin_token:
\fam \g_um_default_fam
#2 \l_um_default_mapping_bool
#1
##1
\c_group_end_token:
}
}
\cs_new_protected_nopar:Nn \um_set_default_mapping:n {
\exp_args:Nc \um_set_default_mapping:N { um_switch_to_ #1 : }
}
\cs_new_protected_nopar:Nn \um_set_default_mapping:N {
\cs_set_protected_nopar:Nn \um_switch_to_default_mapping: {
\bool_if:NF \l_um_default_mapping_bool {
#1
}
}
}
\chk_if_free_cs:N \um_switch_to_default_mapping:
\bool_new:N \l_um_default_mapping_bool
% Classes
\int_const:Nn \c_um_class_ordinary { 0 }
\int_const:Nn \c_um_class_operator { 1 }
\int_const:Nn \c_um_class_binary { 2 }
\int_const:Nn \c_um_class_relation { 3 }
\int_const:Nn \c_um_class_open { 4 }
\int_const:Nn \c_um_class_close { 5 }
\int_const:Nn \c_um_class_punctuation { 6 }
\int_const:Nn \c_um_class_variable { 7 }
% Mathematical codes
\cs_new_protected_nopar:Nn \um_assign_mathcode:nNNn {
\luatexUmathcode #1~ #2 #3 #4~
}
% Delimiter codes
\cs_new_protected_nopar:Nn \um_assign_delcode:nNn {
\luatexUdelcode #1~ #2 #3~
}
% Mathematical character definitions
\cs_new_protected_nopar:Nn \um_new_unsafe_chdef:NNNn {
\um_if_overwrite:nNT { mathchardef } #1 {
\um_declare_chdef:nN #1 #2 #3 { #4 }
}
}
\cs_new_protected_nopar:Nn \um_new_safe_chdef:NNNn {
\um_declare_chdef:nn #1 #2 #3 { #4 }
}
\cs_new_protected_nopar:Nn \um_declare_chdef:NNNn {
\luatexUmathchardef #1 #2 #3 #4~
}
% Local Variables:
% mode: LaTeX
% End: