diff options
Diffstat (limited to 'macros/latex/contrib/unicode-math-input/unicode-math-input.sty')
-rw-r--r-- | macros/latex/contrib/unicode-math-input/unicode-math-input.sty | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/macros/latex/contrib/unicode-math-input/unicode-math-input.sty b/macros/latex/contrib/unicode-math-input/unicode-math-input.sty index dcb72f6a30..b9696c3a32 100644 --- a/macros/latex/contrib/unicode-math-input/unicode-math-input.sty +++ b/macros/latex/contrib/unicode-math-input/unicode-math-input.sty @@ -1,5 +1,5 @@ % File: unicode-math-input.sty -% Copyright 2022-2023 user202729 +% Copyright 2022-2024 user202729 % % This work may be distributed and/or modified under the conditions of the % LaTeX Project Public License (LPPL), either version 1.3c of this license or @@ -14,7 +14,7 @@ \RequirePackage{expl3} \RequirePackage{iftex} -\ProvidesExplPackage{unicode-math-input}{2023-05-12}{0.0.0}{Allow entering Unicode symbols in math formulas} +\ProvidesExplPackage{unicode-math-input}{2024-01-18}{0.1.0}{Allow entering Unicode symbols in math formulas} \makeatletter \AtBeginDocument{ @@ -38,7 +38,17 @@ \cs_new_protected:Npn \umiMathbf {\__umi_check_math_alphabet \mathbf \umiMathbf } \cs_new_protected:Npn \umiMathit {\__umi_check_math_alphabet \mathit \umiMathit } \cs_new_protected:Npn \umiMathbfit {\__umi_check_math_alphabet \bm \umiMathbfit } -\cs_new_protected:Npn \umiMathscr {\__umi_check_math_alphabet \mathscr \umiMathscr } +\cs_new_protected:Npn \umiMathscr { + \ifdefined \mathscr + \expandafter \mathscr + \else + \ifdefined \mathcal + \expandafter \expandafter \expandafter \mathcal + \else + \msg_error:nnnn {unicode-math-input} {define-math-alphabet} {\mathscr/\mathcal} {\umiMathscr} + \fi + \fi +} \cs_new_protected:Npn \umiMathbfscr {\__umi_check_math_alphabet \mathbfscr \umiMathbfscr } \cs_new_protected:Npn \umiMathfrak {\__umi_check_math_alphabet \mathfrak \umiMathfrak } \cs_new_protected:Npn \umiMathbb {\__umi_check_math_alphabet \mathbb \umiMathbb } @@ -79,11 +89,23 @@ \ifdefined #2 #2 \else - \msg_error:nnn {unicode-math-input} {undefined-cs} {#1#2} + \__umi_raise_error {#1#2} \fi \fi } +\cs_new_protected:Npn \__umi_alternatives_m #1 { + \tl_map_inline:nn {#1} { + \ifdefined ##1 + ##1 + \tl_map_break:n {\use_none:nn} + \fi + } + \__umi_raise_error {#1} +} + +\cs_new_protected:Npn \__umi_raise_error { \msg_error:nnn {unicode-math-input} {undefined-cs} } + % #1 is control sequence, #2 is anything (must not peek ahead!) \cs_new_protected:Npn \__umi_alternatives_iisafe #1 #2 { \ifdefined #1 @@ -107,6 +129,16 @@ \fi } +\cs_new_protected:Npn \__umi_alternatives_not_two #1 #2 #3 #4{ + \ifdefined #1 #1 \else + \ifdefined #2 #2 \else + \ifdefined #3 \not#3 \else + \ifdefined #4 \not#4 \else + \msg_error:nnn {unicode-math-input} {undefined-cs} {#1#2#3#4} + \fi \fi \fi \fi +} + + % ======== \__umi_require_math \msg_new:nnn {unicode-math-input} {not-math-mode} { This~symbol~can~only~be~used~in~math~mode! @@ -213,8 +245,8 @@ } - \cs_new_eq:NN \umiDefineMathChar \__umi_define_char_single - \cs_new_protected:Npn \umiDefineMathDelimiter #1 #2 { + \cs_new_eq:NN \umiDeclareMathChar \__umi_define_char_single + \cs_new_protected:Npn \umiDeclareMathDelimiter #1 #2 { \cs_new_protected:Npn \__umi_check_delimiter_defined_not_delimiter ##1 ##2 { \msg_error:nnnn {unicode-math-input} {not-delimiter} {##1} {##2} } @@ -278,16 +310,23 @@ \cs_new_eq:NN \__umi_define_char_maybe_delimiter \__umi_define_char - \cs_new_protected:Npn \umiDefineMathChar #1 #2{ + \cs_new_protected:Npn \umiDeclareMathChar #1 #2{ \ifnum \str_count:n{#1}=1 \__umi_define_char_single #1 {#2} \else \cs_gset_protected:cpx {u8:\detokenize{#1}} {\unexpanded{\__umi_require_math #2}} \fi } - \cs_new_eq:NN \umiDefineMathDelimiter \umiDefineMathChar + \cs_new_eq:NN \umiDeclareMathDelimiter \umiDeclareMathChar } + +\cs_new_eq:NN \umiDefineMathChar \umiDeclareMathChar +\cs_new_eq:NN \umiDefineMathDelimiter \umiDeclareMathDelimiter % backwards compatibility + +\cs_new_protected:Npn \umiDeclareMathCharCopy { \__umi_internal_error } +\cs_new_protected:Npn \umiDeclareMathDelimiterCopy { \__umi_internal_error } + \__umi_if_engine_unicode { \tl_build_begin:N \__umi_delimiter_list } {} @@ -451,8 +490,9 @@ \expandafter \__umi_continue_script_aux \exp:w\exp_end_continue_f:w \char_generate:nn {\expandafter \__umi_gobble_the_character \meaning #1} {13} } { - \cs_gset_eq:NN \__umi_script \__umi_put_script_normal - ^{\l_tmpa_tl} #1 + % is not the case, finished (put back the #1) + \__umi_script_collect_done + \__umi_script_cat{\l_tmpa_tl} #1 } } @@ -492,12 +532,13 @@ } \def \__umi_brace_error {\__umi_internal_error \l_tmpa_tl} + \def \__umi_brace_nobrace {\l_tmpa_tl} \def \__umi_brace_two #1 #2 {\l_tmpa_tl {#1 #2}} \def \__umi_brace_three #1 #2 #3 {\l_tmpa_tl {#1 #2 #3}} \def \__umi_brace_four #1 #2 #3 #4 {\l_tmpa_tl {#1 #2 #3 #4}} \int_step_inline:nnn {"00} {"7F} { - \expandafter\let\csname __umi_brace_handle_ \char_generate:nn {#1} {12} \endcsname \relax + \expandafter\let\csname __umi_brace_handle_ \char_generate:nn {#1} {12} \endcsname \__umi_brace_nobrace } \int_step_inline:nnn {"80} {"BF} { \expandafter\let\csname __umi_brace_handle_ \char_generate:nn {#1} {12} \endcsname \__umi_brace_error |