Debian Codegraph @

texmf-dist/source/latex/unicode-math/um-code-sscript.dtx

raw
1 %%^^A%% um-code-sscript.dtx -- part of UNICODE-MATH <wspr.io/unicode-math>
2 %%^^A%% Setup for active chars needed to process subscript/superscript input chars.
3
4 % \section{Unicode sub- and super-scripts}
5 %
6 % \begin{macrocode}
7 %<*package>
8 % \end{macrocode}
9 %
10 % The idea here is to enter a scanning state after a superscript or subscript
11 % is encountered.
12 % If subsequent superscripts or subscripts (resp.) are found,
13 % they are lumped together.
14 % Each sub/super has a corresponding regular size
15 % glyph which is used by \XeTeX\ to typeset the results; this means that the
16 % actual subscript/superscript glyphs are never seen in the output
17 % document~--- they are only used as input characters.
18 %
19 % Open question: should the superscript-like `modifiers' (\unichar{1D2C}
20 % {modifier capital letter a} and on) be included here?
21 %
22 % \paragraph{Superscripts}
23 % Populate a property list with superscript characters; themselves as their
24 % key, and their replacement as each key's value.
25 % Then make the superscript active and bind it to the scanning function.
26 %
27 % \cs{scantokens} makes this process much simpler since we can activate the
28 % char and assign its meaning in one step.
29 % \begin{macrocode}
30 \cs_new:Nn \@@_setup_active_superscript:nn
31 {
32 \prop_gput:Nxn \g_@@_supers_prop { \int_eval:n {#1} } {#2}
33 \@@_mathactive_remap:nn {#1}
34 {
35 \tl_set:Nn \l_@@_ss_chain_tl {#2}
36 \cs_set_eq:NN \@@_sub_or_super:n \sp
37 \tl_set:Nn \l_@@_tmpa_tl {supers}
38 \@@_scan_sscript:
39 }
40 }
41 % \end{macrocode}
42 %
43 % \paragraph{Subscripts}
44 % \begin{macrocode}
45 \cs_new:Nn \@@_setup_active_subscript:nn
46 {
47 \prop_gput:Nxn \g_@@_subs_prop { \int_eval:n {#1} } {#2}
48 \@@_mathactive_remap:nn {#1}
49 {
50 \tl_set:Nn \l_@@_ss_chain_tl {#2}
51 \cs_set_eq:NN \@@_sub_or_super:n \sb
52 \tl_set:Nn \l_@@_tmpa_tl {subs}
53 \@@_scan_sscript:
54 }
55 }
56 % \end{macrocode}
57 %
58 % \paragraph{The scanning command}
59 % Collects a chain of subscripts or a chain
60 % of superscripts and then typesets what it has collected.
61 % \begin{macrocode}
62 \@@_cs_new:Nn \@@_scan_sscript:
63 {
64 \@@_scan_sscript:TF
65 { \@@_scan_sscript: }
66 { \@@_sub_or_super:n {\l_@@_ss_chain_tl} }
67 }
68 % \end{macrocode}
69 % We do not skip spaces when scanning ahead, and we explicitly wish to
70 % bail out on encountering a space or a brace. These cases are filtered
71 % using \cs{peek_N_type:TF}. Otherwise the token can be taken as an
72 % \texttt{N}-type argument. Then we search for it in the appropriate
73 % property list (\cs{l_@@_tmpa_tl} is |subs| or |supers|).
74 % If found, add the value to the current chain of sub/superscripts.
75 % Remember to put the character back in the input otherwise.
76 % The \cs{group_align_safe_begin:} and \cs{group_align_safe_end:} are
77 % needed in case |#3| is |&|.
78 % \begin{macrocode}
79 \@@_cs_new:Nn \@@_scan_sscript:TF
80 {
81 \peek_N_type:TF
82 {
83 \group_align_safe_begin:
84 \@@_scan_sscript_aux:nnN {#1} {#2}
85 }
86 {#2}
87 }
88 % \end{macrocode}
89 % The look-ahead for the sscripts doesn't try to peek inside the lookahead.
90 % \begin{macrocode}
91 \@@_cs_new:Nn \@@_scan_sscript_aux:nnN
92 {
93 \tl_set:Nx \l_@@_tmpa_key_tl { \tl_to_str:n {#3} }
94 \prop_get:cxNTF {g_@@_\l_@@_tmpa_tl _prop}
95 { \int_eval:n { \exp_after:wN ` \l_@@_tmpa_key_tl } }
96 \l_@@_tmpb_tl
97 {
98 \tl_put_right:NV \l_@@_ss_chain_tl \l_@@_tmpb_tl
99 \group_align_safe_end:
100 #1
101 }
102 { \group_align_safe_end: #2 #3 }
103 }
104 % \end{macrocode}
105 %
106 % \paragraph{Definitions}
107 % Superscripts.
108 % \begin{macrocode}
109 \@@_setup_active_superscript:nn {"2070} {0}
110 \@@_setup_active_superscript:nn {"00B9} {1}
111 \@@_setup_active_superscript:nn {"00B2} {2}
112 \@@_setup_active_superscript:nn {"00B3} {3}
113 \@@_setup_active_superscript:nn {"2074} {4}
114 \@@_setup_active_superscript:nn {"2075} {5}
115 \@@_setup_active_superscript:nn {"2076} {6}
116 \@@_setup_active_superscript:nn {"2077} {7}
117 \@@_setup_active_superscript:nn {"2078} {8}
118 \@@_setup_active_superscript:nn {"2079} {9}
119 \@@_setup_active_superscript:nn {"207A} {+}
120 \@@_setup_active_superscript:nn {"207B} {-}
121 \@@_setup_active_superscript:nn {"207C} {=}
122 \@@_setup_active_superscript:nn {"207D} {(}
123 \@@_setup_active_superscript:nn {"207E} {)}
124 \@@_setup_active_superscript:nn {"1D2C} {A}
125 \@@_setup_active_superscript:nn {"1D2E} {B}
126 \@@_setup_active_superscript:nn {"1D30} {D}
127 \@@_setup_active_superscript:nn {"1D31} {E}
128 \@@_setup_active_superscript:nn {"1D33} {G}
129 \@@_setup_active_superscript:nn {"1D34} {H}
130 \@@_setup_active_superscript:nn {"1D35} {I}
131 \@@_setup_active_superscript:nn {"1D36} {J}
132 \@@_setup_active_superscript:nn {"1D37} {K}
133 \@@_setup_active_superscript:nn {"1D38} {L}
134 \@@_setup_active_superscript:nn {"1D39} {M}
135 \@@_setup_active_superscript:nn {"1D3A} {N}
136 \@@_setup_active_superscript:nn {"1D3C} {O}
137 \@@_setup_active_superscript:nn {"1D3E} {P}
138 \@@_setup_active_superscript:nn {"1D3F} {R}
139 \@@_setup_active_superscript:nn {"1D40} {T}
140 \@@_setup_active_superscript:nn {"1D41} {U}
141 \@@_setup_active_superscript:nn {"2C7D} {V}
142 \@@_setup_active_superscript:nn {"1D42} {W}
143 \@@_setup_active_superscript:nn {"1D43} {a}
144 \@@_setup_active_superscript:nn {"1D47} {b}
145 \@@_setup_active_superscript:nn {"1D9C} {c}
146 \@@_setup_active_superscript:nn {"1D48} {d}
147 \@@_setup_active_superscript:nn {"1D49} {e}
148 \@@_setup_active_superscript:nn {"1DA0} {f}
149 \@@_setup_active_superscript:nn {"1D4D} {g}
150 \@@_setup_active_superscript:nn {"02B0} {h}
151 \@@_setup_active_superscript:nn {"2071} {i}
152 \@@_setup_active_superscript:nn {"02B2} {j}
153 \@@_setup_active_superscript:nn {"1D4F} {k}
154 \@@_setup_active_superscript:nn {"02E1} {l}
155 \@@_setup_active_superscript:nn {"1D50} {m}
156 \@@_setup_active_superscript:nn {"207F} {n}
157 \@@_setup_active_superscript:nn {"1D52} {o}
158 \@@_setup_active_superscript:nn {"1D56} {p}
159 \@@_setup_active_superscript:nn {"02B3} {r}
160 \@@_setup_active_superscript:nn {"02E2} {s}
161 \@@_setup_active_superscript:nn {"1D57} {t}
162 \@@_setup_active_superscript:nn {"1D58} {u}
163 \@@_setup_active_superscript:nn {"1D5B} {v}
164 \@@_setup_active_superscript:nn {"02B7} {w}
165 \@@_setup_active_superscript:nn {"02E3} {x}
166 \@@_setup_active_superscript:nn {"02B8} {y}
167 \@@_setup_active_superscript:nn {"1DBB} {z}
168 \@@_setup_active_superscript:nn {"1D5D} {\beta}
169 \@@_setup_active_superscript:nn {"1D5E} {\gamma}
170 \@@_setup_active_superscript:nn {"1D5F} {\delta}
171 \@@_setup_active_superscript:nn {"1D60} {\phi}
172 \@@_setup_active_superscript:nn {"1D61} {\chi}
173 \@@_setup_active_superscript:nn {"1DBF} {\theta}
174 % \end{macrocode}
175 % A few more subscripts than superscripts:
176 % \begin{macrocode}
177 \@@_setup_active_subscript:nn {"2080} {0}
178 \@@_setup_active_subscript:nn {"2081} {1}
179 \@@_setup_active_subscript:nn {"2082} {2}
180 \@@_setup_active_subscript:nn {"2083} {3}
181 \@@_setup_active_subscript:nn {"2084} {4}
182 \@@_setup_active_subscript:nn {"2085} {5}
183 \@@_setup_active_subscript:nn {"2086} {6}
184 \@@_setup_active_subscript:nn {"2087} {7}
185 \@@_setup_active_subscript:nn {"2088} {8}
186 \@@_setup_active_subscript:nn {"2089} {9}
187 \@@_setup_active_subscript:nn {"208A} {+}
188 \@@_setup_active_subscript:nn {"208B} {-}
189 \@@_setup_active_subscript:nn {"208C} {=}
190 \@@_setup_active_subscript:nn {"208D} {(}
191 \@@_setup_active_subscript:nn {"208E} {)}
192 \@@_setup_active_subscript:nn {"2090} {a}
193 \@@_setup_active_subscript:nn {"2091} {e}
194 \@@_setup_active_subscript:nn {"2095} {h}
195 \@@_setup_active_subscript:nn {"1D62} {i}
196 \@@_setup_active_subscript:nn {"2C7C} {j}
197 \@@_setup_active_subscript:nn {"2096} {k}
198 \@@_setup_active_subscript:nn {"2097} {l}
199 \@@_setup_active_subscript:nn {"2098} {m}
200 \@@_setup_active_subscript:nn {"2099} {n}
201 \@@_setup_active_subscript:nn {"2092} {o}
202 \@@_setup_active_subscript:nn {"209A} {p}
203 \@@_setup_active_subscript:nn {"1D63} {r}
204 \@@_setup_active_subscript:nn {"209B} {s}
205 \@@_setup_active_subscript:nn {"209C} {t}
206 \@@_setup_active_subscript:nn {"1D64} {u}
207 \@@_setup_active_subscript:nn {"1D65} {v}
208 \@@_setup_active_subscript:nn {"2093} {x}
209 \@@_setup_active_subscript:nn {"1D66} {\beta}
210 \@@_setup_active_subscript:nn {"1D67} {\gamma}
211 \@@_setup_active_subscript:nn {"1D68} {\rho}
212 \@@_setup_active_subscript:nn {"1D69} {\phi}
213 \@@_setup_active_subscript:nn {"1D6A} {\chi}
214 % \end{macrocode}
215 %
216 %
217 % \begin{macrocode}
218 %</package>
219 % \end{macrocode}
220
221 \endinput
222
223 % /©
224 %
225 % ------------------------------------------------
226 % The UNICODE-MATH package <wspr.io/unicode-math>
227 % ------------------------------------------------
228 % This package is free software and may be redistributed and/or modified under
229 % the conditions of the LaTeX Project Public License, version 1.3c or higher
230 % (your choice): <http://www.latex-project.org/lppl/>.
231 % ------------------------------------------------
232 % Copyright 2006-2019 Will Robertson, LPPL "maintainer"
233 % Copyright 2010-2017 Philipp Stephani
234 % Copyright 2011-2017 Joseph Wright
235 % Copyright 2012-2015 Khaled Hosny
236 % ------------------------------------------------
237 %
238 % ©/