Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes equation label/reference numbering misalignment that could occur when frame, solution, and similar outer environments internally route through table_rep::typeset_row, unintentionally triggering the “deferred tag rebinding” mechanism intended for multi-line display math (e.g., align).
Changes:
- Restrict row-scoped
defer-tags=rowandthe-tagsisolation intable_rep::typeset_rowto multi-line display math tables only (table-hyphen=y,mode=math,math-display=true). - Update the developer note (
devel/201_35.md) with the new regression context and expected numbering outcomes. - Expand the regression test TMU to cover the
frame+equationscenario alongside the existingalign/equationchecks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Typeset/Table/table.cpp | Gates defer-tags/the-tags row scoping to multi-line display math tables to prevent accidental deferred rebinding in non-target environments. |
| devel/201_35.md | Documents the new failure mode (frame/solution) and updated verification steps. |
| TeXmacs/tests/tmu/201_35.tmu | Adds a frame test case and updates expected reference/smart-ref associations to validate the fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[201_35] align环境编号后 smart-ref 以及 reference 失效
如何测试
打开
TeXmacs\tests\tmu\201_35.tmu,查看 smart-ref 和 reference 的公式编号是否正确2026/2/28
What
修复在 frame、solution 等环境内的公式编号错位的问题
Why
之前的实现把
defer-tags=row放在table_rep::typeset_row行入口处,导致所有走 table row 的场景都可能触发延迟绑定但
defer-tags的设计初衷仅是服务多行公式(align/eqnarray/gather 等)中“label先于eq-number”的时序修正。像 frame、solution 这类外层环境内部也会进入typeset_row,从而把本不该延迟重绑的 label 键加入the-tags,最终在后续set-binding(1参)时被错误覆盖,表现为编号错位How
将
typeset_row中defer-tags/the-tags的行级作用域从“无条件开启”改为“仅在多行显示公式场景开启”:hyphen == "y":仅处理可按行拆分的数学表格(多行公式结构信号)mode == "math":仅在数学语义环境生效math-display == "true":仅在陈列公式模式生效满足三条件时才
local_begin ("defer-tags", "row")与local_begin ("the-tags", tuple);否则不进入 defer 逻辑。exec_set_binding中已有的defer-tags=="row"判定逻辑保持不变,因此修复后既保留 align 场景的正确重绑,也避免 frame/solution 等环境误触发2025/12/12
What
之前的修改会导致 equation 环境中 label 被下一行覆盖绑定,导致编号出错
Why
在
table_rep::typeset_row只用local_begin/end the-tags的隔离设置在 equation 环境下不会进入 table 行,导致the-tags没被隔离好,因此会被下一个 equation 覆盖绑定How
在表格行入口打标记
defer-tags=row,并在 2 参set-binding(label, <value|the-label>)时判断只有存在defer-tags=="row"标记时才把键加入the-tags这么做还能删除前一个实现中不必要的打补丁,因为列表环境的覆盖绑定也是因为
the-tags没被隔离好:2025/11/30
What
在 align 环境中,若
<label|id>出现在<eq-number>之前,则<reference|id>或<smart-ref|id>会"错位",即显示上一行的编号或“?”。Why
这是一个执行时序问题,排版器按从左到右的顺序处理公式/表格时:
<label|id>实际展开是<set-binding|id|<value|the-label>>(二参形式),然后立即用当前the-label值绑定<eq-number>内部调用<next-equation>,然后执行<set-binding|<the-equation>>(一参形式),更新计数器并设置the-label当
<label|id>出现在<eq-number>之前时,在执行<set-binding|id|<value|the-label>>时the-label尚未更新,所以就绑定了错误的值How
edit_env_rep::exec_set_binding中,当处理到<label|id>的二参形式的set-binding时,若值来自<value|the-label>,则将这个键加入the-tags。这样当后续处理到<eq-number>的一参形式的set-binding时,the-tags能读取这些键,就会用正确的编号值去覆盖绑定它们。如下:table_rep::typeset_row中,在每行开始时隔离the-tags,这样确保行与行之间的the-tags互不干扰,避免<label|id>如果打在<eq-number>之后,会被下一行的<eq-number>错误覆盖。如下:FIX
以上修改实测会触发覆盖绑定的警告。故在处理一参和二参形式时,当涉及延迟绑定时都设置
refined= true,在后面需要流入 redefined 时检测 refined 并跳过即可在列表等环境下,如果新值并不符合可读要求(不是atomic结构)则跳过覆盖绑定