diff options
Diffstat (limited to 'Master/texmf-dist/tex/optex/base/unimath-macros.opm')
-rw-r--r-- | Master/texmf-dist/tex/optex/base/unimath-macros.opm | 123 |
1 files changed, 39 insertions, 84 deletions
diff --git a/Master/texmf-dist/tex/optex/base/unimath-macros.opm b/Master/texmf-dist/tex/optex/base/unimath-macros.opm index 96f87a6a9b3..d4cd9e5540a 100644 --- a/Master/texmf-dist/tex/optex/base/unimath-macros.opm +++ b/Master/texmf-dist/tex/optex/base/unimath-macros.opm @@ -1,6 +1,6 @@ %% This is part of the OpTeX project, see http://petr.olsak.net/optex -\_codedecl \loadmath {Unicode Math fonts <2022-12-01>} % preloaded in format +\_codedecl \loadmath {Unicode Math fonts <2023-01-17>} % preloaded in format \_doc ----------------------------- \`\loadmath` `{<Unicode-math font>}` loads the given font. It does: @@ -143,66 +143,6 @@ \_def\_mparams{} \_doc ----------------------------- - Unicode math font includes all typical math alphabets together, user needs not to - load more \TeX/ math families. These math alphabets are encoded by - different parts of Unicode table. We need auxiliary macros for setting - mathcodes by selected math alphabet. - \nl - \`\_umathrange` `{<from->-<to>}<class><family>\<first>` sets `\Umathcode`s - of the characters in the interval `<from>-<to>` to `\<first>`, - `\<first>+1`, `\<first>+2` - etc., but \`\_umathcharholes` are skipped - (`\_umathcharholes` are parts of the Unicode table not designed for math - alphabets, they cause that the math alphabets are - not continuously spread out in the table; I mean that the - designers were under the influence of drugs when they created - this part of the Unicode table). - The `<from>-<to>` clause includes characters like~`A-Z`. - \nl - \`\_umahrangegreek` `\<first>` is the same as - `\_umathrange {<alpha>-<omega>}\<first>`. - \nl - \`\_umahrangeGREEK` `\<first>` is the same as - `\_umathrange {<Alpha>-<Omega>}\<first>`. - \nl - \`\_greekdef` `<control sequences> \_relax` defines each control sequence - as a normal character with codes `\_umathnumB`, `\_umathnumB+1`, - `\_umathnumB+2` etc. It is used for redefinig the contol sequences for - math Greek `\alpha`, `\beta`, `\gamma` etc. - \_cod ----------------------------- - -\_newcount\_umathnumA \_newcount\_umathnumB - -\_def\_umathcorr#1#2{\_ea#1\_ea{\_the#2}} -\_def\_umathprepare#1{\_def\_umathscanholes##1[#1]##2##3\_relax{##2}} -\_def\_umathvalue#1{\_ea\_umathscanholes\_umathcharholes[#1]{#1}\_relax} - -\_def\_umathcharholes{% holes in math alphabets: - [119893]{"210E}[119965]{"212C}[119968]{"2130}[119969]{"2131}% - [119971]{"210B}[119972]{"2110}[119975]{"2112}[119976]{"2133}[119981]{"211B}% - [119994]{"212F}[119996]{"210A}[120004]{"2134}% - [120070]{"212D}[120075]{"210C}[120076]{"2111}[120085]{"211C}[120093]{"2128}% - [120122]{"2102}[120127]{"210D}[120133]{"2115}[120135]{"2119} - [120136]{"211A}[120137]{"211D}[120145]{"2124}% -} -\_def\_umathrange#1#2#3#4{\_umathnumB=#4\_def\_tmp{#2 #3 }\_umathrangeA#1} -\_def\_umathrangeA#1-#2{\_umathnumA=`#1\_relax - \_loop - \_umathcorr\_umathprepare\_umathnumB - \_Umathcode \_umathnumA = \_tmp \_umathcorr\_umathvalue{\_umathnumB} - \_ifnum\_umathnumA<`#2\_relax - \_advance\_umathnumA by1 \_advance\_umathnumB by1 - \_repeat -} -\_def\_umathrangeGREEK{\_umathrange{^^^^0391-^^^^03a9}} -\_def\_umathrangegreek{\_umathrange{^^^^03b1-^^^^03d6}} -\_def\_greekdef#1{\_ifx#1\_relax \_else - \_begingroup \_lccode`X=\_umathnumB \_lowercase{\_endgroup \_def#1{X}}% - \_advance\_umathnumB by 1 - \_ea\_greekdef \_fi -} - - \_doc ----------------------------- \`\addUmathfont` `<fam> {[<normal-font>]}{<ffeatures>} {[<bold-font>]}{<ffeatures>} {<factor>}` allocates new <fam> using \^`\newfam` and adds loading this font to the \~`\normalmath` and \~`\boldmath` macros. Note that allocationos using @@ -230,16 +170,34 @@ } \_doc ----------------------------- + The math characters can be given directly (by their Unicode) or by a macro + like `\doteq`, `\times`, etc. These macros simply expand to the math character + with its Unicode. And this math character has its `\Umathcode` given by + <class>, <family>, <slot-number>. Sometimes, we may want to get these + quantities from the given Unicode math character by our macros. It is + possible by \`\themathcodeclass``<math-char>`, + \`\themathcodefam``<math-char>` and \`\themathcodechar``<math-char>` macros. + The parameter <math-char> is a math character or it is a macro like `\doteq`, `\times`. + Moreower, \`\thedelcodefam``<math-char>` and \`\thedelcodechar``<math-char>` + return delcode quaitities of givem math character. + \_cod ----------------------------- + +\_def\_getmathcode#1#2{\_directlua{tex.print(tex.get#2code(token.scan_int())[#1])}} +\_def\_themathcodeclass #1{\_getmathcode 1{math}\_ea`#1 } +\_def\_themathcodefam #1{\_getmathcode 2{math}\_ea`#1 } +\_def\_themathcodechar #1{\_getmathcode 3{math}\_ea`#1 } +\_def\_thedelcodefam #1{\_getmathcode 1{del}\_ea`#1 } +\_def\_thedelcodechar #1{\_getmathcode 2{del}\_ea`#1 } + +\_public \themathcodeclass \themathcodefam \themathcodechar \thedelcodefam \thedelcodechar ; + + \_doc ----------------------------- \`\mathchars` `<fam> {<list of sequences>}` saves <fam> to \`\_mafam` and runs for each sequence from the <list of sequences> - the relevant code settings. - The `\directlua` chunk prints the 8-digits hexadecimal code of the - sequence followed by the sequence itself. The digts are scanned by \`\_mathcharsB` - and new `\Umathcode` is declared.\nl - If there exist \_d:<sequence> (i.e.\ it is delimiter) then `\Udelcode` is - redeclared too. Finally, in case of `\int`-like operators the - `\_intop` sequence is redeclared by `\Umathchardef`. Note that the used - primitives have the syntax: + the relevant code settings using `\Umathcode` primitive. + In case of `\int`-like operators the <math class>=8 and we only + re-declare `\_int:<int-character>` as an operator with the new \^`\_mafam`. + Note that the used primitives have the syntax: \begtt \catcode`<=13 \Umathchardef <sequence> = <math class> <math family> <slot number> \Umathcode <code> = <math class> <math family> <slot number> @@ -249,20 +207,13 @@ \_def\_mathchars {\_afterassignment\_mathcharsA \_chardef\_mafam=} \_def\_mathcharsA #1{\_foreach #1\_do{% - \_ifcsname _d:\_csstring##1\_endcsname \_ea \_mathcharsD \_csname _d:\_csstring##1\_endcsname - \_else \_mathcharsC ##1\_fi -}} -\_def\_mathcharsC #1{\_ea\_mathcharsB - \_directlua{tex.print(string.format("\_pcent08X", \_the\_Umathcode#1))}#1% -} -\_def\_mathcharsB #1#2#3#4#5#6#7#8#9{% #9 is given \math-sequence - \_ifcsname _\_csstring#9op\_endcsname - \_ea \_Umathchardef \_csname _\_csstring#9op\_endcsname=1 \_mafam #9\_relax + \_chardef\_tmp=\_themathcodeclass##1\_relax + \_ifnum\_tmp=8 % \int, \iint, \oint, etc. + \_ea\_Umathchardef \_csname _int:##1\_endcsname =1 \_mafam \_ea`##1 \_else - \_Umathcode "#4#5#6#7#8=\_numexpr"#3/2\_relax \_mafam "#4#5#6#7#8 + \_Umathcode \_ea`##1=\_tmp \_mafam \_themathcodechar##1 \_fi -} -\_def\_mathcharsD #1{\_mathcharsC #1\_relax \_Udelcode #1=\_mafam #1\_relax} +}} \_doc ----------------------------- \`\mathcodes` `<fam> {<list of pairs>}` sets mathcodes of given @@ -276,10 +227,10 @@ \_def\_mathcodes{\_afterassignment\_mathcodesA\_chardef\_mafam=} \_def\_mathcodesA#1{% \_foreach #1\_do ##1##2{% - \_ea\_foreach\_expanded{##2}\_do{\_Umathcode `####1=##1\_mafam`####1}% + \_ea\_foreach\_expanded{##2}\_do{\_Umathcode `####1=##1\_mafam \_ea`####1}% }% } -\_def\_Urange #1-#2{\_fornum `#1..`#2\_do{\_Uchar##1 }} +\_def\_Urange #1-#2{\_fornum \_ea`#1..\_ea`#2\_do{\_Uchar##1 }} \_public \addUmathfont \mathchars \mathcodes \Urange ; @@ -351,7 +302,8 @@ in the <list-of-pairs> is `<class-number><character>` (separated by optional space) or `<class-number>{<list-of-characters>}`. The <list-of-characters> includes declared characters or \^`\Urange` `<from>-<to>` which is equal to the list of characters beginning <from> and ending <to>, for example -`\Urange a-d` is equal to `abcd`. +`\Urange a-d` is equal to `abcd`. The characters can be given directly or +by the math sequences like `\times`, `\doteq` too. The \^`\mathcodes` macro declares mathcode of given characters internally by \begtt \catcode`<=13 @@ -385,6 +337,9 @@ the section~\ref[math-macros]. \_endinput +2023-01-17 \mathchars: \int operators re-implemented +2023-01-15 \_def\_umathrange moved to unimath-codes.opm +2023.01-15 \themathcodeclass etc. introduced 2022-12-01 reading number by \_loadumathfamily more robust 2022-11-18 \mathchars improved, \Udelcodes are set too, \addUmathfont uses \ahead 2022-11-17 \Umathchardef replaced by \chardef |