commit 99acb3b2b209c550e0485009f35817bea85a7585
parent 4dbb21aa0ed477a91422b43595d2d1bbc380a265
Author: Robert Russell <robertrussell.72001@gmail.com>
Date: Thu, 15 Feb 2024 00:12:59 -0800
Stuff
Diffstat:
7 files changed, 77 insertions(+), 65 deletions(-)
diff --git a/color.tex b/color.tex
@@ -18,12 +18,21 @@
\else
% pdfTeX
% TODO: make this an event
- \everyjob={\mathchardef\@colorstackn=\pdfcolorstackinit page {0 g 0 G}}
+ \everyjob={%
+ \pdfpageresources{/ExtGState <<
+ /R3texGsAlpha0 << /ca 0 /CA 0 >>
+ /R3texGsAlpha1 << /ca 1 /CA 1 >>
+ >>}%
+ \mathchardef\@colorstackn=\pdfcolorstackinit page {%
+ 0 g 0 G /R3texGsAlpha1 gs
+ }%
+ }%
\def\@colorpush#1{\pdfcolorstack\@colorstackn push {#1}}
\def\@colorpop{\pdfcolorstack\@colorstackn pop}
\def\@colorset#1{\@colorpush{#1}\aftergroup\@colorpop}
\def\Colorrgb#1#2#3{\@colorset{#1 #2 #3 rg #1 #2 #3 RG}}
\def\Colorgrey#1{\@colorset{#1 g #1 G}}
+ \def\Cinvis{\@colorset{/R3texGsAlpha0 gs}}
\fi
% Basic colors
diff --git a/control.tex b/control.tex
@@ -1,5 +1,3 @@
-% TODO: make loops expandable with immediateassign{ment,ed}?
-
% The classical Plain TeX \loop macro (approximately).
% Needs grouping to be nested.
\def\loop#1\repeat{\def\@body{#1}\@iterate}
@@ -7,56 +5,61 @@
\def\@iterate{\@body\ea\@iterate\fi}
% Loops that can be nested use this stack.
-\newq\@loopstack
+\newqueue\@ctrlstack
\newcount\@forcnt
\newcount\@forlim
\newcount\@forstep
\def\fornum#1=#2..#3\do{\fornumstep#1=#2..#3:1\do}
-\def\fornumstep#1=#2..#3:#4\do#5{% XXX require open brace like \foreach
+\def\fornumstep#1=#2..#3:#4\do#{%
\@forsave
- \def\@body{\edef#1{\the\@forcnt}#5}%
\@forcnt=\numexpr#2\relax
\@forlim=\numexpr#3\relax
\@forstep=\numexpr#4\relax
+ \@forstart{#1}%
+}
+\def\@forstart#1#2{%
+ \def\@body{\edef#1{\the\@forcnt}#2}%
\@forloop
\@forrestore
}
\def\@forloop{%
- \ifnum\@forcnt \ifnum\@forstep<0>\else<\fi \@forlim
- \@body \advance\@forcnt\@forstep \ea\@forloop
+ \ifnum\@forcnt \ifnum\@forstep<0 >\else <\fi \@forlim
+ \@body
+ \advance\@forcnt\@forstep
+ \ea\@forloop
\fi
}
\def\@forsave{%
- \let\qtok=\@body \pushtok\@loopstack
- \qnum=\@forcnt \pushnum\@loopstack
- \qnum=\@forlim \pushnum\@loopstack
- \qnum=\@forstep \pushnum\@loopstack
+ \let\qtok=\@body \pushtok\@ctrlstack
+ \qnum=\@forcnt \pushnum\@ctrlstack
+ \qnum=\@forlim \pushnum\@ctrlstack
+ \qnum=\@forstep \pushnum\@ctrlstack
}
\def\@forrestore{%
- \popnum\@loopstack \@forstep=\qnum
- \popnum\@loopstack \@forlim=\qnum
- \popnum\@loopstack \@forcnt=\qnum
- \poptok\@loopstack \let\@body=\qtok
+ \popnum\@ctrlstack \@forstep=\qnum
+ \popnum\@ctrlstack \@forlim=\qnum
+ \popnum\@ctrlstack \@forcnt=\qnum
+ \poptok\@ctrlstack \let\@body=\qtok
}
\def\foreach#1\do#2#{\@foreachA{#1}{#2}}
\def\@foreachA#1#2#3{%
- \let\qtok=\@body \pushtok\@loopstack
+ \let\qtok=\@body \pushtok\@ctrlstack
\gdef\@body#2{#3\futurelet\@next\@foreachB}%
\@body#1\@foreachend
- \poptok\@loopstack \let\@body=\qtok
+ \poptok\@ctrlstack \let\@body=\qtok
}
\def\@foreachB{\ifx\@next\@foreachend \ea\selectx \else \ea\@body \fi}
\def\@foreachend{\errmessage{this can not happen}}
\newcount\swnum
\def\switchnum#1#{%
- \qnum=\sqnum \pushnum\@loopstack \swnum=\numexpr#1\relax
- \let\qtok=\case \pushtok\@loopstack \let\case=\@casenum
+ \qnum=\sqnum \pushnum\@ctrlstack \swnum=\numexpr#1\relax
+ \let\qtok=\case \pushtok\@ctrlstack \let\case=\@casenum
\@fallthroughfalse \@switchnum
}
-\def\@switchnum#1{#1\@endswitch \popnum\@loopstack \swnum=\qnum}
+\def\@switchnum#1{#1\@endswitch \popnum\@ctrlstack \swnum=\qnum}
\def\@casenum#1#{%
\if@fallthrough
\ea\@case
@@ -69,11 +72,11 @@
\newdimen\swdim
\def\switchdim#1#{%
- \qdim=\swdim \pushdim\@loopstack \swdim=\dimexpr#1\relax
- \let\qtok=\case \pushtok\@loopstack \let\case=\@casedim
+ \qdim=\swdim \pushdim\@ctrlstack \swdim=\dimexpr#1\relax
+ \let\qtok=\case \pushtok\@ctrlstack \let\case=\@casedim
\@fallthroughfalse \@switchdim
}
-\def\@switchdim#1{#1\@endswitch \popdim\@loopstack \swdim=\qdim}
+\def\@switchdim#1{#1\@endswitch \popdim\@ctrlstack \swdim=\qdim}
\def\@casedim#1#{%
\if@fallthrough
\ea\@case
@@ -85,7 +88,7 @@
}
\newif\if@fallthrough
-\def\@endswitch{\poptok\@loopstack \let\case=\qtok}
+\def\@endswitch{\poptok\@ctrlstack \let\case=\qtok}
\def\fallthrough{\@fallthroughtrue}
\def\@case#1#2\@endswitch{\@fallthroughfalse#1\if@fallthrough#2\fi\@endswitch}
diff --git a/font.tex b/font.tex
@@ -147,6 +147,7 @@
}
\ffamdef[r]"00
+\ffamdef[b]"05
\ffamdef[hr]"06
\ffamdef[hb]"07
\ffamdef[fr]"08
@@ -347,6 +348,10 @@
% \def\vert{\delimiter"066A30C }
% \def\backslash{\delimiter"066E30F }
+\mathcode`\(="42B9
+\mathcode`\)="52BA
+\mathcode`\[="42BB
+\mathcode`\]="52BC
\mathcode`\,="602C
\mathcode`\.="002E
\Umathcode`\/="0"10"3D
@@ -403,7 +408,4 @@
\def\check{\mathaccent"02A7 }
-
-\tenpt\f[r]
-
\endinput
diff --git a/math.tex b/math.tex
@@ -57,8 +57,8 @@
\def\Longleftrightarrow{\Leftarrow\joinrel\Rightarrow}
\def\Iff{\mskip\thickmuskip \Longleftrightarrow \mskip\thickmuskip}
\def\Imp{\mskip\thickmuskip \Longrightarrow \mskip\thickmuskip}
-\def\iff{\mskip\thickmuskip \Leftrightarrow \mskip\thickmuskip}
-\def\imp{\mskip\thickmuskip \Rightarrow \mskip\thickmuskip}
+\def\iff{\Leftrightarrow}
+\def\imp{\Rightarrow}
\def\ldots{\mathinner{\ldotp\ldotp\ldotp}}
\def\cdots{\mathinner{\cdotp\cdotp\cdotp}}
@@ -97,7 +97,7 @@
% \downbracefill\crcr\noalign{\kern3\p@\nointerlineskip}
% $\hfil\displaystyle{#1}\hfil$\crcr}}}\limits}
\def\overbrace#1{%
- \mathop{\vbox{\m@th\ialign{%
+ \mathop{\vbox{\nosurround\ialign{%
##\crcr
\noalign{\kern1pt}%
\downbracefill\crcr
@@ -106,7 +106,7 @@
}}}\limits
}
\def\underbrace#1{%
- \mathop{\vtop{\m@th\ialign{%
+ \mathop{\vtop{\nosurround\ialign{%
##\crcr
$\hfil\displaystyle{#1}\hfil$\crcr
\noalign{\kern1pt\nointerlineskip}%
@@ -130,11 +130,11 @@
% Roots
\newbox\@rootbox
\def\root#1\of{%
- \setbox\@rootbox=\hbox{$\m@th\scriptscriptstyle{#1}$}%
+ \setbox\@rootbox=\hbox{$\nosurround\scriptscriptstyle{#1}$}%
\mathpalette\@root
}
\def\@root#1#2{%
- \setbox0=\hbox{$\m@th\sty#1\sqrt{#2}$}%
+ \setbox0=\hbox{$\nosurround\sty#1\sqrt{#2}$}%
\dimenA=\dimexpr\ht0 - \dp0\relax
% XXX hard-coded dimens
\mkern4mu \raise.82\dimenA\copy\@rootbox \mkern-10.5mu \box0
@@ -156,7 +156,7 @@
% \def\Big#1{{\hbox{$\left#1\vbox to11.5\p@{}\right.\n@space$}}}
% \def\bigg#1{{\hbox{$\left#1\vbox to14.5\p@{}\right.\n@space$}}}
% \def\Bigg#1{{\hbox{$\left#1\vbox to17.5\p@{}\right.\n@space$}}}
-\def\n@space{\nulldelimiterspace=0pt \m@th}
+\def\n@space{\nulldelimiterspace=0pt \nosurround}
\def\choose{\atopwithdelims()}
\def\brack{\atopwithdelims[]}
@@ -164,9 +164,9 @@
\def\cong{\mathrel{\mathpalette\@vereq\sim}}
\def\@vereq#1#2{\lower.5pt \vbox{\lineskiplimit\maxdimen\lineskip-.5pt
- \ialign{$\m@th\sty#1\hfil##\hfil$\crcr#2\crcr=\crcr}}}
+ \ialign{$\nosurround\sty#1\hfil##\hfil$\crcr#2\crcr=\crcr}}}
%\def\notin{\mathrel{\mathpalette\c@ncel\in}}
-\def\c@ncel#1#2{\m@th\ooalign{$\hfil\sty#1\mkern1mu/\hfil$\crcr$\sty#1#2$}}
+\def\c@ncel#1#2{\nosurround\ooalign{$\hfil\sty#1\mkern1mu/\hfil$\crcr$\sty#1#2$}}
% \def\rightleftharpoons{\mathrel{\mathpalette\rlh@{}}}
% \def\rlh@#1{\vcenter{\m@th\hbox{\ooalign{\raise2pt
% \hbox{$#1\rightharpoonup$}\crcr
@@ -186,7 +186,7 @@
\kern#2\@stymu
\hrule height#3\@stymu
\kern#4\@stymu
- \hbox{\kern-#5\@stymu$\m@th\sty#1{#7}$\kern-#6\@stymu}%
+ \hbox{\kern-#5\@stymu$\nosurround\sty#1{#7}$\kern-#6\@stymu}%
}%
\kern#6\@stymu
}}
@@ -235,10 +235,10 @@
\def\@dsty{\displaystyle\displaymath}
\def\@malign{\hfil\strut$\@dsty{##}$\tabskip=0pt&$\@dsty{{}##}$\hfil}
\def\eqalignskip{\qquad}
-\def\eqalign#1{\null\,\vcenter{\openup1\jot \m@th
+\def\eqalign#1{\null\,\vcenter{\openup1\jot \nosurround
\ialign{\cspan\@malign&&\eqalignskip\cspan\@malign\crcr #1\crcr}}\,}
\newif\ifdt@p
-\def\displ@y{\global\dt@ptrue\openup\jot\m@th
+\def\displ@y{\global\dt@ptrue\openup\jot\nosurround
\everycr{\noalign{\ifdt@p \global\dt@pfalse \ifdim\prevdepth>-1000pt
\vskip-\lineskiplimit \vskip\normallineskiplimit \fi
\else \penalty\interdisplaylinepenalty \fi}}}
@@ -246,7 +246,7 @@
\def\exalignno#1{\displ@y \tabskip=\centering
\halign to\displaywidth{%
\hfil$\@lign\@dsty{##}$\tabskip=0pt&$\@lign\@dsty{{}##}$\hfil&
- \qquad\hbox{\rm##}\hfil\tabskip=\centering&
+ \qquad\hbox{\f[r]##}\hfil\tabskip=\centering&
\llap{$\@lign##$}\tabskip=0pt\crcr #1\crcr}}
\def\eqalignno#1{\displ@y \tabskip\centering
\halign to\displaywidth{\hfil$\@lign\@dsty{##}$\tabskip0pt
@@ -260,19 +260,19 @@
\def\bmod{%
\nonscript\mskip-\medmuskip
\mkern5mu
- \mathbin{\rm mod}%
+ \mathbin{\f[sr]mod}%
\penalty900
\mkern5mu
\nonscript\mskip-\medmuskip
}
-\def\mod#1{\allowbreak\ifinner\ \else\mkern18mu\fi({\rm mod}\,\,#1)}
+\def\mod#1{\allowbreak\ifinner\ \else\mkern18mu\fi({\f[r]mod}\,\,#1)}
-\def\cases#1{\left\{\,\vcenter{\normalbaselines\m@th % XXX: \m@th here is wrong; should be inside leftmost column
+\def\cases#1{\left\{\,\vcenter{\normalbaselines\nosurround % XXX: \nosurround here is wrong; should be inside leftmost column
\ialign{$##\hfil$&\quad##\hfil\crcr#1\crcr}}\right.}
\def\matrix#1{%
\null\,\vcenter{%
- \normalbaselines\m@th
+ \normalbaselines\nosurround
\ialign{%
\hfil$##$\hfil&&\quad\hfil$##$\hfil\crcr
\mathstrut\crcr \noalign{\kern-\baselineskip}%
diff --git a/mathenc.tex b/mathenc.tex
@@ -4,10 +4,8 @@
\mathcode`\ ="8000 % \space
\mathcode`\!="5021
\mathcode`\'="8000 % ^\prime
-%\mathcode`\(="4028
-%\mathcode`\)="5029
-\mathcode`\(="42B9
-\mathcode`\)="52BA
+\mathcode`\(="4028
+\mathcode`\)="5029
\mathcode`\*="2203 % \ast
\mathcode`\+="202B
\mathcode`\,="613B
@@ -20,11 +18,9 @@
\mathcode`\=="303D
\mathcode`\>="313E
\mathcode`\?="503F
-%\mathcode`\[="405B
-\mathcode`\[="42BB
+\mathcode`\[="405B
\mathcode`\\="026E % \backslash
-%\mathcode`\]="505D
-\mathcode`\]="52BC
+\mathcode`\]="505D
\mathcode`\_="8000
\mathcode`\{="4266
\mathcode`\|="026A
diff --git a/r3tex.tex b/r3tex.tex
@@ -29,6 +29,8 @@
\def\fmtname{r3TeX}
\def\fmtversion{0.1}
+\tenpt
+\f[r]
\normalbaselines
\nonfrenchspacing
% TODO margins, font preload
diff --git a/text.tex b/text.tex
@@ -35,20 +35,20 @@
% \parskip control: use \tmpparskip to change the \parskip until the next \par;
% use \tmpparskipw to change the \parskip until after the next paragraph (in
% horizontal mode).
-\def\@restoreparskip{\g\parskip=\normalparskip \glet\@tmpparskip\relax}
+\def\@restoreparskip{\global\parskip=\normalparskip \glet\@tmpparskip\relax}
\def\@restoreparskipweak{\ifhmode \@restoreparskip \fi}
-\def\tmpparskip{\glet\@tmpparskip\@restoreparskip \g\parskip=}
-\def\tmpparskipw{\glet\@tmpparskip\@restoreparskipweak \g\parskip=}
+\def\tmpparskip{\glet\@tmpparskip\@restoreparskip \global\parskip=}
+\def\tmpparskipw{\glet\@tmpparskip\@restoreparskipweak \global\parskip=}
\let\@tmpparskip=\relax
\addhook[par]\@tmpparskip
% \parindent control: use \tmpparindent to change the \parindent until the next
% \par; use \tmpparindentw to change the \parindent until after the next
% paragraph (in horizontal mode).
-\def\@restoreparindent{\g\parindent=\normalparindent \glet\@tmpparindent\relax}
+\def\@restoreparindent{\global\parindent=\normalparindent \glet\@tmpparindent\relax}
\def\@restoreparindentweak{\ifhmode \@restoreparindent \fi}
-\def\tmpparindent{\glet\@tmpparindent\@restoreparindent \g\parindent=}
-\def\tmpparindentw{\glet\@tmpparindent\@restoreparindentweak \g\parindent=}
+\def\tmpparindent{\glet\@tmpparindent\@restoreparindent \global\parindent=}
+\def\tmpparindentw{\glet\@tmpparindent\@restoreparindentweak \global\parindent=}
\let\@tmpparindent=\relax
\addhook[par]\@tmpparindent
@@ -97,7 +97,7 @@
\def\hlap{\@ltrue\@rtrue\@lap}
\def\@lap{\modechoice{\@textlap}{\@textlap}{\mathpalette\@mathlap}}
\def\@textlap#1{\hbox to0pt{\if@l\hss\fi{#1}\if@r\hss\fi}}
-\def\@mathlap#1#2{\hbox to0pt{\if@l\hss\fi$\m@th\sty#1{#2}$\if@r\hss\fi}}
+\def\@mathlap#1#2{\hbox to0pt{\if@l\hss\fi$\nosurround\sty#1{#2}$\if@r\hss\fi}}
% Vertical overlaps
\def\ulap#1{\vbox to0pt{\boxmaxdepth=0pt \vss#1}}
@@ -105,7 +105,7 @@
\def\vlap#1{\vbox to0pt{\boxmaxdepth=0pt \vss#1\vss}}
\def\smash{\modechoice{\@textsmash}{\@textsmash}{\mathpalette\@mathsmash}}
\def\@textsmash#1{\setbox0=\hbox{#1}\@finsmash}
-\def\@mathsmash#1#2{\setbox0=\hbox{$\m@th\sty#1{#2}$}\@finsmash}
+\def\@mathsmash#1#2{\setbox0=\hbox{$\nosurround\sty#1{#2}$}\@finsmash}
\def\@finsmash{\ht0=0pt \dp0=0pt \box0 }
% Phantom boxes
@@ -115,7 +115,7 @@
\def\phantom{\@vtrue\@htrue\@phant}
\def\@phant{\modechoice{\@textphant}{\@textphant}{\mathpalette\@mathphant}}
\def\@textphant#1{\setbox0=\hbox{#1}\@finphant}
-\def\@mathphant#1#2{\setbox0=\hbox{$\m@th\sty#1{#2}$}\@finphant}
+\def\@mathphant#1#2{\setbox0=\hbox{$\nosurround\sty#1{#2}$}\@finphant}
\def\@finphant{%
\setbox2=\null
\if@v \ht2=\ht0 \dp2=\dp0 \fi
@@ -148,20 +148,20 @@
\mathchardef\braceld="37A \mathchardef\bracerd="37B
\mathchardef\bracelu="37C \mathchardef\braceru="37D
\def\downbracefill{%
- $\m@th
+ $\nosurround
\setbox0=\hbox{$\braceld$}%
\braceld \leaders\vrule height\ht0 depth0pt \hfill \braceru
\bracelu \leaders\vrule height\ht0 depth0pt \hfill \bracerd
$%
}
\def\upbracefill{%
- $\m@th
+ $\nosurround
\setbox0=\hbox{$\braceld$}%
\bracelu \leaders\vrule height\ht0 depth0pt \hfill \bracerd
\braceld \leaders\vrule height\ht0 depth0pt \hfill \braceru
$%
}
-\def\dots{\relax\ifmmode\ldots\else$\m@th\ldots\,$\fi}
+\def\dots{\relax\ifmmode\ldots\else$\nosurround\ldots\,$\fi}
\endinput