Skip to content

LaTeX reader: space commands, \ outside environments, \middle beside empty sides - #18

Merged
simonebortolin merged 3 commits into
mainfrom
claude/latex-bars-spaces-89b298
Nov 9, 2026
Merged

simonebortolin merged 3 commits into
mainfrom
claude/latex-bars-spaces-89b298

Conversation

@simonebortolin

Copy link
Copy Markdown
Owner

Reads the latex2mathml cases spaces and middle, which leave NotReadYet.

Spaces

  • \hspace, \hskip, \kern, \mkern, \mskip, \mspace take their length in any form (1em, {10ex}, -1.5pt, 10mu, 1em plus 1fil) and become the UnicodeMath space nearest to it (\, \: \; \enspace \quad \qquad). A negative length becomes \!, and a length that is not a number with a unit becomes \quad.
  • \thinspace, \negthinspace, \negmedspace, \negthickspace, \nobreakspace and \space read as the spaces they stand for.
  • \ outside an environment is a line break, which an equation does not keep, so it is left out. a\b now reads as ab; it used to be rejected.

Bars

  • UnicodeMath would read two bars with only zero spaces between them (|\!|) as one double bar, so EscapeOddBars no longer pairs them. A plain || keeps its old reading.
  • The writer now writes a bar standing alone before another bar as |\!, so LaTeX → MathML → LaTeX → MathML gives the same MathML.
  • One-line fix in the UnicodeMath grammar: a no-break space after a bracket is now refused only when a diacritic follows. Before this, (a)~b and |a|~|b| were rejected as invalid UnicodeMath.

\middle

  • An empty side of \middle|, \| or / gets the placeholder ⬚ (├{⬚│⬚┤}). The writer writes it as {}, so the result reads back unchanged: \{{}|{}\}.
  • The corpus test's Canonical now compares UnicodeMath's separator │ as |, which is how latex2mathml writes it.

Merge with main

  • \Box was renamed on both sides; it is kept once.
  • Seven ids that main listed in NotInWordLaTeX now pass, because main wrote that list without the reader changes of b6eeafc: tt, blackboard-bold, mathop, issue-125-4-mathop and the three mathtools arrows. They are taken out of the list.

No snapshot was corrected. VersionPrefix is unchanged. The full suite passes on net10.0 and net481 (5542 tests).

🤖 Generated with Claude Code

simonebortolin and others added 3 commits November 9, 2026 19:12
…ide empty sides

- \hspace, \hskip, \kern, \mkern, \mskip and \mspace read with their length in any form (1em, {10ex}, -1.5pt,
  1em plus 1fil) as the UnicodeMath space nearest to it; \thinspace, \negthinspace, \negmedspace, \negthickspace,
  \nobreakspace and \space as the spaces they are
- \ outside an environment, a line break an equation does not keep, left out
- two bars with only zero spaces between them (|\!|) are no pair, which UnicodeMath would read as a double bar;
  the writer parts a bar alone from the next bar with \!
- \middle with an empty side holds the placeholder there (├{⬚│⬚┤})
- the UnicodeMath grammar takes a no-break space after a bracket ((a)~b), reserved only before a diacritic
- latex2mathml cases spaces and middle read; the corpus test compares the separator │ as |

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The \Box that both sides renamed kept once, and the ids of NotInWordLaTeX that main listed but that read now
with the reader of b6eeafc (\tt, \Bbb, \mathop, the arrows of mathtools) taken out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonebortolin
simonebortolin changed the base branch from main to claude/latex-unknown-command-space-42f4d4 November 9, 2026 18:45
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Pre-release removed now that this PR is closed.

@simonebortolin
simonebortolin changed the base branch from claude/latex-unknown-command-space-42f4d4 to main November 9, 2026 19:07
@simonebortolin
simonebortolin merged commit 2365338 into main Nov 9, 2026
17 checks passed
@simonebortolin
simonebortolin deleted the claude/latex-bars-spaces-89b298 branch November 9, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants