CTeX-org / ctex-kit

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

使用 syntonly 包导致行尾为中文标点时报错 #653

Closed liuzheng closed 1 year ago

liuzheng commented 1 year ago

检查

编译环境

操作系统

macOS Monterey 12.6.3

XeLaTeX 发行版

XeTeX 3.141592653-2.6-0.999994 (TeX Live 2022) kpathsea version 6.3.4 Copyright 2022 SIL International, Jonathan Kew and Khaled Hosny. There is NO warranty. Redistribution of this software is covered by the terms of both the XeTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the XeTeX source. Primary author of XeTeX: Jonathan Kew. Compiled with ICU version 70.1; using 70.1 Compiled with zlib version 1.2.11; using 1.2.11 Compiled with FreeType2 version 2.11.1; using 2.11.1 Compiled with Graphite2 version 1.3.14; using 1.3.14 Compiled with HarfBuzz version 3.4.0; using 3.4.0 Compiled with libpng version 1.6.37; using 1.6.37 Compiled with pplib version v2.05 less toxic i hope Using Mac OS X Core Text and Cocoa frameworks

描述问题

1)使用宏包syntonly 做编译前检查时发现当行尾为中文标点时编译不通过

最小工作示例(MWE)

\documentclass{article}
\usepackage{ctex}

\usepackage{syntonly}
\syntaxonly

\begin{document}
文字,
\end{document}

(用 XeLaTeX 编译后)输出

! Missing number, treated as zero.
<to be read again> 
                   \c__xeCJK_xeCJK/SongtiSCLight(0)/m/n/10.53937/quanjiao/di...
l.8 文字,

? 
muzimuzhi commented 1 year ago

和问题本身无关:你使用 xelatex 编译,但在「TeX 发行版」部分提供了 pdftex 的版本信息。

我不知道具体为什么,不过可以用 \xeCJKsetup{xeCJKactive=false} 整个关掉 xeCJK

liuzheng commented 1 year ago

@muzimuzhi 关掉了编译出来的pdf是乱码,也就是说在做编译检查的时候需要关掉xeCJK?正式编译的时候就不关闭?和想象中的不大一样

muzimuzhi commented 1 year ago

也就是说在做编译检查的时候需要关掉xeCJK?正式编译的时候就不关闭?

是。你把 \xeCJKsetup{xeCJKactive=false} patch 进 \syntaxonly 或者新定义一个命令,包含 \syntaxonly\xeCJKsetup{...},都是一样的。

\syntaxonly 尝试把所有的字体都设成 \nullfont,一方面它没有禁止直接通过 \font 配置字体,另一方面都设成 \nullfont 感觉会让某些功能测不到。开 \syntaxonly 能让你的文档编译快多大比例,是否有必要通过它做「编译检查」(而不是正常编一遍)?我想说 tex 里没有严格定义的编译检查,万一遇到 parse \the\font 结果的逻辑,用了 \syntaxonly 反而会报错……甚至禁止 shipout 也可能影响依赖 \pdflastposx/\pdflastposy 的逻辑。

我的建议是别用 \syntaxonly

liuzheng commented 1 year ago

@muzimuzhi 十分感谢解释,我也是偶然搜到有编译检查,以往的编码经验告诉我这个可能很好用,实际似乎有点不理想