| 1 |
%%^^A%% um-code-mathmap.dtx -- part of UNICODE-MATH <wspr.io/unicode-math> |
| 2 |
%%^^A%% Setup of symbol alphabets. |
| 3 |
|
| 4 |
% \section{Defining the math alphabets per style} |
| 5 |
% \label{sec:mathmap} |
| 6 |
% |
| 7 |
% \begin{macrocode} |
| 8 |
%<*package> |
| 9 |
% \end{macrocode} |
| 10 |
% |
| 11 |
% \begin{macro}{\@@_setup_alphabets:} |
| 12 |
% This function is called within \cs{setmathfont} to configure the |
| 13 |
% mapping between characters inside math styles. Three modes: |
| 14 |
% \begin{description} |
| 15 |
% \item[IMPLICIT] No ranges specified, set up everything |
| 16 |
% \item[EXPLICIT] Some ranges specified, set up what is requested only |
| 17 |
% \item[INHERIT] Of the slots in the ranges specified, compare against |
| 18 |
% slots in each styled alphabet and only set up those needed |
| 19 |
% \end{description} |
| 20 |
% The INHERIT mode saves less time than I was hoping for but is still beneficial |
| 21 |
% in simple cases. |
| 22 |
% \begin{macrocode} |
| 23 |
\@@_cs_new:Nn \@@_setup_alphabets: |
| 24 |
{ |
| 25 |
\bool_if:NTF \g_@@_init_bool { \@@_setup_alphabets_implicit: } |
| 26 |
{ |
| 27 |
\seq_if_empty:NF \g_@@_mathalph_seq { \@@_setup_alphabets_explicit: } |
| 28 |
\clist_if_empty:NF \l_@@_mathmap_charints_clist { \@@_setup_alphabets_inherit: } |
| 29 |
} |
| 30 |
} |
| 31 |
% \end{macrocode} |
| 32 |
% \end{macro} |
| 33 |
% |
| 34 |
% \begin{macro}{ \@@_setup_alphabets_implicit:} |
| 35 |
% \begin{macrocode} |
| 36 |
\@@_cs_new:Nn \@@_setup_alphabets_implicit: |
| 37 |
{ |
| 38 |
\@@_log:n {setup-implicit} |
| 39 |
\seq_gset_eq:NN \g_@@_mathalph_seq \g_@@_default_mathalph_seq |
| 40 |
\bool_set_true:N \l_@@_implicit_alph_bool |
| 41 |
\@@_maybe_init_alphabet:n {sf} |
| 42 |
\@@_maybe_init_alphabet:n {bf} |
| 43 |
\@@_maybe_init_alphabet:n {bfsf} |
| 44 |
\cs_set_eq:NN \@@_set_mathalphabet_char:nnn \@@_mathmap_noparse:nnn |
| 45 |
\cs_set_eq:NN \@@_map_char_single:nn \@@_map_char_noparse:nn |
| 46 |
\@@_mathalph_map: |
| 47 |
\seq_if_empty:NF \l_@@_missing_alph_seq { \@@_log:n { missing-alphabets } } |
| 48 |
} |
| 49 |
% \end{macrocode} |
| 50 |
% \end{macro} |
| 51 |
% |
| 52 |
% \begin{macro}{ \@@_setup_alphabets_explicit:} |
| 53 |
% \begin{macrocode} |
| 54 |
\@@_cs_new:Nn \@@_setup_alphabets_explicit: |
| 55 |
{ |
| 56 |
\@@_log:n {setup-explicit} |
| 57 |
\bool_set_false:N \l_@@_implicit_alph_bool |
| 58 |
\cs_set_eq:NN \@@_set_mathalphabet_char:nnn \@@_mathmap_noparse:nnn |
| 59 |
\cs_set_eq:NN \@@_map_char_single:nn \@@_map_char_noparse:nn |
| 60 |
\@@_mathalph_map: |
| 61 |
\seq_if_empty:NF \l_@@_missing_alph_seq { \@@_log:n { missing-alphabets } } |
| 62 |
} |
| 63 |
% \end{macrocode} |
| 64 |
% \end{macro} |
| 65 |
% |
| 66 |
% \begin{macro}{ \@@_setup_alphabets_inherit:} |
| 67 |
% \begin{macrocode} |
| 68 |
\@@_cs_new:Nn \@@_setup_alphabets_inherit: |
| 69 |
{ |
| 70 |
\seq_gclear:N \g_@@_mathalph_seq |
| 71 |
\seq_map_inline:Nn \g_@@_default_mathalph_seq |
| 72 |
{ |
| 73 |
\tl_set:No \l_@@_style_tl { \use_i:nnn ##1 } |
| 74 |
\clist_set:No \l_@@_alphabet_clist { \use_ii:nnn ##1 } |
| 75 |
|
| 76 |
\clist_map_inline:Nn \l_@@_alphabet_clist |
| 77 |
{ |
| 78 |
\clist_if_exist:cT {g_@@_named_slots_ \l_@@_style_tl _ ####1 _clist} |
| 79 |
{ |
| 80 |
\clist_map_inline:cn {g_@@_named_slots_ \l_@@_style_tl _ ####1 _clist} |
| 81 |
{ |
| 82 |
\clist_map_inline:Nn \l_@@_mathmap_charints_clist |
| 83 |
{ |
| 84 |
\@@_int_if_slot_in_range:nnT {################1} {########1} |
| 85 |
{ |
| 86 |
\seq_gput_right:Nn \g_@@_mathalph_seq {##1} |
| 87 |
\clist_map_break:n { \clist_map_break:n { \clist_map_break: } } |
| 88 |
} |
| 89 |
} |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
\cs_set_eq:NN \@@_set_mathalphabet_char:nnn \@@_mathmap_parse:nnn |
| 96 |
\cs_set_eq:NN \@@_map_char_single:nn \@@_map_char_parse:nn |
| 97 |
\@@_mathalph_map: |
| 98 |
} |
| 99 |
% \end{macrocode} |
| 100 |
% \end{macro} |
| 101 |
% |
| 102 |
% \begin{macro}{\@@_mathalph_map:} |
| 103 |
% \begin{macrocode} |
| 104 |
\cs_set:Nn \@@_mathalph_map: |
| 105 |
{ |
| 106 |
\seq_map_inline:Nn \g_@@_mathalph_seq |
| 107 |
{ |
| 108 |
\tl_set:No \l_@@_style_tl { \use_i:nnn ##1 } |
| 109 |
\clist_set:No \l_@@_alphabet_clist { \use_ii:nnn ##1 } |
| 110 |
\tl_set:No \l_@@_remap_style_tl { \use_iii:nnn ##1 } |
| 111 |
|
| 112 |
% If no set of alphabets is defined: |
| 113 |
\clist_if_empty:NT \l_@@_alphabet_clist |
| 114 |
{ |
| 115 |
\cs_set_eq:NN \@@_maybe_init_alphabet:n \@@_init_alphabet:n |
| 116 |
\prop_get:cnN { g_@@_named_range_ \l_@@_style_tl _prop } |
| 117 |
{ default-alpha } \l_@@_alphabet_clist |
| 118 |
} |
| 119 |
|
| 120 |
\@@_check_math_alphabet: |
| 121 |
\@@_setup_math_alphabet: |
| 122 |
} |
| 123 |
} |
| 124 |
% \end{macrocode} |
| 125 |
% \end{macro} |
| 126 |
% |
| 127 |
% \begin{macro}{\@@_check_math_alphabet:} |
| 128 |
% First check that at least one of the alphabets for the font shape is defined |
| 129 |
% (this process is fast) \dots |
| 130 |
% \begin{macrocode} |
| 131 |
\cs_new:Nn \@@_check_math_alphabet: |
| 132 |
{ |
| 133 |
\clist_map_inline:Nn \l_@@_alphabet_clist |
| 134 |
{ |
| 135 |
\tl_set:Nn \l_@@_alphabet_tl {##1} |
| 136 |
\@@_if_alphabet_exists:nnTF \l_@@_style_tl \l_@@_alphabet_tl |
| 137 |
{ |
| 138 |
\str_if_eq:eeTF {\l_@@_alphabet_tl} {misc} |
| 139 |
{ |
| 140 |
\@@_maybe_init_alphabet:n \l_@@_style_tl |
| 141 |
\clist_map_break: |
| 142 |
} |
| 143 |
{ |
| 144 |
\@@_glyph_if_exist:NnT \g_@@_curr_font_cmd_tl |
| 145 |
{ \@@_to_usv:nn {\l_@@_style_tl} {\l_@@_alphabet_tl} } |
| 146 |
{ |
| 147 |
\@@_maybe_init_alphabet:n \l_@@_style_tl |
| 148 |
\clist_map_break: |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
{ |
| 153 |
\msg_warning:nnx {unicode-math} {no-alphabet} |
| 154 |
{ \l_@@_style_tl / \l_@@_alphabet_tl } |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
% \end{macrocode} |
| 159 |
% \end{macro} |
| 160 |
% |
| 161 |
% \begin{macro}{\@@_setup_math_alphabet:} |
| 162 |
% \dots and then loop through them defining the individual ranges: |
| 163 |
% (currently this process is slow) |
| 164 |
% \begin{macrocode} |
| 165 |
\@@_cs_new:Nn \@@_setup_math_alphabet: |
| 166 |
{ |
| 167 |
\clist_map_inline:Nn \l_@@_alphabet_clist |
| 168 |
{ |
| 169 |
\tl_set:Nx \l_@@_alphabet_tl { \tl_trim_spaces:n {##1} } |
| 170 |
|
| 171 |
%<debug>\@@_debug:n {_setup_math_alphabet:~\l_@@_style_tl/\l_@@_alphabet_tl} |
| 172 |
|
| 173 |
\@@_if_alphabet_exists:nnT {\l_@@_style_tl} {\l_@@_alphabet_tl} |
| 174 |
{ |
| 175 |
\exp_args:No \tl_if_eq:nnTF \l_@@_alphabet_tl {misc} |
| 176 |
{ |
| 177 |
\@@_log:nx {setup-alph} {sym \l_@@_style_tl~(\l_@@_alphabet_tl)} |
| 178 |
\@@_alphabet_config:nnn {\l_@@_style_tl} {\l_@@_alphabet_tl} {\l_@@_remap_style_tl} |
| 179 |
} |
| 180 |
{ |
| 181 |
\@@_glyph_if_exist:NnTF \g_@@_curr_font_cmd_tl { \@@_to_usv:nn {\l_@@_remap_style_tl} {\l_@@_alphabet_tl} } |
| 182 |
{ |
| 183 |
\@@_log:nx {setup-alph} {sym \l_@@_style_tl~(\l_@@_alphabet_tl)} |
| 184 |
\@@_alphabet_config:nnn {\l_@@_style_tl} {\l_@@_alphabet_tl} {\l_@@_remap_style_tl} |
| 185 |
} |
| 186 |
{ |
| 187 |
\bool_if:NTF \l_@@_implicit_alph_bool |
| 188 |
{ |
| 189 |
\seq_put_right:Nx \l_@@_missing_alph_seq |
| 190 |
{ |
| 191 |
\@backslashchar sym \l_@@_style_tl \space |
| 192 |
(\tl_use:c{c_@@_math_alphabet_name_ \l_@@_alphabet_tl _tl}) |
| 193 |
} |
| 194 |
} |
| 195 |
{ |
| 196 |
\@@_alphabet_config:nnn {\l_@@_style_tl} {\l_@@_alphabet_tl} {up} |
| 197 |
} |
| 198 |
} |
| 199 |
} |
| 200 |
} |
| 201 |
} |
| 202 |
} |
| 203 |
% \end{macrocode} |
| 204 |
% \end{macro} |
| 205 |
% |
| 206 |
% Each alphabet style needs to be configured. |
| 207 |
% This happens in Section~\ref{sec:setupalphabets}. |
| 208 |
% \begin{macrocode} |
| 209 |
\cs_new:Nn \@@_new_alphabet_config:nnn |
| 210 |
{ |
| 211 |
\prop_if_exist:cF {g_@@_named_range_#1_prop} |
| 212 |
{ \@@_warning:nnn {no-named-range} {#1} {#2} } |
| 213 |
|
| 214 |
|
| 215 |
\prop_gput:cnn {g_@@_named_range_#1_prop} { alpha_tl } |
| 216 |
{ |
| 217 |
\prop_item:cn {g_@@_named_range_#1_prop} { alpha_tl } {#2} |
| 218 |
} |
| 219 |
% Q: do I need to bother removing duplicates? |
| 220 |
|
| 221 |
% \end{macrocode} |
| 222 |
% Create list of all chars defined in this named range: |
| 223 |
% \begin{macrocode} |
| 224 |
\cs_new:cn { @@_config_#1_#2:n } |
| 225 |
{ |
| 226 |
\clist_gclear_new:c {g_@@_named_slots_#1_#2_clist} |
| 227 |
\tl_set:Nn \l_@@_curr_named_slot { g_@@_named_slots_#1_#2_clist } |
| 228 |
#3 |
| 229 |
\clist_gremove_duplicates:c {g_@@_named_slots_#1_#2_clist} |
| 230 |
} |
| 231 |
|
| 232 |
} |
| 233 |
% \end{macrocode} |
| 234 |
% \begin{macrocode} |
| 235 |
\cs_new:Nn \@@_alphabet_config:nnn |
| 236 |
{ |
| 237 |
\use:c {@@_config_#1_#2:n} {#3} |
| 238 |
} |
| 239 |
% \end{macrocode} |
| 240 |
% \begin{macrocode} |
| 241 |
\prg_new_conditional:Nnn \@@_if_alphabet_exists:nn {T,TF} |
| 242 |
{ |
| 243 |
\cs_if_exist:cTF {@@_config_#1_#2:n} |
| 244 |
\prg_return_true: \prg_return_false: |
| 245 |
} |
| 246 |
% \end{macrocode} |
| 247 |
% |
| 248 |
% \subsection{Mapping `naked’ math characters} |
| 249 |
% |
| 250 |
% Before we show the definitions of the alphabet mappings using the functions |
| 251 |
% |\@@_alphabet_config:nnn \l_@@_style_tl {##1} {...}|, we first want to define some functions |
| 252 |
% to be used inside them to actually perform the character mapping. |
| 253 |
% |
| 254 |
% \subsubsection{Functions} |
| 255 |
% |
| 256 |
% \begin{macro}{\@@_map_char_single:nn} |
| 257 |
% Wrapper for |\@@_map_char_noparse:nn| or |\@@_map_char_parse:nn| |
| 258 |
% depending on the context. |
| 259 |
% |
| 260 |
% \begin{macro}{\@@_map_char_noparse:nn} |
| 261 |
% \begin{macro}{\@@_map_char_parse:nn} |
| 262 |
% \begin{macrocode} |
| 263 |
\cs_new:Nn \@@_map_char_noparse:nn |
| 264 |
{ |
| 265 |
\@@_set_mathcode:nnnn {#1} {\mathalpha} {\l_@@_symfont_label_tl} {#2} |
| 266 |
} |
| 267 |
% \end{macrocode} |
| 268 |
% |
| 269 |
% \begin{macrocode} |
| 270 |
\cs_new:Nn \@@_map_char_parse:nn |
| 271 |
{ |
| 272 |
\@@_if_char_spec:nNT {#1} {\mathalpha} |
| 273 |
{ \@@_map_char_noparse:nn {#1}{#2} } |
| 274 |
} |
| 275 |
% \end{macrocode} |
| 276 |
% \end{macro} |
| 277 |
% \end{macro} |
| 278 |
% \end{macro} |
| 279 |
% |
| 280 |
% \begin{macro}{\@@_map_char_single:nnn} |
| 281 |
% \darg{char name (`dotlessi’)} |
| 282 |
% \darg{from alphabet(s)} |
| 283 |
% \darg{to alphabet} |
| 284 |
% Logical interface to \cs{@@_map_char_single:nn}. |
| 285 |
% \begin{macrocode} |
| 286 |
\cs_new:Nn \@@_map_char_single:nnn |
| 287 |
{ |
| 288 |
\@@_map_char_single:nn { \@@_to_usv:nn {#1} {#3} } |
| 289 |
{ \@@_to_usv:nn {#2} {#3} } |
| 290 |
} |
| 291 |
% \end{macrocode} |
| 292 |
% \end{macro} |
| 293 |
% |
| 294 |
% |
| 295 |
% \begin{macro}{\@@_map_chars_range:nnnn} |
| 296 |
% \darg{Number of chars (26)} |
| 297 |
% \darg{From style, one or more (it)} |
| 298 |
% \darg{To style (up)} |
| 299 |
% \darg{Alphabet name (Latin)} |
| 300 |
% First the function with numbers: |
| 301 |
% \begin{macrocode} |
| 302 |
\cs_set:Nn \@@_map_chars_range:nnn |
| 303 |
{ |
| 304 |
\int_step_inline:nnnn {0} {1} {#1-1} |
| 305 |
{ \@@_map_char_single:nn {#2+##1} {#3+##1} } |
| 306 |
|
| 307 |
\clist_gput_right:cx { \l_@@_curr_named_slot } |
| 308 |
{ \int_eval:n { #3 } - \int_eval:n { #3 + #1-1 } } |
| 309 |
} |
| 310 |
% \end{macrocode} |
| 311 |
% And the wrapper with names: |
| 312 |
% \begin{macrocode} |
| 313 |
\cs_new:Nn \@@_map_chars_range:nnnn |
| 314 |
{ |
| 315 |
\@@_map_chars_range:nnn {#1} { \@@_to_usv:nn {#2} {#4} } |
| 316 |
{ \@@_to_usv:nn {#3} {#4} } |
| 317 |
} |
| 318 |
% \end{macrocode} |
| 319 |
% \end{macro} |
| 320 |
% |
| 321 |
% \subsubsection{Functions for `normal’ alphabet symbols} |
| 322 |
% |
| 323 |
% \begin{macro}{\@@_set_normal_char:nnn} |
| 324 |
% \begin{macrocode} |
| 325 |
\cs_set:Nn \@@_set_normal_char:nnn |
| 326 |
{ |
| 327 |
\@@_usv_if_exist:nnT {#3} {#1} |
| 328 |
{ |
| 329 |
\clist_map_inline:nn {#2} |
| 330 |
{ |
| 331 |
\@@_set_mathalphabet_pos:nnnn {normal} {#1} {##1} {#3} |
| 332 |
\@@_map_char_single:nnn {##1} {#3} {#1} |
| 333 |
|
| 334 |
\clist_gput_right:cx {\l_@@_curr_named_slot} |
| 335 |
{ \int_eval:n { \@@_to_usv:nn {#3} {#1} } } |
| 336 |
} |
| 337 |
} |
| 338 |
} |
| 339 |
% \end{macrocode} |
| 340 |
% \end{macro} |
| 341 |
% |
| 342 |
% \begin{macrocode} |
| 343 |
\cs_new:Nn \@@_set_normal_Latin:nn |
| 344 |
{ |
| 345 |
\clist_map_inline:nn {#1} |
| 346 |
{ |
| 347 |
\@@_set_mathalphabet_Latin:nnn {normal} {##1} {#2} |
| 348 |
\@@_map_chars_range:nnnn {26} {##1} {#2} {Latin} |
| 349 |
} |
| 350 |
} |
| 351 |
% \end{macrocode} |
| 352 |
% |
| 353 |
% \begin{macrocode} |
| 354 |
\cs_new:Nn \@@_set_normal_latin:nn |
| 355 |
{ |
| 356 |
\clist_map_inline:nn {#1} |
| 357 |
{ |
| 358 |
\@@_set_mathalphabet_latin:nnn {normal} {##1} {#2} |
| 359 |
\@@_map_chars_range:nnnn {26} {##1} {#2} {latin} |
| 360 |
} |
| 361 |
} |
| 362 |
% \end{macrocode} |
| 363 |
% |
| 364 |
% \begin{macrocode} |
| 365 |
\cs_new:Nn \@@_set_normal_greek:nn |
| 366 |
{ |
| 367 |
\clist_map_inline:nn {#1} |
| 368 |
{ |
| 369 |
\@@_set_mathalphabet_greek:nnn {normal} {##1} {#2} |
| 370 |
\@@_map_chars_range:nnnn {25} {##1} {#2} {greek} |
| 371 |
\@@_map_char_single:nnn {##1} {#2} {epsilon} |
| 372 |
\@@_map_char_single:nnn {##1} {#2} {vartheta} |
| 373 |
\@@_map_char_single:nnn {##1} {#2} {varkappa} |
| 374 |
\@@_map_char_single:nnn {##1} {#2} {phi} |
| 375 |
\@@_map_char_single:nnn {##1} {#2} {varrho} |
| 376 |
\@@_map_char_single:nnn {##1} {#2} {varpi} |
| 377 |
\@@_set_mathalphabet_pos:nnnn {normal} {epsilon} {##1} {#2} |
| 378 |
\@@_set_mathalphabet_pos:nnnn {normal} {vartheta} {##1} {#2} |
| 379 |
\@@_set_mathalphabet_pos:nnnn {normal} {varkappa} {##1} {#2} |
| 380 |
\@@_set_mathalphabet_pos:nnnn {normal} {phi} {##1} {#2} |
| 381 |
\@@_set_mathalphabet_pos:nnnn {normal} {varrho} {##1} {#2} |
| 382 |
\@@_set_mathalphabet_pos:nnnn {normal} {varpi} {##1} {#2} |
| 383 |
} |
| 384 |
} |
| 385 |
% \end{macrocode} |
| 386 |
% |
| 387 |
% \begin{macrocode} |
| 388 |
\cs_new:Nn \@@_set_normal_Greek:nn |
| 389 |
{ |
| 390 |
\clist_map_inline:nn {#1} |
| 391 |
{ |
| 392 |
\@@_set_mathalphabet_Greek:nnn {normal} {##1} {#2} |
| 393 |
\@@_map_chars_range:nnnn {25} {##1} {#2} {Greek} |
| 394 |
\@@_map_char_single:nnn {##1} {#2} {varTheta} |
| 395 |
\@@_set_mathalphabet_pos:nnnn {normal} {varTheta} {##1} {#2} |
| 396 |
} |
| 397 |
} |
| 398 |
% \end{macrocode} |
| 399 |
% |
| 400 |
% \begin{macrocode} |
| 401 |
\cs_new:Nn \@@_set_normal_numbers:nn |
| 402 |
{ |
| 403 |
\@@_set_mathalphabet_numbers:nnn {normal} {#1} {#2} |
| 404 |
\@@_map_chars_range:nnnn {10} {#1} {#2} {num} |
| 405 |
} |
| 406 |
% \end{macrocode} |
| 407 |
% |
| 408 |
% |
| 409 |
% \subsection{Mapping chars inside a math style} |
| 410 |
% |
| 411 |
% \subsubsection{Functions for setting up the maths alphabets} |
| 412 |
% |
| 413 |
% \begin{macro}{\@@_set_mathalphabet_char:nnn} |
| 414 |
% \darg{Maths alphabet, \eg, `bb’} |
| 415 |
% \darg{Input slot, \eg, the slot for `A’ (comma separated)} |
| 416 |
% \darg{Output slot, \eg, the slot for `$\mathbb{A}$’} |
| 417 |
% This is a wrapper for either |\@@_mathmap_noparse:nnn| or |
| 418 |
% |\@@_mathmap_parse:nnn|, depending on the context. |
| 419 |
% \end{macro} |
| 420 |
% |
| 421 |
% \begin{macro}{\@@_mathmap_noparse:nnn} |
| 422 |
% \darg{Maths alphabet, \eg, `bb’} |
| 423 |
% \darg{Input slot, \eg, the slot for `A’ (comma separated)} |
| 424 |
% \darg{Output slot, \eg, the slot for `$\mathbb{A}$’} |
| 425 |
% Adds \cs{@@_set_mathcode:nnnn} declarations to the specified maths alphabet’s definition. |
| 426 |
% \begin{macrocode} |
| 427 |
\cs_new:Nn \@@_mathmap_noparse:nnn |
| 428 |
{ |
| 429 |
\tl_gput_right:cx { g_@@_switchto_#1_tl } |
| 430 |
{ |
| 431 |
\@@_set_mathcode:nnnn {#2} {\mathalpha} {\l_@@_symfont_label_tl} {#3} |
| 432 |
} |
| 433 |
} |
| 434 |
% \end{macrocode} |
| 435 |
% \end{macro} |
| 436 |
% |
| 437 |
% \begin{macro}{\@@_mathmap_parse:nnn} |
| 438 |
% \darg{Maths alphabet, \eg, `bb’} |
| 439 |
% \darg{Input slot, \eg, the slot for `A’ (comma separated)} |
| 440 |
% \darg{Output slot, \eg, the slot for `$\mathbb{A}$’} |
| 441 |
% When \cmd\@@_if_char_spec:nNT\ is executed, it populates the \cmd\l_@@_mathmap_charints_clist\ |
| 442 |
% macro with slot numbers corresponding to the specified range. This range is used to |
| 443 |
% conditionally add \cs{@@_set_mathcode:nnnn} declaractions to the maths alphabet definition. |
| 444 |
% \begin{macrocode} |
| 445 |
\cs_new:Nn \@@_mathmap_parse:nnn |
| 446 |
{ |
| 447 |
\exp_args:NNx \clist_if_in:NnT \l_@@_mathmap_charints_clist { \int_eval:n {#3} } |
| 448 |
{ |
| 449 |
\@@_mathmap_noparse:nnn {#1} {#2} {#3} |
| 450 |
} |
| 451 |
} |
| 452 |
% \end{macrocode} |
| 453 |
% \end{macro} |
| 454 |
% |
| 455 |
% \begin{macro}{\@@_set_mathalphabet_char:nnnn} |
| 456 |
% \darg{math style command} |
| 457 |
% \darg{input math alphabet name} |
| 458 |
% \darg{output math alphabet name} |
| 459 |
% \darg{char name to map} |
| 460 |
% \begin{macrocode} |
| 461 |
\cs_new:Nn \@@_set_mathalphabet_char:nnnn |
| 462 |
{ |
| 463 |
\@@_set_mathalphabet_char:nnn {#1} { \@@_to_usv:nn {#2} {#4} } |
| 464 |
{ \@@_to_usv:nn {#3} {#4} } |
| 465 |
} |
| 466 |
% \end{macrocode} |
| 467 |
% \end{macro} |
| 468 |
% |
| 469 |
% \begin{macro}{\@@_set_mathalph_range:nnnn} |
| 470 |
% \darg{Number of iterations} |
| 471 |
% \darg{Sym command suffix} |
| 472 |
% \darg{Starting input char} |
| 473 |
% \darg{Starting output char} |
| 474 |
% Loops through character ranges setting \cmd\mathcode. |
| 475 |
% First the version that uses numbers: |
| 476 |
% \begin{macrocode} |
| 477 |
\cs_new:Nn \@@_set_mathalph_range:nnnn |
| 478 |
{ |
| 479 |
\int_step_inline:nnnn {0} {1} {#1-1} |
| 480 |
{ \@@_set_mathalphabet_char:nnn {#2} { ##1 + #3 } { ##1 + #4 } } |
| 481 |
} |
| 482 |
% \end{macrocode} |
| 483 |
% \end{macro} |
| 484 |
% |
| 485 |
% \begin{macro}{\@@_set_mathalph_range:nnnn} |
| 486 |
% \darg{Number of iterations} |
| 487 |
% \darg{Sym command suffix} |
| 488 |
% \darg{input style} |
| 489 |
% \darg{output style} |
| 490 |
% \darg{alphabet} |
| 491 |
% Then the wrapper version that uses names: |
| 492 |
% \begin{macrocode} |
| 493 |
\cs_new:Nn \@@_set_mathalph_range:nnnnn |
| 494 |
{ |
| 495 |
\clist_gput_right:cx { \l_@@_curr_named_slot } |
| 496 |
{ \int_eval:n { \@@_to_usv:nn {#4} {#5} } - \int_eval:n { (#1-1)+\@@_to_usv:nn {#4} {#5} } } |
| 497 |
|
| 498 |
\@@_set_mathalph_range:nnnn {#1} {#2} { \@@_to_usv:nn {#3} {#5} } |
| 499 |
{ \@@_to_usv:nn {#4} {#5} } |
| 500 |
} |
| 501 |
% \end{macrocode} |
| 502 |
% \end{macro} |
| 503 |
% |
| 504 |
% \subsubsection{Individual mapping functions for different alphabets} |
| 505 |
% |
| 506 |
% \begin{macrocode} |
| 507 |
\cs_new:Nn \@@_set_mathalphabet_pos:nnnn |
| 508 |
{ |
| 509 |
\@@_usv_if_exist:nnT {#4} {#2} |
| 510 |
{ |
| 511 |
\clist_map_inline:nn {#3} |
| 512 |
{ \@@_set_mathalphabet_char:nnnn {#1} {##1} {#4} {#2} } |
| 513 |
|
| 514 |
\clist_gput_right:cx {\l_@@_curr_named_slot} |
| 515 |
{ \int_eval:n { \@@_to_usv:nn {#4} {#2} } } |
| 516 |
} |
| 517 |
} |
| 518 |
% \end{macrocode} |
| 519 |
% |
| 520 |
% \begin{macrocode} |
| 521 |
\cs_new:Nn \@@_set_mathalphabet_numbers:nnn |
| 522 |
{ |
| 523 |
\clist_map_inline:nn {#2} |
| 524 |
{ \@@_set_mathalph_range:nnnnn {10} {#1} {##1} {#3} {num} } |
| 525 |
} |
| 526 |
% \end{macrocode} |
| 527 |
% |
| 528 |
% \begin{macrocode} |
| 529 |
\cs_new:Nn \@@_set_mathalphabet_Latin:nnn |
| 530 |
{ |
| 531 |
\clist_map_inline:nn {#2} |
| 532 |
{ \@@_set_mathalph_range:nnnnn {26} {#1} {##1} {#3} {Latin} } |
| 533 |
} |
| 534 |
% \end{macrocode} |
| 535 |
% |
| 536 |
% \begin{macrocode} |
| 537 |
\cs_new:Nn \@@_set_mathalphabet_latin:nnn |
| 538 |
{ |
| 539 |
\clist_map_inline:nn {#2} |
| 540 |
{ |
| 541 |
\@@_set_mathalph_range:nnnnn {26} {#1} {##1} {#3} {latin} |
| 542 |
\@@_set_mathalphabet_char:nnnn {#1} {##1} {#3} {h} |
| 543 |
} |
| 544 |
} |
| 545 |
% \end{macrocode} |
| 546 |
% |
| 547 |
% \begin{macrocode} |
| 548 |
\cs_new:Nn \@@_set_mathalphabet_Greek:nnn |
| 549 |
{ |
| 550 |
\clist_map_inline:nn {#2} |
| 551 |
{ |
| 552 |
\@@_set_mathalph_range:nnnnn {25} {#1} {##1} {#3} {Greek} |
| 553 |
\@@_set_mathalphabet_char:nnnn {#1} {##1} {#3} {varTheta} |
| 554 |
} |
| 555 |
} |
| 556 |
% \end{macrocode} |
| 557 |
% |
| 558 |
% \begin{macrocode} |
| 559 |
\cs_new:Nn \@@_set_mathalphabet_greek:nnn |
| 560 |
{ |
| 561 |
\clist_map_inline:nn {#2} |
| 562 |
{ |
| 563 |
\@@_set_mathalph_range:nnnnn {25} {#1} {##1} {#3} {greek} |
| 564 |
\@@_set_mathalphabet_char:nnnn {#1} {##1} {#3} {epsilon} |
| 565 |
\@@_set_mathalphabet_char:nnnn {#1} {##1} {#3} {vartheta} |
| 566 |
\@@_set_mathalphabet_char:nnnn {#1} {##1} {#3} {varkappa} |
| 567 |
\@@_set_mathalphabet_char:nnnn {#1} {##1} {#3} {phi} |
| 568 |
\@@_set_mathalphabet_char:nnnn {#1} {##1} {#3} {varrho} |
| 569 |
\@@_set_mathalphabet_char:nnnn {#1} {##1} {#3} {varpi} |
| 570 |
} |
| 571 |
} |
| 572 |
% \end{macrocode} |
| 573 |
% |
| 574 |
% \begin{macrocode} |
| 575 |
%</package> |
| 576 |
% \end{macrocode} |
| 577 |
|
| 578 |
\endinput |
| 579 |
|
| 580 |
% /© |
| 581 |
% |
| 582 |
% ------------------------------------------------ |
| 583 |
% The UNICODE-MATH package <wspr.io/unicode-math> |
| 584 |
% ------------------------------------------------ |
| 585 |
% This package is free software and may be redistributed and/or modified under |
| 586 |
% the conditions of the LaTeX Project Public License, version 1.3c or higher |
| 587 |
% (your choice): <http://www.latex-project.org/lppl/>. |
| 588 |
% ------------------------------------------------ |
| 589 |
% Copyright 2006-2019 Will Robertson, LPPL "maintainer" |
| 590 |
% Copyright 2010-2017 Philipp Stephani |
| 591 |
% Copyright 2011-2017 Joseph Wright |
| 592 |
% Copyright 2012-2015 Khaled Hosny |
| 593 |
% ------------------------------------------------ |
| 594 |
% |
| 595 |
% ©/ |