r3tex

custom LuaTeX format
git clone git://git.rr3.xyz/r3tex
Log | Files | Refs | README | LICENSE

commit 7f58376b4321d9d44d4cf951cab07edf0a7bf8bc
parent 4bf471a63007692778d3859205d8b495cf221cb9
Author: robert <robertrussell.72001@gmail.com>
Date:   Sun, 23 Jan 2022 22:12:55 -0800

Extract encoding-specific math stuff

Later we should add a fancy encoding switching system as part of the
font system. For now we just move this so it's out of the way.

Diffstat:
Mmath.tex | 274+++++++------------------------------------------------------------------------
Amathenc.tex | 253+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 275 insertions(+), 252 deletions(-)

diff --git a/math.tex b/math.tex @@ -1,221 +1,32 @@ -% TODO: mathcode, delcode, mathchardefs, etc should be encoding-specific % TODO: most things here copied from plain; need to sort thru -% INITEX sets up \mathcode x=x, for x=0..255, except that -% \mathcode x=x+"7100, for x = `A to `Z and `a to `z; -% \mathcode x=x+"7000, for x = `0 to `9. -\mathcode`\ ="8000 % \space -\mathcode`\!="5021 -\mathcode`\'="8000 % ^\prime -\mathcode`\(="4028 -\mathcode`\)="5029 -\mathcode`\*="2203 % \ast -\mathcode`\+="202B -\mathcode`\,="613B -\mathcode`\-="2200 -\mathcode`\.="013A -\mathcode`\/="013D -\mathcode`\:="303A -\mathcode`\;="603B -\mathcode`\<="313C -\mathcode`\=="303D -\mathcode`\>="313E -\mathcode`\?="503F -\mathcode`\[="405B -\mathcode`\\="026E % \backslash -\mathcode`\]="505D -\mathcode`\_="8000 % \_ -\mathcode`\{="4266 -\mathcode`\|="026A -\mathcode`\}="5267 - -% INITEX sets all \delcode values to -1, except \delcode`.=0 -\delcode`\(="028300 -\delcode`\)="029301 -\delcode`\[="05B302 -\delcode`\]="05D303 -\delcode`\<="26830A -\delcode`\>="26930B -\delcode`\/="02F30E -\delcode`\|="26A30C -\delcode`\\="26E30F -% N.B. { and } should NOT get delcodes; otherwise parameter grouping fails! - -% Greek letters -\mathchardef\alpha="010B -\mathchardef\beta="010C -\mathchardef\gamma="010D -\mathchardef\delta="010E -\mathchardef\epsilon="010F -\mathchardef\zeta="0110 -\mathchardef\eta="0111 -\mathchardef\theta="0112 -\mathchardef\iota="0113 -\mathchardef\kappa="0114 -\mathchardef\lambda="0115 -\mathchardef\mu="0116 -\mathchardef\nu="0117 -\mathchardef\xi="0118 -\mathchardef\pi="0119 -\mathchardef\rho="011A -\mathchardef\sigma="011B -\mathchardef\tau="011C -\mathchardef\upsilon="011D -\mathchardef\phi="011E -\mathchardef\chi="011F -\mathchardef\psi="0120 -\mathchardef\omega="0121 -\mathchardef\varepsilon="0122 -\mathchardef\vartheta="0123 -\mathchardef\varpi="0124 -\mathchardef\varrho="0125 -\mathchardef\varsigma="0126 -\mathchardef\varphi="0127 -\mathchardef\Gamma="7000 -\mathchardef\Delta="7001 -\mathchardef\Theta="7002 -\mathchardef\Lambda="7003 -\mathchardef\Xi="7004 -\mathchardef\Pi="7005 -\mathchardef\Sigma="7006 -\mathchardef\Upsilon="7007 -\mathchardef\Phi="7008 -\mathchardef\Psi="7009 -\mathchardef\Omega="700A - -\mathchardef\aleph="0240 -\def\hbar{{\mathchar'26 \mkern-9mu h}} -\mathchardef\imath="017B -\mathchardef\jmath="017C -\mathchardef\ell="0160 -\mathchardef\wp="017D -\mathchardef\Re="023C -\mathchardef\Im="023D -\mathchardef\partial="0140 -\mathchardef\infty="0231 -\mathchardef\prime="0230 -\mathchardef\emptyset="023B -\mathchardef\nabla="0272 -\def\surd{{\mathchar"1270}} -\mathchardef\top="023E -\mathchardef\bot="023F -\def\angle{{\vbox{\ialign{$\m@th\scriptstyle##$\crcr - \not\mathrel{\mkern14mu}\crcr - \noalign{\nointerlineskip} - \mkern2.5mu\leaders\hrule height.34pt\hfill\mkern2.5mu\crcr}}}} -\mathchardef\triangle="0234 -\mathchardef\forall="0238 -\mathchardef\exists="0239 -\mathchardef\neg="023A \let\lnot=\neg -\mathchardef\flat="015B -\mathchardef\natural="015C -\mathchardef\sharp="015D -\mathchardef\clubsuit="027C -\mathchardef\diamondsuit="027D -\mathchardef\heartsuit="027E -\mathchardef\spadesuit="027F - -\mathchardef\coprod="1360 -\mathchardef\bigvee="1357 -\mathchardef\bigwedge="1356 -\mathchardef\biguplus="1355 -\mathchardef\bigcap="1354 -\mathchardef\bigcup="1353 -\mathchardef\intop="1352 \def\int{\intop\nolimits} -\mathchardef\prod="1351 -\mathchardef\sum="1350 -\mathchardef\bigotimes="134E -\mathchardef\bigoplus="134C -\mathchardef\bigodot="134A -\mathchardef\ointop="1348 \def\oint{\ointop\nolimits} -\mathchardef\bigsqcup="1346 -\mathchardef\smallint="1273 - -\mathchardef\triangleleft="212F -\mathchardef\triangleright="212E -\mathchardef\bigtriangleup="2234 -\mathchardef\bigtriangledown="2235 -\mathchardef\wedge="225E \let\land=\wedge -\mathchardef\vee="225F \let\lor=\vee -\mathchardef\cap="225C -\mathchardef\cup="225B -\mathchardef\ddagger="227A -\mathchardef\dagger="2279 -\mathchardef\sqcap="2275 -\mathchardef\sqcup="2274 -\mathchardef\uplus="225D -\mathchardef\amalg="2271 -\mathchardef\diamond="2205 -\mathchardef\bullet="220F -\mathchardef\wr="226F -\mathchardef\div="2204 -\mathchardef\odot="220C -\mathchardef\oslash="220B -\mathchardef\otimes="220A -\mathchardef\ominus="2209 -\mathchardef\oplus="2208 -\mathchardef\mp="2207 -\mathchardef\pm="2206 -\mathchardef\circ="220E -\mathchardef\bigcirc="220D -\mathchardef\setminus="226E % for set difference A\setminus B -\mathchardef\cdot="2201 -\mathchardef\ast="2203 -\mathchardef\times="2202 -\mathchardef\star="213F - -\mathchardef\propto="322F -\mathchardef\sqsubseteq="3276 -\mathchardef\sqsupseteq="3277 -\mathchardef\parallel="326B -\mathchardef\mid="326A -\mathchardef\dashv="3261 -\mathchardef\vdash="3260 -\mathchardef\nearrow="3225 -\mathchardef\searrow="3226 -\mathchardef\nwarrow="322D -\mathchardef\swarrow="322E -\mathchardef\Leftrightarrow="322C -\mathchardef\Leftarrow="3228 -\mathchardef\Rightarrow="3229 +\let\lnot=\neg +\def\int{\intop\nolimits} +\def\oint{\ointop\nolimits} +\let\land=\wedge +\let\lor=\vee \def\neq{\not=} \let\ne=\neq -\mathchardef\leq="3214 \let\le=\leq -\mathchardef\geq="3215 \let\ge=\geq -\mathchardef\succ="321F -\mathchardef\prec="321E -\mathchardef\approx="3219 -\mathchardef\succeq="3217 -\mathchardef\preceq="3216 -\mathchardef\supset="321B -\mathchardef\subset="321A -\mathchardef\supseteq="3213 -\mathchardef\subseteq="3212 -\mathchardef\in="3232 -\mathchardef\ni="3233 \let\owns=\ni -\mathchardef\gg="321D -\mathchardef\ll="321C -\mathchardef\not="3236 -\mathchardef\leftrightarrow="3224 -\mathchardef\leftarrow="3220 \let\gets=\leftarrow -\mathchardef\rightarrow="3221 \let\to=\rightarrow -\mathchardef\mapstochar="3237 \def\mapsto{\mapstochar\rightarrow} -\mathchardef\sim="3218 -\mathchardef\simeq="3227 -\mathchardef\perp="323F -\mathchardef\equiv="3211 -\mathchardef\asymp="3210 -\mathchardef\smile="315E -\mathchardef\frown="315F -\mathchardef\leftharpoonup="3128 -\mathchardef\leftharpoondown="3129 -\mathchardef\rightharpoonup="312A -\mathchardef\rightharpoondown="312B +\let\le=\leq +\let\ge=\geq +\let\owns=\ni +\let\gets=\leftarrow +\let\to=\rightarrow +\def\mapsto{\mapstochar\rightarrow} +\let\|=\Vert +\let\>=\rangle +\let\<=\langle +\let\}=\rbrace +\let\{=\lbrace +\let\rc=\rceil +\let\lc=\lceil +\let\rf=\rfloor +\let\lr=\lfoor \def\joinrel{\mathrel{\mkern-3mu}} \def\relbar{\mathrel{\smash-}} % \smash, because - has the same height as + \def\Relbar{\mathrel=} -\mathchardef\lhook="312C \def\hookrightarrow{\lhook\joinrel\rightarrow} -\mathchardef\rhook="312D \def\hookleftarrow{\leftarrow\joinrel\rhook} +\def\hookrightarrow{\lhook\joinrel\rightarrow} +\def\hookleftarrow{\leftarrow\joinrel\rhook} \def\bowtie{\mathrel\triangleright\joinrel\mathrel\triangleleft} \def\models{\mathrel|\joinrel=} \def\Longrightarrow{\Relbar\joinrel\Rightarrow} @@ -227,9 +38,6 @@ \def\Longleftrightarrow{\Leftarrow\joinrel\Rightarrow} \def\iff{\;\Longleftrightarrow\;} -\mathchardef\ldotp="613A % ldot as a punctuation mark -\mathchardef\cdotp="6201 % cdot as a punctuation mark -\mathchardef\colon="603A % colon as a punctuation mark \def\ldots{\mathinner{\ldotp\ldotp\ldotp}} \def\cdots{\mathinner{\cdotp\cdotp\cdotp}} \def\vdots{\vbox{\baselineskip4\p@ \lineskiplimit\z@ @@ -237,18 +45,6 @@ \def\ddots{\mathinner{\mkern1mu\raise7\p@\vbox{\kern7\p@\hbox{.}}\mkern2mu \raise4\p@\hbox{.}\mkern2mu\raise\p@\hbox{.}\mkern1mu}} -\def\acute{\mathaccent"7013 } -\def\grave{\mathaccent"7012 } -\def\ddot{\mathaccent"707F } -\def\tilde{\mathaccent"707E } -\def\bar{\mathaccent"7016 } -\def\breve{\mathaccent"7015 } -\def\check{\mathaccent"7014 } -\def\hat{\mathaccent"705E } -\def\vec{\mathaccent"017E } -\def\dot{\mathaccent"705F } -\def\widetilde{\mathaccent"0365 } -\def\widehat{\mathaccent"0362 } \def\overrightarrow#1{\vbox{\m@th\ialign{##\crcr \rightarrowfill\crcr\noalign{\kern-\p@\nointerlineskip} $\hfil\displaystyle{#1}\hfil$\crcr}}} @@ -264,31 +60,6 @@ \def\skew#1#2#3{{\muskip\z@#1mu\divide\muskip\z@\tw@ \mkern\muskip\z@ #2{\mkern-\muskip\z@{#3}\mkern\muskip\z@}\mkern-\muskip\z@}{}} -\def\lmoustache{\delimiter"437A340 } % top from (, bottom from ) -\def\rmoustache{\delimiter"537B341 } % top from ), bottom from ( -\def\lgroup{\delimiter"462833A } % extensible ( with sharper tips -\def\rgroup{\delimiter"562933B } % extensible ) with sharper tips -\def\arrowvert{\delimiter"26A33C } % arrow without arrowheads -\def\Arrowvert{\delimiter"26B33D } % double arrow without arrowheads -\def\bracevert{\delimiter"77C33E } % the vertical bar that extends braces -\def\Vert{\delimiter"26B30D } \let\|=\Vert -\def\vert{\delimiter"26A30C } -\def\uparrow{\delimiter"3222378 } -\def\downarrow{\delimiter"3223379 } -\def\updownarrow{\delimiter"326C33F } -\def\Uparrow{\delimiter"322A37E } -\def\Downarrow{\delimiter"322B37F } -\def\Updownarrow{\delimiter"326D377 } -\def\backslash{\delimiter"26E30F } % for double coset G\backslash H -\def\rangle{\delimiter"526930B } \let\>=\rangle -\def\langle{\delimiter"426830A } \let\<=\langle -\def\rbrace{\delimiter"5267309 } \let\}=\rbrace -\def\lbrace{\delimiter"4266308 } \let\{=\lbrace -\def\rceil{\delimiter"5265307 } \let\rc=\rceil -\def\lceil{\delimiter"4264306 } \let\lc=\lceil -\def\rfloor{\delimiter"5263305 } \let\rf=\rfloor -\def\lfloor{\delimiter"4262304 } \let\lr=\lfoor - % Primes (with nice syntax) % TODO: simplify with \isnextchar<char>{true}{false} macro; see optex {\catcode`\'=13 \gdef'{^\bgroup\@primeA}} @@ -305,7 +76,6 @@ {\catcode`\_=\active \global\let_=\_} % Roots -\def\sqrt{\radical"270370 } \newbox\@rootbox \def\root#1\of{% \setbox\@rootbox=\hbox{$\m@th\scriptscriptstyle{#1}$}% diff --git a/mathenc.tex b/mathenc.tex @@ -0,0 +1,253 @@ +% INITEX sets up \mathcode x=x, for x=0..255, except that +% \mathcode x=x+"7100, for x = `A to `Z and `a to `z; +% \mathcode x=x+"7000, for x = `0 to `9. +\mathcode`\ ="8000 % \space +\mathcode`\!="5021 +\mathcode`\'="8000 % ^\prime +\mathcode`\(="4028 +\mathcode`\)="5029 +\mathcode`\*="2203 % \ast +\mathcode`\+="202B +\mathcode`\,="613B +\mathcode`\-="2200 +\mathcode`\.="013A +\mathcode`\/="013D +\mathcode`\:="303A +\mathcode`\;="603B +\mathcode`\<="313C +\mathcode`\=="303D +\mathcode`\>="313E +\mathcode`\?="503F +\mathcode`\[="405B +\mathcode`\\="026E % \backslash +\mathcode`\]="505D +\mathcode`\_="8000 % \_ +\mathcode`\{="4266 +\mathcode`\|="026A +\mathcode`\}="5267 + +% INITEX sets all \delcode values to -1, except \delcode`.=0 +\delcode`\(="028300 +\delcode`\)="029301 +\delcode`\[="05B302 +\delcode`\]="05D303 +\delcode`\<="26830A +\delcode`\>="26930B +\delcode`\/="02F30E +\delcode`\|="26A30C +\delcode`\\="26E30F +% N.B. { and } should NOT get delcodes; otherwise parameter grouping fails! + +% Greek letters +\mathchardef\alpha="010B +\mathchardef\beta="010C +\mathchardef\gamma="010D +\mathchardef\delta="010E +\mathchardef\epsilon="010F +\mathchardef\zeta="0110 +\mathchardef\eta="0111 +\mathchardef\theta="0112 +\mathchardef\iota="0113 +\mathchardef\kappa="0114 +\mathchardef\lambda="0115 +\mathchardef\mu="0116 +\mathchardef\nu="0117 +\mathchardef\xi="0118 +\mathchardef\pi="0119 +\mathchardef\rho="011A +\mathchardef\sigma="011B +\mathchardef\tau="011C +\mathchardef\upsilon="011D +\mathchardef\phi="011E +\mathchardef\chi="011F +\mathchardef\psi="0120 +\mathchardef\omega="0121 +\mathchardef\varepsilon="0122 +\mathchardef\vartheta="0123 +\mathchardef\varpi="0124 +\mathchardef\varrho="0125 +\mathchardef\varsigma="0126 +\mathchardef\varphi="0127 +\mathchardef\Gamma="7000 +\mathchardef\Delta="7001 +\mathchardef\Theta="7002 +\mathchardef\Lambda="7003 +\mathchardef\Xi="7004 +\mathchardef\Pi="7005 +\mathchardef\Sigma="7006 +\mathchardef\Upsilon="7007 +\mathchardef\Phi="7008 +\mathchardef\Psi="7009 +\mathchardef\Omega="700A + +\mathchardef\aleph="0240 +\def\hbar{{\mathchar'26 \mkern-9mu h}} +\mathchardef\imath="017B +\mathchardef\jmath="017C +\mathchardef\ell="0160 +\mathchardef\wp="017D +\mathchardef\Re="023C +\mathchardef\Im="023D +\mathchardef\partial="0140 +\mathchardef\infty="0231 +\mathchardef\prime="0230 +\mathchardef\emptyset="023B +\mathchardef\nabla="0272 +\def\surd{{\mathchar"1270}} +\mathchardef\top="023E +\mathchardef\bot="023F +\mathchardef\triangle="0234 +\mathchardef\forall="0238 +\mathchardef\exists="0239 +\mathchardef\neg="023A +\mathchardef\flat="015B +\mathchardef\natural="015C +\mathchardef\sharp="015D +\mathchardef\clubsuit="027C +\mathchardef\diamondsuit="027D +\mathchardef\heartsuit="027E +\mathchardef\spadesuit="027F + +\mathchardef\coprod="1360 +\mathchardef\bigvee="1357 +\mathchardef\bigwedge="1356 +\mathchardef\biguplus="1355 +\mathchardef\bigcap="1354 +\mathchardef\bigcup="1353 +\mathchardef\intop="1352 +\mathchardef\prod="1351 +\mathchardef\sum="1350 +\mathchardef\bigotimes="134E +\mathchardef\bigoplus="134C +\mathchardef\bigodot="134A +\mathchardef\ointop="1348 +\mathchardef\bigsqcup="1346 +\mathchardef\smallint="1273 + +\mathchardef\triangleleft="212F +\mathchardef\triangleright="212E +\mathchardef\bigtriangleup="2234 +\mathchardef\bigtriangledown="2235 +\mathchardef\wedge="225E +\mathchardef\vee="225F +\mathchardef\cap="225C +\mathchardef\cup="225B +\mathchardef\ddagger="227A +\mathchardef\dagger="2279 +\mathchardef\sqcap="2275 +\mathchardef\sqcup="2274 +\mathchardef\uplus="225D +\mathchardef\amalg="2271 +\mathchardef\diamond="2205 +\mathchardef\bullet="220F +\mathchardef\wr="226F +\mathchardef\div="2204 +\mathchardef\odot="220C +\mathchardef\oslash="220B +\mathchardef\otimes="220A +\mathchardef\ominus="2209 +\mathchardef\oplus="2208 +\mathchardef\mp="2207 +\mathchardef\pm="2206 +\mathchardef\circ="220E +\mathchardef\bigcirc="220D +\mathchardef\setminus="226E +\mathchardef\cdot="2201 +\mathchardef\ast="2203 +\mathchardef\times="2202 +\mathchardef\star="213F + +\mathchardef\propto="322F +\mathchardef\sqsubseteq="3276 +\mathchardef\sqsupseteq="3277 +\mathchardef\parallel="326B +\mathchardef\mid="326A +\mathchardef\dashv="3261 +\mathchardef\vdash="3260 +\mathchardef\nearrow="3225 +\mathchardef\searrow="3226 +\mathchardef\nwarrow="322D +\mathchardef\swarrow="322E +\mathchardef\Leftrightarrow="322C +\mathchardef\Leftarrow="3228 +\mathchardef\Rightarrow="3229 +\mathchardef\leq="3214 +\mathchardef\geq="3215 +\mathchardef\succ="321F +\mathchardef\prec="321E +\mathchardef\approx="3219 +\mathchardef\succeq="3217 +\mathchardef\preceq="3216 +\mathchardef\supset="321B +\mathchardef\subset="321A +\mathchardef\supseteq="3213 +\mathchardef\subseteq="3212 +\mathchardef\in="3232 +\mathchardef\ni="3233 +\mathchardef\gg="321D +\mathchardef\ll="321C +\mathchardef\not="3236 +\mathchardef\leftrightarrow="3224 +\mathchardef\leftarrow="3220 +\mathchardef\rightarrow="3221 +\mathchardef\mapstochar="3237 +\mathchardef\sim="3218 +\mathchardef\simeq="3227 +\mathchardef\perp="323F +\mathchardef\equiv="3211 +\mathchardef\asymp="3210 +\mathchardef\smile="315E +\mathchardef\frown="315F +\mathchardef\leftharpoonup="3128 +\mathchardef\leftharpoondown="3129 +\mathchardef\rightharpoonup="312A +\mathchardef\rightharpoondown="312B + +\mathchardef\lhook="312C +\mathchardef\rhook="312D + +\mathchardef\ldotp="613A +\mathchardef\cdotp="6201 +\mathchardef\colon="603A + +\def\acute{\mathaccent"7013 } +\def\grave{\mathaccent"7012 } +\def\ddot{\mathaccent"707F } +\def\tilde{\mathaccent"707E } +\def\bar{\mathaccent"7016 } +\def\breve{\mathaccent"7015 } +\def\check{\mathaccent"7014 } +\def\hat{\mathaccent"705E } +\def\vec{\mathaccent"017E } +\def\dot{\mathaccent"705F } +\def\widetilde{\mathaccent"0365 } +\def\widehat{\mathaccent"0362 } + +\def\lmoustache{\delimiter"437A340 } % top from (, bottom from ) +\def\rmoustache{\delimiter"537B341 } % top from ), bottom from ( +\def\lgroup{\delimiter"462833A } % extensible ( with sharper tips +\def\rgroup{\delimiter"562933B } % extensible ) with sharper tips +\def\arrowvert{\delimiter"26A33C } % arrow without arrowheads +\def\Arrowvert{\delimiter"26B33D } % double arrow without arrowheads +\def\bracevert{\delimiter"77C33E } % the vertical bar that extends braces +\def\Vert{\delimiter"26B30D } +\def\vert{\delimiter"26A30C } +\def\uparrow{\delimiter"3222378 } +\def\downarrow{\delimiter"3223379 } +\def\updownarrow{\delimiter"326C33F } +\def\Uparrow{\delimiter"322A37E } +\def\Downarrow{\delimiter"322B37F } +\def\Updownarrow{\delimiter"326D377 } +\def\backslash{\delimiter"26E30F } +\def\rangle{\delimiter"526930B } +\def\langle{\delimiter"426830A } +\def\rbrace{\delimiter"5267309 } +\def\lbrace{\delimiter"4266308 } +\def\rceil{\delimiter"5265307 } +\def\lceil{\delimiter"4264306 } +\def\rfloor{\delimiter"5263305 } +\def\lfloor{\delimiter"4262304 } + +\def\sqrt{\radical"270370 } + +\endinput