You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Too wide spacing between heading numbering and title in CJK #5778
I noticed that typst will automatically add a 0.3em width space after the heading's numbering, which is usually fine, but Chinese is used to use the full-width symbols 、 as the symbol for the heading's numbering, and both the full-width symbols 、 and the 0.3em width space create a part of the space that can lead to too wide a space between the heading's numbering and its content.
although h(0.3em) can be shown as none by the show rule, i think it is possible to add kerning to the numbering, considering that users who have not read the source code may not know the amount of 0.3em.
changed the title [-]Incorrect spacing in heading between full-width numbering symbols and content[/-][+]Too wide spacing between heading numbering and title in CJK[/+]on Feb 6, 2025
The issue is that there are numerous possibilities for permutations/subsets of
numbering (which may have different forms, e.g., 1.1. vs. 1.1, or 一、 vs. 一),
separator (#h(0.3em), #h(1em), or 2em - measure(numbering).width),
supplement (which may consist of two parts, as in 第{1:一}章),
and the page number.
Currently, there is no simple way to customize those forms separately, unless you reconstruct ref completely and ignore all tricky things about context, styling, query, etc.
displaying ≠ outlined (1. The case of $2/3$ and \ blah blah blah blah ≠ 1. The case of $2\/3$ and blah)
The outlined heading might be shorter. In addition, the number and position of manual #linebreak in them might differ.
In Chinese, for special short headings (such as 译后记 Postscript in the image below), the characters might be arranged loosely, but only when displaying.
It can be achieved in typst 0.13.1, though kind of odd:
Only plain text is allowed in the bookmarked form.
As a result, math equations, rubies, and special spacings should take a different form.
In typst 0.13.1, #h(0.3em) and#h(1em) become void when bookmarked, while $2/3$ becomes 23.
The separator between the numbering and content was discussed in #6622:
I'm open to trying to find a way to make it work nicely in more languages, but it should also work for English.
That makes sense. In fact, not all numbering formats in Chinese (and Japanese, I guess) do not require spaces. "1." definitely needs a space, while 第一章 requires a full-width space.
With the merge of typst/codex#182 and #7350, is it possible to auto-magically remove the spacing betweeen 一、 and 汉字?
After all, the following code now works as expected to some degree.
Activity
[-]Incorrect spacing in heading between full-width numbering symbols and content[/-][+]Too wide spacing between heading numbering and title in CJK[/+]YDX-2147483647 commentedon Aug 4, 2025
There is also a need to increase the width (or more precisely, fix the width of numbering+spacing) here. #2351
Each heading may have at least four forms
These form may not all be the same.
Just providing four parameters can solve the problem, but it's too complicated…
displaying (the basic form)
referenced
Challenge: alternative numbering and spacing, and one-off
supplementcustomization like@intro[Chapter].See Section name should be after section number in reference in Chinese #5102, Proper i18n for figure captions #2485, Option to hide last dot in refs to heading that had custom numbering. #6032, Make function
supplementreturn the number as well #2990.outlined (in table of contents within the document)
Challenge: small font size, compact space.
See Different heading text for outline/bookmark and displaying #1889.
bookmarked (in PDF's outline)
Challenge: plain text.
See Different heading text for outline/bookmark and displaying #1889 (comment), and discussion in Include numbering in PDF bookmark #6622.
other: header/footer, HTML sidebar, screen-reader-only version, etc.
It's too early to consider them now.
Comparisons
displaying ≠ referenced ∧ outlined ≠ referenced ∧ bookmarked ≠ referenced (
一、标题≠第一章)Of course they might be different!
The issue is that there are numerous possibilities for permutations/subsets of
1.1.vs.1.1, or一、vs.一),#h(0.3em),#h(1em), or2em - measure(numbering).width),第{1:一}章),Currently, there is no simple way to customize those forms separately, unless you reconstruct
refcompletely and ignore all tricky things about context, styling, query, etc.displaying ≠ outlined (
1. The case of $2/3$ and \ blah blah blah blah≠1. The case of $2\/3$ and blah)The outlined heading might be shorter. In addition, the number and position of manual
#linebreakin them might differ.In Chinese, for special short headings (such as 译后记 Postscript in the image below), the characters might be arranged loosely, but only when displaying.
It can be achieved in typst 0.13.1, though kind of odd:
displaying ≠ bookmarked ∧ outlined ≠ bookmarked (
1. Considering $2/3$≠1. Considering 2/3)Only plain text is allowed in the bookmarked form.
As a result, math equations, rubies, and special spacings should take a different form.
In typst 0.13.1,
#h(0.3em)and#h(1em)become void when bookmarked, while$2/3$becomes23.The separator between the numbering and content was discussed in #6622:
Serenade600 commentedon Aug 14, 2025
Microsoft's Word, born in 1980s and being the most commonly used editor across China, cannot handle the issue stated in title.
Ikaluk commentedon Nov 22, 2026
Compare this issue, where the default spacing needs to be removed too.
flaribbit/numbly#5
YDX-2147483647 commentedon Nov 25, 2026
With the merge of typst/codex#182 and #7350, is it possible to auto-magically remove the spacing betweeen
一、and汉字?After all, the following code now works as expected to some degree.
Problems:
1. 汉字is still wanted.一、? Should the space be kept?