Skip to content

Fix auto hanging-indent for 一、 heading numbering#7247

Draft
YDX-2147483647 wants to merge 10 commits intotypst:mainfrom
YDX-2147483647:indent-auto
Draft

Fix auto hanging-indent for 一、 heading numbering#7247
YDX-2147483647 wants to merge 10 commits intotypst:mainfrom
YDX-2147483647:indent-auto

Conversation

@YDX-2147483647
Copy link
Copy Markdown
Contributor

@YDX-2147483647 YDX-2147483647 commented Oct 28, 2025

Not ready for review yet.

Resolves #6527

See Typographic measure theory (or the backup on the forum) for more testing.

Discord, 2025-10-30:

Hi! There is a 0.3-em spacing between the heading number and the body. At present, the spacing is weak.
Does anyone know why it has to be weak? Could it be changed to a strong spacing? How about h(0.3em, weak: true) + h(0pt, weak: false)?
图片

It is weak to eat up a potential leading space in the body. For inline gaps that are intended to be precise, I prefer weak for that reason.

@YDX-2147483647 YDX-2147483647 changed the title Fixed auto hanging indent for 一、 numbering Fix auto hanging-indent for 一、 heading numbering Oct 28, 2025
@laurmaedje laurmaedje added layout Related to the layout category, which is about composing, positioning, etc. fix A bug fix. labels Nov 7, 2025
@laurmaedje laurmaedje added the waiting-on-author Pull request waits on author label Nov 17, 2025
@laurmaedje
Copy link
Copy Markdown
Member

What's the state of this PR?

@YDX-2147483647
Copy link
Copy Markdown
Contributor Author

YDX-2147483647 commented Jan 8, 2026

It fixes the original issue, but does not work well with show h.where(amount: 0.3em): none.
In practice, there's no space after 一、, so show h.where(…): none is usually (if not always) necessary.
Therefore, this PR alone does not fix the real problem, yet introduces a breaking change.

Also the implementation depends on quirks of measure.

I guess there exists a better fix, so I've marked it as a draft.

@laurmaedje laurmaedje added waiting-on-design This PR or issue is blocked by design work. and removed waiting-on-author Pull request waits on author labels Jan 8, 2026
@laurmaedje
Copy link
Copy Markdown
Member

I think the supposed quirk of measure is rather a quirk of either horizontal spacing or CJ punctuation adjustment. h(0pt) will be discarded during inline layout, while it seems like h(0.1pt) will prevent the 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.

@YDX-2147483647
Copy link
Copy Markdown
Contributor Author

YDX-2147483647 commented Jan 28, 2026

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:

// We don't have a locator for the numbering here, so we just
// use the measurement infrastructure for now.

  1. We don't have a locator after the numbering, so we have to resort to measure.
  2. The measure infrastructure can't measure things in context. It has to isolate the object before measurement.
  3. The space occupied by the content may vary depending on the preceding and following content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A bug fix. layout Related to the layout category, which is about composing, positioning, etc. waiting-on-design This PR or issue is blocked by design work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Indentation on multiline headings with full-width character

2 participants