CTeX-org / ctex-kit

Macro Packages and Scripts for Chinese TeX users
965 stars 124 forks source link

zhlineskip.tex 编译失败 #712

Closed SwitWu closed 2 months ago

SwitWu commented 2 months ago

检查清单

操作系统

macOS Sonoma 14.4.1

TeX 发行版

TeX Live 2024

描述问题

系统安装思源宋体、思源黑体以及 M+ 字体后,在启用 \SourceHanSCandMplustrue 的情况下,使用 xelatex 编译 zhlineskip.tex 失败,报错信息为

! Extra }, or forgotten \endgroup.

若不启用 \SourceHanSCandMplustrue,则不会报错。

最小工作示例(MWE)

见上

链接

No response

其他信息

No response

附件

No response

muzimuzhi commented 2 months ago

\SourceHanSCandMplustrue 时会selectfont hook 添加 \xeCJKsetup { xCJKecglue = <glue> },然后在 \maketitle 排版标题(\title{\vspace*{-26bp}\pkg{zhlineskip} 宏包})时,在西文切换到中文时产生报错。

简化后的例子

% !TeX program = xelatex
\documentclass{article}
\usepackage{xeCJK}

\AddToHook{selectfont}{%
  \xeCJKsetup
    { xCJKecglue = {\hskip 0.2em plus 0.1em minus 0.07em\relax} }%
}

\begin{document}
zhlineskip 宏包
\end{document}

这个例子在 Overleaf 的 texlive 2023 里复现报错,在 texlive 2022 里正常通过。

! Too many }'s.
\__xeCJK_boundary_group_end:n ...class_group_end: 
                                                  {\xeCJK_make_node:n {#1}}
muzimuzhi commented 2 months ago

是 a841dab (xeCJK: 简化部分内部实现, 2022-08-04) 导致的,从 xeCJK v3.9.1 开始出现。(Overleaf texlive 2022 里的是 xeCJK v3.8.9。)

muzimuzhi commented 2 months ago

Duplicate of #636

muzimuzhi commented 2 months ago

https://github.com/CTeX-org/ctex-kit/commit/a841dabaac7c2dccacd1858ba96f6eb38adfb335 (xeCJK: 简化部分内部实现, 2022-08-04) 把

\int_compare:nNnTF \tex_lastnodetype:D = { 11 }

封装为

\__xeCJK_if_last_glue:TF

但在替换时,错把两处 \int_compare:nNnT 换成了 \__xeCJK_if_last_glue:TF(应该是 :T,即只有 true 分支)。

其中一处影响 xCJKecglue 选项的使用,已经由 aa5f00d (xeCJK: 修复 xCJKecglue 错误, 2022-08-31) 在代码库中修复,但没有发版。#636 和当前 issue 报告的问题都是由这一处导致的。

第二处影响 \xeCJKnobreak(但我没找到怎么触发它),我刚才提交了 9599832 (xeCJK: 修复 \xeCJKnobreak 错误 (见 #712), 2024-05-03) 修复它。

muzimuzhi commented 2 months ago

使用 xelatex 编译 zhlineskip.tex 失败,

PS: 现在粘贴的是指向 branch HEAD 的文件链接,可以点页面右上角的 Copy Permalink 复制指向某个提交后的文件链接,这样即使未来这个文件修改,pernalink 依然指向你报告问题时的版本。 image

SwitWu commented 2 months ago

OK