Skip to content

LaTeX reader: a script in brackets that close, x^(a+b), as one group - #35

Merged
simonebortolin merged 1 commit into
mainfrom
claude/latex-bracket-scripts
Nov 11, 2026
Merged

simonebortolin merged 1 commit into
mainfrom
claude/latex-bracket-scripts

Conversation

@simonebortolin

@simonebortolin simonebortolin commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #32: main ← #32 ← this

x^(a+b) was read as x^{()a+b}. The port took the opening bracket alone as the script and closed it with an empty fence. That reading is wrong for TeX and for Word alike, even though it read back the same.

This follows Word's reading, x^{(a+b)}, for two reasons:

  • The reader reads LaTeX as Word reads it.
  • Word's LaTeX writer writes ^(…) for a script in brackets, which would no longer read back with TeX's reading (x^{(}a+b)).

The change is in the pre-pass EscapeOpenBrackets, so the code ported line by line stays as it is. A bracket that is a script and does not close, as in x_(, is still escaped as in #32.

LaTeX Before (written back) Now
x^(a+b) x^{()a+b} x^{(a+b)}
x_[i]y x_{([)i]y} x_{[i]}y
e^(i\pi)_n e_n^{()i\pi} e_n^{(i\pi)}
x^ (a)(b) x^{(()a)(b)} x^{(a)}(b)

4 new cases in ReadsSlashesAndBarsAsLaTeX. 6958/6958 pass on net10.0 and net8.0.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SyVio98rJkziNnwWW9T1Mn

@simonebortolin
simonebortolin added this pull request to stack #36 November 11, 2026 00:18
Base automatically changed from claude/latex-bars-brackets to main November 11, 2026 00:18
…^(a+b) as x^{(a+b)}

The port took the opening bracket alone as the script and closed it with an empty fence (x^{()a+b}). A script in
brackets that close is now grouped whole in EscapeOpenBrackets, as Word's LaTeX writes it and Word reads it
(x^(a+b), x_[i]y, e^(i\pi)_n), keeping the port as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyVio98rJkziNnwWW9T1Mn
@simonebortolin
simonebortolin force-pushed the claude/latex-bracket-scripts branch from e6a4ab3 to 7a7f406 Compare November 11, 2026 00:18
@simonebortolin
simonebortolin merged commit 4ed1669 into main Nov 11, 2026
5 checks passed
@github-actions

Copy link
Copy Markdown

Pre-release 1.0.6-pr.35.97 is ready: https://github.com/simonebortolin/SharpEquations/releases/tag/pr-35-97-1

NuGet package of 7a7f406. Updated on every push, deleted when this PR is closed.

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