Skip to content

LaTeX reader: \newenvironment and \renewenvironment - #10

Merged
simonebortolin merged 3 commits into
mainfrom
claude/latex-macros-bd8629
Nov 9, 2026
Merged

simonebortolin merged 3 commits into
mainfrom
claude/latex-macros-bd8629

Conversation

@simonebortolin

@simonebortolin simonebortolin commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Based on main. It also carries b6eeafc (the LaTeX and amsmath of the latex2mathml cases, pushed to claude/latex-corpus-tests after #4 was merged), which main does not have yet. Merging main removed from NotInWordLaTeX the seven cases that the reader now reads (tt, blackboard-bold, mathop, issue-125-4-mathop, xLeftarrow-double, xleftrightarrow, xhookleftarrow), and dropped the duplicate \Box entry of Renamed.

  • \newenvironment{name}[n][default]{begin}{end} and \renewenvironment are expanded as TeX does, in a new pass (NewEnvironments) before the others: \begin{name}{arguments}…\end{name} becomes the begin code with its #1… (the first argument optional when it has a default, ## → #), the body and the end code. Nested uses of the same environment and environments in the expansion are expanded too; a space is kept where a control word would otherwise run into the next letter (\alpha + x), and an environment that never stops expanding is rejected after 1000 expansions. The ported ApplyMacro machinery is untouched.
  • The definitions go to the macros dictionary under {name} (a key no control word can collide with), where later conversions find them as they find \newcommand macros.
  • newenvironment-multi-node passes and leaves NotReadYet; newenvironment and newenvironment-with-args pass and leave NotExpanded.
  • newcommand-escaped-hash (\newcommand{\foo}[1]{## #1} \foo{x}) moves to NotLaTeX: ## in a macro body is # in its expansion, and a # in math mode is a TeX error.
  • Regression cases in LaTeXReaderTests (ExpandsEnvironments, RejectsEnvironmentsThatExpandForever).

No snapshot was changed. VersionPrefix is untouched. dotnet test --solution SharpEquations.slnx: 5536/5536 on net10.0 and net481.

🤖 Generated with Claude Code

…does

\begin{name}{arguments}...\end{name} becomes the begin code with its #1...
(the first argument optional with a default), the body and the end code,
before the other passes; the definitions go to the macros, where later
conversions find them. ## in a macro body is # in math mode, which TeX
rejects: newcommand-escaped-hash is no LaTeX.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonebortolin
simonebortolin changed the base branch from claude/latex-corpus-tests to main November 8, 2026 14:20
The groups of NotInWordLaTeX taken from main, without the seven cases the
reader now reads (\tt, \Bbb, \mathop, the arrows of mathtools), and \Box
renamed once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Pre-release removed now that this PR is closed.

@simonebortolin
simonebortolin changed the base branch from main to claude/latex-limits-dacdf3 November 9, 2026 18:45
@simonebortolin
simonebortolin added this pull request to stack #21 November 9, 2026 19:04
Base automatically changed from claude/latex-limits-dacdf3 to main November 9, 2026 19:05
@simonebortolin
simonebortolin merged commit 0922147 into main Nov 9, 2026
17 checks passed
@simonebortolin
simonebortolin deleted the claude/latex-macros-bd8629 branch November 9, 2026 19:24
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