Skip to content

[201_85] Fix : LaTeX formula imports using aligned to show correct numbering format#2861

Open
git-lakshy wants to merge 1 commit intoMoganLab:mainfrom
git-lakshy:myb1
Open

[201_85] Fix : LaTeX formula imports using aligned to show correct numbering format#2861
git-lakshy wants to merge 1 commit intoMoganLab:mainfrom
git-lakshy:myb1

Conversation

@git-lakshy
Copy link
Contributor

@git-lakshy git-lakshy commented Feb 25, 2026

fixes #2804

[201_87] : Fix LaTeX formula imports using "aligned" to show correct numbering format

2026/02/25 Fix equation numbering alignment in aligned environment

What

Redefined aligned*, alignedat*, and alignedat in env-math.ts to produce inline tformat tables instead of delegating to align*/align.

Why

Issue #2804 : when using aligned inside equation, the "equation number" appeared below the multi-line expression instead of vertically centered to the right. The root cause was that aligned* was aliased to align*.
This caused the equation number to be appended sequentially after the block rather than inline beside it.

How

Changed the body of aligned* from <align*|<tformat|<arg|body>>> to a inline tformat with explicit settings. This makes aligned behave as an inline math construct with natural width and no block wrapping, so the equation number is placed correctly to the right.

Screenshots

before
image
after
image

@JackYansongLi
Copy link
Contributor

Nice work! LGTM.

@git-lakshy
Copy link
Contributor Author

Resolved merge conflicts, please review this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts TeXmacs’ math environment macros so LaTeX imports using aligned inside equation place the equation number inline (vertically centered to the right) instead of below the multi-line expression.

Changes:

  • Redefines aligned* to build an inline tformat table directly (instead of delegating to align*).
  • Updates alignedat* and alignedat to delegate to the new aligned* implementation.
  • Adds a leading blank line to devel/201_85.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
TeXmacs/packages/environment/env-math.ts Changes aligned*/alignedat*/alignedat macro definitions to fix equation-number placement for imported LaTeX aligned blocks.
devel/201_85.md Introduces a new leading blank line at the start of the dev log entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 151 to 153
<assign|aligned*|<\macro|body>
<align*|<tformat|<arg|body>>>
<tformat|<twith|table-min-cols|2>|<twith|table-max-cols|2>|<cwith|1|-1|1|1|cell-lsep|0spc>|<cwith|1|-1|1|1|cell-rsep|0.5spc>|<cwith|1|-1|-1|-1|cell-rsep|0spc>|<cwith|1|-1|-1|-1|cell-lsep|0spc>|<cwith|1|-1|1|-1|cell-bsep|0.1fn>|<cwith|1|-1|1|-1|cell-tsep|0.1fn>|<cwith|1|-1|1|1|cell-halign|r>|<cwith|1|-1|-1|-1|cell-halign|l>|<cwith|1|-1|1|-1|cell-block|no>|<arg|body>>
</macro>>
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aligned* now hard-codes a large tformat block that largely duplicates the align* table formatting. This creates a maintainability risk (future changes to align* spacing/column settings may not be mirrored here) and also breaks existing customization hooks that currently work by overriding align* (e.g. env-flush-math.ts and customize/math/math-check.ts redefine align*, but those changes will no longer affect aligned*). Consider factoring the shared table formatting into a helper macro used by both align* and aligned*, or otherwise providing a shared hook so downstream packages can override one place.

Copilot uses AI. Check for mistakes.
Comment on lines 151 to +152
<assign|aligned*|<\macro|body>
<align*|<tformat|<arg|body>>>
<tformat|<twith|table-min-cols|2>|<twith|table-max-cols|2>|<cwith|1|-1|1|1|cell-lsep|0spc>|<cwith|1|-1|1|1|cell-rsep|0.5spc>|<cwith|1|-1|-1|-1|cell-rsep|0spc>|<cwith|1|-1|-1|-1|cell-lsep|0spc>|<cwith|1|-1|1|-1|cell-bsep|0.1fn>|<cwith|1|-1|1|-1|cell-tsep|0.1fn>|<cwith|1|-1|1|1|cell-halign|r>|<cwith|1|-1|-1|-1|cell-halign|l>|<cwith|1|-1|1|-1|cell-block|no>|<arg|body>>
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are existing Scheme-based conversion tests for LaTeX math environments (e.g. TeXmacs/tests/203_6.scm asserts the tree shape for align). This change fixes a specific regression for equation + aligned, but there doesn’t appear to be a test covering that combination yet. Adding a focused regression test for issue #2804 (importing an equation containing an aligned block) would help prevent future numbering/alignment regressions.

Copilot uses AI. Check for mistakes.
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.

LaTeX导入多行公式编号混乱

4 participants