mitex
mitex copied to clipboard
Convert box commands
No plan, but some direction:
- find a way of ignoring all box related commands, so that it just compiles in typst instead of really layout something.
- implement kern commands
- implement glue commands
- implement paragraph commands
Materials and ideas
- See ifdim
- See ifhbox
- See ifvbox
- See ifvoid
- See Box family in TUG.
- See Kern family in TUG.
- See Glue family in TUG.
- See Paragraph family in TUG.
Initial Idea is following.
- The boxes are allocated by converter.
- We may have infinite virtual box registers, since holding limit of 256 is just less meaningful but depends on implementation.
- We won't calculate any size of boxes, but converting them with typst scripting. That means, any failed conversions will just make MiTeX ignore layout request from TeX Code.
- For code converting layout, measure for box and box conditions:
#locate(loc => layout(size => { // converted code here }))
Examples
Example 1 (paragraph):
\everypar{\setbox\parbox=
\vbox\bgroup\everypar{}%
\def\par{\endgraf\HandleLines
\egroup\box\parbox}}
\def\HandleLines{ ... \lastbox ... }
Example 2 (box):
\newbox\linebox \newbox\snapbox
\def\eatlines{
\setbox\linebox\lastbox % check the last line
\ifvoid\linebox
\else % if it's not empty
\unskip\unpenalty % take whatever is
{\eatlines} % above it;
% collapse the line
\setbox\snapbox\hbox{\unhcopy\linebox}
% depending on the difference
\ifdim\wd\snapbox<.98\wd\linebox
\box\snapbox % take the one or the other,
\else \box\linebox \fi
\fi}