summaryrefslogtreecommitdiff
path: root/macros/optex/base/unimath-codes.opm
diff options
context:
space:
mode:
Diffstat (limited to 'macros/optex/base/unimath-codes.opm')
-rw-r--r--macros/optex/base/unimath-codes.opm93
1 files changed, 55 insertions, 38 deletions
diff --git a/macros/optex/base/unimath-codes.opm b/macros/optex/base/unimath-codes.opm
index 6e83ab94ad..d7f0d387ef 100644
--- a/macros/optex/base/unimath-codes.opm
+++ b/macros/optex/base/unimath-codes.opm
@@ -1,6 +1,6 @@
%% This is part of the OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \_ncharrmA {Uni math codes <2021-03-11>} % preloaded on demand by \loadmath
+\_codedecl \_ncharrmA {Uni math codes <2021-04-25>} % preloaded on demand by \loadmath
\_doc -----------------------------
The control sequences for `\alpha`, `\beta` etc are redefined here.
@@ -68,12 +68,30 @@
\_protected\_def\_bigreek {\_umathrangegreek71\_greekbia}
\_protected\_def\_bsansgreek {\_umathrangegreek71\_greeksna}
\_protected\_def\_bisansgreek{\_umathrangegreek71\_greeksia}
-\_protected\_def\_itGreek {\_umathrangeGREEK71\_greekitA}
-\_protected\_def\_rmGreek {\_umathrangeGREEK71\_greekrmA}
-\_protected\_def\_bfGreek {\_umathrangeGREEK71\_greekbfA}
-\_protected\_def\_biGreek {\_umathrangeGREEK71\_greekbiA}
-\_protected\_def\_bsansGreek {\_umathrangeGREEK71\_greeksnA}
-\_protected\_def\_bisansGreek{\_umathrangeGREEK71\_greeksiA}
+\_protected\_def\_itGreek {\_umathrangeGREEK71\_greekitA \_setnablait}
+\_protected\_def\_rmGreek {\_umathrangeGREEK71\_greekrmA \_setnablarm}
+\_protected\_def\_bfGreek {\_umathrangeGREEK71\_greekbfA \_setnablabf}
+\_protected\_def\_biGreek {\_umathrangeGREEK71\_greekbiA \_setnablabi}
+\_protected\_def\_bsansGreek {\_umathrangeGREEK71\_greeksnA \_setnablabsans}
+\_protected\_def\_bisansGreek{\_umathrangeGREEK71\_greeksiA \_setnablabisans}
+
+ \_doc -----------------------------
+ \`\_setnabla` is used in order to `\nabla` behaves like uppercase Greek
+ letter, similar like `\Delta`. It depends on `\bf`, `\it` etc. selectors.
+ If you want to deactivate this behavior, use `\def\_setnabla#1 {}`.
+ \_cod -----------------------------
+
+\_def \_setnabla {\_Umathcode"2207 = 7 1}
+\_def \_setnablarm {\_setnabla"02207 }
+\_def \_setnablabf {\_setnabla"1D6C1 }
+\_def \_setnablait {\_setnabla"1D6FB }
+\_def \_setnablabi {\_setnabla"1D735 }
+\_def \_setnablabsans {\_setnabla"1D76F }
+\_def \_setnablabisans {\_setnabla"1D7A9 }
+
+ \_doc -----------------------------
+ Digits are configured like math alphabets.
+ \_cod -----------------------------
\_chardef\_digitrmO=`0
\_chardef\_digitbfO="1D7CE
@@ -90,8 +108,7 @@
\_protected\_def\_ttdigits {\_umathrange{0-9}71\_digitttO}
\_doc -----------------------------
- The \`\cal`, \`\bbchar`, \`\frak`, \`\script`
- and
+ The \`\cal`, \`\bbchar`, \`\frak`, \`\script` and
the \`\rm`, \`\bf`, \`\it`, \`\bi`, \`\tt` are defined here.
Their \"8bit definitions" from the file `math-preload.opm`
(section~\ref[math-preload]) are removed.\nl
@@ -114,7 +131,7 @@
% \bf and \bi behave as sans serif in math, ...
\_protected\_def\_rm {\_tryloadrm \_tenrm \_inmath{\_rmvariables \_rmdigits}}
-\_protected\_def\_it {\_tryloadit \_tenit \_inmath{\_itvariables}}
+\_protected\_def\_it {\_tryloadit \_tenit \_inmath{\_itvariables \_itGreek}}
\_protected\_def\_bf
{\_tryloadbf \_tenbf \_inmath{\_bsansvariables \_bsansgreek \_bsansGreek \_bsansdigits}}
\_protected\_def\_bi
@@ -132,33 +149,28 @@
\_doc -----------------------------
Each Unicode slot carries information about math type. This is saved in
- the file `mathclass.txt` which is copied to `mathclass.opm` The file
+ the file `MathClass-15.txt` which is copied to `mathclass.opm` The file
has the following format:
{\vitt{mathclass.opm}\verbinput (70-85) mathclass.opm }
We have to read this information and convert it to the `\Umathcode`s.
\_cod -----------------------------
\_begingroup % \input mathclass.opm (which is a copy of MathClass.txt):
- \_def\_p#1;#2{\_edef\_tmp{\_pB#2}\_ifx\_tmp\_empty \_else\_pA#1....\_end#2\_fi}
+ \_long\_def\_p#1;#2 {\_ifx^#2^\_else
+ \_edef\_tmp{\_csname _c:#2\_endcsname}\_if\_relax\_tmp\_else \_pA#1....\_end#2\_fi
+ \_ea\_p \_fi }
\_def\_pA#1..#2..#3\_end#4{%
- \_ifx\_relax#2\_relax \_pset{"#1}{#4}\_else
- \_umathnumA="#1
- \_loop
- \_pset{\_umathnumA}{#4}%
- \_ifnum\_umathnumA<"#2 \_advance\_umathnumA by1
- \_repeat
- \_fi
+ \_ifx\_relax#2\_relax \_pset{"#1}{#4}\_else \_fornum "#1.."#2\_do{\_pset{##1}{#4}}\_fi
}
- \_def\_pB#1{\_if#1L1\_fi \_if#1B2\_fi \_if#1V2\_fi \_if#1R3\_fi \_if#1N0\_fi \_if#1U0\_fi
- \_if#1F0\_fi \_if#1O4\_fi \_if#1C5\_fi \_if#1P6\_fi \_if#1A7\_fi}
- \_def\_pset#1#2{\_global\_Umathcode#1=\_tmp\_space 1 #1\_relax
- \_if#2O\_global\_Udelcode#1=1 #1\_relax\_fi
- \_if#2C\_global\_Udelcode#1=1 #1\_relax\_fi
- \_if#2F\_global\_Udelcode#1=1 #1\_relax\_fi
+ \_sdef{_c:L}{1}\_sdef{_c:B}{2}\_sdef{_c:V}{2}\_sdef{_c:R}{3}\_sdef{_c:N}{0}\_sdef{_c:U}{0}
+ \_sdef{_c:F}{0}\_sdef{_c:O}{4}\_sdef{_c:C}{5}\_sdef{_c:P}{6}\_sdef{_c:A}{7}
+ \_def\_pset#1#2{\_Umathcode#1=\_tmp\_space 1 #1\_relax
+ \_if#2O\_Udelcode#1=1 #1\_relax\_fi
+ \_if#2C\_Udelcode#1=1 #1\_relax\_fi
+ \_if#2F\_Udelcode#1=1 #1\_relax\_fi
}
- \_catcode`#=14
- \_everypar={\_setbox0=\_lastbox \_par \_p}
- \_setbox0=\_vbox{\_input mathclass.opm }
+ \_catcode`#=14 \_everyeof={;{} } \_def\par{}
+ \_globaldefs=1 \_ea \_p \_input mathclass.opm
\_endgroup
\_doc -----------------------------
@@ -171,13 +183,13 @@
\_begingroup % \input unimath-table.opm (it is a copy of unicode-math-table.tex):
\_def\UnicodeMathSymbol #1#2#3#4{%
\_ifnum#1=\_Umathcodenum#1 % the code isn't set by mathclass.opm
- \_global\_Umathchardef#2=0 1 #1 \_global\_Umathcode#1=0 1 #1
- \_else \_global\_Umathcharnumdef#2=\_Umathcodenum#1 \_fi
- \_ifx#3\_mathopen \_gdef#2{\_Udelimiter 4 1 #1 }\_fi
- \_ifx#3\_mathclose \_gdef#2{\_Udelimiter 5 1 #1 }\_fi
- \_ifx#3\_mathaccent \_gdef#2{\_Umathaccent fixed 7 1 #1 }\_fi
+ \_Umathchardef#2=0 1 #1 \_Umathcode#1=0 1 #1
+ \_else \_Umathcharnumdef#2=\_Umathcodenum#1 \_fi
+ \_ifx#3\_mathopen \_def#2{\_Udelimiter 4 1 #1 }\_fi
+ \_ifx#3\_mathclose \_def#2{\_Udelimiter 5 1 #1 }\_fi
+ \_ifx#3\_mathaccent \_def#2{\_Umathaccent fixed 7 1 #1 }\_fi
}
- \_input unimath-table.opm
+ \_globaldefs=1 \_input unimath-table.opm
\_endgroup
\_doc -----------------------------
@@ -195,8 +207,6 @@
% mathclass defines : as Punct, plain.tex as Rel, we keep mathclass,
% i.e. there is difference from plain.tex, you can use $f:A\to B$.
-\_let\{=\lbrace \_let\}=\rbrace
-
% mathclas defines ! as Ord, plain.tex as Close
\_Umathcode `! = 5 1 `! % keep plain.tex declaration
\_Umathchardef \mathexclam = 5 1 `!
@@ -210,6 +220,8 @@
\_protected\_def \_cuberoot {\_Uradical 1 "0221B }
\_protected\_def \_fourthroot {\_Uradical 1 "0221C }
+\_def \nabla {^^^^2207} % \nabla behaves as uppercase Gereek letter, see \_setnabla
+
\_public \sqrt \cuberoot \fourthroot ;
\_def\_intwithnolimits#1#2 {\_ifx#1\_relax \_else
@@ -405,9 +417,9 @@
\_cod -----------------------------
\_private
- \ldotp \cdotp \bullet \triangleleft \trianglerigt \mapstochar \rightarrow
+ \ldotp \cdotp \bullet \triangleleft \triangleright \mapstochar \rightarrow
\prime \lhook \rightarrow \leftarrow \rhook \triangleright \triangleleft
- \Relbar \Rightarrow \relbar \rightarrow \Leftarrow \mapstochar
+ \rbrace \lbrace \Relbar \Rightarrow \relbar \rightarrow \Leftarrow \mapstochar
\longrightarrow \Longleftrightarrow \unicodevdots \unicodeddots \unicodeadots ;
\_endcode
@@ -427,6 +439,11 @@ for technical details about Unicode-math.
\_endinput
History:
+2021-04-25 \triangleright: typo fixed
+2021-04-20 reading mathclass.opm improved
+2021-04-07 \_setnabla introduced, \nabla as uppercase Greek letter
+2021-03-26 \it does \_itGreek
+2021-03-19 \{, \} are defined as mode independent macros in math-macros.opm
2021-03-11 Umathcode `* declaed as \ast
2021-02-03 Unicode superscripts, subscripts declared
2021-01-31 Mathcode of ! ? set to Close, codes undeclared in mathclass set correctly