01
02
03
04
05
06
07
08
09
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
#!/bin/python
import re, unicodedata
from pylatexenc import latexencode
def uni_name(c: str) -> str:
try:
return unicodedata.name(c).lower()
except ValueError:
return None
def tex(c: str) -> str:
try:
l = latexencode.utf8tolatex(c, brackets=False, fail_bad_chars=True)
except ValueError:
return None
l = l.replace('boldsymbol', 'mathbf')
m = re.match(r'\\ensuremath{(\\.+)}', l)
if m:
return m.group(1)
elif l.startswith('\\text') and l.endswith('arrow'):
return l.replace('text', '')
else:
return l
math_chars = set()
# Operators
math_chars |= {chr(c) for c in range(0x2200, 0x22FF + 1)}
# Alpha numeric symbols
math_chars |= {chr(c) for c in range(0x1d400, 0x1d7ff + 1)}
# Suplemental operators
math_chars |= {chr(c) for c in range(0x2a00, 0x2aff + 1)}
# Miscellaneous symbols (A)
math_chars |= {chr(c) for c in range(0x27c0, 0x27ef + 1)}
# Miscellaneous symbols (B)
math_chars |= {chr(c) for c in range(0x2980, 0x29FF + 1)}
# Greek and Coptic
math_chars |= {chr(c) for c in range(0x0370, 0x3ff + 1)}
# APL symbols
math_chars |= {chr(c) for c in range(0x2336, 0x237a + 1)} | {chr(0x2395)}
# Letterlike symbols
math_chars |= {chr(c) for c in range(0x2100, 0x214f + 1)}
# Superscripts
math_chars |= {chr(c) for c in range(0x2070, 0x207f + 1)}
# Subscripts
math_chars |= {chr(c) for c in range(0x2080, 0x2093 + 1)}
# Arrows
math_chars |= {chr(c) for c in range(0x2190, 0x21ff + 1)}
math_chars = {(c, uni_name(c)) for c in math_chars}
math_chars = {(c, name, f'{ord(c):X}') for c, name in math_chars if name}
for char, name, code in sorted(math_chars, key=lambda x: (x[1], x[0])):
print(f'{char} {name}; {code};')
tex_equivalent = tex(char)
if tex_equivalent:
print(f'{char} {tex_equivalent}; {code};')