| 1 |
%% This is part of the OpTeX project, see http://petr.olsak.net/optex |
| 2 |
|
| 3 |
\_codedecl \_ncharrmA {Uni math codes <2026-05-08>} % preloaded on demand by \loadmath |
| 4 |
|
| 5 |
\_doc ----------------------------- |
| 6 |
Unicode math font includes all typical math alphabets together, user needs no |
| 7 |
load more \TeX/ math families. These math alphabets are encoded by |
| 8 |
different parts of Unicode table. We need auxiliary macros for setting |
| 9 |
mathcodes by selected math alphabet. |
| 10 |
\nl |
| 11 |
\`\_umathrange` `{<from->-<to>}<class><family>\<first>` sets `\Umathcode`s |
| 12 |
of the characters in the interval `<from>-<to>` to `\<first>`, |
| 13 |
`\<first>+1`, `\<first>+2` |
| 14 |
etc., but \`\_umathcharholes` are skipped |
| 15 |
(`\_umathcharholes` are parts of the Unicode table not designed for math |
| 16 |
alphabets, they cause that the math alphabets are |
| 17 |
not continuously spread out in the table; I mean that the |
| 18 |
designers were under the influence of drugs when they created |
| 19 |
this part of the Unicode table). |
| 20 |
The `<from>-<to>` clause includes characters like~`A-Z`. |
| 21 |
Note that the `\_umathrange` sets the \`\_classfam` macro as <class> |
| 22 |
<family> for later use. |
| 23 |
\_cod ----------------------------- |
| 24 |
|
| 25 |
\_newcount\_umathnumA \_newcount\_umathnumB |
| 26 |
|
| 27 |
\_def\_umathholes[#1]#2{\_ifx^#1^\_else |
| 28 |
\_ea\_chardef \_csname _mh:#1\_endcsname=#2 \_ea\_umathholes\_fi} |
| 29 |
\_umathholes % holes in math alphabets: |
| 30 |
[119893]{"210E}[119965]{"212C}[119968]{"2130}[119969]{"2131}% |
| 31 |
[119971]{"210B}[119972]{"2110}[119975]{"2112}[119976]{"2133}[119981]{"211B}% |
| 32 |
[119994]{"212F}[119996]{"210A}[120004]{"2134}% |
| 33 |
[120070]{"212D}[120075]{"210C}[120076]{"2111}[120085]{"211C}[120093]{"2128}% |
| 34 |
[120122]{"2102}[120127]{"210D}[120133]{"2115}[120135]{"2119}% |
| 35 |
[120136]{"211A}[120137]{"211D}[120145]{"2124}[]{}% |
| 36 |
\_let\_umathholes=\_undefined |
| 37 |
|
| 38 |
\_def\_umathrange#1#2#3#4{\_umathnumB=#4\_def\_classfam{#2 #3 }\_umathrangeA#1} |
| 39 |
\_def\_umathrangeA#1-#2{\_umathnumA=`#1\_relax |
| 40 |
\_loop |
| 41 |
\_Umathcode \_umathnumA = \_classfam \_trycs{_mh:\_the\_umathnumB}\_umathnumB |
| 42 |
\_ifnum\_umathnumA<`#2\_relax |
| 43 |
\_advance\_umathnumA by1 \_advance\_umathnumB by1 |
| 44 |
\_repeat |
| 45 |
} |
| 46 |
|
| 47 |
\_doc ----------------------------- |
| 48 |
A few math characters have very specific Unicode and must be handled |
| 49 |
individually. We can run \`\_umathrangespec``<list of characters>\relax` |
| 50 |
just after \^`\_umathrange`. The `\_umathnumB` must be set to the first |
| 51 |
destination code. The \^`\_umathrangespec` applies to each character from |
| 52 |
the <list of characters> this: |
| 53 |
`\Umathcode``<char-code>=\_classfam\_umathnumB` and increments |
| 54 |
`\_umathnumB`. If `\_umathnumB=0` then it applies |
| 55 |
`\Umathcode``<char-code>=\_classfam <char-code>`. |
| 56 |
The \^`\_classfam` and `\_umathnumB` were typically set by previous call |
| 57 |
of the \^`\_umathrange` macro. |
| 58 |
\_cod ----------------------------- |
| 59 |
|
| 60 |
\_def\_umathrangespec#1{\_ifx#1\_relax \_else |
| 61 |
\_Umathcode `#1=\_classfam \_ifnum\_umathnumB=0 `#1 \_else \_umathnumB\_fi |
| 62 |
\_unless\_ifnum\_umathnumB=0 \_advance\_umathnumB by1 \_fi |
| 63 |
\_ea\_umathrangespec \_fi |
| 64 |
} |
| 65 |
|
| 66 |
\_doc ----------------------------- |
| 67 |
The math alphabets are set by |
| 68 |
\`\_rmvariables`, \`\_rmletters`, \`\_bfvariables`, \`\_bfletters`,\nl |
| 69 |
\`\_itvariables`, \`\_itletters`, \`\_bivariables`, \`\_biletters`,\nl |
| 70 |
\`\_calvariables`, \`\_bcalvariables`, \`\_frakvariables`, |
| 71 |
\`\_bfrakvariables`, \`\_bbvariables`,\nl \`\_sansvariables`, |
| 72 |
\`\_bsansvariables`, \`\_isansvariables`, \`\_bisansvariables`, |
| 73 |
\`\_ttvariables`,\nl \`\_itgreek`, \`\_rmgreek,` \`\_bfgreek`, \`\_bigreek`, |
| 74 |
\`\_bsansgreek`, \`\_bisansgreek`,\nl \`\_itGreek`, \`\_rmGreek`, \`\_bfGreek`, |
| 75 |
\`\_biGreek`, \`\_bsansGreek`, \`\_bisansGreek`,\nl \`\_rmdigits`, |
| 76 |
\`\_bfdigits`, \`\_bbdigits`, \`\_sansdigits`, \`\_bsansdigits`, |
| 77 |
\`\_ttdigits`.\nl |
| 78 |
They are declared using the |
| 79 |
\^`\_umathrange {<range>}<class><family><starting-code>` macro. |
| 80 |
\_cod ----------------------------- |
| 81 |
|
| 82 |
\_chardef\_ncharrmA=`A \_chardef\_ncharrma=`a |
| 83 |
\_chardef\_ncharbfA="1D400 \_chardef\_ncharbfa="1D41A |
| 84 |
\_chardef\_ncharitA="1D434 \_chardef\_ncharita="1D44E |
| 85 |
\_chardef\_ncharbiA="1D468 \_chardef\_ncharbia="1D482 |
| 86 |
\_chardef\_ncharclA="1D49C \_chardef\_ncharcla="1D4B6 |
| 87 |
\_chardef\_ncharbcA="1D4D0 \_chardef\_ncharbca="1D4EA |
| 88 |
\_chardef\_ncharfrA="1D504 \_chardef\_ncharfra="1D51E |
| 89 |
\_chardef\_ncharbrA="1D56C \_chardef\_ncharbra="1D586 |
| 90 |
\_chardef\_ncharbbA="1D538 \_chardef\_ncharbba="1D552 |
| 91 |
\_chardef\_ncharsnA="1D5A0 \_chardef\_ncharsna="1D5BA |
| 92 |
\_chardef\_ncharbsA="1D5D4 \_chardef\_ncharbsa="1D5EE |
| 93 |
\_chardef\_ncharsiA="1D608 \_chardef\_ncharsia="1D622 |
| 94 |
\_chardef\_ncharsxA="1D63C \_chardef\_ncharsxa="1D656 |
| 95 |
\_chardef\_ncharttA="1D670 \_chardef\_nchartta="1D68A |
| 96 |
|
| 97 |
\_protected\_def\_rmvariables {\_umathrange{A-Z}71\_ncharrmA \_umathrange{a-z}71\_ncharrma} |
| 98 |
\_protected\_def\_rmletters {\_umathrange{A-Z}72\_ncharrmA \_umathrange{a-z}72\_ncharrma} |
| 99 |
\_protected\_def\_bfvariables {\_umathrange{A-Z}71\_ncharbfA \_umathrange{a-z}71\_ncharbfa} |
| 100 |
\_protected\_def\_bfletters {\_umathrange{A-Z}72\_ncharbfA \_umathrange{a-z}72\_ncharbfa} |
| 101 |
\_protected\_def\_itvariables {\_umathrange{A-Z}71\_ncharitA \_umathrange{a-z}71\_ncharita} |
| 102 |
\_protected\_def\_itletters {\_umathrange{A-Z}72\_ncharitA \_umathrange{a-z}72\_ncharita} |
| 103 |
\_protected\_def\_bivariables {\_umathrange{A-Z}71\_ncharbiA \_umathrange{a-z}71\_ncharbia} |
| 104 |
\_protected\_def\_biletters {\_umathrange{A-Z}72\_ncharbiA \_umathrange{a-z}72\_ncharbia} |
| 105 |
\_protected\_def\_calvariables {\_umathrange{A-Z}71\_ncharclA \_umathrange{a-z}71\_ncharcla} |
| 106 |
\_protected\_def\_bcalvariables {\_umathrange{A-Z}71\_ncharbcA \_umathrange{a-z}71\_ncharbca} |
| 107 |
\_protected\_def\_frakvariables {\_umathrange{A-Z}71\_ncharfrA \_umathrange{a-z}71\_ncharfra} |
| 108 |
\_protected\_def\_bfrakvariables {\_umathrange{A-Z}71\_ncharbrA \_umathrange{a-z}71\_ncharbra} |
| 109 |
\_protected\_def\_bbvariables {\_umathrange{A-Z}71\_ncharbbA \_umathrange{a-z}71\_ncharbba} |
| 110 |
\_protected\_def\_sansvariables {\_umathrange{A-Z}71\_ncharsnA \_umathrange{a-z}71\_ncharsna} |
| 111 |
\_protected\_def\_bsansvariables {\_umathrange{A-Z}71\_ncharbsA \_umathrange{a-z}71\_ncharbsa} |
| 112 |
\_protected\_def\_isansvariables {\_umathrange{A-Z}71\_ncharsiA \_umathrange{a-z}71\_ncharsia} |
| 113 |
\_protected\_def\_bisansvariables {\_umathrange{A-Z}71\_ncharsxA \_umathrange{a-z}71\_ncharsxa} |
| 114 |
\_protected\_def\_ttvariables {\_umathrange{A-Z}71\_ncharttA \_umathrange{a-z}71\_nchartta} |
| 115 |
|
| 116 |
\_chardef\_greekrmA="0391 \_chardef\_greekrma="03B1 |
| 117 |
\_chardef\_greekbfA="1D6A8 \_chardef\_greekbfa="1D6C2 |
| 118 |
\_chardef\_greekitA="1D6E2 \_chardef\_greekita="1D6FC |
| 119 |
\_chardef\_greekbiA="1D71C \_chardef\_greekbia="1D736 |
| 120 |
\_chardef\_greeksnA="1D756 \_chardef\_greeksna="1D770 |
| 121 |
\_chardef\_greeksiA="1D790 \_chardef\_greeksia="1D7AA |
| 122 |
|
| 123 |
\_protected\_def\_itgreek {\_umathrangegreek71\_greekita} |
| 124 |
\_protected\_def\_rmgreek {\_umathrangegreek71\_greekrma} |
| 125 |
\_protected\_def\_bfgreek {\_umathrangegreek71\_greekbfa} |
| 126 |
\_protected\_def\_bigreek {\_umathrangegreek71\_greekbia} |
| 127 |
\_protected\_def\_bsansgreek {\_umathrangegreek71\_greeksna} |
| 128 |
\_protected\_def\_bisansgreek{\_umathrangegreek71\_greeksia} |
| 129 |
\_protected\_def\_itGreek {\_umathrangeGREEK71\_greekitA} |
| 130 |
\_protected\_def\_rmGreek {\_umathrangeGREEK71\_greekrmA} |
| 131 |
\_protected\_def\_bfGreek {\_umathrangeGREEK71\_greekbfA} |
| 132 |
\_protected\_def\_biGreek {\_umathrangeGREEK71\_greekbiA} |
| 133 |
\_protected\_def\_bsansGreek {\_umathrangeGREEK71\_greeksnA} |
| 134 |
\_protected\_def\_bisansGreek{\_umathrangeGREEK71\_greeksiA} |
| 135 |
|
| 136 |
\_chardef\_digitrmO=`0 |
| 137 |
\_chardef\_digitbfO="1D7CE |
| 138 |
\_chardef\_digitbbO="1D7D8 |
| 139 |
\_chardef\_digitsnO="1D7E2 |
| 140 |
\_chardef\_digitbsO="1D7EC |
| 141 |
\_chardef\_digitttO="1D7F6 |
| 142 |
|
| 143 |
\_protected\_def\_rmdigits {\_umathrange{0-9}71\_digitrmO} |
| 144 |
\_protected\_def\_bfdigits {\_umathrange{0-9}71\_digitbfO} |
| 145 |
\_protected\_def\_bbdigits {\_umathrange{0-9}71\_digitbbO} |
| 146 |
\_protected\_def\_sansdigits {\_umathrange{0-9}71\_digitsnO} |
| 147 |
\_protected\_def\_bsansdigits {\_umathrange{0-9}71\_digitbsO} |
| 148 |
\_protected\_def\_ttdigits {\_umathrange{0-9}71\_digitttO} |
| 149 |
|
| 150 |
\_doc ----------------------------- |
| 151 |
The control sequences for `\alpha`, `\beta`, etc.\ are redefined here. |
| 152 |
The `\alpha` will expand to the character with Unicode `"03B1`, this is a normal |
| 153 |
character $α$. You can type it directly in your editor if you know how |
| 154 |
to do this. These sequences are declared by |
| 155 |
`\_greekdef``<list of sequences>\relax`. |
| 156 |
\_cod ----------------------------- |
| 157 |
|
| 158 |
\_def\_greekdef#1{\_ifx#1\_relax |
| 159 |
\_else |
| 160 |
\_edef#1{\_Uchar\_umathnumB}% |
| 161 |
\_advance\_umathnumB by 1 |
| 162 |
\_ea\_greekdef \_fi |
| 163 |
} |
| 164 |
\_umathnumB="0391 |
| 165 |
\_greekdef \Alpha \Beta \Gamma \Delta \Epsilon \Zeta \Eta \Theta \Iota \Kappa |
| 166 |
\Lambda \Mu \Nu \Xi \Omicron \Pi \Rho \varTheta \Sigma \Tau \Upsilon \Phi |
| 167 |
\Chi \Psi \Omega \_relax |
| 168 |
|
| 169 |
\_umathnumB="03B1 |
| 170 |
\_greekdef \alpha \beta \gamma \delta \varepsilon \zeta \eta \theta \iota \kappa |
| 171 |
\lambda \mu \nu \xi \omicron \pi \rho \varsigma \sigma \tau \upsilon |
| 172 |
\varphi \chi \psi \omega \_relax |
| 173 |
|
| 174 |
\_doc ----------------------------- |
| 175 |
The \`\_umathrangeGREEK``<class><family><first>` and |
| 176 |
\`\_umathrangegreek``<class><family><first>` macros |
| 177 |
for setting math codes of Greek characters are defined here. They use \^`\_umathrange` |
| 178 |
for general codes but the exceptions must be handled by the |
| 179 |
\^`\_umathrangespec` macro. |
| 180 |
The exceptions are seven Greek characters: |
| 181 |
$\epsilon, \vartheta, \varkappa, \phi, \varrho, \varpi, \nabla$. |
| 182 |
The first six of these characters should behave as lowercase Greek letters |
| 183 |
and the last one `\nabla` is uppercase Greek letter. |
| 184 |
\_cod ----------------------------- |
| 185 |
|
| 186 |
\_def\epsilon{^^^^03f5} \_def\vartheta{^^^^03d1} \_def\varkappa{^^^^03f0} |
| 187 |
\_def\phi{^^^^03d5} \_def\varrho{^^^^03f1} \_def\varpi{^^^^03d6} |
| 188 |
\_def \nabla{^^^^2207} |
| 189 |
|
| 190 |
\_def\_umathrangeGREEK#1#2#3{\_umathrange{^^^^0391-^^^^03a9}#1#2#3% \Alpha-\Omega |
| 191 |
\_resetnabla % you can do \let\_resetnabla=\relax if you don't want to change \nabla shape |
| 192 |
} |
| 193 |
\_def\_resetnabla {% |
| 194 |
\_ifnum\_umathnumB<950 \_umathnumB=0 \_else \_advance\_umathnumB by1 \_fi |
| 195 |
\_umathrangespec ^^^^2207\_relax % \nabla |
| 196 |
} |
| 197 |
\_def\_umathrangegreek#1#2#3{% |
| 198 |
\_umathrange{^^^^03b1-^^^^03c9}#1#2#3% \alpha-\omega |
| 199 |
\_ifnum#3=\_greekrma \_umathnumB=0 \_else \_advance\_umathnumB by2 \_fi |
| 200 |
\_umathrangespec ^^^^03f5^^^^03d1^^^^03f0^^^^03d5^^^^03f1^^^^03d6\_relax % \epsilon-\varpi |
| 201 |
} |
| 202 |
|
| 203 |
\_doc ----------------------------- |
| 204 |
The math alphabets \`\cal`, \`\bbchar`, \`\frak`, \`\script`, |
| 205 |
\`\misans`, \`\mbisans` are re-defined |
| 206 |
here. The \`\_marm`, \`\_mabf`, \`\_mait`, \`\_mabi`, \`\_matt` |
| 207 |
used in \^`\rm`, \^`\bf`, \^`\it`, \^`\bi` are re-defined too.\nl |
| 208 |
You can redefine them again if you need different behavior (for example |
| 209 |
you don't want to use sans serif bold in math). What to do: |
| 210 |
\begtt |
| 211 |
\_protected\_def\_mabf {\_inmath{\_bfvariables\_bfgreek\_bfGreek\_bfdigits}} |
| 212 |
\_protected\_def\_mabi {\_inmath{\_bivariables\_bigreek\_bfGreek\_bfdigits}} |
| 213 |
\endtt |
| 214 |
\`\_inmath` `{<cmds>}` applies `<cmds>` only in math mode. |
| 215 |
\_cod ----------------------------- |
| 216 |
|
| 217 |
\_protected\_def\_inmath#1{\_relax \_ifmmode#1\_fi} % to keep off \loop processing in text mode |
| 218 |
|
| 219 |
% You can redefine these macros to follow your wishes. |
| 220 |
% For example, you need upright lowercase greek letters, you don't need |
| 221 |
% \bf and \bi behave as sans serif in math, ... |
| 222 |
|
| 223 |
\_protected\_def\_marm {\_inmath{\_rmletters \_rmdigits}} |
| 224 |
\_protected\_def\_mait {\_inmath{\_itletters \_itGreek}} |
| 225 |
\_protected\_def\_mabf {\_inmath{\_bsansvariables \_bsansgreek \_bsansGreek \_bsansdigits}} |
| 226 |
\_protected\_def\_mabi {\_inmath{\_bisansvariables \_bisansgreek \_bsansGreek \_bsansdigits}} |
| 227 |
\_protected\_def\_matt {\_inmath{\_ttvariables \_ttdigits}} |
| 228 |
\_protected\_def\_bbchar {\_bbvariables \_bbdigits} |
| 229 |
\_protected\_def\_cal {\_calvariables} |
| 230 |
\_protected\_def\_frak {\_frakvariables} |
| 231 |
\_protected\_def\_misans {\_isansvariables \_sansdigits} |
| 232 |
\_protected\_def\_mbisans {\_bisansvariables \_bisansgreek \_bsansGreek \_bsansdigits} |
| 233 |
\_protected\_def\_script {\_rmvariables \_fam4 } |
| 234 |
\_protected\_def\_mit {\_itvariables \_rmdigits \_itgreek \_rmGreek } |
| 235 |
|
| 236 |
\_public \bbchar \cal \frak \misans \mbisans \script \mit ; |
| 237 |
|
| 238 |
\_doc ----------------------------- |
| 239 |
Each Unicode slot carries information about math type. This is saved in |
| 240 |
the file `MathClass-15.txt` which is copied to `mathclass.opm` The file |
| 241 |
has the following format: |
| 242 |
{\vitt{mathclass.opm}\verbinput (70-85) mathclass.opm }% |
| 243 |
We have to read this information and convert it to the `\Umathcode`s. |
| 244 |
\_cod ----------------------------- |
| 245 |
|
| 246 |
\_begingroup % \input mathclass.opm (which is a copy of MathClass.txt): |
| 247 |
\_long\_def\_p#1;#2 {\_ifx^#2^\_else |
| 248 |
\_edef\_tmp{\_csname _c:#2\_endcsname}\_if\_relax\_tmp\_else \_pA#1....\_end#2\_fi |
| 249 |
\_ea\_p \_fi } |
| 250 |
\_def\_pA#1..#2..#3\_end#4{% |
| 251 |
\_ifx\_relax#2\_relax \_pset{"#1}{#4}\_else \_fornum "#1.."#2\_do{\_pset{##1}{#4}}\_fi |
| 252 |
} |
| 253 |
\_sdef{_c:L}{1}\_sdef{_c:B}{2}\_sdef{_c:V}{2}\_sdef{_c:R}{3}\_sdef{_c:N}{0}\_sdef{_c:U}{0} |
| 254 |
\_sdef{_c:F}{0}\_sdef{_c:O}{4}\_sdef{_c:C}{5}\_sdef{_c:P}{6}\_sdef{_c:A}{7} |
| 255 |
\_def\_pset#1#2{\_Umathcode#1=\_tmp\_space 1 #1\_relax |
| 256 |
\_if#2O\_Udelcode#1=1 #1\_relax\_fi |
| 257 |
\_if#2C\_Udelcode#1=1 #1\_relax\_fi |
| 258 |
\_if#2F\_Udelcode#1=1 #1\_relax\_fi |
| 259 |
} |
| 260 |
\_catcode`#=14 \_everyeof={;{} } \_def\par{} |
| 261 |
\_globaldefs=1 \_ea \_p \_input mathclass.opm |
| 262 |
\_endgroup |
| 263 |
|
| 264 |
\_doc ----------------------------- |
| 265 |
Each math symbol has its declaration in the file `unicode-math-table.tex` |
| 266 |
which is copied to `unimath-table.opm`. The file has the following format: |
| 267 |
{\vitt{unimath-table.opm}\verbinput (36-41) unimath-table.opm }% |
| 268 |
We have to read this information and set given control sequences as macros |
| 269 |
which expand to the given Unicode character. This solution enables to use |
| 270 |
such control sequences in PDF outlines where they expand to the appropriate |
| 271 |
Unicode character. |
| 272 |
We don't use `\mathchardef`, we set the mathcodes (class, family, slot) |
| 273 |
only at single place: for Unicode math characters. For example for we |
| 274 |
define `\times`: |
| 275 |
\begtt |
| 276 |
\def\times{^^d7} \Umathcode "D7 = 2 1 "D7 |
| 277 |
\endtt |
| 278 |
Because math codes of Greek upright letters vary depending on |
| 279 |
\^`\_itgreek`, \^`\_bfgreek`, |
| 280 |
etc.\ macros, we need to keep the access directly to these characters. |
| 281 |
We define `\mupalpha`, `\mupbeta`, ..., `\mupomega` macros as a code from |
| 282 |
PUA (Private Use Area) of Unicode table and set mathcode of these |
| 283 |
codes to the real upright alpha, beta, ..., omega. |
| 284 |
\_cod ----------------------------- |
| 285 |
|
| 286 |
\_begingroup % \input unimath-table.opm (it is a copy of unicode-math-table.tex): |
| 287 |
\_umathnumB="F800 % pointer to the Private User Area |
| 288 |
\_def\UnicodeMathSymbol #1#2#3#4{% |
| 289 |
\_edef#2{\_Uchar #1}% control sequence is a macro which expands to the Unicode character |
| 290 |
\_ifnum#1=\_Umathcodenum#1 \_Umathcode#1=0 1 #1 \_fi % it isn't set by mathclass.opm |
| 291 |
\_ifx#3\_mathaccent \_protected\_def#2{\_Umathaccent fixed 7 1 #1 }\_fi |
| 292 |
\_ifnum#1>"390 \_ifnum#1<"3F6 |
| 293 |
\_edef#2{\_Uchar\_umathnumB}% \mupAlpha, \mupBeta, \mupalpha, \mupbeta, ... |
| 294 |
\_Umathcode\_umathnumB=0 1 #1 |
| 295 |
\_advance\_umathnumB by1 |
| 296 |
\_fi\_fi % \muGreek, \mugreek symbols |
| 297 |
} |
| 298 |
\_def\mathfence{F}% |
| 299 |
\_globaldefs=1 \_input unimath-table.opm |
| 300 |
\_endgroup |
| 301 |
|
| 302 |
\_doc ----------------------------- |
| 303 |
The macro `\int` expands to an <int-character>. We save the `\mathcode` |
| 304 |
of the <int-character> to `\_int:<int-character>` using `\Umathchardef` and |
| 305 |
declare <int-character> as math-active and define it |
| 306 |
as `\_int:<int-character> \_nolimits`. Moreover, we define `\intop` as |
| 307 |
`\_int:<int-character>` (it is the integral with limits like in plain \TeX). |
| 308 |
We do this with other int-like operators listed below too. |
| 309 |
\_cod ----------------------------- |
| 310 |
|
| 311 |
\_def\_intwithnolimits#1{\_ifx#1\_relax \_else |
| 312 |
\_ea\_Umathcharnumdef\_csname _int:#1\_endcsname=\_Umathcodenum\_ea`#1 % |
| 313 |
\_ea\_def \_csname\_csstring#1op\_ea\_endcsname\_ea{\_csname _int:#1\_endcsname}% |
| 314 |
\_bgroup \_lccode`\~=\_ea`#1 \_lowercase{\_egroup |
| 315 |
\_ea\_def\_ea~\_ea{\_csname _int:#1\_endcsname\_nolimits}\_mathcode`~="8000 }% |
| 316 |
\_ea \_intwithnolimits \_fi |
| 317 |
} |
| 318 |
\_intwithnolimits \int \iint \iiint \oint \oiint \oiiint |
| 319 |
\intclockwise \varointclockwise \ointctrclockwise \sumint \iiiint \intbar \intBar \fint |
| 320 |
\pointint \sqint \intlarhk \intx \intcap \intcup \upint \lowint \_relax |
| 321 |
|
| 322 |
\_doc ----------------------------- |
| 323 |
Many special characters must be declared with care... |
| 324 |
\_cod ----------------------------- |
| 325 |
|
| 326 |
\_global\_Udelcode`<=1 "027E8 % these characters have different meaning |
| 327 |
\_global\_Udelcode`>=1 "027E9 % as normal and as delimiter |
| 328 |
|
| 329 |
\_mit % default math alphabets setting |
| 330 |
|
| 331 |
% hyphen character is transformed to minus: |
| 332 |
\_Umathcode `- = 2 1 "2212 |
| 333 |
|
| 334 |
% mathclass defines : as Punct, plain.tex as Rel, we keep mathclass, |
| 335 |
% i.e. there is difference from plain.tex, you can use $f:A\to B$. |
| 336 |
|
| 337 |
% mathclas defines ! as Ord, plain.tex as Close |
| 338 |
\_Umathcode `! = 5 1 `! % keep plain.tex declaration |
| 339 |
% mathclas defines ? as Punct, plain.tex as Close |
| 340 |
\_Umathcode `? = 5 1 `? % keep plain.tex declaration |
| 341 |
|
| 342 |
\_Umathcode `* = 2 1 "02217 % equivalent to \ast, like in plain TeX |
| 343 |
|
| 344 |
\_Umathcode "03A2 = 7 1 "03F4 % \varTheta |
| 345 |
|
| 346 |
\_Umathcode `© = 0 1 `© % usage $\copyright$ can be seen in old documents |
| 347 |
|
| 348 |
\_protected\_def \_sqrt {\_Uradical 1 "0221A } |
| 349 |
\_protected\_def \_cuberoot {\_Uradical 1 "0221B } |
| 350 |
\_protected\_def \_fourthroot {\_Uradical 1 "0221C } |
| 351 |
|
| 352 |
\_public \sqrt \cuberoot \fourthroot ; |
| 353 |
|
| 354 |
\_protected\_def \_overbrace #1{\_mathop {\_Umathaccent 7 1 "023DE{#1}}\_limits} |
| 355 |
\_protected\_def \_underbrace #1{\_mathop {\_Umathaccent bottom 7 1 "023DF{#1}}\_limits} |
| 356 |
\_protected\_def \_overparen #1{\_mathop {\_Umathaccent 7 1 "023DC{#1}}\_limits} |
| 357 |
\_protected\_def \_underparen #1{\_mathop {\_Umathaccent bottom 7 1 "023DD{#1}}\_limits} |
| 358 |
\_protected\_def \_overbracket #1{\_mathop {\_Umathaccent 7 1 "023B4{#1}}\_limits} |
| 359 |
\_protected\_def \_underbracket #1{\_mathop {\_Umathaccent bottom 7 1 "023B5{#1}}\_limits} |
| 360 |
|
| 361 |
\_public \overbrace \underbrace \overparen \underparen \overbracket \underbracket ; |
| 362 |
|
| 363 |
\_protected\_def \widehat {\_Umathaccent 7 1 "00302 } |
| 364 |
\_protected\_def \widetilde {\_Umathaccent 7 1 "00303 } |
| 365 |
\_protected\_def \overleftharpoon {\_Umathaccent 7 1 "020D0 } |
| 366 |
\_protected\_def \overrightharpoon {\_Umathaccent 7 1 "020D1 } |
| 367 |
\_protected\_def \overleftarrow {\_Umathaccent 7 1 "020D6 } |
| 368 |
\_protected\_def \overrightarrow {\_Umathaccent 7 1 "020D7 } |
| 369 |
\_protected\_def \overleftrightarrow {\_Umathaccent 7 1 "020E1 } |
| 370 |
|
| 371 |
\_protected\_def \wideoverbar {\_Umathaccent 7 1 "00305 } |
| 372 |
\_protected\_def \widebreve {\_Umathaccent 7 1 "00306 } |
| 373 |
\_protected\_def \widecheck {\_Umathaccent 7 1 "0030C } |
| 374 |
\_protected\_def \wideutilde #1{\_Umathaccent bottom 7 1 "00330{\_kern\_zo #1}} |
| 375 |
\_protected\_def \mathunderbar #1{\_Umathaccent bottom 7 1 "00332{\_kern\_zo #1}} |
| 376 |
\_protected\_def \underleftrightarrow #1{\_Umathaccent bottom 7 1 "0034D{\_kern\_zo #1}} |
| 377 |
\_protected\_def \widebridgeabove {\_Umathaccent 7 1 "020E9 } |
| 378 |
\_protected\_def \underrightharpoondown #1{\_Umathaccent bottom 7 1 "020EC{\_kern\_zo #1}} |
| 379 |
\_protected\_def \underleftharpoondown #1{\_Umathaccent bottom 7 1 "020ED{\_kern\_zo #1}} |
| 380 |
\_protected\_def \underleftarrow #1{\_Umathaccent bottom 7 1 "020EE{\_kern\_zo #1}} |
| 381 |
\_protected\_def \underrightarrow #1{\_Umathaccent bottom 7 1 "020EF{\_kern\_zo #1}} |
| 382 |
|
| 383 |
\_mathchardef\ldotp="612E |
| 384 |
\_let\|=\Vert |
| 385 |
\_mathcode`\_="8000 |
| 386 |
|
| 387 |
\_global\_Umathcode "22EF = 0 1 "22EF % mathclass says that it is Rel |
| 388 |
\_global\_Umathcode "002E = 0 1 "002E % mathclass says that dot is Punct |
| 389 |
|
| 390 |
\_global\_Umathcode `/ = 0 1 `/ % mathclass says that / is Bin, Plain TeX says that it is Ord. |
| 391 |
|
| 392 |
% compressed dots in S and SS styles (usable in \matrix when it is in T, S and SS style) |
| 393 |
\_protected\_def \vdots {\_relax \_ifnum \_mathstyle>3 \_unicodevdots \_else \_vdots \_fi} |
| 394 |
\_protected\_def \ddots {\_relax \_ifnum \_mathstyle>3 \_unicodeddots \_else \_ddots \_fi} |
| 395 |
\_protected\_def \adots {\_relax \_ifnum \_mathstyle>3 \_unicodeadots \_else \_adots \_fi} |
| 396 |
|
| 397 |
% Unicode superscripts (²) and subscripts as simple macros with \mathcode"8000 |
| 398 |
\_bgroup |
| 399 |
\_def\_tmp#1#2{\_global\_mathcode#1="8000 \_lccode`\~=#1 \_lowercase{\_gdef~}{#2}} |
| 400 |
\_fornum 0..1 \_do {\_tmp{"207#1}{{^#1}}} |
| 401 |
\_tmp{"B2}{{^2}}\_tmp{"B3}{{^3}} |
| 402 |
\_fornum 4..9 \_do {\_tmp{"207#1}{{^#1}}} |
| 403 |
\_fornum 0..9 \_do {\_tmp{"208#1}{{_#1}}} |
| 404 |
\_egroup |
| 405 |
|
| 406 |
\_doc ----------------------------- |
| 407 |
Aliases are declared here. They are names not mentioned in the `unimath-table.opm` file |
| 408 |
but commonly used in \TeX. |
| 409 |
\_cod ----------------------------- |
| 410 |
|
| 411 |
\_let \setminus=\smallsetminus |
| 412 |
\_let \diamond=\smwhtdiamond |
| 413 |
\_let \colon=\mathcolon |
| 414 |
\_let \bullet=\smblkcircle |
| 415 |
\_let \circ=\vysmwhtcircle |
| 416 |
\_let \bigcirc=\mdlgwhtcircle |
| 417 |
\_let \to=\rightarrow |
| 418 |
\_let \le=\leq |
| 419 |
\_let \ge=\geq |
| 420 |
\_let \neq=\ne |
| 421 |
\_protected\_def \triangle {\mathord{\bigtriangleup}} |
| 422 |
\_let \emptyset=\varnothing |
| 423 |
\_let \hbar=\hslash |
| 424 |
\_let \land=\wedge |
| 425 |
\_let \lor=\vee |
| 426 |
\_let \owns=\ni |
| 427 |
\_let \gets=\leftarrow |
| 428 |
\_let \mathring=\ocirc |
| 429 |
\_let \lnot=\neg |
| 430 |
\_let \longdivisionsign=\longdivision |
| 431 |
\_let \backepsilon=\upbackepsilon |
| 432 |
\_let \eth=\matheth |
| 433 |
\_let \dbkarow=\dbkarrow |
| 434 |
\_let \drbkarow=\drbkarrow |
| 435 |
\_let \hksearow=\hksearrow |
| 436 |
\_let \hkswarow=\hkswarrow |
| 437 |
\_let \square=\mdlgwhtsquare |
| 438 |
\_let \blacksquare=\mdlgblksquare |
| 439 |
|
| 440 |
\_let \upalpha=\mupalpha |
| 441 |
\_let \upbeta=\mupbeta |
| 442 |
\_let \upgamma=\mupgamma |
| 443 |
\_let \updelta=\mupdelta |
| 444 |
\_let \upepsilon=\mupvarepsilon |
| 445 |
\_let \upvarepsilon=\mupvarepsilon |
| 446 |
\_let \upzeta=\mupzeta |
| 447 |
\_let \upeta=\mupeta |
| 448 |
\_let \uptheta=\muptheta |
| 449 |
\_let \upiota=\mupiota |
| 450 |
\_let \upkappa=\mupkappa |
| 451 |
\_let \uplambda=\muplambda |
| 452 |
\_let \upmu=\mupmu |
| 453 |
\_let \upnu=\mupnu |
| 454 |
\_let \upxi=\mupxi |
| 455 |
\_let \upomicron=\mupomicron |
| 456 |
\_let \uppi=\muppi |
| 457 |
\_let \uprho=\muprho |
| 458 |
\_let \upvarrho=\mupvarrho |
| 459 |
\_let \upvarsigma=\mupvarsigma |
| 460 |
\_let \upsigma=\mupsigma |
| 461 |
\_let \uptau=\muptau |
| 462 |
\_let \upupsilon=\mupupsilon |
| 463 |
\_let \upvarphi=\mupvarphi |
| 464 |
\_let \upchi=\mupchi |
| 465 |
\_let \uppsi=\muppsi |
| 466 |
\_let \upomega=\mupomega |
| 467 |
\_let \upvartheta=\mupvartheta |
| 468 |
\_let \upphi=\mupphi |
| 469 |
\_let \upvarpi=\mupvarpi |
| 470 |
\_let \varTheta=\mupvarTheta |
| 471 |
\_let \vardelta=\delta |
| 472 |
|
| 473 |
\_doc ----------------------------- |
| 474 |
The \`\not` macro is redefined here. If the `\_not!<char>` is defined |
| 475 |
(by \`\_negationof`) |
| 476 |
then this macro is used. Else centered / is printed over the <char>. |
| 477 |
\_cod ----------------------------- |
| 478 |
|
| 479 |
\_protected\_def\_not#1{% |
| 480 |
\_trycs{_not!\_csstring#1}{\_mathrel{\_Umathaccent overlay fixed 7 1 "00338 {#1}}}} |
| 481 |
|
| 482 |
\_def\_negationof #1#2{\_ea\_let \_csname _not!\_csstring#1\_endcsname =#2} |
| 483 |
|
| 484 |
\_negationof = \neq |
| 485 |
\_negationof < \nless |
| 486 |
\_negationof > \ngtr |
| 487 |
\_negationof \gets \nleftarrow |
| 488 |
\_negationof \simeq \nsime |
| 489 |
\_negationof \equal \ne |
| 490 |
\_negationof \le \nleq |
| 491 |
\_negationof \ge \ngeq |
| 492 |
\_negationof \greater \ngtr |
| 493 |
\_negationof \forksnot \forks |
| 494 |
\_negationof \in \notin |
| 495 |
\_negationof \mid \nmid |
| 496 |
\_negationof \cong \ncong |
| 497 |
\_negationof \leftarrow \nleftarrow |
| 498 |
\_negationof \rightarrow \nrightarrow |
| 499 |
\_negationof \leftrightarrow \nleftrightarrow |
| 500 |
\_negationof \Leftarrow \nLeftarrow |
| 501 |
\_negationof \Leftrightarrow \nLeftrightarrow |
| 502 |
\_negationof \Rightarrow \nRightarrow |
| 503 |
\_negationof \exists \nexists |
| 504 |
\_negationof \ni \nni |
| 505 |
\_negationof \parallel \nparallel |
| 506 |
\_negationof \sim \nsim |
| 507 |
\_negationof \approx \napprox |
| 508 |
\_negationof \equiv \nequiv |
| 509 |
\_negationof \asymp \nasymp |
| 510 |
\_negationof \lesssim \nlesssim |
| 511 |
\_negationof \ngtrsim \ngtrsim |
| 512 |
\_negationof \lessgtr \nlessgtr |
| 513 |
\_negationof \gtrless \ngtrless |
| 514 |
\_negationof \prec \nprec |
| 515 |
\_negationof \succ \nsucc |
| 516 |
\_negationof \subset \nsubset |
| 517 |
\_negationof \supset \nsupset |
| 518 |
\_negationof \subseteq \nsubseteq |
| 519 |
\_negationof \supseteq \nsupseteq |
| 520 |
\_negationof \vdash \nvdash |
| 521 |
\_negationof \vDash \nvDash |
| 522 |
\_negationof \Vdash \nVdash |
| 523 |
\_negationof \VDash \nVDash |
| 524 |
\_negationof \preccurlyeq \npreccurlyeq |
| 525 |
\_negationof \succcurlyeq \nsucccurlyeq |
| 526 |
\_negationof \sqsubseteq \nsqsubseteq |
| 527 |
\_negationof \sqsupseteq \nsqsupseteq |
| 528 |
\_negationof \vartriangleleft \nvartriangleleft |
| 529 |
\_negationof \vartriangleright \nvartriangleright |
| 530 |
\_negationof \trianglelefteq \ntrianglelefteq |
| 531 |
\_negationof \trianglerighteq \ntrianglerighteq |
| 532 |
\_negationof \vinfty \nvinfty |
| 533 |
|
| 534 |
\_public \not ; |
| 535 |
|
| 536 |
\_doc ----------------------------- |
| 537 |
Newly declared public control sequences are used in internal macros by |
| 538 |
\OpTeX/. We need to get new meanings for these control sequences in |
| 539 |
the private namespace. |
| 540 |
\_cod ----------------------------- |
| 541 |
|
| 542 |
\_private |
| 543 |
\ldotp \cdotp \bullet \triangleleft \triangleright \mapstochar \rightarrow |
| 544 |
\prime \lhook \rightarrow \leftarrow \rhook \triangleright \triangleleft |
| 545 |
\rbrace \lbrace \Relbar \Rightarrow \relbar \rightarrow \Leftarrow \mapstochar |
| 546 |
\longrightarrow \Longleftrightarrow \unicodevdots \unicodeddots \unicodeadots ; |
| 547 |
|
| 548 |
\_endcode |
| 549 |
|
| 550 |
\secc More Unicode-math examples |
| 551 |
|
| 552 |
Example of using additional math font is in section 5.3 in the |
| 553 |
\ulink[http://petr.olsak.net/ftp/olsak/optex/optex-math.pdf]{\tt optex-math.pdf} documentation. |
| 554 |
More examples are in the |
| 555 |
\ulink[http://petr.olsak.net/optex/optex-tricks.html]{OpTeX tricks} and in the |
| 556 |
\ulink[https://petr.olsak.net/ftp/olsak/optex/math-doc.pdf]{math.opm} package. |
| 557 |
|
| 558 |
See \url{http://tex.stackexchange.com/questions/308749} |
| 559 |
for technical details about Unicode-math. |
| 560 |
|
| 561 |
\_endinput |
| 562 |
|
| 563 |
History: |
| 564 |
2026-05-08 default \not defined as Umathaccent, no slash |
| 565 |
2025-02-17 \mathunderbar s_2 bug fixed, see tex.stackexchange.com/questions/759771/ |
| 566 |
2026-02-09 \_umathholes use \_chardef |
| 567 |
2026-02-07 \_umathholes reimplemented |
| 568 |
2025-02-06 \_rmletters, \_itletters introduced |
| 569 |
2023-01-17 \int operators re-implemented |
| 570 |
2023-01-15 \mupalpha, \mupbeta etc. have codes from PUA |
| 571 |
2023-01-15 math control sequences are macros, they expand to math characters |
| 572 |
2023-01-14 \epsilon, \vartheta, \varkappa, \phi, \varrho, \varpi, ... bug fix |
| 573 |
2023-01-13 \mupalhpha, \mupbeta, ... bug fix |
| 574 |
2022-11-20 \mathfence's get delimiter code too |
| 575 |
2022-11-18 Delimiters re-implemented |
| 576 |
2022-11-17 \Umathchardef replaced by \chardef |
| 577 |
2022-07-20 \Umathcode for copyright declared |
| 578 |
2022-02-22 \rm, \bf etc. moved to font-select, \_marm, \_mabf etc. introduced |
| 579 |
2022-02-08 several wide math accents added |
| 580 |
2022-01-06 \varTheta corrected |
| 581 |
2021-09-15 \square, \blacksquare defined |
| 582 |
2021-04-25 \triangleright: typo fixed |
| 583 |
2021-04-20 reading mathclass.opm improved |
| 584 |
2021-04-07 \_setnabla introduced, \nabla as uppercase Greek letter |
| 585 |
2021-03-26 \it does \_itGreek |
| 586 |
2021-03-19 \{, \} are defined as mode independent macros in math-macros.opm |
| 587 |
2021-03-11 Umathcode `* declaed as \ast |
| 588 |
2021-02-03 Unicode superscripts, subscripts declared |
| 589 |
2021-01-31 Mathcode of ! ? set to Close, codes undeclared in mathclass set correctly |
| 590 |
2021-01-23 Compressed \vdots, \ddots, \adots in script(script)style. |
| 591 |
2020-11-13 Bug fix: \colon declared |
| 592 |
2020-06-13 Umathcode of / declared as in Plain TeX |
| 593 |
2020-06-07 \_itgreek \_itGreek, \_rmgreek \_rmGreek etc. introduced, names changed |
| 594 |
2020-06-03 \not\mid = \nmid added, \not corrected |
| 595 |
2020-04-30 Bug fix: \phi, \varpi etc. were bad encoded |
| 596 |
2020-04-09 Bug fix: \Udelcode`<, \Udelcode`> added |