Hello typst authors and developers!
We recently updated Chinese Layout Gap Analysis (clreq-gap) for Typst to v0.14.0. As introduced before, this is a document describing gaps or shortcomings in typst for the support of the Chinese script, including text layout and bibliography.
🔗 Chinese Layout Gap Analysis for Typst. 分析 Typst 与中文排版的差距。
Typst v0.14.0 changes the way of setting Chinese font in math.
Setting Chinese font is necessary, because the default math font (New Computer Modern Math) does not cover Chinese characters like (定义). Without proper configuration, they will either become tofus □□, or fallback to the Chinese serif font with the shortest name installed on the system (KaiTi for most people).
In v0.13, text handling is math was quite limited, and the way of setting Chinese font actually “depended” on several bugs. Thanks to mkorje and other contributors, the situation has improved significantly in v0.14.0.
$"x"$) and variables ($x$) in math are treated more equally.So the new recommend way to set Chinese font in math is:
1#show math.equation: set text(font: (2 (name: "New Computer Modern Math", covers: "latin-in-cjk"), // Math3 (name: "Source Han Serif SC", covers: regex(".")), // Chinese4 "New Computer Modern Math", // Math5))6$hat(alpha)(f) = f(alpha) "(同上,α–map的“定义”)"$7$ f(alpha) #[或者*任意*内容 _α–map_ $alpha$–map] $8$ cases("Math" 1 I l, "正文 1Il") $
“”.This specific order/repetition/syntax is derived from the following propositions.
covers as the base math font. It has to provide math metrics, otherwise “warning: rendering may be poor”.{ of cases will use the Chinese font, but it does not support being stretched.If you do not use punctuation marks in math, then a simpler solution is as follows.
1#show math.equation: set text(font: (2 "New Computer Modern Math",3 "Noto Serif CJK SC"4))
If you prefer to use different fonts for Latin and math, please refer to 如何修改公式里的中文字体? or use the website Typst set font to generate the code. This website is planned to be moved to Typst Chinese community’s GitHub organization after completion.
Bibliography has always been a painful area. As shown in the summary, it has the most red and orange dots. There are basic demands that lack nice and clean workarounds. Bibliography has the highest degree of automation, but at the cost of increasing the difficulty to tweak subtleties. If Typst does not support something natively, it is really hard to patch it on our own.
The good news is that we are improving it bit by bit, and Typst 0.14.0 has made some leapfrog progress.
The Citation Style Language (CSL) is an XML-based format to describe the formatting of citations, notes and bibliographies. You can use it to customize bibliography.style.
However Typst v0.13.1 did not recognize certain elements in CSL 1.0.2 Specification. For example, when you were trying to use 历史研究.csl, the old Typst would refuse to load it and throw the following scary error:
Failed to load CSL style (unknown variant page, expected one of chapter-number, citation-number, collection-number, edition, first-reference-note-number, issue, locator, number, number-of-pages, number-of-volumes, page-first, part-number, printing, printing-number, section, supplement-number, version, volume)
It is caused by <number variable="page"/> in 历史研究.csl. Even if you don’t actually use this type of citation, it will prevent you from loading the CSL.
Typst v0.14.0 no longer throws that error. According to our survey, all ~300 Chinese CSL styles can now be loaded by new Typst, after removing non-standard elements.
As mentioned in the previous post, the Chinese convention for citation numbers is [1]. In Typst v0.13.1, 1 may fly over [], and the severity depends on the specific configuration.
Typst v0.14.0 fixes the positioning issue of superscripts in #5777, including these [1] created by the cite function. Now both of the examples in the document become sane.
However, that fix triggered another issue about the interaction between superscripts and CJK-Latin spaces (#7113 and w3c/clreq#713). Fortunately, we managed to correct the behaviour before the release deadline.
The national standard for bibliography in China specifies three citation styles: numeric 顺序编码, author-date 著者-出版年, and note/footnote 注释/脚注.
In Typst v0.13.1, footnote styles were totally broken, because Typst didn’t pass correct info to CSL. You may get awkward results like ;;..
Typst v0.14 now corrects it. Those ;;. becomes 同上 (meaning: same as above, ibid.) as expected.
Typst v0.14.0 also fixes a minor issue on text spacing.
The document is written in typst and hosted open source (Apache 2.0).
Thanks to the new Typed HTML API, we deleted 1410 lines when updating to v0.14.
Discussion and contributions are welcomed. You can comment in English or Chinese in that repo, but please use English when replying on the forum (due to forum rules).
Thank you for your attention!
—
This page was originally posted by Y.D.X. on the forum with screenshots. Based on the suggestion of pg999w, I added a paragraph introducing a concise method for setting Chinese font in mathematical equations.