Repository navigation
Fix auto hanging-indent for 〔1〕 heading numbering - #7247
Conversation
一、 numbering一、 heading numbering
6399109 to
f52f91d
Compare
|
What's the state of this PR? |
|
It fixes the original issue, but does not work well with Also the implementation depends on quirks of I guess there exists a better fix, so I've marked it as a draft. |
|
I think the supposed quirk of measure is rather a quirk of either horizontal spacing or CJ punctuation adjustment. From a Western perspective, the patch here seems unproblematic, but if it doesn't really solve the problem for CJ users, that's unfortunate. I can't properly judge it, but from gut feeling perhaps the CJ punctuation adjustment is the root cause and needs change? I'd overall like to see the CJK handling in inline layout reworked as it has various subtle issues and is not that cleanly implemented. |
|
I haven't carefully inspected how the CJ punctuation adjustment is implemented; but based on what DeepWiki told me, I think it looks logical. It's just that the punctuation adjustment doesn't rhyme with higher-level adjustment (e.g., justification). Higher-level adjustment is irrelevant in this case, because the issue occurs even if justification is disabled and linebreaks are controlled manually. I believe the root cause lies in this comment: typst/crates/typst-layout/src/rules.rs Lines 267 to 268 in bf94617
|
|
Having a locator wouldn't really change anything about measurement for this case. It lets things resolve "in context" in the sense that introspections resolve properly, but it does not let measure peak ahead and see that a weak space would not collapse. Overall, I'm not sure how to proceed here. As I mentioned, the current diff looks unproblematic, but you mentioned that it does not fully address the issue. I think we should come to a decision here on whether we actually think we can merge something here or whether to close this. |
|
Oh, my opinion has changed a bit. Someone once came across a use case in their real life that involves full-width punctuations and don't need to remove the 0.3em space (but I can't recall the speicifc case right now…). I'll check my chat history, replace the currently suboptimal test case with that case, and then mark this PR as ready for review. Update: Update 2: Update 3: Test#set page(height: auto, width: 120pt, margin: 10pt)
#set text(lang: "zh", region: "CN", font: "Noto Serif CJK SC", fallback: false)
#set text(10pt)
#show heading: set text(10pt, weight: "regular")
#set page(width: 12em, margin: 1em)
#set heading(numbering: "〔1〕")
= #context here().position().x;犹可说也不可说也
〔1〕#h(0.3em, weak: true)#context here().position().x;犹可说也不可说也
#h(0.00001pt)〔1〕#h(0.3em, weak: true)#context here().position().x;犹可说也不可说也
#block(inset: (left: 22.71pt))[
#h(-22.71pt)〔1〕#h(0.3em, weak: true)#context here().position().x;犹可说也不可说也
]
#context here().position().x
- #context measure("〔1〕" + h(0.3em)).width
- #context measure("〔").width
- #context measure("1").width
- #context measure("〕").width
|
一、 heading numbering〔1〕 heading numbering
|
Hi! I've revised the code and update the PR description. It's ready for review now. |
7b2b9a6 to
cdf8231
Compare
|
Thanks! |
|
Update: Oh, I see what's going here… Never mind. |
|
I felt a weak space was a bit cleaner since it doesn't just cancel out, but actually disappears during layout. |
93 commits novos desde v0.15.1 (tag 9dfd3a0) até upstream/main (a51e028). 397 ficheiros alterados, 5782 inserções, 2831 remoções. Destaques do upstream: - Store required features in bindings (typst#8599) - Support raw serialization format for typst eval (typst#8295) - Add diagnostics-format environment variable (typst#8438) - More robust overhang (typst#8131) - Fix logical indices of hyphens with respect to surrounding tags (typst#8714) - Bump krilla and hayro (typst#8716) - Fix line breaking for hosts starting with a digit (typst#8039) - Fix auto hanging-indent for heading numbering (typst#7247) Build vanilla verificado: cargo build ok (3m02s).
93 commits novos desde v0.15.1 (tag 9dfd3a0) até upstream/main (a51e028). 397 ficheiros alterados, 5782 inserções, 2831 remoções. Destaques do upstream: - Store required features in bindings (typst#8599) - Support raw serialization format for typst eval (typst#8295) - Add diagnostics-format environment variable (typst#8438) - More robust overhang (typst#8131) - Fix logical indices of hyphens with respect to surrounding tags (typst#8714) - Bump krilla and hayro (typst#8716) - Fix line breaking for hosts starting with a digit (typst#8039) - Fix auto hanging-indent for heading numbering (typst#7247) Build vanilla verificado: cargo build ok (3m02s).


Resolves a part of #6527.
Previously, if the heading numbering starts or ends with a CJ punctuation and its width is allowed to be shrunk or stretched, then
hanging-indent: autoresolves to the wrong length, resulting in multi-line headings misaligned.This PR amends the logic of
measure(heading.numbering).widthto fix that.#set heading(hanging-indent: 2em).Previous discussions
See Typographic measure theory (or the backup on the forum) for more testing.
Discord, 2025-10-30: