From fe1a001e62abccc961057740b210efd0170559fd Mon Sep 17 00:00:00 2001 From: GloamXun Date: Mon, 26 Oct 2026 03:10:47 +0800 Subject: [PATCH] Widen numbered registers to 256 slots --- README.md | 2 +- docs/ROUTE_D_PLAN.md | 2 +- docs/TEX_CORE.md | 4 +-- src/route_d.rs | 69 ++++++++++++++++++++++++++++++++++---------- 4 files changed, 57 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3005524..2766bef 100644 --- a/README.md +++ b/README.md @@ -473,7 +473,7 @@ the assignable TeX parameters `\\delimiterfactor` (default 901) and Route-D text faces follow the NFSS declarations and compose with the surrounding run: `\sffamily\bfseries` selects cmssbx10, `\sffamily\itshape` selects cmssi10, and bold italic sans substitutes cmssbx10 because Computer Modern has no sans bold italic. `\scshape`/`\textsc` select the real cmcsc10 small-caps face, `\slshape`/`\textsl` use cmsl10 (or cmbxsl10 when bold) rather than the italic cmti10, and `\ttfamily\itshape` reaches cmitt10. All twelve text programs (cmr10, cmbx10, cmti10, cmbxti10, cmtt10, cmss10, cmssbx10, cmssi10, cmcsc10, cmsl10, cmbxsl10, cmitt10) are embedded as Type1 outlines. Characters outside a program's encoding fall back per glyph to a Liberation subset, so the ASCII letters of an accented word still use Computer Modern and Greek text keeps its Unicode text under PDF extraction, including capital Omega, because the embedded Type1 faces carry a ToUnicode CMap built from the requested characters rather than relying on glyph names. Accent commands such as `\'`, `` \` ``, `\"`, `\^`, `\~`, `\c`, `\v` and `\=` compose precomposed Unicode letters and fall back to the base letter plus a combining mark. `\textsuperscript` and `\textsubscript` set a 70% run raised or lowered by 0.4em. `\MakeUppercase` and `\MakeLowercase` (also `\uppercase`/`\lowercase`) transform their braced text while keeping the surrounding face. Because Computer Modern has no bold small caps, a bold small-caps request falls back to cmbx10. A `\textcolor{name}{...}` run paints in one of the standard named colours in both the SVG preview and the PDF, and a leading `\\color{name}` switch colours the rest of its paragraph (`\definecolor` supports rgb, RGB, gray, HTML and cmyk models, `\pagecolor{name}` fills the page background, a `name!percent!other` spec mixes two named colours linearly, the second defaulting to white, and `\hypersetup{urlcolor=...}` colours `\href` labels, and `\colorbox{name}{...}` paints a filled rectangle behind its text, and `\fcolorbox{frame}{background}{...}` draws a 0.4pt frame around that rectangle).. Section-wide declarations such as `\bfseries` apply from where they appear to the end of their group, and `\em` toggles emphasis relative to the surrounding face. Paragraph base sizes come from `\fontsize{}{}` and the article size commands (`\tiny` through `\Huge`), scaling glyph metrics and the default interline glue while the measure, indentation and authored skips stay absolute. The class options `10pt`/`11pt`/`12pt` on `\documentclass[...]` set the default base size (and article `\baselineskip` of 12pt/13.6pt/14.5pt), and `\linespread{factor}` (or `\renewcommand{\baselinestretch}{factor}`) scales that baseline; a size command inside a paragraph overrides the class default and keeps its own glyph size in that run. Inline math inside a styled run keeps its math face while the surrounding text retains its style. The paragraph measure follows `\textwidth`/`\hsize` (or `\setlength{\textwidth}{...}`), and `\setlength` accepts the other supported layout lengths, including a `\parskip` with plus/minus glue; a counter declared with `\newcounter{name}` starts at zero and can be changed by `\setcounter`/`\addtocounter`, and a length declared with `\newlength{\name}` can be set by `\setlength{\name}{...}` and then used as the value of a later `\setlength{\parindent}{\name}`, and `\addtolength{\name}{...}` adds to such a length, so class code that stores its dimensions in named lengths takes effect. The `geometry` package's `margin`/`hmargin`/`vmargin`/`left`/`right`/`top`/`bottom`/`textwidth`/`textheight` options (or `\geometry{...}`) are applied to the page measure and height; other package code is not executed. Block environments `center`, `flushleft` and `flushright` set the paragraph alignment, and aligned short lines are centring/flushing within the full measure rather than at the natural line width. A leading `\noindent` starts its paragraph flush with the measure. Page numbers print centred below the text block, `\setcounter{page}` offsets the printed number, `\addtocounter{page}` shifts it (`\pagenumbering` resets it to 1), and `\pagenumbering{roman|Roman|alph|Alph|arabic}` changes their format and `\pagestyle{empty}` suppresses them on every page and `\thispagestyle{empty}` on the first page. `\hypersetup{pdftitle=...}` writes the PDF Info dictionary (title, author, subject and keywords, UTF-16BE for non-ASCII text), each numbered heading becomes a PDF bookmark nested by heading level, `\title`, `\author` and `\date` are captured from the preamble, `\today` expands to the current date, and `\maketitle` expands into a centered title block at the article class sizes (using today's date when `\date` is absent and none for `\date{}`). `\section`, `\subsection`, `\subsubsection`, `\paragraph` and `\subparagraph` advance five-level article counters, prefix their titles with the number, and paint bold at `\Large`/`\large`/`\normalsize` (the two deepest levels stay at the base size); starred headings stay unnumbered, and an optional `[short]` title replaces the long title in the table of contents. The `abstract` environment expands into a centered bold heading and a 9pt body, and `\maketitle` joins multiple `\and` authors and turns `\thanks` notes into title footnotes. Section labels resolve `\ref`/`\eqref` to the heading number (standalone `\label` lines attach to the previous heading, unknown references print `??`), and `\pageref{label}` reports that heading's formatted page number after a probe layout, `\appendix` restarts sectioning with letter numbers, `\tableofcontents` lists the numbered headings through `\subsubsection` with their page numbers right-aligned after dot leaders (the default article `tocdepth` of 3, changed by `\setcounter{tocdepth}`), `\setcounter{secnumdepth}` limits which levels are numbered, `\setcounter{section}`/`{figure}`/`{table}`/`{equation}`/`{theorem}` offsets the next counter value, `\listoffigures`/`\listoftables` reproduce the numbered captions with each float's page number right-aligned after dot leaders, `verbatim` keeps monospaced source lines, `\verb|...|` renders inline literal text monospaced, and text commands such as `\LaTeX`, `\TeX`, `\ldots`, `\S`, `\ss`, `\ae`, `\oe`, `\o`, `\l`, `\dh`, `\th`, `\textdegree`, `\textmu`, `\textonehalf` and `\texteuro` expand to their characters (a control word swallows the spaces that follow it), `\href` keeps its link text and paints a PDF `/Link` URI annotation over the label, and `\url` becomes typewriter text, and the `abstract` environment expands to its heading and body. In route-D, math uses Computer Modern metrics from the bundled `cmmi10`, `cmsy10`, `cmex10`, `msbm10` and `eufm10` TFMs and embeds their Type1 programs, so italic letters, relation symbols, big operators, `\mathcal` capitals, `\mathbb` capitals and `\mathfrak` Fraktur letters each paint with their own face. Fractions can be written as `\frac` or with TeX's infix forms (`\over`, `\atop`, `\choose`, `\brace`, `\brack`, `\overwithdelims`, `\atopwithdelims`), and `\genfrac` takes explicit delimiters and rule thickness; only `\over`-style fractions draw a bar and fractions never draw parentheses. `displaymath` and `math` environments are accepted alongside `$$`, `\[` and `\(...\)`, and `cases`, `matrix`/`pmatrix`/`bmatrix`/`Bmatrix`/`vmatrix`/`Vmatrix` and `array` environments build a grid with the matching delimiters (an `array` column spec chooses left, centred or right alignment). `\left`/`\right` choose CMEX delimiter sizes from the body extent using TeX's delimiterfactor and shortfall, `\middle` delimiters are sized with their group, and `\big`/`\Big`/`\bigg`/`\Bigg` paint at their selected CMEX size. `align`/`align*` displays share column widths, right-align even columns at their relations, and number each row (with `\tag`/`\notag` per row); `gather`/`gather*` centre each row instead, `alignat` numbers rows the same way while ignoring its column-count argument, a `split` body inside `equation` is numbered once, and `multline` sets its first row flush left, its last row flush right and the rest centred around a single number. Inter-atom spacing uses TeX's 3/4/5mu classes (`1mu` is `1/18em`), `\mid` is a relation and `\colon` punctuation, `\limits` stacks an operator's scripts above and below using TeX's script size and clearance rules while `\nolimits` keeps them beside it, `\substack{...}` stacks its rows with TeX's inter-row gaps, and an integral stays sideways unless `\limits` is given, and `\mskip`/`\mkern`/`\mspace`/`\hskip`/`\kern`/`\hspace` scan TeX dimensions, taking the natural width of any `plus`/`minus` parts; `\operatorname{...}` sets an upright operator name, its starred form stacks following limits and `\DeclareMathOperator{\name}{text}` defines new ones. `\footnote{...}` leaves a numbered marker in the paragraph and sets the note as a 9pt page insertion at the bottom of the page that mentions it. A `thebibliography` environment turns its `\bibitem` entries into numbered `[n]` paragraphs, and `\cite{...}` resolves to `[n]`/`[n, m]` (unknown keys print `[?]`; optional citation notes are dropped, `\citep`/`\citet` behave like `\cite`, `\nocite` is ignored, and `\bibliography`/`\bibliographystyle` are consumed without BibTeX). A `figure` environment becomes a float at its `[t]`/`[b]`/`[h]` placement, its `\caption` numbers as `Figure n:` and feeds `\ref`, and `\includegraphics` embeds the referenced project image when it decodes (PNG/JPEG/BMP become a PDF XObject; missing or undecodable files keep the rule placeholder), a standalone `\includegraphics` paragraph becomes an in-text graphic float, and a standalone `\rule{width}{height}` becomes an in-text rule box; `width=`/`height=` take dimensions or fractions of `\textwidth`/`\textheight`, `scale=` a percentage, `keepaspectratio` fits both dimensions, and `\graphicspath` directories are searched (with `.png`/`.jpg`/`.bmp` fallbacks) when a path has no suffix. `table` environments likewise become floats carrying their captured `tabular` body, with `Table n:` captions that resolve from `\ref`. Table captions sit above the tabular as in LaTeX, figure captions below the graphic, and `\caption*` leaves either unnumbered; an optional `[short]` caption is used by `\listoffigures`/`\listoftables` while the long caption stays on the float; the glue on each side of a tabular column follows `\tabcolsep` (6pt by default), `\arraystretch` scales the tabular row heights, a begin-position option is accepted and ignored, and `\\[dim]` adds an extra gap after that row, and `|` rules in the column template paint vertical rules, and `*{n}{cols}` repeats a column group (a `tabularx` target width expands its `X` columns to share the leftover measure, and a `\multirow{n}{width}{text}` cell keeps its text on the first row of its span), and `\renewcommand` can rename the `Figure`/`Table` caption prefixes, the `Abstract` heading, and the `References`/`Contents`/`List of Figures`/`List of Tables` headings that open the bibliography, table of contents and float lists. Theorem-like environments (`theorem`, `lemma`, `corollary`, `proposition`, `definition`, `example`, `remark`, `proof`) produce a bold numbered heading with an optional `[title]`, italic statements for the theorem group, and unnumbered proofs whose optional argument replaces the heading, with `\label`/`\ref` resolving to the theorem number. `\newtheorem{env}[shared]{Display}`, `\newtheorem{env}{Display}[section]` and `\newtheorem*{env}{Display}` add custom theorem environments: a shared counter numbers the env with its parent, `[section]` scopes numbers to the enclosing section, and the starred form stays unnumbered. In project previews and PDF exports, `\input{...}` and `\include{...}` expand from files in the same project (a missing `.tex` suffix is added), so chapter files render in place; a project's own `.sty`/`.cls` files are inlined for `\usepackage{name}`/`\documentclass{name}` with local `\RequirePackage` dependencies inlined recursively, local base classes named by `\LoadClass`/`\LoadClassWithOptions` inlined the same way, class and package bodies inlining their local `\input{...}` files (missing files are dropped), and package/class boilerplate dropped, `\AtBeginDocument`/`\AtEndDocument` bodies executed, and `\makeatletter`/`\makeatother` stripped; local class and package files run their `\DeclareOption` code for the options named on `\documentclass[...]` / `\usepackage[...]` (with `\ExecuteOptions` defaults), and preamble `\PassOptionsToPackage`/`\PassOptionsToClass` lines are merged into the next request, and unknown paths stay as literal text. Preview JSON also reports a `warnings` array naming environments route-D cannot lay out and control words that survived layout, so unsupported source is reported rather than silently typeset. Route-D project previews are memoised by a hash of the expanded source (32 entries) and invalidated on edit; PDF exports cache the last eight results and the cache key also covers decoded image bytes, so replacing an image re-renders both. A malformed source answers 422 with a JSON error body and never populates either cache. `itemize`/`enumerate`/`description` environments nest arbitrarily: bullet labels cycle `•`/`–`/`*`, sub-enumerations use `(a)`, roman and upper-letter labels, description items print their `[term]` in bold before the definition, an optional `\item[label]` replaces the generated marker, each depth adds 12pt of indentation, and list items take article's per-level `\topsep`, `\itemsep` and `\partopsep` (top level 8+2/4pt at 10pt, 9+3/4.5pt at 11pt and 10+3/5pt at 12pt; second level 4+2/2pt, 4.5+3/2pt and 5+3/2pt) unless `\setlength{\topsep}`, `\setlength{\itemsep}` or `\setlength{\partopsep}` override them, a wrapped item hangs its continuation lines at the text indent while its first line stays at the bullet indent, and an `\setcounter{enumi}` (or `enumii`/`enumiii`/`enumiv`) line before the first `\item` resumes enumerate numbering. A `quotation` environment splits its blank-line-separated paragraphs into blocks indented 20pt on both sides, and `quote` uses the same 20pt margins, and `verse` keeps its explicit line breaks as separate 20pt-indented lines, and a `minipage{w}` environment lays its body out at width `w` (its optional position argument is ignored). -Inline `$...$` and `\(...\)` math is laid out inside 10pt paragraphs (larger sizes keep the delimiters literal). `\newcommand`/`\renewcommand` definitions are captured from the preamble and expanded textually, including numbered arguments and one `[default]` optional first argument; TeX's `\def` parameter texts and `\let` aliases are executed the same way, `\edef`/`\xdef` expand their bodies once at definition time and `\csname...\endcsname` builds the named control sequence, `\expandafter` runs the macro after its prefix once, and `\newenvironment` definitions wrap their bodies with the declared begin/end material. `\newif` flags select between `\if...\else...\fi` branches, with assignments honoured in the preamble or the body, so class conditionals like `\ifdraft` work, and `\ifdefined\name` tests whether a macro is declared. `\ifnum` compares integers from literals, `\newcount` registers or `\value{counter}`, and `\ifx` compares token meanings (two macros are equal when their parameter text and body match) `\ifcase ` chooses the n-th `\or` branch and falls back to `\else` when the value is out of range.. the scratch registers `\dimen0`-`\dimen9` and `\skip0`-`\skip9` hold dimensions and glue with the same assignment and `\advance` forms, and `\count0`-`\count9` take assignments, `\advance`, `\multiply` and `\divide` and print through `\the`/`\number`, while `\newcount\name` declares an integer register whose value `\name= `\dimexpr ... \relax` evaluates `+`, `-`, `*` (by an integer) and `/` over dimensions and `\newdimen` registers and prints through `\the`, while `\glueexpr ... \relax` evaluates glue with `plus`/`minus` components over dimensions and `\newskip` registers; `\noexpand\token` keeps the token unexpanded for the current pass (a later pass still expands it), and a later `\def` with the same name replaces the earlier definition The LaTeX internals `\@namedef`, `\@nameuse`, `\@ifundefined`, `\@firstofone`, `\@firstoftwo`, `\@secondoftwo` and `\@empty` expand, and `\@ifstar{yes}{no}` / `\@ifnextchar{yes}{no}` choose from the following token, and `@` counts as a letter in control words so `\makeatletter`-guarded names parse `\numexpr` evaluates `+`, `-`, `*`, `/` and parentheses over integers and integer registers, either standalone or after `\the` `\newskip\name` declares a glue register that `\the\name` prints as `wpt plus spt minus hpt`. `\newdimen\name` declares a dimension register whose value `\name=`, `\advance\name by `, `\multiply\name by ` and `\divide\name by ` update and which `\the\name` prints in TeX's `pt` form.......`, `\advance\name by ...`, `\multiply\name by ...` and `\divide\name by ...` update and which `\the\name`/`\number\name` print. +Inline `$...$` and `\(...\)` math is laid out inside 10pt paragraphs (larger sizes keep the delimiters literal). `\newcommand`/`\renewcommand` definitions are captured from the preamble and expanded textually, including numbered arguments and one `[default]` optional first argument; TeX's `\def` parameter texts and `\let` aliases are executed the same way, `\edef`/`\xdef` expand their bodies once at definition time and `\csname...\endcsname` builds the named control sequence, `\expandafter` runs the macro after its prefix once, and `\newenvironment` definitions wrap their bodies with the declared begin/end material. `\newif` flags select between `\if...\else...\fi` branches, with assignments honoured in the preamble or the body, so class conditionals like `\ifdraft` work, and `\ifdefined\name` tests whether a macro is declared. `\ifnum` compares integers from literals, `\newcount` registers or `\value{counter}`, and `\ifx` compares token meanings (two macros are equal when their parameter text and body match) `\ifcase ` chooses the n-th `\or` branch and falls back to `\else` when the value is out of range.. the scratch registers `\dimen0`-`\dimen255` and `\skip0`-`\skip9` hold dimensions and glue with the same assignment and `\advance` forms, and `\count0`-`\count9` take assignments, `\advance`, `\multiply` and `\divide` and print through `\the`/`\number`, while `\newcount\name` declares an integer register whose value `\name= `\dimexpr ... \relax` evaluates `+`, `-`, `*` (by an integer) and `/` over dimensions and `\newdimen` registers and prints through `\the`, while `\glueexpr ... \relax` evaluates glue with `plus`/`minus` components over dimensions and `\newskip` registers; `\noexpand\token` keeps the token unexpanded for the current pass (a later pass still expands it), and a later `\def` with the same name replaces the earlier definition The LaTeX internals `\@namedef`, `\@nameuse`, `\@ifundefined`, `\@firstofone`, `\@firstoftwo`, `\@secondoftwo` and `\@empty` expand, and `\@ifstar{yes}{no}` / `\@ifnextchar{yes}{no}` choose from the following token, and `@` counts as a letter in control words so `\makeatletter`-guarded names parse `\numexpr` evaluates `+`, `-`, `*`, `/` and parentheses over integers and integer registers, either standalone or after `\the` `\newskip\name` declares a glue register that `\the\name` prints as `wpt plus spt minus hpt`. `\newdimen\name` declares a dimension register whose value `\name=`, `\advance\name by `, `\multiply\name by ` and `\divide\name by ` update and which `\the\name` prints in TeX's `pt` form.......`, `\advance\name by ...`, `\multiply\name by ...` and `\divide\name by ...` update and which `\the\name`/`\number\name` print. Route-D integration can also be checked against a real TeX page: `cargo test -p texrra-tex-core --test route_d` includes `route_d_page_matches_pdftex_raster_geometry`, which renders the route-D PDF and a pdfTeX Letter page at the same scaled-point geometry, rasterizes both with `pdftoppm`, and compares ink line count plus left, right, and bottom edges. It is skipped when `pdflatex`/`pdftoppm` are unavailable. `route_d_multiline_bands_track_pdftex` extends that check to a wrapped paragraph: the pixel rows that carry ink form one band per TeX line, and every band top, bottom, left edge and (except for the last line, whose width follows the break point) right edge must land within a couple of pixels of the pdfTeX page. diff --git a/docs/ROUTE_D_PLAN.md b/docs/ROUTE_D_PLAN.md index 674a436..c37b2da 100644 --- a/docs/ROUTE_D_PLAN.md +++ b/docs/ROUTE_D_PLAN.md @@ -48,7 +48,7 @@ floats (`\floatsep`, `\textfloatsep`, `\intextsep`, `\topfraction`, `\bottomnumber`, `\totalnumber`), insertion classes (`\skip`, fraction and absolute limits, splitting), marks, Rust output hook, multi-page PDF, and the route-D service endpoints (`/api/route-d/preview|pdf|edit`, project preview and -PDF opt-in with `?engine=route-d`). 884 workspace tests are green and no oracle +PDF opt-in with `?engine=route-d`). 885 workspace tests are green and no oracle fixture is ignored. Preview JSON also carries a `warnings` array naming environments route-D cannot lay out and control words that survived layout, so unsupported source is reported instead of being silently typeset. diff --git a/docs/TEX_CORE.md b/docs/TEX_CORE.md index be5fb24..946cc94 100755 --- a/docs/TEX_CORE.md +++ b/docs/TEX_CORE.md @@ -133,7 +133,7 @@ and justification. | M3 | `\halign`, `\omit`, `\span`, `\multispan`, booktabs/longtable | **partial**: source parsing, natural column widths, spans, rule rows, 10pt display-list painting and row-level page splitting; the paged builder splits a tall alignment into page-sized row chunks that keep the table's column widths, so long tables continue across pages; `p{width}` paragraph columns wrap cell text and grow row heights, wrapped rows participate in row-level splitting, explicit per-column `\tabskip` glue is honoured through layout, painting and page chunks, and booktabs rules carry their own weights and spans (`\toprule`/`\bottomrule` 0.8pt, `\midrule`/`\cmidrule` 0.5pt, with `\cmidrule(lr){a-b}` trimming and column ranges), `@{}` / `@{\hspace{...}}` column expressions override the inter-column glue, and row-boundary `\noalign{\vskip ...}` glue is honoured by layout, painting and page chunks; longtable head/foot sections (`\endfirsthead`/`\endhead`/`\endfoot`/`\endlastfoot`) are parsed, continuation chunks repeat the head rows and the foot block paints once at the end, LaTeX `tabular` environments are captured and laid out through the same `\halign` path (rules are stripped from the column spec, `p{...}`/`m{...}`/`b{...}` become wrapping columns, `@{}` expressions are ignored for spacing), `\multicolumn{n}{align}{...}` cells span columns with the requested alignment, `\cline{a-b}` draws a 0.4pt partial rule over a column range, though `\valign`, nested tables and full tabular parity remain open | | M4 | math lists, scripts, fractions, radicals, accents, delimiters | **partial**: token parser, atom boxes with Computer Modern metrics (italic letters from the bundled `cmmi10`, big operators from `cmex10`, symbols such as `\times`/`\leq`/`\infty` from `cmsy10`, with `cmmi10`, `cmsy10` and `cmex10` glyphs embedded as Type1 outlines), `\left...\right` delimiter selection through CMEX size variants using TeX's delimiterfactor and shortfall, accents and a display-list painter; display formulas wider than the measure are split at top-level binary/relation operators into multiple lines (an approximation of TeX's `\split` behaviour; `align`/`align*` displays share column widths and number each row, while `gather`/`gather*` centre every row, `alignat` numbers rows the same way while ignoring its column-count argument, a `split` body inside `equation` is numbered once, and `multline` rows flush left and right around a single number); CMEX delimiter size variants back `\big`/`\Big`/`\bigg`/`\Bigg`; inter-atom spacing uses TeX's full atom-class table with binary-operator normalisation, with `1mu` = `1/18em` (a thin space is 3mu = 1.67pt at 10pt); `\mid` is a relation while `\colon` is punctuation; `\limits` stacks an operator's scripts above and below at TeX's script size and clearance (checked against pdfLaTeX word positions, including descender bases) while `\nolimits` keeps them beside the operator, `\substack{...}` stacks its rows with TeX's inter-row gaps, and an integral keeps its scripts beside it unless `\limits` asks otherwise, as TeX's display rules do; `\mskip`, `\mkern`, `\mspace`, `\hskip`, `\kern` and `\hspace` scan TeX dimensions (`mu`, `pt`, `em`, ...) and contribute their natural width, accepting `plus`/`minus` parts even though math boxes are not glue lists; route-D numbers `equation` environments and resolves `\eqref`/`\ref` through their labels; `\tag` overrides the number and `\notag`/`\nonumber` suppress it; `displaymath` environments (and `$$`/`\[` displays) stay unnumbered while `math` environments select inline math; math italic letters are embedded as Computer Modern Type1 outlines (`cmmi10`), and math alphabets map `\\mathbf`/`\\mathit`/`\\mathsf`/`\\mathtt` onto the bold, math-italic, sans and mono faces with their TFMs and `\\mathcal` onto the cmsy10 calligraphic capitals; `\mathfrak` maps onto the bundled eufm10 Fraktur letters (embedded as Type1 outlines); infix fractions `\over`, `\atop`, `\choose`, `\brace`, `\brack` and their `withdelims` forms build fractions from the current row, with the bar only for the `\over` forms; `\genfrac{left}{right}{thickness}{style}{num}{den}` builds a fraction with optional delimiters and no rule for an empty or `0pt` thickness; `\middle` delimiters are sized with their enclosing `\left`/`\right` group and `\big`/`\Big`/`\bigg`/`\Bigg` paint at their selected CMEX size | | M5 | NFSS/TFM metrics, CM/Latin Modern | **partial**: paragraph-level NFSS declarations and inline run composition over the built-in Roman/Bold/Italic/BoldItalic/Mono/MonoItalic/Sans/SansBold/SansItalic/SmallCaps/Slanted/BoldSlanted faces (CM has no sans bold-italic, so `cmss/bx/it` substitutes `cmss/bx/n`; `\scshape` selects cmcsc10 and a bold small caps request falls back to cmbx10; `\slshape` uses the slanted cmsl10 rather than the italic cmti10 and `\ttfamily\itshape` reaches cmitt10), per-face Computer Modern TFM metrics, and Type1 (PFB) outline embedding for every built-in face plus `cmmi10` math italics, `cmsy10` math symbols and `cmex10` big operators, with a Liberation subset falling back per glyph for characters outside the Type1 encodings, so ASCII on an accented line still uses the Computer Modern face, and Type1 faces carry a ToUnicode CMap built from the requested characters so extraction does not depend on ambiguous glyph names; paragraph base sizes from `\fontsize` and the article size commands scale glyph metrics and the default interline glue while the measure and authored skips stay absolute, a size command in the middle of a paragraph splits a sized run that is shaped and painted at its own type size, and inline math inside a styled run keeps its math boxes while the surrounding text keeps its face; accent commands such as `\'`, `` \` ``, `\"`, `\^`, `\~`, `\c`, `\v` and `\=` compose precomposed Unicode letters and fall back to the base letter plus a combining mark, while `\textsuperscript` and `\textsubscript` set a 70% run raised or lowered by 0.4em; `\MakeUppercase`/`\MakeLowercase` (and `\uppercase`/`\lowercase`) transform their braced text and keep the surrounding face; full NFSS family/shape state and Type1 coverage for arbitrary Unicode remain open | -| M6 | class/package execution (`article`, `sn-jnl`) | **partial**: a leading `\noindent` starts a paragraph flush with the measure, `\documentclass[...]` options are read and the article `10pt`/`11pt`/`12pt` base size sets the default paragraph font size and `\baselineskip` (13.6pt/14.5pt), and `\linespread{factor}` (or `\renewcommand{\baselinestretch}{factor}`/`\def\baselinestretch{factor}`) scales that class baseline, while `\newlength{\name}` registers a named length that `\setlength` can assign and a later `\setlength{\parindent}{\name}` can read, and `\addtolength{\name}{...}` adjusts it; the `geometry` package's `margin`/`hmargin`/`vmargin`/`left`/`right`/`top`/`bottom` options (and `\geometry{...}`) adjust the measure and page height; page numbers print centred below the text block, `\setcounter{page}` offsets the printed number, `\addtocounter{page}` shifts it (`\pagenumbering` resets it to 1), `\pagenumbering{roman|Roman|alph|Alph|arabic}` selects the format and `\pagestyle{empty}` suppresses them on every page and `\thispagestyle{empty}` on the first page; `\title`/`\author`/`\date` are captured, `\hypersetup{pdftitle=...}` (also `pdfauthor`/`pdfsubject`/`pdfkeywords`) writes the PDF Info dictionary with UTF-16BE values for non-ASCII text (falling back to `\title`/`\author`), each numbered heading becomes a PDF bookmark in `/Outlines`, nested by heading level and pointing at its page, `\today` expands to the UTC calendar date in the title block and the body, and `\maketitle` expands into the centered article title block at the class sizes (with today's date when `\date` is absent and no date for `\date{}`); numbered `\section`/`\subsection`/`\subsubsection`/`\paragraph`/`\subparagraph` headings advance five-level article counters (article's `\setcounter{secnumdepth}` default of 3 numbers through `\subsubsection`, and raising it numbers the two deeper levels; `\setcounter{section}`/`{figure}`/`{table}`/`{equation}`/`{theorem}` offsets the next counter value) and paint at `\Large`/`\large`/`\normalsize` (the two deepest levels stay bold at the base size), starred headings stay unnumbered, and an optional `[short]` title replaces the long title in the table of contents; the `abstract` environment expands into a centered bold heading and a 9pt body, `\maketitle` joins `\and` authors and turns `\thanks` notes into title footnotes, and `\label` inside a heading (or on its own line after it) resolves `\ref`/`\eqref` to the section number while unknown references print `??`, and `\pageref{label}` reports the formatted page number of that heading after a probe layout (unknown labels print `??`), and `\appendix` restarts sectioning with letters (`A`, `A.1`), and `\tableofcontents` lists the numbered headings through `\subsubsection` with 12pt per-level indentation and a right-aligned page number reached by dot leaders that fill the measure (the default article `tocdepth` of 3; `\setcounter{tocdepth}` changes the depth) while `\listoffigures`/`\listoftables` reproduce the numbered figure/table captions and append each float's page number after dot leaders that fill the measure (an optional `[short]` caption is used there while the long caption stays on the float); `verbatim` environments keep each source line as a monospaced 9pt paragraph indented by 12pt (leading whitespace is normalised), `\verb|...|` renders inline literal text in the mono face, common text commands such as `\LaTeX`, `\TeX`, `\ldots`, `\dots`, `\S`, `\copyright`, `\pounds`, `\ss`/`\ae`/`\oe`/`\o`/`\l`/`\dh`/`\th` and symbol commands such as `\textdegree`/`\textmu`/`\textonehalf`/`\texteuro` expand to their characters, and a control word swallows the spaces that follow it, `\href{url}{text}` keeps its text, and `\url{...}` becomes typewriter text; `\footnote{...}` becomes a numbered 9pt page insertion on the page that mentions it; a `thebibliography` environment is removed from the body, its `\bibitem` entries become numbered `[n]` paragraphs, and `\cite{...}` resolves to `[n]`/`[n, m]` (unknown keys print `[?]`, an optional note like `\cite[p.~3]{...}` is dropped, `\citep`/`\citet` behave like `\cite`, `\nocite` is ignored, and `\bibliography`/`\bibliographystyle` lines are consumed without running BibTeX); a `figure` environment becomes a float at its `[t]`/`[b]`/`[h]` placement, its `\caption` numbers as `Figure n:` and resolves `\ref`, and `\includegraphics` embeds the referenced project image (PNG/JPEG/BMP are decoded into a PDF XObject, with a rule placeholder when the file is missing or cannot be decoded), and a standalone `\includegraphics` paragraph becomes an in-text graphic float, while a standalone `\rule{width}{height}` becomes an in-text rule box, with `width=`/`height=` taking dimensions or fractions of `\textwidth`/`\textheight`, `scale=` a percentage of the natural size, `keepaspectratio` shrinking both dimensions to fit, and `\graphicspath` directories searched with common image extensions when the path has no suffix; `longtable` environments are captured through the same tabular path (including their `\endfirsthead`/`\endhead` markers), and a `table` environment becomes a float that carries its captured `tabular` body and a numbered `Table n:` caption whose text sits above the tabular as in LaTeX, while `\caption*` stays unnumbered for either float kind; `\tabcolsep` (or `\setlength{\tabcolsep}`) sets the glue on each side of every tabular column, with LaTeX's 6pt default when unset, and `\renewcommand{\arraystretch}{factor}` (or `\def\arraystretch{factor}`) scales every tabular row height; a `tabular`/`longtable` optional position argument is accepted and ignored, and a row separator `\\[dim]` adds that vertical gap after its row, and `|` column separators paint 0.4pt vertical rules at their column boundaries, and `*{n}{cols}` repeats a column group n times; caption prefixes and the abstract heading can be renamed with `\renewcommand{\figurename}`, `\renewcommand{\tablename}` and `\renewcommand{\abstractname}`, while the bibliography, table of contents and float lists open with `References`/`Contents`/`List of Figures`/`List of Tables` headings renamed by `\renewcommand{\refname}`, `\renewcommand{\contentsname}`, `\renewcommand{\listfigurename}` and `\renewcommand{\listtablename}`; `theorem`/`lemma`/`corollary`/`proposition`/`definition`/`example`/`remark`/`proof` environments get a bold numbered heading (optionally with `[title]`), italic statements for the theorem group, an unnumbered proof whose optional argument replaces its heading text, and `\label`/`\ref` targets; `\newtheorem{env}[shared]{Display}`, `\newtheorem{env}{Display}[section]` and `\newtheorem*{env}{Display}` define custom environments with shared counters and section-scoped numbers; `itemize`/`enumerate`/`description` lists nest with depth-aware bullets (`•`, `–`, `*`), lettered/roman sub-labels and 12pt-per-level indentation, items take article's per-level `\topsep`/`\itemsep` plus `\partopsep` above the first item (top level 8+2/4pt at 10pt, 9+3/4.5pt at 11pt and 10+3/5pt at 12pt, with 4+2/2pt, 4.5+3/2pt and 5+3/2pt at the second level; `\setlength{\topsep}`, `\setlength{\itemsep}` and `\setlength{\partopsep}` override them, and a wrapped item hangs its continuation lines at the text indent while its first line stays at the bullet indent), an optional `\item[label]` overrides the generated marker, and `description` items print their term in bold before the definition, and a `\setcounter{enumi}` (or `enumii`/`enumiii`/`enumiv`) line before the first `\item` resumes the enumerate count; `center`/`flushleft`/`flushright` parse their body as blocks (so a nested list, graphic or rule keeps its own handling), a `quotation` environment splits its blank-line-separated paragraphs into blocks indented 20pt on both sides (nested lists add the margins to their own indentation), and `quote` uses the same 20pt margins, while `verse` keeps its explicit line breaks as separate 20pt-indented lines, and a `minipage{w}` environment lays its body out at width `w` (its optional position argument is ignored); `\def\name#1{...}` parameter texts and `\let\alias=\other` aliases are executed as textual definitions, and the scratch registers `\dimen0`-`\dimen9` and `\skip0`-`\skip9` hold dimensions and glue with the same assignment and `\advance` forms, and `\count0`-`\count9` take assignments, `\advance`, `\multiply` and `\divide` and print through `\the`/`\number`, while `\newcount\name` declares an integer register that `\name= `\numexpr` evaluates `+`, `-`, `*`, `/` and parentheses over integers and integer registers, either standalone or after `\the` `\newdimen\name` declares a dimension register whose value `\name=`, `\advance\name by `, `\multiply\name by ` and `\divide\name by ` update and which `\the\name` prints in TeX's `pt` form.....`, `\advance\name by ...`, `\multiply\name by ...` and `\divide\name by ...` update and that `\the\name`/`\number\name` print `\dimexpr ... \relax` evaluates `+`, `-`, `*` (by an integer) and `/` over dimensions and `\newdimen` registers and prints through `\the`, and `\glueexpr ... \relax` evaluates glue expressions over dimensions, `\newskip` registers and `plus`/`minus` components, printing through `\the`; `\noexpand\token` keeps the token unexpanded for the current pass (a later pass still expands it), and a later `\def` with the same name replaces the earlier definition The LaTeX internals `\@namedef`, `\@nameuse`, `\@ifundefined`, `\@firstofone`, `\@firstoftwo`, `\@secondoftwo` and `\@empty` expand, and `\@ifstar{yes}{no}` / `\@ifnextchar{yes}{no}` choose a branch from the following token, and `@` counts as a letter in control words so `\makeatletter`-guarded names parse..; `\newenvironment{name}[n]{begin}{end}` definitions expand their begin/end codes around the environment body, with numbered arguments available in both; `\newif\ifname` flags default to false and `\nametrue`/`\namefalse` assignments, whether in the preamble or the body, select between `\ifname ... \else ... \fi` branches (and `\ifdefined\name` tests whether a macro is declared; `\ifnum` compares integers from literals, `\newcount` registers or `\value{counter}`, and `\ifx` compares token meanings (two macros are equal when their parameter text and body match) `\ifcase ` chooses the n-th `\or` branch and falls back to `\else` when the value is out of range..); project previews and PDF exports expand `\input{...}`/`\include{...}` from the project's files (the `.tex` suffix may be omitted) while unknown files stay literal text, and inline a project's own `.sty` files for `\usepackage{name}` and `.cls` files for `\documentclass` (rewritten to `article` with the original options kept), recursively inlining local `\RequirePackage` dependencies (up to eight levels, cycles skipped), inlining local `\input{...}` files inside class/package bodies (unresolved ones are dropped), `\AtBeginDocument`/`\AtEndDocument` bodies are executed while `\makeatletter`/`\makeatother` are stripped, dropping package/class boilerplate (`\ProvidesPackage`/`\ProvidesClass`, `\NeedsTeXFormat`, `\RequirePackage`) and inlining local base classes requested with `\LoadClass`/`\LoadClassWithOptions` (unknown bases keep LaTeX's article fallback); local class and package files execute their `\DeclareOption`/`\ExecuteOptions`/`\ProcessOptions` subset, so options named on `\documentclass[...]` or `\usepackage[...]` run their declaration code and `\ExecuteOptions` supplies defaults, and `\PassOptionsToPackage`/`\PassOptionsToClass` lines are collected from the preamble and merged into the next `\usepackage`/`\documentclass` request; a full class layout implementation and arbitrary package code remain open, and `\textcolor{name}{...}` paints an inline run in one of the standard named colours in both the SVG preview and the PDF, and a leading `\color{name}` switch colours the rest of its paragraph (`\definecolor` supports rgb, RGB, gray, HTML and cmyk models, `\pagecolor{name}` fills the page background, a `name!percent!other` spec mixes two named colours linearly, the second defaulting to white, and `\hypersetup{urlcolor=...}` colours `\href` labels and `linkbordercolor`/`urlbordercolor` request a 1pt coloured annotation border (`hidelinks` omits it), and `\colorbox{name}{...}` paints a filled rectangle behind its text, and `\fcolorbox{frame}{background}{...}` draws a 0.4pt frame around that rectangle; `\newskip\name` declares a glue register whose width, stretch and shrink are updated by `\name=`, `\advance\name by ` and `\setlength{\name}{}`, and `\the\name` prints them as `wpt plus spt minus hpt`) | +| M6 | class/package execution (`article`, `sn-jnl`) | **partial**: a leading `\noindent` starts a paragraph flush with the measure, `\documentclass[...]` options are read and the article `10pt`/`11pt`/`12pt` base size sets the default paragraph font size and `\baselineskip` (13.6pt/14.5pt), and `\linespread{factor}` (or `\renewcommand{\baselinestretch}{factor}`/`\def\baselinestretch{factor}`) scales that class baseline, while `\newlength{\name}` registers a named length that `\setlength` can assign and a later `\setlength{\parindent}{\name}` can read, and `\addtolength{\name}{...}` adjusts it; the `geometry` package's `margin`/`hmargin`/`vmargin`/`left`/`right`/`top`/`bottom` options (and `\geometry{...}`) adjust the measure and page height; page numbers print centred below the text block, `\setcounter{page}` offsets the printed number, `\addtocounter{page}` shifts it (`\pagenumbering` resets it to 1), `\pagenumbering{roman|Roman|alph|Alph|arabic}` selects the format and `\pagestyle{empty}` suppresses them on every page and `\thispagestyle{empty}` on the first page; `\title`/`\author`/`\date` are captured, `\hypersetup{pdftitle=...}` (also `pdfauthor`/`pdfsubject`/`pdfkeywords`) writes the PDF Info dictionary with UTF-16BE values for non-ASCII text (falling back to `\title`/`\author`), each numbered heading becomes a PDF bookmark in `/Outlines`, nested by heading level and pointing at its page, `\today` expands to the UTC calendar date in the title block and the body, and `\maketitle` expands into the centered article title block at the class sizes (with today's date when `\date` is absent and no date for `\date{}`); numbered `\section`/`\subsection`/`\subsubsection`/`\paragraph`/`\subparagraph` headings advance five-level article counters (article's `\setcounter{secnumdepth}` default of 3 numbers through `\subsubsection`, and raising it numbers the two deeper levels; `\setcounter{section}`/`{figure}`/`{table}`/`{equation}`/`{theorem}` offsets the next counter value) and paint at `\Large`/`\large`/`\normalsize` (the two deepest levels stay bold at the base size), starred headings stay unnumbered, and an optional `[short]` title replaces the long title in the table of contents; the `abstract` environment expands into a centered bold heading and a 9pt body, `\maketitle` joins `\and` authors and turns `\thanks` notes into title footnotes, and `\label` inside a heading (or on its own line after it) resolves `\ref`/`\eqref` to the section number while unknown references print `??`, and `\pageref{label}` reports the formatted page number of that heading after a probe layout (unknown labels print `??`), and `\appendix` restarts sectioning with letters (`A`, `A.1`), and `\tableofcontents` lists the numbered headings through `\subsubsection` with 12pt per-level indentation and a right-aligned page number reached by dot leaders that fill the measure (the default article `tocdepth` of 3; `\setcounter{tocdepth}` changes the depth) while `\listoffigures`/`\listoftables` reproduce the numbered figure/table captions and append each float's page number after dot leaders that fill the measure (an optional `[short]` caption is used there while the long caption stays on the float); `verbatim` environments keep each source line as a monospaced 9pt paragraph indented by 12pt (leading whitespace is normalised), `\verb|...|` renders inline literal text in the mono face, common text commands such as `\LaTeX`, `\TeX`, `\ldots`, `\dots`, `\S`, `\copyright`, `\pounds`, `\ss`/`\ae`/`\oe`/`\o`/`\l`/`\dh`/`\th` and symbol commands such as `\textdegree`/`\textmu`/`\textonehalf`/`\texteuro` expand to their characters, and a control word swallows the spaces that follow it, `\href{url}{text}` keeps its text, and `\url{...}` becomes typewriter text; `\footnote{...}` becomes a numbered 9pt page insertion on the page that mentions it; a `thebibliography` environment is removed from the body, its `\bibitem` entries become numbered `[n]` paragraphs, and `\cite{...}` resolves to `[n]`/`[n, m]` (unknown keys print `[?]`, an optional note like `\cite[p.~3]{...}` is dropped, `\citep`/`\citet` behave like `\cite`, `\nocite` is ignored, and `\bibliography`/`\bibliographystyle` lines are consumed without running BibTeX); a `figure` environment becomes a float at its `[t]`/`[b]`/`[h]` placement, its `\caption` numbers as `Figure n:` and resolves `\ref`, and `\includegraphics` embeds the referenced project image (PNG/JPEG/BMP are decoded into a PDF XObject, with a rule placeholder when the file is missing or cannot be decoded), and a standalone `\includegraphics` paragraph becomes an in-text graphic float, while a standalone `\rule{width}{height}` becomes an in-text rule box, with `width=`/`height=` taking dimensions or fractions of `\textwidth`/`\textheight`, `scale=` a percentage of the natural size, `keepaspectratio` shrinking both dimensions to fit, and `\graphicspath` directories searched with common image extensions when the path has no suffix; `longtable` environments are captured through the same tabular path (including their `\endfirsthead`/`\endhead` markers), and a `table` environment becomes a float that carries its captured `tabular` body and a numbered `Table n:` caption whose text sits above the tabular as in LaTeX, while `\caption*` stays unnumbered for either float kind; `\tabcolsep` (or `\setlength{\tabcolsep}`) sets the glue on each side of every tabular column, with LaTeX's 6pt default when unset, and `\renewcommand{\arraystretch}{factor}` (or `\def\arraystretch{factor}`) scales every tabular row height; a `tabular`/`longtable` optional position argument is accepted and ignored, and a row separator `\\[dim]` adds that vertical gap after its row, and `|` column separators paint 0.4pt vertical rules at their column boundaries, and `*{n}{cols}` repeats a column group n times; caption prefixes and the abstract heading can be renamed with `\renewcommand{\figurename}`, `\renewcommand{\tablename}` and `\renewcommand{\abstractname}`, while the bibliography, table of contents and float lists open with `References`/`Contents`/`List of Figures`/`List of Tables` headings renamed by `\renewcommand{\refname}`, `\renewcommand{\contentsname}`, `\renewcommand{\listfigurename}` and `\renewcommand{\listtablename}`; `theorem`/`lemma`/`corollary`/`proposition`/`definition`/`example`/`remark`/`proof` environments get a bold numbered heading (optionally with `[title]`), italic statements for the theorem group, an unnumbered proof whose optional argument replaces its heading text, and `\label`/`\ref` targets; `\newtheorem{env}[shared]{Display}`, `\newtheorem{env}{Display}[section]` and `\newtheorem*{env}{Display}` define custom environments with shared counters and section-scoped numbers; `itemize`/`enumerate`/`description` lists nest with depth-aware bullets (`•`, `–`, `*`), lettered/roman sub-labels and 12pt-per-level indentation, items take article's per-level `\topsep`/`\itemsep` plus `\partopsep` above the first item (top level 8+2/4pt at 10pt, 9+3/4.5pt at 11pt and 10+3/5pt at 12pt, with 4+2/2pt, 4.5+3/2pt and 5+3/2pt at the second level; `\setlength{\topsep}`, `\setlength{\itemsep}` and `\setlength{\partopsep}` override them, and a wrapped item hangs its continuation lines at the text indent while its first line stays at the bullet indent), an optional `\item[label]` overrides the generated marker, and `description` items print their term in bold before the definition, and a `\setcounter{enumi}` (or `enumii`/`enumiii`/`enumiv`) line before the first `\item` resumes the enumerate count; `center`/`flushleft`/`flushright` parse their body as blocks (so a nested list, graphic or rule keeps its own handling), a `quotation` environment splits its blank-line-separated paragraphs into blocks indented 20pt on both sides (nested lists add the margins to their own indentation), and `quote` uses the same 20pt margins, while `verse` keeps its explicit line breaks as separate 20pt-indented lines, and a `minipage{w}` environment lays its body out at width `w` (its optional position argument is ignored); `\def\name#1{...}` parameter texts and `\let\alias=\other` aliases are executed as textual definitions, and the scratch registers `\dimen0`-`\dimen255` and `\skip0`-`\skip255` hold dimensions and glue with the same assignment and `\advance` forms, and `\count0`-`\count255` take assignments, `\advance`, `\multiply` and `\divide` and print through `\the`/`\number`, while `\newcount\name` declares an integer register that `\name= `\numexpr` evaluates `+`, `-`, `*`, `/` and parentheses over integers and integer registers, either standalone or after `\the` `\newdimen\name` declares a dimension register whose value `\name=`, `\advance\name by `, `\multiply\name by ` and `\divide\name by ` update and which `\the\name` prints in TeX's `pt` form.....`, `\advance\name by ...`, `\multiply\name by ...` and `\divide\name by ...` update and that `\the\name`/`\number\name` print `\dimexpr ... \relax` evaluates `+`, `-`, `*` (by an integer) and `/` over dimensions and `\newdimen` registers and prints through `\the`, and `\glueexpr ... \relax` evaluates glue expressions over dimensions, `\newskip` registers and `plus`/`minus` components, printing through `\the`; `\noexpand\token` keeps the token unexpanded for the current pass (a later pass still expands it), and a later `\def` with the same name replaces the earlier definition The LaTeX internals `\@namedef`, `\@nameuse`, `\@ifundefined`, `\@firstofone`, `\@firstoftwo`, `\@secondoftwo` and `\@empty` expand, and `\@ifstar{yes}{no}` / `\@ifnextchar{yes}{no}` choose a branch from the following token, and `@` counts as a letter in control words so `\makeatletter`-guarded names parse..; `\newenvironment{name}[n]{begin}{end}` definitions expand their begin/end codes around the environment body, with numbered arguments available in both; `\newif\ifname` flags default to false and `\nametrue`/`\namefalse` assignments, whether in the preamble or the body, select between `\ifname ... \else ... \fi` branches (and `\ifdefined\name` tests whether a macro is declared; `\ifnum` compares integers from literals, `\newcount` registers or `\value{counter}`, and `\ifx` compares token meanings (two macros are equal when their parameter text and body match) `\ifcase ` chooses the n-th `\or` branch and falls back to `\else` when the value is out of range..); project previews and PDF exports expand `\input{...}`/`\include{...}` from the project's files (the `.tex` suffix may be omitted) while unknown files stay literal text, and inline a project's own `.sty` files for `\usepackage{name}` and `.cls` files for `\documentclass` (rewritten to `article` with the original options kept), recursively inlining local `\RequirePackage` dependencies (up to eight levels, cycles skipped), inlining local `\input{...}` files inside class/package bodies (unresolved ones are dropped), `\AtBeginDocument`/`\AtEndDocument` bodies are executed while `\makeatletter`/`\makeatother` are stripped, dropping package/class boilerplate (`\ProvidesPackage`/`\ProvidesClass`, `\NeedsTeXFormat`, `\RequirePackage`) and inlining local base classes requested with `\LoadClass`/`\LoadClassWithOptions` (unknown bases keep LaTeX's article fallback); local class and package files execute their `\DeclareOption`/`\ExecuteOptions`/`\ProcessOptions` subset, so options named on `\documentclass[...]` or `\usepackage[...]` run their declaration code and `\ExecuteOptions` supplies defaults, and `\PassOptionsToPackage`/`\PassOptionsToClass` lines are collected from the preamble and merged into the next `\usepackage`/`\documentclass` request; a full class layout implementation and arbitrary package code remain open, and `\textcolor{name}{...}` paints an inline run in one of the standard named colours in both the SVG preview and the PDF, and a leading `\color{name}` switch colours the rest of its paragraph (`\definecolor` supports rgb, RGB, gray, HTML and cmyk models, `\pagecolor{name}` fills the page background, a `name!percent!other` spec mixes two named colours linearly, the second defaulting to white, and `\hypersetup{urlcolor=...}` colours `\href` labels and `linkbordercolor`/`urlbordercolor` request a 1pt coloured annotation border (`hidelinks` omits it), and `\colorbox{name}{...}` paints a filled rectangle behind its text, and `\fcolorbox{frame}{background}{...}` draws a 0.4pt frame around that rectangle; `\newskip\name` declares a glue register whose width, stretch and shrink are updated by `\name=`, `\advance\name by ` and `\setlength{\name}{}`, and `\the\name` prints them as `wpt plus spt minus hpt`) | | M7 | `\special`, PDF XObjects, hyperref annotations | PDF structure parity | ## Current limits @@ -367,7 +367,7 @@ Math coverage includes fractions/roots, scripts, `\left...\right` with body-scal Paragraph units carry a `ParagraphFont`; `Unit::paragraph_with_face` and `Unit::paragraph_with_style_and_face` select Roman, bold, italic, mono, or sans. The corresponding Computer Modern TFM (`cmr10`, `cmbx10`, `cmti10`, `cmbxti10`, `cmtt10`, `cmss10`, `cmssbx10`, `cmssi10`, `cmcsc10`) supplies advances, kerns, ligatures, and italic correction for layout, the display list selects the matching face, and the PDF writes Computer Modern Type1 outlines for each built-in face (`cmr10`/`cmbx10`/`cmti10`/`cmbxti10`/`cmtt10`/`cmss10`/`cmssbx10`/`cmssi10`/`cmcsc10`, plus `cmmi10` for mathematical italic letters, `cmsy10` for math symbols and `cmex10` for big operators), falling back to Liberation subsets only for characters the Type1 encodings cannot address; those fallback glyphs keep their Unicode text under PDF extraction, so accented and Greek words round-trip; Type1 faces carry a ToUnicode CMap built from the requested characters, so glyphs whose names are ambiguous in the Adobe Glyph List (capital Omega, which would otherwise extract as U+2126) keep their intended code points. `Engine::edit` preserves the face when reflowing an edited paragraph. -The crate currently has 427 unit tests plus ten route-D integration tests and thirty-eight oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 884 tests (427 route-D unit, 273 engine binary unit, 10 route-D integration, 38 oracle, 71 v1 integration, 60 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path. +The crate currently has 427 unit tests plus ten route-D integration tests and thirty-eight oracle fixtures. Workspace verification: `cargo fmt --all -- --check`; `cargo test --workspace --offline` runs 885 tests (427 route-D unit, 274 engine binary unit, 10 route-D integration, 38 oracle, 71 v1 integration, 60 server, 4 engine unit, 1 core unit), with none ignored. v1 remains the live server path. ### M0 incremental demo diff --git a/src/route_d.rs b/src/route_d.rs index e4b93fe..e32636a 100755 --- a/src/route_d.rs +++ b/src/route_d.rs @@ -196,11 +196,11 @@ struct PageGeometry { /// Glue registers declared with `\newskip` as width, stretch, shrink. skip_registers: Vec<(String, [i64; 3])>, /// TeX scratch count registers 0 through 9. - numbered_counts: [i64; 10], + numbered_counts: Vec, /// TeX scratch dimension registers 0 through 9, in scaled points. - numbered_dimens: [i64; 10], + numbered_dimens: Vec, /// TeX scratch glue registers 0 through 9. - numbered_skips: [[i64; 3]; 10], + numbered_skips: Vec<[i64; 3]>, /// `\pagenumbering` style used for the printed page numbers. page_numbering: Option, /// Zero-based page counter offset set with `\setcounter{page}`. @@ -3173,31 +3173,49 @@ fn expand_dimension_registers(body: &str, registers: &mut Vec<(String, i64)>) -> /// `\multiply` / `\divide`, and `\the` / `\number` printing. fn numbered_count(text: &str) -> Option<(usize, usize)> { let rest = text.strip_prefix("\\count")?; - let digit = rest.chars().next()?; - if !digit.is_ascii_digit() { + let digits: String = rest + .chars() + .take_while(|character| character.is_ascii_digit()) + .collect(); + if digits.is_empty() || digits.len() > 3 { return None; } - let index = digit.to_digit(10)? as usize; - if index > 9 { + let index: usize = digits.parse().ok()?; + if index >= 256 { return None; } - Some((index, "\\count".len() + digit.len_utf8())) + Some((index, "\\count".len() + digits.len())) } fn numbered_slot(text: &str, command: &str) -> Option<(usize, usize)> { let rest = text.strip_prefix(command)?; - let digit = rest.chars().next()?; - if !digit.is_ascii_digit() { + let digits: String = rest + .chars() + .take_while(|character| character.is_ascii_digit()) + .collect(); + if digits.is_empty() || digits.len() > 3 { return None; } - let index = digit.to_digit(10)? as usize; - if index > 9 { + let index: usize = digits.parse().ok()?; + if index >= 256 { return None; } - Some((index, command.len() + digit.len_utf8())) + Some((index, command.len() + digits.len())) } -fn expand_numbered_dimens(body: &str, registers: &mut [i64; 10]) -> String { +fn ensure_count_slot(registers: &mut Vec, index: usize) { + if registers.len() <= index { + registers.resize(index + 1, 0); + } +} + +fn ensure_skip_slot(registers: &mut Vec<[i64; 3]>, index: usize) { + if registers.len() <= index { + registers.resize(index + 1, [0, 0, 0]); + } +} + +fn expand_numbered_dimens(body: &str, registers: &mut Vec) -> String { let mut result = String::new(); let mut index = 0; while index < body.len() { @@ -3211,6 +3229,7 @@ fn expand_numbered_dimens(body: &str, registers: &mut [i64; 10]) -> String { let name = command.trim_start_matches('\\'); if name == "dimen" { if let Some((slot, used)) = numbered_slot(rest, "\\dimen") { + ensure_count_slot(registers, slot); let trimmed = rest[used..].trim_start(); if let Some(value) = trimmed.strip_prefix('=') { if let Some((dimension, consumed)) = scan_tex_dimension(value) { @@ -3227,6 +3246,7 @@ fn expand_numbered_dimens(body: &str, registers: &mut [i64; 10]) -> String { if matches!(name, "advance" | "multiply" | "divide") { let after = rest[length..].trim_start(); if let Some((slot, used)) = numbered_slot(after, "\\dimen") { + ensure_count_slot(registers, slot); let raw = after[used..].trim_start(); let raw = raw.strip_prefix("by").map(str::trim_start).unwrap_or(raw); if let Some((value, consumed)) = scan_tex_dimension(raw) { @@ -3247,6 +3267,7 @@ fn expand_numbered_dimens(body: &str, registers: &mut [i64; 10]) -> String { if name == "the" || name == "number" { let after = rest[length..].trim_start(); if let Some((slot, used)) = numbered_slot(after, "\\dimen") { + ensure_count_slot(registers, slot); result.push_str(&format_dimension(registers[slot])); index = body.len() - after[used..].len(); continue; @@ -3258,7 +3279,7 @@ fn expand_numbered_dimens(body: &str, registers: &mut [i64; 10]) -> String { result } -fn expand_numbered_skips(body: &str, registers: &mut [[i64; 3]; 10]) -> String { +fn expand_numbered_skips(body: &str, registers: &mut Vec<[i64; 3]>) -> String { let mut result = String::new(); let mut index = 0; while index < body.len() { @@ -3272,6 +3293,7 @@ fn expand_numbered_skips(body: &str, registers: &mut [[i64; 3]; 10]) -> String { let name = command.trim_start_matches('\\'); if name == "skip" { if let Some((slot, used)) = numbered_slot(rest, "\\skip") { + ensure_skip_slot(registers, slot); let trimmed = rest[used..].trim_start(); if let Some(value) = trimmed.strip_prefix('=') { if let Some((width, stretch, shrink, consumed)) = parse_glue(value) { @@ -3288,6 +3310,7 @@ fn expand_numbered_skips(body: &str, registers: &mut [[i64; 3]; 10]) -> String { if name == "advance" { let after = rest[length..].trim_start(); if let Some((slot, used)) = numbered_slot(after, "\\skip") { + ensure_skip_slot(registers, slot); let raw = after[used..].trim_start(); let raw = raw.strip_prefix("by").map(str::trim_start).unwrap_or(raw); if let Some((width, stretch, shrink, consumed)) = parse_glue(raw) { @@ -3303,6 +3326,7 @@ fn expand_numbered_skips(body: &str, registers: &mut [[i64; 3]; 10]) -> String { if name == "the" { let after = rest[length..].trim_start(); if let Some((slot, used)) = numbered_slot(after, "\\skip") { + ensure_skip_slot(registers, slot); result.push_str(&format_glue(registers[slot])); index = body.len() - after[used..].len(); continue; @@ -3314,7 +3338,7 @@ fn expand_numbered_skips(body: &str, registers: &mut [[i64; 3]; 10]) -> String { result } -fn expand_numbered_counts(body: &str, registers: &mut [i64; 10]) -> String { +fn expand_numbered_counts(body: &str, registers: &mut Vec) -> String { let mut result = String::new(); let mut index = 0; while index < body.len() { @@ -3328,6 +3352,7 @@ fn expand_numbered_counts(body: &str, registers: &mut [i64; 10]) -> String { let name = command.trim_start_matches('\\'); if name == "count" { if let Some((slot, used)) = numbered_count(rest) { + ensure_count_slot(registers, slot); let after = &rest[used..]; let trimmed = after.trim_start(); if let Some(value) = trimmed.strip_prefix('=') { @@ -3345,6 +3370,7 @@ fn expand_numbered_counts(body: &str, registers: &mut [i64; 10]) -> String { if matches!(name, "advance" | "multiply" | "divide") { let after = rest[length..].trim_start(); if let Some((slot, used)) = numbered_count(after) { + ensure_count_slot(registers, slot); let raw = after[used..].trim_start(); let raw = raw.strip_prefix("by").map(str::trim_start).unwrap_or(raw); if let Some((number, consumed)) = scan_signed_integer(raw) { @@ -3365,6 +3391,7 @@ fn expand_numbered_counts(body: &str, registers: &mut [i64; 10]) -> String { if name == "the" || name == "number" { let after = rest[length..].trim_start(); if let Some((slot, used)) = numbered_count(after) { + ensure_count_slot(registers, slot); result.push_str(®isters[slot].to_string()); index = body.len() - after[used..].len(); continue; @@ -9931,6 +9958,16 @@ a & b ); } + #[test] + fn numbered_registers_accept_multi_digit_slots() { + let source = "\\count12=7\n\\dimen42=3pt\n\\skip100=2pt plus 1pt\n\nA \\the\\count12 B \\the\\dimen42 C \\the\\skip100."; + let (body, geometry) = geometry_and_body(source); + assert_eq!(geometry.numbered_counts[12], 7); + assert_eq!(geometry.numbered_dimens[42], 196_608); + assert_eq!(geometry.numbered_skips[100], [131_072, 65_536, 0]); + assert!(body.contains("A 7 B 3.0pt C 2.0pt plus 1.0pt."), "{body:?}"); + } + #[test] fn numbered_count_registers_track_arithmetic() { let source = "\\count0=5\n\\advance\\count0 by 2\n\\multiply\\count0 by 3\n\\divide\\count0 by 2\n\nSteps \\the\\count0.";