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
174
175
176
177
178
179
180
181
182
183
184
185
186
// Copyright © 2026 Mikhail Hogrefe
//
// This file is part of Malachite.
//
// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.
use cratelatex_spelling;
use crateVarScheme;
use ;
// Each Greek alphabet is 24 letters that Unicode lays out over 25 code points, with one place in
// the middle taken by something that is not one of the 24: among the lowercase letters it is the
// final sigma, a second form of a letter already counted, and among the uppercase letters it is
// unassigned. Writing the letters out rather than counting from the first one keeps that gap from
// having to be described twice, and shows at a glance which characters are meant.
const GREEK_LETTERS: = ;
const GREEK_CAPS_LETTERS: = ;
// Writes a Greek letter as a LaTeX math-mode fragment.
//
// LaTeX has a macro for a Greek letter only where that letter is not already a Latin one to look
// at: there is a `\Gamma` and a `\Sigma`, but no `\Alpha` or `\Rho`, since an `A` and a `P` are
// what those are set with. The table that spells `char`s for LaTeX draws exactly that line already,
// so the spelling is read off it rather than written out a second time. A spelling from that table
// is either a macro or a single Latin letter, and each stands in math mode as it is.
//
// Every Greek letter is in the table, which is why the spelling is taken rather than asked for.
/// A scheme that names variables `α`, `β`, `γ`, and so on, through `ω`.
///
/// The names are the 24 lowercase Greek letters. The final sigma `ς` is not among them: it is a
/// second form of a letter that is already there, and two names for one variable is exactly what a
/// scheme may not have.
///
/// There are 24 letters, so this scheme's [`capacity`](VarScheme::capacity) is 24.
///
/// In LaTeX a letter is written with its macro where it has one, and as the Latin letter it looks
/// like where it does not, since LaTeX has no `\omicron`. In Typst the letter is written as itself.
///
/// # Examples
/// ```
/// use malachite_base::strings::latex::ToLatex;
/// use malachite_base::strings::typst::ToTypst;
/// use malachite_base::vars::VarScheme;
/// use malachite_base::vars::greek::GreekVars;
///
/// assert_eq!(GreekVars.capacity(), Some(24));
/// assert_eq!(GreekVars.var(0).to_string(), "α");
/// assert_eq!(GreekVars.var(17).to_string(), "σ");
/// assert_eq!(GreekVars.var(23).to_string(), "ω");
/// assert_eq!(GreekVars.var(0).to_latex_string(), r"\alpha");
/// assert_eq!(GreekVars.var(14).to_latex_string(), "o");
/// assert_eq!(GreekVars.var(0).to_typst_string(), "α");
/// ```
;
/// A scheme that names variables `Α`, `Β`, `Γ`, and so on, through `Ω`.
///
/// This is [`GreekVars`] in capitals, for when the lowercase letters are wanted for something else.
/// The 24 letters skip the one unassigned code point that Unicode leaves among them.
///
/// # Examples
/// ```
/// use malachite_base::strings::latex::ToLatex;
/// use malachite_base::strings::typst::ToTypst;
/// use malachite_base::vars::VarScheme;
/// use malachite_base::vars::greek::GreekCapsVars;
///
/// assert_eq!(GreekCapsVars.capacity(), Some(24));
/// assert_eq!(GreekCapsVars.var(0).to_string(), "Α");
/// assert_eq!(GreekCapsVars.var(17).to_string(), "Σ");
/// assert_eq!(GreekCapsVars.var(23).to_string(), "Ω");
/// assert_eq!(GreekCapsVars.var(2).to_latex_string(), r"\Gamma");
/// assert_eq!(GreekCapsVars.var(0).to_latex_string(), "A");
/// assert_eq!(GreekCapsVars.var(0).to_typst_string(), "Α");
/// ```
;
impl_greek!;
impl_greek!;