Debian Codegraph @

texmf-dist/source/xelatex/xecjk/xeCJK.dtx

raw
1 % \iffalse meta-comment
2 % !TEX program = XeLaTeX
3 %<*internal>
4 \iffalse
5 %</internal>
6 %<*readme>
7 xeCJK
8 =====
9
10 `xeCJK` is a package written for XeLaTeX which allows users to typeset
11 CJK scripts easily.
12
13 - Different default fonts for CJK and other characters.
14 - Spaces automatically ignored between CJK characters.
15 - Special effects on full-width CJK punctuation.
16 - Automatic adjustment of the space between CJK and other characters.
17
18 Contributing
19 ------------
20
21 This package is a part of the [ctex-kit](https://github.com/CTeX-org/ctex-kit) project.
22
23 Issues and pull requests are welcome.
24
25 Copyright and Licence
26 ---------------------
27
28 Copyright (C) 2007--2010 by Wenchang Sun <[email protected]>
29 Copyright (C) 2009--2022 by Leo Liu <[email protected]>
30 Copyright (C) 2012--2022 by Qing Lee <[email protected]>
31 ----------------------------------------------------------------------
32
33 This work may be distributed and/or modified under the
34 conditions of the LaTeX Project Public License, either
35 version 1.3c of this license or (at your option) any later
36 version. This version of this license is in
37 http://www.latex-project.org/lppl/lppl-1-3c.txt
38 and the latest version of this license is in
39 http://www.latex-project.org/lppl.txt
40 and version 1.3 or later is part of all distributions of
41 LaTeX version 2005/12/01 or later.
42
43 This work has the LPPL maintenance status "maintained".
44
45 The Current Maintainers of this work are Leo Liu and Qing Lee.
46
47 This package consists of the files xeCJK.dtx,
48 full-stop.map,
49 fullwidth-stop.map,
50 han-simp.map,
51 han-trad.map,
52 and the derived files xeCJK.pdf,
53 xeCJK.sty,
54 xeCJK.cfg,
55 xeCJK.ins,
56 xeCJKfntef.sty,
57 xeCJK-listings.sty,
58 xunicode-addon.sty,
59 xunicode-extra.def,
60 xeCJK-example-autofake.tex,
61 xeCJK-example-fallback.tex,
62 xeCJK-example-subCJKblock.tex,
63 xeCJK-example-CJKecglue.tex,
64 xeCJK-example-checksingle.tex,
65 xeCJK-example-CJKfntef.tex,
66 xeCJK-example-punctstyle.tex,
67 xeCJK-example-verbatim.tex,
68 xeCJK-example-CM.tex,
69 xeCJK-example-listings.tex,
70 xeCJK-example-mathblock.tex,
71 xunicode-symbols.tex,
72 xunicode-commands.tex,
73 xunicode-combine-marks.tex,
74 xunicode-symbols.pdf,
75 full-stop.tec,
76 fullwidth-stop.tec,
77 han-simp.tec,
78 han-trad.tec, and
79 README.md (this file).
80 %</readme>
81 %<*internal>
82 \fi
83 \begingroup
84 \def\temp{LaTeX2e}
85 \expandafter\endgroup\ifx\temp\fmtname\else
86 \csname fi\endcsname
87 %</internal>
88 %<*install>
89
90 \input ctxdocstrip %
91
92 \preamble
93
94 Copyright (C) 2007--2010 by Wenchang Sun <[email protected]>
95 Copyright (C) 2009--2022 by Leo Liu <[email protected]>
96 Copyright (C) 2012--2022 by Qing Lee <[email protected]>
97 ----------------------------------------------------------------------
98
99 This work may be distributed and/or modified under the
100 conditions of the LaTeX Project Public License, either
101 version 1.3c of this license or (at your option) any later
102 version. This version of this license is in
103 http://www.latex-project.org/lppl/lppl-1-3c.txt
104 and the latest version of this license is in
105 http://www.latex-project.org/lppl.txt
106 and version 1.3 or later is part of all distributions of
107 LaTeX version 2005/12/01 or later.
108
109 This work has the LPPL maintenance status "maintained".
110
111 The Current Maintainers of this work are Leo Liu and Qing Lee.
112
113 ----------------------------------------------------------------------
114
115 \endpreamble
116 \postamble
117
118 This package consists of the files xeCJK.dtx,
119 full-stop.map,
120 fullwidth-stop.map,
121 han-simp.map,
122 han-trad.map,
123 and the derived files xeCJK.pdf,
124 xeCJK.sty,
125 xeCJK.cfg,
126 xeCJK.ins,
127 xeCJKfntef.sty,
128 xeCJK-listings.sty,
129 xunicode-addon.sty,
130 xunicode-extra.def,
131 xeCJK-example-autofake.tex,
132 xeCJK-example-fallback.tex,
133 xeCJK-example-subCJKblock.tex,
134 xeCJK-example-CJKecglue.tex,
135 xeCJK-example-checksingle.tex,
136 xeCJK-example-CJKfntef.tex,
137 xeCJK-example-punctstyle.tex,
138 xeCJK-example-verbatim.tex,
139 xeCJK-example-CM.tex,
140 xeCJK-example-listings.tex,
141 xeCJK-example-mathblock.tex,
142 xunicode-symbols.tex,
143 xunicode-commands.tex,
144 xunicode-combine-marks.tex,
145 xunicode-symbols.pdf,
146 full-stop.tec,
147 fullwidth-stop.tec,
148 han-simp.tec,
149 han-trad.tec, and
150 README.md.
151 \endpostamble
152
153 \generate
154 {
155 %</install>
156 %<*internal>
157 \usedir{source/xelatex/xecjk}
158 \file{xeCJK.ins} {\from{\jobname.dtx}{install}}
159 %</internal>
160 %<*install>
161 \usedir{tex/xelatex/xecjk}
162 \file{xeCJK.sty} {\from{\jobname.dtx}{package}}
163 \file{xeCJKfntef.sty} {\from{\jobname.dtx}{fntef}}
164 \file{xeCJK-listings.sty} {\from{\jobname.dtx}{listings}}
165 \file{xunicode-addon.sty} {\from{\jobname.dtx}{xunicode}}
166 \file{xunicode-extra.def} {\from{\jobname.dtx}{xunextra}}
167 \usepreamble\emptypreamble
168 \usepostamble\emptypostamble
169 \usedir{tex/xelatex/xecjk/config}
170 \file{xeCJK.cfg} {\from{\jobname.dtx}{config}}
171 \usedir{doc/xelatex/xecjk/example}
172 \file{xeCJK-example-autofake.tex} {\from{\jobname.dtx}{ex-autofake}}
173 \file{xeCJK-example-fallback.tex} {\from{\jobname.dtx}{ex-fallback}}
174 \file{xeCJK-example-subCJKblock.tex} {\from{\jobname.dtx}{ex-block}}
175 \file{xeCJK-example-CJKecglue.tex} {\from{\jobname.dtx}{ex-ecglue}}
176 \file{xeCJK-example-checksingle.tex} {\from{\jobname.dtx}{ex-single}}
177 \file{xeCJK-example-CJKfntef.tex} {\from{\jobname.dtx}{ex-fntef}}
178 \file{xeCJK-example-punctstyle.tex} {\from{\jobname.dtx}{ex-punctstyle}}
179 \file{xeCJK-example-verbatim.tex} {\from{\jobname.dtx}{ex-verb}}
180 \file{xeCJK-example-CM.tex} {\from{\jobname.dtx}{ex-cm}}
181 \file{xeCJK-example-listings.tex} {\from{\jobname.dtx}{ex-listings}}
182 \file{xeCJK-example-mathblock.tex} {\from{\jobname.dtx}{ex-mathblock}}
183 \file{xunicode-symbols.tex} {\from{\jobname.dtx}{xunicode-symbols}}
184 \nopreamble\nopostamble
185 \usedir{doc/xelatex/xecjk}
186 \file{README.md} {\from{\jobname.dtx}{readme}}
187 }
188
189 \endbatchfile
190 %</install>
191 %<*internal>
192 \fi
193 %</internal>
194 %<*package|config|fntef|listings|xunicode|xunextra>
195 %<!(config|xunextra)>\NeedsTeXFormat{LaTeX2e}
196 %<!(config|xunextra)>\RequirePackage{expl3}
197 %<+!driver>\GetIdInfo$Id: xeCJK.dtx c4ccfae 2022-08-05 21:02:32 +0800 Qing Lee <[email protected]> $
198 %<package> {Typesetting CJK scripts with XeLaTeX}
199 %<config> {Configuration file for xeCJK package}
200 %<fntef> {xeCJK font effect}
201 %<listings> {xeCJK patch file for listings}
202 %<xunicode> {addon file for xunicode}
203 %<xunextra> {extra definition for xunicode}
204 %<package>\ProvidesExplPackage{\ExplFileName}
205 %<config>\ProvidesExplFile{\ExplFileName.cfg}
206 %<fntef>\ProvidesExplPackage{xeCJKfntef}
207 %<listings>\ProvidesExplPackage{xeCJK-listings}
208 %<xunicode>\ProvidesExplPackage{xunicode-addon}
209 %<xunextra>\ProvidesExplFile{xunicode-extra.def}
210 %<!driver> {\ExplFileDate}{3.9.1}{\ExplFileDescription}
211 %</package|config|fntef|listings|xunicode|xunextra>
212 %<*driver>
213 \documentclass{ctxdoc}
214 \usepackage{xeCJKfntef}
215 \xeCJKDeclareSubCJKBlock{SP} { "2E3A , "301C , "30A0 , "FF65 }
216 \xeCJKDeclareSubCJKBlock{Ext-B} { "20000 -> "2A6DF }
217 \xeCJKDeclareSubCJKBlock{Hangul}
218 { "1100 -> "11FF, "3130 -> "318F, "A960 -> "A97F, "AC00 -> "D7AF }
219 \setCJKmainfont[SP, Language=Chinese Simplified]{Source Han Serif SC}
220 \setCJKmainfont[Ext-B]{SimSun-ExtB}
221 \setCJKmainfont[Hangul, Script=Hangul, Language=Korean]{Source Han Serif K}
222 \newlist{psopt}{description}{3}
223 \setlist[psopt]{%
224 font=\mdseries\ttfamily, align=right,
225 labelsep=.5em, leftmargin=4.5em, labelindent=0pt}
226 \newcommand\PSKeyVal[2]{%
227 \item[#1]\makebox[4em][l]{\meta{#2}}\ignorespaces}
228 \newcommand\tokslink[1]{\hyperlink{#1}{\ding{51}}}
229 \newcommand\ghissue[1]{%
230 \href{https://github.com/CTeX-org/ctex-kit/issues/#1}{\##1}}
231 \AtBeginDocument{\DeleteShortVerb{\"}}
232 \ExplSyntaxOn
233 \NewDocumentCommand \PrintPunctList { O{7} m m }
234 {
235 \par
236 \begingroup
237 \CJKfontspec[Language=Chinese ~ Simplified]{Source ~ Han ~ Serif ~ SC}
238 \tl_clear:N \l_tmpa_tl
239 \int_zero:N \l_tmpa_int
240 \tl_set:Nx \l_tmpb_tl { \tl_to_str:n { c__xeCJK_#2_chars_clist } }
241 \int_set:Nn \l_tmpb_int { \clist_count:c { \l_tmpb_tl } }
242 \clist_map_inline:cn { \l_tmpb_tl }
243 {
244 \int_incr:N \l_tmpa_int
245 \tl_put_right:Nx \l_tmpa_tl
246 {
247 \use_none:n ##1 & \tex_char:D ##1 \scan_stop:
248 \int_compare:nNnF \l_tmpa_int = \l_tmpb_int
249 {
250 \int_compare:nNnTF { \int_mod:nn \l_tmpa_int {#1} } = \c_zero_int
251 { \exp_not:N \\ \scan_stop: } { & }
252 }
253 }
254 }
255 \noindent\hfill\linespread{1}\selectfont
256 \begin{tabular}{|*{#1}{>{\footnotesize\ttfamily U+}c|c|}}
257 \tl_use:N \l_tmpa_tl
258 \end{tabular}\hfill\null
259 \endgroup
260 \par
261 }
262 \ExplSyntaxOff
263 \begin{document}
264 \DocInput{\jobname.dtx}
265 \IndexLayout
266 \PrintChanges
267 \PrintIndex
268 \end{document}
269 %</driver>
270 % \fi
271 %
272 % \changes{v3.1.0}{2012/11/13}{放弃对 \tn{outer} 宏的特殊处理。}
273 % \changes{v3.1.1}{2012/12/07}{不再依赖 \pkg{xpatch} 宏包。}
274 % \changes{v3.2.2}{2013/06/01}{修正某些重音不能正确显示的问题。}
275 % \changes{v3.2.3}{2013/06/07}{提供四个 TECkit 映射文件用于句号转换和简繁互换。}
276 % \changes{v3.2.4}{2013/07/02}{遵循 \LaTeXiii{} 变量需要预先声明的原则。}
277 % \changes{v3.2.6}{2013/07/29}{\texttt{case} 类函数的用法与 \LaTeXiii{} 同步。}
278 % \changes{v3.3.2}{2015/05/15}{随 Unicode 7.0.0 更新简繁汉字映射。}
279 % \changes{v3.3.3}{2015/09/25}{更新 \LaTeXiii{} 代码。}
280 % \changes{v3.5.0}{2017/07/19}{常数 \cs{c_minus_one} 已过时。}
281 % \changes{v3.5.0}{2017/07/22}{使用 \texttt{lazy} 函数对 Boolean 表达式
282 % 进行最小化运算(\LaTeXiii{} 2017/07/19)。}
283 % \changes{v3.6.0}{2018/01/13}{同步 \LaTeXiii{} 2017/12/16。}
284 % \changes{v3.6.1}{2018/02/27}{减少 \texttt{bool} 运算。}
285 % \changes{v3.7.2}{2019/03/23}{同步 \LaTeXiii{} 2019/03/05。}
286 % \changes{v3.8.0}{2020/02/09}{兼容 \LaTeXe\ 2020/02/02 对 \pkg{NFSS} 的修改。}
287 % \changes{v3.8.0}{2020/02/09}{清理过时的兼容性补丁代码。}
288 % \changes{v3.8.3}{2020/04/07}{删除 \texttt{\_nopar}。}
289 %
290 % \CheckSum{11032}
291 % \GetFileId{xeCJK.sty}
292 %
293 % \title{\bfseries\pkg{xeCJK} 宏包}
294 % \author{\href{http://www.ctex.org}{CTEX.ORG}}
295 % \date{\filedate\qquad\fileversion\thanks{\ctexkitrev{\ExplFileVersion}.}}
296 % \maketitle
297 %
298 % \tableofcontents
299 % \vspace{\baselineskip}
300 %
301 % \begin{documentation}
302 %
303 % \section{简介}
304 %
305 % \pkg{xeCJK} 是一个 \XeLaTeX 宏包,用于排版中日韩(CJK)文字。主要功能:
306 % \begin{enumerate}
307 % \item 分别设置 CJK 和英文字体;
308 % \item 自动忽略 CJK 文字间的空格而保留其他空格,允许在非标点汉字和英文
309 % 字母 (a -- z, A -- Z) 间断行;
310 % \item 提供多种标点处理方式: 全角式、半角式、开明式、行末半角式和 CCT 式;
311 % \item 自动调整中英文间空白。
312 % \end{enumerate}
313 %
314 % \pkg{xeCJK} 使用了 \XeTeX 的一些最新特性,需要 \XeTeX{} 0.9995.0 (2009/06/29) 以
315 % 后的版本。\pkg{xeCJK} 依赖 \LaTeXiii{} 项目的宏包套件
316 % \package{l3kernel} 和 \package{l3packages}。
317 % \pkg{xeCJK} 还需要通过 \package{fontspec} 宏包来调用系统字体。
318 % \pkg{xeCJK} 会自动根据需要载入这些宏包。
319 %
320 % \pkg{xeCJK} 的原始作者是孙文昌,2009 年 5 月起宏包被收入 \ctexkit\ 项目进行
321 % 维护,目前主要维护者是刘海洋\footnote{\email{[email protected]}} 和
322 % 李清\footnote{\email{[email protected]}}。
323 %
324 % \section{基本用法}
325 %
326 % 与其他 \LaTeX{} 宏包一样,引入 \pkg{xeCJK} 宏包只要在导言区使用
327 % \begin{frameverb}
328 % \usepackage{xeCJK}
329 % \end{frameverb}
330 % 在引入 \pkg{xeCJK} 宏包之后,只要设置 CJK 文字的字体,就可以在文档中使用中日
331 % 韩文字了。
332 %
333 % 可以在各种文档类中使用 \pkg{xeCJK} 宏包,最简单的示例是:
334 % \begin{ctexexam}
335 % \documentclass{article}
336 % \usepackage{xeCJK}
337 % \setCJKmainfont{SimSun}
338 %
339 % \begin{document}
340 % 中文 \LaTeX 示例。
341 % \end{document}
342 % \end{ctexexam}
343 % 上述示例设置了中文字体 SimSun(宋体)。运行此示例要求系统安装了设置的字体,
344 % 源文件用 UTF-8 编码保存,使用 \XeLaTeX{} 编译。
345 %
346 % \pkg{xeCJK} 只提供了字体和标点控制等基本 CJK 语言支持。对于中文文档,可以使
347 % 用更为高层的 \package{ctex} 宏包或文档类,它将自动调用 \pkg{xeCJK} 并设置好中文
348 % 字体,同时提供了进一步的本地化支持。详细内容参看 \package{ctex} 宏包套件的说明。
349 %
350 % \pkg{xeCJK} 提供了大量选项,可以在宏包调用时作为宏包选项或用 \tn{xeCJKsetup}
351 % 命令进行设置,详见 \ref{subsec:opts}~节。除了 \tn{setCJKmainfont} 命令,
352 % \pkg{xeCJK} 还提供了许多其他命令设置和选择中文字体,详见
353 % \ref{subsec:fontset}~节。其他更详细的功能也都将在下面详细说明。在本文档所在的
354 % 文件夹的 |example| 目录下面也有一些例子可以参考。
355 %
356 % \section{用户手册}
357 %
358 % \subsection{宏包选项}
359 % \label{subsec:opts}
360 %
361 % \pkg{xeCJK} 以 \meta{key}|=|\meta{var} 的形式提供宏包选项,你可以在调用宏包
362 % 的时候直接设置这些选项,也可以在调用宏包之后使用 \tn{xeCJKsetup} 来设置这些选
363 % 项。\pkg{xeCJK} 内部调用 \pkg{fontspec} 宏包,可以在调用 \pkg{xeCJK} 的时候,
364 % 使用它的宏包选项。\pkg{xeCJK} 会将 \pkg{fontspec} 的选项传递给它。
365 %
366 % \begin{function}{\xeCJKsetup}
367 % \begin{syntax}
368 % \tn{xeCJKsetup} \{\meta{key_1}=\meta{val_1}, \meta{key_2}=\meta{val_2}, ...\}
369 % \end{syntax}
370 % 其中 \meta{key_1}, \meta{key_2} 是设置选项,而 \meta{val_1}, \meta{val_2} 则是对应选项的
371 % 设置内容。多个选项可以在一个语句中完成设置。例如
372 % \begin{ctexexam}
373 % \usepackage[PunctStyle=kaiming]{xeCJK}
374 % \end{ctexexam}
375 % 等价于
376 % \begin{ctexexam}
377 % \usepackage{xeCJK}
378 % ......
379 % \xeCJKsetup{PunctStyle=kaiming}
380 % \end{ctexexam}
381 % \end{function}
382 %
383 % 带有 \exptarget\expstar{} 或者 \rexptarget\rexpstar{} 标记的选项或命令
384 % 只能在导言区中使用,其中 \rexptarget\rexpstar{} 还表示这个选项或命令只
385 % 影响随后定义的 CJK 字体。其余不带特殊标记的选项或命令,如果没有特别说明,
386 % 则可以在导言区或正文中使用。\textbf{粗体}表示 \pkg{xeCJK} 的默认设置。
387 %
388 % \begin{function}[EXP,added=2012-11-22]{LocalConfig}
389 % \begin{syntax}
390 % LocalConfig = \Arg{\TTF|name}
391 % \end{syntax}
392 % 是否使用本地配置文件 \texttt{xeCJK-\meta{name}.cfg}。\meta{name} 可以是不包含
393 % 空格的任意使文件名合法的字符串。如果设置为 |true|,则使用的是 \texttt{xeCJK.cfg};
394 % 设置为 |false| 则不载入配置文件。可以把将要在下文介绍到的对 \pkg{xeCJK} 的一些
395 % 设置(例如设置常用 CJK 字体、修改字符范围和定义新的标点输出格式等)保存到文件
396 % \texttt{xeCJK-\meta{name}.cfg}。然后把这个文件放在本地的 |TDS| 目录下的适当
397 % 位置。使用 \TeX~Live 的用户,可以新建下列目录,然后再把
398 % \texttt{xeCJK-\meta{name}.cfg} 放在里面:
399 % \begin{frameverb}
400 % texlive/texmf-local/tex/xelatex/xecjk
401 % \end{frameverb}
402 % 最后还需要在命令行下执行 |mktexlsr|,刷新文件名数据库以便 \TeX 系统能够找到它。
403 % \end{function}
404 %
405 % 请注意,\pkg{xeCJK} 宏包中只有上述 |LocalConfig| 选项需要在调用 \pkg{xeCJK} 时
406 % 设置,而不能通过 \tn{xeCJKsetup} 来设置。
407 %
408 % \begin{function}{xeCJKactive}
409 % \begin{syntax}
410 % xeCJKactive = \meta{\TTF}
411 % \end{syntax}
412 % 打开/关闭对中文的特殊处理。事实上,这个选项会打开/关闭 \XeTeX 的整个字符类机制,依赖
413 % 这个机制的宏包都会受到影响。
414 % \end{function}
415 %
416 % \begin{function}{CJKspace}
417 % \begin{syntax}
418 % CJKspace = \meta{\TFF}
419 % \end{syntax}
420 % 缺省状态下,\pkg{xeCJK} 会忽略 CJK 文字之间的空格,使用这一选项来保留它们之间的空格。
421 % \end{function}
422 %
423 % \begin{function}[EXP,updated=2016-05-04]{CJKmath}
424 % \begin{syntax}
425 % CJKmath = \meta{\TFF}
426 % \end{syntax}
427 % 是否支持在数学环境中直接输入 CJK 字符。使用这个选项后,可以直接在数学环境中
428 % 输出 CJK 字符。\pkg{url} 宏包将一个 URL 放在一个特殊的数学环境中排版,所以如果在
429 % \tn{path} 等命令的路径参数中含有汉字,则需要启用这个选项,路径中的汉字才能显示。
430 % \end{function}
431 %
432 % \begin{function}{CJKglue}
433 % \begin{syntax}
434 % CJKglue = \{\tn{hskip} 0pt plus 0.08\tn{baselineskip}\}
435 % \end{syntax}
436 % 设置 CJK 文字之间插入的 |glue|,上边是 \pkg{xeCJK} 的默认值。一般来说,除非有
437 % 特殊需要(例如,改变文字间距等),否则不需要设置这个选项,使用默认值即可。如果要设置
438 % 这个选项,为了行末的对齐,设置的 |glue| 最好有一定的弹性。
439 % \end{function}
440 %
441 % \begin{function}{CJKecglue}
442 % \begin{syntax}
443 % CJKecglue = \Arg{glue}
444 % \end{syntax}
445 % 设置 CJK 文字与西文、CJK 文字与行内数学公式之间的间距,默认值是一个空格。使用这个
446 % 选项设置的 \meta{glue} 最好也要用一定的弹性。请注意,这里设置的 \meta{glue} 只影响
447 % \pkg{xeCJK} 根据需要自动添加的空白,源文件中直接输入的 CJK 文字与西文之间的空格不
448 % 受影响(直接输出)。有时候 \pkg{xeCJK} 可能不能正确地调整间距,需要手动加空格。
449 % \end{function}
450 %
451 % \begin{function}{xCJKecglue}
452 % \begin{syntax}
453 % xCJKecglue = \Arg{\TFF|glue}
454 % \end{syntax}
455 % 缺省状态下,\pkg{xeCJK} 不对源文件中直接输入的 CJK 文字与西文之间的空格进行调整,如
456 % 果需要调整,请使用这个选项。如果使用这个选项,将使用 |CJKecglue| 替换源文件中直接输
457 % 入的 CJK 文字与西文之间的空格。
458 % \end{function}
459 %
460 % \begin{function}[updated=2013-06-26]{CheckSingle}
461 % \begin{syntax}
462 % CheckSingle = \meta{\TFF}
463 % \end{syntax}
464 % 是否避免单个 CJK 文字单独占一个段落的最后一行。需要说明的是,这个选项只有在
465 % 段末的最后一个字是 CJK 文字或者标点符号,并且倒数第二和第三个字都是文字才能
466 % 正确处理处理孤字的问题。如果这倒数三个字有作为控制序列的参数的情况,那么一般
467 % 来说也不能正确处理。
468 % \end{function}
469 %
470 % \begin{function}[added=2015-04-08]{WidowPenalty}
471 % \begin{syntax}
472 % WidowPenalty = \Arg{penalty|(10000)}
473 % \end{syntax}
474 % 使用 \texttt{CheckSingle} 选项后,设置段末三个汉字之间的 penalty。
475 % 初始值为 \num{10000},即禁止在它们之间折行。
476 % \end{function}
477 %
478 % \begin{function}[added=2012-12-06]{PlainEquation}
479 % \begin{syntax}
480 % PlainEquation = \meta{\TFF}
481 % \end{syntax}
482 % 如果使用了 |$$...$$| 的形式来输入行间数学公式,就需要启用本选项,以便
483 % |CheckSingle| 选项能够正确识别。推荐使用 |\[...\]| 的形式来输入行间数学公式。
484 % \end{function}
485 %
486 % \begin{function}[added=2012-12-04]{NewLineCS,NewLineCS+,NewLineCS-}
487 % \begin{syntax}
488 % NewLineCS = \{ \tn{par} \tn{[} \}
489 % \end{syntax}
490 % 设置造成断行的控制序列,以便 |CheckSingle| 选项能够正确识别。
491 % 以上是 \pkg{xeCJK} 的初始设置。
492 % \end{function}
493 %
494 % \begin{function}[added=2012-12-04]{EnvCS,EnvCS+,EnvCS-}
495 % \begin{syntax}
496 % EnvCS = \{ \tn{begin} \tn{end} \}
497 % \end{syntax}
498 % 设置 \LaTeX 环境开始和结束的控制序列,以便 |CheckSingle| 选项能够正确识别。
499 % 以上是 \pkg{xeCJK} 的初始设置。
500 % \end{function}
501 %
502 % \begin{function}[updated=2012-12-06]{InlineEnv,InlineEnv+,InlineEnv-}
503 % \begin{syntax}
504 % InlineEnv = \{\meta{env_1}, \meta{env_2}, \meta{env_3}, ...\}
505 % \end{syntax}
506 % 在使用 |CheckSingle| 选项的时候,\pkg{xeCJK} 会将 CJK 文字后接着的 \LaTeX 环境的
507 % 开始 |\begin{...}| 和结束 |\end{...}| 视为断行的地方,如果有某些特殊
508 % 的 \LaTeX 环境没有造成断行,可以使用这个选项来声明它,以便 |CheckSingle| 能正确识别。
509 % \end{function}
510 %
511 % \begin{function}{AutoFallBack}
512 % \begin{syntax}
513 % AutoFallBack = \meta{\TFF}
514 % \end{syntax}
515 % 当文档中有个别生僻字时,可以使用这个选项,自动使用预先设置好的后备字体来输出这些生僻
516 % 字。后备字体的设置方法将在 \ref{subsec:fontset} 节中介绍。
517 % \end{function}
518 %
519 % \begin{function}[rEXP]{AutoFakeBold}
520 % \begin{syntax}
521 % AutoFakeBold = \Arg{\TFF|数字}
522 % \end{syntax}
523 % 全局设定当没有声明对应的粗体时,是否使用^^A
524 % \textbf{\CJKfontspec[AutoFakeBold]{FandolSong-Regular.otf}伪粗体};
525 % 当输入的是数字时,将使用伪粗体,并将使用输入的数字作为伪粗体的默认粗细程度。
526 % \end{function}
527 %
528 % \begin{function}[rEXP]{AutoFakeSlant}
529 % \begin{syntax}
530 % AutoFakeSlant = \Arg{\TFF|数字}
531 % \end{syntax}
532 % 全局设定当没有声明对应的斜体时,是否使用^^A
533 % \textit{\CJKfontspec[AutoFakeSlant]{FandolSong-Regular.otf}伪斜体};
534 % 当输入的是数字时,将使用伪斜体,并将使用输入的数字作为伪斜体的默认倾斜程度。
535 % 倾斜程度的取值范围是 $[-0.999, 0.999]$。
536 % \end{function}
537 %
538 % \begin{function}[rEXP]{EmboldenFactor}
539 % \begin{syntax}
540 % EmboldenFactor = \Arg{数字|(4)}
541 % \end{syntax}
542 % 设置伪粗体的默认粗细程度。
543 % \end{function}
544 %
545 % \begin{function}[rEXP]{SlantFactor}
546 % \begin{syntax}
547 % SlantFactor = \Arg{数字|(0.167)}
548 % \end{syntax}
549 % 设置伪斜体的倾斜程度,范围是 $[-0.999, 0.999]$。
550 % \end{function}
551 %
552 % \begin{function}[updated=2012-11-10]{PunctStyle}
553 % \begin{syntax}
554 % PunctStyle = \Arg{(quanjiao)|banjiao|kaiming|hangmobanjiao|CCT|plain|...}
555 % \end{syntax}
556 % 设置标点处理格式。\pkg{xeCJK} 中预先定义好的格式为
557 % \begin{optdesc}
558 % \item[quanjiao] 全角式:所有标点占一个汉字宽度,相邻两个标点占 1.5 汉字宽度;
559 % \item[banjiao] 半角式:所有标点占半个汉字宽度;
560 % \item[kaiming] 开明式:句末点号用全角,其他半角;
561 % \item[hangmobanjiao] 行末半角式:所有标点占一个汉字宽度,行首行末对齐;
562 % \item[CCT] CCT 格式:所有标点符号的宽度略小于一个汉字宽度;
563 % \item[plain] 原样(不调整标点间距)。
564 % \end{optdesc}
565 % 可以使用 \ref{subsec:punctstyle} 中介绍的 \tn{xeCJKDeclarePunctStyle} 定义新的标点
566 % 格式。
567 % \end{function}
568 %
569 % \begin{function}[added=2018-01-24]{PunctFamily}
570 % \begin{syntax}
571 % PunctFamily = \Arg{(false)|family}
572 % \end{syntax}
573 % 默认情况下,CJK 标点符号的字体与 CJK 正文一致,\opt{PunctFamily} 用于单独对标点符号设置字体。
574 % \meta{family} 需要使用随后说明的 \tn{setCJKfamilyfont} 或 \tn{newCJKfontfamily}
575 % 预先定义。\opt{false} 表示取消本选项的作用,让标点符号字体与正文一致。
576 % \end{function}
577 %
578 % \begin{function}[EXP]{KaiMingPunct,KaiMingPunct+,KaiMingPunct-}
579 % \begin{syntax}
580 % KaiMingPunct = \Arg{( . 。? !)}
581 % \end{syntax}
582 % 设置开明(|kaiming|)标点处理格式时的句末点号,|KaiMingPunct| 后带的 |+| 与 |-|
583 % 分别表示从已有的开明句末点号中增加或减少标点。
584 % \end{function}
585 %
586 % \begin{function}[EXP]{LongPunct,LongPunct+,LongPunct-}
587 % \begin{syntax}
588 % LongPunct = \Arg{( — ⸺ ‥ … )}
589 % \end{syntax}
590 % 设置长标点,例如破折号“——”与省略号“……”,允许在长标点前后
591 % 断行,但是禁止在它们之间断行。
592 % \end{function}
593 %
594 % \begin{function}[EXP]{MiddlePunct,MiddlePunct+,MiddlePunct-}
595 % \begin{syntax}
596 % MiddlePunct = \Arg{( – — ⸺ · · ・ 〜゠~)}
597 % \end{syntax}
598 % 设置居中显示的标点,例如间隔号“\textbf{·}”。对于在 CJK 文字之间的居中标点,
599 % \pkg{xeCJK} 会根据不同的标点处理格式,调整居中标点与前后文字之间的空白,保证
600 % 其确实居中。对于行末出现的居中标点,允许在其后面断行,但禁止在它前面断行。
601 % \end{function}
602 %
603 % \begin{function}[EXP]{PunctWidth}
604 % \begin{syntax}
605 % PunctWidth = \Arg{length}
606 % \end{syntax}
607 % 缺省状态下,\pkg{xeCJK} 会根据所选择的标点处理格式自动计算标点所占的宽度,如果对缺
608 % 省设置不满意,可以通过这一选项来改变它。为了使得标点所占的宽度能够适应字体大小的变化,
609 % 这里设置的 |length| 的单位最好用 |em| 等相对距离单位,而不建议使用诸如 |pt| 之类的
610 % 绝对距离单位。这里的设置可用于除了 |plain| 以外的所有标点处理格式。同时,这里的
611 % 设置对所有的 CJK 标点都生效,如果只要设置部分标点,请使用 \ref{subsec:punct}~节的
612 % \tn{xeCJKsetwidth}。
613 % \end{function}
614 %
615 % \begin{function}[EXP,added=2013-08-22]{PunctBoundWidth}
616 % \begin{syntax}
617 % PunctBoundWidth = \Arg{length}
618 % \end{syntax}
619 % 与以上选项类似,但设置的是标点符号出现在行首/尾时的宽度。
620 % \end{function}
621 %
622 % \begin{function}{AllowBreakBetweenPuncts}
623 % \begin{syntax}
624 % AllowBreakBetweenPuncts = \meta{\TFF}
625 % \end{syntax}
626 % 缺省状态下,\pkg{xeCJK} 禁止在相邻 CJK 右标点和 CJK 左标点之间换行,可以使用
627 % 这一选项改变这一设置。
628 % \end{function}
629 %
630 % \begin{function}[updated=2016-05-13]{RubberPunctSkip}
631 % \begin{syntax}
632 % RubberPunctSkip = \meta{\TTF|plus|minus}
633 % \end{syntax}
634 % 缺省状态下,标点符号前/后的间距有一定的弹性。可以伸长到原始边界宽度,可以收缩到
635 % 标点另一侧的边界宽度。将本选项设置为 \texttt{plus},将只允许伸长;设置为
636 % \texttt{minus} 只允许收缩。设置为 \texttt{false} 将禁用这一特性,
637 % 从而使得前/后的间距为固定值。
638 % \end{function}
639 %
640 % \begin{function}[added=2012-12-02]{CheckFullRight}
641 % \begin{syntax}
642 % CheckFullRight = \meta{\TFF}
643 % \end{syntax}
644 % 某些控制序列要求不能在它的前面断行。但是在缺省状态下,单个全角右标点的后面总是
645 % 可以断行的。因此当这些控制序列出现在全角右标点后面时,可能会出现意料之外的断行。
646 % 此时可以使用这个选项来避免这个情况。
647 % \end{function}
648 %
649 % \begin{function}[added=2012-12-02]{NoBreakCS,NoBreakCS+,NoBreakCS-}
650 % \begin{syntax}
651 % NoBreakCS = \{ \tn{footnote} \tn{footnotemark} \tn{nobreak} \}
652 % \end{syntax}
653 % 设置不能在全角右标点后断行的控制序列。以上是 \pkg{xeCJK} 的默认设置。如果这些
654 % 控制序列在文档中只出现少量几次,也可以不必使用 |CheckFullRight| 选项,而是手工
655 % 在这些控制序列前面加上 \ref{subsec:others}~节介绍的 \tn{xeCJKnobreak}。
656 % \end{function}
657 %
658 % \begin{function}[updated=2013-11-16]{Verb}
659 % \begin{syntax}
660 % Verb = \meta{\TF|(env)|env+}
661 % \end{syntax}
662 % \texttt{true} 表示在 \tn{verb} 命令或 \texttt{verbatim} 环境里不自动调整中英文
663 % 之间的间距。\texttt{env} 选项在 \texttt{verbatim} 环境里自动计算中西文间距和中文
664 % 之间的间距,以便于保持代码的对齐;\texttt{env} 选项不调整 \tn{verb} 里的间距,^^A
665 % \texttt{env+} 选项还将正文里设置的间距应用到 \tn{verb} 里。^^A
666 % 这个选项对使用到 \tn{verbatim@font} 命令的情形均有效,更一般的情况可以使用
667 % \ref{subsec:others}~节介绍的 \tn{xeCJKVerbAddon}。\texttt{false} 表示不作任何
668 % 处理。以上选项的值除 \texttt{false} 外,都禁止在汉字之间和汉字与西文之间自动换行。
669 % \end{function}
670 %
671 % \begin{function}[rEXP,added=2014-03-01]{LoadFandol}
672 % \begin{syntax}
673 % LoadFandol = \meta{\TTF}
674 % \end{syntax}
675 % 当没有在导言区设置 CJK 字体时,是否使用 Fandol 字体。如果启用这个选项,需要
676 % 安装 \package{Fandol} 字体系列。
677 % \end{function}
678 %
679 % \subsection{字体设置与选择}
680 % \label{subsec:fontset}
681 %
682 % \begin{function}[EXP,updated=2016-11-18]{\setCJKmainfont}
683 % \begin{syntax}
684 % \tn{setCJKmainfont} \Arg{font name}\oarg{font features} 或\\
685 % \tn{setCJKmainfont} \oarg{font features} \Arg{font name}
686 % \end{syntax}
687 % 设置正文罗马族的 CJK 字体,影响 \tn{rmfamily} 和 \tn{textrm} 的字体。后面两个
688 % 参数继承自 \pkg{fontspec} 宏包, \meta{font features} 表示字体属性选项,
689 % \meta{font name} 是字体名。字体名可以是字体族名,也可以是字体的文件名,查
690 % 找字体名见 \ref{subsubsec:fontsearch}~节;可用的字体属性选项参见
691 % \pkg{fontspec} 宏包的文档。需要说明的是 \pkg{xeCJK} 修改了 |AutoFakeBold|
692 % 和 |AutoFakeSlant| 选项,以便配合全局伪粗体和伪斜体的设定。
693 %
694 % 出于兼容性考虑,字体属性可选项可以放在字体名称前面,也可以放在后面。
695 % 如果可选项放在后面,字体名称与可选项之间不要有空格或者换行。
696 % \end{function}
697 %
698 % \begin{function}[label = ]{AutoFakeBold,AutoFakeSlant}
699 % \begin{syntax}
700 % AutoFakeBold = \Arg{\TF|数字}
701 % AutoFakeSlant = \Arg{\TF|数字}
702 % \end{syntax}
703 % 局部设置当前字体族的伪粗和伪斜属性。如果没有在局部给出这些选项,将使用全局设定。
704 % \end{function}
705 %
706 % \begin{function}[added=2013-06-07]{Mapping}
707 % \begin{syntax}
708 % Mapping = \Arg{fullwidth-stop|full-stop|han-trad|han-simp|...}
709 % \end{syntax}
710 % \pkg{xeCJK} 提供了以上四个 \href{http://scripts.sil.org/teckit}{TECKit} 映射
711 % 文件,可以在设置字体的时候通过 \texttt{Mapping} 选项来使用它们。其中
712 % \texttt{fullwidth-stop} 用于将正常句号“。”转换成全角实心句号“.”,
713 % \texttt{full-stop} 的作用相反。\texttt{han-trad} 用于将简体中文转换成繁体中文,
714 % \texttt{han-simp} 的作用相反。需要注意的是,简繁互换都是简单机械的字字对译,
715 % 不能做到完全准确,使用时要小心。例如简体的“发挥”和“头发”被转换成繁体的
716 % “發揮”和“頭發”,显然后者应作“頭髮”。也可以根据实际需要,制作新的映射文件,
717 % 请参考 TECKit 的文档。
718 % \end{function}
719 %
720 % \begin{function}[EXP,updated=2016-11-18]{\setCJKsansfont}
721 % \begin{syntax}
722 % \tn{setCJKsansfont} \Arg{font name}\oarg{font features} 或\\
723 % \tn{setCJKsansfont} \oarg{font features} \Arg{font name}
724 % \end{syntax}
725 % 设置正文无衬线族的 CJK 字体,影响 \tn{sffamily} 和 \tn{textsf} 的字体。
726 % \end{function}
727 %
728 % \begin{function}[EXP,updated=2016-11-18]{\setCJKmonofont}
729 % \begin{syntax}
730 % \tn{setCJKmonofont} \Arg{font name}\oarg{font features} 或\\
731 % \tn{setCJKmonofont} \oarg{font features} \Arg{font name}
732 % \end{syntax}
733 % 设置正文等宽族的 CJK 字体,影响 \tn{ttfamily} 和 \tn{texttt} 的字体。
734 % \end{function}
735 %
736 % \begin{function}[EXP,updated=2016-11-18]{\setCJKfamilyfont}
737 % \begin{syntax}
738 % \tn{setCJKfamilyfont} \Arg{family} \Arg{font name}\oarg{font features} 或\\
739 % \tn{setCJKfamilyfont} \Arg{family} \oarg{font features} \Arg{font name}
740 % \end{syntax}
741 % 声明新的 CJK 字体族 \meta{family} 并指定字体。
742 % \end{function}
743 %
744 % \begin{function}[updated=2012-10-27]{\CJKfamily}
745 % \begin{syntax}
746 % \tn{CJKfamily} \Arg{family}
747 % \tn{CJKfamily} + \Arg{family}
748 % \tn{CJKfamily} - \Arg{family}
749 % \end{syntax}
750 % 用于在文档中切换 |CJK| 字体族,\meta{family} 必须预先声明。\tn{CJKfamily} 仅对
751 % CJK 字符类有效,\tn{CJKfamily}|+| 对所有字符类均有效,\tn{CJKfamily}|-| 对非 CJK 字
752 % 符类有效。当 \tn{CJKfamily}|+| 和 \tn{CJKfamily}|-| 的参数为空时,则使用当前的 |CJK| 字体族。
753 % \end{function}
754 %
755 % \begin{function}[EXP,updated=2016-11-18]{\newCJKfontfamily}
756 % \begin{syntax}
757 % \tn{newCJKfontfamily} \oarg{family} \cs{\meta{font-switch}} \Arg{font name}\oarg{font features} 或\\
758 % \tn{newCJKfontfamily} \oarg{family} \cs{\meta{font-switch}} \oarg{font features} \Arg{font name}
759 % \end{syntax}
760 % 声明新的 CJK 字体族 \meta{family} 并指定字体,并定义 \cs{\meta{font-switch}},在
761 % 文档中可以使用它来切换 CJK 字体族。可以不必指定 \meta{family},这时候 \meta{family}
762 % 将等于 \meta{font-switch}。
763 % \end{function}
764 %
765 % 事实上,\tn{newCJKfontfamily} 是 \tn{setCJKfamilyfont} 和
766 % \tn{CJKfamily} 的合并。例如
767 % \begin{ctexexam}
768 % \newCJKfontfamily[song]\songti{SimSun}
769 % \end{ctexexam}
770 % 等价于
771 % \begin{ctexexam}
772 % \setCJKfamilyfont{song}{SimSun}
773 % \newcommand*{\songti}{\CJKfamily{song}}
774 % \end{ctexexam}
775 %
776 % \begin{function}[updated=2016-11-18]{\CJKfontspec}
777 % \begin{syntax}
778 % \tn{CJKfontspec} \Arg{font name}\oarg{font features} 或\\
779 % \tn{CJKfontspec} \oarg{font features} \Arg{font name}
780 % \end{syntax}
781 % 在文档中定义新的 CJK 字体族,并马上使用它。
782 % \end{function}
783 %
784 % \begin{function}[rEXP]{\defaultCJKfontfeatures}
785 % \begin{syntax}
786 % \tn{defaultCJKfontfeatures} \Arg{font features}
787 % \end{syntax}
788 % 全局设置 CJK 字体族的默认选项。例如,使用
789 % \begin{ctexexam}
790 % \defaultCJKfontfeatures{Scale=0.962216}
791 % \end{ctexexam}
792 % 可以将全部 CJK 字体缩小为 |0.962216|。\pkg{xeCJK} 宏包的初始化设置是
793 % \begin{frameverb}
794 % \defaultCJKfontfeatures{Script=CJK}
795 % \end{frameverb}
796 % \end{function}
797 %
798 % \begin{function}[updated=2013-06-30]{\addCJKfontfeatures}
799 % \begin{syntax}
800 % \tn{addCJKfontfeatures} \Arg{font features}
801 % \tn{addCJKfontfeatures} * \Arg{font features}
802 % \tn{addCJKfontfeatures} \oarg{block_1, block_2, ...} \Arg{font features}
803 % \tn{addCJKfontfeatures} * \oarg{block_1, block_2, ...} \Arg{font features}
804 % \end{syntax}
805 % 临时增加当前使用的 CJK 字体的选项。第一条命令,仅对当前 CJK 主分区字体有效;
806 % 第二条对主分区和其他分区的字体都有效;第三条仅对可选参数中指定的分区有效;
807 % 第四条对主分区和可选参数中指定的分区有效。例如,使用
808 % \begin{ctexexam}
809 % \addCJKfontfeatures{Scale=1.1}
810 % \end{ctexexam}
811 % 可以将文档中当前使用的 CJK 主分区字体放大为 |1.1|。
812 % \end{function}
813 %
814 % \begin{function}{\CJKrmdefault}
815 % 保存 \tn{textrm} 和 \tn{rmfamily} 所使用的 CJK 字体族,默认值是 |rm|。
816 % \end{function}
817 %
818 % \begin{function}{\CJKsfdefault}
819 % 保存 \tn{textsf} 和 \tn{sffamily} 所使用的 CJK 字体族,默认值是 |sf|。
820 % \end{function}
821 %
822 % \begin{function}{\CJKttdefault}
823 % 保存 \tn{texttt} 和 \tn{ttfamily} 所使用的 CJK 字体族,默认值是 |tt|。
824 % \end{function}
825 %
826 % \begin{function}[updated=2013-01-01]{\CJKfamilydefault}
827 % 保存 \tn{textnormal} 和 \tn{normalfont} 所使用的 CJK 字体族。类似西文字体的 \tn{familydefault}。
828 % 初始值是 \tn{CJKrmdefault}。如果没有在导言区中修改它,\pkg{xeCJK} 会在导言区
829 % 结束的时候根据西文字体的情况自动更新 \tn{CJKfamilydefault}。因此,在导言区里使用
830 % \begin{frameverb}
831 % \renewcommand\familydefault{\sfdefault}
832 % \end{frameverb}
833 % 就可以将全文的 CJK 和西文默认字体都改为无衬线字体族。
834 % \end{function}
835 %
836 % \begin{function}[EXP,updated=2016-11-18]{\setCJKmathfont}
837 % \begin{syntax}
838 % \tn{setCJKmathfont} \Arg{font name}\oarg{font features} 或\\
839 % \tn{setCJKmathfont} \oarg{font features} \Arg{font name}
840 % \end{syntax}
841 % 设置数学公式中的 CJK 字体族。如果使用了 |CJKmath| 选项,但是没有使用
842 % \tn{setCJKmathfont} 设置数学公式中的 CJK 字体,那么将使用 \tn{CJKfamilydefault}
843 % 作为数学公式中的 CJK 字体。
844 % \end{function}
845 %
846 % \begin{function}[EXP, label=, updated=2016-11-18]{\setCJKfallbackfamilyfont}
847 % \begin{syntax}
848 % \tn{setCJKfallbackfamilyfont} \Arg{family} \Arg{font name}\oarg{font features} 或\\
849 % \tn{setCJKfallbackfamilyfont} \Arg{family} \oarg{font features} \Arg{font name}
850 % \end{syntax}
851 % 设置 CJK 字体族 \meta{family} 的备用字体。例如,使用
852 % \begin{ctexexam}
853 % \setCJKmainfont{SimSun}
854 % \setCJKfallbackfamilyfont{\CJKrmdefault}{SimSun-ExtB}
855 % \end{ctexexam}
856 % 可以将 |SimSun-ExtB| 作为 |SimSun| 的备用字体。
857 % \end{function}
858 %
859 % \begin{function}{FallBack}
860 % \begin{syntax}
861 % FallBack = \{\oarg{font features}\Arg{font name}\}
862 % \end{syntax}
863 % \pkg{xeCJK} 在 \meta{font features} 里增加了 |FallBack| 这个选项。用来在声明主
864 % 字体的时候,同时设置备用字体。例如,上面的例子等价于:
865 % \begin{ctexexam}
866 % \setCJKmainfont[FallBack=SimSun-ExtB]{SimSun}
867 % \end{ctexexam}
868 % 如果 |FallBack| 的值为空,将设置的是备用字体。例如,
869 % \begin{ctexexam}
870 % \setCJKmainfont[FallBack,AutoFakeBold,Scale=.97]{SimSun-ExtB}
871 % \end{ctexexam}
872 % 等价于
873 % \begin{ctexexam}
874 % \setCJKfallbackfamilyfont{\CJKrmdefault}[AutoFakeBold,Scale=.97]{SimSun-ExtB}
875 % \end{ctexexam}
876 % \end{function}
877 %
878 % \begin{function}[EXP,updated=2013-06-30]{\setCJKfallbackfamilyfont}
879 % \begin{syntax}
880 % \tn{setCJKfallbackfamilyfont} \Arg{family}
881 % \ \{
882 % \ \{\oarg{font features_1} \Arg{font name_1}\} ,
883 % \ \{\oarg{font features_2} \Arg{font name_2}\} ,
884 % \ ......
885 % \ \}\oarg{common font features} 或\\
886 % \tn{setCJKfallbackfamilyfont} \Arg{family} \oarg{common font features}
887 % \ \{
888 % \ \{\oarg{font features_1} \Arg{font name_1}\} ,
889 % \ \{\oarg{font features_2} \Arg{font name_2}\} ,
890 % \ ......
891 % \ \}
892 % \end{syntax}
893 % \tn{setCJKfallbackfamilyfont} 还可以用于设置多层的备用字体。例如,使用
894 % \begin{ctexexam}
895 % \setCJKmainfont[AutoFakeBold,AutoFakeSlant]{KaiTi_GB2312}
896 % \setCJKfallbackfamilyfont{\CJKrmdefault}[AutoFakeSlant]
897 % { [BoldFont=SimHei]{SimSun} ,
898 % [AutoFakeBold] {SimSun-ExtB} }
899 % \end{ctexexam}
900 % 之后,就设置了 |SimSun| 是 |KaiTi_GB2312| 的备用字体,而 |SimSun-ExtB| 是
901 % |SimSun| 的备用字体。若当前字体族缺字,并没有备用字体,则尝试使用
902 % \tn{CJKfamilydefault} 的备用字体。
903 % \end{function}
904 %
905 % \subsubsection{\XeTeX 的字体名查找}
906 % \label{subsubsec:fontsearch}
907 %
908 % 由于在 \pkg{fontspec} 宏包文档中缺少关于如何查看 \XeTeX{} 可用字体名的说明,
909 % 这里略作说明。
910 %
911 % \XeTeX{} 通常使用 fontconfig 库查找和调用字体,因此,可以用 |fc-list| 命令显
912 % 示可用的字体。在命令行(Windows 的“命令提示符”,Linux 的 Console)下运行以
913 % 下命令:
914 % \begin{frameverb}
915 % fc-list > fontlist.txt
916 % \end{frameverb}
917 % 可以将系统中所有安装的字体列表存入 \file{fontlist.txt} 文件中(可能很长)。
918 %
919 % |fc-list| 命令列出的信息很多,而且在安装字体较多的 Windows 系统上的输出将非
920 % 常庞大,如其中可能包含:
921 % \begin{frameverb}
922 % Times New Roman:style=cursiva,kurzíva,kursiv,Πλάγια,Italic,
923 % Kursivoitu,Italique,Dőlt,Corsivo,Cursief,kursywa,Itálico,Курсив,
924 % İtalik,Poševno,nghiêng,Etzana
925 % Times New Roman:style=Negreta cursiva,tučné kurzíva,fed kursiv,
926 % Fett Kursiv,Έντονα Πλάγια,Bold Italic,Negrita Cursiva,
927 % Lihavoitu Kursivoi,Gras Italique,Félkövér dőlt,Grassetto Corsivo,
928 % Vet Cursief,Halvfet Kursiv,Pogrubiona kursywa,Negrito Itálico,
929 % Полужирный Курсив,Tučná kurzíva,Fet Kursiv,Kalın İtalik,
930 % Krepko poševno,nghiêng đậm,Lodi etzana
931 % Times New Roman:style=Negreta,tučné,fed,Fett,Έντονα,Bold,Negrita,
932 % Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiona,Negrito,
933 % Полужирный,Fet,Kalın,Krepko,đậm,Lodia
934 % Times New Roman:style=Normal,obyčejné,Standard,Κανονικά,Regular,
935 % Normaali,Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,
936 % thường,Arrunta
937 % 宋体,SimSun:style=Regular
938 % 黑体,SimHei:style=Normal,obyčejné,Standard,Κανονικά,Regular,Normaali,
939 % Normál,Normale,Standaard,Normalny,Обычный,Normálne,Navadno,Arrunta
940 % \end{frameverb}
941 % 在 \pkg{fontspec} 或 \pkg{xeCJK} 中使用的字体族名是上面列表中冒号前的部分。
942 % 例如可以使用
943 % \begin{ctexexam}
944 % \setmainfont{Times New Roman}
945 % \setCJKmainfont{SimSun} % 或者 \setCJKmainfont{宋体}
946 % \end{ctexexam}
947 % 来设置字体。
948 %
949 % 为了方便起见,|fc-list| 命令也可以加上各种选项控制输出格式,例如如果只要列出
950 % 所有的中文字体的字体族名,可以用命令:
951 % \begin{frameverb}
952 % fc-list -f "%{family}\n" :lang=zh > zhfont.txt
953 % \end{frameverb}
954 % 这样就把字体列表保存在文件 \file{zhfont.txt} 中\footnote{由于汉字编码原因,
955 % Windows 下总需要把字体列表输出的文件中防止乱码。}。这样列出的字体列表就比较
956 % 简明易用,如 Windows 下预装的中文字体:
957 % \begin{frameverb}
958 % Arial Unicode MS
959 % FangSong,仿宋
960 % KaiTi,楷体
961 % Microsoft YaHei,微软雅黑
962 % MingLiU,細明體
963 % NSimSun,新宋体
964 % PMingLiU,新細明體
965 % SimHei,黑体
966 % SimSun,宋体
967 % \end{frameverb}
968 % 要列出日文和韩文的字体,可以把 |:lang=zh| 选项中的 |zh| 改成 |ja| 或 |ko|。
969 %
970 % \pkg{fontspec} 和 \pkg{xeCJK} 也可以使用字体的文件名访问字体。例如 Windows
971 % 下的宋体也可以使用命令:
972 % \begin{frameverb}
973 % \setCJKmainfont{simsun.ttc}
974 % \end{frameverb}
975 % 来设置。设置字体文件名的相关选项和语法在 \pkg{fontspec} 宏包手册中叙述甚详,
976 % 这里不再赘述。有个别字体名不规范的中文字体,\pkg{xeCJK} 宏包可能无法正确地通
977 % 过字体名访问,那么也可以使用这种方式设置。
978 %
979 % \subsection{CJK 分区字体设置}
980 % \label{subsec:block}
981 %
982 % 众所周知,CJK 文字数量极其庞大,单一的字体不可能涵盖所有的 CJK 文字。\pkg{xeCJK} 可
983 % 以在同一 CJK 字体族下,自动使用不同的字体输出 CJK 字符范围内不同区块里的文字。首先要
984 % 声明 CJK 子分区。
985 %
986 % \begin{function}[EXP]{\xeCJKDeclareSubCJKBlock}
987 % \begin{syntax}
988 % \tn{xeCJKDeclareSubCJKBlock} \Arg{block} \Arg{block range}
989 % \tn{xeCJKDeclareSubCJKBlock} * \Arg{block} \Arg{block range}
990 % \end{syntax}
991 % 其中 \meta{block range} 是逗号列表,可以是 CJK 字符的 |Unicode| 范围,也可以是单个字符
992 % 的 |Unicode|。例如
993 % \end{function}
994 % \begin{ctexexam}
995 % { `中 -> `文 , "3400 -> "4DBF , "5000 -> "7000 , `汉 , `字 , "3500 }
996 % \end{ctexexam}
997 % 的形式。需要注意的是,这里设置的 \meta{block range} 除非确实需要(例如某些特殊字体使用
998 % 了 |Unicode| 中的私人使用区的情况),否则不要超出源代码中预设的
999 % \hyperlink{CJKcharclass}{CJK 文字范围}。使用
1000 % \begin{ctexexam}
1001 % \xeCJKDeclareSubCJKBlock{SPUA}{ "E400 -> "E4DA , "E500 -> "E5E8 , "E600 -> "E6CE }
1002 % \xeCJKDeclareSubCJKBlock{Ext-B}{ "20000 -> "2A6DF }
1003 % \end{ctexexam}
1004 % 就声明了 |SPUA| 和 |Ext-B| 这两个个子分区。同时在 \ref{subsec:fontset} 节介绍的
1005 % CJK 字体设置命令的 \meta{font features} 里新建了 |SPUA| 和 |Ext-B| 这两个选项。
1006 % 新建的这两个选项的使用方法跟 \ref{subsec:fontset} 介绍的 |FallBack| 类似。可以
1007 % 通过它们来设置字体。
1008 %
1009 % 例如,可以使用
1010 % \begin{ctexexam}
1011 % \setCJKmainfont[SPUA=SunmanPUA,Ext-B=SimSun-ExtB]{SimSun}
1012 % \end{ctexexam}
1013 % 设置文档的主字体是 |SimSun|,|SPUA| 分区的字体是 |SunmanPUA|,而 |Ext-B| 分区
1014 % 的字体是 |SimSun-ExtB|。
1015 %
1016 % \tn{xeCJKDeclareSubCJKBlock} 应该在声明所有的 CJK 字体族之前使用。如果有某个 CJK 字
1017 % 体族没有设置 \meta{block} 选项,将使用 \tn{CJKfamilydefault} 的 \meta{block} 选项
1018 % 作为该 CJK 字体族的 \meta{block} 选项。如果希望在使用某 CJK 字体族时,不在 CJK 主
1019 % 分区与 \meta{block} 之间切换字体,可以使用 \meta{block}|=*| 选项。带星号的命令除了
1020 % 设置 CJK 子分区以外,还重置标点符号所属的字符类。
1021 %
1022 % \begin{function}{\xeCJKCancelSubCJKBlock}
1023 % \begin{syntax}
1024 % \tn{xeCJKCancelSubCJKBlock} \Arg{block_1, block_2, ...}
1025 % \tn{xeCJKCancelSubCJKBlock} \Arg{block_1, block_2, ...}
1026 % \end{syntax}
1027 % 在文档中取消对 |CJK| 分区的声明。带星号的命令还重置标点符号所属的字符类。
1028 % \end{function}
1029 %
1030 % \begin{function}{\xeCJKRestoreSubCJKBlock}
1031 % \begin{syntax}
1032 % \tn{xeCJKRestoreSubCJKBlock} \Arg{block_1, block_2, ...}
1033 % \tn{xeCJKRestoreSubCJKBlock} * \Arg{block_1, block_2, ...}
1034 % \end{syntax}
1035 % 在文档中恢复对 |CJK| 分区的声明。带星号的命令还重置标点符号所属的字符类。
1036 % \end{function}
1037 %
1038 % \subsection{设置 CJK 字符范围}
1039 %
1040 % \begin{function}[EXP]{\xeCJKDeclareCharClass}
1041 % \begin{syntax}
1042 % \tn{xeCJKDeclareCharClass} \Arg{class} \Arg{class range}
1043 % \tn{xeCJKDeclareCharClass} * \Arg{class} \Arg{class range}
1044 % \end{syntax}
1045 % \meta{class range} 的格式和 \ref{subsec:block} 节的 \meta{block range} 相同。
1046 % \meta{class} 的有效值见源代码(第 \ref{sec:xeCJK-class-set} 节)。\pkg{xeCJK} 已
1047 % 经支持 |Unicode| 中所有 CJK 文字和标点。一般来说,不要轻易改变字符类别。带星号的
1048 % 命令除了设置字符类别以外,为了确保标点处理的正确性,还重置标点符号所属的字符类。
1049 % \end{function}
1050 %
1051 % \begin{function}[EXP]{\xeCJKResetCharClass}
1052 % 用于恢复 \pkg{xeCJK} 对各个字符类别的初始化设置。
1053 % \end{function}
1054 %
1055 % \begin{function}[EXP]{\xeCJKResetPunctClass}
1056 % 用于重置标点符号所属的字符类。
1057 % \end{function}
1058 %
1059 % \begin{function}{\normalspacedchars}
1060 % \begin{syntax}
1061 % \tn{normalspacedchars} \Arg{char list}
1062 % \end{syntax}
1063 % 在 \meta{char list} 中出现的字符两端不自动添加空格,初始设置是 |/|、|\|、
1064 % 和 |-| (|U+002D|)。
1065 % \end{function}
1066 %
1067 % \subsection{标点符号的处理}
1068 %
1069 % \pkg{xeCJK} 对标点符号的输出宽度的调整是通过调整其左边或右边的空白宽度来实现的。
1070 % 按照目前的处理方式,对于位于左边的标点符号(如左引号),\pkg{xeCJK} 只能调整它
1071 % 左边的空白;对于位于右边的标点符号(如右引号),\pkg{xeCJK} 只能调整它右边的空
1072 % 白;对于居中的标点符号,则调整其左右空白,以保证其居中。对于标点符号的相关设置,
1073 % 只能在导言区中进行。
1074 %
1075 % \subsubsection{设置特定标点符号的宽度和间距}
1076 % \label{subsec:punct}
1077 %
1078 % 这里的设置可用于除 |plain| 以外的所有标点处理格式。
1079 %
1080 % \begin{function}[EXP,updated=2013-08-22]{\xeCJKsetwidth}
1081 % \begin{syntax}
1082 % \tn{xeCJKsetwidth} \Arg{标点列表} \Arg{length}
1083 % \tn{xeCJKsetwidth} * \Arg{标点列表} \Arg{length}
1084 % \end{syntax}
1085 % \meta{标点列表}可以是单个标点,也可以是多个标点。例如,
1086 % \begin{ctexexam}
1087 % \xeCJKsetwidth{。?}{0.7em}
1088 % \end{ctexexam}
1089 % 将设置句号和问号所占的宽度为 |0.7em|。带星号的命令,设置标点符号出现在行首/尾
1090 % 时的宽度。
1091 % \end{function}
1092 %
1093 % \begin{function}[EXP]{\xeCJKsetkern}
1094 % \begin{syntax}
1095 % \tn{xeCJKsetkern} \Arg{前标点} \Arg{后标点} \Arg{length}
1096 % \end{syntax}
1097 % \pkg{xeCJK} 会根据选定的标点处理格式自动调整相邻的前后两个 |CJK| 标点符号的
1098 % 空白宽度。如果需要对个别情况进行特殊调整,可以使用这个命令。例如,
1099 % \begin{ctexexam}
1100 % \xeCJKsetkern{:}{“}{0.3em}
1101 % \end{ctexexam}
1102 % 将设置冒号与左双引号之间的空白宽度为 |0.3em|。
1103 % \end{function}
1104 %
1105 % \subsubsection{定义标点符号处理格式}
1106 % \label{subsec:punctstyle}
1107 %
1108 % \begin{function}[EXP,updated=2013-08-22]{\xeCJKDeclarePunctStyle}
1109 % \begin{syntax}
1110 % \tn{xeCJKDeclarePunctStyle} \Arg{style} \Arg{options}
1111 % \end{syntax}
1112 % 定义新的标点符号处理格式,已经存在的同名格式将被覆盖。可以设置的选项将在下面介绍。
1113 % \end{function}
1114 %
1115 % \begin{function}[EXP,updated=2013-08-22]{\xeCJKEditPunctStyle}
1116 % \begin{syntax}
1117 % \tn{xeCJKEditPunctStyle} \Arg{style} \Arg{options}
1118 % \end{syntax}
1119 % 修改已有的标点符号处理格式。
1120 % \end{function}
1121 %
1122 % 下面是可以设置的标点符号格式选项。其中左边一栏是选项名称,中间是选项的输入值类
1123 % 型,右边则是相关说明。某些选项之间是互斥的,具有优先级关系。要使下一级的选项有
1124 % 效,则需要先禁用上一级的设置:对于 \meta{boolean} 类型的选项,将其设置为 |false|,
1125 % 对于 \meta{length} 类型的选项,将其设置为 \tn{maxdimen},而对于 \meta{real} 类型
1126 % 的选项,将其设置为 |nan|。
1127 %
1128 % \begin{psopt}
1129 % \PSKeyVal{enabled-global-setting}{boolean}
1130 % 是否使用 \tn{xeCJKsetup} 的 |PunctWidth|、|PunctBoundWidth| 选项和
1131 % \tn{xeCJKsetwidth}、\tn{xeCJKsetkern} 的设置。默认值是 |true|。
1132 % \end{psopt}
1133 %
1134 % \begin{psopt}
1135 % \PSKeyVal{fixed-punct-width}{length}
1136 % 设置单个标点符号的宽度。默认值是 \tn{maxdimen}。
1137 % \PSKeyVal{fixed-punct-ratio}{real}
1138 % 设置单个标点符号的输出宽度与实际宽度的比例。默认值是 |1.0|。
1139 % \PSKeyVal{mixed-punct-width}{length}
1140 % 设置句末标点符号的宽度。其中句末标点符号通过 \tn{xeCJKsetup} 的 |KaiMingPunct|
1141 % 来设置。默认值是与 |fixed-punct-width| 选项的值相同。
1142 % \PSKeyVal{mixed-punct-ratio}{real}
1143 % 设置句末标点符号的宽度比例。默认值是与 |fixed-punct-ratio| 选项的值相同。
1144 % \PSKeyVal{middle-punct-width}{length}
1145 % 设置居中标点符号的宽度。其中居中标点符号通过 \tn{xeCJKsetup} 的 |MiddlePunct|
1146 % 来设置。默认值是与 |fixed-punct-width| 选项的值相同。
1147 % \PSKeyVal{middle-punct-ratio}{real}
1148 % 设置居中标点符号的宽度比例。默认值是与 |fixed-punct-ratio| 选项的值相同。
1149 % \end{psopt}
1150 %
1151 % 以上几个选项设置的是标点的固定宽度或比例,\pkg{xeCJK} 会根据设定的选项计算标点符号
1152 % 左/右的空白宽度。下面的选项设置的是标点符号左/右的空白宽度或比例,因此不同标点符号
1153 % 的宽度可能会不同。为了使下面的选项生效,需要先禁用上面的相应选项。优先级自上而下。
1154 %
1155 % \begin{psopt}
1156 % \PSKeyVal{fixed-margin-width}{length}
1157 % 设置标点的左/右空白宽度。默认值是 \tn{maxdimen}。
1158 % \PSKeyVal{fixed-margin-ratio}{real}
1159 % 设置标点的左/右空白宽度与字体中该标点的相应实际边界宽度的比例。默认值是~|1.0|。
1160 % \PSKeyVal{mixed-margin-width}{length}
1161 % 设置句末标点的左/右空白宽度。默认值是与 |fixed-margin-width| 的值相同。
1162 % \PSKeyVal{mixed-margin-ratio}{real}
1163 % 设置句末标点的左/右空白宽度的比例。默认值是与 |fixed-margin-ratio| 的值相同。
1164 % \PSKeyVal{middle-margin-width}{length}
1165 % 设置居中标点的两边空白宽度。默认值是与 |fixed-margin-width| 的值相同。
1166 % \PSKeyVal{middle-margin-ratio}{real}
1167 % 设置居中标点的两边空白宽度之和与两边实际两边边界宽度之和的比例。
1168 % 默认值是与 |fixed-margin-ratio| 的值相同。
1169 % \end{psopt}
1170 %
1171 % 下面选项设置标点符号出现在行首或者行尾时的宽度或比例。
1172 %
1173 % \begin{psopt}
1174 % \PSKeyVal{bound-punct-width}{length}
1175 % 设置标点符号出现在行首/尾时的宽度。默认值是 \tn{maxdimen}。
1176 % \PSKeyVal{bound-punct-ratio}{real}
1177 % 设置标点符号出现在行首/尾时的输出宽度与实际宽度的比例。默认值是 |nan|。
1178 % \PSKeyVal{bound-margin-width}{length}
1179 % 设置标点符号出现在行首/尾时的左/右空白宽度。默认值是 \tn{maxdimen}。
1180 % \PSKeyVal{bound-margin-ratio}{real}
1181 % 设置标点符号出现在行首/尾时的左/右空白宽度与相应实际边界宽度的比例。默认值是 |0|。
1182 % \PSKeyVal{enabled-hanging}{boolean}
1183 % 当以上选项的计算结果得到的宽度小于标点符号的实际边界宽度时,是否允许标点符号
1184 % 悬挂出页面边界。默认值是 |false|。
1185 % \end{psopt}
1186 %
1187 % \begin{psopt}
1188 % \PSKeyVal{add-min-bound-to-margin}{boolean}
1189 % 是否在以上计算结果的基础上再加上标点的左右实际边界宽度中的最小值。这个选项
1190 % 对居中的标点无效。默认值是 |false|。
1191 % \end{psopt}
1192 %
1193 % \begin{psopt}
1194 % \PSKeyVal{optimize-margin}{boolean}
1195 % 使用以上设置空白宽度或比例的选项时,最终输出的标点符号左/右的空白宽度可能大
1196 % 于原来的实际边界宽度。若此时本选项被设置为 |true|,则使用原来的实际边界宽度。
1197 % 而使用 |fixed-punct-width| 选项计算得出的左/右宽度可能小于该标点的另一侧宽
1198 % 度,若此时本选项被启用,则使用该标点的另一侧宽度。默认值为 |false|。
1199 % \end{psopt}
1200 %
1201 % \begin{psopt}
1202 % \PSKeyVal{margin-minimum}{length}
1203 % 指定标点符号左/右的最小空白宽度。当经过以上选项设置的空白宽度小于这个选项的值
1204 % 时,则使用这个选项的值。默认值是 |0pt|。
1205 % \end{psopt}
1206 %
1207 % 下面的选项处理的是前后相邻的两个标点符号之间的空白宽度。这些选项是互斥的,优先级
1208 % 自上而下。
1209 %
1210 % \begin{psopt}
1211 % \PSKeyVal{enabled-kerning}{boolean}
1212 % 是否调整前后相邻的两个标点之间的空白宽度。如果设置为 |false|,则每个标点都按
1213 % 原来的输出宽度输出。默认值是 |true|。
1214 % \PSKeyVal{min-bound-to-kerning}{boolean}
1215 % 是否使用当前字体中前面标点实际左右边界的最小值与后面标点实际左右边界的最小值
1216 % 中的最大值作为两个标点之间的空白宽度。默认值是 |false|。
1217 % \PSKeyVal{kerning-total-width}{length}
1218 % 设置两个标点的总共宽度。此时 \pkg{xeCJK} 会自动计算两个标点之间的空白宽度。
1219 % 默认值是 \tn{maxdimen}。
1220 % \PSKeyVal{kerning-total-ratio}{real}
1221 % 设置两个标点的总共输出宽度与实际宽度的比例。默认值是 |0.75|。
1222 % \PSKeyVal{same-align-margin}{length}
1223 % 前后两个标点位于同侧时,它们之间的空白宽度。默认值是 \tn{maxdimen}。
1224 % \PSKeyVal{same-align-ratio}{real}
1225 % 前后两个标点位于同侧时,它们之间的空白宽度与实际输出宽度的比例。默认值是~|nan|。
1226 % \PSKeyVal{different-align-margin}{length}
1227 % 前后两个标点位于异侧时,它们之间的空白宽度。默认值是 \tn{maxdimen}。
1228 % \PSKeyVal{different-align-ratio}{real}
1229 % 前后两个标点位于异侧时,它们之间的空白宽度与实际输出宽度的比例。默认值是~|nan|。
1230 % \PSKeyVal{kerning-margin-width}{length}
1231 % 设置前后两个标点之间的空白宽度。默认值是 \tn{maxdimen}。
1232 % \PSKeyVal{kerning-margin-ratio}{real}
1233 % 设置前后两个标点之间的空白宽度与实际输出空白的比例。默认值是 |1.0|。
1234 % \end{psopt}
1235 %
1236 % \begin{psopt}
1237 % \PSKeyVal{optimize-kerning}{boolean}
1238 % 使用以上选项计算出两个标点之间的空白宽度可能小于通过 |min-bound-to-kerning|
1239 % 选项得出的结果。当出现这一情况时,若此选项被设置为 |true|,则使用该选项的空
1240 % 白宽度。默认值为 |false|。
1241 % \end{psopt}
1242 %
1243 % \begin{psopt}
1244 % \PSKeyVal{kerning-margin-minimum}{length}
1245 % 指定两个标点之间的最小空白宽度。当经过以上选项设置的空白宽度小于这个选项的值
1246 % 时,则使用这个选项的值。默认值是 |0pt|。
1247 % \end{psopt}
1248 %
1249 % 事实上,\pkg{xeCJK} 的默认设置就相当于中文全角(|quanjiao|)格式。可以使用上面
1250 % 说明的选项定义新的标点处理格式。例如,使用
1251 % \begin{ctexexam}
1252 % \xeCJKDeclarePunctStyle { mine }
1253 % {
1254 % fixed-punct-ratio = nan ,
1255 % fixed-margin-width = 0 pt ,
1256 % mixed-margin-width = \maxdimen ,
1257 % mixed-margin-ratio = 0.5 ,
1258 % middle-margin-width = \maxdimen ,
1259 % middle-margin-ratio = 0.5 ,
1260 % add-min-bound-to-margin = true ,
1261 % bound-punct-width = 0 em ,
1262 % enabled-hanging = true ,
1263 % min-bound-to-kerning = true ,
1264 % kerning-margin-minimum = 0.1 em
1265 % }
1266 % \end{ctexexam}
1267 % 就定义了一个名为 |mine| 的标点处理格式。可以在导言区通过
1268 % \begin{frameverb}
1269 % \xeCJKsetup{PunctStyle=mine}
1270 % \end{frameverb}
1271 % 在文档中使用这个格式。它的意义是:使用标点符号的实际左右边界中的最小值作为其左/右
1272 % 空白的宽度,对于句末标点和居中标点,再加上实际边界空白的一半;当标点出现在行首或
1273 % 行尾时宽度为零,允许悬挂出页面边界;使用相邻两个标点的实际边界中的较小值作为它们
1274 % 之间的空白宽度,并且最小的空白宽度是 |0.1em|。再例如,使用
1275 % \begin{ctexexam}
1276 % \xeCJKEditPunctStyle { hangmobanjiao } { enabled-global-setting = false }
1277 % \end{ctexexam}
1278 % 将使得 \tn{xeCJKsetkern} 等的设置对 |hangmobanjiao| 这一格式无效。
1279 %
1280 % \subsection{\pkg{xeCJKfntef} 用法说明}
1281 %
1282 % \pkg{xeCJK} 包含有一个子宏包 \pkg{xeCJKfntef},可以用它来实现\CJKunderdot{汉字加点}%
1283 % 和可断行的下划线等。它是 \pkg{CJKfntef} 宏包在 \XeLaTeX 下的替换版本,基本用法完全一致。
1284 %
1285 % \pkg{xeCJKfntef} 基于 \package{ulem} 宏包,除了兼容 \pkg{ulem} 定义的一些命令外,
1286 % 还进行了一些扩充:
1287 %
1288 % \begin{function}[updated=2014-11-04]
1289 % {\CJKunderline,\CJKunderdblline,\CJKunderwave,\CJKsout,\CJKxout}
1290 % \begin{syntax}
1291 % \tn{CJKunderline} [*] [-] \oarg{选项} \Arg{内容}
1292 % \end{syntax}
1293 % \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=6]
1294 % \CJKunderline{虚室生白,吉祥止止}\\
1295 % \CJKunderdblline{虚室生白,吉祥止止}\\
1296 % \CJKunderwave{虚室生白,吉祥止止}\\
1297 % \CJKsout{虚室生白,吉祥止止}\\
1298 % \CJKxout{虚室生白,吉祥止止}
1299 % \end{SideBySideExample}
1300 % \end{function}
1301 %
1302 % \csappto{NoHighlight@Attributes}{\catcode37=14\relax}
1303 %
1304 % \begin{Example}[frame=single,numbers=left,gobble=4]
1305 % \CJKunderline-{南朝}\CJKunderline-{梁}\CJKunderline-{劉勰}%
1306 % \CJKunderwave-{文心雕龍}\CJKunderwave-{養氣}\\
1307 % \CJKunderline*[thickness=1pt, hidden=true]{瞻彼阕者,虚室生白,吉祥止止}
1308 % \end{Example}
1309 %
1310 % \begin{function}[updated=2014-11-04]{\CJKunderdot}
1311 % \begin{syntax}
1312 % \tn{CJKunderdot} \oarg{选项} \Arg{内容}
1313 % \end{syntax}
1314 % 在汉字下加点,可以和上述下划线命令嵌套使用。例如\smallskip
1315 %
1316 % \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=6]
1317 % \CJKunderline{虚室生白,\CJKunderdot{吉祥}止止}\\
1318 % \CJKunderdot{虚室生白,\CJKunderline{吉祥}止止}
1319 % \end{SideBySideExample}
1320 % \end{function}
1321 %
1322 % \bigskip
1323 %
1324 % 对上述六种对象,\pkg{xeCJKfntef} 提供了一些选项,设置点或线的位置和颜色。可以用
1325 % \tn{xeCJKsetup} 预先统一设置它们,也可以在使用时特别设置。
1326 %
1327 % \begin{function}[added=2014-11-04]{skip}
1328 % \begin{syntax}
1329 % \tn{xeCJKsetup} \{ underline/skip = \meta{\TTF} \}
1330 % \tn{xeCJKsetup} \{ underline = \{ skip = \meta{\TTF} , ... \} \}
1331 % \end{syntax}
1332 % 默认情况下,下划线会自动跳过中文标点符号,可以设置本选项为 \texttt{false},
1333 % 禁用这一功能。相应下划线命令后加上 |*| 号,具有相同的效果。
1334 % \end{function}
1335 %
1336 % \begin{function}{subtract}
1337 % 设置本选项为 \texttt{true},使得下划线的首尾减少一定距离,避免前后的下划线
1338 % 连在一起,适用于古籍标点整理中的专名号和书名号。在相应下划线命令后加上 |-|
1339 % 号,具有相同的效果。
1340 % \end{function}
1341 %
1342 % \begin{function}{hidden}
1343 % 设置本选项为 \texttt{true},将隐藏文本内容,只画下划线。
1344 % \end{function}
1345 %
1346 % \begin{function}{format}
1347 % \begin{syntax}
1348 % \tn{xeCJKsetup} \{ underline/format = \tn{color}\{red\} \}
1349 % \tn{xeCJKsetup} \{ underwave = \{ format = \tn{color}\{red\}, ... \} \}
1350 % \end{syntax}
1351 % 设置线或点的格式,比如颜色。
1352 % \end{function}
1353 %
1354 % \begin{function}[added=2016-06-03]{textformat}
1355 % 设置下划线或点的正文的格式。例如:\smallskip
1356 % \begin{Example}[frame=single,numbers=left,gobble=6]
1357 % \CJKunderline[textformat=\color{blue}]{虚室生白,吉祥止止}\\
1358 % \CJKunderdot[textformat=\bfseries, format=\color{red}]{虚室生白,吉祥止止}
1359 % \end{Example}
1360 % \end{function}
1361 %
1362 % \begin{function}{symbol}
1363 % 设置 \tn{CJKunderwave} 或 \tn{CJKunderdot} 的符号。
1364 % \end{function}
1365 %
1366 % 例如,波浪线 \tn{CJKunderwave} 的符号不会随字号而变化,在小字号下不好看。我们可以
1367 % 将它改为随字号而变化大小:
1368 %
1369 % \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.35\linewidth,gobble=4]
1370 % % \usepackage{fix-cm}
1371 % \xeCJKsetup{%
1372 % underwave/symbol=
1373 % \fontsize{0.5em}{0pt}%
1374 % \fontencoding{U}\fontfamily{lasy}\selectfont
1375 % \char 58\relax}
1376 % \footnotesize
1377 % \CJKunderwave{瞻彼阕者,虚室生白,吉祥止止}
1378 % \end{SideBySideExample}
1379 %
1380 % \begin{function}{thickness}
1381 % 设置 \tn{CJKunderline}、\tn{CJKunderdblline} 和 \tn{CJKsout} 的线的厚度。
1382 % 初始值是 \tn{ULthickness}。
1383 % \end{function}
1384 %
1385 % \begin{function}{depth}
1386 % 设置线或点的深度(基线到线或点的顶部的距离)。初始值都是 \texttt{0.2em}。
1387 % \end{function}
1388 %
1389 % \begin{function}{boxdepth}
1390 % \tn{CJKunderdot} 可能会影响到行距,可以设置本选项进行调整。如果不希望
1391 % \tn{CJKunderdot} 影响行距,可以将本选项设置为 \texttt{0pt}。
1392 % \end{function}
1393 %
1394 % \begin{function}{sep}
1395 % 设置 \tn{CJKunderdot} 与 \tn{CJKunderline}、\tn{CJKunderdblline} 或
1396 % \tn{CJKunderwave} 嵌套使用时,点与线或者线与点的距离。
1397 % \end{function}
1398 %
1399 % \begin{function}{gap}
1400 % 设置 \tn{CJKunderdblline} 的两条线之间的距离。初始值是 \texttt{1.1pt}。
1401 % \end{function}
1402 %
1403 % \begin{function}{height}
1404 % 设置删除线 \tn{CJKsout} 的高度(线的中心到基线的距离)。初始值是 \texttt{0.35em}。
1405 %
1406 % 例如,我们可以设置 \tn{CJKsout} 的厚度和颜色,让它具有类似高亮的效果:\smallskip
1407 %
1408 % \begin{Example}[frame=single,numbers=left,gobble=4]
1409 % \CJKsout*[thickness=2.5ex, format=\color{yellow}]{瞻彼阕者,虚室生白,吉祥止止}
1410 % \end{Example}
1411 % \end{function}
1412 %
1413 % \medskip
1414 %
1415 % \pkg{xeCJKfntef} 还提供给了自定义下划线和符号的 \tn{CJKunderanyline} 和
1416 % \tn{CJKunderanysymbol}。
1417 %
1418 % \begin{function}[updated=2014-11-07]{\CJKunderanyline}
1419 % \begin{syntax}
1420 % \tn{CJKunderanyline} [*] [-] \oarg{选项} \Arg{深度} \Arg{下划内容} \Arg{文本内容}
1421 % \end{syntax}
1422 % \pkg{xeCJKfntef} 先将 \meta{下划内容} 放进一个盒子(\tn{xeCJKfntefbox})里,然后
1423 % 向下移动 \meta{深度} 给定的距离,再用于填充。可用的 \meta{选项} 是 \texttt{textformat}、
1424 % \texttt{skip}、\texttt{hidden}、\texttt{subtract}、\texttt{sep} 和
1425 % \texttt{boxdepth}。选项 \texttt{sep} 和 \texttt{boxdepth} 的初始值是空,表示
1426 % 禁用该选项的功能。可以在 \tn{xeCJKsetup} 中通过对象 \texttt{ulem} 来设置。
1427 % \end{function}
1428 %
1429 % 例如,高亮效果也可以如下实现:\smallskip
1430 %
1431 % \begin{Example}[frame=single,numbers=left,gobble=4]
1432 % \CJKunderanyline*{0.5ex}{\color{yellow}\rule{2pt}{2.5ex}}{虚室生白,吉祥止止}
1433 % \end{Example}
1434 %
1435 % \begin{function}[updated=2014-11-04]{\CJKunderanysymbol}
1436 % \begin{syntax}
1437 % \tn{CJKunderanysymbol} \oarg{选项} \Arg{深度} \Arg{符号} \Arg{文本内容}
1438 % \end{syntax}
1439 % \pkg{xeCJKfntef} 将 \meta{符号} 放进一个盒子(\tn{xeCJKfntefbox})里。
1440 % \meta{深度} 参数用于设置盒子顶部的深度(基线到盒子顶部的距离)。
1441 % 可用的 \meta{选项} 是 \texttt{textformat}、\texttt{sep} 和 \texttt{boxdepth},意义与
1442 % \tn{CJKunderdot} 的相同。
1443 % \end{function}
1444 %
1445 % 例如,给汉字加三角形,可以如下设置:\smallskip
1446 %
1447 % \begin{Example}[frame=single,numbers=left,gobble=4]
1448 % \CJKunderanysymbol[sep=0.1em]{0.2em}{\tiny$\triangle$}
1449 % {瞻彼阕者,虚室生白,\CJKunderline{吉祥止止}}
1450 % \end{Example}
1451 %
1452 % \begin{function}[updated=2014-11-07]{\xeCJKfntefon}
1453 % \begin{syntax}
1454 % \tn{xeCJKfntefon} [*] [-] \oarg{选项}
1455 % \end{syntax}
1456 % 功能与用法 \pkg{ulem} 宏包的 \tn{ULon} 相同,扩展了可选参数符号 |*| 和 |-|,
1457 % 可用的 \meta{选项} 是 \texttt{textformat}、 \texttt{skip}、\texttt{hidden} 和
1458 % \texttt{subtract}。 这四个选项对 \pkg{ulem} 宏包定义的 \tn{uline} 等命令也有效,需要在
1459 % \tn{xeCJKsetup} 中通过对象 \texttt{ulem} 来设置。例如\smallskip
1460 %
1461 % \begin{Example}[frame=single,numbers=left,gobble=6]
1462 % \xeCJKsetup{ulem={textformat=\bfseries\color{red}, skip=true}}
1463 % \uline{虚室生白,吉祥止止}
1464 % \end{Example}
1465 % \end{function}
1466 %
1467 % \medskip
1468 %
1469 % 此外,\pkg{xeCJKfntef} 还提供了指定宽度,让汉字分散对齐的的环境
1470 % \env{CJKfilltwosides} 和 \env{CJKfilltwosides*}。
1471 %
1472 % \begin{function}[updated=2014-11-04]{CJKfilltwosides}
1473 % \begin{syntax}
1474 % \tn{begin}\{CJKfilltwosides\} \oarg{位置} \Arg{宽度}
1475 % 文本内容\verb=\\=
1476 % 文本内容
1477 % \tn{end}\{CJKfilltwosides\}
1478 % \end{syntax}
1479 % 环境中的内容被放入垂直盒子中,可选参数 \meta{位置} 指定盒子的基线位置。
1480 % 可以使用 \texttt{t}(顶部)、\texttt{c}(居中)和 \texttt{b}(底部),默认是 \texttt{c}。
1481 % \meta{宽度} 参数指定盒子的宽度。
1482 % \env{CJKfilltwosides*} 环境与 \env{CJKfilltwosides} 的区别是,当 \meta{宽度}
1483 % 不大于零或者不大于盒子的自然宽度时,就取盒子的自然宽度。例如
1484 % \end{function}
1485 %
1486 % \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.5\linewidth,gobble=4]
1487 % \begin{CJKfilltwosides}{.8\linewidth}
1488 % 瞻彼阕者,\\
1489 % 虚室生白,吉祥止止
1490 % \end{CJKfilltwosides}
1491 % \end{SideBySideExample}
1492 %
1493 % \begin{SideBySideExample}[frame=single,numbers=left,xrightmargin=.5\linewidth,gobble=4]
1494 % \begin{CJKfilltwosides*}{0pt}
1495 % 瞻彼阕者,\\
1496 % 虚室生白,吉祥止止
1497 % \end{CJKfilltwosides*}
1498 % \end{SideBySideExample}
1499 %
1500 % \subsection{其他}
1501 % \label{subsec:others}
1502 %
1503 % \begin{function}[updated=2013-11-16]{\xeCJKVerbAddon,\xeCJKOffVerbAddon}
1504 % 调整文字间距以便于让 CJK 字符占的宽度等于西文等宽字体中两个空格的宽度。如果这两
1505 % 个空格的宽度小于当前 CJK 正常文字的宽度,将对 CJK 字体进行适当地缩小。这有利于
1506 % 等宽字体的代码对齐等情形。需要注意的是,\tn{xeCJKVerbAddon} 对 \pkg{xeCJK} 的内
1507 % 部进行了比较大的修改,使用它之后,将禁止在 CJK 字符类之间自动换行,这与西文在
1508 % 抄录环境中的情况是一致的。所以不应该单独使用,应该放在分组里限制其作用域,否则
1509 % 是无效的。当然它可以和其他关于代码抄录的宏包配合使用。例如,可以使用于
1510 % \package{fancyvrb} 宏包的 \texttt{formatcom} 选项。此时设置的西文字体应该确实
1511 % 是等宽的以保证对齐。若西文等宽字体发生变动(包括字体大小),则需要在其后面使用
1512 % \tn{xeCJKVerbAddon},重新计算间距的宽度。\tn{xeCJKOffVerbAddon}
1513 % 用于在使用 \tn{xeCJKVerbAddon} 的环境中局部取消它的作用。由于 \package{listings}
1514 % 宏包有自己的代码对齐机制,所以 \tn{xeCJKVerbAddon} 在由 \pkg{listings} 定义的
1515 % 代码环境中无效。
1516 % \end{function}
1517 %
1518 % \begin{function}[added=2012-12-03]{\xeCJKnobreak}
1519 % \begin{syntax}
1520 % ……汉字。\tn{xeCJKnobreak}\tn{footnote}\{脚注\}
1521 % \end{syntax}
1522 % \tn{xeCJKnobreak} 用在全角标点符号后面,目的是确保不能在此处断行。如果已经启用了
1523 % 前面介绍的 |CheckFullRight| 选项,则不需要再用此命令。
1524 % \end{function}
1525 %
1526 % \begin{function}[added=2013-11-09]{\xeCJKShipoutHook}
1527 % \pkg{xeCJK} 在正文中的一些特殊设置(汉字下加点、在 \env{verbatim} 或
1528 % \env{lstlisting} 环境中分页)可能会影响到 \TeX 的输出例行程序(output routine)
1529 % 中的内容(比如页眉和页脚)。\tn{xeCJKShipoutHook} 用于恢复正文中的普通设置。
1530 % \pkg{xeCJK} 已经处理了页眉和页脚的情况,其他的就需要根据情况自行调用。
1531 % 比如若使用 \pkg{eso-pic} 或者 \pkg{atbegshi} 实现文字水印,并且正文中使用了
1532 % 以上所列的特殊形式,就需要在命令 \tn{AtBeginShipout} 的参数的最前面使用
1533 % \tn{xeCJKShipoutHook}。
1534 % \end{function}
1535 %
1536 % \section{已知问题和兼容性}
1537 %
1538 % 根据 \pkg{unicode-data} 宏包,\XeTeX 将所有 CJK 表意文字的 \tn{catcode}
1539 % 设置为 $11$。因此汉字可以直接用作控制序列的名字,但是当汉字出现在控制序列后面的
1540 % 时候,要用空格分隔开,否则就会出现“\texttt{! Undefined control sequence.}”的错误。
1541 %
1542 % \pkg{xeCJK} 使用并重新定义了 \pkg{CJK} 宏包的部分宏命令,如 \tn{CJKfamily}、
1543 % \tn{CJKsymbol} 和 \tn{CJKglue} 等。需要指出,\pkg{xeCJK} 不需要 \pkg{CJK}
1544 % 的支持,并且 \pkg{xeCJK} 自动禁止在它之后载入 \pkg{CJK} 宏包。
1545 % 可以在 \pkg{xeCJK} 之\emph{后}载入 \pkg{CJKnumb} 宏包,实现数字的中文化,
1546 % 也可以用功能更完善的 \package{zhnumber} 宏包。
1547 %
1548 % \pkg{xeCJK} 进行了一些处理,使得在使用 \XeTeX 时 \package{listings} 宏包可以
1549 % 支持 Unicode,因此在 \texttt{listings} 定义的代码环境中可以直接使用中文,不再
1550 % 需要通过 \texttt{escapechar}。
1551 %
1552 % 新版本(\texttt{3.x})的 \pkg{xeCJK} 完全使用 \LaTeXiii{} 的语法来编写。
1553 % \LaTeXiii{} 放弃了 \tn{outer} 宏的概念,因此相关工具在
1554 % 遇到 \tn{outer} 宏时可能会存在问题。按照目前 \pkg{xeCJK} 的实现方式,在 CJK 文字
1555 % 后面遇到 \tn{outer} 宏时会出现类似
1556 % \begin{frameverb}
1557 % ! Forbidden control sequence found while scanning use of \use_i:nn
1558 % \end{frameverb}
1559 % 的错误。目前已知的有 \package{cprotect} 宏包提供的 \tn{cprotect}。它的定义是
1560 % \begin{frameverb}
1561 % \outer\long\def\cprotect{\icprotect}
1562 % \end{frameverb}
1563 % 因此,这时可以暂时用 \tn{icprotect} 代替 \tn{cprotect}。事实上,当 \pkg{cprotect}
1564 % 被引入时,\pkg{xeCJK} 将使用
1565 % \begin{frameverb}
1566 % \let\cprotect\icprotect
1567 % \end{frameverb}
1568 % 来取消 \tn{cprotect} 的外部宏限制。但由于 \tn{cprotect} 的特殊性,应该只在外部
1569 % 使用它,即不要让它出现在任何宏的参数中。其他 \tn{outer} 宏的情况,可以在它前面
1570 % 加上 \tn{relax} 来回避上面的错误。
1571 %
1572 % \pkg{xeCJK} 依赖 \XeTeX 的 \tn{XeTeXinterchartoks} 机制,与使用相同机制的宏包(例如
1573 % \pkg{polyglossia} 和 \pkg{xesearch})可能会存在大小不一的冲突。
1574 % \pkg{xeCJK} 虽然为此作了一些处理,但与它们共同使用时应该小心。
1575 %
1576 %\end{documentation}
1577 %
1578 %
1579 % \StopEventually{}
1580 %
1581 %
1582 %\begin{implementation}
1583 %
1584 % \section{\pkg{xeCJK} 代码实现}
1585 %
1586 % \begin{macrocode}
1587 %<*package>
1588 % \end{macrocode}
1589 %
1590 % \begin{macrocode}
1591 %<@@=xeCJK>
1592 % \end{macrocode}
1593 %
1594 % \subsection{运行环境检查}
1595 %
1596 % \pkg{xeCJK} 必须使用 \XeTeX 引擎的支持。
1597 % \begin{macrocode}
1598 \msg_new:nnn { xeCJK } { Require-XeTeX }
1599 {
1600 The~xeCJK~package~requires~XeTeX~to~function.\\\\
1601 You~must~change~your~typesetting~engine~to~"xelatex" \\
1602 instead~of~plain~"latex"~or~"pdflatex"~or~"lualatex".\\
1603 Loading~xeCJK~will~abort!
1604 }
1605 \sys_if_engine_xetex:F { \msg_critical:nn { xeCJK } { Require-XeTeX } }
1606 % \end{macrocode}
1607 %
1608 % 应该使用较新版本的 \pkg{expl3} 宏包。
1609 % \begin{macrocode}
1610 \msg_new:nnn { xeCJK } { l3-too-old }
1611 {
1612 Support~package~`#1'~too~old. \\\\
1613 Please~update~an~up~to~date~version~of~the~bundles\\\\
1614 `l3kernel'~and~`l3packages'\\\\
1615 using~your~TeX~package~manager~or~from~CTAN.\\
1616 \str_if_eq:nnT {#1} { expl3 } { Loading~xeCJK~will~abort! }
1617 }
1618 \@ifpackagelater { expl3 } { 2020/02/08 } { }
1619 { \msg_critical:nnn { xeCJK } { l3-too-old } { expl3 } }
1620 % \end{macrocode}
1621 %
1622 % \cs{ctex_disable_package:n} 由 \pkg{ctexhook} 提供。
1623 % \begin{macrocode}
1624 \RequirePackage { ctexhook }
1625 % \end{macrocode}
1626 %
1627 % \begin{macro}[pTF,int]{\xeCJK_if_package_loaded:n}
1628 % 判断宏包是否被引入,可用于文档正文中。
1629 % \begin{macrocode}
1630 \prg_new_conditional:Npnn \xeCJK_if_package_loaded:n #1 { p , T , F , TF }
1631 {
1632 \tl_if_exist:cTF { ver@ #1 . \c_@@_package_ext_tl }
1633 { \prg_return_true: } { \prg_return_false: }
1634 }
1635 \tl_const:Nx \c_@@_package_ext_tl { \@pkgextension }
1636 % \end{macrocode}
1637 % \end{macro}
1638 %
1639 % \changes{v3.8.7}{2021/06/09}{应用 \tn{disable@package@load} 和
1640 % \tn{declare@file@substitution}。}
1641 %
1642 % 下面这些 \pkg{CJK} 系列宏包不应该被使用。
1643 % \begin{macrocode}
1644 \msg_new:nnn { xeCJK } { after-package }
1645 {
1646 The~`#1'~package~and~xeCJK~are~incompatible.\\\\
1647 Please~load~it~after~xeCJK.
1648 }
1649 \clist_map_inline:nn { CJKnumb }
1650 {
1651 \xeCJK_if_package_loaded:nT {#1}
1652 { \msg_error:nnn { xeCJK } { after-package } {#1} }
1653 }
1654 \clist_map_inline:nn
1655 { CJKulem , CJKvert , CJKpunct , CJKutf8 , CJK }
1656 { \ctex_disable_package:n {#1} }
1657 % \end{macrocode}
1658 %
1659 % \changes{v3.8.7}{2021/06/09}{将 \pkg{CJKfntef} 包替换为 \pkg{xeCJKfntef} 包。}
1660 %
1661 % 将 \pkg{CJKfntef} 包替换为 \pkg{xeCJKfntef} 包。
1662 % \begin{macrocode}
1663 \ctex_if_format_at_least:nTF { 2020/10/01 }
1664 { \ctex_replace_package:nn { CJKfntef } { xeCJKfntef } }
1665 { \ctex_disable_package:n { CJKfntef } }
1666 % \end{macrocode}
1667 %
1668 % \changes{v3.9.0}{2022/07/08}{不直接依赖 \pkg{xparse} 和 \pkg{l3keys2e}。}
1669 %
1670 % \begin{macrocode}
1671 \cs_if_exist:NF \NewDocumentCommand
1672 { \RequirePackage { xparse } }
1673 \RequirePackage { xtemplate }
1674 % \end{macrocode}
1675 %
1676 % \subsection{内部工具}
1677 %
1678 % 分配临时变量。
1679 % \begin{macrocode}
1680 \tl_new:N \l_@@_tmp_tl
1681 \int_new:N \l_@@_tmp_int
1682 \box_new:N \l_@@_tmp_box
1683 \dim_new:N \l_@@_tmp_dim
1684 \bool_new:N \l_@@_tmp_bool
1685 \skip_new:N \l_@@_tmp_skip
1686 \clist_new:N \l_@@_tmp_clist
1687 % \end{macrocode}
1688 %
1689 % \begin{macro}
1690 % {\@@_msg_new:nn ,\@@_error:n,\@@_error:nx,\@@_warning:nx,\@@_info:nxx}
1691 % 各种信息函数的缩略形式。
1692 % \begin{macrocode}
1693 \cs_new_protected:Npn \@@_msg_new:nn { \msg_new:nnn { xeCJK } }
1694 \cs_new_protected:Npn \@@_msg_new:nnn { \msg_new:nnnn { xeCJK } }
1695 \cs_new_protected:Npn \@@_error:n { \msg_error:nn { xeCJK } }
1696 \cs_new_protected:Npn \@@_error:nx { \msg_error:nnx { xeCJK } }
1697 \cs_new_protected:Npn \@@_warning:n { \msg_warning:nn { xeCJK } }
1698 \cs_new_protected:Npn \@@_warning:nx { \msg_warning:nnx { xeCJK } }
1699 \cs_new_protected:Npn \@@_warning:nxx { \msg_warning:nnxx { xeCJK } }
1700 \cs_new_protected:Npn \@@_warning:nxxx { \msg_warning:nnxxx { xeCJK } }
1701 \cs_new_protected:Npn \@@_info:nxx { \msg_info:nnxx { xeCJK } }
1702 % \end{macrocode}
1703 % \end{macro}
1704 %
1705 % \begin{macro}[int]{\xeCJK_allow_break:,\xeCJK_no_break:}
1706 % \begin{macrocode}
1707 \cs_new_protected:Npn \xeCJK_allow_break:
1708 { \tex_penalty:D \c_zero_int }
1709 \cs_new_protected:Npn \xeCJK_no_break:
1710 { \tex_penalty:D \c_@@_nobreak_penalty_int }
1711 \int_const:Nn \c_@@_nobreak_penalty_int { 10 000 }
1712 % \end{macrocode}
1713 % \end{macro}
1714 %
1715 % \changes{v3.8.3}{2020/04/07}{依赖 \pkg{ctexhook} 宏包。}
1716 %
1717 % \begin{macro}
1718 % {\@@_at_end_preamble:n,\@@_after_preamble:n,
1719 % \@@_after_end_preamble:n,\@@_package_hook:nn}
1720 % 在 \tn{document} 前后和宏包后加上各种钩子,依赖 \pkg{ctexhook}。
1721 % \begin{macrocode}
1722 \AtBeginDocument { \xeCJK@document@hook }
1723 \ctex_at_end_preamble:n { \xeCJK@document@left@hook }
1724 \ctex_after_end_preamble:n { \xeCJK@document@right@hook }
1725 \cs_new_protected:Npn \xeCJK@document@hook
1726 { \tl_use:N \g_@@_after_preamble_hook_tl }
1727 \cs_new_protected:Npn \xeCJK@document@left@hook
1728 { \tl_use:N \g_@@_at_end_preamble_hook_tl }
1729 \cs_new_protected:Npn \xeCJK@document@right@hook
1730 { \tl_use:N \g_@@_after_end_preamble_hook_tl }
1731 \cs_new_protected:Npn \@@_at_end_preamble:n
1732 { \tl_gput_right:Nn \g_@@_at_end_preamble_hook_tl }
1733 \cs_new_protected:Npn \@@_after_preamble:n
1734 { \tl_gput_right:Nn \g_@@_after_preamble_hook_tl }
1735 \cs_new_protected:Npn \@@_after_end_preamble:n
1736 { \tl_gput_right:Nn \g_@@_after_end_preamble_hook_tl }
1737 \cs_new_protected:Npn \@@_package_hook:nn
1738 { \ctex_at_end_package:nn }
1739 \tl_new:N \g_@@_at_end_preamble_hook_tl
1740 \tl_new:N \g_@@_after_preamble_hook_tl
1741 \tl_new:N \g_@@_after_end_preamble_hook_tl
1742 % \end{macrocode}
1743 % \end{macro}
1744 %
1745 % \changes{v3.2.7}{2013/11/09}{使用 \pkg{everypage} 往 \tn{shipout} 盒子里加钩子。}
1746 % \changes{v3.2.16}{2014/12/16}{不再依赖 \pkg{everypage} 宏包。}
1747 %
1748 % \begin{macro}{\xeCJKShipoutHook}
1749 % 在 \tn{shipout} 盒子里加钩子,可以影响到页眉页脚。\tn{AtBeginDvi} 将参数保存在
1750 % 盒子中,而 \pkg{atbegshi} 的 \tn{AtBeginShipout} 在 \tn{shipout} 盒子构建好之后
1751 % 才起作用,所以它们都影响不到页眉页脚。我们通过往 \tn{@begindvi} 里加入钩子来完成。
1752 % 注意,第一次使用 \tn{@begindvi} 之后,它会将自身定义为 \tn{@empty}。
1753 % \begin{macrocode}
1754 \@@_after_preamble:n
1755 { \tl_put_right:Nn \@begindvi { \xeCJK@first@begindvi } }
1756 \cs_new_protected:Npn \xeCJK@first@begindvi
1757 {
1758 \xeCJKShipoutHook
1759 \cs_if_exist:NTF \@begindvi
1760 { \tl_gput_right:Nn }
1761 { \tl_const:Nn }
1762 \@begindvi { \xeCJKShipoutHook }
1763 }
1764 \NewDocumentCommand \xeCJKShipoutHook { }
1765 {
1766 \bool_if:NF \l_@@_shipout_hook_bool
1767 {
1768 \bool_set_true:N \l_@@_shipout_hook_bool
1769 \tl_use:N \l_@@_shipout_hook_tl
1770 }
1771 }
1772 % \end{macrocode}
1773 % \end{macro}
1774 %
1775 % \begin{macro}[int]{\xeCJK_add_to_shipout:n}
1776 % \changes{v3.2.11}{2014/03/14}{不再使用内部名字。}
1777 % 往 \tn{shipout} 盒子中加入钩子。
1778 % \begin{macrocode}
1779 \cs_new_protected:Npn \xeCJK_add_to_shipout:n
1780 { \tl_put_right:Nn \l_@@_shipout_hook_tl }
1781 \tl_new:N \l_@@_shipout_hook_tl
1782 \bool_new:N \l_@@_shipout_hook_bool
1783 % \end{macrocode}
1784 % \end{macro}
1785 %
1786 % \begin{macro}[int]{\xeCJK_tl_remove_outer_braces:n}
1787 % \changes{v3.2.4}{2013/07/02}{去掉外层分组括号时,移除空格,避免死循环。}
1788 % 去掉 |#1| 外层的分组括号。
1789 % \begin{macrocode}
1790 \cs_new:Npn \xeCJK_tl_remove_outer_braces:n #1
1791 {
1792 \exp_last_unbraced:Ne
1793 \@@_tl_remove_outer_braces:w { \tl_trim_spaces:n {#1} } \s_stop
1794 }
1795 \cs_new:Npn \@@_tl_remove_outer_braces:w #1 \s_stop
1796 {
1797 \tl_if_single:nTF {#1}
1798 {
1799 \tl_if_head_is_N_type:nTF {#1}
1800 { \tl_trim_spaces:n }
1801 { \xeCJK_tl_remove_outer_braces:n }
1802 }
1803 { \tl_trim_spaces:n }
1804 {#1}
1805 }
1806 % \end{macrocode}
1807 % \end{macro}
1808 %
1809 % \begin{macro}[int]{\xeCJK_cs_clear:N,\xeCJK_cs_gclear:N}
1810 % 让控制序列的意义为空。
1811 % \begin{macrocode}
1812 \cs_new_protected:Npn \xeCJK_cs_clear:N #1
1813 { \cs_set_eq:NN #1 \prg_do_nothing: }
1814 \cs_new_protected:Npn \xeCJK_cs_gclear:N #1
1815 { \cs_gset_eq:NN #1 \prg_do_nothing: }
1816 % \end{macrocode}
1817 % \end{macro}
1818 %
1819 % \begin{macro}[int]{\xeCJK_swap_cs:NN}
1820 % 交换 |#1| 和 |#2| 的意义。
1821 % \begin{macrocode}
1822 \cs_new_protected:Npn \xeCJK_swap_cs:NN #1#2
1823 {
1824 \cs_set_eq:NN \@@_swap_cs_aux:w #1
1825 \cs_set_eq:NN #1 #2
1826 \cs_set_eq:NN #2 \@@_swap_cs_aux:w
1827 \cs_undefine:N \@@_swap_cs_aux:w
1828 }
1829 % \end{macrocode}
1830 % \end{macro}
1831 %
1832 % \begin{macro}[int]{\xeCJK_font_gset_to_current:N}
1833 % \changes{v3.8.4}{2020/06/04}{不缓存 \tn{nullfont}。}
1834 % |#1| 是控制序列的名字,令它等于当前字体命令。
1835 % \begin{macrocode}
1836 \cs_new_protected:Npn \xeCJK_font_gset_to_current:N
1837 { \exp_after:wN \@@_font_gset_to_current_aux:NN \tex_the:D \tex_font:D }
1838 \cs_new_protected:Npn \@@_font_gset_to_current_aux:NN #1#2
1839 { \cs_if_eq:NNF #1 \tex_nullfont:D { \cs_gset_eq:NN #2#1 } }
1840 % \end{macrocode}
1841 % \end{macro}
1842 %
1843 % \begin{macro}[int,pTF]{\xeCJK_glyph_if_exist:N}
1844 % \changes{v3.1.0}{2012/11/19}{改进 \pkg{fontspec} 宏包中定义的
1845 % \cs{font_glyph_if_exist:NnTF}。}
1846 % 判断当前字体中是否含有字符 |#1|。\pkg{fontspec} 中的类似函数在判断为真的时候,
1847 % 会留有一个 \cs{scan_stop:},造成不必要的边界,同时也不完全可展。因此,我们重新
1848 % 定义它。
1849 % \begin{macrocode}
1850 \prg_new_conditional:Npnn \xeCJK_glyph_if_exist:N #1 { p , T , F , TF }
1851 {
1852 \tex_iffontchar:D \tex_font:D `#1 \exp_stop_f:
1853 \prg_return_true: \else: \prg_return_false: \fi:
1854 }
1855 % \end{macrocode}
1856 % \end{macro}
1857 %
1858 % \begin{variable}[int]{\c_xeCJK_space_skip_tl}
1859 % \changes{v3.1.0}{2012/11/18}{字间空格考虑 \tn{spaceskip} 不为零的情况。}
1860 % \changes{v3.2.0}{2013/05/22}{字间空格考虑到 \tn{spacefactor} 和 \tn{xspaceskip} 的情况。}
1861 % 当前字体状态下,一个字间空格产生的 |glue| 的长度,包括伸展和收缩部分。
1862 % \begin{macrocode}
1863 \tl_const:Nn \c_xeCJK_space_skip_tl
1864 {
1865 \int_compare:nNnTF \g_@@_space_factor_int = { 1000 }
1866 {
1867 \skip_if_eq:nnTF \tex_spaceskip:D \c_zero_skip
1868 {
1869 \tex_fontdimen:D 2 ~ \tex_font:D
1870 plus \tex_fontdimen:D 3 ~ \tex_font:D
1871 minus \tex_fontdimen:D 4 ~ \tex_font:D
1872 }
1873 { \tex_spaceskip:D }
1874 }
1875 {
1876 \skip_if_eq:nnTF \tex_spaceskip:D \c_zero_skip
1877 {
1878 \int_compare:nNnTF \g_@@_space_factor_int < { 2000 }
1879 {
1880 \@@_space_skip_scale:nnn
1881 { \tex_fontdimen:D 2 ~ \tex_font:D }
1882 }
1883 {
1884 \skip_if_eq:nnTF \tex_xspaceskip:D \c_zero_skip
1885 {
1886 \@@_space_skip_scale:nnn
1887 {
1888 \tex_fontdimen:D 2 ~ \tex_font:D +
1889 \tex_fontdimen:D 7 ~ \tex_font:D
1890 }
1891 }
1892 { \tex_xspaceskip:D \use_none:nn }
1893 }
1894 { \tex_fontdimen:D 3 ~ \tex_font:D }
1895 { \tex_fontdimen:D 4 ~ \tex_font:D }
1896 }
1897 {
1898 \int_compare:nNnTF \g_@@_space_factor_int < { 2000 }
1899 { \@@_space_skip_scale:nnn { \tex_spaceskip:D } }
1900 {
1901 \skip_if_eq:nnTF \tex_xspaceskip:D \c_zero_skip
1902 {
1903 \@@_space_skip_scale:nnn
1904 {
1905 \tex_spaceskip:D +
1906 \tex_fontdimen:D 7 ~ \tex_font:D
1907 }
1908 }
1909 { \tex_xspaceskip:D \use_none:nn }
1910 }
1911 { \tex_gluestretch:D \tex_spaceskip:D }
1912 { \tex_glueshrink:D \tex_spaceskip:D }
1913 }
1914 }
1915 }
1916 \cs_new:Npn \@@_space_skip_scale:nnn #1#2#3
1917 {
1918 \dim_eval:n {#1}
1919 plus \fp_eval:n { \g_@@_space_factor_int / 1000 } #2
1920 minus
1921 \int_div_truncate:nn
1922 { 1000 * \int_value:w #3 } { \g_@@_space_factor_int } sp
1923 }
1924 % \end{macrocode}
1925 % \end{variable}
1926 %
1927 % \begin{macro}[int]{\xeCJK_reset_space_factor:}
1928 % \begin{variable}[int]{\g_@@_space_factor_int}
1929 % 在 \tn{XeTeXinterchartoks} 里,\tn{spacefactor} 已经被重置为 $1000$。
1930 % 我们需要在 Default 类里保存 \tn{spacefactor} 用于计算空格宽度。
1931 % \begin{macrocode}
1932 \int_new:N \g_@@_space_factor_int
1933 \cs_new_protected:Npn \xeCJK_reset_space_factor:
1934 { \int_gset:Nn \g_@@_space_factor_int { 1000 } }
1935 \xeCJK_reset_space_factor:
1936 % \end{macrocode}
1937 % \end{variable}
1938 % \end{macro}
1939 %
1940 % \begin{macro}[int]{\xeCJK_glue_to_skip:nN}
1941 % 取得一个 |glue| 的长度,包括伸展和收缩部分。如果参数不是 |glue|,则取其宽度。
1942 % \begin{macrocode}
1943 \cs_new_protected:Npn \xeCJK_glue_to_skip:nN #1#2
1944 {
1945 \group_begin:
1946 \hbox_set:Nw \l_@@_tmp_box #1 \scan_stop:
1947 \@@_if_last_glue:TF
1948 {
1949 \exp_args:NNNo \hbox_set_end:
1950 \skip_set:Nn #2 { \skip_use:N \tex_lastskip:D }
1951 }
1952 {
1953 \exp_args:NNNo \hbox_set_end:
1954 \skip_set:Nn #2 { \dim_use:N \box_wd:N \l_@@_tmp_box }
1955 }
1956 \exp_args:NNNo \group_end:
1957 \skip_set:Nn #2 { \skip_use:N #2 }
1958 }
1959 % \end{macrocode}
1960 % \end{macro}
1961 %
1962 % \begin{macro}[int]{\xeCJK_int_until_do:nn}
1963 % \begin{macro}{\@@_int_until_do:wn}
1964 % 由于定义较为简单,可以比 \cs{int_until_do:nNnn} 稍微快一点点。
1965 % \begin{macrocode}
1966 \cs_new_protected:Npn \xeCJK_int_until_do:nn #1#2
1967 {
1968 \@@_int_until_do:wn \use_none:n
1969 { \reverse_if:N \if_int_compare:w #1#2 }
1970 }
1971 \cs_new_protected:Npn \@@_int_until_do:wn \use_none:n #1
1972 { #1 \exp_after:wN \@@_int_until_do:wn \fi: \use_none:n {#1} }
1973 \int_new:N \l_@@_begin_int
1974 \int_new:N \l_@@_end_int
1975 % \end{macrocode}
1976 % \end{macro}
1977 % \end{macro}
1978 %
1979 % \begin{macro}[int]{\xeCJK_peek_catcode_ignore_spaces:NTF}
1980 % \changes{v3.1.1}{2012/12/04}{新增有省略空格标识的 \texttt{peek} 函数。}
1981 % 我们在里面设置了一个变量 \cs{l_@@_peek_ignore_spaces_bool} 用于标识后面的空格
1982 % 是否被省略掉了。
1983 % \begin{macrocode}
1984 \cs_new_protected:Npn \xeCJK_peek_catcode_ignore_spaces:NTF #1#2#3
1985 {
1986 \cs_set_eq:NN \l_@@_peek_search_token #1 \scan_stop:
1987 \cs_set_protected:Npx \@@_peek_catcode_true:w
1988 { \exp_not:N \group_align_safe_end: \exp_not:n {#2} }
1989 \cs_set_protected:Npx \@@_peek_catcode_false:w
1990 { \exp_not:N \group_align_safe_end: \exp_not:n {#3} }
1991 \bool_set_false:N \l_@@_peek_ignore_spaces_bool
1992 \group_align_safe_begin:
1993 \peek_after:Nw \@@_peek_catcode_ignore_spaces_branches:w
1994 }
1995 \cs_new_protected:Npn \@@_peek_catcode_ignore_spaces_branches:w
1996 {
1997 \if_meaning:w \l_peek_token \c_space_token
1998 \bool_set_true:N \l_@@_peek_ignore_spaces_bool
1999 \exp_after:wN \peek_after:Nw
2000 \exp_after:wN \@@_peek_catcode_ignore_spaces_branches:w
2001 \tex_romannumeral:D 0
2002 \else:
2003 \if_catcode:w
2004 \exp_not:N \l_peek_token \exp_not:N \l_@@_peek_search_token
2005 \exp_after:wN \exp_after:wN
2006 \exp_after:wN \@@_peek_catcode_true:w
2007 \else:
2008 \exp_after:wN \exp_after:wN
2009 \exp_after:wN \@@_peek_catcode_false:w
2010 \fi:
2011 \fi:
2012 }
2013 \cs_new_eq:NN \l_@@_peek_search_token ?
2014 \cs_new_eq:NN \@@_peek_catcode_true:w \prg_do_nothing:
2015 \cs_new_eq:NN \@@_peek_catcode_false:w \prg_do_nothing:
2016 \bool_new:N \l_@@_peek_ignore_spaces_bool
2017 % \end{macrocode}
2018 % \end{macro}
2019 %
2020 % \changes{v3.8.0}{2020/02/10}{应用 \cs{peek_remove_spaces:n}。}
2021 %
2022 % \begin{macro}[int]{\xeCJK_token_value_class:N}
2023 % 用于取得记号 |#1| 所在的 \XeTeX 字符类。|#1| 应为 \tn{catcode} 为 |11| 或 |12|
2024 % 的显性或隐性记号。
2025 % \begin{macrocode}
2026 \cs_new:Npn \xeCJK_token_value_class:N #1
2027 { \tex_XeTeXcharclass:D \xeCJK_token_value_charcode:N #1 }
2028 % \end{macrocode}
2029 % \end{macro}
2030 %
2031 % \begin{macro}[int]{\xeCJK_token_value_charcode:N}
2032 % \changes{v3.2.4}{2013/06/30}{考虑 \texttt{charcode} 超出 BMP 的情况。}
2033 % \changes{v3.3.1}{2015/05/08}{\texttt{0.99992} 版修复了 \tn{meaning} 的 Bug。}
2034 % 当记号 |#1| 的 \texttt{charcode} 大于等于 \texttt{0x10000} 时,\XeTeX\
2035 % \texttt{0.9999.0} 版以前的 \tn{meaning} 的返回结果比较特殊\footnote{参见
2036 % \url{http://tug.org/pipermail/xetex/2013-January/023967.html} 和
2037 % \url{http://tex.stackexchange.com/a/64848}。},需要特别处理。
2038 % \texttt{0.9999.0} 版以后的 \XeTeX 的 \tn{meaning}
2039 % 对于超出 BMP 的字符,会返回两个字符,分别对应于其 UTF-16 编码的首尾代理^^A
2040 % \footnote{参见 \url{http://tug.org/pipermail/xetex/2013-June/024543.html}。}。
2041 % 这一 Bug 在 TeX Live 2015 的 \texttt{0.99992} 版中得到修复^^A
2042 % \footnote{参见\url{http://tug.org/pipermail/xetex/2015-May/025941.html}}。
2043 % \begin{macrocode}
2044 \cs_new:Npn \xeCJK_token_value_charcode:N #1
2045 { \exp_after:wN \@@_get_charcode:w \token_to_meaning:N #1 \q_stop }
2046 \group_begin:
2047 \cs_set:Npn \@@_tmp:w #1 ~ #2 ~ #3#4#5 \q_stop
2048 {
2049 \tl_if_empty:nTF { #4#5 }
2050 {
2051 \cs_new:Npn \@@_get_charcode:w ##1 ~ ##2 ~ ##3 \q_stop
2052 { \int_eval:n { `##3 } }
2053 }
2054 {
2055 \tl_if_empty:nTF {#5}
2056 {
2057 \cs_new:Npn \@@_get_charcode:w ##1 ~ ##2 ~ ##3##4 \q_stop
2058 {
2059 \int_eval:n
2060 {
2061 \tl_if_empty:nTF { ##4 }
2062 { `##3 }
2063 { ( `##3 - "D800 ) * "400 + ( `##4 - "DC00 ) + "10000 }
2064 }
2065 }
2066 }
2067 {
2068 \cs_new:Npn \@@_get_charcode:w ##1 ~ ##2 ~ ##3##4 \q_stop
2069 { \int_eval:n { \tl_if_empty:nTF { ##4 } { `##3 } { "20000 } } }
2070 }
2071 }
2072 }
2073 \exp_after:wN \@@_tmp:w \token_to_meaning:N ^^^^^20000 { } \q_stop
2074 \group_end:
2075 % \end{macrocode}
2076 % \end{macro}
2077 %
2078 % \begin{macro}[pTF,int]{\xeCJK_if_CJK_class:N}
2079 % 判断字符 |#1| 是否为 CJK 字符类,包括文字和标点符号。
2080 % \begin{macrocode}
2081 \prg_new_conditional:Npnn \xeCJK_if_CJK_class:N #1 { p , T , F , TF }
2082 {
2083 \if_cs_exist:w
2084 \@@_CJK_class_tl:n { \xeCJK_token_value_class:N #1 }
2085 \cs_end:
2086 \prg_return_true: \else: \prg_return_false: \fi:
2087 }
2088 \cs_new:Npn \@@_CJK_class_tl:n #1
2089 { c_@@_CJK_class_ \int_eval:n {#1} _tl }
2090 % \end{macrocode}
2091 % \end{macro}
2092 %
2093 % \begin{macro}[pTF,int]{\xeCJK_if_same_class:NN}
2094 % 判断两个字符是否同属于一个字符类。
2095 % \begin{macrocode}
2096 \prg_new_conditional:Npnn \xeCJK_if_same_class:NN #1#2 { p , T , F , TF }
2097 {
2098 \if_int_compare:w \xeCJK_token_value_class:N #1 =
2099 \xeCJK_token_value_class:N #2 \exp_stop_f:
2100 \prg_return_true: \else: \prg_return_false: \fi:
2101 }
2102 % \end{macrocode}
2103 % \end{macro}
2104 %
2105 % \begin{macro}[int]{\xeCJK_make_boundary:}
2106 % 利用 \cs{scan_stop:} 结束 CJK 分组,用于恢复字体等。
2107 % \begin{macrocode}
2108 \cs_new_protected:Npn \xeCJK_make_boundary:
2109 { \bool_if:NT \l_@@_CJK_group_bool { \scan_stop: } }
2110 % \end{macrocode}
2111 % \end{macro}
2112 %
2113 % \subsection{功能开关}
2114 %
2115 % \begin{macro}{xeCJKactive}
2116 % 事实上,将开启或关闭 \XeTeX 的整个字符类机制。
2117 % \begin{macrocode}
2118 \keys_define:nn { xeCJK / options }
2119 {
2120 xeCJKactive .choice: ,
2121 xeCJKactive / true .code:n = { \makexeCJKactive } ,
2122 xeCJKactive / false .code:n = { \makexeCJKinactive } ,
2123 xeCJKactive .default:n = { true }
2124 }
2125 % \end{macrocode}
2126 % \end{macro}
2127 %
2128 % \begin{macro}[int]{\makexeCJKactive, \makexeCJKinactive}
2129 % \begin{macrocode}
2130 \NewDocumentCommand \makexeCJKactive { }
2131 { \tex_XeTeXinterchartokenstate:D = \c_one_int }
2132 \NewDocumentCommand \makexeCJKinactive { }
2133 { \tex_XeTeXinterchartokenstate:D = \c_zero_int }
2134 % \end{macrocode}
2135 % \end{macro}
2136 %
2137 % 抑制 |BOM|。
2138 % \begin{macrocode}
2139 \char_set_catcode_ignore:n { "FEFF }
2140 % \end{macrocode}
2141 %
2142 % \subsection{字符类别设定}\label{sec:xeCJK-class-set}
2143 %
2144 % \begin{variable}{\g_@@_class_seq,\g_@@_new_class_seq}
2145 % 分别用于记录在 \pkg{xeCJK} 中使用的字符类别名称和新建的字符类别的编号。
2146 % \begin{macrocode}
2147 \seq_new:N \g_@@_class_seq
2148 \seq_new:N \g_@@_new_class_seq
2149 % \end{macrocode}
2150 % \end{variable}
2151 %
2152 % \begin{macro}[int]{\xeCJK_new_class:n}
2153 % 新建一个字符类别。|#1| 是自定义名称。
2154 % \begin{macrocode}
2155 \cs_new_protected:Npn \xeCJK_new_class:n #1
2156 {
2157 \int_if_exist:cTF { \@@_class_csname:n {#1} }
2158 { \@@_error:nx { class-already-defined } {#1} }
2159 {
2160 \exp_args:Nc \newXeTeXintercharclass
2161 { \@@_class_csname:n {#1} }
2162 \clist_new:c { g_@@_#1_range_clist }
2163 \seq_gput_right:Nn \g_@@_class_seq {#1}
2164 \seq_gput_right:Nv \g_@@_new_class_seq
2165 { \@@_class_csname:n {#1} }
2166 }
2167 }
2168 % \end{macrocode}
2169 % \end{macro}
2170 %
2171 % \begin{macro}[int]{\xeCJK_save_class:nn}
2172 % \changes{v3.1.1}{2012/12/06}
2173 % {使用 \cs{xeCJK_save_class:nn} 保存 \XeTeX 预定义的字符类别。}
2174 % 保存 \XeTeX 预定义的字符类别。|#1| 是自定义名称,|#2| 是编号。
2175 % \begin{macrocode}
2176 \cs_new_protected:Npn \xeCJK_save_class:nn #1#2
2177 {
2178 \int_if_exist:cTF { \@@_class_csname:n {#1} }
2179 { \@@_error:nx { class-already-defined } {#1} }
2180 {
2181 \int_const:cn { \@@_class_csname:n {#1} } {#2}
2182 \clist_new:c { g_@@_#1_range_clist }
2183 \seq_gput_right:Nn \g_@@_class_seq {#1}
2184 }
2185 }
2186 % \end{macrocode}
2187 % \end{macro}
2188 %
2189 % \begin{macro}{\@@_class_csname:n}
2190 % 字符类名称对应的控制序列名字。
2191 % \begin{macrocode}
2192 \cs_new:Npn \@@_class_csname:n #1 { c_@@_#1_class_int }
2193 \cs_new_eq:cN { \@@_class_csname:n { Others } } \l_@@_tmp_int
2194 \@@_msg_new:nn { class-already-defined }
2195 {
2196 XeTeX~character~class~`#1'~has~been~already~defined.\\\\
2197 Please~take~another~name. \\
2198 }
2199 % \end{macrocode}
2200 % \end{macro}
2201 %
2202 % \changes{v3.2.0}{2013/05/20}{增加 \texttt{IVS} 字符类用于处理异体字选择符。}
2203 % \changes{v3.3.1}{2015/01/22}{\texttt{IVS} 字符类更名为 \texttt{CM}。}
2204 %
2205 % \pkg{xeCJK} 需要以下字符类别用于字符输出。其中 |Default|、|CJK|、|FullLeft|、
2206 % |FullRight|、|Boundary| 为 \XeTeX\ 中预定义的类别,\pkg{xeCJK} 新增加了\
2207 % |HalfLeft|、|HalfRight|、|NormalSpace| 和 |CM|。其中异体字选择符
2208 % (Ideographic Variation Selectors)\footnote{\url{http://www.unicode.org/reports/tr37/}}
2209 % 需要 \XeTeX\ |0.9999.0| 以上的版本^^A
2210 % \footnote{\url{http://tug.org/pipermail/xetex/2013-March/024118.html}}和相关字体的支持。
2211 % \begin{center}\xeCJKsetup{PunctStyle=hangmobanjiao}
2212 % \begin{tabular}{cll}
2213 % \toprule
2214 % 类别 & 说明 & 例子 \\ \midrule
2215 % |Default| & 西文一般符号 & abc123 \\
2216 % |CJK| & CJK 表意符号 & 汉字ぁぃぅ \\
2217 % |FullLeft| & 全角左标点 & (《:“ \\
2218 % |FullRight| & 全角右标点 & ,。)》” \\
2219 % |HalfLeft| & 半角左标点 & ( [ \{ \\
2220 % |HalfRight| & 半角右标点 & , . ? ) ] \} \\
2221 % |NormalSpace| & 前后原始间距的符号 & / \\
2222 % |Boundary| & 边界 & 空格 \\
2223 % |CM| & 组合标识 & 异体字选择符\\
2224 % |HangulJamo| & 朝鲜文字母 & |ᄻ||ᆟ||ᇫ|\\
2225 % \bottomrule
2226 % \end{tabular}
2227 % \end{center}
2228 %
2229 % \changes{v3.3.3}{2016/01/20}{兼容 \LaTeXe{} 2016/02/01 的字符类设置。}
2230 % \changes{v3.3.4}{2016/02/07}{兼容 \XeTeX{} 0.99994 的边界字符类。}
2231 % \begin{macro}[int]{Default,CJK,FullLeft,FullRight,Boundary}
2232 % \begin{macrocode}
2233 \xeCJK_save_class:nn { Default } { 0 }
2234 % \end{macrocode}
2235 % \XeTeX{} 0.99994 将字符类总数扩大到 $4096$^^A
2236 % \footnote{\url{http://tug.org/pipermail/xetex/2016-February/026363.html}}。
2237 % \begin{macrocode}
2238 \str_const:Nx \c_@@_xetex_version_str
2239 { \int_use:N \tex_XeTeXversion:D \tex_XeTeXrevision:D }
2240 \fp_compare:nNnTF { \c_@@_xetex_version_str } > { 0.99993 }
2241 { \xeCJK_save_class:nn { Boundary } { 4095 } }
2242 { \xeCJK_save_class:nn { Boundary } { 255 } }
2243 % \end{macrocode}
2244 % \LaTeXe{} 2016/02/01 不再预设置 CJK 字符类。
2245 % \begin{macrocode}
2246 \int_compare:nNnTF { \tex_XeTeXcharclass:D "4E00 } = \c_one_int
2247 {
2248 \xeCJK_save_class:nn { CJK } { 1 }
2249 \xeCJK_save_class:nn { FullLeft } { 2 }
2250 \xeCJK_save_class:nn { FullRight } { 3 }
2251 \int_const:Nn \c_@@_class_begin_int { 3 }
2252 }
2253 {
2254 \xeCJK_new_class:n { CJK }
2255 \xeCJK_new_class:n { FullLeft }
2256 \xeCJK_new_class:n { FullRight }
2257 \int_const:Nn \c_@@_class_begin_int { 0 }
2258 }
2259 % \end{macrocode}
2260 % \end{macro}
2261 %
2262 % \changes{v3.2.15}{2014/11/10}{增加 \texttt{HangulJamo} 字符类。}
2263 %
2264 % \begin{macro}[int]{HalfLeft,HalfRight,NormalSpace,CM,HangulJamo}
2265 % 新增西文半角左/右标点、前后原始间距的符号和异体字选择符类。
2266 % \begin{macrocode}
2267 \xeCJK_new_class:n { HalfLeft }
2268 \xeCJK_new_class:n { HalfRight }
2269 \xeCJK_new_class:n { NormalSpace }
2270 \xeCJK_new_class:n { CM }
2271 \xeCJK_new_class:n { HangulJamo }
2272 % \end{macrocode}
2273 % \end{macro}
2274 %
2275 % \changes{v3.2.11}{2014/04/10}
2276 % {左右角括号 \texttt{U+2329} 和 \texttt{U+232A} 是西文标点符号。}
2277 % \changes{v3.2.15}{2014/11/09}
2278 % {把 REVERSE SOLIDUS(\texttt{U+005C})、HYPHEN-MINUS(\texttt{U+002D})和
2279 % EN DASH(\texttt{U+2013})归入 \texttt{NormalSpace} 类。}
2280 %
2281 % \begin{variable}
2282 % {\c_@@_HalfLeft_chars_clist,\c_@@_HalfRight_chars_clist,\c_@@_NormalSpace_chars_clist}
2283 % \hypertarget{CJKcharclass}{西文半角左/右标点和前后原始间距的字符类。}
2284 % \begin{macrocode}
2285 \clist_const:Nn \c_@@_HalfLeft_chars_clist
2286 { "28 , "5B , "60 , "7B , "2329 }
2287 \clist_const:Nn \c_@@_HalfRight_chars_clist
2288 { "21 , "22 , "25 , "27 , "29 , "2C , "2E , "3A , "3B , "3F , "5D , "7D , "232A }
2289 \clist_const:Nn \c_@@_NormalSpace_chars_clist { "2D , "2F , "5C }
2290 % \end{macrocode}
2291 % \end{variable}
2292 %
2293 % 以下对全角标点符号的归类来源于 \XeTeX 的脚本
2294 % \href{http://sourceforge.net/p/xetex/code/ci/master/tree/source/texk/web2c/xetexdir/unicode-char-prep.pl}
2295 % {\file{unicode-char-prep.pl}} 和 Unicode 数据库\footnote{\url{http://www.unicode.org/reports/tr14/}}。
2296 %
2297 % \changes{v3.2.3}{2013/06/09}{根据 \XeTeX 的脚本重新整理全角标点符号。}
2298 %
2299 % \begin{variable}{\c_@@_OP_chars_clist}
2300 % Open Punctuation (OP)
2301 % \PrintPunctList{OP}{Open Punctuation}
2302 % 以下代码的第一行是中西文共用的左引号。
2303 % \begin{macrocode}
2304 \clist_const:Nn \c_@@_OP_chars_clist
2305 {
2306 "2018 , "201C ,
2307 "3008 , "300A , "300C , "300E , "3010 , "3014 , "3016 , "3018 , "301A , "301D ,
2308 "FE17 , "FE35 , "FE37 , "FE39 , "FE3B , "FE3D , "FE3F , "FE41 , "FE43 , "FE47 ,
2309 "FE59 , "FE5B , "FE5D , "FF08 , "FF3B , "FF5B , "FF5F , "FF62
2310 }
2311 % \end{macrocode}
2312 % \end{variable}
2313 %
2314 % \begin{variable}{\c_@@_PR_chars_clist}
2315 % \changes{v3.3.0}{2014/12/26}{不把 \texttt{U+20A9} 归入 CJK 的 PR 类。}
2316 % Prefix Numeric (PR)
2317 % \PrintPunctList{PR}{Prefix Numeric}
2318 % \begin{macrocode}
2319 \clist_const:Nn \c_@@_PR_chars_clist
2320 { "FE69 , "FF04 , "FFE1 , "FFE5 , "FFE6 }
2321 % \end{macrocode}
2322 % \end{variable}
2323 %
2324 % \begin{variable}{\c_@@_FullLeft_chars_clist}
2325 % 以上两类标点符号出现在文字的左边,不应出现在行尾位置。
2326 % \begin{macrocode}
2327 \clist_new:N \c_@@_FullLeft_chars_clist
2328 \clist_gconcat:NNN \c_@@_FullLeft_chars_clist
2329 \c_@@_OP_chars_clist
2330 \c_@@_PR_chars_clist
2331 % \end{macrocode}
2332 % \end{variable}
2333 %
2334 % \changes{v3.3.3}{2015/12/12}
2335 % {把 EN DASH(\texttt{U+2013})作为半字线连接号归入 \texttt{FullRight} 类。}
2336 % \changes{v3.3.3}{2015/12/12}
2337 % {不再把 \texttt{U+2015} 和 \texttt{U+2500} 归入 \texttt{FullRight} 类。}
2338 % \changes{v3.6.0}{2018/01/14}
2339 % {把 TWO-EM DASH (\texttt{U+2E3A}) 归入 \texttt{FullRight} 类和设为
2340 % \texttt{LongPunct} 与 \texttt{MiddlePunct}。}
2341 %
2342 % \begin{variable}{\c_@@_CL_chars_clist}
2343 % Close Punctuation (CL)
2344 % \PrintPunctList{CL}{Close Punctuation}
2345 % 以下代码的第一行是中西文共用的一些标点符号。
2346 % \begin{macrocode}
2347 \clist_const:Nn \c_@@_CL_chars_clist
2348 {
2349 "00B7 , "2019 , "201D , "2013 , "2014 , "2025 , "2026 , "2027 , "2E3A ,
2350 "3001 , "3002 , "3009 , "300B , "300D , "300F , "3011 , "3015 , "3017 , "3019 ,
2351 "301B , "301E , "301F , "FE11 , "FE12 , "FE18 , "FE36 , "FE38 , "FE3A , "FE3C ,
2352 "FE3E , "FE40 , "FE42 , "FE44 , "FE48 , "FE50 , "FE52 , "FE5A , "FE5C , "FE5E ,
2353 "FF09 , "FF0C , "FF0E , "FF3D , "FF5D , "FF60 , "FF61 , "FF63 , "FF64
2354 }
2355 % \end{macrocode}
2356 % \end{variable}
2357 %
2358 % \changes{v3.3.0}{2014/12/26}{不把 NS 类中的一些有禁则的日文归入 \texttt{FullRight} 类。}
2359 % \changes{v3.6.0}{2018/01/14}
2360 % {将全角浪线 \texttt{U+FF5E} 等连接号归入 \texttt{FullRight} 类和设为 \texttt{MiddlePunct}。}
2361 %
2362 % \begin{variable}{\c_@@_NS_chars_clist}
2363 % Nonstarter (NS)
2364 % \PrintPunctList{NS}{Nonstarter}
2365 % \noindent Hyphens (cl-03)
2366 % \PrintPunctList{hyphens}{Hyphens}
2367 % \noindent Iteration marks (cl-09)
2368 % \PrintPunctList{iteration_marks}{Iteration marks}
2369 % 根据 W3C 的资料\footnote{\url{http://www.w3.org/TR/jlreq/}},\texttt{cl-03} 和
2370 % \texttt{cl-09} 在非常松散的情况下可以没有禁则。我们仅将全角浪线 \texttt{U+FF5E} 等连接号归入
2371 % \texttt{FullRight} 类并在宏包末尾设为 \texttt{MiddlePunct}。
2372 % \begin{macrocode}
2373 \clist_const:Nn \c_@@_hyphens_chars_clist
2374 { "301C , "30A0 , "FF5E }
2375 \clist_const:Nn \c_@@_iteration_marks_chars_clist
2376 { "3005 , "303B , "309D , "309E , "30FD , "30FE }
2377 \clist_const:Nn \c_@@_NS_chars_clist
2378 { "30FB , "FE54 , "FE55 , "FF1A , "FF1B , "FF65 , "16FE0 }
2379 \AtEndOfPackage
2380 {
2381 \cs_set:Npn \@@_tmp:w #1
2382 { \char_generate:nn {#1} { 12 } }
2383 \@@_add_special_punct:nn { middle }
2384 { \clist_map_function:NN \c_@@_hyphens_chars_clist \@@_tmp:w }
2385 \cs_undefine:N \@@_tmp:w
2386 }
2387 % \end{macrocode}
2388 % \end{variable}
2389 %
2390 % \begin{variable}{\c_@@_EX_chars_clist}
2391 % Exclamation/Interrogation (EX)
2392 % \PrintPunctList{EX}{Exclamation/Interrogation}
2393 % \begin{macrocode}
2394 \clist_const:Nn \c_@@_EX_chars_clist
2395 { "FE15 , "FE16 , "FE56 , "FE57 , "FF01 , "FF1F }
2396 % \end{macrocode}
2397 % \end{variable}
2398 %
2399 % \begin{variable}{\c_@@_IS_chars_clist}
2400 % Infix Numeric Separator (IS)
2401 % \PrintPunctList{IS}{Infix Numeric Separator}
2402 % \begin{macrocode}
2403 \clist_const:Nn \c_@@_IS_chars_clist { "FE10 , "FE13 , "FE14 }
2404 % \end{macrocode}
2405 % \end{variable}
2406 %
2407 % \begin{variable}{\c_@@_CJ_chars_clist}
2408 % Conditional Japanese Starter (CJ)。这类字符的禁则是可选的^^A
2409 % \footnote{\url{https://github.com/CTeX-org/ctex-kit/issues/165}},
2410 % 为实现的简单计,我们把它们归入 CJK 类,即没有禁则。
2411 % \PrintPunctList{CJ}{Conditional Japanese Starter}
2412 % \begin{macrocode}
2413 \clist_const:Nn \c_@@_CJ_chars_clist
2414 {
2415 "3041 , "3043 , "3045 , "3047 , "3049 , "3063 , "3083 , "3085 , "3087 , "308E ,
2416 "3095 , "3096 , "30A1 , "30A3 , "30A5 , "30A7 , "30A9 , "30C3 , "30E3 , "30E5 ,
2417 "30E7 , "30EE , "30F5 , "30F6 , "30FC , "31F0 , "31F1 , "31F2 , "31F3 , "31F4 ,
2418 "31F5 , "31F6 , "31F7 , "31F8 , "31F9 , "31FA , "31FB , "31FC , "31FD , "31FE ,
2419 "31FF , "FF67 , "FF68 , "FF69 , "FF6A , "FF6B , "FF6C , "FF6D , "FF6E , "FF6F ,
2420 "FF70
2421 }
2422 % \end{macrocode}
2423 % \end{variable}
2424 %
2425 % \begin{variable}{\c_@@_PO_chars_clist}
2426 % Postfix Numeric (PO)
2427 % \PrintPunctList{PO}{Postfix Numeric}
2428 % \begin{macrocode}
2429 \clist_const:Nn \c_@@_PO_chars_clist { "FE6A , "FF05 , "FFE0 }
2430 % \end{macrocode}
2431 % \end{variable}
2432 %
2433 % \changes{v3.3.0}{2014/12/26}{不把小写日文假名归入 \texttt{FullRight} 类。}
2434 %
2435 % \begin{variable}{\c_@@_FullRight_chars_clist}
2436 % 以上六类标点符号出现在文字的右边,不应出现在行首位置。
2437 % \begin{macrocode}
2438 \clist_new:N \c_@@_FullRight_chars_clist
2439 \tl_map_inline:nn
2440 {
2441 \c_@@_CL_chars_clist
2442 \c_@@_NS_chars_clist
2443 \c_@@_EX_chars_clist
2444 \c_@@_IS_chars_clist
2445 \c_@@_PO_chars_clist
2446 \c_@@_hyphens_chars_clist
2447 }
2448 {
2449 \clist_gconcat:NNN \c_@@_FullRight_chars_clist
2450 \c_@@_FullRight_chars_clist #1
2451 }
2452 % \end{macrocode}
2453 % \end{variable}
2454 %
2455 % \changes{v3.3.3}{2015/06/25}{补充 Ext-E。}
2456 % \changes{v3.4.1}{2016/08/18}{补充 Unicode 9.0.0 的西夏文。}
2457 % \changes{v3.5.0}{2017/07/22}{补充 Ext-F。}
2458 % \changes{v3.7.3}{2019/04/15}{补充日文假名扩展。}
2459 % \changes{v3.8.3}{2020/03/15}{同步 Unicode 13.0.0。}
2460 % \changes{v3.8.3}{2020/04/09}{补充 \texttt{U+02EA} 和 \texttt{U+02EB}。}
2461 % \changes{v3.8.8}{2021/09/15}{同步 Unicode 14.0.0。}
2462 % \changes{v3.8.8}{2021/09/16}{补充女书。}
2463 %
2464 % \begin{variable}{\c_@@_CJK_chars_clist}
2465 % CJK 字符类,包括文字和标点符号。
2466 % \begin{macrocode}
2467 \clist_const:Nn \c_@@_CJK_chars_clist
2468 {
2469 % \end{macrocode}
2470 % \begin{itemize}[nosep,leftmargin=0pt]
2471 % \item 闽南语、客家话阴去和阳去声调标记
2472 % \begin{macrocode}
2473 "02EA -> "02EB ,
2474 % \end{macrocode}
2475 % \item CJK Radicals Supplement (中日韩部首补充)
2476 % \begin{macrocode}
2477 "2E80 -> "2EFF ,
2478 % \end{macrocode}
2479 % \item Kangxi Radicals (康熙部首)
2480 % \begin{macrocode}
2481 "2F00 -> "2FDF ,
2482 % \end{macrocode}
2483 % \item Ideographic Description Characters (表意文字描述符)
2484 % \begin{macrocode}
2485 "2FF0 -> "2FFF ,
2486 % \end{macrocode}
2487 % \item CJK Symbols and Punctuation (中日韩符号和标点)
2488 % \begin{macrocode}
2489 "3000 -> "303F ,
2490 % \end{macrocode}
2491 % \item Hiragana (日文平假名)
2492 % \begin{macrocode}
2493 "3040 -> "309F ,
2494 % \end{macrocode}
2495 % \item Katakana (日文片假名)
2496 % \begin{macrocode}
2497 "30A0 -> "30FF ,
2498 % \end{macrocode}
2499 % \item Bopomofo (注音字母)
2500 % \begin{macrocode}
2501 "3100 -> "312F ,
2502 % \end{macrocode}
2503 % \item Hangul Compatibility Jamo (谚文兼容字母)
2504 % \begin{macrocode}
2505 "3130 -> "318F ,
2506 % \end{macrocode}
2507 % \item Kanbun (象形字注释标志)
2508 % \begin{macrocode}
2509 "3190 -> "319F ,
2510 % \end{macrocode}
2511 % \item Bopomofo Extended (注音字母扩展)
2512 % \begin{macrocode}
2513 "31A0 -> "31BF ,
2514 % \end{macrocode}
2515 % \item CJK Strokes (中日韩笔画)
2516 % \begin{macrocode}
2517 "31C0 -> "31EF ,
2518 % \end{macrocode}
2519 % \item Katakana Phonetic Extensions (日文片假名语音扩展)
2520 % \begin{macrocode}
2521 "31F0 -> "31FF ,
2522 % \end{macrocode}
2523 % \item Enclosed CJK Letters and Months (带圈中日韩字母和月份)
2524 % \begin{macrocode}
2525 "3200 -> "32FF ,
2526 % \end{macrocode}
2527 % \item CJK Compatibility (中日韩兼容)
2528 % \begin{macrocode}
2529 "3300 -> "33FF ,
2530 % \end{macrocode}
2531 % \item CJK Unified Ideographs Extension-A (中日韩统一表意文字扩展 A)
2532 % \begin{macrocode}
2533 "3400 -> "4DBF ,
2534 % \end{macrocode}
2535 % \item Yijing Hexagrams Symbols (易经六十四卦符号)
2536 % \begin{macrocode}
2537 "4DC0 -> "4DFF ,
2538 % \end{macrocode}
2539 % \item CJK Unified Ideographs (中日韩统一表意文字)
2540 % \begin{macrocode}
2541 "4E00 -> "9FFF ,
2542 % \end{macrocode}
2543 % \item Yi Syllables (彝文音节)
2544 % \begin{macrocode}
2545 "A000 -> "A48F ,
2546 % \end{macrocode}
2547 % \item Yi Radicals (彝文字根)
2548 % \begin{macrocode}
2549 "A490 -> "A4CF ,
2550 % \end{macrocode}
2551 % \item Hangul Syllables (谚文音节)
2552 % \begin{macrocode}
2553 "AC00 -> "D7AF ,
2554 % \end{macrocode}
2555 % \item CJK Compatibility Ideographs (中日韩兼容表意文字)
2556 % \begin{macrocode}
2557 "F900 -> "FAFF ,
2558 % \end{macrocode}
2559 % \item Vertical Forms (竖排形式)
2560 % \begin{macrocode}
2561 "FE10 -> "FE1F ,
2562 % \end{macrocode}
2563 % \item CJK Compatibility Forms (中日韩兼容形式)
2564 % \begin{macrocode}
2565 "FE30 -> "FE4F ,
2566 % \end{macrocode}
2567 % \item Halfwidth and Fullwidth Forms (半角及全角形式)
2568 % \begin{macrocode}
2569 "FF00 -> "FFEF ,
2570 % \end{macrocode}
2571 % \item Ideographic Symbols and Punctuation (表意文字符号及标点)
2572 % \begin{macrocode}
2573 "16FE0 -> "16FFF ,
2574 % \end{macrocode}
2575 % \item Tangut (西夏文)
2576 % \begin{macrocode}
2577 "17000 -> "187FF ,
2578 % \end{macrocode}
2579 % \item Tangut Components (西夏文部首)
2580 % \begin{macrocode}
2581 "18800 -> "18AFF ,
2582 % \end{macrocode}
2583 % \item Khitan Small Script (契丹小字)
2584 % \begin{macrocode}
2585 "18B00 -> "18CFF ,
2586 % \end{macrocode}
2587 % \item Tangut Supplement (西夏文增补)
2588 % \begin{macrocode}
2589 "18D00 -> "18D7F ,
2590 % \end{macrocode}
2591 % \item Kana Extended-B (日文假名扩展 B)
2592 % \begin{macrocode}
2593 "1AFF0 -> "1AFFF ,
2594 % \end{macrocode}
2595 % \item Kana Supplement (日文假名增补)
2596 % \begin{macrocode}
2597 "1B000 -> "1B0FF ,
2598 % \end{macrocode}
2599 % \item Kana Extended-A (日文假名扩展 A)
2600 % \begin{macrocode}
2601 "1B100 -> "1B12F ,
2602 % \end{macrocode}
2603 % \item Small Kana Extension (小型日文假名扩展)
2604 % \begin{macrocode}
2605 "1B130 -> "1B16F ,
2606 % \end{macrocode}
2607 % \item Nushu (女书)
2608 % \begin{macrocode}
2609 "1B170 -> "1B2FF ,
2610 % \end{macrocode}
2611 % \item Enclosed Ideographic Supplement (带圈表意文字增补)
2612 % \begin{macrocode}
2613 "1F200 -> "1F2FF ,
2614 % \end{macrocode}
2615 % \item CJK Unified Ideographs Extension-B (中日韩统一表意文字扩展 B)
2616 % \begin{macrocode}
2617 "20000 -> "2A6DF ,
2618 % \end{macrocode}
2619 % \item CJK Unified Ideographs Extension-C (中日韩统一表意文字扩展 C)
2620 % \begin{macrocode}
2621 "2A700 -> "2B73F ,
2622 % \end{macrocode}
2623 % \item CJK Unified Ideographs Extension-D (中日韩统一表意文字扩展 D)
2624 % \begin{macrocode}
2625 "2B740 -> "2B81F ,
2626 % \end{macrocode}
2627 % \item CJK Unified Ideographs Extension-E (中日韩统一表意文字扩展 E)
2628 % \begin{macrocode}
2629 "2B820 -> "2CEAF ,
2630 % \end{macrocode}
2631 % \item CJK Unified Ideographs Extension-F (中日韩统一表意文字扩展 F)
2632 % \begin{macrocode}
2633 "2CEB0 -> "2EBEF ,
2634 % \end{macrocode}
2635 % \item CJK Compatibility Ideographs Supplement (中日韩兼容表意文字增补)
2636 % \begin{macrocode}
2637 "2F800 -> "2FA1F ,
2638 % \end{macrocode}
2639 % \item CJK Unified Ideographs Extension-G (中日韩统一表意文字扩展 G)
2640 % \begin{macrocode}
2641 "30000 -> "3134F
2642 % \end{macrocode}
2643 % \end{itemize}
2644 % \begin{macrocode}
2645 }
2646 % \end{macrocode}
2647 % \end{variable}
2648 %
2649 % \begin{variable}{\c_@@_CM_chars_clist}
2650 % \changes{v3.3.1}{2015/01/22}{补充音调符号。}
2651 % 包括日文假名浊点和异体字选择符。组合标识是最好是归入 256 类,即透明类,不会影响
2652 % 状态。但也会产生一定问题。比如下面的例子,位于行尾的“二”造成分组不匹配。
2653 % \begin{verbatim}
2654 % \XeTeXinterchartokenstate=1
2655 % \XeTeXcharclass`二=256
2656 % \XeTeXinterchartoks 255 1 = {\bgroup}
2657 % \XeTeXinterchartoks 1 255 = {\egroup}
2658 % \XeTeXinterchartoks 1 1 = {x}
2659 % \font\zhfont="SimSun"
2660 % \zhfont
2661 % 一二三二
2662 % \bye
2663 % \end{verbatim}
2664 % \begin{macrocode}
2665 \clist_const:Nn \c_@@_CM_chars_clist
2666 {
2667 % \end{macrocode}
2668 % \begin{itemize}[nosep,leftmargin=0pt]
2669 % \item Diacritics (音调符号)
2670 % \begin{macrocode}
2671 "302A -> "302F ,
2672 % \end{macrocode}
2673 % \item 日文假名浊点
2674 % \begin{macrocode}
2675 "3099 -> "309A ,
2676 % \end{macrocode}
2677 % \item Variation Selectors (异体字选择符)
2678 % \begin{macrocode}
2679 "FE00 -> "FE0F ,
2680 % \end{macrocode}
2681 % \item Variation Selectors Supplement (异体字选择符增补)
2682 % \begin{macrocode}
2683 "E0100 -> "E01EF
2684 % \end{macrocode}
2685 % \end{itemize}
2686 % \begin{macrocode}
2687 }
2688 % \end{macrocode}
2689 % \end{variable}
2690 %
2691 % \begin{variable}{\c_@@_HangulJamo_chars_clist}
2692 % 朝鲜文字母。
2693 % \begin{macrocode}
2694 \clist_const:Nn \c_@@_HangulJamo_chars_clist
2695 {
2696 % \end{macrocode}
2697 % \begin{itemize}[nosep,leftmargin=0pt]
2698 % \item Hangul Jamo (谚文字母)
2699 % \begin{macrocode}
2700 "1100 -> "11FF ,
2701 % \end{macrocode}
2702 % \item Hangul Jamo Extended-A (谚文扩展 A)
2703 % \begin{macrocode}
2704 "A960 -> "A97F ,
2705 % \end{macrocode}
2706 % \item Hangul Jamo Extended-B (谚文扩展 B)
2707 % \begin{macrocode}
2708 "D7B0 -> "D7FF
2709 % \end{macrocode}
2710 % \end{itemize}
2711 % \begin{macrocode}
2712 }
2713 % \end{macrocode}
2714 % \end{variable}
2715 %
2716 % \subsection{字符类别处理}
2717 %
2718 % \begin{macro}[int]{\xeCJK_class_num:n}
2719 % |#1| 为字符类别名称,用于取得字符类别对应的编号。
2720 % \begin{macrocode}
2721 \cs_new:Npn \xeCJK_class_num:n #1
2722 { \use:c { \@@_class_csname:n {#1} } }
2723 % \end{macrocode}
2724 % \end{macro}
2725 %
2726 % \begin{macro}{\xeCJKDeclareCharClass}
2727 % \begin{macrocode}
2728 \NewDocumentCommand \xeCJKDeclareCharClass { s > { \TrimSpaces } m m }
2729 {
2730 \xeCJK_declare_char_class:nn {#2} {#3}
2731 \IfBooleanT {#1} { \xeCJKResetPunctClass }
2732 }
2733 % \end{macrocode}
2734 % \end{macro}
2735 %
2736 % \begin{macro}[int]{\xeCJK_declare_char_class:nn,\xeCJK_declare_char_class:nN}
2737 % \begin{macro}{\@@_set_char_class_aux:Nnw}
2738 % 用于设置字符所属的类别,|#1| 为类别名称,|#2| 为字符的 |Unicode|,相邻字符用
2739 % 半角逗号隔开,支持类似 |"1100 -> "11FF| 起止范围的使用方式。
2740 % \begin{macrocode}
2741 \cs_new_protected:Npn \xeCJK_declare_char_class:nn #1#2
2742 {
2743 \clist_set:Nx \l_@@_tmp_clist {#2}
2744 \xeCJK_declare_char_class:nN {#1} \l_@@_tmp_clist
2745 }
2746 \cs_new_protected:Npn \xeCJK_declare_char_class:nN #1#2
2747 {
2748 \clist_gconcat:ccN
2749 { g_@@_#1_range_clist } { g_@@_#1_range_clist } #2
2750 \clist_map_inline:Nn #2
2751 {
2752 \str_if_eq:nnF {##1} { -> }
2753 {
2754 \@@_set_char_class_aux:Nnw \xeCJK_set_char_class:nnn {##1}
2755 { \xeCJK_class_num:n {#1} }
2756 }
2757 }
2758 \xeCJK_set_char_class:nnn { "3099 } { "309A } { \xeCJK_class_num:n { CM } }
2759 }
2760 \NewDocumentCommand \@@_set_char_class_aux:Nnw
2761 { m > { \SplitArgument { 1 } { -> } } m } { #1 #2 }
2762 \cs_generate_variant:Nn \clist_gconcat:NNN { cc }
2763 % \end{macrocode}
2764 % \end{macro}
2765 % \end{macro}
2766 %
2767 % \begin{macro}{\@@_check_num_range:nnNN}
2768 % \begin{macrocode}
2769 \cs_new_protected:Npn \@@_check_num_range:nnNN #1#2#3#4
2770 {
2771 \bool_lazy_or:nnTF
2772 { \tl_if_blank_p:n {#1} }
2773 { \tl_if_blank_p:n {#2} }
2774 {
2775 \int_set:Nn #3 { \tl_if_blank:nTF {#1} {#2} {#1} }
2776 \int_set_eq:NN #3 #4
2777 }
2778 {
2779 \int_set:Nn #3 { \int_min:nn {#1} { \tl_if_novalue:nTF {#2} {#1} {#2} } }
2780 \int_set:Nn #4 { \int_max:nn {#1} { \tl_if_novalue:nTF {#2} {#1} {#2} } }
2781 }
2782 }
2783 % \end{macrocode}
2784 % \end{macro}
2785 %
2786 % \changes{v3.2.3}{2013/06/08}{不再改变 CJK 字符类的 \tn{catcode}。}
2787 % \changes{v3.2.7}{2013/08/29}{修正 \file{unicode-letters.tex} 中谚文符号
2788 % \tn{catcode} 不准的问题。}
2789 % \begin{macrocode}
2790 \token_if_letter:NF ^^^^ac00
2791 {
2792 \int_set:Nn \l_@@_begin_int { "AC00 }
2793 \int_set:Nn \l_@@_end_int { "D7A3 }
2794 \xeCJK_int_until_do:nn { \l_@@_begin_int > \l_@@_end_int }
2795 {
2796 \char_set_catcode_letter:n { \l_@@_begin_int }
2797 \int_incr:N \l_@@_begin_int
2798 }
2799 }
2800 % \end{macrocode}
2801 %
2802 % \begin{macro}[int]{\xeCJK_set_char_class:nnn}
2803 % \changes{v3.1.1}{2012/12/05}{在文档中设置字符类别时不重复设置 \tn{catcode}。}
2804 % 设置字符类别,|#1| 和 |#2| 为字符类别起止的 |Unicode|,|#3| 为类别名称对应编号。
2805 % \begin{macrocode}
2806 \cs_new_protected:Npn \xeCJK_set_char_class:nnn #1#2#3
2807 {
2808 \@@_check_num_range:nnNN {#1} {#2} \l_@@_begin_int \l_@@_end_int
2809 \int_set:Nn \l_@@_tmp_int {#3}
2810 \xeCJK_int_until_do:nn { \l_@@_begin_int > \l_@@_end_int }
2811 {
2812 \tex_XeTeXcharclass:D \l_@@_begin_int = \l_@@_tmp_int
2813 \int_incr:N \l_@@_begin_int
2814 }
2815 }
2816 % \end{macrocode}
2817 % \end{macro}
2818 %
2819 % \begin{macro}{\@@_set_char_class_eq:nn}
2820 % \changes{v3.1.1}{2012/12/06}{交换参数的顺序。}
2821 % 将字符类 |#1| 中的字符全部设置成字符类 |#2|。只适用于 |#1| 的字符类范围为离散的
2822 % 逗号列表的情况。
2823 % \begin{macrocode}
2824 \cs_new_protected:Npn \@@_set_char_class_eq:nn #1#2
2825 {
2826 \int_set:Nn \l_@@_tmp_int { \xeCJK_class_num:n {#2} }
2827 \clist_map_inline:cn { c_@@_#1_chars_clist }
2828 { \tex_XeTeXcharclass:D ##1 = \l_@@_tmp_int }
2829 }
2830 % \end{macrocode}
2831 % \end{macro}
2832 %
2833 % \begin{macro}{\normalspacedchars}
2834 % 声明前后不加间距的字符。
2835 % \begin{macrocode}
2836 \NewDocumentCommand \normalspacedchars { m }
2837 {
2838 \tl_map_inline:nn {#1}
2839 { \tex_XeTeXcharclass:D `##1 = \xeCJK_class_num:n { NormalSpace } }
2840 }
2841 % \end{macrocode}
2842 % \end{macro}
2843 %
2844 % \begin{macro}{\xeCJKResetPunctClass}
2845 % 用于重置标点符号所属的字符类。
2846 % \begin{macrocode}
2847 \NewDocumentCommand \xeCJKResetPunctClass { }
2848 {
2849 \clist_gclear:N \g_@@_HalfLeft_range_clist
2850 \clist_gclear:N \g_@@_HalfRight_range_clist
2851 \clist_gclear:N \g_@@_FullLeft_range_clist
2852 \clist_gclear:N \g_@@_FullRight_range_clist
2853 \xeCJK_declare_char_class:nN { HalfLeft } \c_@@_HalfLeft_chars_clist
2854 \xeCJK_declare_char_class:nN { HalfRight } \c_@@_HalfRight_chars_clist
2855 \xeCJK_declare_char_class:nN { FullLeft } \c_@@_FullLeft_chars_clist
2856 \xeCJK_declare_char_class:nN { FullRight } \c_@@_FullRight_chars_clist
2857 }
2858 % \end{macrocode}
2859 % \end{macro}
2860 %
2861 %
2862 % \begin{macro}{\xeCJKResetCharClass}
2863 % 用于恢复 \pkg{xeCJK} 对字符类别的设置。
2864 % \begin{macrocode}
2865 \NewDocumentCommand \xeCJKResetCharClass { }
2866 {
2867 \clist_gclear:N \g_@@_CJK_range_clist
2868 \clist_gclear:N \g_@@_NormalSpace_range_clist
2869 \clist_gclear:N \g_@@_CM_range_clist
2870 \clist_gclear:N \g_@@_HangulJamo_range_clist
2871 \xeCJK_declare_char_class:nN { CJK } \c_@@_CJK_chars_clist
2872 \xeCJK_declare_char_class:nN { NormalSpace } \c_@@_NormalSpace_chars_clist
2873 \xeCJK_declare_char_class:nN { CM } \c_@@_CM_chars_clist
2874 \xeCJK_declare_char_class:nN { HangulJamo } \c_@@_HangulJamo_chars_clist
2875 \xeCJKResetPunctClass
2876 }
2877 % \end{macrocode}
2878 % \end{macro}
2879 %
2880 % 设置字符类别。
2881 % \begin{macrocode}
2882 \xeCJKResetCharClass
2883 % \end{macrocode}
2884 %
2885 % \begin{macro}[int]{\xeCJK_inter_class_toks:nnn}
2886 % 在相邻类别之间插入内容。
2887 % \begin{macrocode}
2888 \cs_new_protected:Npn \xeCJK_inter_class_toks:nnn #1#2#3
2889 {
2890 \tex_XeTeXinterchartoks:D \xeCJK_class_num:n {#1} ~
2891 \xeCJK_class_num:n {#2} = {#3}
2892 }
2893 \cs_generate_variant:Nn \xeCJK_inter_class_toks:nnn { nne }
2894 % \end{macrocode}
2895 % \end{macro}
2896 %
2897 % \begin{macro}[int]{\xeCJK_get_inter_class_toks:nn}
2898 % 取出相邻类别之间的内容。
2899 % \begin{macrocode}
2900 \cs_new:Npn \xeCJK_get_inter_class_toks:nn #1#2
2901 {
2902 \tex_the:D \tex_XeTeXinterchartoks:D \xeCJK_class_num:n {#1} ~
2903 \xeCJK_class_num:n {#2}
2904 }
2905 % \end{macrocode}
2906 % \end{macro}
2907 %
2908 % \begin{macro}[int]{\xeCJK_clear_inter_class_toks:nn}
2909 % 清除相邻类别之间的内容。注意,直接赋空值可能会导致 \XeTeX 崩溃。例如
2910 % \begin{verbatim}
2911 % \XeTeXinterchartokenstate = 1
2912 % \XeTeXcharclass`A=10
2913 % \XeTeXinterchartoks 10 10 = {xx}
2914 % \begingroup
2915 % \XeTeXinterchartoks 10 10 = {} AA
2916 % \endgroup
2917 % \bye
2918 % \end{verbatim}
2919 % 如果把上述例子中的分组 \tn{begingroup} 和 \tn{endgroup} 去掉,则结果正常,甚为怪异。
2920 % 此处 \XeTeX 的 bug 已经在 0.999992 版中修复^^A
2921 % \footnote{\url{http://tug.org/svn/texlive?view=revision&revision=53880}}。
2922 % \begin{macrocode}
2923 \cs_new_protected:Npn \xeCJK_clear_inter_class_toks:nn #1#2
2924 { \xeCJK_inter_class_toks:nnn {#1} {#2} { \prg_do_nothing: } }
2925 % \end{macrocode}
2926 % \end{macro}
2927 %
2928 % \begin{macro}[int]{\xeCJK_pre_inter_class_toks:nnn}
2929 % 在相邻类别之间已有的内容前增加内容。
2930 % \begin{macrocode}
2931 \cs_new_protected:Npn \xeCJK_pre_inter_class_toks:nnn #1#2#3
2932 {
2933 \xeCJK_inter_class_toks:nne {#1} {#2}
2934 { \exp_not:n {#3} \xeCJK_get_inter_class_toks:nn {#1} {#2} }
2935 }
2936 \cs_generate_variant:Nn \xeCJK_pre_inter_class_toks:nnn { nne }
2937 % \end{macrocode}
2938 % \end{macro}
2939 %
2940 % \begin{macro}[int]{\xeCJK_app_inter_class_toks:nnn}
2941 % 在相邻类别之间已有的内容后追加内容。
2942 % \begin{macrocode}
2943 \cs_new_protected:Npn \xeCJK_app_inter_class_toks:nnn #1#2#3
2944 {
2945 \xeCJK_inter_class_toks:nne {#1} {#2}
2946 { \xeCJK_get_inter_class_toks:nn {#1} {#2} \exp_not:n {#3} }
2947 }
2948 \cs_generate_variant:Nn \xeCJK_app_inter_class_toks:nnn { nne }
2949 % \end{macrocode}
2950 % \end{macro}
2951 %
2952 % \begin{macro}[int]{\xeCJK_copy_inter_class_toks:nnnn}
2953 % 将 |#3| 和 |#4| 之间的内容复制到 |#1| 和 |#2| 之间。
2954 % \begin{macrocode}
2955 \cs_new_protected:Npn \xeCJK_copy_inter_class_toks:nnnn #1#2#3#4
2956 {
2957 \tl_set:Nx \l_@@_tmp_tl
2958 { \xeCJK_get_inter_class_toks:nn {#3} {#4} }
2959 \tl_if_empty:NTF \l_@@_tmp_tl
2960 {
2961 \tl_set:Nx \l_@@_tmp_tl
2962 { \xeCJK_get_inter_class_toks:nn {#1} {#2} }
2963 \tl_if_empty:NF \l_@@_tmp_tl
2964 { \xeCJK_clear_inter_class_toks:nn {#1} {#2} }
2965 }
2966 { \xeCJK_inter_class_toks:nne {#1} {#2} { \exp_not:o \l_@@_tmp_tl } }
2967 }
2968 % \end{macrocode}
2969 % \end{macro}
2970 %
2971 % \begin{macro}[int]{\xeCJK_replace_inter_class_toks:nnnn}
2972 % 将 |#1| 和 |#2| 之间出现的 |#3| 用 |#4| 替换。
2973 % \begin{macrocode}
2974 \cs_new_protected:Npn \xeCJK_replace_inter_class_toks:nnnn #1#2#3#4
2975 {
2976 \tl_set:Nx \l_@@_tmp_tl
2977 { \xeCJK_get_inter_class_toks:nn {#1} {#2} }
2978 \tl_if_empty:NF \l_@@_tmp_tl
2979 {
2980 \tl_replace_all:Nnn \l_@@_tmp_tl {#3} {#4}
2981 \xeCJK_inter_class_toks:nne {#1} {#2}
2982 { \exp_not:o \l_@@_tmp_tl }
2983 }
2984 }
2985 % \end{macrocode}
2986 % \end{macro}
2987 %
2988 % \begin{macro}[int]{\xeCJK_clear_Boundary_and_CJK_toks:}
2989 % \changes{v3.4.2}{2016/10/19}{提高效率,避免重复循环。}
2990 % 清除边界与 CJK 文字、全角左右标点之间的内容。
2991 % \begin{macrocode}
2992 \cs_new_protected:Npn \xeCJK_clear_Boundary_and_CJK_toks:
2993 { }
2994 \cs_new_protected:Npn \@@_update_clear_toks:n #1
2995 {
2996 \cs_gset_protected:Npx \xeCJK_clear_Boundary_and_CJK_toks:
2997 {
2998 \exp_not:o { \xeCJK_clear_Boundary_and_CJK_toks: }
2999 \tex_XeTeXinterchartoks:D
3000 \xeCJK_class_num:n { Boundary } ~
3001 \xeCJK_class_num:n {#1} = { \exp_not:N \prg_do_nothing: }
3002 }
3003 }
3004 % \end{macrocode}
3005 % \end{macro}
3006 %
3007 % \begin{variable}
3008 % {\g_@@_base_class_seq,\g_@@_non_CJK_class_seq,\g_@@_CJK_class_seq}
3009 % 保存宏包预先定义的字符类。
3010 % \begin{macrocode}
3011 \seq_new:N \g_@@_base_class_seq
3012 \seq_gset_eq:NN \g_@@_base_class_seq \g_@@_class_seq
3013 \seq_new:N \g_@@_non_CJK_class_seq
3014 \seq_gset_from_clist:Nn \g_@@_non_CJK_class_seq
3015 { Default , HalfLeft , HalfRight , NormalSpace , Boundary }
3016 \seq_new:N \g_@@_CJK_class_seq
3017 \cs_new_protected:Npn \@@_save_CJK_class:n #1
3018 {
3019 \seq_gput_right:Nn \g_@@_CJK_class_seq {#1}
3020 \tl_const:cn
3021 { \@@_CJK_class_tl:n { \use:c { \@@_class_csname:n {#1} } } }
3022 {#1}
3023 \@@_update_clear_toks:n {#1}
3024 }
3025 \clist_map_function:nN
3026 { CJK , FullLeft , FullRight , CM , HangulJamo } \@@_save_CJK_class:n
3027 % \end{macrocode}
3028 % \end{variable}
3029 %
3030 % \subsection{字符输出规则}
3031 %
3032 % \begin{center}
3033 % \begin{tabular}{l*9c}
3034 % \toprule
3035 % & |Default| & |CJK| & |FullL| & |FullR| & |HalfL|
3036 % & |HalfR| & |Normal| & |Bound| & |CM| \\ \midrule
3037 % |Default|
3038 % &
3039 % & \tokslink{def-cjk}
3040 % & \tokslink{def-cjk}
3041 % & \tokslink{def-cjk}
3042 % &
3043 % &
3044 % &
3045 % & \tokslink{def-bound}
3046 % & \tokslink{def-cm}\\
3047 % |CJK|
3048 % & \tokslink{def-cjk}
3049 % & \tokslink{cjk-cjk}
3050 % & \tokslink{cjk-fl-fr}
3051 % & \tokslink{cjk-fl-fr}
3052 % & \tokslink{def-cjk}
3053 % & \tokslink{def-cjk}
3054 % & \tokslink{def-cjk}
3055 % & \tokslink{cjk-bound}
3056 % &\\
3057 % |FullLeft|
3058 % & \tokslink{def-cjk}
3059 % & \tokslink{fl-fr-others}
3060 % & \tokslink{cjk-fl-fr}
3061 % & \tokslink{cjk-fl-fr}
3062 % & \tokslink{def-cjk}
3063 % & \tokslink{def-cjk}
3064 % & \tokslink{def-cjk}
3065 % & \tokslink{fl-fr-bound}
3066 % & \tokslink{def-cm}\\
3067 % |FullRight|
3068 % & \tokslink{def-cjk}
3069 % & \tokslink{fl-fr-others}
3070 % & \tokslink{cjk-fl-fr}
3071 % & \tokslink{cjk-fl-fr}
3072 % & \tokslink{def-cjk}
3073 % & \tokslink{def-cjk}
3074 % & \tokslink{def-cjk}
3075 % & \tokslink{fl-fr-bound}
3076 % & \tokslink{def-cm}\\
3077 % |HalfLeft|
3078 % &
3079 % & \tokslink{def-cjk}
3080 % & \tokslink{def-cjk}
3081 % & \tokslink{def-cjk}
3082 % &
3083 % &
3084 % &
3085 % &
3086 % & \tokslink{def-cm}\\
3087 % |HalfRight|
3088 % &
3089 % & \tokslink{def-cjk}
3090 % & \tokslink{def-cjk}
3091 % & \tokslink{def-cjk}
3092 % &
3093 % &
3094 % &
3095 % & \tokslink{def-bound}
3096 % & \tokslink{def-cm}\\
3097 % |NormalSpace|
3098 % &
3099 % & \tokslink{def-cjk}
3100 % & \tokslink{def-cjk}
3101 % & \tokslink{def-cjk}
3102 % &
3103 % &
3104 % &
3105 % & \tokslink{ns-bound}
3106 % & \tokslink{def-cm}\\
3107 % |Boundary|
3108 % & \tokslink{bound-def}
3109 % & \tokslink{bound-cjk}
3110 % & \tokslink{bound-fl-fr}
3111 % & \tokslink{bound-fl-fr}
3112 % & \tokslink{bound-def}
3113 % &
3114 % & \tokslink{bound-ns}
3115 % &
3116 % & \tokslink{def-cm}\\
3117 % |CM|
3118 % & \tokslink{def-cm}
3119 % & \tokslink{def-cm}
3120 % & \tokslink{def-cm}
3121 % & \tokslink{def-cm}
3122 % & \tokslink{def-cm}
3123 % & \tokslink{def-cm}
3124 % & \tokslink{def-cm}
3125 % & \tokslink{def-cm}
3126 % & \tokslink{def-cm}\\
3127 % \bottomrule
3128 % \end{tabular}
3129 % \end{center}
3130 %
3131 % \changes{v3.4.2}{2016/10/19}{避免在破折号之间折行。}
3132 %
3133 % \begin{macro}[int]{\xeCJK_class_group_begin:,\xeCJK_class_group_end:}
3134 % 在 CJK 类开始时,设置 \tn{XeTeXdashbreakstate} 为零,避免破折号之间的折行。
3135 % \begin{macrocode}
3136 \cs_new_protected:Npn \xeCJK_class_group_begin:
3137 {
3138 \c_group_begin_token
3139 \bool_set_true:N \l_@@_CJK_group_bool
3140 \xeCJK_reset_space_factor:
3141 \int_zero:N \tex_XeTeXdashbreakstate:D
3142 }
3143 \bool_new:N \l_@@_CJK_group_bool
3144 \cs_new_eq:NN \xeCJK_class_group_end: \c_group_end_token
3145 % \end{macrocode}
3146 % \end{macro}
3147 %
3148 % \hypertarget{def-cm}{\texttt{CM}} 字符类与 |CJK| 字符类基本相同,只是从 |CJK|
3149 % 转移到 |CM| 时,不加入任何内容。
3150 % \begin{macrocode}
3151 \AtEndOfPackage
3152 {
3153 \seq_map_inline:Nn \g_@@_class_seq
3154 {
3155 \str_if_eq:nnTF {#1} { CM }
3156 { \xeCJK_copy_inter_class_toks:nnnn { CM } {#1} { CJK } { CJK } }
3157 {
3158 \xeCJK_copy_inter_class_toks:nnnn { CM } {#1} { CJK } {#1}
3159 \str_if_eq:nnF {#1} { CJK }
3160 { \xeCJK_copy_inter_class_toks:nnnn {#1} { CM } {#1} { CJK } }
3161 }
3162 }
3163 }
3164 % \end{macrocode}
3165 %
3166 % \hypertarget{def-HJ}{\texttt{HangulJamo}} 字符类与 |CJK| 字符类基本相同,只是
3167 % |HangulJamo| 类之间不加入任何内容。
3168 % \begin{macrocode}
3169 \AtEndOfPackage
3170 {
3171 \seq_map_inline:Nn \g_@@_class_seq
3172 {
3173 \str_if_eq:nnF {#1} { HangulJamo }
3174 {
3175 \xeCJK_copy_inter_class_toks:nnnn { HangulJamo } {#1} { CJK } {#1}
3176 \xeCJK_copy_inter_class_toks:nnnn {#1} { HangulJamo } {#1} { CJK }
3177 }
3178 }
3179 }
3180 % \end{macrocode}
3181 %
3182 % \hypertarget{def-cjk}{}
3183 % \begin{macrocode}
3184 \clist_map_inline:nn { Default , HalfLeft , HalfRight , NormalSpace }
3185 {
3186 \xeCJK_inter_class_toks:nnn {#1} { CJK }
3187 {
3188 \xeCJK_class_group_begin:
3189 \xeCJK_select_font:
3190 \xeCJK_clear_inter_class_toks:nn {#1} { CJK }
3191 \xeCJK_clear_Boundary_and_CJK_toks:
3192 \xeCJK_fallback_symbol:NN
3193 \CJKsymbol
3194 }
3195 \xeCJK_inter_class_toks:nnn { CJK } {#1} { \xeCJK_class_group_end: }
3196 }
3197 % \end{macrocode}
3198 %
3199 % \hypertarget{bound-def}{}
3200 % \begin{macrocode}
3201 \clist_map_inline:nn { Default , HalfLeft }
3202 {
3203 \xeCJK_inter_class_toks:nnn { Boundary } {#1}
3204 { \xeCJK_Boundary_and_Default: }
3205 \xeCJK_app_inter_class_toks:nnn { CJK } {#1}
3206 { \CJKecglue }
3207 }
3208 % \end{macrocode}
3209 %
3210 % \begin{macro}[int]{\xeCJK_Boundary_and_Default:}
3211 % \begin{macrocode}
3212 \cs_new_protected:Npn \xeCJK_Boundary_and_Default:
3213 { \xeCJK_check_for_ecglue: }
3214 \cs_new_protected:Npn \@@_check_for_xecglue:
3215 {
3216 \@@_if_last_glue:TF
3217 { \@@_replace_space: }
3218 { \@@_check_for_ecglue: }
3219 }
3220 \cs_new_protected:Npn \@@_check_for_ecglue:
3221 {
3222 \xeCJK_if_last_node:nTF { CJK }
3223 { \use_i:nn }
3224 { \xeCJK_if_last_node:nTF { CJK-widow } }
3225 { \xeCJK_remove_node: \CJKecglue }
3226 {
3227 \xeCJK_if_last_node:nT { CJK-space }
3228 { \xeCJK_remove_node: \xeCJK_space_or_xecglue: }
3229 }
3230 }
3231 \cs_new_eq:NN \xeCJK_check_for_ecglue: \@@_check_for_ecglue:
3232 % \end{macrocode}
3233 % \end{macro}
3234 %
3235 % \changes{v3.4.0}{2016/05/08}{改进 \texttt{xCJKecglue} 的实现。}
3236 %
3237 % \begin{macro}{\@@_replace_space:}
3238 % 将空格替换为 \tn{CJKecglue}。注意由 \tn{leaders} 等产生的 glue,并不能正确地还回去。
3239 % 好在 \LaTeXe{} 中常用的 \tn{hrulefill} 和 \tn{dotfill} 定义末尾都有 |\kern\z@| 保护。
3240 % \begin{macrocode}
3241 \cs_new_protected:Npn \@@_replace_space:
3242 {
3243 \skip_set_eq:NN \l_@@_last_skip \tex_lastskip:D
3244 \tex_unskip:D
3245 \xeCJK_if_last_node:nTF { CJK-space }
3246 { \xeCJK_remove_node: \CJKecglue }
3247 {
3248 \xeCJK_if_last_node:nTF { CJK }
3249 {
3250 \skip_if_eq:nnTF
3251 { \l_@@_last_skip }
3252 { \c_xeCJK_space_skip_tl }
3253 { \xeCJK_remove_node: \CJKecglue }
3254 { \skip_horizontal:N \l_@@_last_skip }
3255 }
3256 { \skip_horizontal:N \l_@@_last_skip }
3257 }
3258 }
3259 \skip_new:N \l_@@_last_skip
3260 % \end{macrocode}
3261 % \end{macro}
3262 %
3263 % \hypertarget{def-bound}{}
3264 % \begin{macrocode}
3265 \clist_map_inline:nn { Default , HalfRight }
3266 {
3267 \xeCJK_inter_class_toks:nnn {#1} { Boundary }
3268 {
3269 \int_gset_eq:NN \g_@@_space_factor_int \tex_spacefactor:D
3270 \peek_meaning_remove:NTF \tex_italiccorrection:D
3271 {
3272 \tex_italiccorrection:D
3273 { \xeCJK_make_node:n { default } }
3274 }
3275 {
3276 \token_if_space:NTF \l_peek_token
3277 { \xeCJK_make_space_node: }
3278 { { \xeCJK_make_node:n { default } } }
3279 }
3280 }
3281 \xeCJK_pre_inter_class_toks:nnn {#1} { CJK } { \CJKecglue }
3282 }
3283 % \end{macrocode}
3284 %
3285 % \changes{v3.2.5}{2013/07/10}
3286 % {修正 \texttt{CJK} 和 \texttt{NormalSpace} 字符类之间因为边界造成的间距不正确的问题。}
3287 %
3288 % \hypertarget{bound-ns}{}
3289 % \begin{macrocode}
3290 \xeCJK_inter_class_toks:nnn { Boundary } { NormalSpace }
3291 { \xeCJK_Boundary_and_NormalSp: }
3292 % \end{macrocode}
3293 %
3294 % \begin{macro}[int]{\xeCJK_Boundary_and_NormalSp:}
3295 % \begin{macrocode}
3296 \cs_new_protected:Npn \xeCJK_Boundary_and_NormalSp:
3297 { \xeCJK_check_for_ecglue_normalsp: }
3298 \cs_new_protected:Npn \@@_check_for_xecglue_normalsp:
3299 {
3300 \@@_if_last_glue:TF
3301 { \@@_replace_space: }
3302 { \@@_check_for_ecglue_normalsp: }
3303 }
3304 \cs_new_protected:Npn \@@_check_for_ecglue_normalsp:
3305 {
3306 \xeCJK_if_last_node:nT { CJK-space }
3307 { \xeCJK_remove_node: \xeCJK_space_or_xecglue: }
3308 }
3309 \cs_new_eq:NN \xeCJK_check_for_ecglue_normalsp:
3310 \@@_check_for_ecglue_normalsp:
3311 % \end{macrocode}
3312 % \end{macro}
3313 %
3314 % \hypertarget{ns-bound}{}
3315 % \begin{macrocode}
3316 \xeCJK_inter_class_toks:nnn { NormalSpace } { Boundary }
3317 {
3318 \int_gset_eq:NN \g_@@_space_factor_int \tex_spacefactor:D
3319 \peek_meaning_remove:NTF \tex_italiccorrection:D
3320 {
3321 \tex_italiccorrection:D
3322 { \xeCJK_make_node:n { normalspace } }
3323 }
3324 {
3325 \token_if_space:NTF \l_peek_token
3326 { \xeCJK_make_space_node: }
3327 { { \xeCJK_make_node:n { normalspace } } }
3328 }
3329 }
3330 % \end{macrocode}
3331 %
3332 % \hypertarget{bound-cjk}{}
3333 % \begin{macrocode}
3334 \xeCJK_inter_class_toks:nnn { Boundary } { CJK }
3335 {
3336 \xeCJK_check_for_glue:
3337 \xeCJK_class_group_begin:
3338 \xeCJK_clear_Boundary_and_CJK_toks:
3339 \xeCJK_select_font:
3340 \xeCJK_fallback_symbol:NN
3341 \CJKsymbol
3342 }
3343 % \end{macrocode}
3344 %
3345 % \begin{macro}[int]{\xeCJK_check_for_glue:}
3346 % \begin{macrocode}
3347 \cs_new_protected:Npn \xeCJK_check_for_glue:
3348 {
3349 \@@_if_last_kern:TF
3350 { \@@_check_for_glue_auxi: }
3351 {
3352 \@@_if_last_math:TF
3353 { \xeCJK_remove_node: \CJKecglue }
3354 { \@@_check_for_glue_auxii: }
3355 }
3356 }
3357 \cs_new_protected:Npn \@@_check_for_glue_auxi:
3358 {
3359 \dim_case:nn { \tex_lastkern:D }
3360 {
3361 { \@@_node:n { CJK } }
3362 { \xeCJK_remove_node: \CJKglue }
3363 { \@@_node:n { CJK-space } }
3364 { \xeCJK_remove_node: \@@_ccglue_or_space: }
3365 { \@@_node:n { CJK-widow } }
3366 { \xeCJK_remove_node: \xeCJK_widow_penalty: \CJKglue }
3367 { \@@_node:n { default } }
3368 { \xeCJK_remove_node: \CJKecglue }
3369 }
3370 }
3371 \cs_new_protected:Npn \@@_check_for_glue_auxii:
3372 {
3373 \xeCJK_if_last_punct:TF
3374 { \@@_check_for_glue_auxiii: }
3375 { \xeCJK_check_for_xglue: }
3376 }
3377 \cs_new_protected:Npn \@@_check_for_glue_auxiii:
3378 {
3379 \bool_if:NT \l_@@_last_penalty_bool
3380 { \tex_penalty:D \l_@@_last_penalty_int }
3381 \skip_horizontal:N \l_@@_last_skip
3382 \tl_if_eq:NNF \l_@@_aligni_tl \c_@@_left_tl { \CJKglue }
3383 }
3384 \cs_new_eq:NN \xeCJK_check_for_xglue: \prg_do_nothing:
3385 \cs_new_protected:Npn \@@_check_for_xglue:
3386 {
3387 \@@_if_last_glue:TF
3388 {
3389 \skip_set_eq:NN \l_@@_last_skip \tex_lastskip:D
3390 \tex_unskip:D
3391 \xeCJK_if_last_node:nTF { CJK-space }
3392 { \xeCJK_remove_node: \@@_ccglue_or_space: }
3393 {
3394 \xeCJK_if_last_node:nTF { default-space }
3395 { \xeCJK_remove_node: \CJKecglue }
3396 { \@@_check_for_xglue_aux: }
3397 }
3398 }
3399 }
3400 \cs_new_protected:Npn \@@_check_for_xglue_aux:
3401 {
3402 \skip_if_eq:nnTF
3403 { \l_@@_last_skip }
3404 { \c_xeCJK_space_skip_tl }
3405 {
3406 \xeCJK_if_last_node:nTF { CJK }
3407 { \xeCJK_remove_node: \@@_ccglue_or_space: }
3408 {
3409 \xeCJK_if_last_node:nTF { default }
3410 { \xeCJK_remove_node: \CJKecglue }
3411 {
3412 \@@_if_last_math:TF
3413 { \CJKecglue }
3414 { \skip_horizontal:N \l_@@_last_skip }
3415 }
3416 }
3417 }
3418 { \skip_horizontal:N \l_@@_last_skip }
3419 }
3420 \cs_new_protected:Npn \@@_ccglue_or_space:
3421 { \CJKglue }
3422 % \end{macrocode}
3423 % \end{macro}
3424 %
3425 % \changes{v3.9.1}{2022/08/02}{简化部分内部实现。}
3426 %
3427 % \begin{macro}[TF]{
3428 % \@@_if_last_none:,
3429 % \@@_if_last_hlist:,
3430 % \@@_if_last_math:,
3431 % \@@_if_last_glue:,
3432 % \@@_if_last_kern:,
3433 % \@@_if_last_penalty:}
3434 % 一些 \hologo{eTeX} 结点判定函数。
3435 % \begin{macrocode}
3436 \group_begin:
3437 \cs_set:Npn \@@_tmp:nn #1
3438 {
3439 \exp_args:Ncc \@@_tmp_aux:NNn
3440 { @@_if_last_ #1 : }
3441 { c_@@_ #1 _node }
3442 }
3443 \cs_set:Npn \@@_tmp_aux:NNn #1#2#3
3444 {
3445 \int_const:Nn #2 {#3}
3446 \prg_new_conditional:Npnn #1 { T , F , TF }
3447 {
3448 \if_int_compare:w \tex_lastnodetype:D = #2
3449 \prg_return_true: \else: \prg_return_false: \fi:
3450 }
3451 }
3452 \@@_tmp:nn { none } { -1 }
3453 \@@_tmp:nn { hlist } { 1 }
3454 \@@_tmp:nn { math } { 10 }
3455 \@@_tmp:nn { glue } { 11 }
3456 \@@_tmp:nn { kern } { 12 }
3457 \@@_tmp:nn { penalty } { 13 }
3458 \group_end:
3459 % \end{macrocode}
3460 % \end{macro}
3461 %
3462 % \begin{macro}[pTF,int]{\xeCJK_if_last_node:n}
3463 % \begin{macrocode}
3464 \prg_new_conditional:Npnn \xeCJK_if_last_node:n #1 { p , T , F , TF }
3465 {
3466 \if_dim:w
3467 \cs_if_exist_use:cTF { c_@@_#1_node_dim }
3468 { = \tex_lastkern:D }
3469 { \use:c { c_@@_#1_node_skip } = \tex_lastskip:D }
3470 \prg_return_true: \else: \prg_return_false: \fi:
3471 }
3472 % \end{macrocode}
3473 % \end{macro}
3474 %
3475 % \changes{v3.1.0}{2012/11/14}{删除多余的 \texttt{default-itcorr} 结点。}
3476 % \changes{v3.2.4}{2013/07/03}{尽量移除用作判断标志的 \tn{kern}。}
3477 %
3478 % \begin{macro}[int]{\xeCJK_declare_node:n,\xeCJK_make_node:n}
3479 % 用于判断插入的各种 |kern| 和 |glue|。
3480 % \begin{macrocode}
3481 \cs_new_protected:Npn \xeCJK_declare_node:n #1
3482 {
3483 \int_gincr:N \g_@@_node_int
3484 \dim_if_exist:cTF { c_@@_#1_node_dim }
3485 { \dim_gset:cn } { \dim_const:cn }
3486 { c_@@_#1_node_dim } { \g_@@_node_int sp }
3487 }
3488 \cs_new_protected:Npn \xeCJK_declare_glue_node:n #1
3489 {
3490 \int_gincr:N \g_@@_node_int
3491 \skip_if_exist:cTF { c_@@_#1_node_skip }
3492 { \skip_gset:cn } { \skip_const:cn }
3493 { c_@@_#1_node_skip } { \g_@@_node_int sp }
3494 }
3495 \int_new:N \g_@@_node_int
3496 \int_gset:Nn \g_@@_node_int { 10 }
3497 \cs_new_protected:Npn \xeCJK_make_node:n #1
3498 { \exp_args:Nc \@@_make_node:N { c_@@_#1_node_dim } }
3499 \cs_new:Npn \@@_node:n #1
3500 { \use:c { c_@@_#1_node_dim } }
3501 \cs_new:Npn \@@_gule_node:n #1
3502 { \use:c { c_@@_#1_node_skip } }
3503 \cs_new_protected:Npn \@@_make_node:N #1
3504 {
3505 \tex_kern:D - #1
3506 \tex_kern:D #1
3507 }
3508 \cs_new_protected:Npn \xeCJK_remove_node:
3509 {
3510 \@@_if_last_kern:TF
3511 { \tex_unkern:D \tex_unkern:D }
3512 {
3513 \@@_if_last_glue:T
3514 { \tex_unskip:D \tex_unskip:D }
3515 }
3516 }
3517 \xeCJK_declare_node:n { CJK }
3518 \xeCJK_declare_node:n { CJK-space }
3519 \xeCJK_declare_node:n { default }
3520 \xeCJK_declare_node:n { CJK-widow }
3521 \xeCJK_declare_node:n { normalspace }
3522 \xeCJK_declare_glue_node:n { default-space }
3523 % \end{macrocode}
3524 % \end{macro}
3525 %
3526 % \changes{v3.9.0}{2022/06/06}{修复西文的 character protrusion 功能。}
3527 %
3528 % \begin{macro}[int]{\xeCJK_make_space_node:}
3529 % 用于判断插入空格之前的 node,默认为空,只有用户设置了 \opt{xCJKecglue} 选项才有意义。
3530 % 需要使用 |glue| 来标记,使用 |kern| 会影响 character protrusion 功能。
3531 % \begin{macrocode}
3532 \cs_new_eq:NN \xeCJK_make_space_node: \prg_do_nothing:
3533 \cs_new_protected:Npx \@@_make_space_node:
3534 {
3535 \tex_hskip:D - \@@_gule_node:n { default-space }
3536 \tex_hskip:D \@@_gule_node:n { default-space }
3537 }
3538 % \end{macrocode}
3539 % \end{macro}
3540 %
3541 % \begin{macro}{CJKglue}
3542 % CJK 文字之间插入的 |glue|。
3543 % \begin{macrocode}
3544 \keys_define:nn { xeCJK / options }
3545 {
3546 CJKglue .code:n =
3547 {
3548 \cs_set_protected:Npn \CJKglue {#1}
3549 \xeCJK_glue_to_skip:nN {#1} \l_@@_ccglue_skip
3550 }
3551 }
3552 \skip_new:N \l_@@_ccglue_skip
3553 % \end{macrocode}
3554 % \end{macro}
3555 %
3556 % \changes{v3.2.16}{2014/12/16}{整理 \texttt{xCJKecglue} 的部分代码。}
3557 %
3558 % \begin{macro}{CJKecglue,xCJKecglue}
3559 % CJK 与西文和数学行内数学公式之间自动添加的空白。
3560 % \begin{macrocode}
3561 \keys_define:nn { xeCJK / options }
3562 {
3563 CJKecglue .code:n =
3564 {
3565 \cs_set_protected:Npn \CJKecglue {#1}
3566 \xeCJK_glue_to_skip:nN {#1} \l_@@_ecglue_skip
3567 } ,
3568 xCJKecglue .choice: ,
3569 xCJKecglue / true .code:n =
3570 {
3571 \bool_set_true:N \l_@@_xecglue_bool
3572 \cs_set_eq:NN \xeCJK_space_or_xecglue: \CJKecglue
3573 \cs_set_eq:NN \xeCJK_make_space_node: \@@_make_space_node:
3574 \cs_set_eq:NN \xeCJK_check_for_xglue: \@@_check_for_xglue:
3575 \cs_set_eq:NN \xeCJK_check_for_ecglue: \@@_check_for_xecglue:
3576 \cs_set_eq:NN
3577 \xeCJK_check_for_ecglue_normalsp:
3578 \@@_check_for_xecglue_normalsp:
3579 } ,
3580 xCJKecglue / false .code:n =
3581 {
3582 \bool_set_false:N \l_@@_xecglue_bool
3583 \cs_set_eq:NN \xeCJK_space_or_xecglue: \xeCJK_space_glue:
3584 \xeCJK_cs_clear:N \xeCJK_make_space_node:
3585 \xeCJK_cs_clear:N \xeCJK_check_for_xglue:
3586 \cs_set_eq:NN \xeCJK_check_for_ecglue: \@@_check_for_ecglue:
3587 \cs_set_eq:NN
3588 \xeCJK_check_for_ecglue_normalsp:
3589 \@@_check_for_ecglue_normalsp:
3590 } ,
3591 xCJKecglue / unknown .code:n =
3592 {
3593 \bool_set_true:N \l_@@_xecglue_bool
3594 \cs_set_protected:Npn \CJKecglue {#1}
3595 \xeCJK_glue_to_skip:nN {#1} \l_@@_ecglue_skip
3596 \cs_set_eq:NN \xeCJK_space_or_xecglue: \CJKecglue
3597 \cs_set_eq:NN \xeCJK_make_space_node: \@@_make_space_node:
3598 \cs_set_eq:NN \xeCJK_check_for_xglue: \@@_check_for_xglue:
3599 \cs_set_eq:NN \xeCJK_check_for_ecglue: \@@_check_for_xecglue:
3600 \cs_set_eq:NN
3601 \xeCJK_check_for_ecglue_normalsp:
3602 \@@_check_for_xecglue_normalsp:
3603 } ,
3604 xCJKecglue .default:n = { true }
3605 }
3606 \cs_new_eq:NN \xeCJK_space_glue: \c_space_tl
3607 \skip_new:N \l_@@_ecglue_skip
3608 \bool_new:N \l_@@_xecglue_bool
3609 % \end{macrocode}
3610 % \end{macro}
3611 %
3612 % \changes{v3.4.1}{2016/05/21}{修复 \texttt{CJKspace} 功能失效。}
3613 % \changes{v3.7.2}{2019/04/07}{简化 \texttt{CJKspace} 的实现,并修复错误。}
3614 %
3615 % \begin{macro}{CJKspace}
3616 % 是否保留 CJK 文字间的空白,默认不保留。
3617 % \begin{macrocode}
3618 \keys_define:nn { xeCJK / options }
3619 {
3620 CJKspace .choice: ,
3621 CJKspace / true .code:n =
3622 {
3623 \bool_set_true:N \l_@@_reserve_space_bool
3624 \cs_set_protected:Npn \@@_ccglue_or_space:
3625 { \xeCJK_space_glue: }
3626 } ,
3627 CJKspace / false .code:n =
3628 {
3629 \bool_set_false:N \l_@@_reserve_space_bool
3630 \cs_set_protected:Npn \@@_ccglue_or_space:
3631 { \CJKglue }
3632 } ,
3633 CJKspace .default:n = { true } ,
3634 space .meta:n = { CJKspace = true } ,
3635 nospace .meta:n = { CJKspace = false }
3636 }
3637 \bool_new:N \l_@@_reserve_space_bool
3638 % \end{macrocode}
3639 % \end{macro}
3640 %
3641 % \hypertarget{cjk-bound}{}
3642 % \begin{macrocode}
3643 \xeCJK_inter_class_toks:nnn { CJK } { Boundary } { \xeCJK_CJK_and_Boundary:w }
3644 % \end{macrocode}
3645 %
3646 % \begin{macro}[int]{\xeCJK_CJK_and_Boundary:w}
3647 % \changes{v3.2.6}{2013/08/05}{更好的处理边界是 \tn{relax} 的情况。}
3648 % 当边界是 \tn{relax} 的时候,它可能是由 |\csname ...\endcsname| 的形式产生的,
3649 % 这样就可能出现问题\footnote{参见 \url{http://bbs.ctex.org/forum.php?mod=viewthread&tid=71563}。}。
3650 % 原来是都在未定义控制序列前都加上 \cs{exp_not:N},现在是采用分组结束后手工恢复的方式。
3651 % \begin{macrocode}
3652 \cs_new_protected:Npn \xeCJK_CJK_and_Boundary:w
3653 {
3654 \xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token
3655 {
3656 \bool_if:NTF \l_@@_peek_ignore_spaces_bool
3657 { \xeCJK_class_group_end: \xeCJK_space_or_xecglue: }
3658 { \xeCJK_class_group_end: \CJKecglue }
3659 }
3660 {
3661 \group_align_safe_begin:
3662 \bool_if:NTF \l_@@_peek_ignore_spaces_bool
3663 {
3664 \token_if_macro:NTF \l_peek_token
3665 { \@@_boundary_reserve_space: }
3666 { \@@_boundary_group_end:n { CJK-space } }
3667 }
3668 {
3669 \token_if_eq_meaning:NNTF \l_peek_token \scan_stop:
3670 { \@@_CJK_and_Boundary_relax:N }
3671 { \@@_boundary_group_end:n { CJK } }
3672 }
3673 }
3674 }
3675 \cs_new_protected:Npn \@@_boundary_reserve_space:
3676 {
3677 \@@_boundary_group_end:n { CJK-space }
3678 \xeCJK_space_or_xecglue:
3679 }
3680 \cs_new_protected:Npn \@@_CJK_and_Boundary_relax:N #1
3681 {
3682 \@@_boundary_group_end:n { CJK }
3683 \token_if_eq_meaning:NNTF #1 \scan_stop:
3684 {#1} { \cs_set_eq:NN #1 \scan_stop: #1 }
3685 }
3686 \cs_new_protected:Npn \@@_boundary_group_end:n #1
3687 {
3688 \group_align_safe_end:
3689 \xeCJK_class_group_end:
3690 { \xeCJK_make_node:n {#1} }
3691 }
3692 % \end{macrocode}
3693 % \end{macro}
3694 %
3695 % \begin{macro}[int]{\xeCJK_ignore_spaces:w}
3696 % \begin{macrocode}
3697 \cs_new_protected:Npn \xeCJK_ignore_spaces:w
3698 {
3699 \xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token
3700 {
3701 \bool_if:NTF \l_@@_peek_ignore_spaces_bool
3702 { \xeCJK_space_or_xecglue: } { \CJKecglue }
3703 }
3704 {
3705 \bool_if:NT \l_@@_peek_ignore_spaces_bool
3706 {
3707 \dim_case:nn { \tex_lastkern:D }
3708 {
3709 { \@@_node:n { CJK } }
3710 { \xeCJK_remove_node: \xeCJK_make_node:n { CJK-space } }
3711 { \@@_node:n { default } }
3712 { \xeCJK_remove_node: \xeCJK_make_space_node: }
3713 }
3714 \group_align_safe_begin:
3715 \token_if_macro:NTF \l_peek_token
3716 { \@@_reserve_space_aux: }
3717 { \group_align_safe_end: }
3718 }
3719 }
3720 }
3721 \cs_new_protected:Npn \@@_reserve_space_aux:
3722 {
3723 \group_align_safe_end:
3724 \xeCJK_space_or_xecglue:
3725 }
3726 % \end{macrocode}
3727 % \end{macro}
3728 %
3729 % \hypertarget{cjk-cjk}{}
3730 % \begin{macrocode}
3731 \xeCJK_inter_class_toks:nnn { CJK } { CJK }
3732 { \xeCJK_CJK_and_CJK:N }
3733 % \end{macrocode}
3734 %
3735 % \begin{macro}[int]{\xeCJK_CJK_and_CJK:N}
3736 % \begin{macrocode}
3737 \cs_new_protected:Npn \xeCJK_CJK_and_CJK:N
3738 {
3739 \CJKglue
3740 \xeCJK_fallback_symbol:NN
3741 \CJKsymbol
3742 }
3743 % \end{macrocode}
3744 % \end{macro}
3745 %
3746 % \hypertarget{fl-fr-others}{}
3747 % \begin{macrocode}
3748 \xeCJK_inter_class_toks:nnn { FullLeft } { CJK }
3749 {
3750 \xeCJK_FullLeft_and_CJK:
3751 \xeCJK_fallback_symbol:NN
3752 \CJKsymbol
3753 }
3754 \xeCJK_inter_class_toks:nnn { FullRight } { CJK }
3755 {
3756 \xeCJK_FullRight_and_CJK:
3757 \xeCJK_fallback_symbol:NN
3758 \CJKsymbol
3759 }
3760 \seq_map_inline:Nn \g_@@_non_CJK_class_seq
3761 {
3762 \clist_map_inline:nn { FullLeft , FullRight }
3763 {
3764 \xeCJK_inter_class_toks:nne {#1} {##1}
3765 { \exp_not:c { xeCJK_Default_and_##1:nN } {#1} }
3766 \xeCJK_inter_class_toks:nne {##1} {#1}
3767 { \exp_not:c { xeCJK_##1_and_Default: } }
3768 }
3769 }
3770 % \end{macrocode}
3771 %
3772 % \hypertarget{bound-fl-fr}{}
3773 % \begin{macrocode}
3774 \xeCJK_inter_class_toks:nnn { Boundary } { FullLeft }
3775 { \xeCJK_Boundary_and_FullLeft:N }
3776 \xeCJK_inter_class_toks:nnn { Boundary } { FullRight }
3777 { \xeCJK_Boundary_and_FullRight:N }
3778 % \end{macrocode}
3779 %
3780 % \hypertarget{fl-fr-bound}{}
3781 % \begin{macrocode}
3782 \xeCJK_inter_class_toks:nnn { FullLeft } { Boundary }
3783 { \xeCJK_FullLeft_and_Boundary: }
3784 \xeCJK_inter_class_toks:nnn { FullRight } { Boundary }
3785 { \xeCJK_FullRight_and_Boundary: }
3786 % \end{macrocode}
3787 %
3788 % \begin{macro}[int]{\xeCJK_FullLeft_and_Boundary:}
3789 % \hypertarget{fl-fr-bound}{}
3790 % \begin{macrocode}
3791 \cs_new_protected:Npn \xeCJK_FullLeft_and_Boundary:
3792 {
3793 \@@_punct_if_middle:NTF \g_@@_last_punct_tl
3794 {
3795 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
3796 \xeCJK_class_group_end:
3797 \exp_after:wN \xeCJK_punct_node:N \g_@@_last_punct_tl
3798 \xeCJK_no_break:
3799 \@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
3800 }
3801 {
3802 \xeCJK_class_group_end:
3803 \exp_after:wN \xeCJK_punct_node:N \g_@@_last_punct_tl
3804 \@@_nobreak_zero_glue:
3805 }
3806 \tex_ignorespaces:D
3807 }
3808 % \end{macrocode}
3809 % \end{macro}
3810 %
3811 % \begin{macro}[int]{\xeCJK_FullRight_and_Boundary:}
3812 % \begin{macrocode}
3813 \cs_new_protected:Npn \xeCJK_FullRight_and_Boundary:
3814 {
3815 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
3816 \xeCJK_class_group_end:
3817 \exp_after:wN \xeCJK_punct_node:N \g_@@_last_punct_tl
3818 \@@_punct_glue:NN \c_@@_right_tl \g_@@_last_punct_tl
3819 \tex_ignorespaces:D
3820 }
3821 % \end{macrocode}
3822 % \end{macro}
3823 %
3824 % \begin{macro}[int]{\xeCJK_punct_node:N}
3825 % 保存标点的当前边界宽度和字符码,通过插入 \tn{kern} 实现。
3826 % \begin{macrocode}
3827 \cs_new_protected:Npn \xeCJK_punct_node:N #1
3828 {
3829 \@@_punct_bound_unitization:NN #1 \l_@@_tmp_dim
3830 \@@_make_node:N \l_@@_tmp_dim
3831 \dim_set:Nn \l_@@_tmp_dim { `#1 sp }
3832 \@@_make_node:N \l_@@_tmp_dim
3833 }
3834 % \end{macrocode}
3835 % \end{macro}
3836 %
3837 % \begin{macro}{\@@_punct_bound_unitization:NN}
3838 % 我们不想出现过大的 \tn{kern},因此当边界大于 \SI{1}{pt} 时,以 \cs{c_max_dim} 为标准
3839 % 对其进行“单位化”。
3840 % \begin{macrocode}
3841 \cs_new_protected:Npn \@@_punct_bound_unitization:NN #1#2
3842 {
3843 \dim_set:Nn #2
3844 {
3845 \dim_max:nn
3846 { \c_zero_dim }
3847 { \@@_use_punct_dim:nNN { bound } \c_@@_right_tl #1 }
3848 }
3849 \dim_compare:nNnF {#2} < { 1pt }
3850 { \dim_set:Nn #2 { -1pt * \dim_ratio:nn {#2} { \c_max_dim } } }
3851 }
3852 % \end{macrocode}
3853 % \end{macro}
3854 %
3855 % \begin{macro}[int]{\xeCJK_punct_bound_kern:N}
3856 % \begin{macro}{\@@_punct_bound_kern:NN}
3857 % \begin{macrocode}
3858 \cs_new_protected:Npn \xeCJK_punct_bound_kern:N #1
3859 {
3860 \exp_after:wN \@@_punct_bound_kern:NN
3861 \g_@@_last_punct_tl #1
3862 }
3863 \cs_new_protected:Npn \@@_punct_bound_kern:NN #1#2
3864 {
3865 \xeCJK_get_punct_bounds:NN \l_@@_aligni_tl #1
3866 \xeCJK_get_punct_kerning:NN #1 #2
3867 \@@_punct_bound_unitization:NN #1 \l_@@_tmp_dim
3868 \skip_set:Nn \l_@@_punct_kern_skip
3869 { \@@_use_dim_or_skip:nNN { bound_kern } #1 #2 }
3870 \dim_compare:nNnF \l_@@_tmp_dim = \l_@@_last_bound_dim
3871 { \@@_punct_bound_kern_ratio:NN #1 #2 }
3872 \bool_if:NTF \l_@@_last_penalty_bool
3873 {
3874 \tex_penalty:D \l_@@_last_penalty_int
3875 \skip_horizontal:N
3876 }
3877 { \@@_punct_bound_kern_aux:NNN #1 #2 }
3878 \l_@@_punct_kern_skip
3879 }
3880 \skip_new:N \l_@@_punct_kern_skip
3881 % \end{macrocode}
3882 % \end{macro}
3883 % \end{macro}
3884 %
3885 % \begin{macro}{\@@_punct_bound_kern_ratio:NN}
3886 % 当标点前后的字体情况不一致时,按一定的比例进行压缩。
3887 % \begin{macrocode}
3888 \cs_new_protected:Npn \@@_punct_bound_kern_ratio:NN #1#2
3889 {
3890 \dim_set:Nn \l_@@_bound_dim
3891 { \@@_use_punct_dim:nNN { bound_width } #1 #2 }
3892 \dim_compare:nNnT \l_@@_bound_dim > \c_zero_dim
3893 {
3894 \dim_compare:nNnF \l_@@_last_bound_dim > \c_zero_dim
3895 {
3896 \dim_set:Nn \l_@@_last_bound_dim
3897 {
3898 - \l_@@_last_bound_dim *
3899 \dim_ratio:nn { \c_max_dim } { 1pt }
3900 }
3901 }
3902 \@@_punct_bound_kern_ratio_aux:N #2
3903 }
3904 }
3905 \cs_new_protected:Npn \@@_punct_bound_kern_ratio_aux:N #1
3906 {
3907 \skip_set:Nn \l_@@_punct_kern_skip
3908 {
3909 \l_@@_punct_kern_skip *
3910 \dim_ratio:nn
3911 {
3912 \l_@@_last_bound_dim
3913 + \@@_use_punct_dim:nNN { bound } \c_@@_left_tl #1
3914 }
3915 { \l_@@_bound_dim }
3916 }
3917 }
3918 % \end{macrocode}
3919 % \end{macro}
3920 %
3921 %
3922 % \begin{macro}{\@@_nobreak_hskip:N,\@@_nobreak_hskip:n,
3923 % \@@_punct_bound_kern:N, \@@_punct_bound_breakable_kern:N}
3924 % \begin{macrocode}
3925 \cs_new_protected:Npn \@@_nobreak_hskip:N
3926 { \xeCJK_no_break: \skip_horizontal:N }
3927 \cs_new_protected:Npn \@@_nobreak_hskip:n
3928 { \xeCJK_no_break: \skip_horizontal:n }
3929 \cs_new_eq:NN \@@_punct_bound_kern:N \@@_nobreak_hskip:N
3930 \cs_new_protected:Npn \@@_punct_bound_breakable_kern:N
3931 {
3932 \tl_if_eq:NNTF \l_@@_aligni_tl \c_@@_right_tl
3933 {
3934 \tl_if_eq:NNTF \l_@@_alignii_tl \c_@@_left_tl
3935 { \skip_horizontal:N }
3936 { \@@_nobreak_hskip:N }
3937 }
3938 { \@@_nobreak_hskip:N }
3939 }
3940 \cs_new_protected:Npn \@@_punct_bound_kern_aux:NNN #1#2
3941 {
3942 \str_if_eq:nnTF {#1} {#2}
3943 { \@@_nobreak_hskip:N }
3944 {
3945 \@@_punct_if_long:NTF #1
3946 { \skip_horizontal:N }
3947 {
3948 \@@_punct_if_long:NTF #2
3949 { \skip_horizontal:N }
3950 { \@@_punct_bound_kern:N }
3951 }
3952 }
3953 }
3954 % \end{macrocode}
3955 % \end{macro}
3956 %
3957 % \hypertarget{cjk-fl-fr}{}
3958 % \begin{macrocode}
3959 \clist_map_inline:nn { CJK , FullLeft , FullRight }
3960 {
3961 \clist_map_inline:nn { FullLeft , FullRight }
3962 {
3963 \xeCJK_inter_class_toks:nne {#1} {##1}
3964 { \exp_not:c { xeCJK_#1_and_##1:N } }
3965 }
3966 }
3967 % \end{macrocode}
3968 %
3969 % \begin{macro}{\@@_punct_bound_rule:NN}
3970 % 用于抹去标点符号的全部左/右空白。
3971 % \begin{macrocode}
3972 \cs_new_protected:Npn \@@_punct_bound_rule:NN #1#2
3973 {
3974 \tex_vrule:D
3975 width - \@@_use_punct_dim:nNN { bound } #1 #2 ~
3976 depth \c_zero_dim
3977 height \c_zero_dim \scan_stop:
3978 }
3979 % \end{macrocode}
3980 % \end{macro}
3981 %
3982 % \begin{macro}{\@@_punct_rule:NN}
3983 % 用于减少标点符号的左/右空白。
3984 % \begin{macrocode}
3985 \cs_new_protected:Npn \@@_punct_rule:NN #1#2
3986 {
3987 \tex_vrule:D
3988 width \@@_use_punct_dim:nNN { rule } #1 #2 ~
3989 depth \c_zero_dim
3990 height \c_zero_dim \scan_stop:
3991 }
3992 % \end{macrocode}
3993 % \end{macro}
3994 %
3995 % \begin{macro}{\@@_punct_glue:NN}
3996 % \changes{v3.2.7}{2013/08/23}
3997 % {标点符号左/右空白的伸展值不超过原始边界,收缩值不小于另一侧边界。}
3998 % 根据所选的标点处理方式在标点符号左/右增加的空白。
3999 % \begin{macrocode}
4000 \cs_new_protected:Npn \@@_punct_glue:NN #1#2
4001 { \@@_punct_hskip:n { \@@_use_dim_or_skip:nNN { glue } #1 #2 } }
4002 \cs_new_eq:NN \@@_punct_hskip:n \skip_horizontal:n
4003 % \end{macrocode}
4004 % \end{macro}
4005 %
4006 % \changes{v3.6.0}{2018/01/23}{总允许长标点与其他标点之间折行。}
4007 % \begin{macro}{\xeCJK_punct_kern:NN,\@@_punct_kern:NN}
4008 % 相邻两个标点之间的间距,总允许长标点与其他标点之间折行。
4009 % \begin{macrocode}
4010 \cs_new_protected:Npn \@@_punct_kern:NN #1#2
4011 {
4012 \str_if_eq:eeTF {#1} {#2}
4013 { \@@_punct_nobreak_kern:NN }
4014 {
4015 \@@_punct_if_long:NTF #1
4016 { \@@_punct_breakable_kern:NN }
4017 {
4018 \@@_punct_if_long:NTF #2
4019 { \@@_punct_breakable_kern:NN }
4020 { \@@_punct_nobreak_kern:NN }
4021 }
4022 }
4023 #1 #2
4024 }
4025 \cs_new_eq:NN \xeCJK_punct_kern:NN \@@_punct_kern:NN
4026 % \end{macrocode}
4027 % \end{macro}
4028 %
4029 % \begin{macro}{\@@_punct_nobreak_kern:NN}
4030 % \begin{macrocode}
4031 \cs_new_protected:Npn \@@_punct_nobreak_kern:NN #1#2
4032 { \@@_nobreak_hskip:n { \@@_use_dim_or_skip:nNN { kern } #1 #2 } }
4033 % \end{macrocode}
4034 % \end{macro}
4035 %
4036 % \changes{v3.2.4}{2013/07/06}
4037 % {使用 \texttt{AllowBreakBetweenPuncts} 时,相应标点符号仍能与边界对齐。}
4038 % \changes{v3.2.7}{2013/08/23}
4039 % {处理 \texttt{AllowBreakBetweenPuncts} 与 \pkg{xeCJKfntef} 的兼容问题。}
4040 %
4041 % \begin{macro}{\@@_punct_breakable_kern:NN}
4042 % \begin{macrocode}
4043 \cs_new_protected:Npn \@@_punct_breakable_kern:NN #1#2
4044 {
4045 \exp_after:wN \@@_punct_if_right:NT #1
4046 { \@@_punct_rule:NN \c_@@_right_tl #1 }
4047 \@@_punct_breakable_kern:n
4048 { \@@_use_dim_or_skip:nNN { bound_kern } #1 #2 }
4049 \@@_punct_if_right:NF #2
4050 { \@@_punct_rule:NN \c_@@_left_tl #2 }
4051 }
4052 \cs_new_eq:NN \@@_punct_breakable_kern:n \skip_horizontal:n
4053 % \end{macrocode}
4054 % \end{macro}
4055 %
4056 % \begin{variable}{\g_@@_last_punct_tl}
4057 % 用于记录当前的标点符号。
4058 % \begin{macrocode}
4059 \tl_new:N \g_@@_last_punct_tl
4060 % \end{macrocode}
4061 % \end{variable}
4062 %
4063 % \begin{macro}[int]{\xeCJK_FullLeft_and_CJK:}
4064 % \begin{macrocode}
4065 \cs_new_protected:Npn \xeCJK_FullLeft_and_CJK:
4066 {
4067 \@@_punct_if_middle:NTF \g_@@_last_punct_tl
4068 {
4069 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
4070 \xeCJK_no_break:
4071 \@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
4072 }
4073 { }
4074 \@@_select_font:
4075 }
4076 % \end{macrocode}
4077 % \end{macro}
4078 %
4079 % \begin{macro}[int]{\xeCJK_FullLeft_and_Default:}
4080 % \changes{v3.2.0}{2013/05/20}{修正 \pkg{xeCJK} 使西文在部分情况下无法断词的问题。}
4081 % \changes{v3.7.2}{2018/05/21}{再次修正 FullLeft 类字符与西文连用断词失败的问题。}
4082 % \cs{@@_nobreak_zero_glue:} 用于确保 FullLeft 类后的西文单词可以断词。
4083 % \begin{macrocode}
4084 \cs_new_protected:Npn \xeCJK_FullLeft_and_Default:
4085 {
4086 \@@_punct_if_middle:NTF \g_@@_last_punct_tl
4087 {
4088 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
4089 \xeCJK_class_group_end: \xeCJK_no_break:
4090 \@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
4091 }
4092 {
4093 \xeCJK_class_group_end:
4094 \@@_nobreak_zero_glue:
4095 }
4096 }
4097 \cs_new_protected:Npn \@@_nobreak_zero_glue:
4098 {
4099 \tex_penalty:D \c_@@_nobreak_penalty_int
4100 \skip_horizontal:N \c_zero_skip
4101 }
4102 \cs_new_protected:Npn \@@_zero_glue:
4103 { \skip_horizontal:N \c_zero_skip }
4104 % \end{macrocode}
4105 % \end{macro}
4106 %
4107 % \begin{macro}[int]{\xeCJK_FullRight_and_CJK:}
4108 % \begin{macrocode}
4109 \cs_new_protected:Npn \xeCJK_FullRight_and_CJK:
4110 {
4111 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
4112 \@@_punct_glue:NN \c_@@_right_tl \g_@@_last_punct_tl
4113 \@@_select_font:
4114 \CJKglue
4115 }
4116 % \end{macrocode}
4117 % \end{macro}
4118 %
4119 % \begin{macro}[int]{\xeCJK_FullRight_and_Default:}
4120 % \begin{macrocode}
4121 \cs_new_protected:Npn \xeCJK_FullRight_and_Default:
4122 {
4123 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
4124 \xeCJK_class_group_end:
4125 \@@_punct_glue:NN \c_@@_right_tl \g_@@_last_punct_tl
4126 }
4127 % \end{macrocode}
4128 % \end{macro}
4129 %
4130 % \begin{macro}[int]{\xeCJK_Default_and_FullLeft:nN}
4131 % \begin{macrocode}
4132 \cs_new_protected:Npn \xeCJK_Default_and_FullLeft:nN #1#2
4133 {
4134 \xeCJK_get_punct_bounds:NN \c_@@_left_tl #2
4135 \@@_Default_and_FullLeft_glue:N #2
4136 \xeCJK_class_group_begin:
4137 \xeCJK_select_punct_font:
4138 \xeCJK_clear_inter_class_toks:nn {#1} { FullLeft }
4139 \xeCJK_clear_Boundary_and_CJK_toks:
4140 \tl_gset:Nn \g_@@_last_punct_tl {#2}
4141 \@@_punct_rule:NN \c_@@_left_tl #2
4142 \xeCJK_fallback_punct_symbol:NN
4143 \CJKpunctsymbol #2
4144 }
4145 \cs_new_protected:Npn \@@_Default_and_FullLeft_glue:N #1
4146 { \@@_punct_glue:NN \c_@@_left_tl #1 }
4147 % \end{macrocode}
4148 % \end{macro}
4149 %
4150 % \begin{macro}[int]{\xeCJK_CJK_and_FullLeft:N}
4151 % \begin{macrocode}
4152 \cs_new_protected:Npn \xeCJK_CJK_and_FullLeft:N #1
4153 {
4154 \xeCJK_get_punct_bounds:NN \c_@@_left_tl #1
4155 \@@_CJK_and_FullLeft_glue:N #1
4156 \tl_gset:Nn \g_@@_last_punct_tl {#1}
4157 \@@_punct_rule:NN \c_@@_left_tl #1
4158 \@@_select_punct_font:
4159 \xeCJK_fallback_punct_symbol:NN
4160 \CJKpunctsymbol #1
4161 }
4162 \cs_new_protected:Npn \@@_CJK_and_FullLeft_glue:N #1
4163 {
4164 \CJKglue
4165 \@@_punct_glue:NN \c_@@_left_tl #1
4166 }
4167 % \end{macrocode}
4168 % \end{macro}
4169 %
4170 % \begin{macro}[int]{\xeCJK_Boundary_and_FullLeft:N}
4171 % \begin{macrocode}
4172 \cs_new_protected:Npn \xeCJK_Boundary_and_FullLeft:N #1
4173 {
4174 \xeCJK_get_punct_bounds:NN \c_@@_left_tl #1
4175 \@@_Boundary_and_FullLeft_glue:N #1
4176 \xeCJK_class_group_begin:
4177 \xeCJK_select_punct_font:
4178 \xeCJK_clear_Boundary_and_CJK_toks:
4179 \tl_gset:Nn \g_@@_last_punct_tl {#1}
4180 \@@_punct_rule:NN \c_@@_left_tl #1
4181 \xeCJK_fallback_punct_symbol:NN
4182 \CJKpunctsymbol #1
4183 }
4184 % \end{macrocode}
4185 % \end{macro}
4186 %
4187 % \begin{macro}{\@@_Boundary_and_FullLeft_glue:N}
4188 % \changes{v3.2.0}{2013/05/22}{当全角左标点前面是 \texttt{hlist}、\texttt{none}、
4189 % \texttt{glue} 和 \texttt{penalty} 等节点时,压缩其左空白。}
4190 % \changes{v3.2.4}{2013/07/03}{细化边界与全角左标点之间是否压缩空白的判断。}
4191 % \changes{v3.2.5}{2013/07/13}{细化全角左标点是否位于段首的判断。}
4192 % \changes{v3.2.5}{2013/07/13}{增加对 \pkg{enumitem} 宏包修改的 \tn{item} 的判断。}
4193 % 根据 \cs{etex_lastnodetype:D} 的值进行分别处理。
4194 % \begin{macrocode}
4195 \cs_new_protected:Npn \@@_Boundary_and_FullLeft_glue:N #1
4196 {
4197 \tl_set_eq:NN \l_@@_alignii_tl \c_@@_left_tl
4198 \group_begin: \exp_args:NNc \group_end: \cs_if_exist_use:NTF
4199 { @@_bound_type_ \int_use:N \tex_lastnodetype:D _glue:Nn }
4200 {#1}
4201 { \use:n }
4202 { \@@_punct_glue:NN \c_@@_left_tl #1 }
4203 }
4204 \tl_new:N \c_@@_alignii_tl
4205 % \end{macrocode}
4206 % \end{macro}
4207 %
4208 % \begin{macro}{\@@_bound_type_-1_glue:Nn}
4209 % \cs{etex_lastnodetype:D} 为 $-1$ 表示 empty list,常出现在盒子的起始位置,
4210 % 在段落前使用 \tn{noindent} 就是这种情况。
4211 % \begin{macrocode}
4212 \cs_new_protected:cpn { @@_bound_type_ -1 _glue:Nn } #1#2
4213 { \@@_zero_glue: }
4214 % \end{macrocode}
4215 % \end{macro}
4216 %
4217 % \begin{macro}{\@@_bound_type_1_glue:Nn}
4218 % \changes{v3.8.5}{2020/06/26}{增加盒子高度判断。}
4219 % \changes{v3.8.9}{2022/05/26}{增加位于段首的支架盒子判断。}
4220 % $1$ 表示 hlist node,在这里用来判断是否位于段首。基于正常情况下,\TeX 会在段落开头插入宽度为
4221 % \tn{parindent} 的水平盒子用于缩进。
4222 % \begin{macrocode}
4223 \cs_new_protected:cpn { @@_bound_type_ 1 _glue:Nn } #1
4224 {
4225 \int_do_while:nNnn \tex_lastnodetype:D = \c_@@_hlist_node
4226 { \@@_bound_hbox_auxi: }
4227 \@@_if_last_none:TF
4228 {
4229 \dim_case:nnF { \box_wd:N \l_@@_indent_box }
4230 {
4231 { \tex_parindent:D } { \@@_bound_hbox_auxii:nn }
4232 { \c_zero_dim } { \use_i:nn }
4233 }
4234 { \use:nn }
4235 }
4236 { \use:nn }
4237 { \hbox_unpack_drop:N \l_@@_indent_box }
4238 }
4239 \cs_new_protected:Npn \@@_bound_hbox_auxi:
4240 {
4241 \box_set_to_last:N \l_@@_tmp_box
4242 \hbox_set:Nn \l_@@_indent_box
4243 {
4244 \box_use:N \l_@@_tmp_box
4245 \hbox_unpack:N \l_@@_indent_box
4246 }
4247 }
4248 \cs_new_protected:Npn \@@_bound_hbox_auxii:nn
4249 {
4250 \dim_compare:nNnTF
4251 { \box_ht:N \l__xeCJK_tmp_box } = \c_zero_dim
4252 { \use_i:nn }
4253 { \use:nn }
4254 }
4255 \box_new:N \l_@@_indent_box
4256 % \end{macrocode}
4257 % \end{macro}
4258 %
4259 % \begin{macro}{\@@_bound_type_11_glue:Nn}
4260 % $11$ 表示 glue node,这里判断的目的是当全角左标点出现在 \LaTeX 表格的非 \texttt{p} 列行首时,
4261 % 能够对齐到单元格的边界。判断基于标准 \LaTeX 表格的列格式(\tn{@tabclassz})定义中,
4262 % 在 \texttt{l} 列和 \texttt{r} 列前为了防止 \tn{tabcolsep} 被无意 \tn{unskip} 掉,
4263 % 都加了 |\hskip1sp|,而 \texttt{c} 列前则有 \tn{hfil}。\package{enumitem} 宏包修改了
4264 % \env{description} 环境中使用的 \tn{item}(\tn{enit@postlabel@i}),
4265 % 在这里起到影响作用的是 |\penalty\z@ \hskip\labelsep|。
4266 % \begin{macrocode}
4267 \cs_new_protected:cpn { @@_bound_type_ 11 _glue:Nn } #1#2
4268 {
4269 \skip_if_finite:nTF { \tex_lastskip:D }
4270 { \@@_bound_glue_auxi:Nn #1 {#2} }
4271 { \@@_zero_glue: }
4272 }
4273 \cs_new_protected:Npn \@@_bound_glue_auxi:Nn #1#2
4274 {
4275 \@@_if_last_punct_glue:TF
4276 { \xeCJK_punct_bound_kern:N #1 }
4277 { \@@_bound_glue_auxii:n {#2} }
4278 }
4279 \cs_new_protected:Npn \@@_bound_glue_auxii:n #1
4280 {
4281 \skip_set_eq:NN \l_@@_last_skip \tex_lastskip:D
4282 \skip_if_eq:nnTF { \l_@@_last_skip } { 1sp }
4283 { \@@_zero_glue: }
4284 {
4285 \skip_if_eq:nnTF { \l_@@_last_skip } { \labelsep }
4286 {
4287 \tex_unskip:D
4288 \@@_if_last_penalty:TF
4289 {
4290 \int_compare:nNnTF \tex_lastpenalty:D = \c_zero_int
4291 { \skip_horizontal:N \l_@@_last_skip }
4292 { \skip_horizontal:N \l_@@_last_skip #1 }
4293 }
4294 { \skip_horizontal:N \l_@@_last_skip #1 }
4295 }
4296 {#1}
4297 }
4298 }
4299 % \end{macrocode}
4300 % \end{macro}
4301 %
4302 % \begin{macro}{\@@_bound_type_12_glue:Nn}
4303 % $12$ 表示 kern node,用于判断之前的字符是否是 CJK 类,如果是,则插入 \tn{CJKglue}。
4304 % \begin{macrocode}
4305 \cs_new_protected:cpn { @@_bound_type_ 12 _glue:Nn } #1#2
4306 {
4307 \xeCJK_if_last_node:nF { CJK }
4308 { \xeCJK_if_last_node:nF { CJK-space } { \use_none:nn } }
4309 \xeCJK_remove_node: \CJKglue
4310 #2
4311 }
4312 % \end{macrocode}
4313 % \end{macro}
4314 %
4315 % \begin{macro}{\@@_bound_type_13_glue:n}
4316 % $13$ 表示 penalty node,这里判断的目的是全角左标点出现在 \LaTeX 列表环境的 \tn{item} 后面时,
4317 % 能对齐到边界。判断基于 \tn{item} 的内部定义 \tn{@item} 对 \tn{everypar} 进行了修改,在这里起
4318 % 到影响作用的是 |\box\@labels \penalty\z@|。以上判断都比较粗略,暂时也没有想起更好的办法。
4319 % \begin{macrocode}
4320 \cs_new_protected:cpn { @@_bound_type_ 13 _glue:Nn } #1#2
4321 {
4322 \@@_if_last_punct_penalty:TF
4323 { \xeCJK_punct_bound_kern:N #1 }
4324 {
4325 \int_compare:nNnTF \tex_lastpenalty:D = \c_zero_int
4326 {
4327 \tex_unpenalty:D
4328 \@@_if_last_hlist:TF
4329 { \tex_penalty:D \c_zero_int }
4330 { \tex_penalty:D \c_zero_int #2 }
4331 }
4332 {#2}
4333 }
4334 }
4335 % \end{macrocode}
4336 % \end{macro}
4337 %
4338 % \begin{macro}[int]{\xeCJK_Default_and_FullRight:nN}
4339 % \begin{macrocode}
4340 \cs_new_protected:Npn \xeCJK_Default_and_FullRight:nN #1#2
4341 {
4342 \xeCJK_get_punct_bounds:NN \c_@@_right_tl #2
4343 \@@_Default_and_FullRight_glue:N #2
4344 \xeCJK_class_group_begin:
4345 \xeCJK_select_punct_font:
4346 \xeCJK_clear_inter_class_toks:nn {#1} { FullRight }
4347 \xeCJK_clear_Boundary_and_CJK_toks:
4348 \tl_gset:Nn \g_@@_last_punct_tl {#2}
4349 \xeCJK_FullRight_symbol:N #2
4350 }
4351 % \end{macrocode}
4352 % \end{macro}
4353 %
4354 % \begin{macro}[int]{\xeCJK_Boundary_and_FullRight:N}
4355 % \begin{macrocode}
4356 \cs_new_protected:Npn \xeCJK_Boundary_and_FullRight:N #1
4357 {
4358 \xeCJK_get_punct_bounds:NN \c_@@_right_tl #1
4359 \xeCJK_if_last_punct:TF
4360 {
4361 \tl_set_eq:NN \l_@@_alignii_tl \c_@@_right_tl
4362 \xeCJK_punct_bound_kern:N
4363 }
4364 { \@@_Default_and_FullRight_glue:N }
4365 #1
4366 \xeCJK_class_group_begin:
4367 \xeCJK_select_punct_font:
4368 \xeCJK_clear_Boundary_and_CJK_toks:
4369 \tl_gset:Nn \g_@@_last_punct_tl {#1}
4370 \xeCJK_FullRight_symbol:N #1
4371 }
4372 % \end{macrocode}
4373 % \end{macro}
4374 %
4375 % \begin{macro}[int]{\xeCJK_CJK_and_FullRight:N}
4376 % \begin{macrocode}
4377 \cs_new_protected:Npn \xeCJK_CJK_and_FullRight:N #1
4378 {
4379 \xeCJK_get_punct_bounds:NN \c_@@_right_tl #1
4380 \@@_CJK_and_FullRight_glue:N #1
4381 \tl_gset:Nn \g_@@_last_punct_tl {#1}
4382 \@@_select_punct_font:
4383 \xeCJK_FullRight_symbol:N #1
4384 }
4385 % \end{macrocode}
4386 % \end{macro}
4387 %
4388 % \changes{v3.6.0}{2018/01/23}{解决标点中间被隔开的禁则与压缩问题。}
4389 % \changes{v3.7.3}{2019/04/15}{修复 penalty 数值错误。}
4390 % \changes{v3.8.3}{2020/04/27}{修复 \opt{xCJKecglue} 选项。}
4391 % \changes{v3.8.6}{2020/10/18}{正确还原标点符号后的 penalty 状态。}
4392 %
4393 % \begin{macro}{\xeCJK_if_last_punct:TF}
4394 % \changes{v3.6.1}{2018/02/25}{细化判断。}
4395 % 判断之前是否是一个标点符号。
4396 % \begin{macrocode}
4397 \cs_new_protected:Npn \xeCJK_if_last_punct:TF
4398 {
4399 \bool_set_false:N \l_@@_last_penalty_bool
4400 \@@_if_last_glue:TF
4401 { \@@_if_last_punct_glue:TF }
4402 {
4403 \@@_if_last_penalty:TF
4404 { \@@_if_last_punct_penalty:TF }
4405 { \use_ii:nn }
4406 }
4407 }
4408 \cs_new_protected:Npn \@@_if_last_punct_glue:TF
4409 {
4410 \prop_get:NoNTF \g_@@_punct_skip_prop
4411 { \skip_use:N \tex_lastskip:D } \l_@@_tmp_tl
4412 { \@@_if_last_punct_glue_auxi:TF }
4413 { \@@_if_last_punct_glue_auxii:TF }
4414 }
4415 \cs_new_protected:Npn \@@_if_last_punct_glue_auxi:TF
4416 {
4417 \skip_set_eq:NN \l_@@_last_skip \tex_lastskip:D
4418 \tex_unskip:D
4419 \int_compare:nNnTF \tex_lastpenalty:D = \c_@@_nobreak_penalty_int
4420 { \@@_if_last_punct_auxi:TF { \use_i:nn } }
4421 {
4422 \xeCJK_if_last_node:TF
4423 { \@@_if_last_punct_auxii:TF { \use_i:nn } }
4424 { \use:n }
4425 }
4426 { \skip_horizontal:N \l_@@_last_skip \use_ii:nn }
4427 }
4428 \cs_new_protected:Npn \@@_if_last_punct_glue_auxii:TF
4429 {
4430 \group_begin:
4431 \g_@@_space_factor_int \tex_spacefactor:D
4432 \skip_if_eq:nnTF { \tex_lastskip:D } { \c_xeCJK_space_skip_tl }
4433 { \group_end: \@@_if_last_punct_glue_auxiii:TF }
4434 { \group_end: \use_ii:nn }
4435 }
4436 \cs_new_protected:Npn \@@_if_last_punct_glue_auxiii:TF
4437 {
4438 \skip_set_eq:NN \l_@@_tmp_skip \tex_lastskip:D
4439 \tex_unskip:D
4440 \@@_if_last_glue:TF
4441 {
4442 \prop_get:NoNTF \g_@@_punct_skip_prop
4443 { \skip_use:N \tex_lastskip:D } \l_@@_tmp_tl
4444 { \@@_if_last_punct_glue_auxi:TF { \use_i:nn } }
4445 { \use:n }
4446 }
4447 { \use:n }
4448 { \skip_horizontal:N \l_@@_tmp_skip \use_ii:nn }
4449 }
4450 \cs_new_protected:Npn \@@_if_last_punct_penalty:TF
4451 {
4452 \int_set_eq:NN \l_@@_last_penalty_int \tex_lastpenalty:D
4453 \tex_unpenalty:D
4454 \bool_set_true:N \l_@@_last_penalty_bool
4455 \@@_if_last_glue:TF
4456 { \@@_if_last_punct_glue:TF { \use_i:nn } }
4457 { \use:n }
4458 { \@@_last_punct_penalty_false:nn }
4459 }
4460 \cs_new_protected:Npn \@@_last_punct_penalty_false:nn #1#2
4461 {
4462 \bool_set_false:N \l_@@_last_penalty_bool
4463 \tex_penalty:D \l_@@_last_penalty_int
4464 #2
4465 }
4466 \cs_new_protected:Npn \@@_if_last_punct_auxi:TF
4467 {
4468 \tex_unpenalty:D
4469 \bool_if:NF \l_@@_last_penalty_bool
4470 {
4471 \bool_set_true:N \l_@@_last_penalty_bool
4472 \int_set_eq:NN \l_@@_last_penalty_int \c_@@_nobreak_penalty_int
4473 }
4474 \xeCJK_if_last_node:TF
4475 { \@@_if_last_punct_auxii:TF { \use_i:nn } }
4476 { \use:n }
4477 { \xeCJK_no_break: \use_ii:nn }
4478 }
4479 \cs_new_protected:Npn \@@_if_last_punct_auxii:TF
4480 {
4481 \dim_compare:nNnTF \l_@@_last_kern_dim > \c_zero_dim
4482 { \@@_if_last_punct_auxiii:TF }
4483 { \@@_make_node:N \l_@@_last_kern_dim \use_ii:nn }
4484 }
4485 \cs_new_protected:Npn \@@_if_last_punct_auxiii:TF
4486 {
4487 \int_case:nnTF { \tex_XeTeXcharclass:D \l_@@_last_kern_dim }
4488 {
4489 { \xeCJK_class_num:n { FullRight } }
4490 { \tl_set_eq:NN \l_@@_aligni_tl \c_@@_right_tl }
4491 { \xeCJK_class_num:n { FullLeft } }
4492 { \tl_set_eq:NN \l_@@_aligni_tl \c_@@_left_tl }
4493 }
4494 { \@@_if_last_punct_auxiv:TF }
4495 { \use_ii:nn }
4496 }
4497 \cs_new_protected:Npn \@@_if_last_punct_auxiv:TF
4498 {
4499 \dim_set_eq:NN \l_@@_tmp_dim \l_@@_last_kern_dim
4500 \xeCJK_if_last_node:TF
4501 {
4502 \tl_gset:Nx \g_@@_last_punct_tl
4503 { \tex_Uchar:D \l_@@_tmp_dim }
4504 \dim_set_eq:NN \l_@@_last_bound_dim \l_@@_last_kern_dim
4505 \use_i:nn
4506 }
4507 { \@@_make_node:N \l_@@_tmp_dim \use_ii:nn }
4508 }
4509 \tl_new:N \l_@@_aligni_tl
4510 \tl_new:N \l_@@_alignii_tl
4511 \int_new:N \l_@@_last_penalty_int
4512 \dim_new:N \l_@@_last_bound_dim
4513 \bool_new:N \l_@@_last_penalty_bool
4514 % \end{macrocode}
4515 % \end{macro}
4516 %
4517 % \begin{macro}{\xeCJK_if_last_node:TF}
4518 % \begin{macrocode}
4519 \cs_new_protected:Npn \xeCJK_if_last_node:TF #1#2
4520 {
4521 \@@_if_last_kern:TF
4522 {
4523 \dim_set_eq:NN \l_@@_last_kern_dim \tex_lastkern:D
4524 \tex_unkern:D
4525 \@@_if_last_kern:TF
4526 {
4527 \dim_compare:nNnTF \tex_lastkern:D = { - \l_@@_last_kern_dim }
4528 { \tex_unkern:D #1 }
4529 { \tex_kern:D \l_@@_last_kern_dim #2 }
4530 }
4531 { \tex_kern:D \l_@@_last_kern_dim #2 }
4532 }
4533 {#2}
4534 }
4535 \dim_new:N \l_@@_last_kern_dim
4536 % \end{macrocode}
4537 % \end{macro}
4538 %
4539 % \changes{v3.6.0}{2018/01/14}
4540 % {修正标点同为 \texttt{LongPunct} 与 \texttt{MiddlePunct} 时的实现错误。}
4541 % \changes{v3.6.0}{2018/01/14}
4542 % {\texttt{Default} 类与 \texttt{MiddlePunct} 之间不应该有 \tn{CJKglue}。}
4543 %
4544 % \begin{macro}
4545 % {\@@_CJK_and_FullRight_glue:N,\@@_Default_and_FullRight_glue:N}
4546 % \begin{macrocode}
4547 \cs_new_protected:Npn \@@_CJK_and_FullRight_glue:N #1
4548 {
4549 \@@_punct_if_long:NTF #1
4550 { \xeCJK_allow_break: }
4551 { \xeCJK_no_break: }
4552 \@@_punct_if_middle:NT #1
4553 {
4554 \CJKglue
4555 \@@_punct_glue:NN \c_@@_right_tl #1
4556 \@@_punct_rule:NN \c_@@_left_tl #1
4557 }
4558 }
4559 \cs_new_protected:Npn \@@_Default_and_FullRight_glue:N #1
4560 {
4561 \@@_punct_if_long:NTF #1
4562 { \xeCJK_allow_break: }
4563 { \xeCJK_no_break: }
4564 \@@_punct_if_middle:NT #1
4565 {
4566 \@@_punct_glue:NN \c_@@_right_tl #1
4567 \@@_punct_rule:NN \c_@@_left_tl #1
4568 }
4569 }
4570 % \end{macrocode}
4571 % \end{macro}
4572 %
4573 % \begin{macro}[int]{\xeCJK_FullLeft_and_FullLeft:N}
4574 % \begin{macrocode}
4575 \cs_new_protected:Npn \xeCJK_FullLeft_and_FullLeft:N #1
4576 {
4577 \xeCJK_get_punct_bounds:NN \c_@@_left_tl #1
4578 \xeCJK_get_punct_kerning:oN \g_@@_last_punct_tl #1
4579 \@@_punct_kern:NN \g_@@_last_punct_tl #1
4580 \tl_gset:Nn \g_@@_last_punct_tl {#1}
4581 \xeCJK_fallback_punct_symbol:NN
4582 \CJKpunctsymbol #1
4583 }
4584 % \end{macrocode}
4585 % \end{macro}
4586 %
4587 % \begin{macro}[int]{\xeCJK_FullLeft_and_FullRight:N}
4588 % \begin{macrocode}
4589 \cs_new_protected:Npn \xeCJK_FullLeft_and_FullRight:N #1
4590 {
4591 \xeCJK_get_punct_bounds:NN \c_@@_right_tl #1
4592 \xeCJK_get_punct_kerning:oN \g_@@_last_punct_tl #1
4593 \@@_punct_kern:NN \g_@@_last_punct_tl #1
4594 \tl_gset:Nn \g_@@_last_punct_tl {#1}
4595 \xeCJK_FullRight_symbol:N #1
4596 }
4597 % \end{macrocode}
4598 % \end{macro}
4599 %
4600 % \begin{macro}[int]{\xeCJK_FullRight_and_FullLeft:N}
4601 % \begin{macrocode}
4602 \cs_new_protected:Npn \xeCJK_FullRight_and_FullLeft:N #1
4603 {
4604 \xeCJK_get_punct_bounds:NN \c_@@_left_tl #1
4605 \xeCJK_get_punct_kerning:oN \g_@@_last_punct_tl #1
4606 \xeCJK_punct_kern:NN \g_@@_last_punct_tl #1
4607 \tl_gset:Nn \g_@@_last_punct_tl {#1}
4608 \xeCJK_fallback_punct_symbol:NN
4609 \CJKpunctsymbol #1
4610 }
4611 % \end{macrocode}
4612 % \end{macro}
4613 %
4614 % \begin{macro}[int]{\xeCJK_FullRight_and_FullRight:N}
4615 % \begin{macrocode}
4616 \cs_new_protected:Npn \xeCJK_FullRight_and_FullRight:N #1
4617 {
4618 \xeCJK_get_punct_bounds:NN \c_@@_right_tl #1
4619 \xeCJK_get_punct_kerning:oN \g_@@_last_punct_tl #1
4620 \@@_punct_kern:NN \g_@@_last_punct_tl #1
4621 \tl_gset:Nn \g_@@_last_punct_tl {#1}
4622 \xeCJK_FullRight_symbol:N #1
4623 }
4624 % \end{macrocode}
4625 % \end{macro}
4626 %
4627 % \subsection{全角右标点后的断行}
4628 %
4629 % \begin{macro}{CheckFullRight}
4630 % \changes{v3.1.1}{2012/12/02}{处理全角右标点之后的断行问题。}
4631 % 选项设置。
4632 % \begin{macrocode}
4633 \keys_define:nn { xeCJK / options }
4634 {
4635 CheckFullRight .choice: ,
4636 CheckFullRight / true .code:n =
4637 {
4638 \cs_if_eq:NNF \xeCJK_FullRight_and_Boundary: \xeCJK_check_FullRight:
4639 {
4640 \cs_set_eq:NN \@@_save_FullRight_check:
4641 \xeCJK_FullRight_and_Boundary:
4642 \cs_set_eq:NN \@@_save_FullRight_symbol:N
4643 \xeCJK_FullRight_symbol:N
4644 \cs_set_eq:NN \xeCJK_FullRight_and_Boundary:
4645 \xeCJK_check_FullRight:
4646 \cs_set_eq:NN \xeCJK_FullRight_symbol:N
4647 \xeCJK_check_FullRight_symbol:Nw
4648 }
4649 } ,
4650 CheckFullRight / false .code:n =
4651 {
4652 \cs_if_eq:NNT \xeCJK_FullRight_and_Boundary: \xeCJK_check_FullRight:
4653 {
4654 \cs_set_eq:NN \xeCJK_FullRight_and_Boundary:
4655 \@@_save_FullRight_check:
4656 \cs_set_eq:NN \xeCJK_FullRight_symbol:N
4657 \@@_save_FullRight_symbol:N
4658 }
4659 } ,
4660 CheckFullRight .default:n = { true }
4661 }
4662 % \end{macrocode}
4663 % \end{macro}
4664 %
4665 % \begin{macro}[int]{\xeCJK_FullRight_symbol:N}
4666 % \begin{macrocode}
4667 \cs_new_protected:Npn \xeCJK_FullRight_symbol:N
4668 {
4669 \xeCJK_fallback_punct_symbol:NN
4670 \CJKpunctsymbol
4671 }
4672 % \end{macrocode}
4673 % \end{macro}
4674 %
4675 % \begin{macro}[int]{\xeCJK_check_FullRight:}
4676 % \begin{macrocode}
4677 \cs_new_protected:Npn \xeCJK_check_FullRight:
4678 {
4679 \xeCJK_get_punct_bounds:No \c_@@_right_tl \g_@@_last_punct_tl
4680 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
4681 \group_align_safe_begin:
4682 \token_case_meaning:NoTF \l_peek_token
4683 { \l_@@_no_break_cs_case_tl }
4684 {
4685 \group_align_safe_end:
4686 \xeCJK_no_break:
4687 \group_insert_after:N \xeCJK_no_break:
4688 }
4689 { \group_align_safe_end: }
4690 \exp_after:wN \xeCJK_punct_node:N \g_@@_last_punct_tl
4691 \xeCJK_class_group_end:
4692 \@@_punct_glue:NN \c_@@_right_tl \g_@@_last_punct_tl
4693 }
4694 \prg_generate_conditional_variant:Nnn \token_case_meaning:Nn { No } { TF , F }
4695 % \end{macrocode}
4696 % \end{macro}
4697 %
4698 % \begin{macro}[int]{\xeCJK_check_FullRight_symbol:Nw}
4699 % \begin{macrocode}
4700 \cs_new_protected:Npn \xeCJK_check_FullRight_symbol:Nw #1
4701 { \peek_remove_spaces:n { \@@_save_FullRight_symbol:N #1 } }
4702 % \end{macrocode}
4703 % \end{macro}
4704 %
4705 % \begin{macro}[int]{\xeCJK_cs_case_keys_define:nNNnn}
4706 % \begin{macrocode}
4707 \cs_new_protected:Npn \xeCJK_cs_case_keys_define:nNNnn #1#2#3#4#5
4708 {
4709 \tl_new:N #2
4710 \seq_new:N #3
4711 \keys_define:nn { xeCJK / options }
4712 {
4713 #1 .code:n =
4714 {
4715 \seq_set_split:Nnn #3 { } {##1}
4716 \@@_update_cs_case_tl:NNnn #2#3 {#4} {#5}
4717 } ,
4718 #1+ .code:n =
4719 {
4720 \tl_map_inline:nn {##1}
4721 { \seq_if_in:NnF #3 {####1} { \seq_put_right:Nn #3 {####1} } }
4722 \@@_update_cs_case_tl:NNnn #2#3 {#4} {#5}
4723 } ,
4724 #1- .code:n =
4725 {
4726 \tl_map_inline:nn {##1} { \seq_remove_all:Nn #3 {####1} }
4727 \@@_update_cs_case_tl:NNnn #2#3 {#4} {#5}
4728 }
4729 }
4730 }
4731 \cs_new_protected:Npn \@@_update_cs_case_tl:NNnn #1#2#3#4
4732 {
4733 \tl_clear:N #1
4734 \seq_map_inline:Nn #2 { \tl_put_right:Nn #1 { {##1} {#3} } }
4735 #4
4736 }
4737 % \end{macrocode}
4738 % \end{macro}
4739 %
4740 % \begin{macro}{NoBreakCS}
4741 % 设置不能在全角右标点之后断行的控制序列。
4742 % \begin{macrocode}
4743 \xeCJK_cs_case_keys_define:nNNnn { NoBreakCS }
4744 \l_@@_no_break_cs_case_tl \l_@@_no_break_cs_seq { } { }
4745 % \end{macrocode}
4746 % \end{macro}
4747 %
4748 % \begin{macro}{\xeCJKnobreak}
4749 % \changes{v3.1.1}{2012/12/03}{增加 \tn{nobreak} 的 \pkg{xeCJK} 版本。}
4750 % 为保险起见,我们在这里用了一个循环。
4751 % \begin{macrocode}
4752 \NewDocumentCommand \xeCJKnobreak { }
4753 {
4754 \bool_set_true:N \l_@@_tmp_bool
4755 \int_while_do:nNnn \tex_lastnodetype:D = \c_@@_glue_node
4756 {
4757 \bool_if:NTF \l_@@_tmp_bool
4758 {
4759 \bool_set_false:N \l_@@_tmp_bool
4760 \skip_set_eq:NN \l_@@_last_skip \tex_lastskip:D
4761 }
4762 { \skip_add:Nn \l_@@_last_skip \tex_lastskip:D }
4763 \tex_unskip:D
4764 }
4765 \xeCJK_if_last_node:TF
4766 {
4767 \dim_set_eq:NN \l_@@_tmp_dim \l_@@_last_kern_dim
4768 \xeCJK_if_last_node:TF
4769 {
4770 \@@_if_last_glue:TF
4771 {
4772 \exp_args:NNNo \tex_unskip:D \xeCJK_no_break:
4773 \skip_horizontal:n { \skip_use:N \tex_lastskip:D }
4774 }
4775 \@@_make_node:N \l_@@_last_kern_dim
4776 }
4777 { }
4778 \@@_make_node:N \l_@@_tmp_dim
4779 }
4780 { }
4781 \xeCJK_no_break:
4782 \bool_if:NF \l_@@_tmp_bool
4783 { \skip_horizontal:N \l_@@_last_skip }
4784 }
4785 % \end{macrocode}
4786 % \end{macro}
4787 %
4788 % \subsection{段末孤字处理}
4789 %
4790 % \begin{macro}{CheckSingle}
4791 % 孤字处理功能选项。
4792 % \begin{macrocode}
4793 \keys_define:nn { xeCJK / options }
4794 {
4795 CheckSingle .choice: ,
4796 CheckSingle / true .code:n =
4797 {
4798 \cs_if_eq:NNF \xeCJK_CJK_and_CJK:N \xeCJK_check_single:Nw
4799 {
4800 \cs_set_eq:NN \@@_check_single_save:N \xeCJK_CJK_and_CJK:N
4801 \cs_set_eq:NN \xeCJK_CJK_and_CJK:N \xeCJK_check_single:Nw
4802 }
4803 } ,
4804 CheckSingle / false .code:n =
4805 {
4806 \cs_if_eq:NNT \xeCJK_CJK_and_CJK:N \xeCJK_check_single:Nw
4807 { \cs_set_eq:NN \xeCJK_CJK_and_CJK:N \@@_check_single_save:N }
4808 } ,
4809 CheckSingle .default:n = { true } ,
4810 CJKchecksingle .meta:n = { CheckSingle = true }
4811 }
4812 % \end{macrocode}
4813 % \end{macro}
4814 %
4815 % \changes{v3.3.1}{2015/04/08}{新选项 \texttt{WidowPenalty}。}
4816 %
4817 % \begin{macro}{WidowPenalty}
4818 % 设置段末汉字的 penalty,默认值是 \num{10000}。
4819 % \begin{macrocode}
4820 \keys_define:nn { xeCJK / options }
4821 {
4822 WidowPenalty .int_set:N = \l_@@_widow_penalty_int ,
4823 WidowPenalty .default:n = { 10 000 }
4824 }
4825 % \end{macrocode}
4826 % \end{macro}
4827 %
4828 % \begin{macro}[int]{\xeCJK_widow_penalty:}
4829 % 预防段末孤字而插入的 penalty,值为 \cs{l_@@_widow_penalty_int}。
4830 % \begin{macrocode}
4831 \cs_new_protected:Npn \xeCJK_widow_penalty:
4832 { \tex_penalty:D \l_@@_widow_penalty_int }
4833 % \end{macrocode}
4834 % \end{macro}
4835 %
4836 % \changes{v3.4.7}{2017/03/20}{简化 \texttt{CheckSingle} 的实现,不再展开宏。}
4837 %
4838 % \begin{macro}[int]{\xeCJK_check_single:Nw}
4839 % \begin{macro}{\@@_check_single_end:N}
4840 % \begin{macrocode}
4841 \cs_new_protected:Npn \xeCJK_check_single:Nw #1
4842 {
4843 \group_align_safe_begin:
4844 \peek_catcode:NTF \c_catcode_letter_token
4845 { \xeCJK_check_single:NNw #1 }
4846 {
4847 \token_if_other:NTF \l_peek_token
4848 { \xeCJK_check_single:NNw }
4849 { \@@_check_single_end:N }
4850 #1
4851 }
4852 }
4853 \cs_new_protected:Npn \@@_check_single_end:N
4854 {
4855 \group_align_safe_end:
4856 \@@_check_single_save:N
4857 }
4858 % \end{macrocode}
4859 % \end{macro}
4860 % \end{macro}
4861 %
4862 % \begin{macro}[int]{\xeCJK_check_single:NNw}
4863 % \begin{macro}{\@@_check_single_aux:nNNw}
4864 % \changes{v3.1.1}{2012/12/04}{改进定义,减少使用 \texttt{peek} 函数的次数。}
4865 % \changes{v3.2.7}{2013/08/30}{与 \tn{CJKspace} 兼容。}
4866 % 使用 \cs{group_align_safe_begin:} 和 \cs{group_align_safe_end:} 是为了防止在表格
4867 % 里面报错。
4868 % \begin{macrocode}
4869 \cs_new_protected:Npn \xeCJK_check_single:NNw #1#2
4870 {
4871 \xeCJK_peek_catcode_ignore_spaces:NTF \c_catcode_letter_token
4872 {
4873 \bool_if:NTF \l_@@_peek_ignore_spaces_bool
4874 {
4875 \bool_if:NTF \l_@@_reserve_space_bool
4876 { \@@_check_single_end:N #1 #2 ~ }
4877 { \@@_check_single_space:NN #1#2 }
4878 }
4879 { \@@_check_single_end:N #1 #2 }
4880 }
4881 {
4882 \token_if_other:NTF \l_peek_token
4883 {
4884 \bool_if:NTF \l_@@_peek_ignore_spaces_bool
4885 { \@@_check_single_space:NN }
4886 { \@@_check_single_end:N }
4887 }
4888 {
4889 \bool_if:NTF \l_@@_peek_ignore_spaces_bool
4890 { \@@_check_single_aux:nNNw { ~ } }
4891 { \@@_check_single_aux:nNNw { } }
4892 }
4893 #1 #2
4894 }
4895 }
4896 \cs_new_protected:Npn \@@_check_single_aux:nNNw #1#2#3
4897 {
4898 \token_if_cs:NTF \l_peek_token
4899 { \xeCJK_check_single_cs:NNn }
4900 { \xeCJK_check_single_end:NNnw }
4901 #2 #3 {#1}
4902 }
4903 % \end{macrocode}
4904 % \end{macro}
4905 % \end{macro}
4906 %
4907 % \begin{macro}[int]{\xeCJK_check_single_end:NNnw}
4908 % \begin{macro}{\@@_check_single_end_aux:NNn,\@@_check_single_end_equation:NNnw}
4909 % \begin{macrocode}
4910 \cs_new_protected:Npn \@@_check_single_end_aux:NNn #1#2#3
4911 { \@@_check_single_end:N #1 #2 #3 }
4912 \cs_new_eq:NN \xeCJK_check_single_end:NNnw \@@_check_single_end_aux:NNn
4913 \cs_new_protected:Npn \@@_check_single_end_equation:NNnw
4914 {
4915 \token_if_math_toggle:NTF \l_peek_token
4916 { \xeCJK_check_single_equation:NNnNw }
4917 { \@@_check_single_end_aux:NNn }
4918 }
4919 % \end{macrocode}
4920 % \end{macro}
4921 % \end{macro}
4922 %
4923 % \begin{macro}{PlainEquation}
4924 % \changes{v3.1.1}{2012/12/06}{增加 \texttt{PlainEquation} 选项。}
4925 % \begin{macrocode}
4926 \keys_define:nn { xeCJK / options }
4927 {
4928 PlainEquation .choice: ,
4929 PlainEquation / true .code:n =
4930 {
4931 \cs_set_eq:NN \xeCJK_check_single_end:NNnw
4932 \@@_check_single_end_equation:NNnw
4933 } ,
4934 PlainEquation / false .code:n =
4935 {
4936 \cs_set_eq:NN \xeCJK_check_single_end:NNnw
4937 \@@_check_single_end_aux:NNn
4938 } ,
4939 PlainEquation .default:n = { true } ,
4940 }
4941 % \end{macrocode}
4942 % \end{macro}
4943 %
4944 % \begin{macro}{\@@_check_single_space:NN}
4945 % \changes{v3.1.1}{2012/12/13}
4946 % {\texttt{CheckSingle} 支持段末“汉字$+$汉字$+$空格$+$汉字/标点”的形式。}
4947 % \changes{v3.1.2}{2012/12/27}
4948 % {使用 \cs{xeCJK_if_CJK_class:NTF} 来代替 \cs{int_case:nnn} 判断是否是 CJK 字符类。}
4949 % \begin{macrocode}
4950 \cs_new_protected:Npn \@@_check_single_space:NN #1#2
4951 {
4952 \xeCJK_if_CJK_class:NTF #2
4953 {
4954 \xeCJK_if_CJK_class:NTF \l_peek_token
4955 { \@@_check_single_end:N #1 #2 }
4956 { \@@_check_single_end:N #1 #2 ~ }
4957 }
4958 { \@@_check_single_end:N #1 #2 ~ }
4959 }
4960 % \end{macrocode}
4961 % \end{macro}
4962 %
4963 % \begin{macro}[int]{\xeCJK_check_single_equation:NNnNw}
4964 % \begin{macrocode}
4965 \cs_new_protected:Npn \xeCJK_check_single_equation:NNnNw #1#2#3#4
4966 {
4967 \peek_catcode:NTF \c_math_toggle_token
4968 {
4969 \xeCJK_widow_penalty: \@@_check_single_end:N #1
4970 \xeCJK_make_node:n { CJK-widow } #2 #4
4971 }
4972 { \@@_check_single_end:N #1 #2#3#4 }
4973 }
4974 % \end{macrocode}
4975 % \end{macro}
4976 %
4977 % \changes{v3.2.3}{2013/06/11}
4978 % {解决 \texttt{CheckSingle} 选项与 \pkg{tablists} 宏包的冲突。}
4979 % \changes{v3.2.4}{2013/06/26}
4980 % {解决使用 \texttt{CheckSingle} 时,某些 \tn{CJKglue} 不能被正确加入的问题。}
4981 %
4982 % \begin{macro}[int]{\xeCJK_check_single_cs:NNn}
4983 % \changes{v3.3.1}{2015/04/06}{补充可能遗漏的空格。}
4984 % 在使用 \texttt{CheckSingle} 选项时,在 \package{tablists} 宏包定义的
4985 % \env{tabenum} 环境中会出现下面的错误:
4986 % \begin{verbatim}
4987 % ! Forbidden control sequence found while scanning use of \use_ii:nn.
4988 % <inserted text>
4989 % \par
4990 % l.10 \item
4991 % \end{verbatim}
4992 % 原因在于 \env{tabenum} 实际上是一个 \TeX 对齐环境(\tn{halign}),\tn{par} 在
4993 % 其中被重定义为 \tn{cr}。而在下面 \cs{token_case_meaning:NnF} 的分支里有对 \tn{par} 的
4994 % \tn{ifx} 判断。解决办法是将判断用 \cs{group_align_safe_begin:} 和
4995 % \cs{group_align_safe_end:} 包起来。或者改用原语 \cs{tex_par:D} 作为判断条件。
4996 % \begin{macrocode}
4997 \cs_new_protected:Npn \xeCJK_check_single_cs:NNn #1#2#3
4998 {
4999 \token_case_meaning:NoF \l_peek_token
5000 { \l_@@_check_single_cs_case_tl }
5001 { \use_iii:nnn }
5002 { \xeCJK_check_single_env:nnNn }
5003 {
5004 \xeCJK_widow_penalty:
5005 \@@_check_single_end:N #1
5006 \xeCJK_make_node:n { CJK-widow } #2#3
5007 }
5008 { \@@_check_single_end:N #1 #2#3 }
5009 }
5010 \tl_new:N \l_@@_check_single_cs_case_tl
5011 % \end{macrocode}
5012 % \end{macro}
5013 %
5014 % \begin{macro}[int]{\xeCJK_check_single_env:nnNn}
5015 % \begin{macrocode}
5016 \cs_new_protected:Npn \xeCJK_check_single_env:nnNn #1#2#3#4
5017 {
5018 \str_case_e:noTF {#4}
5019 { \l_@@_inline_env_case_tl }
5020 {#2}
5021 {#1}
5022 #3 {#4}
5023 }
5024 \prg_generate_conditional_variant:Nnn \str_case_e:nn { no } { TF }
5025 % \end{macrocode}
5026 % \end{macro}
5027 %
5028 % \changes{v3.1.1}{2012/12/04}{增加 \texttt{NewLineCS} 和 \texttt{EnvCS} 选项。}
5029 %
5030 % \begin{macro}{NewLineCS}
5031 % \begin{macrocode}
5032 \xeCJK_cs_case_keys_define:nNNnn { NewLineCS }
5033 \l_@@_new_line_cs_case_tl \l_@@_new_line_cs_seq
5034 { \use_ii:nnn }
5035 {
5036 \tl_concat:NNN \l_@@_check_single_cs_case_tl
5037 \l_@@_new_line_cs_case_tl \l_@@_env_cs_case_tl
5038 }
5039 % \end{macrocode}
5040 % \end{macro}
5041 %
5042 % \begin{macro}{EnvCS}
5043 % \begin{macrocode}
5044 \xeCJK_cs_case_keys_define:nNNnn { EnvCS }
5045 \l_@@_env_cs_case_tl \l_@@_env_cs_seq
5046 { \use:n }
5047 {
5048 \tl_concat:NNN \l_@@_check_single_cs_case_tl
5049 \l_@@_new_line_cs_case_tl \l_@@_env_cs_case_tl
5050 }
5051 % \end{macrocode}
5052 % \end{macro}
5053 %
5054 % \begin{macro}{InlineEnv}
5055 % \changes{v3.1.1}{2012/12/05}{改变行内环境的设置方式,从而使用 \cs{str_case_x:nnn}
5056 % 代替原来的 \cs{clist_if_in:NnTF} 来判断是否是行内环境。}
5057 % \begin{macrocode}
5058 \keys_define:nn { xeCJK / options }
5059 {
5060 InlineEnv .code:n =
5061 {
5062 \seq_set_from_clist:Nn \l_@@_inline_env_seq {#1}
5063 \@@_update_inline_env_case_tl:
5064 } ,
5065 InlineEnv+ .code:n =
5066 {
5067 \clist_map_inline:nn {#1}
5068 {
5069 \seq_if_in:NnF \l_@@_inline_env_seq {##1}
5070 { \seq_put_right:Nn \l_@@_inline_env_seq {##1} }
5071 }
5072 \@@_update_inline_env_case_tl:
5073 } ,
5074 InlineEnv- .code:n =
5075 {
5076 \clist_map_inline:nn {#1}
5077 { \seq_remove_all:Nn \l_@@_inline_env_seq {##1} }
5078 \@@_update_inline_env_case_tl:
5079 }
5080 }
5081 \seq_new:N \l_@@_inline_env_seq
5082 % \end{macrocode}
5083 % \end{macro}
5084 %
5085 % \begin{macro}{\@@_update_inline_env_case_tl:}
5086 % \begin{macrocode}
5087 \cs_new_protected:Npn \@@_update_inline_env_case_tl:
5088 {
5089 \tl_clear:N \l_@@_inline_env_case_tl
5090 \seq_map_inline:Nn \l_@@_inline_env_seq
5091 { \tl_put_right:Nn \l_@@_inline_env_case_tl { {##1} { } } }
5092 }
5093 \tl_new:N \l_@@_inline_env_case_tl
5094 % \end{macrocode}
5095 % \end{macro}
5096 %
5097 % \subsection{增加 CJK 子分区}
5098 %
5099 % \begin{variable}{\g_@@_CJK_sub_class_seq}
5100 % \begin{macrocode}
5101 \seq_new:N \g_@@_CJK_sub_class_seq
5102 % \end{macrocode}
5103 % \end{variable}
5104 %
5105 % \begin{macro}{\xeCJKDeclareSubCJKBlock}
5106 % 声明 CJK 子区范围,|#1| 为自定义名称,|#2| 为子区的 |Unicode| 范围。
5107 % \begin{macrocode}
5108 \NewDocumentCommand \xeCJKDeclareSubCJKBlock
5109 { s > { \TrimSpaces } m m }
5110 {
5111 \xeCJK_declare_sub_char_class:nen { CJK } {#2} {#3}
5112 \IfBooleanT {#1} { \xeCJKResetPunctClass }
5113 }
5114 \@onlypreamble \xeCJKDeclareSubCJKBlock
5115 % \end{macrocode}
5116 % \end{macro}
5117 %
5118 % \begin{macro}{\xeCJKCancelSubCJKBlock,\xeCJKRestoreSubCJKBlock}
5119 % 取消和恢复对 CJK 子区的声明。
5120 % \begin{macrocode}
5121 \bool_new:N \l_@@_sub_cancel_bool
5122 \NewDocumentCommand \xeCJKCancelSubCJKBlock { s m }
5123 {
5124 \bool_if:NF \l_@@_sub_cancel_bool
5125 {
5126 \bool_set_true:N \l_@@_sub_cancel_bool
5127 \@@_sub_restore_or_cancel:e {#2}
5128 \IfBooleanT {#1} { \xeCJKResetPunctClass }
5129 }
5130 }
5131 \NewDocumentCommand \xeCJKRestoreSubCJKBlock { s m }
5132 {
5133 \bool_if:NT \l_@@_sub_cancel_bool
5134 {
5135 \bool_set_false:N \l_@@_sub_cancel_bool
5136 \@@_sub_restore_or_cancel:e {#2}
5137 \IfBooleanT {#1} { \xeCJKResetPunctClass }
5138 }
5139 }
5140 % \end{macrocode}
5141 % \end{macro}
5142 %
5143 % \begin{macro}{\@@_sub_restore_or_cancel:n}
5144 % \begin{macrocode}
5145 \cs_new_protected:Npn \@@_sub_restore_or_cancel:n #1
5146 {
5147 \clist_map_inline:nn {#1}
5148 {
5149 \int_if_exist:cTF { \@@_class_csname:n { CJK/##1 } }
5150 {
5151 \xeCJK_declare_char_class:nn
5152 { CJK \bool_if:NF \l_@@_sub_cancel_bool { /##1 } }
5153 { \use:c { g_@@_CJK/##1_range_clist } }
5154 }
5155 { \@@_error:nx { SubBlock-undefined } {##1} }
5156 }
5157 }
5158 \cs_generate_variant:Nn \@@_sub_restore_or_cancel:n { e }
5159 \@@_msg_new:nn { SubBlock-undefined }
5160 {
5161 The~CJK~sub~block~`#1'~is~undefined.\\\\
5162 Try~to~use~\token_to_str:N \xeCJKDeclareSubCJKBlock \
5163 to~declare~it.
5164 }
5165 % \end{macrocode}
5166 % \end{macro}
5167 %
5168 % \begin{macro}[int]{\xeCJK_declare_sub_char_class:nnn}
5169 % \begin{macrocode}
5170 \cs_new_protected:Npn \xeCJK_declare_sub_char_class:nnn #1#2#3
5171 {
5172 \int_if_exist:cF { \@@_class_csname:n { #1/#2 } }
5173 {
5174 \xeCJK_new_class:n { #1/#2 }
5175 \@@_set_sub_class_toks:nn {#1} {#2}
5176 \xeCJK_new_sub_key:n {#2}
5177 }
5178 \xeCJK_declare_char_class:nn { #1/#2 } {#3}
5179 }
5180 \cs_generate_variant:Nn \xeCJK_declare_sub_char_class:nnn { ne }
5181 % \end{macrocode}
5182 % \end{macro}
5183 %
5184 % \begin{macro}{\@@_set_sub_class_toks:nn}
5185 % \begin{macrocode}
5186 \cs_new_protected:Npn \@@_set_sub_class_toks:nn #1#2
5187 {
5188 \seq_map_inline:Nn \g_@@_base_class_seq
5189 {
5190 \xeCJK_copy_inter_class_toks:nnnn { #1/#2 } {##1} {#1} {##1}
5191 \xeCJK_copy_inter_class_toks:nnnn {##1} { #1/#2 } {##1} {#1}
5192 \str_if_eq:nnTF {##1} { CJK }
5193 {
5194 \xeCJK_pre_inter_class_toks:nnn {##1} { #1/#2 }
5195 { \@@_switch_font:nn {#1} {#2} }
5196 }
5197 {
5198 \xeCJK_replace_inter_class_toks:nnnn {##1} { #1/#2 }
5199 { \xeCJK_fallback_symbol:NN }
5200 {
5201 \@@_switch_font:nn {#1} {#2}
5202 \xeCJK_fallback_symbol:NN
5203 }
5204 }
5205 }
5206 \xeCJK_copy_inter_class_toks:nnnn { #1/#2 } { #1/#2 } {#1} {#1}
5207 \seq_map_inline:Nn \g_@@_CJK_sub_class_seq
5208 {
5209 \xeCJK_copy_inter_class_toks:nnnn { #1/#2 } { #1/##1 } {#1} {#1}
5210 \xeCJK_copy_inter_class_toks:nnnn { #1/##1 } { #1/#2 } {#1} {#1}
5211 \xeCJK_pre_inter_class_toks:nnn { #1/#2 } { #1/##1 }
5212 { \@@_switch_font:nn {#2} {##1} }
5213 \xeCJK_pre_inter_class_toks:nnn { #1/##1 } { #1/#2 }
5214 { \@@_switch_font:nn {##1} {#2} }
5215 }
5216 \seq_gput_right:Nn \g_@@_CJK_sub_class_seq {#2}
5217 \@@_save_CJK_class:n { #1/#2 }
5218 \clist_map_inline:nn { CJK , FullLeft , FullRight , HangulJamo }
5219 {
5220 \xeCJK_pre_inter_class_toks:nnn { #1/#2 } {##1}
5221 { \@@_switch_font:nn {#2} {#1} }
5222 }
5223 }
5224 % \end{macrocode}
5225 % \end{macro}
5226 %
5227 % \subsection{标点处理}
5228 %
5229 % \changes{v3.2.7}{2013/08/22}{实现自定义行首/尾标点符号宽度功能。}
5230 % \changes{v3.7.4}{2019/05/31}{简化行首/尾标点符号宽度的实现。}
5231 %
5232 % \tn{XeTeXglyphbounds} 可以得到一个字符的左右边距,用于标点压缩。如果它不可用,则
5233 % 在文档中只能使用 |plain| 这一标点格式原样输出标点。
5234 % \begin{macrocode}
5235 \cs_if_exist:NF \tex_XeTeXglyphbounds:D
5236 {
5237 \@@_msg_new:nn { XeTeX-too-old }
5238 {
5239 \token_to_str:N \tex_XeTeXglyphbounds:D \ is~not~defined.\\
5240 CJK~punctuation~kerning~will~not~be~available.\\\\
5241 You~have~to~update~XeTeX~to~the~version~0.9995.0~or~later.
5242 }
5243 \@@_error:n { XeTeX-too-old }
5244 \AtEndOfPackage
5245 {
5246 \keys_define:nn { xeCJK / options }
5247 {
5248 PunctStyle .code:n =
5249 { \@@_error:nx { punct-style-unknown } {#1} }
5250 }
5251 \seq_gclear:N \g_@@_punct_style_seq
5252 \@@_set_punct_style:n { plain }
5253 }
5254 }
5255 % \end{macrocode}
5256 %
5257 % \begin{macro}{\xeCJKsetwidth}
5258 % 手动设置参数中的标点符号的宽度。
5259 % \begin{macrocode}
5260 \NewDocumentCommand \xeCJKsetwidth { s m m }
5261 {
5262 \IfBooleanTF {#1}
5263 {
5264 \tl_map_inline:en {#2}
5265 { \tl_gset:cn { g_@@_punct_bound_width/##1/tl } {#3} }
5266 }
5267 {
5268 \tl_map_inline:en {#2}
5269 { \tl_gset:cn { g_@@_punct_width/##1/tl } {#3} }
5270 }
5271 }
5272 \@onlypreamble \xeCJKsetwidth
5273 \cs_generate_variant:Nn \tl_map_inline:nn { e }
5274 % \end{macrocode}
5275 % \end{macro}
5276 %
5277 % \begin{macro}{\xeCJKsetkern}
5278 % 手动设置相邻标点的距离。
5279 % \begin{macrocode}
5280 \NewDocumentCommand \xeCJKsetkern { m m m }
5281 { \tl_gset:cn { g_@@_punct/kern/#1/#2/tl } {#3} }
5282 \@onlypreamble \xeCJKsetkern
5283 % \end{macrocode}
5284 % \end{macro}
5285 %
5286 % \begin{variable}{\c_@@_left_tl,\c_@@_right_tl}
5287 % \begin{macrocode}
5288 \tl_const:Nn \c_@@_left_tl { left }
5289 \tl_const:Nn \c_@@_right_tl { right }
5290 % \end{macrocode}
5291 % \end{variable}
5292 %
5293 % \changes{v3.2.12}{2014/05/12}{新增 \texttt{RubberPunctSkip} 选项。}
5294 % \changes{v3.4.0}{2016/05/13}{\texttt{RubberPunctSkip} 选项有新的值 \texttt{plus} 和 \texttt{minus}。}
5295 %
5296 % \begin{macro}
5297 % {AllowBreakBetweenPuncts,KaiMingPunct,LongPunct,
5298 % MiddlePunct,PunctWidth,PunctBoundWidth,RubberPunctSkip}
5299 % 相关选项声明。
5300 % \begin{macrocode}
5301 \keys_define:nn { xeCJK / options }
5302 {
5303 AllowBreakBetweenPuncts .choice: ,
5304 AllowBreakBetweenPuncts / true .code:n =
5305 {
5306 \bool_set_true:N \l_@@_punct_breakable_bool
5307 \cs_set_eq:NN \xeCJK_punct_kern:NN \@@_punct_breakable_kern:NN
5308 \cs_set_eq:NN \@@_punct_bound_kern:N
5309 \@@_punct_bound_breakable_kern:N
5310 } ,
5311 AllowBreakBetweenPuncts / false .code:n =
5312 {
5313 \bool_set_false:N \l_@@_punct_breakable_bool
5314 \cs_set_eq:NN \xeCJK_punct_kern:NN \@@_punct_kern:NN
5315 \cs_set_eq:NN \@@_punct_bound_kern:N
5316 \@@_nobreak_hskip:N
5317 } ,
5318 AllowBreakBetweenPuncts .default:n = { true } ,
5319 KaiMingPunct .code:n = { \@@_set_special_punct:nn { mixed_width } {#1} } ,
5320 KaiMingPunct+ .code:n = { \@@_add_special_punct:nn { mixed_width } {#1} } ,
5321 KaiMingPunct- .code:n = { \@@_sub_special_punct:nn { mixed_width } {#1} } ,
5322 LongPunct .code:n = { \@@_set_special_punct:nn { long } {#1} } ,
5323 LongPunct+ .code:n = { \@@_add_special_punct:nn { long } {#1} } ,
5324 LongPunct- .code:n = { \@@_sub_special_punct:nn { long } {#1} } ,
5325 MiddlePunct .code:n = { \@@_set_special_punct:nn { middle } {#1} } ,
5326 MiddlePunct+ .code:n = { \@@_add_special_punct:nn { middle } {#1} } ,
5327 MiddlePunct- .code:n = { \@@_sub_special_punct:nn { middle } {#1} } ,
5328 PunctWidth .tl_gset:N = \g_@@_punct_width_tl ,
5329 PunctBoundWidth .tl_gset:N = \g_@@_punct_bound_width_tl ,
5330 PunctWidth .value_required:n = true ,
5331 PunctBoundWidth .value_required:n = true ,
5332 RubberPunctSkip .choice: ,
5333 RubberPunctSkip .default:n = { true } ,
5334 RubberPunctSkip / true .code:n =
5335 { \cs_set_eq:NN \@@_use_dim_or_skip:nNN \@@_use_punct_skip:nNN } ,
5336 RubberPunctSkip / plus .code:n =
5337 { \cs_set_eq:NN \@@_use_dim_or_skip:nNN \@@_use_punct_skip_plus:nNN } ,
5338 RubberPunctSkip / minus .code:n =
5339 { \cs_set_eq:NN \@@_use_dim_or_skip:nNN \@@_use_punct_skip_minus:nNN } ,
5340 RubberPunctSkip / false .code:n =
5341 { \cs_set_eq:NN \@@_use_dim_or_skip:nNN \@@_use_punct_dim:nNN }
5342 }
5343 \bool_new:N \l_@@_punct_breakable_bool
5344 % \end{macrocode}
5345 % \end{macro}
5346 %
5347 % 相关选项定义的辅助函数。
5348 % \begin{macrocode}
5349 \clist_new:N \g_@@_special_punct_clist
5350 \clist_gset:Nn \g_@@_special_punct_clist { mixed_width , long , middle }
5351 \cs_new:Npn \@@_special_punct_seq:n #1 { g_@@_special_punct_#1_seq }
5352 \cs_new:Npn \@@_special_punct_tl:nN #1#2 { g_@@_special_punct_#1_#2_tl }
5353 \clist_map_inline:Nn \g_@@_special_punct_clist
5354 { \seq_new:c { \@@_special_punct_seq:n {#1} } }
5355 \cs_new_protected:Npn \@@_set_special_punct:nn #1#2
5356 {
5357 \seq_map_inline:cn { \@@_special_punct_seq:n {#1} }
5358 { \cs_undefine:c { \@@_special_punct_tl:nN {#1} {##1} } }
5359 \seq_gclear:c { \@@_special_punct_seq:n {#1} }
5360 \tl_map_inline:en {#2}
5361 {
5362 \tl_new:c { \@@_special_punct_tl:nN {#1} {##1} }
5363 \seq_gput_right:cn { \@@_special_punct_seq:n {#1} } {##1}
5364 }
5365 }
5366 \cs_new_protected:Npn \@@_add_special_punct:nn #1#2
5367 {
5368 \tl_map_inline:en {#2}
5369 {
5370 \seq_if_in:cnF { \@@_special_punct_seq:n {#1} } {##1}
5371 {
5372 \tl_new:c { \@@_special_punct_tl:nN {#1} {##1} }
5373 \seq_gput_right:cn { \@@_special_punct_seq:n {#1} } {##1}
5374 }
5375 }
5376 }
5377 \cs_new_protected:Npn \@@_sub_special_punct:nn #1#2
5378 {
5379 \tl_map_inline:en {#2}
5380 {
5381 \cs_undefine:c { \@@_special_punct_tl:nN {#1} {##1} }
5382 \seq_gremove_all:cn { \@@_special_punct_seq:n {#1} } {##1}
5383 }
5384 }
5385 % \end{macrocode}
5386 %
5387 % 判断一个标点符号是否为全角右标点和长标点符号。
5388 % \begin{macrocode}
5389 \prg_new_conditional:Npnn \@@_punct_if_right:N #1 { p , T , F , TF }
5390 {
5391 \if_int_compare:w \xeCJK_token_value_class:N #1 =
5392 \xeCJK_class_num:n { FullRight }
5393 \prg_return_true: \else: \prg_return_false: \fi:
5394 }
5395 \clist_map_inline:Nn \g_@@_special_punct_clist
5396 {
5397 \exp_args:Nc
5398 \prg_new_conditional:Npnn { @@_punct_if_#1:N } ##1 { p , T , F , TF }
5399 {
5400 \if_cs_exist:w \@@_special_punct_tl:nN {#1} {##1} \cs_end:
5401 \prg_return_true: \else: \prg_return_false: \fi:
5402 }
5403 }
5404 % \end{macrocode}
5405 %
5406 % 一些用于记录的辅助函数。
5407 % \begin{macrocode}
5408 \cs_new:Npn \@@_punct_csname:n #1
5409 { c_@@_\l_xeCJK_current_punct_font_tl/\l_xeCJK_punct_style_tl/#1/tl }
5410 \cs_new:Npn \@@_use_punct_dim:nN #1#2
5411 { \use:c { \@@_punct_csname:n { dim/#1/#2 } } }
5412 \cs_new:Npn \@@_use_punct_dim:nNN #1#2#3
5413 { \use:c { \@@_punct_csname:n { dim/#1/#2/#3 } } }
5414 \cs_new:Npn \@@_use_punct_skip:nNN #1#2#3
5415 { \use:c { \@@_punct_csname:n { skip/#1/#2/#3 } } }
5416 \cs_new:Npn \@@_use_punct_skip_plus:nNN #1#2#3
5417 { \use:c { \@@_punct_csname:n { skip/plus/#1/#2/#3 } } }
5418 \cs_new:Npn \@@_use_punct_skip_minus:nNN #1#2#3
5419 { \use:c { \@@_punct_csname:n { skip/minus/#1/#2/#3 } } }
5420 \cs_new_protected:Npn \@@_save_punct_dim:nNn #1#2
5421 { \@@_save_punct_width_aux:nnnn { dim } {#1} { #1/#2 } }
5422 \cs_new_protected:Npn \@@_save_punct_dim:nNNn #1#2#3
5423 { \@@_save_punct_width_aux:nnnn { dim } {#1} { #1/#2/#3 } }
5424 \cs_new_protected:Npn \@@_save_punct_skip:nNNn #1#2#3#4
5425 {
5426 \@@_save_punct_width_aux:nnnn { skip } {#1} { #1/#2/#3 } {#4}
5427 \@@_save_punct_width_aux:nnnn { skip } {#1} { plus/#1/#2/#3 } {#4}
5428 \@@_save_punct_width_aux:nnnn { skip } {#1} { minus/#1/#2/#3 } {#4}
5429 }
5430 \cs_new_protected:Npn \@@_save_punct_skip:nNNnnn #1#2#3#4#5#6
5431 {
5432 \exp_last_unbraced:Ne
5433 \@@_save_punct_skip_aux:nnnnn
5434 {
5435 {#1}
5436 { #1/#2/#3 }
5437 { \dim_eval:n {#4} }
5438 { \dim_max:nn { \c_zero_dim } {#5} }
5439 { \dim_max:nn { \c_zero_dim } {#6} }
5440 }
5441 }
5442 \cs_new_protected:Npn \@@_save_punct_skip_aux:nnnnn #1#2#3#4#5
5443 {
5444 \@@_save_punct_width_aux:nnnn { skip } {#1}
5445 {#2} { #3 ~ plus ~ #4 ~ minus ~ #5 ~ }
5446 \@@_save_punct_width_aux:nnnn { skip } {#1}
5447 { plus/#2 } { #3 ~ plus ~ #4 ~ }
5448 \@@_save_punct_width_aux:nnnn { skip } {#1}
5449 { minus/#2 } { #3 ~ minus ~ #5 ~ }
5450 }
5451 \cs_new_protected:Npn \@@_save_punct_width_aux:nnnn #1#2#3#4
5452 {
5453 \@@_save_punct_width_aux:cen
5454 { \@@_punct_csname:n { #1/#3 } }
5455 { \use:c { #1_eval:n } {#4} }
5456 {#2}
5457 }
5458 \cs_new_protected:Npn \@@_save_punct_width_aux:Nnn #1#2#3
5459 {
5460 \tl_const:Nn #1 {#2}
5461 \str_if_eq:nnT {#3} { glue }
5462 { \prop_gput:Nnn \g_@@_punct_skip_prop {#2} { } }
5463 }
5464 \prop_new:N \g_@@_punct_skip_prop
5465 \prop_gput:Non \g_@@_punct_skip_prop { \skip_use:N \c_zero_skip } { }
5466 \cs_generate_variant:Nn \@@_save_punct_width_aux:Nnn { ce }
5467 \cs_new_eq:NN \@@_use_dim_or_skip:nNN \@@_use_punct_skip:nNN
5468 % \end{macrocode}
5469 %
5470 % \changes{v3.1.0}{2012/11/14}{使用 \pkg{xtemplate} 宏包的机制来组织标点符号的处理。}
5471 %
5472 % 定义标点处理模板。
5473 % \begin{macrocode}
5474 \DeclareObjectType { xeCJK / punctuation } { 0 }
5475 % \end{macrocode}
5476 %
5477 % \begin{macrocode}
5478 \DeclareTemplateInterface { xeCJK / punctuation } { basic } { 0 }
5479 {
5480 enabled-global-setting : boolean = true ,
5481 fixed-punct-width : length = \c_max_dim ,
5482 fixed-punct-ratio : real = \c_one_fp ,
5483 mixed-punct-width : length = \KeyValue { fixed-punct-width } ,
5484 mixed-punct-ratio : real = \KeyValue { fixed-punct-ratio } ,
5485 middle-punct-width : length = \KeyValue { fixed-punct-width } ,
5486 middle-punct-ratio : real = \KeyValue { fixed-punct-ratio } ,
5487 fixed-margin-width : length = \c_max_dim ,
5488 fixed-margin-ratio : real = \c_one_fp ,
5489 mixed-margin-width : length = \KeyValue { fixed-margin-width } ,
5490 mixed-margin-ratio : real = \KeyValue { fixed-margin-ratio } ,
5491 middle-margin-width : length = \KeyValue { fixed-margin-width } ,
5492 middle-margin-ratio : real = \KeyValue { fixed-margin-ratio } ,
5493 bound-punct-width : length = \c_max_dim ,
5494 bound-punct-ratio : real = \c_nan_fp ,
5495 bound-margin-width : length = \c_max_dim ,
5496 bound-margin-ratio : real = \c_zero_fp ,
5497 enabled-hanging : boolean = false ,
5498 add-min-bound-to-margin : boolean = false ,
5499 optimize-margin : boolean = false ,
5500 margin-minimum : length = \c_zero_dim ,
5501 enabled-kerning : boolean = true ,
5502 min-bound-to-kerning : boolean = false ,
5503 kerning-total-width : length = \c_max_dim ,
5504 kerning-total-ratio : real = 0.75 ,
5505 optimize-kerning : boolean = false ,
5506 same-align-margin : length = \c_max_dim ,
5507 same-align-ratio : real = \c_nan_fp ,
5508 different-align-margin : length = \c_max_dim ,
5509 different-align-ratio : real = \c_nan_fp ,
5510 kerning-margin-width : length = \c_max_dim ,
5511 kerning-margin-ratio : real = \c_one_fp ,
5512 kerning-margin-minimum : length = \c_zero_dim
5513 }
5514 % \end{macrocode}
5515 %
5516 % \begin{macrocode}
5517 \DeclareTemplateCode { xeCJK / punctuation } { basic } { 0 }
5518 {
5519 enabled-global-setting = \l_@@_enabled_global_setting_bool ,
5520 fixed-punct-width = \l_@@_fixed_punct_width_dim ,
5521 fixed-punct-ratio = \l_@@_fixed_punct_ratio_fp ,
5522 mixed-punct-width = \l_@@_mixed_punct_width_dim ,
5523 mixed-punct-ratio = \l_@@_mixed_punct_ratio_fp ,
5524 middle-punct-width = \l_@@_middle_punct_width_dim ,
5525 middle-punct-ratio = \l_@@_middle_punct_ratio_fp ,
5526 fixed-margin-width = \l_@@_fixed_margin_width_dim ,
5527 fixed-margin-ratio = \l_@@_fixed_margin_ratio_fp ,
5528 mixed-margin-width = \l_@@_mixed_margin_width_dim ,
5529 mixed-margin-ratio = \l_@@_mixed_margin_ratio_fp ,
5530 middle-margin-width = \l_@@_middle_margin_width_dim ,
5531 middle-margin-ratio = \l_@@_middle_margin_ratio_fp ,
5532 bound-punct-width = \l_@@_bound_punct_width_dim ,
5533 bound-punct-ratio = \l_@@_bound_punct_ratio_fp ,
5534 bound-margin-width = \l_@@_bound_margin_width_dim ,
5535 bound-margin-ratio = \l_@@_bound_margin_ratio_fp ,
5536 enabled-hanging = \l_@@_enabled_hanging_bool ,
5537 add-min-bound-to-margin = \l_@@_add_min_bound_to_margin_bool ,
5538 optimize-margin = \l_@@_optimize_margin_bool ,
5539 margin-minimum = \l_@@_margin_minimum_dim ,
5540 enabled-kerning = \l_@@_enabled_kerning_bool ,
5541 min-bound-to-kerning = \l_@@_min_bound_to_kerning_bool ,
5542 kerning-total-width = \l_@@_kerning_total_width_dim ,
5543 kerning-total-ratio = \l_@@_kerning_total_ratio_fp ,
5544 optimize-kerning = \l_@@_optimize_kerning_bool ,
5545 same-align-margin = \l_@@_same_align_margin_dim ,
5546 same-align-ratio = \l_@@_same_align_ratio_fp ,
5547 different-align-margin = \l_@@_different_align_margin_dim ,
5548 different-align-ratio = \l_@@_different_align_ratio_fp ,
5549 kerning-margin-width = \l_@@_kerning_margin_width_dim ,
5550 kerning-margin-ratio = \l_@@_kerning_margin_ratio_fp ,
5551 kerning-margin-minimum = \l_@@_kerning_margin_minimum_dim
5552 }
5553 { \AssignTemplateKeys }
5554 % \end{macrocode}
5555 %
5556 % \begin{macro}[int]{\xeCJK_get_punct_bounds:NN}
5557 % |#1| 为 \cs{c_@@_left_tl} 或 \cs{c_@@_right_tl},|#2| 为标点符号。
5558 % \begin{macrocode}
5559 \cs_new_protected:Npn \xeCJK_get_punct_bounds:NN #1#2
5560 {
5561 \tl_if_exist:cF { \@@_punct_csname:n { dim/glue/#1/#2 } }
5562 { \@@_get_punct_bounds_aux:NN #1 #2 }
5563 }
5564 \cs_new_protected:Npn \@@_get_punct_bounds_aux:NN
5565 {
5566 \tl_if_eq:NNTF \l_xeCJK_punct_style_tl \c_@@_punct_style_plain_tl
5567 { \@@_save_punct_margin_plain:NN }
5568 { \@@_save_punct_margin:NN }
5569 }
5570 \cs_new_protected:Npn \xeCJK_get_punct_bounds:No
5571 { \exp_last_unbraced:NNo \xeCJK_get_punct_bounds:NN }
5572 \cs_new_protected:Npn \@@_save_punct_margin_plain:NN #1#2
5573 {
5574 \@@_save_punct_dim:nNNn { glue } #1 #2 { \c_zero_dim }
5575 \@@_save_punct_dim:nNNn { offset } #1 #2 { \c_zero_dim }
5576 \@@_save_punct_dim:nNNn { margin } #1 #2 { \c_zero_dim }
5577 \@@_save_punct_dim:nNNn { rule } \c_@@_left_tl {#2} { \c_zero_dim }
5578 \@@_save_punct_dim:nNNn { rule } \c_@@_right_tl {#2} { \c_zero_dim }
5579 \@@_save_punct_dim:nNNn { bound } \c_@@_left_tl {#2} { \c_zero_dim }
5580 \@@_save_punct_dim:nNNn { bound } \c_@@_right_tl {#2} { \c_zero_dim }
5581 \@@_save_punct_skip:nNNn { glue } #1 #2 { \c_zero_skip }
5582 }
5583 \cs_new_protected:Npn \@@_save_punct_margin:NN #1#2
5584 {
5585 \group_begin:
5586 \xeCJK_select_punct_font:
5587 \xeCJK_fallback_punct_symbol:NN
5588 \xeCJK_calc_punct_dimen:N #2
5589 \group_end:
5590 \dim_set:Nn \l_@@_bound_dim
5591 { \@@_use_punct_dim:nNN { bound } #1 #2 }
5592 \tl_if_eq:NNTF #1 \c_@@_right_tl
5593 { \tl_set_eq:NN \l_@@_reverse_tl \c_@@_left_tl }
5594 { \tl_set_eq:NN \l_@@_reverse_tl \c_@@_right_tl }
5595 \dim_set:Nn \l_@@_reverse_bound_dim
5596 { \@@_use_punct_dim:nNN { bound } \l_@@_reverse_tl #2 }
5597 \UseInstance { xeCJK / punctuation } { \l_xeCJK_punct_style_tl }
5598 \xeCJK_punct_margin_process:NN #1 #2
5599 \xeCJK_punct_offset_process:NN #1 #2
5600 \@@_punct_if_long:NT #2
5601 { \@@_long_punct_kerning:N #2 }
5602 }
5603 \tl_new:N \l_@@_reverse_tl
5604 \dim_new:N \l_@@_bound_dim
5605 \dim_new:N \l_@@_reverse_bound_dim
5606 % \end{macrocode}
5607 % \end{macro}
5608 %
5609 % \changes{v3.7.0}{2018/03/12}{修正长标点被隔开时的压缩处理错误。}
5610 %
5611 % \begin{macro}[int]{\@@_long_punct_kerning:N}
5612 % \changes{v3.4.3}{2016/10/27}{考虑破折号边界为负值的情况。}
5613 % 相同长标点压缩。对于破折号,计算两标点之间的空白,保证它中间不被断开。
5614 % 注意,破折号的边界可能为负值(比如方正新书宋),此时不必压缩。
5615 % \begin{macrocode}
5616 \cs_new_protected:Npn \@@_long_punct_kerning:N #1
5617 {
5618 \dim_set:Nn \l_@@_tmp_dim
5619 {
5620 \dim_max:nn
5621 { \l_@@_bound_dim + \l_@@_reverse_bound_dim }
5622 { \c_zero_dim }
5623 }
5624 \@@_save_punct_dim:nNNn { bound_width } #1 #1 { \l_@@_tmp_dim }
5625 \dim_set:Nn \l_@@_tmp_dim
5626 {
5627 \str_case:nnTF {#1}
5628 { { ^^^^2025 } { } { ^^^^2026 } { } }
5629 { \c_zero_dim }
5630 { -\l_@@_tmp_dim }
5631 }
5632 \@@_save_punct_dim:nNNn { kern } #1 #1 { \l_@@_tmp_dim }
5633 \@@_save_punct_skip:nNNn { kern } #1 #1 { \l_@@_tmp_dim }
5634 \dim_add:Nn \l_@@_tmp_dim
5635 { \dim_max:nn { \l_@@_bound_dim } { \c_zero_dim } }
5636 \@@_save_punct_dim:nNNn { bound_kern } #1 #1 { \l_@@_tmp_dim }
5637 \@@_save_punct_skip:nNNn { bound_kern } #1 #1 { \l_@@_tmp_dim }
5638 }
5639 % \end{macrocode}
5640 % \end{macro}
5641 %
5642 % \begin{macro}[int]{\xeCJK_get_punct_kerning:NN}
5643 % 标点压缩。
5644 % \begin{macrocode}
5645 \cs_new_protected:Npn \xeCJK_get_punct_kerning:NN #1#2
5646 {
5647 \tl_if_exist:cF { \@@_punct_csname:n { dim/kern/#1/#2 } }
5648 {
5649 \tl_if_eq:NNTF \l_xeCJK_punct_style_tl \c_@@_punct_style_plain_tl
5650 { \@@_save_punct_kerning_plain:NN }
5651 { \@@_save_punct_kerning:NN }
5652 #1 #2
5653 }
5654 }
5655 \cs_new_protected:Npn \xeCJK_get_punct_kerning:oN
5656 { \exp_after:wN \xeCJK_get_punct_kerning:NN }
5657 \cs_new_protected:Npn \@@_save_punct_kerning_plain:NN #1#2
5658 {
5659 \@@_save_punct_dim:nNNn { kern } #1 #2 { \c_zero_dim }
5660 \@@_save_punct_dim:nNNn { bound_kern } #1 #2 { \c_zero_dim }
5661 \@@_save_punct_dim:nNNn { bound_width } #1 #2 { \c_zero_dim }
5662 \@@_save_punct_skip:nNNn { kern } #1 #2 { \c_zero_skip }
5663 \@@_save_punct_skip:nNNn { bound_kern } #1 #2 { \c_zero_skip }
5664 }
5665 \cs_new_protected:Npn \@@_save_punct_kerning:NN
5666 {
5667 \UseInstance { xeCJK / punctuation } { \l_xeCJK_punct_style_tl }
5668 \xeCJK_punct_kerning_process:NN
5669 }
5670 % \end{macrocode}
5671 % \end{macro}
5672 %
5673 % \begin{macro}[int]{\xeCJK_punct_margin_process:NN}
5674 % \begin{macrocode}
5675 \cs_new_protected:Npn \xeCJK_punct_margin_process:NN #1#2
5676 {
5677 \dim_set:Nn \l_@@_tmp_dim
5678 {
5679 \bool_if:NTF \l_@@_enabled_global_setting_bool
5680 {
5681 \cs_if_exist_use:cF { g_@@_punct_width/#2/tl }
5682 {
5683 \tl_if_empty:NTF \g_@@_punct_width_tl
5684 { \@@_calc_punct_width:N #2 }
5685 { \g_@@_punct_width_tl }
5686 }
5687 }
5688 { \@@_calc_punct_width:N #2 }
5689 }
5690 \dim_set:Nn \l_@@_margin_dim
5691 {
5692 \dim_max:nn
5693 { \l_@@_margin_minimum_dim }
5694 {
5695 \dim_compare:nNnTF \l_@@_tmp_dim < \c_max_dim
5696 {
5697 \@@_punct_if_middle:NTF #2
5698 {
5699 ( \l_@@_tmp_dim
5700 - ( \@@_use_punct_dim:nN { dimen } #2 )
5701 ) / 2
5702 }
5703 {
5704 \bool_if:NTF \l_@@_optimize_margin_bool
5705 {
5706 \dim_max:nn
5707 {
5708 \dim_min:nn
5709 { \l_@@_bound_dim }
5710 { \l_@@_reverse_bound_dim }
5711 }
5712 }
5713 { \use:n }
5714 {
5715 \l_@@_tmp_dim
5716 - \l_@@_reverse_bound_dim
5717 - ( \@@_use_punct_dim:nN { dimen } #2 )
5718 }
5719 }
5720 }
5721 {
5722 \bool_if:NTF \l_@@_optimize_margin_bool
5723 { \dim_min:nn { \l_@@_bound_dim } }
5724 { \use:n }
5725 { \@@_calc_margin_width:N #2 }
5726 }
5727 }
5728 }
5729 \@@_save_punct_dim:nNNn { margin } #1 #2 { \l_@@_margin_dim }
5730 }
5731 \dim_new:N \l_@@_margin_dim
5732 % \end{macrocode}
5733 % \end{macro}
5734 %
5735 % \begin{macro}{\@@_calc_punct_width:N}
5736 % \begin{macrocode}
5737 \cs_new:Npn \@@_calc_punct_width:N #1
5738 {
5739 \@@_punct_if_middle:NTF #1
5740 { \@@_punct_width_or_ratio:nN { middle } }
5741 {
5742 \@@_punct_if_mixed_width:NTF #1
5743 { \@@_punct_width_or_ratio:nN { mixed } }
5744 { \@@_punct_width_or_ratio:nN { fixed } }
5745 }
5746 #1
5747 }
5748 % \end{macrocode}
5749 % \end{macro}
5750 %
5751 % \begin{macro}{\@@_calc_margin_width:N}
5752 % \begin{macrocode}
5753 \cs_new:Npn \@@_calc_margin_width:N #1
5754 {
5755 \@@_punct_if_middle:NTF #1
5756 {
5757 \dim_compare:nNnTF \l_@@_middle_margin_width_dim < \c_max_dim
5758 { \l_@@_middle_margin_width_dim }
5759 {
5760 \@@_dim_ratio:Nn \l_@@_middle_margin_ratio_fp
5761 { ( \l_@@_bound_dim + \l_@@_reverse_bound_dim ) / 2 }
5762 }
5763 }
5764 {
5765 \@@_punct_if_mixed_width:NTF #1
5766 { \@@_margin_width_or_ratio:n { mixed } }
5767 { \@@_margin_width_or_ratio:n { fixed } }
5768 }
5769 }
5770 % \end{macrocode}
5771 % \end{macro}
5772 %
5773 % \begin{macro}{\@@_dim_ratio:Nn}
5774 % \begin{macrocode}
5775 \cs_new:Npn \@@_dim_ratio:Nn #1#2
5776 { \fp_to_dim:n { #1 \dim_to_fp:n {#2} } }
5777 \cs_generate_variant:Nn \@@_dim_ratio:Nn { c }
5778 % \end{macrocode}
5779 % \end{macro}
5780 %
5781 % \changes{v3.8.9}{2022/05/26}{修正居中标点悬挂错误。}
5782 %
5783 % \begin{macro}[int]{\xeCJK_punct_offset_process:NN}
5784 % \begin{macrocode}
5785 \cs_new_protected:Npn \xeCJK_punct_offset_process:NN #1#2
5786 {
5787 \dim_set:Nn \l_@@_tmp_dim
5788 {
5789 \bool_if:NTF \l_@@_enabled_global_setting_bool
5790 {
5791 \cs_if_exist_use:cF { g_@@_punct_bound_width/#2/tl }
5792 {
5793 \tl_if_empty:NTF \g_@@_punct_bound_width_tl
5794 { \@@_punct_width_or_ratio:nN { bound } #2 }
5795 { \g_@@_punct_bound_width_tl }
5796 }
5797 }
5798 { \@@_punct_width_or_ratio:nN { bound } #2 }
5799 }
5800 \dim_set:Nn \l_@@_tmp_dim
5801 {
5802 \bool_if:NTF \l_@@_enabled_hanging_bool
5803 { \use:n }
5804 { \dim_max:nn { \l_@@_margin_minimum_dim } }
5805 {
5806 \dim_compare:nNnTF \l_@@_tmp_dim < \c_max_dim
5807 {
5808 \@@_punct_if_middle:NTF #2
5809 {
5810 \l_@@_tmp_dim
5811 - \l_@@_margin_dim
5812 - ( \@@_use_punct_dim:nN { dimen } #2 )
5813 }
5814 {
5815 \l_@@_tmp_dim
5816 - \l_@@_reverse_bound_dim
5817 - ( \@@_use_punct_dim:nN { dimen } #2 )
5818 }
5819 }
5820 {
5821 \bool_if:NTF \l_@@_optimize_margin_bool
5822 { \dim_min:nn { \l_@@_bound_dim } }
5823 { \use:n }
5824 { \@@_margin_width_or_ratio:n { bound } }
5825 }
5826 }
5827 }
5828 \@@_save_punct_dim:nNNn { offset } #1 #2
5829 { \l_@@_tmp_dim }
5830 \@@_save_punct_dim:nNNn { rule } #1 #2
5831 { \l_@@_tmp_dim - \l_@@_bound_dim }
5832 \@@_save_punct_dim:nNNn { rule } \l_@@_reverse_tl #2
5833 { \l_@@_tmp_dim - \l_@@_reverse_bound_dim }
5834 \@@_save_punct_dim:nNNn { glue } #1 #2
5835 { \l_@@_margin_dim - \l_@@_tmp_dim }
5836 \@@_save_punct_skip:nNNnnn { glue } #1 #2
5837 { \l_@@_margin_dim - \l_@@_tmp_dim }
5838 {
5839 \@@_punct_if_middle:NTF #2
5840 {
5841 ( \@@_use_punct_dim:nN { width } #2 -
5842 \@@_use_punct_dim:nN { dimen } #2 ) / 2
5843 - \l_@@_margin_dim
5844 }
5845 { \l_@@_bound_dim - \l_@@_margin_dim }
5846 }
5847 {
5848 \@@_punct_if_middle:NTF #2
5849 { \l_@@_margin_dim / 2 }
5850 { \l_@@_margin_dim - \l_@@_reverse_bound_dim }
5851 }
5852 }
5853 % \end{macrocode}
5854 % \end{macro}
5855 %
5856 % \changes{v3.2.7}{2013/08/25}{标点宽度设置禁用比例选项的值改为 \texttt{nan}。}
5857 % \changes{v3.8.0}{2020/02/10}{应用 \cs{fp_if_nan:nTF}。}
5858 %
5859 % \begin{macro}{\@@_punct_width_or_ratio:nN}
5860 % \begin{macrocode}
5861 \cs_new:Npn \@@_punct_width_or_ratio:nN #1#2
5862 {
5863 \dim_compare:nNnTF { \use:c { l_@@_#1_punct_width_dim } } < \c_max_dim
5864 { \use:c { l_@@_#1_punct_width_dim } }
5865 {
5866 \fp_if_nan:nTF { \use:c { l_@@_#1_punct_ratio_fp } }
5867 { \c_max_dim }
5868 {
5869 \@@_dim_ratio:cn
5870 { l_@@_#1_punct_ratio_fp }
5871 { \@@_use_punct_dim:nN { width } #2 }
5872 }
5873 }
5874 }
5875 % \end{macrocode}
5876 % \end{macro}
5877 %
5878 % \begin{macro}{\@@_margin_width_or_ratio:n}
5879 % \begin{macrocode}
5880 \cs_new:Npn \@@_margin_width_or_ratio:n #1
5881 {
5882 \dim_compare:nNnTF { \use:c { l_@@_#1_margin_width_dim } } < \c_max_dim
5883 { \use:c { l_@@_#1_margin_width_dim } }
5884 {
5885 \@@_dim_ratio:cn
5886 { l_@@_#1_margin_ratio_fp }
5887 { \l_@@_bound_dim }
5888 }
5889 \bool_if:NT \l_@@_add_min_bound_to_margin_bool
5890 { + \dim_min:nn \l_@@_bound_dim \l_@@_reverse_bound_dim }
5891 }
5892 % \end{macrocode}
5893 % \end{macro}
5894 %
5895 % \changes{v3.4.4}{2016/11/30}{不压缩长标点与其他标点的间距。}
5896 %
5897 % \begin{macro}[int]{\xeCJK_punct_kerning_process:NN}
5898 % 当标点之一为长标点时,不必进行压缩。
5899 % \begin{macrocode}
5900 \cs_new_protected:Npn \xeCJK_punct_kerning_process:NN #1#2
5901 {
5902 \dim_set:Nn \l_@@_margin_dim
5903 { \@@_original_kerning_margin:NN #1 #2 }
5904 \dim_set:Nn \l_@@_minimum_bound_dim
5905 { \@@_punct_min_bound:NN #1 #2 }
5906 \@@_punct_if_long:NTF #1
5907 { \bool_set_false:N \l_@@_enabled_kerning_bool }
5908 {
5909 \@@_punct_if_long:NT #2
5910 { \bool_set_false:N \l_@@_enabled_kerning_bool }
5911 }
5912 \dim_set:Nn \l_@@_kerning_margin_dim
5913 {
5914 \bool_if:NTF \l_@@_enabled_global_setting_bool
5915 {
5916 \cs_if_exist_use:cF { g_@@_punct/kern/#1/#2/tl }
5917 { \@@_punct_kerning_process_aux:NN #1 #2 }
5918 }
5919 { \@@_punct_kerning_process_aux:NN #1 #2 }
5920 }
5921 \@@_save_kerning:nnNN { kern } { bound } #1 #2
5922 \@@_save_punct_dim:nNNn { bound_width } #1 #2
5923 { \l_@@_kerning_margin_dim - \l_@@_tmp_dim }
5924 \@@_punct_if_right:NTF #1
5925 {
5926 \@@_punct_if_right:NTF #2
5927 { \@@_save_kerning:nnnNN { bound_kern } { offset } { bound } }
5928 { \@@_save_kerning:nnNN { bound_kern } { offset } }
5929 }
5930 {
5931 \@@_punct_if_right:NTF #2
5932 { \@@_save_kerning:nnNN { bound_kern } { bound } }
5933 { \@@_save_kerning:nnnNN { bound_kern } { bound } { offset } }
5934 }
5935 #1 #2
5936 }
5937 \cs_new:Npn \@@_punct_kerning_process_aux:NN #1#2
5938 {
5939 \bool_if:NTF \l_@@_enabled_kerning_bool
5940 { \@@_calc_kerning_margin:NN #1 #2 }
5941 { \l_@@_margin_dim }
5942 }
5943 \dim_new:N \l_@@_minimum_bound_dim
5944 \dim_new:N \l_@@_kerning_margin_dim
5945 % \end{macrocode}
5946 % \end{macro}
5947 %
5948 % \changes{v3.4.0}{2016/05/12}{标点符号的压缩量能伸长到原始空白,能收缩到较小边距。}
5949 %
5950 % \begin{macro}{\@@_save_kerning:nnNN}
5951 % 相邻两个标点符号的间距能伸长到原始空白(未压缩时的状态),能收缩到较小边距。
5952 % \begin{macrocode}
5953 \cs_new_protected:Npn \@@_save_kerning:nnNN #1#2
5954 { \@@_save_kerning:nnnNN {#1} {#2} {#2} }
5955 \cs_new_protected:Npn \@@_save_kerning:nnnNN #1#2#3#4#5
5956 {
5957 \dim_set:Nn \l_@@_tmp_dim
5958 {
5959 \l_@@_kerning_margin_dim
5960 - ( \@@_use_punct_dim:nNN {#2} \c_@@_right_tl #4 )
5961 - ( \@@_use_punct_dim:nNN {#3} \c_@@_left_tl #5 )
5962 }
5963 \@@_save_punct_dim:nNNn {#1} #4 #5 { \l_@@_tmp_dim }
5964 \@@_save_punct_skip:nNNnnn {#1} #4 #5
5965 { \l_@@_tmp_dim }
5966 { \l_@@_margin_dim - \l_@@_kerning_margin_dim }
5967 { \l_@@_kerning_margin_dim - \l_@@_minimum_bound_dim }
5968 }
5969 % \end{macrocode}
5970 % \end{macro}
5971 %
5972 % \begin{macro}{\@@_original_kerning_margin:NN}
5973 % 相邻两个标点符号之间的本来空白宽度。
5974 % \begin{macrocode}
5975 \cs_new:Npn \@@_original_kerning_margin:NN #1#2
5976 {
5977 \dim_eval:n
5978 {
5979 \@@_use_punct_dim:nNN
5980 { \@@_punct_if_right:NTF #1 { margin } { bound } } \c_@@_right_tl #1
5981 +
5982 \@@_use_punct_dim:nNN
5983 { \@@_punct_if_right:NTF #2 { bound } { margin } } \c_@@_left_tl #2
5984 }
5985 }
5986 % \end{macrocode}
5987 % \end{macro}
5988 %
5989 % \begin{macro}{\@@_calc_kerning_margin:NN,\@@_calc_kerning_margin_aux:NN}
5990 % \begin{macrocode}
5991 \cs_new:Npn \@@_calc_kerning_margin:NN #1#2
5992 {
5993 \dim_max:nn
5994 { \l_@@_kerning_margin_minimum_dim }
5995 {
5996 \bool_if:NTF \l_@@_min_bound_to_kerning_bool
5997 { \l_@@_minimum_bound_dim }
5998 {
5999 \bool_if:NTF \l_@@_optimize_kerning_bool
6000 { \dim_max:nn { \l_@@_minimum_bound_dim } }
6001 { \use:n }
6002 { \@@_calc_kerning_margin_aux:NN #1 #2 }
6003 }
6004 }
6005 }
6006 \cs_new:Npn \@@_calc_kerning_margin_aux:NN #1#2
6007 {
6008 \dim_compare:nNnTF \l_@@_kerning_total_width_dim < \c_max_dim
6009 { \@@_calc_kerning_margin:nNN \l_@@_kerning_total_width_dim }
6010 {
6011 \fp_if_nan:nTF { \l_@@_kerning_total_ratio_fp }
6012 {
6013 \xeCJK_if_same_class:NNTF #1 #2
6014 { \@@_kerning_width_or_ratio:nNN { same } }
6015 { \@@_kerning_width_or_ratio:nNN { different } }
6016 }
6017 {
6018 \@@_calc_kerning_margin:nNN
6019 {
6020 \@@_dim_ratio:Nn \l_@@_kerning_total_ratio_fp
6021 {
6022 \@@_use_punct_dim:nN { width } #1 +
6023 \@@_use_punct_dim:nN { width } #2
6024 }
6025 }
6026 }
6027 }
6028 #1 #2
6029 }
6030 % \end{macrocode}
6031 % \end{macro}
6032 %
6033 % \begin{macro}{\@@_kerning_width_or_ratio:nNN}
6034 % \begin{macrocode}
6035 \cs_new:Npn \@@_kerning_width_or_ratio:nNN #1#2#3
6036 {
6037 \dim_compare:nNnTF { \use:c { l_@@_#1_align_margin_dim } } < \c_max_dim
6038 { \use:c { l_@@_#1_align_margin_dim } }
6039 {
6040 \fp_if_nan:nTF { \use:c { l_@@_#1_align_ratio_fp } }
6041 {
6042 \dim_compare:nNnTF \l_@@_kerning_margin_width_dim < \c_max_dim
6043 { \l_@@_kerning_margin_width_dim \use_none:n }
6044 { \@@_dim_ratio:Nn \l_@@_kerning_margin_ratio_fp }
6045 }
6046 { \@@_dim_ratio:cn { l_@@_#1_align_ratio_fp } }
6047 { \l_@@_margin_dim }
6048 }
6049 }
6050 % \end{macrocode}
6051 % \end{macro}
6052 %
6053 % \begin{macro}{\@@_punct_min_bound:NN}
6054 % \begin{macrocode}
6055 \cs_new:Npn \@@_punct_min_bound:NN #1#2
6056 {
6057 \dim_max:nn
6058 {
6059 \dim_min:nn
6060 { \@@_use_punct_dim:nNN { bound } \c_@@_left_tl #1 }
6061 { \@@_use_punct_dim:nNN { bound } \c_@@_right_tl #1 }
6062 }
6063 {
6064 \dim_min:nn
6065 { \@@_use_punct_dim:nNN { bound } \c_@@_left_tl #2 }
6066 { \@@_use_punct_dim:nNN { bound } \c_@@_right_tl #2 }
6067 }
6068 }
6069 % \end{macrocode}
6070 % \end{macro}
6071 %
6072 % \begin{macro}{\@@_calc_kerning_margin:nNN}
6073 % |#2| 和 |#3| 为相邻的两个标点,|#1| 为要确定的相邻两个标点总共占的宽度。
6074 % \begin{macrocode}
6075 \cs_new:Npn \@@_calc_kerning_margin:nNN #1#2#3
6076 {
6077 \dim_eval:n
6078 {
6079 (#1)
6080 - ( \@@_use_punct_dim:nNN
6081 { \@@_punct_if_right:NTF #2 { bound } { margin } }
6082 \c_@@_left_tl #2 )
6083 - ( \@@_use_punct_dim:nNN
6084 { \@@_punct_if_right:NTF #3 { margin } { bound } }
6085 \c_@@_right_tl #3 )
6086 - ( \@@_use_punct_dim:nN { dimen } #2 )
6087 - ( \@@_use_punct_dim:nN { dimen } #3 )
6088 }
6089 }
6090 % \end{macrocode}
6091 % \end{macro}
6092 %
6093 % \begin{macro}[int]{\xeCJK_calc_punct_dimen:N}
6094 % 计算标点的左右实际边距和实际尺寸。
6095 % \begin{macrocode}
6096 \cs_new_protected:Npn \xeCJK_calc_punct_dimen:N #1
6097 {
6098 \@@_save_punct_dim:nNNn { bound } \c_@@_left_tl #1
6099 { \xeCJK_glyph_bounds:NN 1 #1 }
6100 \@@_save_punct_dim:nNNn { bound } \c_@@_right_tl #1
6101 { \xeCJK_glyph_bounds:NN 3 #1 }
6102 \@@_save_punct_dim:nNn { width } #1
6103 { \tex_fontcharwd:D \tex_font:D `#1 }
6104 \@@_save_punct_dim:nNn { dimen } #1
6105 {
6106 ( \@@_use_punct_dim:nN { width } #1 ) -
6107 ( \@@_use_punct_dim:nNN { bound } \c_@@_left_tl #1 ) -
6108 ( \@@_use_punct_dim:nNN { bound } \c_@@_right_tl #1 )
6109 }
6110 }
6111 % \end{macrocode}
6112 % \end{macro}
6113 %
6114 % \begin{macro}[int]{\xeCJK_glyph_bounds:NN}
6115 % 用 \tn{XeTeXglyphbounds} 取得标点符号的上下左右空白。
6116 % \begin{macrocode}
6117 \cs_new:Npn \xeCJK_glyph_bounds:NN #1#2
6118 { \tex_XeTeXglyphbounds:D #1 ~ \tex_XeTeXcharglyph:D `#2 \exp_stop_f: }
6119 % \end{macrocode}
6120 % \end{macro}
6121 %
6122 % \changes{v3.8.3}{2020/04/09}{重构 \opt{PunctStyle} 选项,完全展开参数。}
6123 %
6124 % \begin{macro}{PunctStyle}
6125 % \begin{macrocode}
6126 \keys_define:nn { xeCJK / options }
6127 { PunctStyle .code:n = \exp_args:Nx \@@_set_punct_style:n {#1} }
6128 \cs_new_protected:Npn \@@_set_punct_style:n #1
6129 {
6130 \IfInstanceExistTF { xeCJK / punctuation } {#1}
6131 { \tl_set:Nn \l_xeCJK_punct_style_tl {#1} }
6132 {
6133 \prop_get:NnNF \c_@@_punct_style_alias_prop
6134 {#1} \l_xeCJK_punct_style_tl
6135 { \@@_error:nx { punct-style-unknown } {#1} }
6136 }
6137 }
6138 \prop_const_from_keyval:Nn \c_@@_punct_style_alias_prop
6139 {
6140 halfwidth = banjiao ,
6141 fullwidth = quanjiao ,
6142 mixedwidth = kaiming ,
6143 marginkerning = hangmobanjiao ,
6144 plain = plain
6145 }
6146 \tl_new:N \l_xeCJK_punct_style_tl
6147 \tl_const:Nn \c_@@_punct_style_plain_tl { plain }
6148 \@@_msg_new:nn { punct-style-unknown }
6149 {
6150 Punctuation~style~"#1"~is~unknown. \\\\
6151 The~available~styles~are~listed~as~follow.\\\\
6152 "plain,~\seq_use:Nnnn \g_@@_punct_style_seq
6153 { ~and~ } { ,~ } { ,~and~ }".\\
6154 }
6155 % \end{macrocode}
6156 % \end{macro}
6157 %
6158 % \begin{macro}{\@@_trim_spaces:n}
6159 % \pkg{xparse} 处理函数,先完全展开参数再删除两边空格。
6160 % \begin{macrocode}
6161 \cs_new_protected:Npn \@@_trim_spaces:n #1
6162 {
6163 \tl_set:Nx \ProcessedArgument
6164 { \exp_args:Ne \tl_trim_spaces:n {#1} }
6165 }
6166 % \end{macrocode}
6167 % \end{macro}
6168 %
6169 % \begin{macro}{\xeCJKDeclarePunctStyle}
6170 % 定义新的标点处理风格,已经存在的同名风格将被覆盖。
6171 % \begin{macrocode}
6172 \NewDocumentCommand \xeCJKDeclarePunctStyle
6173 { > { \@@_trim_spaces:n } m m }
6174 {
6175 \IfInstanceExistTF { xeCJK / punctuation } {#1}
6176 { \@@_warning:nx { punct-style-already-defined } {#1} }
6177 { \seq_gput_right:Nn \g_@@_punct_style_seq {#1} }
6178 \DeclareInstance { xeCJK / punctuation } {#1} { basic } {#2}
6179 }
6180 \seq_new:N \g_@@_punct_style_seq
6181 \@@_msg_new:nn { punct-style-already-defined }
6182 {
6183 Punctuation~style~"#1"~is~already~defined!. \\\\
6184 The~existing~style~of~"#1"~will~be~overwritten.\\
6185 }
6186 \@onlypreamble \xeCJKDeclarePunctStyle
6187 % \end{macrocode}
6188 % \end{macro}
6189 %
6190 % \begin{macro}{\xeCJKEditPunctStyle}
6191 % 对已有的标点处理风格进行修改。
6192 % \begin{macrocode}
6193 \NewDocumentCommand \xeCJKEditPunctStyle
6194 { > { \@@_trim_spaces:n } m m }
6195 {
6196 \IfInstanceExistTF { xeCJK / punctuation } {#1}
6197 { \EditInstance { xeCJK / punctuation } {#1} {#2} }
6198 { \@@_error:nx { punct-style-unknown } {#1} }
6199 }
6200 \@onlypreamble \xeCJKEditPunctStyle
6201 % \end{macrocode}
6202 % \end{macro}
6203 %
6204 % 默认设置即为全角格式。
6205 % \begin{macrocode}
6206 \xeCJKDeclarePunctStyle { quanjiao } { }
6207 % \end{macrocode}
6208 %
6209 % \begin{macrocode}
6210 \xeCJKDeclarePunctStyle { hangmobanjiao } { enabled-kerning = false }
6211 % \end{macrocode}
6212 %
6213 % \begin{macrocode}
6214 \xeCJKDeclarePunctStyle { banjiao }
6215 {
6216 fixed-punct-ratio = 0.5 ,
6217 optimize-margin = true ,
6218 kerning-total-ratio = 0.5 ,
6219 optimize-kerning = true
6220 }
6221 % \end{macrocode}
6222 %
6223 % \begin{macrocode}
6224 \xeCJKDeclarePunctStyle { kaiming }
6225 {
6226 fixed-punct-ratio = 0.5 ,
6227 mixed-punct-ratio = 0.8 ,
6228 optimize-margin = true ,
6229 kerning-total-ratio = 0.5 ,
6230 optimize-kerning = true
6231 }
6232 % \end{macrocode}
6233 %
6234 % \begin{macrocode}
6235 \xeCJKDeclarePunctStyle { CCT }
6236 {
6237 fixed-punct-ratio = 0.7 ,
6238 optimize-margin = true ,
6239 kerning-total-ratio = 0.6 ,
6240 optimize-kerning = true
6241 }
6242 % \end{macrocode}
6243 %
6244 % \subsection{后备字体}
6245 %
6246 % \changes{v3.8.4}{2020/05/31}{重构后备字体的实现,修正标点符号无后备字体的问题。}
6247 %
6248 % \begin{macro}{AutoFallBack}
6249 % 后备字体的宏包选项声明。
6250 % \begin{macrocode}
6251 \keys_define:nn { xeCJK / options }
6252 {
6253 AutoFallBack .choice: ,
6254 AutoFallBack / true .code:n =
6255 {
6256 \cs_set_eq:NN \xeCJK_fallback_symbol:NN
6257 \@@_fallback_symbol:NN
6258 \cs_set_eq:NN \xeCJK_fallback_punct_symbol:NN
6259 \@@_fallback_punct_symbol:NN
6260 \cs_set_eq:NN \xeCJK_clear_fallback_font:
6261 \@@_clear_fallback_font:
6262 } ,
6263 AutoFallBack / false .code:n =
6264 {
6265 \xeCJK_cs_clear:N \xeCJK_fallback_symbol:NN
6266 \xeCJK_cs_clear:N \xeCJK_fallback_punct_symbol:NN
6267 \xeCJK_cs_clear:N \xeCJK_clear_fallback_font:
6268 } ,
6269 AutoFallBack .default:n = { true } ,
6270 fallback .meta:n = { AutoFallBack = true }
6271 }
6272 % \end{macrocode}
6273 % \end{macro}
6274 %
6275 % \begin{macro}[int]{\xeCJK_fallback_symbol:NN,\xeCJK_fallback_punct_symbol:NN}
6276 % 测试当前字体中是否存在当前字符,如存在则直接输出,否则启用后备字体。
6277 % \begin{macrocode}
6278 \cs_new_protected:Npn \@@_fallback_symbol:NN #1#2
6279 {
6280 \xeCJK_reset_fallback_font:
6281 \xeCJK_glyph_if_exist:NF #2
6282 { \@@_fallback_symbol_aux:NN }
6283 #1#2
6284 }
6285 \cs_new_protected:Npn \@@_fallback_punct_symbol:NN #1#2
6286 {
6287 \xeCJK_reset_fallback_font:
6288 \xeCJK_glyph_if_exist:NF #2
6289 { \@@_fallback_punct_symbol_aux:NN }
6290 #1#2
6291 }
6292 \cs_new_eq:NN \xeCJK_fallback_symbol:NN \prg_do_nothing:
6293 \cs_new_eq:NN \xeCJK_fallback_punct_symbol:NN \prg_do_nothing:
6294 \cs_new_protected:Npn \@@_fallback_symbol_aux:NN
6295 {
6296 \@@_fallback_symbol_aux:nnNN
6297 { \CJK@family }
6298 { \l_xeCJK_family_tl }
6299 }
6300 \cs_new_protected:Npn \@@_fallback_punct_symbol_aux:NN
6301 {
6302 \@@_fallback_symbol_aux:nnNN
6303 { \CJK@punctfamily }
6304 { \l_xeCJK_punct_family_tl }
6305 }
6306 \cs_new_protected:Npn \@@_fallback_symbol_aux:nnNN
6307 {
6308 \cs_set_protected:Npx \xeCJK_reset_fallback_font:
6309 {
6310 \tex_the:D \tex_font:D
6311 \xeCJK_clear_fallback_font:
6312 }
6313 \exp_args:Nee \@@_fallback_loop:nnNN
6314 }
6315 \cs_new_protected:Npn \@@_clear_fallback_font:
6316 { \cs_set_eq:NN \xeCJK_reset_fallback_font: \prg_do_nothing: }
6317 \cs_new_eq:NN \xeCJK_reset_fallback_font: \prg_do_nothing:
6318 \cs_new_eq:NN \xeCJK_clear_fallback_font: \prg_do_nothing:
6319 % \end{macrocode}
6320 % \end{macro}
6321 %
6322 % \changes{v3.5.1}{2017/11/16}{修正 fallback 字体后无法忽略空格的错误。}
6323 % \changes{v3.2.12}{2014/05/12}{更新 \cs{int_to_Hex:n}。}
6324 %
6325 % \begin{macro}[int]{\@@_fallback_loop:nnNN}
6326 % \changes{v3.1.0}{2012/11/19}{调整备用字体的循环方式。}
6327 % \changes{v3.2.4}{2013/06/30}
6328 % {使 \tn{CJKfamilydefault} 的 \texttt{FallBack} 设置全局可用。}
6329 % 循环测试后备字体是否包含字符 |#1|。若后备字体中存在该字符或者再没有后备字体,则
6330 % 结束循环。当前字体族没有备用字体时,使用 \tn{CJKfamilydefault} 的设置。
6331 % \begin{macrocode}
6332 \cs_new_protected:Npn \@@_fallback_loop:nnNN
6333 {
6334 \cs_set_eq:NN \@@_fallback_loop:TF \use_i:nn
6335 \@@_fallback_loop:nnnNN { FallBack }
6336 }
6337 \cs_new_protected:Npn \@@_fallback_loop:nnnNN #1#2#3
6338 {
6339 \xeCJK_select_fallback_font:nnn {#1} {#2} {#3}
6340 \@@_fallback_loop:TF
6341 { \@@_fallback_loop_aux:nnnNN }
6342 { \@@_fallback_missing_glyph:nnnNN }
6343 {#1} {#2} {#3}
6344 }
6345 \cs_new_protected:Npn \@@_fallback_loop_aux:nnnNN #1#2#3#4#5
6346 {
6347 \xeCJK_glyph_if_exist:NF #5
6348 { \@@_fallback_loop:nnnNN { #1/FallBack } {#2} {#3} }
6349 #4#5
6350 }
6351 \cs_new_protected:Npn \@@_fallback_missing_glyph:nnnNN #1#2#3#4#5
6352 {
6353 \@@_warning:nxxx { missing-glyph } {#1} {#2} {#5}
6354 #4#5
6355 }
6356 \cs_new_protected:Npn \xeCJK_select_fallback_font:nnn #1#2
6357 {
6358 \@@_select_fallback_font:cnnn
6359 { \@@_font_csname:n { #2/#1 } } {#1} {#2}
6360 }
6361 \cs_new_protected:Npn \@@_select_fallback_font:Nnnn #1
6362 {
6363 \cs_if_exist:NF #1
6364 { \@@_fallback_font_initial:NNnnn }
6365 #1 \use_none:nnn
6366 }
6367 \cs_generate_variant:Nn \@@_select_fallback_font:Nnnn { c }
6368 \cs_new_protected:Npn \@@_fallback_font_initial:NNnnn #1#2#3#4#5
6369 {
6370 \xeCJK_family_if_exist:nTF { #5/#3 }
6371 { \@@_font_initial:Nn #1 { #5/#3 } }
6372 { \@@_fallback_font_initial_auxi:Nnnn #1 {#5} {#3} {#4} }
6373 #1
6374 }
6375 \cs_new_protected:Npn \@@_fallback_font_initial_auxi:Nnnn #1
6376 {
6377 \exp_args:NNe \@@_fallback_font_initial_auxii:Nnnnn
6378 #1 { \CJKfamilydefault }
6379 }
6380 \cs_new_protected:Npn \@@_fallback_font_initial_auxii:Nnnnn #1#2#3
6381 {
6382 \str_if_eq:nnTF {#2} {#3}
6383 { \@@_fallback_loop_end:Nnnn }
6384 { \@@_fallback_font_initial_auxiii:Nnnn }
6385 #1 {#2}
6386 }
6387 \cs_new_protected:Npn \@@_fallback_font_initial_auxiii:Nnnn #1#2
6388 {
6389 \xeCJK_family_if_exist:nTF {#2}
6390 { \@@_fallback_font_initial_auxiv:Nnnn }
6391 { \@@_fallback_loop_end:Nnnn }
6392 #1 {#2}
6393 }
6394 \cs_new_protected:Npn \@@_fallback_font_initial_auxiv:Nnnn #1#2#3#4
6395 {
6396 \@@_font_initial:Nn #1 {#2}
6397 \exp_args:Nc \@@_fallback_font_initial_auxiii:Nnnn
6398 { \@@_font_csname:n { #4/#3/FallBack } }
6399 { #2/FallBack } { #3/FallBack } {#4}
6400 }
6401 \cs_new_eq:NN \@@_fallback_loop:TF \use_i:nn
6402 \cs_new_protected:Npn \@@_fallback_loop_end:Nnnn #1#2#3#4
6403 { \cs_gset_eq:NN #1 \@@_fallback_loop_end: }
6404 \cs_new_protected:Npn \@@_fallback_loop_end:
6405 { \cs_set_eq:NN \@@_fallback_loop:TF \use_ii:nn }
6406 \@@_msg_new:nn { missing-glyph }
6407 {
6408 CJKfamily~`\@@_msg_family_map:n {#2}'~(#1)~
6409 does~not~contain~glyph~`#3'~
6410 ( U + \int_to_Hex:n { `#3 } )~\msg_line_context:.
6411 }
6412 % \end{macrocode}
6413 % \end{macro}
6414 %
6415 % \begin{macro}{\setCJKfallbackfamilyfont}
6416 % \changes{v3.4.3}{2016/11/18}{允许字体属性可选项在后的新语法。}
6417 % \begin{macrocode}
6418 \NewDocumentCommand \setCJKfallbackfamilyfont { m o m }
6419 {
6420 \@@_pass_args:nnnn
6421 { \xeCJK_set_family_fallback:nnn {#1} } {#2} {#3}
6422 { }
6423 }
6424 % \end{macrocode}
6425 % \end{macro}
6426 %
6427 % \begin{macro}[int]{\xeCJK_set_family_fallback:nnn}
6428 % \begin{macrocode}
6429 \cs_new_protected:Npn \xeCJK_set_family_fallback:nnn #1#2#3
6430 {
6431 \group_begin:
6432 \tl_set:Nn \l_@@_fallback_family_tl {#1}
6433 \prop_get:NoNF \g_@@_family_font_name_prop
6434 \l_@@_fallback_family_tl \l_@@_font_name_tl
6435 { \tl_clear:N \l_@@_font_name_tl }
6436 \clist_set:Nn \l_@@_public_options_clist {#2}
6437 \clist_map_function:nN {#3} \@@_set_family_fallback:n
6438 \group_end:
6439 }
6440 \cs_new_protected:Npn \@@_set_family_fallback:n #1
6441 {
6442 \tl_put_right:Nn \l_@@_fallback_family_tl { /FallBack }
6443 \@@_get_sub_features:on \l_@@_fallback_family_tl {#1}
6444 \clist_concat:NNN \l_@@_sub_font_options_clist
6445 \l_@@_public_options_clist
6446 \l_@@_sub_font_options_clist
6447 \exp_args:Nooo \xeCJK_set_family:nnn
6448 \l_@@_fallback_family_tl
6449 \l_@@_sub_font_options_clist
6450 \l_@@_sub_font_name_tl
6451 }
6452 \tl_new:N \l_@@_fallback_family_tl
6453 \clist_new:N \l_@@_public_options_clist
6454 % \end{macrocode}
6455 % \end{macro}
6456 %
6457 %
6458 % \subsection{CJK 字体族声明方式}
6459 %
6460 % \begin{macrocode}
6461 \bool_new:N \g_@@_auto_fake_bold_bool
6462 \bool_new:N \g_@@_auto_fake_slant_bool
6463 \fp_new:N \g_@@_embolden_factor_fp
6464 \fp_new:N \g_@@_slant_factor_fp
6465 % \end{macrocode}
6466 %
6467 % \begin{macro}{AutoFakeBold, AutoFakeSlant,EmboldenFactor,SlantFactor}
6468 % 伪粗体和伪斜体的宏包选项声明。
6469 % \begin{macrocode}
6470 \keys_define:nn { xeCJK / options }
6471 {
6472 AutoFakeBold .choices:nn = { true , false }
6473 { \use:c { bool_gset_ \l_keys_choice_tl :N } \g_@@_auto_fake_bold_bool } ,
6474 AutoFakeBold / unknown .code:n =
6475 {
6476 \bool_gset_true:N \g_@@_auto_fake_bold_bool
6477 \fp_gset:Nn \g_@@_embolden_factor_fp { \l_keys_value_tl }
6478 } ,
6479 AutoFakeBold .default:n = { true } ,
6480 AutoFakeSlant .choices:nn = { true , false }
6481 { \use:c { bool_gset_ \l_keys_choice_tl :N } \g_@@_auto_fake_slant_bool } ,
6482 AutoFakeSlant / unknown .code:n =
6483 {
6484 \bool_gset_true:N \g_@@_auto_fake_slant_bool
6485 \fp_gset:Nn \g_@@_slant_factor_fp { \l_keys_value_tl }
6486 } ,
6487 AutoFakeSlant .default:n = { true } ,
6488 EmboldenFactor .fp_gset:N = \g_@@_embolden_factor_fp ,
6489 SlantFactor .fp_gset:N = \g_@@_slant_factor_fp ,
6490 BoldFont .meta:n = { AutoFakeBold = true } ,
6491 boldfont .meta:n = { AutoFakeBold = true } ,
6492 SlantFont .meta:n = { AutoFakeSlant = true } ,
6493 slantfont .meta:n = { AutoFakeSlant = true }
6494 }
6495 % \end{macrocode}
6496 % \end{macro}
6497 %
6498 % \changes{v3.2.4}{2013/07/02}{内部调整分区字体的设置方法。}
6499 %
6500 % \begin{macro}[int]{\xeCJK_new_sub_key:n}
6501 % \begin{variable}{\g_@@_sub_key_seq}
6502 % 用于定义 CJK 子区字体和备用字体的选项。
6503 % \begin{macrocode}
6504 \seq_new:N \g_@@_sub_key_seq
6505 \cs_new_protected:Npn \xeCJK_new_sub_key:n #1
6506 {
6507 \seq_gput_right:Nn \g_@@_sub_key_seq {#1}
6508 \keys_define:nn { xeCJK / features }
6509 {
6510 #1 .code:n =
6511 {
6512 \tl_if_blank:nTF {##1}
6513 {
6514 \prop_clear:N \l_@@_sub_key_prop
6515 \tl_set:Nx \l_@@_sub_family_name_tl
6516 { \l_@@_family_name_tl /#1 }
6517 \clist_remove_all:Nn \l_@@_font_options_clist {#1}
6518 }
6519 {
6520 \tl_clear:N \l_@@_sub_family_name_tl
6521 \str_if_eq:nnTF {##1} { * }
6522 { \prop_put:Nnn \l_@@_sub_key_prop {#1} { \q_no_value } }
6523 { \@@_get_sub_features:nn {#1} {##1} }
6524 }
6525 } ,
6526 #1 .default:n = { }
6527 }
6528 }
6529 % \end{macrocode}
6530 % \end{variable}
6531 % \end{macro}
6532 %
6533 % \changes{v3.2.4}{2013/07/02}{改进获取分区字体属性的办法。}
6534 %
6535 % \begin{macro}{\@@_get_sub_features:nn,\@@_get_sub_features:w}
6536 % \begin{macrocode}
6537 \cs_new_protected:Npn \@@_get_sub_features:nn #1#2
6538 {
6539 \tl_set:Nx \l_@@_tmp_tl { \xeCJK_tl_remove_outer_braces:n {#2} }
6540 \clist_clear:N \l_@@_sub_font_options_clist
6541 \exp_after:wN \@@_get_sub_features:w \l_@@_tmp_tl
6542 \q_mark [ \q_nil ] \q_mark \q_stop
6543 \tl_if_empty:NTF \l_@@_sub_font_name_tl
6544 { \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_font_name_tl }
6545 { \tl_replace_all:Nno \l_@@_sub_font_name_tl { * } \l_@@_font_name_tl }
6546 \prop_put:Nne \l_@@_sub_key_prop {#1}
6547 {
6548 { \exp_not:o \l_@@_sub_font_options_clist }
6549 { \exp_not:o \l_@@_sub_font_name_tl }
6550 }
6551 }
6552 \cs_new_protected:Npn \@@_get_sub_features:w #1 [#2] #3 \q_mark #4 \q_stop
6553 {
6554 \quark_if_nil:nTF {#2}
6555 { \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_tmp_tl }
6556 {
6557 \tl_set:Nx \l_@@_sub_font_name_tl
6558 { \xeCJK_tl_remove_outer_braces:n {#3} }
6559 \tl_if_empty:NTF \l_@@_sub_font_name_tl
6560 { \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_tmp_tl }
6561 { \clist_set:Nn \l_@@_sub_font_options_clist {#2} }
6562 }
6563 }
6564 \tl_new:N \l_@@_sub_family_name_tl
6565 \tl_new:N \l_@@_sub_font_name_tl
6566 \clist_new:N \l_@@_sub_font_options_clist
6567 \cs_generate_variant:Nn \@@_get_sub_features:nn { o }
6568 \cs_generate_variant:Nn \tl_replace_all:Nnn { Nno }
6569 % \end{macrocode}
6570 % \end{macro}
6571 %
6572 % \begin{macro}{FallBack}
6573 % \begin{macrocode}
6574 \xeCJK_new_sub_key:n { FallBack }
6575 % \end{macrocode}
6576 % \end{macro}
6577 %
6578 % \begin{macro}[int]{BoldFont,ItalicFont}
6579 % 调用字体的属性声明,同 \pkg{fontspec} 宏包。
6580 % \begin{macrocode}
6581 \keys_define:nn { xeCJK / features }
6582 {
6583 BoldFont .tl_set:N = \l_@@_font_name_bf_tl ,
6584 ItalicFont .tl_set:N = \l_@@_font_name_it_tl
6585 }
6586 % \end{macrocode}
6587 % \end{macro}
6588 %
6589 % \changes{v3.2.6}{2013/07/31}{\texttt{AutoFakeBold} 和 \texttt{AutoFakeSlant}
6590 % 选项直接使用 \pkg{fontspec} 的设置,修正不能调用相应实际字体的问题。}
6591 %
6592 % \begin{macro}[int]{AutoFakeBold, AutoFakeSlant}
6593 % \begin{macrocode}
6594 \keys_define:nn { xeCJK / features }
6595 {
6596 AutoFakeBold .choice: ,
6597 AutoFakeBold / true .code:n =
6598 {
6599 \bool_set_true:N \l_@@_auto_fake_bold_bool
6600 \fp_set_eq:NN \l_@@_embolden_factor_fp \g_@@_embolden_factor_fp
6601 } ,
6602 AutoFakeBold / false .code:n =
6603 { \bool_set_false:N \l_@@_auto_fake_bold_bool } ,
6604 AutoFakeBold / unknown .code:n =
6605 {
6606 \bool_set_true:N \l_@@_auto_fake_bold_bool
6607 \fp_set:Nn \l_@@_embolden_factor_fp { \l_keys_value_tl }
6608 } ,
6609 AutoFakeBold .default:n = { true } ,
6610 AutoFakeSlant .choice: ,
6611 AutoFakeSlant / true .code:n =
6612 {
6613 \bool_set_true:N \l_@@_auto_fake_slant_bool
6614 \fp_set_eq:NN \l_@@_slant_factor_fp \g_@@_slant_factor_fp
6615 } ,
6616 AutoFakeSlant / false .code:n =
6617 { \bool_set_false:N \l_@@_auto_fake_slant_bool } ,
6618 AutoFakeSlant / unknown .code:n =
6619 {
6620 \bool_set_true:N \l_@@_auto_fake_slant_bool
6621 \fp_set:Nn \l_@@_slant_factor_fp { \l_keys_value_tl }
6622 } ,
6623 AutoFakeSlant .default:n = { true }
6624 }
6625 % \end{macrocode}
6626 % \end{macro}
6627 %
6628 % \begin{macro}{\@@_set_family_initial:}
6629 % \begin{macrocode}
6630 \cs_new_protected:Npn \@@_set_family_initial:
6631 {
6632 \int_gincr:N \g_@@_family_int
6633 \prop_clear:N \l_@@_sub_key_prop
6634 \tl_clear:N \l_@@_font_name_bf_tl
6635 \tl_clear:N \l_@@_font_name_it_tl
6636 \tl_clear:N \l_@@_sub_family_name_tl
6637 \clist_clear:N \l_@@_fontspec_options_clist
6638 \bool_set_eq:NN \l_@@_auto_fake_bold_bool \g_@@_auto_fake_bold_bool
6639 \bool_set_eq:NN \l_@@_auto_fake_slant_bool \g_@@_auto_fake_slant_bool
6640 \fp_set_eq:NN \l_@@_embolden_factor_fp \g_@@_embolden_factor_fp
6641 \fp_set_eq:NN \l_@@_slant_factor_fp \g_@@_slant_factor_fp
6642 }
6643 \int_new:N \g_@@_family_int
6644 \prop_new:N \l_@@_sub_key_prop
6645 \clist_new:N \l_@@_fontspec_options_clist
6646 \bool_new:N \l_@@_auto_fake_bold_bool
6647 \bool_new:N \l_@@_auto_fake_slant_bool
6648 \fp_new:N \l_@@_embolden_factor_fp
6649 \fp_new:N \l_@@_slant_factor_fp
6650 % \end{macrocode}
6651 % \end{macro}
6652 %
6653 % \begin{macro}[int]{\xeCJK_set_family:nnn}
6654 % 设置一个 CJK 新字体族,与 \tn{newfontfamily} 类似,增加 |FallBack| 选项。
6655 % \begin{macrocode}
6656 \cs_new_protected:Npn \xeCJK_set_family:nnn #1#2#3
6657 {
6658 \group_begin:
6659 \@@_set_family_initial:
6660 \tl_set:Nn \l_@@_family_name_tl {#1}
6661 \clist_set:Nn \l_@@_font_options_clist {#2}
6662 \tl_set:Nn \l_@@_font_name_tl {#3}
6663 \clist_concat:NNN \l_@@_font_options_clist
6664 \g_@@_default_features_clist \l_@@_font_options_clist
6665 \keys_set_known:noN { xeCJK / features }
6666 \l_@@_font_options_clist \l_@@_fontspec_options_clist
6667 \@@_binding_sub_family:
6668 \@@_parse_font_shape:
6669 \@@_check_family:o \l_@@_family_name_tl
6670 \@@_gset_family_cs:n { \l_@@_family_name_tl }
6671 \@@_save_family_info:
6672 \@@_set_sub_block_family:
6673 \group_end:
6674 }
6675 \tl_new:N \l_@@_family_name_tl
6676 \tl_new:N \l_@@_font_name_tl
6677 \clist_new:N \l_@@_font_options_clist
6678 \cs_generate_variant:Nn \xeCJK_set_family:nnn { e , o }
6679 % \end{macrocode}
6680 % \end{macro}
6681 %
6682 % \changes{v3.7.2}{2019/03/27}{删除定义新字体族时过滤重复选项的功能。}
6683 %
6684 % \begin{macro}{\@@_binding_sub_family:}
6685 % \begin{macrocode}
6686 \cs_new_protected:Npn \@@_binding_sub_family:
6687 {
6688 \tl_if_empty:NF \l_@@_sub_family_name_tl
6689 { \tl_set_eq:NN \l_@@_family_name_tl \l_@@_sub_family_name_tl }
6690 }
6691 % \end{macrocode}
6692 % \end{macro}
6693 %
6694 % \begin{macro}{\@@_gset_family_cs:n}
6695 % \begin{macrocode}
6696 \cs_new_protected:Npn \@@_gset_family_cs:n #1
6697 {
6698 \cs_gset_protected:cpx { \@@_family_csname:n {#1} }
6699 {
6700 \group_begin:
6701 \exp_not:n { \cs_set_eq:NN \xeCJK@fontfamily \use_none:n }
6702 \exp_not:n { \fontspec_gset_family:Nnn \g_@@_fontspec_family_tl }
6703 { \exp_not:o \l_@@_fontspec_options_clist }
6704 { \exp_not:o \l_@@_font_name_tl }
6705 \@@_gset_family_nfss_cs:no
6706 {#1} { \exp_not:N \g_@@_fontspec_family_tl }
6707 \group_end:
6708 \tl_set_eq:NN \exp_not:N \l_@@_fontspec_family_tl
6709 \exp_not:N \g_@@_fontspec_family_tl
6710 }
6711 }
6712 \tl_new:N \g_@@_fontspec_family_tl
6713 \tl_new:N \l_@@_fontspec_family_tl
6714 % \end{macrocode}
6715 % \end{macro}
6716 %
6717 % \begin{macro}{\@@_check_family:n}
6718 % \begin{macrocode}
6719 \cs_new_protected:Npn \@@_check_family:n #1
6720 {
6721 \prop_gpop:NnNT \g_@@_family_font_name_prop {#1} \l_@@_tmp_tl
6722 {
6723 \prop_gpop:NnNT \g_@@_family_name_prop {#1} \l_@@_tmp_tl
6724 {
6725 \cs_undefine:c { \@@_family_csname:n {#1} }
6726 \cs_undefine:c { \@@_family_nfss_csname:n {#1} }
6727 }
6728 \@@_warning:nxx { CJKfamily-redef } {#1} { \l_@@_tmp_tl }
6729 }
6730 }
6731 \cs_generate_variant:Nn \@@_check_family:n { o }
6732 \@@_msg_new:nn { CJKfamily-redef }
6733 { Redefining~CJKfamily~`\@@_msg_family_map:n {#1}'~(#2). }
6734 % \end{macrocode}
6735 % \end{macro}
6736 %
6737 % \begin{macro}{\@@_parse_font_shape:}
6738 % \begin{macrocode}
6739 \cs_new_protected:Npn \@@_parse_font_shape:
6740 {
6741 \tl_if_blank:oTF \l_@@_font_name_bf_tl
6742 {
6743 \bool_if:NT \l_@@_auto_fake_bold_bool
6744 {
6745 \clist_put_right:Nx \l_@@_fontspec_options_clist
6746 { AutoFakeBold = { \fp_use:N \l_@@_embolden_factor_fp } }
6747 }
6748 }
6749 {
6750 \clist_put_right:Nx \l_@@_fontspec_options_clist
6751 { BoldFont = { \exp_not:o \l_@@_font_name_bf_tl } }
6752 }
6753 \tl_if_blank:oTF \l_@@_font_name_it_tl
6754 {
6755 \bool_if:NT \l_@@_auto_fake_slant_bool
6756 {
6757 \clist_put_right:Nx \l_@@_fontspec_options_clist
6758 { AutoFakeSlant = { \fp_use:N \l_@@_slant_factor_fp } }
6759 }
6760 }
6761 {
6762 \clist_put_right:Nx \l_@@_fontspec_options_clist
6763 { ItalicFont = { \exp_not:o \l_@@_font_name_it_tl } }
6764 }
6765 }
6766 % \end{macrocode}
6767 % \end{macro}
6768 %
6769 % \begin{variable}
6770 % {\g_@@_family_name_prop,\g_@@_family_font_name_prop,\g_@@_family_font_options_prop}
6771 % \begin{macrocode}
6772 \prop_new:N \g_@@_family_name_prop
6773 \prop_new:N \g_@@_family_font_name_prop
6774 \prop_new:N \g_@@_family_font_options_prop
6775 % \end{macrocode}
6776 % \end{variable}
6777 %
6778 % \begin{macro}{\@@_save_family_info:}
6779 % \begin{macrocode}
6780 \cs_new_protected:Npn \@@_save_family_info:
6781 {
6782 \exp_args:Nooo \@@_save_family_info:nnn
6783 \l_@@_family_name_tl
6784 \l_@@_font_name_tl
6785 \l_@@_font_options_clist
6786 }
6787 \cs_new_protected:Npn \@@_save_family_info:nnn #1#2#3
6788 {
6789 \prop_gput:Nnn \g_@@_family_font_name_prop {#1} {#2}
6790 \prop_gput:Nnn \g_@@_family_font_options_prop {#1} {#3}
6791 }
6792 % \end{macrocode}
6793 % \end{macro}
6794 %
6795 % \begin{macro}{\@@_set_sub_block_family:}
6796 % \begin{macrocode}
6797 \cs_new_protected:Npn \@@_set_sub_block_family:
6798 {
6799 \prop_if_empty:NF \l_@@_sub_key_prop
6800 {
6801 \prop_map_function:NN
6802 \l_@@_sub_key_prop
6803 \@@_set_sub_block_family:nn
6804 }
6805 }
6806 \cs_new_protected:Npn \@@_set_sub_block_family:nn #1#2
6807 {
6808 \tl_set:Nx \l_@@_sub_family_name_tl { \l_@@_family_name_tl/#1 }
6809 \quark_if_no_value:nTF {#2}
6810 { \@@_copy_sub_family:n {#1} }
6811 { \xeCJK_set_family:onn \l_@@_sub_family_name_tl #2 }
6812 }
6813 \cs_new_protected:Npn \@@_copy_sub_family:n #1
6814 {
6815 \@@_check_family:o \l_@@_sub_family_name_tl
6816 \prop_get:NoNT \g_@@_family_font_name_prop
6817 \l_@@_family_name_tl \l_@@_sub_font_name_tl
6818 {
6819 \prop_gput:Noo \g_@@_family_font_name_prop
6820 \l_@@_sub_family_name_tl \l_@@_sub_font_name_tl
6821 }
6822 \prop_get:NoNT \g_@@_family_font_options_prop
6823 \l_@@_family_name_tl \l_@@_sub_font_options_clist
6824 {
6825 \clist_remove_all:Nn \l_@@_sub_font_options_clist { #1 = * }
6826 \prop_gput:Noo \g_@@_family_font_options_prop
6827 \l_@@_sub_family_name_tl \l_@@_sub_font_options_clist
6828 }
6829 \cs_gset_protected:cpx
6830 { \@@_family_csname:n { \l_@@_sub_family_name_tl } }
6831 {
6832 \xeCJK_family_if_exist:eT { \l_@@_family_name_tl }
6833 {
6834 \@@_gset_family_nfss_cs:no
6835 { \l_@@_sub_family_name_tl }
6836 { \exp_not:N \l_@@_fontspec_family_tl }
6837 }
6838 }
6839 }
6840 % \end{macrocode}
6841 % \end{macro}
6842 %
6843 % \begin{macro}{\@@_copy_family:nn,\@@_copy_family:ee}
6844 % \begin{macrocode}
6845 \cs_new_protected:Npn \@@_copy_family:nn #1#2
6846 {
6847 \xeCJK_family_if_exist:nT {#2}
6848 {
6849 \prop_gput:Nno \g_@@_family_name_prop
6850 {#1} \l_@@_fontspec_family_tl
6851 \tl_map_inline:nn
6852 {
6853 \g_@@_family_font_name_prop
6854 \g_@@_family_font_options_prop
6855 }
6856 {
6857 \prop_get:NnNT ##1 {#2} \l_@@_tmp_tl
6858 { \prop_gput:Nno ##1 {#1} \l_@@_tmp_tl }
6859 }
6860 \cs_gset_eq:cc
6861 { \@@_family_nfss_csname:n {#1} }
6862 { \@@_family_nfss_csname:n {#2} }
6863 }
6864 }
6865 \cs_generate_variant:Nn \@@_copy_family:nn { ee }
6866 % \end{macrocode}
6867 % \end{macro}
6868 %
6869 % \subsection{字体切换}
6870 %
6871 % \begin{macro}[int]{\xeCJK_select_font:}
6872 % \begin{variable}[int]{\l_xeCJK_current_font_tl}
6873 % 缓存当前字体的原始格式,以加速编译。
6874 % \begin{macrocode}
6875 \cs_new:Npn \@@_font_csname:n #1
6876 { xeCJK/#1/\f@series/\f@shape/\f@size }
6877 \tl_new:N \l_xeCJK_current_font_tl
6878 \tl_set:No \l_xeCJK_current_font_tl
6879 { \@@_font_csname:n { \CJK@family } }
6880 \cs_new_protected:Npn \xeCJK_select_font:
6881 {
6882 \@@_select_font:cn
6883 { \l_xeCJK_current_font_tl }
6884 { \l_xeCJK_family_tl }
6885 }
6886 \cs_new_protected:Npn \@@_select_font:Nn #1#2
6887 {
6888 \xeCJK_clear_fallback_font:
6889 \cs_if_exist:NF #1 { \@@_font_initial:Nn #1 {#2} }
6890 #1
6891 }
6892 \cs_generate_variant:Nn \@@_select_font:Nn { c }
6893 \tl_new:N \l_@@_current_coor_tl
6894 \cs_new_eq:NN \xeCJK@setfont \xeCJK_select_font:
6895 % \end{macrocode}
6896 % \end{variable}
6897 % \end{macro}
6898 %
6899 % \changes{v3.8.1}{2020/02/14}{修复 \cs{l_xeCJK_current_font_tl} 标记错误。}
6900 %
6901 % \begin{macro}{\@@_font_initial:Nn}
6902 % 注意要将 \tn{selectfont} 放在分组中调用,防止 \tn{f@series} 等字体参数被修改,
6903 % 导致 \cs{l_xeCJK_current_font_tl} 标记前后不一致,引发错误(见~\ghissue{486})。
6904 % \begin{macrocode}
6905 \cs_new_protected:Npn \@@_font_initial:Nn #1#2
6906 {
6907 \group_begin:
6908 \@@_font_initial_hook:
6909 \@@_family_use:n {#2}
6910 \xeCJK_font_gset_to_current:N #1
6911 \group_end:
6912 }
6913 \cs_new_protected:Npn \@@_font_initial_hook:
6914 { \tl_use:N \g_@@_font_initial_hook_tl }
6915 \cs_new_protected:Npn \@@_gadd_font_initial_hook:n
6916 { \tl_gput_right:Nn \g_@@_font_initial_hook_tl }
6917 \tl_new:N \g_@@_font_initial_hook_tl
6918 % \end{macrocode}
6919 % \end{macro}
6920 %
6921 % \begin{macro}[int]{\xeCJK_select_punct_font:}
6922 % \begin{variable}[int]{\l_xeCJK_current_punct_font_tl}
6923 % 切换标点符号字体。
6924 % \begin{macrocode}
6925 \cs_new_eq:NN \xeCJK_select_punct_font: \xeCJK_select_font:
6926 \cs_new_protected:Npn \@@_select_punct_font_aux:
6927 {
6928 \@@_select_font:cn
6929 { \l_xeCJK_current_punct_font_tl }
6930 { \l_xeCJK_punct_family_tl }
6931 }
6932 \tl_new:N \CJK@punctfamily
6933 \tl_new:N \l_xeCJK_punct_family_tl
6934 \tl_new:N \l_xeCJK_current_punct_font_tl
6935 \tl_set:Nn \CJK@punctfamily { \CJK@family }
6936 \tl_set:Nn \l_xeCJK_punct_family_tl { \l_xeCJK_family_tl }
6937 \tl_set:No \l_xeCJK_current_punct_font_tl
6938 { \@@_font_csname:n { \CJK@punctfamily } }
6939 \cs_new_eq:NN \@@_select_font: \prg_do_nothing:
6940 \cs_new_eq:NN \@@_select_punct_font: \prg_do_nothing:
6941 % \end{macrocode}
6942 % \end{variable}
6943 % \end{macro}
6944 %
6945 % \begin{macro}{\@@_switch_font:nn}
6946 % \changes{v3.1.0}{2012/11/18}{改进定义,加快切换速度。}
6947 % 两个 CJK 分区之间的字体切换。
6948 % \begin{macrocode}
6949 \cs_new_protected:Npn \@@_switch_font:nn #1#2
6950 {
6951 \str_if_eq:nnF {#1} {#2}
6952 {
6953 \@@_info:nxx { CJK-block } {#1} {#2}
6954 \str_if_eq:nnTF {#2} { CJK }
6955 { \xeCJK_select_font: }
6956 { \xeCJK_select_font:n {#2} }
6957 }
6958 }
6959 \@@_msg_new:nn { CJK-block } { Switch~from~block~`#1'~to~`#2'. }
6960 % \end{macrocode}
6961 % \end{macro}
6962 %
6963 % \changes{v3.8.2}{2020/02/17}{修复分区字体错误。}
6964 %
6965 % \begin{macro}[int]{\xeCJK_select_font:n,\xeCJK_block_family:nn}
6966 % 若当前 CJK 字体族没有定义子分区 |#1| 的字体,则使用 \tn{CJKfamilydefault} 的对应
6967 % 分区字体;若 \tn{CJKfamilydefault} 也没有定义该分区字体,则使用当前 CJK 字体族的
6968 % 主分区字体。
6969 % \begin{macrocode}
6970 \cs_new_protected:Npn \xeCJK_select_font:n #1
6971 {
6972 \@@_select_font:cnn
6973 { \@@_font_csname:n { \CJK@family/#1 } }
6974 { \l_xeCJK_family_tl }
6975 {#1}
6976 }
6977 \cs_new_protected:Npn \@@_select_font:Nnn #1#2#3
6978 {
6979 \xeCJK_clear_fallback_font:
6980 \cs_if_exist:NF #1
6981 { \@@_block_font_initial:Nnn #1 {#2} {#3} }
6982 #1
6983 }
6984 \cs_generate_variant:Nn \@@_select_font:Nnn { c }
6985 \cs_new_protected:Npn \@@_block_font_initial:Nnn #1#2#3
6986 {
6987 \xeCJK_block_family:nn {#2} {#3}
6988 \@@_font_initial:Nn #1 { #2/#3 }
6989 }
6990 \cs_new_protected:Npn \xeCJK_block_family:nn #1#2
6991 {
6992 \xeCJK_family_if_exist:eF { #1/#2 }
6993 {
6994 \@@_copy_family:ee { #1/#2 }
6995 {
6996 \cs_if_exist:cTF
6997 { \@@_family_csname:n { \CJKfamilydefault/#2 } }
6998 { \CJKfamilydefault/#2 } {#1}
6999 }
7000 }
7001 }
7002 % \end{macrocode}
7003 % \end{macro}
7004 %
7005 % \begin{macro}
7006 % {\@@_family_csname:n,\@@_family_nfss_csname:n,
7007 % \@@_family_use:n,\@@_gset_family_nfss_cs:nn}
7008 % \begin{macrocode}
7009 \cs_new:Npn \@@_family_csname:n #1
7010 { xeCJK/family/#1 }
7011 \cs_new:Npn \@@_family_nfss_csname:n #1
7012 { xeCJK/family/nfss/#1 }
7013 \cs_new_protected:Npn \@@_family_use:n #1
7014 { \use:c { \@@_family_nfss_csname:n {#1} } }
7015 \cs_new_protected:Npn \@@_gset_family_nfss_cs:nn #1#2
7016 {
7017 \prop_gput:Nnn \g_@@_family_name_prop {#1} {#2}
7018 \cs_gset_protected:cpx
7019 { \@@_family_nfss_csname:n {#1} }
7020 { \@@_nfss_family:nn { \c_@@_encoding_tl } {#2} }
7021 }
7022 \cs_generate_variant:Nn \@@_gset_family_nfss_cs:nn { no }
7023 % \end{macrocode}
7024 % \end{macro}
7025 %
7026 % \begin{macro}{\@@_nfss_family:n}
7027 % 用于处理 \LaTeXe\ 2020/02/02 中 \tn{bfseries@rm} 等与 \tn{bfdefault} 不一致可能导致的问题。
7028 % \begin{macrocode}
7029 \cs_if_exist:NTF \fontseriesforce
7030 {
7031 \cs_new_protected:Npn \@@_nfss_family:nn #1#2
7032 {
7033 \fontencoding {#1}
7034 \str_if_eq:eeF { \f@series } { \bfdefault }
7035 {
7036 \str_case_e:nn { \f@family }
7037 {
7038 { \rmdefault } { \@@_nfss_series:n { rm } }
7039 { \sfdefault } { \@@_nfss_series:n { sf } }
7040 { \ttdefault } { \@@_nfss_series:n { tt } }
7041 }
7042 }
7043 \fontfamily {#2}
7044 \selectfont
7045 }
7046 \cs_new_protected:Npn \@@_nfss_series:n #1
7047 {
7048 \str_if_eq:eeT { \f@series } { \use:c { bfseries@#1 } }
7049 { \fontseriesforce { \bfdefault } }
7050 }
7051 }
7052 {
7053 \cs_new_protected:Npn \@@_nfss_family:nn #1#2
7054 {
7055 \fontencoding {#1}
7056 \tl_set:Nn \f@family {#2}
7057 \selectfont
7058 }
7059 }
7060 % \end{macrocode}
7061 % \end{macro}
7062 %
7063 % \begin{macro}[TF,int]{\xeCJK_family_if_exist:n}
7064 % \begin{macrocode}
7065 \prg_new_protected_conditional:Npnn \xeCJK_family_if_exist:n #1 { T , F , TF }
7066 {
7067 \prop_get:NnNTF \g_@@_family_name_prop
7068 {#1} \l_@@_fontspec_family_tl
7069 { \prg_return_true: }
7070 {
7071 \exp_args:Ne \cs_if_exist_use:cTF
7072 { \@@_family_csname:n {#1} }
7073 { \prg_return_true: }
7074 { \prg_return_false: }
7075 }
7076 }
7077 \prg_generate_conditional_variant:Nnn \xeCJK_family_if_exist:n { e } { T , F , TF }
7078 % \end{macrocode}
7079 % \end{macro}
7080 %
7081 % \begin{macro}{\CJKfamily}
7082 % 用于切换 CJK 字体族。
7083 % \begin{macrocode}
7084 \NewDocumentCommand \CJKfamily { t+ t- m }
7085 {
7086 \xeCJK_family:NNe #1 #2 {#3}
7087 \tex_ignorespaces:D
7088 }
7089 \cs_new_protected:Npn \xeCJK_family:NNn #1#2#3
7090 {
7091 \tl_if_blank:nTF {#3}
7092 {
7093 \bool_if:NF #1 { \bool_if:NF #2 { \use_none:nn } }
7094 \xeCJK_family_if_exist_use:e { \l_xeCJK_family_tl }
7095 }
7096 {
7097 \bool_if:NTF #2
7098 { \xeCJK_family_if_exist_use:n {#3} }
7099 {
7100 \xeCJK_family_if_exist:nTF {#3}
7101 {
7102 \tl_set:Nn \l_xeCJK_family_tl {#3}
7103 \tl_set_eq:NN \CJK@family \l_@@_fontspec_family_tl
7104 \bool_if:NT #1 { \@@_family_use:n {#3} }
7105 }
7106 { \@@_family_unknown_warning:n {#3} }
7107 }
7108 }
7109 }
7110 \cs_generate_variant:Nn \xeCJK_family:NNn { NNe }
7111 \cs_new_protected:Npn \xeCJK_switch_family:n #1
7112 {
7113 \xeCJK_family_if_exist:nTF {#1}
7114 {
7115 \tl_set:Nn \l_xeCJK_family_tl {#1}
7116 \tl_set_eq:NN \CJK@family \l_@@_fontspec_family_tl
7117 }
7118 { \@@_family_unknown_warning:n {#1} }
7119 }
7120 \cs_generate_variant:Nn \xeCJK_switch_family:n { e , o }
7121 % \end{macrocode}
7122 % \end{macro}
7123 %
7124 % \changes{v3.6.0}{2018/01/24}{新增 \opt{PunctFamily} 选项支持对汉字标点单独切换字体。}
7125 %
7126 % \begin{macro}{PunctFamily}
7127 % 设置汉字标点符号的字体。
7128 % \begin{macrocode}
7129 \keys_define:nn { xeCJK / options }
7130 {
7131 PunctFamily .choice: ,
7132 PunctFamily .value_required:n = { true } ,
7133 PunctFamily / false .code:n =
7134 {
7135 \tl_set:Nn \CJK@punctfamily { \CJK@family }
7136 \tl_set:Nn \l_xeCJK_punct_family_tl { \l_xeCJK_family_tl }
7137 \xeCJK_cs_clear:N \@@_select_font:
7138 \xeCJK_cs_clear:N \@@_select_punct_font:
7139 \cs_set_eq:NN \xeCJK_select_punct_font: \xeCJK_select_font:
7140 } ,
7141 PunctFamily / unknown .code:n =
7142 { \xeCJK_punct_family:e {#1} } ,
7143 }
7144 \cs_new_protected:Npn \xeCJK_punct_family:n #1
7145 {
7146 \xeCJK_family_if_exist:nTF {#1}
7147 {
7148 \tl_set:Nn \l_xeCJK_punct_family_tl {#1}
7149 \tl_set_eq:NN \CJK@punctfamily \l_@@_fontspec_family_tl
7150 \cs_set_eq:NN \@@_select_font: \xeCJK_select_font:
7151 \cs_set_eq:NN \@@_select_punct_font: \@@_select_punct_font_aux:
7152 \cs_set_eq:NN \xeCJK_select_punct_font: \@@_select_punct_font:
7153 }
7154 { \@@_family_unknown_warning:n {#1} }
7155 }
7156 \cs_generate_variant:Nn \xeCJK_punct_family:n { e }
7157 % \end{macrocode}
7158 % \end{macro}
7159 %
7160 % \begin{variable}[int]{\l_xeCJK_family_tl}
7161 % 用于保存文档当前正在使用的 CJK 字体族。
7162 % \changes{v3.2.0}{2013/04/14}{不将其初始化为 \tn{CJKfamilydefault}。}
7163 % \begin{macrocode}
7164 \tl_new:N \l_xeCJK_family_tl
7165 % \end{macrocode}
7166 % \end{variable}
7167 %
7168 % \begin{variable}{\CJK@family}
7169 % 用于保存实际的字体族名称。
7170 % \changes{v3.2.11}{2014/03/29}{引入 \tn{CJK@family} 保存实际的字体族名。}
7171 % \begin{macrocode}
7172 \tl_new:N \CJK@family
7173 % \end{macrocode}
7174 % \end{variable}
7175 %
7176 % \begin{macro}{\@@_gobble_CJKfamily:}
7177 % \begin{macrocode}
7178 \cs_new_protected:Npn \@@_gobble_CJKfamily:
7179 { \cs_set_eq:NN \CJKfamily \@@_gobble_CJKfamily:wn }
7180 \NewExpandableDocumentCommand \@@_gobble_CJKfamily:wn { t+ t- m } { }
7181 % \end{macrocode}
7182 % \end{macro}
7183 %
7184 % \begin{macro}[int]{\xeCJK_family_if_exist_use:n}
7185 % \begin{macrocode}
7186 \cs_new_protected:Npn \xeCJK_family_if_exist_use:n #1
7187 {
7188 \xeCJK_family_if_exist:nTF {#1}
7189 { \@@_family_use:n {#1} }
7190 { \@@_family_unknown_warning:n {#1} }
7191 }
7192 \cs_generate_variant:Nn \xeCJK_family_if_exist_use:n { e }
7193 % \end{macrocode}
7194 % \end{macro}
7195 %
7196 % \begin{macro}{\@@_family_unknown_warning:n}
7197 % \changes{v3.1.2}{2013/01/01}
7198 % {在没有定义任何 CJK 字体的情况下,不再重复给出字体没有定义的警告。}
7199 % \begin{macrocode}
7200 \cs_new_protected:Npn \@@_family_unknown_warning:n #1
7201 {
7202 \prop_if_empty:NF \g_@@_family_font_name_prop
7203 {
7204 \seq_if_in:NnF \g_@@_unknown_family_seq {#1}
7205 {
7206 \seq_gput_right:Nn \g_@@_unknown_family_seq {#1}
7207 \@@_warning:nx { CJKfamily-Unknown } {#1}
7208 }
7209 }
7210 }
7211 \seq_new:N \g_@@_unknown_family_seq
7212 \@@_msg_new:nn { CJKfamily-Unknown }
7213 {
7214 Unknown~CJK~family~`\@@_msg_family_map:n {#1}'~is~being~ignored.\\\\
7215 Try~to~use~`\@@_msg_def_family_map:n {#1}'~to~define~it.
7216 }
7217 \cs_new:Npn \@@_msg_def_family_map:n #1
7218 {
7219 \str_case_e:nnF {#1}
7220 {
7221 \CJKrmdefault { \token_to_str:N \setCJKmainfont }
7222 \CJKsfdefault { \token_to_str:N \setCJKsansfont }
7223 \CJKttdefault { \token_to_str:N \setCJKmonofont }
7224 }
7225 { \token_to_str:N \setCJKfamilyfont \{ #1 \} }
7226 [<...>]\{<...>\}
7227 }
7228 \cs_new:Npn \@@_msg_family_map:n #1
7229 {
7230 \str_case_e:nnF {#1}
7231 {
7232 \CJKrmdefault { \token_to_str:N \CJKrmdefault }
7233 \CJKsfdefault { \token_to_str:N \CJKsfdefault }
7234 \CJKttdefault { \token_to_str:N \CJKttdefault }
7235 }
7236 {#1}
7237 }
7238 % \end{macrocode}
7239 % \end{macro}
7240 %
7241 % \begin{macro}{\@@_pass_args:nnnn}
7242 % 为了支持字体属性可选项在前在后两种语法,给出两个辅助工具,类似
7243 % \package{fontspec} 的实现。自带展开功能,额外参数 |#4| 用于后处理。
7244 % \begin{macrocode}
7245 \cs_new_protected:Npn \@@_pass_args:nnnn #1#2#3#4
7246 {
7247 \tl_if_novalue:nTF {#2}
7248 { \@@_post_arg:w {#1} {#3} {#4} }
7249 {
7250 \use:e { #1 {#2} {#3} }
7251 #4
7252 }
7253 }
7254 \NewDocumentCommand \@@_post_arg:w { m m m O { } }
7255 {
7256 \use:e { #1 {#4} {#2} }
7257 #3
7258 }
7259 % \end{macrocode}
7260 % \end{macro}
7261 %
7262 % \begin{macro}{\setCJKmainfont,\setCJKsansfont,\setCJKmonofont}
7263 % 设置文档的 CJK 普通字体、无衬线和等宽字体。
7264 % \changes{v3.2.0}{2013/04/14}{定义中加入 \tn{normalfont}。}
7265 % \changes{v3.4.3}{2016/11/18}{允许字体属性可选项在后的新语法。}
7266 % \begin{macrocode}
7267 \NewDocumentCommand \setCJKmainfont { o m }
7268 {
7269 \@@_pass_args:nnnn
7270 { \xeCJK_set_family:nnn { \CJKrmdefault } } {#1} {#2}
7271 { \@@_preamble_family:n { \CJKrmdefault } }
7272 }
7273 \cs_new_eq:NN \setCJKromanfont \setCJKmainfont
7274 \NewDocumentCommand \setCJKsansfont { o m }
7275 {
7276 \@@_pass_args:nnnn
7277 { \xeCJK_set_family:nnn { \CJKsfdefault } } {#1} {#2}
7278 { \@@_preamble_family:n { \CJKsfdefault } }
7279 }
7280 \NewDocumentCommand \setCJKmonofont { o m }
7281 {
7282 \@@_pass_args:nnnn
7283 { \xeCJK_set_family:nnn { \CJKttdefault } } {#1} {#2}
7284 { \@@_preamble_family:n { \CJKttdefault } }
7285 }
7286 % \end{macrocode}
7287 % \end{macro}
7288 %
7289 % \begin{macrocode}
7290 \@onlypreamble \setCJKmainfont
7291 \@onlypreamble \setCJKmathfont
7292 \@onlypreamble \setCJKsansfont
7293 \@onlypreamble \setCJKmonofont
7294 \@onlypreamble \setCJKromanfont
7295 % \end{macrocode}
7296 %
7297 % \changes{v3.8.2}{2020/02/17}{避免导言区字体警告。}
7298 %
7299 % \begin{macro}{\@@_preamble_family:n}
7300 % 用在 \tn{setCJKmainfont} 等主要命令之后,确保导言区有 CJK 字体可用。
7301 % \begin{macrocode}
7302 \cs_new_protected:Npn \@@_preamble_family:n #1
7303 { \str_if_eq:eeT {#1} { \CJKfamilydefault } { \normalfont } }
7304 % \end{macrocode}
7305 % \end{macro}
7306 %
7307 % \begin{macro}{\setCJKfamilyfont, \newCJKfontfamily, \CJKfontspec}
7308 % \changes{v3.4.3}{2016/11/18}{允许字体属性可选项在后的新语法。}
7309 % 分别用于预声明 CJK 字体族和声明并马上调用 CJK 字体族。
7310 % \begin{macrocode}
7311 \NewDocumentCommand \setCJKfamilyfont { m o m }
7312 {
7313 \@@_pass_args:nnnn
7314 { \xeCJK_set_family:nnn {#1} } {#2} {#3}
7315 { }
7316 }
7317 \NewDocumentCommand \newCJKfontfamily { o m o m }
7318 {
7319 \tl_set:Nx \l_@@_tmp_tl
7320 { \tl_if_novalue:nTF {#1} { \cs_to_str:N #2 } {#1} }
7321 \cs_new_protected:Npx #2
7322 { \xeCJK_switch_family:n { \l_@@_tmp_tl } }
7323 \@@_pass_args:nnnn
7324 { \xeCJK_set_family:nnn { \l_@@_tmp_tl } } {#3} {#4}
7325 { }
7326 }
7327 \NewDocumentCommand \CJKfontspec { o m }
7328 {
7329 \@@_pass_args:nnnn
7330 { \xeCJK_fontspec:nn } {#1} {#2}
7331 { \tex_ignorespaces:D }
7332 }
7333 % \end{macrocode}
7334 % \end{macro}
7335 %
7336 % \begin{macro}[int]{\xeCJK_fontspec:nn}
7337 % \begin{macrocode}
7338 \cs_new_protected:Npn \xeCJK_fontspec:nn #1#2
7339 {
7340 \prop_get:NnNTF \g_@@_fontspec_prop
7341 { CJKfontspec/#1/#2/id } \l_xeCJK_family_tl
7342 { \xeCJK_switch_family:o { \l_xeCJK_family_tl } }
7343 {
7344 \@@_fontspec:enn
7345 { CJKfontspec ( \int_eval:n { \g_@@_family_int + 1 } ) }
7346 {#1} {#2}
7347 }
7348 }
7349 \cs_new_protected:Npn \@@_fontspec:nnn #1#2#3
7350 {
7351 \prop_gput:Nnn \g_@@_fontspec_prop { CJKfontspec/#2/#3/id } {#1}
7352 \xeCJK_set_family:nnn {#1} {#2} {#3}
7353 \xeCJK_switch_family:n {#1}
7354 }
7355 \cs_generate_variant:Nn \xeCJK_fontspec:nn { oo }
7356 \cs_generate_variant:Nn \@@_fontspec:nnn { e }
7357 \prop_new:N \g_@@_fontspec_prop
7358 % \end{macrocode}
7359 % \end{macro}
7360 %
7361 % \begin{macro}{\defaultCJKfontfeatures, \addCJKfontfeatures}
7362 % \changes{v3.2.4}{2013/06/30}{可以单独增加当前各个分区字体的属性。}
7363 % 分别用于设置 CJK 字体的默认属性和增加当前 CJK 字体的属性。
7364 % \begin{macrocode}
7365 \clist_new:N \g_@@_default_features_clist
7366 \NewDocumentCommand \defaultCJKfontfeatures { m }
7367 { \clist_gset:Nn \g_@@_default_features_clist {#1} }
7368 \@onlypreamble \defaultCJKfontfeatures
7369 \NewDocumentCommand \addCJKfontfeatures { s O { } m }
7370 {
7371 \xeCJK_add_font_features:Nee #1 {#2} {#3}
7372 \tex_ignorespaces:D
7373 }
7374 \cs_new_eq:NN \addCJKfontfeature \addCJKfontfeatures
7375 % \end{macrocode}
7376 % \end{macro}
7377 %
7378 % \begin{macro}[int]{\xeCJK_add_font_features:Nnn}
7379 % \begin{macrocode}
7380 \cs_new_protected:Npn \xeCJK_add_font_features:Nnn #1#2#3
7381 {
7382 \prop_get:NoNTF \g_@@_family_font_name_prop
7383 \l_xeCJK_family_tl \l_@@_font_name_tl
7384 {
7385 \clist_set:Nn \l_@@_add_font_features_clist {#3}
7386 \seq_map_inline:Nn \g_@@_sub_key_seq
7387 { \clist_remove_all:Nn \l_@@_add_font_features_clist {##1} }
7388 \seq_clear:N \l_@@_sub_key_seq
7389 \clist_clear:N \l_@@_add_block_features_clist
7390 \clist_map_function:nN {#2} \@@_add_sub_features:n
7391 \bool_lazy_and:nnT
7392 {#1}
7393 { \seq_if_empty_p:N \l_@@_sub_key_seq }
7394 {
7395 \seq_map_function:NN
7396 \g_@@_sub_key_seq \@@_add_sub_class_features:n
7397 }
7398 \prop_get:NoNT \g_@@_family_font_options_prop
7399 \l_xeCJK_family_tl \l_@@_font_options_clist
7400 {
7401 \bool_lazy_or:nnT
7402 { \seq_if_empty_p:N \l_@@_sub_key_seq }
7403 {#1}
7404 {
7405 \clist_concat:NNN \l_@@_font_options_clist
7406 \l_@@_font_options_clist \l_@@_add_font_features_clist
7407 }
7408 \clist_concat:NNN \l_@@_font_options_clist
7409 \l_@@_font_options_clist \l_@@_add_block_features_clist
7410 }
7411 \xeCJK_fontspec:oo \l_@@_font_options_clist \l_@@_font_name_tl
7412 }
7413 { \@@_warning:n { addCJKfontfeature-ignored } }
7414 }
7415 \cs_new_protected:Npn \@@_add_sub_features:n #1
7416 {
7417 \seq_if_in:NnTF \g_@@_sub_key_seq {#1}
7418 {
7419 \seq_put_right:Nn \l_@@_sub_key_seq {#1}
7420 \@@_add_sub_class_features:n {#1}
7421 }
7422 { \@@_warning:nx { SubBlock-undefined } {#1} }
7423 }
7424 \clist_new:N \l_@@_add_font_features_clist
7425 \clist_new:N \l_@@_add_block_features_clist
7426 \cs_generate_variant:Nn \xeCJK_add_font_features:Nnn { Nee , Nne }
7427 \@@_msg_new:nn { addCJKfontfeature-ignored }
7428 {
7429 \token_to_str:N \addCJKfontfeature (s)~ignored.\\\\
7430 It~cannot~be~used~with~a~font~that~wasn't~selected~by~xeCJK.
7431 }
7432 % \end{macrocode}
7433 % \end{macro}
7434 %
7435 % \begin{macro}{\@@_add_sub_class_features:n}
7436 % \begin{macrocode}
7437 \cs_new_protected:Npn \@@_add_sub_class_features:n #1
7438 {
7439 \prop_get:NoNTF \g_@@_family_font_name_prop
7440 { \l_xeCJK_family_tl/#1 } \l_@@_sub_font_name_tl
7441 {
7442 \prop_get:NoN \g_@@_family_font_options_prop
7443 { \l_xeCJK_family_tl/#1 } \l_@@_sub_font_options_clist
7444 }
7445 {
7446 \prop_get:NeNTF \g_@@_family_font_name_prop
7447 { \CJKfamilydefault/#1 } \l_@@_sub_font_name_tl
7448 {
7449 \prop_get:NeN \g_@@_family_font_options_prop
7450 { \CJKfamilydefault/#1 } \l_@@_sub_font_options_clist
7451 }
7452 {
7453 \prop_get:NoN \g_@@_family_font_options_prop
7454 \l_xeCJK_family_tl \l_@@_sub_font_options_clist
7455 \tl_set_eq:NN \l_@@_sub_font_name_tl \l_@@_font_name_tl
7456 }
7457 }
7458 \clist_concat:NNN \l_@@_sub_font_options_clist
7459 \l_@@_sub_font_options_clist \l_@@_add_font_features_clist
7460 \clist_put_right:Nx \l_@@_add_block_features_clist
7461 {
7462 #1 =
7463 {
7464 [ \exp_not:o \l_@@_sub_font_options_clist ]
7465 { \exp_not:o \l_@@_sub_font_name_tl }
7466 }
7467 }
7468 }
7469 \cs_generate_variant:Nn \prop_get:NnN { Ne }
7470 \prg_generate_conditional_variant:Nnn \prop_get:NnN { Ne } { T , TF }
7471 % \end{macrocode}
7472 % \end{macro}
7473 %
7474 % \begin{macro}{LoadFandol}
7475 % \changes{v3.2.10}{2014/03/01}{当没有设置字体时,使用 Fandol 字体系列。}
7476 % \changes{v3.3.1}{2015/04/08}{为方便 MacTeX 用户,Fandol 字体改用文件名。}
7477 % \begin{macrocode}
7478 \keys_define:nn { xeCJK / options }
7479 { LoadFandol .bool_gset:N = \g_@@_fandol_bool }
7480 \cs_new_protected:Npn \@@_load_fandol:
7481 {
7482 \xeCJK_set_family:enn { \CJKrmdefault }
7483 { Extension = .otf , BoldFont = FandolSong-Bold , ItalicFont = FandolKai-Regular }
7484 { FandolSong-Regular }
7485 \xeCJK_set_family:enn { \CJKsfdefault }
7486 { Extension = .otf , BoldFont = FandolHei-Bold } { FandolHei-Regular }
7487 \xeCJK_set_family:enn { \CJKttdefault }
7488 { Extension = .otf } { FandolFang-Regular }
7489 }
7490 % \end{macrocode}
7491 % \end{macro}
7492 %
7493 % \changes{v3.1.2}{2013/01/01}{修正重定义 \tn{CJKfamilydefault} 无效的问题,恢复容错能力。}
7494 % \changes{v3.2.13}{2014/06/02}{自动调整 \tn{CJKfamilydefault} 时,只将 \tn{familydefault} 展开一次。}
7495 %
7496 % 在导言区结束的时候,若没有声明 CJK 字体,则给出一个警告。如果 \tn{CJKfamilydefault}
7497 % 没有被更改,则在此时根据西文字体的情况更新 \tn{CJKfamilydefault}。
7498 % 如果 \tn{CJKfamilydefault} 对应的字体族没有定义,则使用 \tn{CJKrmdefault} 作为
7499 % 默认字体族。若 \tn{CJKrmdefault} 也没有定义,则使用在导言区设置的第一个 CJK 字体
7500 % 作为默认字体族。最后设置数学字体。
7501 % \begin{macrocode}
7502 \@@_at_end_preamble:n
7503 {
7504 \tl_if_eq:NNT \CJKfamilydefault \l_@@_family_default_init_tl
7505 {
7506 \group_begin:
7507 \cs_set_eq:NN \@@_family_default_wrap:n \exp_not:n
7508 \tl_gset:Nx \CJKfamilydefault
7509 {
7510 \str_case:onF { \familydefault }
7511 {
7512 { \rmdefault } { \exp_not:N \CJKrmdefault }
7513 { \sfdefault } { \exp_not:N \CJKsfdefault }
7514 { \ttdefault } { \exp_not:N \CJKttdefault }
7515 }
7516 { \CJKfamilydefault }
7517 }
7518 \group_end:
7519 }
7520 \prop_if_empty:NTF \g_@@_family_font_name_prop
7521 {
7522 \bool_if:NTF \g_@@_fandol_bool
7523 {
7524 \@@_warning:n { fandol }
7525 \@@_load_fandol:
7526 \xeCJK_ensure_default_family:
7527 }
7528 { \@@_warning:nx { no-CJKfamily } { \CJKfamilydefault } }
7529 }
7530 { \xeCJK_ensure_default_family: }
7531 }
7532 \cs_new_protected:Npn \xeCJK_ensure_default_family:
7533 {
7534 \xeCJK_family_if_exist:eF { \CJKfamilydefault }
7535 {
7536 \tl_set_eq:NN \l_@@_tmp_tl \CJKfamilydefault
7537 \str_if_eq:eeTF { \CJKfamilydefault } { \CJKrmdefault }
7538 { \use:n }
7539 {
7540 \xeCJK_family_if_exist:eTF { \CJKrmdefault }
7541 { \tl_gset:Nn \CJKfamilydefault { \CJKrmdefault } }
7542 }
7543 {
7544 \prop_map_inline:Nn \g_@@_family_font_name_prop
7545 {
7546 \prop_map_break:n
7547 { \tl_gset_rescan:Nnn \CJKfamilydefault { } { ##1 } }
7548 }
7549 }
7550 \@@_warning:nxx { CJKfamilydefault-undefined }
7551 { \l_@@_tmp_tl } { \CJKfamilydefault }
7552 }
7553 \xeCJK_switch_family:e { \CJKfamilydefault }
7554 \bool_if:NT \g_@@_math_bool { \xeCJK_set_mathfont: }
7555 }
7556 \@@_msg_new:nn { no-CJKfamily }
7557 {
7558 It~seems~that~you~have~not~declare~a~CJKfamily.\\
7559 If~you~want~to~use~xeCJK~in~the~right~way,~you~should~use\\\\
7560 `\@@_msg_def_family_map:n {#1}'\\\\
7561 in~the~preamble~to~declare~the~default~CJKfamily.\\
7562 }
7563 \@@_msg_new:nn { CJKfamilydefault-undefined }
7564 {
7565 Undefined~CJK~default~family~`\@@_msg_family_map:n {#1}'~
7566 has~been~replaced~by~`\@@_msg_family_map:n {#2}'.\\\\
7567 Try~to~use~`\@@_msg_def_family_map:n {#1}'~to~define~it.
7568 }
7569 \@@_msg_new:nn { fandol }
7570 {
7571 Fandol~is~being~set~as~the~default~font~for~CJK~text.\\
7572 Please~make~sure~it~has~been~properly~installed.
7573 }
7574 % \end{macrocode}
7575 %
7576 % \subsection{数学字体设置}
7577 %
7578 % \begin{macro}{CJKmath}
7579 % 是否启用 CJK 数学字体的宏包选项。
7580 % \begin{macrocode}
7581 \keys_define:nn { xeCJK / options } { CJKmath .bool_gset:N = \g_@@_math_bool }
7582 % \end{macrocode}
7583 % \end{macro}
7584 %
7585 % \begin{macro}{\setCJKmathfont}
7586 % \changes{v3.4.3}{2016/11/18}{允许字体属性可选项在后的新语法。}
7587 % 设置 CJK 数学字体。
7588 % \begin{macrocode}
7589 \NewDocumentCommand \setCJKmathfont { o m }
7590 {
7591 \@@_pass_args:nnnn
7592 { \xeCJK_set_family:nnn { \c_@@_math_tl } } {#1} {#2}
7593 { }
7594 }
7595 \tl_const:Nn \c_@@_math_tl { CJKmath }
7596 % \end{macrocode}
7597 % \end{macro}
7598 %
7599 % \begin{macro}[int]{\xeCJK_set_mathfont:}
7600 % \changes{v3.2.6}{2013/08/01}{设置粗体时先检查对应字体是否存在。}
7601 % \changes{v3.2.7}{2013/11/09}{将 CJK 字符的数学归类由 $7$ 改为 $0$,解决汉字路径的问题。}
7602 % \changes{v3.2.13}{2014/06/20}{修复参数类型错误。}
7603 % \changes{v3.4.0}{2016/05/01}{CJKmath 的字符范围遵从 \tn{xeCJKDeclareCharClass} 的设置。}
7604 % 当没有设置 CJK 数学字体时,使用 \tn{CJKfamilydefault} 作为数学字体。
7605 % \begin{macrocode}
7606 \cs_new_protected:Npn \xeCJK_set_mathfont:
7607 {
7608 \cs_if_exist_use:N \@@_save_um_char:
7609 \xeCJK_family_if_exist:eTF { \c_@@_math_tl }
7610 { \@@_set_mathfont_aux: }
7611 {
7612 \xeCJK_family_if_exist:eT { \CJKfamilydefault }
7613 {
7614 \@@_copy_family:ee { \c_@@_math_tl } { \CJKfamilydefault }
7615 \@@_set_mathfont_aux:
7616 }
7617 }
7618 \cs_if_exist_use:N \@@_restore_um_char:
7619 }
7620 \cs_new_protected:Npn \@@_set_mathfont_aux:
7621 {
7622 \tl_const:Nx \c_@@_math_family_tl
7623 { \l_@@_fontspec_family_tl }
7624 \xeCJK_declare_mathfont:ee
7625 { \c_@@_math_tl }
7626 { \c_@@_math_family_tl }
7627 \int_const:Nn \c_xeCJK_math_fam_int
7628 { \use:c { sym \c_@@_math_tl } }
7629 \clist_gconcat:NNN \g_@@_math_chars_clist
7630 \g_@@_CJK_range_clist \g_@@_FullLeft_range_clist
7631 \clist_gconcat:NNN \g_@@_math_chars_clist
7632 \g_@@_math_chars_clist \g_@@_FullRight_range_clist
7633 \xeCJK_gset_mathcode:Nn \g_@@_math_chars_clist
7634 { \c_xeCJK_math_fam_int }
7635 \xeCJK_set_mathfont_block:
7636 }
7637 \clist_new:N \g_@@_math_chars_clist
7638 \prop_new:N \g_@@_fam_prop
7639 % \end{macrocode}
7640 % \end{macro}
7641 %
7642 % \changes{v3.4.0}{2016/05/04}{CJKmath 功能也支持分区字体。}
7643 %
7644 % \begin{macro}[int]{\xeCJK_set_mathfont_block:}
7645 % 分区数学字体。
7646 % \begin{macrocode}
7647 \cs_new_protected:Npn \xeCJK_set_mathfont_block:
7648 {
7649 \seq_if_empty:NF \g_@@_CJK_sub_class_seq
7650 {
7651 \seq_map_function:NN
7652 \g_@@_CJK_sub_class_seq
7653 \xeCJK_set_mathfont_block:n
7654 }
7655 }
7656 \cs_new_protected:Npn \xeCJK_set_mathfont_block:n #1
7657 {
7658 \xeCJK_block_family:nn { \c_@@_math_tl } {#1}
7659 \prop_get:NoNTF \g_@@_fam_prop
7660 \l_@@_fontspec_family_tl \l_@@_tmp_tl
7661 { \int_set:Nn \l_@@_fam_int { \l_@@_tmp_tl } }
7662 {
7663 \xeCJK_declare_mathfont:ee
7664 { \c_@@_math_tl / #1 }
7665 { \l_@@_fontspec_family_tl }
7666 \@@_set_mathfont_block_aux:cn
7667 { sym \c_@@_math_tl / #1 } {#1}
7668 }
7669 \xeCJK_gset_mathcode:cn { g_@@_CJK/#1_range_clist } { \l_@@_fam_int }
7670 }
7671 \cs_new_protected:Npn \@@_set_mathfont_block_aux:Nn #1#2
7672 {
7673 \int_set_eq:NN \l_@@_fam_int #1
7674 \prop_gput:Nnn \g_@@_block_fam_prop {#2} {#1}
7675 }
7676 \int_new:N \l_@@_fam_int
7677 \prop_new:N \g_@@_block_fam_prop
7678 \cs_generate_variant:Nn \@@_set_mathfont_block_aux:Nn { c }
7679 % \end{macrocode}
7680 % \end{macro}
7681 %
7682 % \changes{v3.8.1}{2020/02/14}{应用 \tn{shapedefault}。}
7683 %
7684 % \begin{macro}[int]{\xeCJK_declare_mathfont:nn}
7685 % 注意从 \LaTeXe\ 2020/02/02 开始,\tn{shapedefault} 初始值是 \texttt{n},
7686 % 而 \tn{updefault} 初始值是 \texttt{up},两者并不一致。
7687 % \pkg{fontspec} 包定义字体使用的是 \tn{shapedefault}。
7688 % \begin{macrocode}
7689 \cs_new_protected:Npn \xeCJK_declare_mathfont:nn #1#2
7690 {
7691 \xeCJK_declare_symbol_font:nnnnn {#1} { \c_@@_encoding_tl }
7692 {#2} { \mddefault } { \shapedefault }
7693 \cs_if_free:cF
7694 { \c_@@_encoding_tl/#2/\bfdefault/\shapedefault }
7695 {
7696 \SetSymbolFont {#1} { bold } { \c_@@_encoding_tl }
7697 {#2} { \bfdefault } { \shapedefault }
7698 }
7699 \prop_gput:Nne \g_@@_fam_prop {#2} { \exp_not:c { sym #1 } }
7700 }
7701 \cs_generate_variant:Nn \prop_put:Nnn { Nne }
7702 \cs_generate_variant:Nn \prop_gput:Nnn { Nne }
7703 \cs_generate_variant:Nn \xeCJK_declare_mathfont:nn { ee }
7704 % \end{macrocode}
7705 % \end{macro}
7706 %
7707 % \begin{macro}[int]{\xeCJK_declare_symbol_font:nnnnn}
7708 % 主要功能同 \tn{DeclareSymbolFont},不带编码和重复定义检查。
7709 % \begin{macrocode}
7710 \cs_new_protected:Npn \xeCJK_declare_symbol_font:nnnnn #1
7711 { \@@_declare_symbol_font:cnnnn { sym #1 } }
7712 \cs_new_protected:Npn \@@_declare_symbol_font:Nnnnn #1
7713 {
7714 \xeCJK_new_fam:N #1
7715 \xeCJK_new_symbol_font:Nnnnn #1
7716 }
7717 \cs_generate_variant:Nn \@@_declare_symbol_font:Nnnnn { c }
7718 % \end{macrocode}
7719 % \end{macro}
7720 %
7721 % \begin{macro}[int]{\xeCJK_new_fam:N}
7722 % 我们从 $255$ 往下分配 \tn{fam},|\count18| 是 \LaTeXe{} 记录最后分配的 \tn{fam} 编号,
7723 % 作为我们的分配器的下限。事实上,还应该相应地减小 \tn{e@mathgroup@top} 才合理,但这可能会有不利影响,
7724 % 我们暂未处理。
7725 % \begin{macrocode}
7726 \cs_new_protected:Npn \xeCJK_new_fam:N #1
7727 {
7728 \int_compare:nNnTF
7729 { \g_@@_fam_allocation_int } > { \g_@@_fam_bottom_int }
7730 {
7731 \int_set_eq:NN \allocationnumber \g_@@_fam_allocation_int
7732 \int_const:Nn #1 { \allocationnumber }
7733 \iow_log:x
7734 {
7735 \token_to_str:N #1 =
7736 \token_to_str:N \mathgroup \int_use:N \allocationnumber
7737 }
7738 \int_gdecr:N \g_@@_fam_allocation_int
7739 }
7740 { \@@_error:n { fam-exhausted } }
7741 }
7742 \tex_countdef:D \g_@@_fam_bottom_int = 18 ~
7743 \int_new:N \g_@@_fam_allocation_int
7744 \int_gset:Nn \g_@@_fam_allocation_int { 255 }
7745 \@@_msg_new:nn { fam-exhausted }
7746 { No~room~for~a~new~fam. }
7747 % \end{macrocode}
7748 % \end{macro}
7749 %
7750 % \begin{macro}[int]{\xeCJK_new_symbol_font:Nnnnn}
7751 % \begin{macro}{\@@_new_symbol_font:NN}
7752 % 功能同 \tn{new@symbolfont},但我们不增加 \tn{c@mv@normal} 和 \tn{c@mv@bold} 之类的计数器。
7753 % \begin{macrocode}
7754 \cs_new_protected:Npn \xeCJK_new_symbol_font:Nnnnn #1#2#3#4#5
7755 { \@@_new_symbol_font:Nc #1 { #2/#3/#4/#5 } }
7756 \cs_new_protected:Npn \@@_new_symbol_font:NN #1#2
7757 {
7758 \tl_put_right:Nn \group@list { \group@elt #1 #2 }
7759 \cs_set:Npn \version@elt ##1
7760 { \tl_put_right:Nn ##1 { \getanddefine@fonts #1 #2 } }
7761 \version@list
7762 }
7763 \cs_generate_variant:Nn \@@_new_symbol_font:NN { Nc }
7764 % \end{macrocode}
7765 % \end{macro}
7766 % \end{macro}
7767 %
7768 % \begin{macro}[int]{\xeCJK_gset_mathcode:Nn,
7769 % \xeCJK_gset_mathcode:Nnn,\xeCJK_gset_mathcode:nnnn}
7770 % CJK 字符的数学类别固定为 $0$(\tn{mathord})。
7771 % \begin{macrocode}
7772 \cs_new_protected:Npn \xeCJK_gset_mathcode:Nn #1#2
7773 {
7774 \clist_map_inline:Nn #1
7775 {
7776 \@@_set_char_class_aux:Nnw \xeCJK_gset_mathcode:nnnn { ##1 }
7777 { 0 } {#2}
7778 }
7779 }
7780 \cs_generate_variant:Nn \xeCJK_gset_mathcode:Nn { c }
7781 \cs_new_protected:Npn \xeCJK_gset_mathcode:nnnn #1#2#3#4
7782 {
7783 \@@_check_num_range:nnNN {#1} {#2} \l_@@_begin_int \l_@@_end_int
7784 \xeCJK_int_until_do:nn { \l_@@_begin_int > \l_@@_end_int }
7785 {
7786 \xeCJK_gset_mathcode:Nnn \l_@@_begin_int {#3} {#4}
7787 \int_incr:N \l_@@_begin_int
7788 }
7789 }
7790 \cs_new_protected:Npn \xeCJK_gset_mathcode:Nnn #1#2#3
7791 { \tex_global:D \tex_Umathcode:D #1 = #2 ~ #3 ~ #1 }
7792 % \end{macrocode}
7793 % \end{macro}
7794 %
7795 %
7796 % \subsection{抄录环境中的间距调整}
7797 %
7798 % \changes{v3.1.0}{2012/11/19}{放弃使用放缩字体大小的方式,而只采用调整间距的方式
7799 % 与西文等宽字体对齐。并且只适用于与抄录环境下。}
7800 % \changes{v3.2.0}{2013/04/15}{增加 \texttt{Verb} 选项。}
7801 % \changes{v3.2.1}{2013/05/29}{调整 \texttt{Verb} 选项:在命令 \tn{verb} 里使用时,
7802 % 不破坏标点禁则,增加值 \texttt{env+}。}
7803 %
7804 % \begin{macro}{Verb}
7805 % \changes{v3.2.5}{2013/07/25}{微调定义。}
7806 % 如果设置为 \texttt{env},则只在 \LaTeX 的抄录环境里使用 \tn{xeCJKVerbAddon},^^A
7807 % 而不包括 \tn{verb}。对当前使用环境的判断基于在标准 \LaTeX 的坏境定义里使用
7808 % \tn{begingroup} 和 \tn{endgroup} 来分组。
7809 % \begin{macrocode}
7810 \int_new:N \l_@@_verb_case_int
7811 \keys_define:nn { xeCJK / options }
7812 {
7813 Verb .choices:nn =
7814 { true , env+ , env , false }
7815 { \int_set_eq:NN \l_@@_verb_case_int \l_keys_choice_int } ,
7816 Verb .default:n = { env }
7817 }
7818 \cs_new_protected:Npn \@@_verb_font_hook:
7819 {
7820 \if_case:w \l_@@_verb_case_int
7821 \or:
7822 \@@_nobreak_skip_zero:
7823 \or:
7824 \int_compare:nNnTF \tex_currentgrouptype:D = { 14 }
7825 { \xeCJKVerbAddon }
7826 { \@@_nobreak_skip: }
7827 \or:
7828 \int_compare:nNnTF \tex_currentgrouptype:D = { 14 }
7829 { \xeCJKVerbAddon }
7830 { \@@_nobreak_skip_zero: }
7831 \fi:
7832 }
7833 \@@_after_preamble:n
7834 {
7835 \cs_set_protected:Npx \verbatim@font
7836 { \exp_not:o { \verbatim@font } \@@_verb_font_hook: }
7837 }
7838 % \end{macrocode}
7839 % \end{macro}
7840 %
7841 % \begin{macro}{\@@_nobreak_skip_zero:,\@@_nobreak_skip:}
7842 % \changes{v3.2.8}{2013/11/16}{禁止在 \tn{verb} 中断行。}
7843 % \begin{macrocode}
7844 \cs_new_protected:Npn \@@_nobreak_skip_zero:
7845 {
7846 \@@_reset_shipout_skip:
7847 \cs_set_eq:NN \@@_shipout_check_for_glue: \xeCJK_check_for_glue:
7848 \cs_set_eq:NN \@@_shipout_boundary:w \xeCJK_CJK_and_Boundary:w
7849 \tl_put_right:Nn \l_@@_reset_shipout_skip_hook_tl
7850 {
7851 \cs_set_eq:NN \xeCJK_check_for_glue: \@@_shipout_check_for_glue:
7852 \cs_set_eq:NN \xeCJK_CJK_and_Boundary:w \@@_shipout_boundary:w
7853 }
7854 \xeCJK_cs_clear:N \CJKglue
7855 \xeCJK_cs_clear:N \CJKecglue
7856 \xeCJK_cs_clear:N \xeCJK_check_for_glue:
7857 \cs_set_eq:NN \xeCJK_CJK_and_Boundary:w \xeCJK_class_group_end:
7858 \cs_set_eq:NN \@@_punct_hskip:n \@@_nobreak_hskip:n
7859 \cs_set_eq:NN \@@_punct_breakable_kern:n \@@_nobreak_hskip:n
7860 }
7861 \cs_new_protected:Npn \@@_nobreak_skip:
7862 {
7863 \@@_reset_shipout_skip:
7864 \xeCJK_glue_to_skip:nN { \CJKglue } \l_@@_ccglue_skip
7865 \skip_if_eq:nnTF { \l_@@_ccglue_skip } { \c_zero_skip }
7866 { \xeCJK_cs_clear:N \CJKglue }
7867 { \cs_set_eq:NN \CJKglue \@@_nobreak_ccglue: }
7868 \xeCJK_glue_to_skip:nN { \CJKecglue } \l_@@_ecglue_skip
7869 \skip_if_eq:nnTF { \l_@@_ecglue_skip } { \c_zero_skip }
7870 { \xeCJK_cs_clear:N \CJKecglue }
7871 { \cs_set_eq:NN \CJKecglue \@@_nobreak_ecglue: }
7872 \cs_set_eq:NN \@@_punct_hskip:n \@@_nobreak_hskip:n
7873 \cs_set_eq:NN \@@_punct_breakable_kern:n \@@_nobreak_hskip:n
7874 }
7875 \cs_new_protected:Npn \@@_nobreak_ccglue:
7876 { \xeCJK_no_break: \skip_horizontal:N \l_@@_ccglue_skip }
7877 \cs_new_protected:Npn \@@_nobreak_ecglue:
7878 { \xeCJK_no_break: \skip_horizontal:N \l_@@_ecglue_skip }
7879 % \end{macrocode}
7880 % \end{macro}
7881 %
7882 % \begin{macro}{\@@_reset_shipout_skip:}
7883 % \begin{macrocode}
7884 \cs_new_protected:Npn \@@_reset_shipout_skip:
7885 {
7886 \cs_set_eq:NN \@@_shipout_CJKglue: \CJKglue
7887 \cs_set_eq:NN \@@_shipout_CJKecglue: \CJKecglue
7888 \cs_set_eq:NN \@@_shipout_punct_hskip:n \@@_punct_hskip:n
7889 \cs_set_eq:NN
7890 \@@_shipout_punct_breakable_kern:n \@@_punct_breakable_kern:n
7891 \tl_set:Nx \l_@@_off_verb_addon_tl
7892 {
7893 \bool_if:NTF \l_@@_xecglue_bool
7894 { \keys_set:nn { xeCJK / options } { xCJKecglue = true } }
7895 { \keys_set:nn { xeCJK / options } { xCJKecglue = false } }
7896 \exp_not:n
7897 {
7898 \cs_set_eq:NN \CJKglue \@@_shipout_CJKglue:
7899 \cs_set_eq:NN \CJKecglue \@@_shipout_CJKecglue:
7900 \cs_set_eq:NN \@@_punct_hskip:n \@@_shipout_punct_hskip:n
7901 \cs_set_eq:NN \@@_punct_breakable_kern:n
7902 \@@_shipout_punct_breakable_kern:n
7903 \l_@@_reset_shipout_skip_hook_tl
7904 }
7905 }
7906 \xeCJK_add_to_shipout:n { \l_@@_off_verb_addon_tl }
7907 \keys_set:nn { xeCJK / options } { xCJKecglue = false }
7908 }
7909 \tl_new:N \l_@@_reset_shipout_skip_hook_tl
7910 % \end{macrocode}
7911 % \end{macro}
7912 %
7913 % \begin{macro}{\xeCJKOffVerbAddon,\xeCJKVerbAddon}
7914 % \changes{v3.1.0}{2012/11/19}{新增 \tn{xeCJKVerbAddon} 用于抄录环境中的间距调整。}
7915 % \changes{v3.2.3}{2013/06/04}
7916 % {新增 \tn{xeCJKOffVerbAddon} 用于局部取消 \tn{xeCJKOffVerbAddon} 的影响;并解决
7917 % 跨页使用时影响到页眉页脚的问题。}
7918 % \changes{v3.2.5}{2013/07/13}{禁止自动换行,与西文一致。}
7919 % \changes{v3.2.8}{2013/11/16}{增加是否是等宽字体的判断。}
7920 % \tn{xeCJKVerbAddon} 进行了比较大的调整,应该只在分组环境里使用。为了方便调整间距
7921 % 以利于对齐,这里只把字符分成了两类,并且在 CJK 类与边界(空格)之间也插入
7922 % \tn{CJKecglue}。以字母“M”的宽度是否等于 \tn{fontdimen2} 来判断当前字体是否是
7923 % 等宽字体。如果不是等宽字体,则设置间距为零或正文间距。
7924 % \begin{macrocode}
7925 \NewDocumentCommand \xeCJKVerbAddon { }
7926 {
7927 \int_compare:nNnF \tex_currentgrouplevel:D = \c_zero_int
7928 {
7929 \bool_if:NF \l_@@_listings_env_bool
7930 {
7931 \dim_compare:nNnTF
7932 { \tex_fontdimen:D 2 ~ \tex_font:D } =
7933 { \tex_fontcharwd:D \tex_font:D \c_@@_mono_letter_int }
7934 {
7935 \@@_set_verb_exspace:
7936 \@@_verb_addon:
7937 }
7938 {
7939 \int_if_odd:nTF { \l_@@_verb_case_int }
7940 { \@@_nobreak_skip_zero: }
7941 { \@@_nobreak_skip: }
7942 }
7943 }
7944 }
7945 }
7946 \int_const:Nn \c_@@_mono_letter_int { 77 }
7947 \bool_new:N \l_@@_listings_env_bool
7948 \NewDocumentCommand \xeCJKOffVerbAddon { }
7949 { \tl_use:N \l_@@_off_verb_addon_tl }
7950 \tl_new:N \l_@@_off_verb_addon_tl
7951 \cs_new_protected:Npn \@@_verb_addon:
7952 {
7953 \bool_if:NF \l_@@_verb_addon_bool
7954 { \@@_verb_addon_action: }
7955 \skip_if_eq:nnTF { \l_@@_verb_exspace_skip } { \c_zero_skip }
7956 {
7957 \xeCJK_cs_clear:N \CJKglue
7958 \xeCJK_cs_clear:N \CJKecglue
7959 }
7960 {
7961 \skip_set_eq:NN \l_@@_ccglue_skip \l_@@_verb_exspace_skip
7962 \skip_set:Nn \l_@@_ecglue_skip { \l_@@_verb_exspace_skip / 2 }
7963 \cs_set_eq:NN \CJKglue \@@_nobreak_ccglue:
7964 \cs_set_eq:NN \CJKecglue \@@_nobreak_ecglue:
7965 }
7966 \cs_set_eq:NN \xeCJK_check_for_glue: \CJKecglue
7967 \cs_set_eq:NN \xeCJK_CJK_and_Boundary:w \@@_verb_CJK_and_Boundary:w
7968 }
7969 \cs_new_protected:Npn \@@_verb_addon_action:
7970 {
7971 \bool_set_true:N \l_@@_verb_addon_bool
7972 \@@_set_char_class_eq:nn { FullLeft } { CJK }
7973 \@@_set_char_class_eq:nn { FullRight } { CJK }
7974 \@@_set_char_class_eq:nn { HalfLeft } { Default }
7975 \@@_set_char_class_eq:nn { HalfRight } { Default }
7976 \@@_set_char_class_eq:nn { NormalSpace } { Default }
7977 \cs_set_eq:NN \@@_shipout_CJKglue: \CJKglue
7978 \cs_set_eq:NN \@@_shipout_CJKecglue: \CJKecglue
7979 \cs_set_eq:NN \@@_shipout_check_for_glue: \xeCJK_check_for_glue:
7980 \cs_set_eq:NN \@@_shipout_boundary:w \xeCJK_CJK_and_Boundary:w
7981 \cs_set_protected:Npx \xeCJKOffVerbAddon
7982 {
7983 \@@_reset_char_class:n { FullLeft }
7984 \@@_reset_char_class:n { FullRight }
7985 \@@_reset_char_class:n { HalfLeft }
7986 \@@_reset_char_class:n { HalfLeft }
7987 \@@_reset_char_class:n { NormalSpace }
7988 \bool_if:NTF \l_@@_xecglue_bool
7989 { \keys_set:nn { xeCJK / options } { xCJKecglue = true } }
7990 { \keys_set:nn { xeCJK / options } { xCJKecglue = false } }
7991 \exp_not:n
7992 {
7993 \cs_set_eq:NN \CJKglue \@@_shipout_CJKglue:
7994 \cs_set_eq:NN \CJKecglue \@@_shipout_CJKecglue:
7995 \cs_set_eq:NN \xeCJK_check_for_glue: \@@_shipout_check_for_glue:
7996 \cs_set_eq:NN \xeCJK_CJK_and_Boundary:w \@@_shipout_boundary:w
7997 }
7998 }
7999 \xeCJK_add_to_shipout:n { \xeCJKOffVerbAddon }
8000 \keys_set:nn { xeCJK / options } { xCJKecglue = false }
8001 }
8002 \cs_new_protected:Npn \@@_verb_CJK_and_Boundary:w
8003 { \xeCJK_class_group_end: \CJKecglue }
8004 \cs_new_protected:Npn \@@_reset_char_class:n #1
8005 {
8006 \int_set:Nn \l_@@_tmp_int { \xeCJK_class_num:n {#1} }
8007 \clist_map_inline:cn { c_@@_#1_chars_clist }
8008 { \tex_XeTeXcharclass:D ##1 = \l_@@_tmp_int }
8009 }
8010 \bool_new:N \l_@@_verb_addon_bool
8011 \cs_new_eq:NN \CJKfixedspacing \xeCJKVerbAddon
8012 % \end{macrocode}
8013 % \end{macro}
8014 %
8015 % \begin{macro}{\@@_set_verb_exspace:}
8016 % \changes{v3.1.1}{2012/12/08}{调整间距的计算方法。}
8017 % \changes{v3.2.4}{2013/06/29}{当计算得出的间距为负时,缩小 CJK 字体。}
8018 % 在抄录环境中,CJK 文字之间的间距为当前西文字体两个空格的宽度与当前字体大小之差,
8019 % 而与西文和空格的间距为 CJK 文字之间的间距的一半。
8020 % \begin{macrocode}
8021 \cs_new_protected:Npn \@@_set_verb_exspace:
8022 {
8023 \tl_if_exist:cTF { xeCJK/verb/\CJK@family/\curr@fontshape/\f@size }
8024 {
8025 \skip_set:Nn \l_@@_verb_exspace_skip
8026 { \use:c { xeCJK/verb/\CJK@family/\curr@fontshape/\f@size } }
8027 }
8028 {
8029 \tl_set:Nx \l_@@_current_coor_tl { \CJK@family/\curr@fontshape }
8030 \prop_get:NoNTF \g_@@_scale_family_prop
8031 \l_@@_current_coor_tl \l_xeCJK_family_tl
8032 {
8033 \xeCJK_switch_family:o { \l_xeCJK_family_tl }
8034 \skip_zero:N \l_@@_verb_exspace_skip
8035 }
8036 {
8037 \group_begin: \xeCJK_select_font: \exp_args:NNo \group_end:
8038 \@@_set_verb_exspace:n
8039 { \dim_use:N \tex_fontcharwd:D \tex_font:D "4E00 ~ }
8040 }
8041 }
8042 }
8043 \skip_new:N \l_@@_verb_exspace_skip
8044 % \end{macrocode}
8045 % \end{macro}
8046 %
8047 % \begin{macro}{\@@_set_verb_exspace:n}
8048 % 当两个西文空格的宽度小于一个 CJK 文字的宽度时,对目前使用的 CJK 字体进行适当缩小。
8049 % \begin{macrocode}
8050 \cs_new_protected:Npn \@@_set_verb_exspace:n #1
8051 {
8052 \skip_set:Nn \l_@@_verb_exspace_skip
8053 { 2 \tex_fontdimen:D 2 ~ \tex_font:D - #1 }
8054 \dim_compare:nNnTF \l_@@_verb_exspace_skip < \c_zero_dim
8055 {
8056 \skip_zero:N \l_@@_verb_exspace_skip
8057 \exp_args:Nee \@@_set_verb_scale:nn
8058 { \dim_to_fp:n { 2 \tex_fontdimen:D 2 ~ \tex_font:D } }
8059 { \dim_to_fp:n {#1} }
8060 }
8061 {
8062 \tl_const:cx { xeCJK/verb/\CJK@family/\curr@fontshape/\f@size }
8063 { \skip_use:N \l_@@_verb_exspace_skip }
8064 }
8065 }
8066 % \end{macrocode}
8067 % \end{macro}
8068 %
8069 % \begin{macro}{\@@_set_verb_scale:nn}
8070 % 缩小 CJK 字体,并保存相关信息。
8071 % \begin{macrocode}
8072 \cs_new_protected:Npn \@@_set_verb_scale:nn #1#2
8073 {
8074 \fp_set:Nn \l_@@_scale_factor_fp { #1 / #2 }
8075 \@@_warning:nxx { scale-factor }
8076 { \fp_eval:n { trunc ( \l_@@_scale_factor_fp , 4 ) } }
8077 { \fp_eval:n { ceil ( #2 / #1 , 4 ) } }
8078 \xeCJK_add_font_features:Nne \c_true_bool
8079 { } { Scale = { \fp_use:N \l_@@_scale_factor_fp } }
8080 \prop_gput:Noo \g_@@_scale_family_prop
8081 \l_@@_current_coor_tl \l_xeCJK_family_tl
8082 }
8083 \@@_msg_new:nn { scale-factor }
8084 {
8085 `\token_to_str:N \xeCJKVerbAddon'~may~not~work~properly.\\\\
8086 You~may~set~`Scale=#1'~to~CJKfamily~
8087 `\@@_msg_family_map:n { \l_xeCJK_family_tl }',\\
8088 or~set~`Scale=#2'~to~family~
8089 `\str_if_eq:eeTF \f@family \ttdefault
8090 { \token_to_str:N \ttdefault } { \f@family }'.
8091 }
8092 \fp_new:N \l_@@_scale_factor_fp
8093 \prop_new:N \g_@@_scale_family_prop
8094 % \end{macrocode}
8095 % \end{macro}
8096 %
8097 % \begin{macro}[int]{\xeCJK_visible_space:}
8098 % \begin{macro}[int]{\@setupverbvisiblespace}
8099 % \changes{v3.2.5}{2013/07/13}{可视空格考虑传统 \TeX 字体的情况。}
8100 % \changes{v3.8.0}{2020/02/09}{更新可视空格补丁。}
8101 % 如果文档不使用 \texttt{EU1} 作为默认字体编码,那么默认的打字机字体族很可能是
8102 % 传统的 \TeX 字体,这时可视空格按照 \texttt{OT1} 编码传统一般就是字体中的 |\char32|。
8103 % \begin{macrocode}
8104 \cs_new_protected:Npn \xeCJK_setup_visible_space:
8105 {
8106 \xeCJK_make_boundary:
8107 \xeCJK_glyph_if_exist:NTF { ^^^^2423 }
8108 { \tl_set:Nn \l_@@_visible_space_tl { ^^^^2423 } }
8109 {
8110 \int_compare:nNnTF { \tex_XeTeXfonttype:D \tex_font:D } = \c_zero_int
8111 {
8112 \tl_set:Nx \l_@@_visible_space_tl
8113 {
8114 \str_if_eq:eeTF { \f@family } { \ttdefault }
8115 { \c_catcode_other_space_tl }
8116 { \exp_not:N \textvisiblespace }
8117 }
8118 }
8119 { \@@_visible_space_fallback: }
8120 }
8121 \cs_set_eq:NN \@xobeysp \l_@@_visible_space_tl
8122 }
8123 \tl_new:N \l_@@_visible_space_tl
8124 \cs_set_eq:NN \@setupverbvisiblespace \xeCJK_setup_visible_space:
8125 % \end{macrocode}
8126 % \end{macro}
8127 % \end{macro}
8128 %
8129 % \begin{macro}{\@@_visible_space_fallback:}
8130 % 我们使用 |lmtt| 字体中的可视空格符号(|U+2423|)作为当前字体中相应符号
8131 % 的后备,但是 |lmtt| 的字体大小未必与当前字体匹配。因此,这里需要做一些调整,以
8132 % 保证使用后备可视空格符号时,也能保证对齐。
8133 % \begin{macrocode}
8134 \cs_new_protected:Npn \@@_visible_space_fallback:
8135 {
8136 \exp_args:Nc \@@_visible_space_fallback_auxi:N
8137 { xeCJK/space/\curr@fontshape/\f@size }
8138 }
8139 \cs_new_protected:Npn \@@_visible_space_fallback_auxi:N #1
8140 {
8141 \cs_if_exist:NF #1
8142 { \@@_visible_space_fallback_auxii:N #1 }
8143 \tl_set:Nn \l_@@_visible_space_tl {#1}
8144 }
8145 % \end{macrocode}
8146 % \end{macro}
8147 %
8148 % \begin{macro}{\@@_visible_space_fallback_auxii:N}
8149 % 当前字体空格的宽度与后备字体 |lmtt| 不一样时,就对 \tn{textvisiblespace} 的字体尺寸
8150 % 按相应的比例放缩。
8151 % \begin{macrocode}
8152 \cs_new_protected:Npn \@@_visible_space_fallback_auxii:N #1
8153 {
8154 \group_begin:
8155 \exp_args:No \@@_set_visible_space_size:n
8156 { \dim_use:N \tex_fontdimen:D 2 ~ \tex_font:D }
8157 \cs_new_protected:Npx #1
8158 { \group_begin: \tex_the:D \tex_font:D ^^^^2423 \group_end: }
8159 \group_end:
8160 }
8161 \cs_new_protected:Npn \@@_set_visible_space_size:n #1
8162 {
8163 \fontencoding { \UnicodeEncodingName }
8164 \tl_set:Nn \f@family { lmtt }
8165 \selectfont
8166 \dim_compare:nNnF {#1} = { \tex_fontdimen:D 2 ~ \tex_font:D }
8167 {
8168 \fontsize
8169 {
8170 \dim_eval:n
8171 {
8172 \f@size pt *
8173 \dim_ratio:nn {#1} { \tex_fontdimen:D 2 ~ \tex_font:D }
8174 }
8175 }
8176 { \f@baselineskip }
8177 \selectfont
8178 }
8179 }
8180 % \end{macrocode}
8181 % \end{macro}
8182 %
8183 % \subsection{\pkg{xeCJK} 其他选项}
8184 %
8185 % \begin{macro}{LocalConfig}
8186 % \changes{v3.1.0}{2012/11/20}{增加 \texttt{LocalConfig} 选项用于载入本地配置文件。}
8187 % 声明载入本地配置文件的选项。
8188 % \begin{macrocode}
8189 \keys_define:nn { xeCJK / options }
8190 {
8191 LocalConfig .choice: ,
8192 LocalConfig / false .code:n =
8193 { \bool_gset_false:N \g_@@_config_bool } ,
8194 LocalConfig / true .code:n =
8195 {
8196 \bool_gset_true:N \g_@@_config_bool
8197 \tl_gset:Nn \g_@@_config_name_tl { xeCJK }
8198 } ,
8199 LocalConfig / unknown .code:n =
8200 {
8201 \bool_gset_true:N \g_@@_config_bool
8202 \tl_gset:Nx \g_@@_config_name_tl { xeCJK - \l_keys_value_tl }
8203 } ,
8204 LocalConfig .default:n = { true }
8205 }
8206 \tl_new:N \g_@@_config_name_tl
8207 \bool_new:N \g_@@_config_bool
8208 % \end{macrocode}
8209 % \end{macro}
8210 %
8211 % \begin{macro}[int]{CJKnumber,indentfirst}
8212 % \changes{v3.2.11}{2014/03/14}{放弃 \texttt{indentfirst} 和 \texttt{CJKnumber} 选项。}
8213 % \texttt{CJKnumber} 和 \texttt{indentfirst} 是过时选项。
8214 % \begin{macrocode}
8215 \keys_define:nn { xeCJK / options }
8216 {
8217 CJKnumber .code:n =
8218 { \@@_warning:nxx { option-deprecated } { \l_keys_key_tl } { CJKnumb } } ,
8219 indentfirst .code:n =
8220 { \@@_warning:nxx { option-deprecated } { \l_keys_key_tl } { indentfirst } } ,
8221 normalindentfirst .code:n =
8222 { \@@_warning:nxx { option-deprecated } { \l_keys_key_tl } { } }
8223 }
8224 \@@_msg_new:nn { option-deprecated }
8225 {
8226 The~`#1'~option~is~deprecated.\\
8227 \tl_if_empty:nF {#2}
8228 { You~may~load~the~package~`#2'~after~xeCJK~to~use~its~function.\\ }
8229 }
8230 % \end{macrocode}
8231 % \end{macro}
8232 %
8233 % \begin{macro}[int]{quiet,silent}
8234 % 将调用 \pkg{xeCJK} 时使用的未知的选项传递给 \pkg{fontspec} 宏包。
8235 % 对 \pkg{fontspec} 的 |quiet| 和 |silent| 选项进行修改,使其适用于 \pkg{xeCJK}。
8236 % \begin{macrocode}
8237 \keys_define:nn { xeCJK / options }
8238 {
8239 quiet .code:n =
8240 {
8241 \msg_redirect_module:nnn { xeCJK } { warning } { info }
8242 \msg_redirect_module:nnn { xeCJK } { info } { none }
8243 \xeCJK_if_package_loaded:nF { fontspec }
8244 { \PassOptionsToPackage { quiet } { fontspec } }
8245 } ,
8246 silent .code:n =
8247 {
8248 \msg_redirect_module:nnn { xeCJK } { warning } { none }
8249 \msg_redirect_module:nnn { xeCJK } { info } { none }
8250 \xeCJK_if_package_loaded:nF { fontspec }
8251 { \PassOptionsToPackage { silent } { fontspec } }
8252 } ,
8253 unknown .code:n =
8254 {
8255 \xeCJK_if_package_loaded:nTF { fontspec }
8256 { \@@_error:nx { key-unknown } { \l_keys_key_tl } }
8257 { \PassOptionsToPackage { \l_keys_key_tl } { fontspec } }
8258 }
8259 }
8260 \@@_msg_new:nn { key-unknown }
8261 {
8262 Sorry,~but~xeCJK/options~does~not~have~a~key~called~`#1'.\\\\
8263 The~key~`#1'~is~being~ignored.
8264 }
8265 % \end{macrocode}
8266 % \end{macro}
8267 %
8268 % \subsection{\pkg{xeCJK} 初始化设置}
8269 %
8270 % \begin{macro}[int]{\CJKsymbol, \CJKpunctsymbol}
8271 % \begin{macrocode}
8272 \cs_new_eq:NN \CJKsymbol \use:n
8273 \cs_new_eq:NN \CJKpunctsymbol \use:n
8274 % \end{macrocode}
8275 % \end{macro}
8276 %
8277 % \pkg{xeCJK} 宏包的初始化设置。
8278 %
8279 % \begin{macrocode}
8280 \keys_set:nn { xeCJK / options }
8281 {
8282 CJKglue = { \skip_horizontal:n { \c_zero_dim plus 0.08 \tex_baselineskip:D } } ,
8283 CJKecglue = { ~ } ,
8284 xCJKecglue = false ,
8285 CheckSingle = false ,
8286 PlainEquation = false ,
8287 CheckFullRight = false ,
8288 CJKspace = false ,
8289 CJKmath = false ,
8290 xeCJKactive = true ,
8291 LocalConfig = true ,
8292 LoadFandol = true ,
8293 RubberPunctSkip = true ,
8294 Verb = env ,
8295 EmboldenFactor = 4 ,
8296 SlantFactor = 0.167 ,
8297 PunctStyle = quanjiao ,
8298 NewLineCS = { \par \[ } ,
8299 EnvCS = { \begin \end } ,
8300 WidowPenalty = { 10 000 } ,
8301 NoBreakCS = { \footnote \footnotemark \nobreak } ,
8302 KaiMingPunct = { ^^^^3002 ^^^^ff0e ^^^^ff1f ^^^^ff01 } ,
8303 LongPunct = { ^^^^2014 ^^^^2e3a ^^^^2025 ^^^^2026 } ,
8304 MiddlePunct = { ^^^^2013 ^^^^2014 ^^^^2e3a ^^^^2027 ^^^^00b7 ^^^^30fb ^^^^ff65 } ,
8305 AllowBreakBetweenPuncts = false
8306 }
8307 \defaultCJKfontfeatures { Script = CJK }
8308 % \end{macrocode}
8309 %
8310 % 半字线连接号\footnote{见\href{http://www.moe.gov.cn/ewebeditor/uploadfile/2015/01/13/20150113092346124.pdf}
8311 % {《夹用英文的中文文本的标点符号用法(草案)》5.13 节。}}应为半角宽度。
8312 % \begin{macrocode}
8313 \xeCJKsetwidth { ^^^^2013 } { 0.5 em }
8314 % \end{macrocode}
8315 %
8316 % \changes{v3.7.0}{2018/03/16}{不再默认引入 \pkg{xunicode} 宏包。}
8317 %
8318 % 执行宏包选项,并载入 \pkg{fontspec} 宏包。
8319 % \begin{macrocode}
8320 \cs_if_exist:NTF \ProcessKeyOptions
8321 { \ProcessKeyOptions [ xeCJK / options ] }
8322 {
8323 \RequirePackage { l3keys2e }
8324 \ProcessKeysOptions { xeCJK / options }
8325 }
8326 \RequirePackage { fontspec } [ 2020/02/03 ]
8327 % \end{macrocode}
8328 %
8329 % \begin{variable}{\c_@@_encoding_tl}
8330 % 保存 \pkg{fontspec} 声明字体时使用的字体编码。
8331 % \begin{macrocode}
8332 \tl_const:Nx \c_@@_encoding_tl { \g_fontspec_encoding_tl }
8333 % \end{macrocode}
8334 % \end{variable}
8335 %
8336 % \changes{v3.1.0}{2012/11/21}{改用 \pkg{indentfirst} 宏包处理缩进的问题。}
8337 %
8338 % 对不能通过 \tn{xeCJKsetup} 设置的选项给出警告。
8339 % \begin{macrocode}
8340 \keys_define:nn { xeCJK / options }
8341 {
8342 LocalConfig .code:n =
8343 { \@@_warning:nx { option-invalid } { \l_keys_key_tl } }
8344 }
8345 \@@_msg_new:nn { option-invalid }
8346 {
8347 The~`#1'~option~can~only~be~set~in~the~optional~argument~to~the\\
8348 \token_to_str:N \usepackage \ command~when~xeCJK~is~being~loaded.\\\\
8349 Please~do~not~set~it~via~the~\token_to_str:N \xeCJKsetup \ command.
8350 }
8351 % \end{macrocode}
8352 %
8353 % \begin{variable}{\CJKrmdefault,\CJKsfdefault,\CJKttdefault,\CJKfamilydefault}
8354 % \begin{macrocode}
8355 \tl_if_exist:NF \CJKrmdefault { \tl_gset:Nn \CJKrmdefault { rm } }
8356 \tl_if_exist:NF \CJKsfdefault { \tl_gset:Nn \CJKsfdefault { sf } }
8357 \tl_if_exist:NF \CJKttdefault { \tl_gset:Nn \CJKttdefault { tt } }
8358 \tl_new:N \l_@@_family_default_init_tl
8359 \cs_new_eq:NN \@@_family_default_wrap:n \use:n
8360 \tl_set:Nx \l_@@_family_default_init_tl
8361 {
8362 \exp_not:N \@@_family_default_wrap:n
8363 {
8364 \tl_if_exist:NTF \CJKfamilydefault
8365 { \exp_not:o \CJKfamilydefault }
8366 { \exp_not:N \CJKrmdefault }
8367 }
8368 }
8369 \tl_gset_eq:NN \CJKfamilydefault \l_@@_family_default_init_tl
8370 % \end{macrocode}
8371 % \end{variable}
8372 %
8373 % \begin{macro}{\xeCJKsetup}
8374 % 在导言区或文档中设置 \pkg{xeCJK} 的接口。
8375 % \begin{macrocode}
8376 \NewDocumentCommand \xeCJKsetup { +m }
8377 {
8378 \keys_set:nn { xeCJK / options } {#1}
8379 \tex_ignorespaces:D
8380 }
8381 % \end{macrocode}
8382 % \end{macro}
8383 %
8384 % \begin{macro}[int]{\xeCJKsetemboldenfactor, \xeCJKsetslantfactor}
8385 % \begin{macrocode}
8386 \NewDocumentCommand \xeCJKsetemboldenfactor { m }
8387 { \xeCJKsetup { EmboldenFactor = {#1} } }
8388 \NewDocumentCommand \xeCJKsetslantfactor { m }
8389 { \xeCJKsetup { SlantFactor = {#1} } }
8390 % \end{macrocode}
8391 % \end{macro}
8392 %
8393 % \begin{macro}[int]{\punctstyle, \xeCJKplainchr}
8394 % \begin{macrocode}
8395 \NewDocumentCommand \punctstyle { m } { \xeCJKsetup { PunctStyle = {#1} } }
8396 \NewDocumentCommand \xeCJKplainchr { } { \xeCJKsetup { PunctStyle = plain } }
8397 % \end{macrocode}
8398 % \end{macro}
8399 %
8400 % \begin{macro}[int]{\CJKsetecglue}
8401 % \begin{macrocode}
8402 \NewDocumentCommand \CJKsetecglue { m } { \xeCJKsetup { CJKecglue = {#1} } }
8403 \cs_new_eq:NN \xeCJKsetecglue \CJKsetecglue
8404 % \end{macrocode}
8405 % \end{macro}
8406 %
8407 % \begin{macro}[int]{\CJKspace,\CJKnospace}
8408 % \begin{macrocode}
8409 \NewDocumentCommand \CJKspace { } { \xeCJKsetup { CJKspace = true } }
8410 \NewDocumentCommand \CJKnospace { } { \xeCJKsetup { CJKspace = false } }
8411 % \end{macrocode}
8412 % \end{macro}
8413 %
8414 % \begin{macro}[int]{\xeCJKallowbreakbetweenpuncts, \xeCJKnobreakbetweenpuncts}
8415 % \begin{macrocode}
8416 \NewDocumentCommand \xeCJKallowbreakbetweenpuncts { }
8417 { \xeCJKsetup { AllowBreakBetweenPuncts = true } }
8418 \NewDocumentCommand \xeCJKnobreakbetweenpuncts { }
8419 { \xeCJKsetup { AllowBreakBetweenPuncts = false } }
8420 % \end{macrocode}
8421 % \end{macro}
8422 %
8423 % \begin{macro}[int]{\xeCJKenablefallback, \xeCJKdisablefallback}
8424 % \begin{macrocode}
8425 \NewDocumentCommand \xeCJKenablefallback { }
8426 { \xeCJKsetup { AutoFallBack = true } }
8427 \NewDocumentCommand \xeCJKdisablefallback { }
8428 { \xeCJKsetup { AutoFallBack = false } }
8429 % \end{macrocode}
8430 % \end{macro}
8431 %
8432 % \begin{macro}[int]{\xeCJKsetcharclass}
8433 % \begin{macrocode}
8434 \NewDocumentCommand \xeCJKsetcharclass { m m m }
8435 {
8436 \xeCJK_set_char_class:nnn {#1} {#2} {#3}
8437 \xeCJKResetPunctClass
8438 }
8439 % \end{macrocode}
8440 % \end{macro}
8441 %
8442 % \subsection{兼容性修补}
8443 %
8444 % \changes{v3.2.16}{2014/11/20}{修复 \tn{hbar}。}
8445 % \changes{v3.8.0}{2020/02/09}{删除 \tn{hbar} 补丁。}
8446 %
8447 % \begin{macro}[int]{\xeCJK@update@fam,\Url@MathSetup}
8448 % \changes{v3.2.7}{2013/11/09}{使通过 \tn{UrlFont} 等命令设置的 CJK 字体生效。}
8449 % 使通过 \tn{urlstyle} 或者 \tn{UrlFont} 设置的路径中使用的 CJK 字体生效。
8450 % 使用 \tn{everymath} 钩子中数学模式中重定义 CJK 数学字体,以确保我们的设置在
8451 % \tn{check@mathfonts} 之后生效,不会被它覆盖。
8452 % 更合理的方式是定义一个新的 \tn{mathversion} 来切换。
8453 % \begin{macrocode}
8454 \cs_new_protected:Npn \xeCJK@update@fam
8455 {
8456 \addto@hook \everymath
8457 {
8458 \@@_update_main_fam:
8459 \@@_update_block_fam:
8460 }
8461 }
8462 \cs_new_protected:Npn \@@_update_main_fam:
8463 {
8464 \group_begin:
8465 \xeCJK_select_font:
8466 \exp_last_unbraced:NNNo \group_end:
8467 \tex_textfont:D \c_xeCJK_math_fam_int \tex_the:D \tex_font:D
8468 }
8469 \cs_new_protected:Npn \@@_update_block_fam:
8470 {
8471 \prop_if_empty:NF \g_@@_block_fam_prop
8472 {
8473 \prop_map_function:NN
8474 \g_@@_block_fam_prop
8475 \@@_update_block_fam:nn
8476 }
8477 }
8478 \cs_new_protected:Npn \@@_update_block_fam:nn #1#2
8479 {
8480 \int_set:Nn \l_@@_fam_int {#2}
8481 \group_begin:
8482 \xeCJK_select_font:n {#1}
8483 \exp_last_unbraced:NNNo \group_end:
8484 \tex_textfont:D \l_@@_fam_int \tex_the:D \tex_font:D
8485 }
8486 \@@_after_end_preamble:n
8487 {
8488 \bool_lazy_and:nnT
8489 { \g_@@_math_bool }
8490 { \cs_if_exist_p:N \Url@MathSetup }
8491 { \tl_put_right:Nn \Url@MathSetup { \xeCJK@update@fam } }
8492 }
8493 % \end{macrocode}
8494 % \end{macro}
8495 %
8496 % \changes{v3.2.6}{2013/08/02}{为 \tn{mathrm} 减少一个可能的数学字体族。}
8497 % \changes{v3.8.0}{2020/02/09}{删除 \tn{mathrm} 补丁。}
8498 %
8499 % \changes{v3.4.5}{2017/01/02}{更新 \LaTeXiii{} 的过时用法。}
8500 %
8501 % \begin{macro}[int]{\(,\),\math,\endmath,\ensuremath}
8502 % \begin{macro}{\@@_math_robust:N}
8503 % \changes{v3.2.5}{2013/07/25}
8504 % {解决汉字后紧跟 \tn{(}\texttt{...}\tn{)} 形式的行内数学公式时,不能加入间距的问题。}
8505 % \changes{v3.2.6}{2013/08/03}{考虑 \pkg{ulem} 对 \tn{MakeRobust} 的不当定义。}
8506 % \changes{v3.2.6}{2013/08/03}{考虑 \tn{math} 和 \tn{ensuremath}。}
8507 % \changes{v3.3.1}{2015/04/14}{兼容 \LaTeXe{} 2015。}
8508 % \tn{(} 的在 \LaTeXe 中的定义是
8509 % \begin{verbatim}
8510 % \def\({\relax\ifmmode\@badmath\else$\fi}
8511 % \end{verbatim}
8512 % 这个定义最开始的 \tn{relax} 是为了防止 \tn{(} 出现在表格单元格的开始位置时,模式
8513 % 判断不正确(因为 \TeX 会先看单元格中第一个不可展的非空格记号是否是 \tn{omit} 或
8514 % \tn{noalign})。但是它会造成一个边界,使 \pkg{xeCJK} 不能看到 \tn{relax} 后面出现的
8515 % |$|,从而不能加入间距\footnote{\url{http://tex.stackexchange.com/q/124773}}。使用
8516 % \hologo{eTeX} 的 \tn{protected} 来定义它,可以不需要 \tn{relax},或者将 \tn{relax}
8517 % 改成 \cs{scan_align_safe_stop:},都可以避免这些情况。同时 \pkg{fixltx2e} 中还使用了
8518 % |\MakeRobust\(|,我们需要小心处理。另外 \pkg{ulem} 也定义了一个 \tn{MakeRobust},
8519 % 如果它被放在 \pkg{fixltx2e} 之前载入,那么 \pkg{fixltx2e} 的定义就会失效(因为
8520 % \pkg{fixltx2e} 使用 \tn{providecommand}|*| 来定义 \tn{MakeRobust})。但是 \pkg{ulem}
8521 % 的定义并不完全正确,没有考虑 \TeX 不会略去控制符号后面的空格的情况。
8522 % \begin{macrocode}
8523 \cs_new_protected:Npn \@@_math_robust:N #1
8524 {
8525 \group_begin: \exp_args:NcNc \group_end:
8526 { @@_math_robust_aux:NN } #1 { \cs_to_str:N #1 ~ }
8527 }
8528 \cs_new_protected:Npn \@@_math_robust_aux:NN #1#2
8529 {
8530 \exp_args:Ne \str_case:nnTF { \cs_replacement_spec:N #1 }
8531 {
8532 { \x@protect #1 \protect #2 } { }
8533 { \protect #2 } { }
8534 }
8535 { \@@_math_robust:NN #1#2 }
8536 { \@@_math_robust:NN #1#1 }
8537 }
8538 \cs_new_protected:Npn \@@_math_robust:NN #1#2
8539 {
8540 \str_if_eq:eeTF { \cs_argument_spec:N #2 } { }
8541 {
8542 \exp_args:No \tl_if_head_eq_meaning:nNTF {#2} \scan_stop:
8543 {
8544 \cs_gset_protected:Npx #1
8545 { \tl_tail:N #2 }
8546 }
8547 {
8548 \cs_if_eq:NNTF #1 \ensuremath
8549 {
8550 \cs_gset_protected:Npx #1
8551 { \exp_not:o {#2} }
8552 }
8553 {
8554 \@@_warning:nxx { robust-failure }
8555 { \token_to_str:N #1 } { \token_to_meaning:N #2 }
8556 }
8557 }
8558 }
8559 {
8560 \@@_warning:nxx { robust-failure }
8561 { \token_to_str:N #1 } { \token_to_meaning:N #2 }
8562 }
8563 }
8564 \@@_msg_new:nnn { robust-failure }
8565 { xeCJK~can~not~make~`#1'~robust. }
8566 {
8567 The~current~meaning~of~`#1'~is:\\
8568 \iow_indent:n {#2}
8569 }
8570 \cs_if_eq:NNTF \( \math
8571 {
8572 \@@_math_robust:N \(
8573 \cs_set_eq:NN \math \(
8574 }
8575 {
8576 \@@_math_robust:N \(
8577 \@@_math_robust:N \math
8578 }
8579 \cs_if_eq:NNTF \) \endmath
8580 {
8581 \@@_math_robust:N \)
8582 \cs_set_eq:NN \endmath \)
8583 }
8584 {
8585 \@@_math_robust:N \)
8586 \@@_math_robust:N \endmath
8587 }
8588 \@@_math_robust:N \ensuremath
8589 % \end{macrocode}
8590 % \end{macro}
8591 % \end{macro}
8592 %
8593 % \changes{v3.2.5}{2013/07/25}{解决 \pkg{fixltx2e} 和 \pkg{amsthm} 的冲突。}
8594 % \changes{v3.3.1}{2015/04/15}{删去 \pkg{fixltx2e} 和 \pkg{amsthm} 的冲突补丁。}
8595 %
8596 % \changes{v3.1.2}{2013/01/01}
8597 % {修正非 \tn{UTFencname} 编码下面 \pkg{xunicode} 重定义的 \tn{nobreakspace} 会失效的问题。}
8598 % \changes{v3.2.5}{2013/07/18}{恢复 \tn{nobreakspace} 的原始定义。}
8599 % \changes{v3.7.0}{2018/03/18}{对 \tn{nobreakspace} 的恢复放到 \pkg{xunicode-addon} 中处理。}
8600 %
8601 % \changes{v3.1.1}{2012/12/13}{对于与 \pkg{xltxtra} 的冲突给出错误警告。}
8602 % \changes{v3.8.0}{2020/02/09}{删除 \pkg{realscripts} 补丁。}
8603 %
8604 % \changes{v3.8.6}{2020/10/17}{兼容 \LaTeX\ 2020/10/01 的 \pkg{NFSS} 钩子机制。}
8605 %
8606 % \begin{macro}[int]{\fontfamily}
8607 % \begin{macro}[int]{\xeCJK@fontfamily,\xeCJK@family}
8608 % \changes{v3.1.1}{2012/12/06}{修改主要 \texttt{CJK} 字体族的自动更新方式。}
8609 % \changes{v3.1.2}{2013/01/01}{不将参数完全展开。}
8610 % \changes{v3.4.6}{2017/02/23}
8611 % {将族名参数完全展开,以解决与 \pkg{fontspec} 2017/01/24 v2.5d 的兼容问题。}
8612 % 对于 \LaTeXe\ 2020/02/02 之前的版本,修改 \tn{fontfamily},
8613 % 使主要 |CJK| 字体族能随西文主要字体更新,之后的版本可以使用 \tn{@rmfamilyhook} 等新钩子处理。
8614 % \LaTeXe\ 2020/10/01 提供了新的的 \pkg{NFSS} 钩子。
8615 % \begin{macrocode}
8616 \ctex_if_format_at_least:nTF { 2020/10/01 }
8617 {
8618 \cs_set_eq:NN \xeCJK@family \xeCJK_switch_family:e
8619 \ctex_gadd_ltxhook:nn { rmfamily } { \xeCJK@family { \CJKrmdefault } }
8620 \ctex_gadd_ltxhook:nn { sffamily } { \xeCJK@family { \CJKsfdefault } }
8621 \ctex_gadd_ltxhook:nn { ttfamily } { \xeCJK@family { \CJKttdefault } }
8622 \ctex_gadd_ltxhook:nn { normalfont } { \xeCJK@family { \CJKfamilydefault } }
8623 }
8624 {
8625 \cs_if_exist:NTF \@rmfamilyhook
8626 {
8627 \cs_set_eq:NN \xeCJK@family \xeCJK_switch_family:e
8628 \g@addto@macro \@rmfamilyhook { \xeCJK@family { \CJKrmdefault } }
8629 \g@addto@macro \@sffamilyhook { \xeCJK@family { \CJKsfdefault } }
8630 \g@addto@macro \@ttfamilyhook { \xeCJK@family { \CJKttdefault } }
8631 \exp_args:Nc \g@addto@macro
8632 {
8633 \cs_if_exist:NTF \@defaultfamilyhook
8634 { @defaultfamilyhook } { normalfont ~ }
8635 }
8636 { \xeCJK@family { \CJKfamilydefault } }
8637 }
8638 {
8639 \RenewDocumentCommand \fontfamily { m }
8640 {
8641 \tl_set:Nx \f@family {#1}
8642 \xeCJK@fontfamily {#1}
8643 }
8644 \cs_new_protected:Npn \xeCJK@fontfamily #1
8645 {
8646 \str_if_eq:nnTF {#1} { \familydefault }
8647 { \xeCJK_switch_family:e { \CJKfamilydefault } }
8648 { \@@_update_family_aux: }
8649 }
8650 \cs_new_protected:Npn \@@_update_family_aux:
8651 {
8652 \str_case_e:nn { \f@family }
8653 {
8654 { \rmdefault } { \xeCJK_switch_family:e { \CJKrmdefault } }
8655 { \sfdefault } { \xeCJK_switch_family:e { \CJKsfdefault } }
8656 { \ttdefault } { \xeCJK_switch_family:e { \CJKttdefault } }
8657 { \familydefault } { \xeCJK_switch_family:e { \CJKfamilydefault } }
8658 }
8659 }
8660 }
8661 }
8662 % \end{macrocode}
8663 % \end{macro}
8664 % \end{macro}
8665 %
8666 % \begin{macrocode}
8667 %<@@=>
8668 % \end{macrocode}
8669 %
8670 % \begin{macro}[int]{\xeCJK@fix@penalty}
8671 % \changes{v3.1.0}{2012/11/13}{采用通过不修改原语 \tn{/} 的方式对修复倾斜校正。}
8672 % 对 \LaTeXe 内核中的 \tn{fix@penalty} 被用于诸如 \tn{textit} 之类的文档
8673 % 字体转换命令的定义之中。这里对它进行补丁的目的是修复其中的倾斜校正,并使得这些
8674 % 文档命令与紧随其后的汉字之间可以正确的插入 \tn{CJKecglue} 或者忽略其中的空格。
8675 % 例如 \verb*|这是 \emph{强调} 文本|,第二个空格可以被忽略掉。如果使用 |xCJKecglue|
8676 % 选项,第一个空格也可以被省略。事实上,在 \tn{sw@slant} 的定义中,\tn{@@italiccorr}
8677 % 前面的 \tn{lastskip} 和 \tn{lastpenalty} 有四种情况,这里只对它们都为零的情况进行
8678 % 处理。
8679 % \begin{macrocode}
8680 \cs_new_eq:NN \xeCJK@fix@penalty \fix@penalty
8681 \tl_replace_once:Nnn \xeCJK@fix@penalty { \@@italiccorr } { \xeCJK@italiccorr }
8682 \tl_replace_once:Nnn \sw@slant { \fix@penalty } { \xeCJK@fix@penalty }
8683 % \end{macrocode}
8684 % \end{macro}
8685 %
8686 % \begin{macro}[int]{\xeCJK@italiccorr}
8687 % 修复倾斜校正,并处理汉字后面的空格。
8688 % \begin{macrocode}
8689 \cs_new_protected:Npn \xeCJK@italiccorr
8690 {
8691 \int_compare:nNnTF \tex_XeTeXinterchartokenstate:D > \c_zero_int
8692 { \xeCJK_italic_correction: }
8693 { \@@italiccorr }
8694 }
8695 % \end{macrocode}
8696 % \end{macro}
8697 %
8698 % \begin{macrocode}
8699 %<@@=xeCJK>
8700 % \end{macrocode}
8701 %
8702 % \begin{macro}[int]{\xeCJK_italic_correction:}
8703 % 修复倾斜校正,并处理汉字后面的空格。
8704 % \begin{macrocode}
8705 \cs_new_protected:Npn \xeCJK_italic_correction:
8706 { \@@_if_last_kern:T { \@@_italic_correction: } }
8707 \cs_new_protected:Npn \@@_italic_correction:
8708 {
8709 \dim_case:nnF { \tex_lastkern:D }
8710 {
8711 { \@@_node:n { default } }
8712 {
8713 \xeCJK_remove_node: \tex_italiccorrection:D
8714 \xeCJK_make_node:n { default }
8715 }
8716 { \@@_node:n { CJK } }
8717 {
8718 \xeCJK_remove_node: \tex_italiccorrection:D
8719 \xeCJK_make_node:n { CJK }
8720 \@@_italic_correction_aux:
8721 }
8722 { \@@_node:n { CJK-space } }
8723 {
8724 \xeCJK_remove_node: \tex_italiccorrection:D
8725 \xeCJK_make_node:n { CJK-space }
8726 \@@_italic_correction_aux:
8727 }
8728 }
8729 { \tex_italiccorrection:D }
8730 }
8731 % \end{macrocode}
8732 % \cs{xeCJK_ignore_spaces:w} 里面用到 |peek| 函数来判断后面是不是空格,而此时它
8733 % 后面还有 $4$ 个 \tn{fi} 或者 |\else...\fi| 没有被展开,将影响 |peek| 函数的
8734 % 判断。因此我们需要用 $2^4-1=15$ 个 \cs{exp_after:wN} 来展开它们。
8735 % 显然,这里用 \cs{exp_last_unbraced:Nf} 会比较方便,但是它会吃掉
8736 % \verb*|\textit{...} | 等后面原来存在的空格作为完全展开的结束。要正确使用它还
8737 % 需要另外的处理(使用 \cs{exp_stop_f:})。
8738 % \begin{macrocode}
8739 \cs_new_protected:Npn \@@_italic_correction_aux:
8740 {
8741 \exp_after:wN \exp_after:wN \exp_after:wN
8742 \exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN
8743 \exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN
8744 \exp_after:wN \exp_after:wN \exp_after:wN \exp_after:wN
8745 \xeCJK_ignore_spaces:w
8746 }
8747 % \end{macrocode}
8748 % \end{macro}
8749 %
8750 % \begin{variable}{\g_@@_xetex_allocator_int}
8751 % \changes{v3.3.1}{2015/04/14}{兼容 \LaTeXe{} 2015。}
8752 % \changes{v3.3.2}{2015/05/15}{\tn{xe@alloc@intercharclass} 总是有定义的。}
8753 % \LaTeXe{} 2015/01/01 接管了 \tn{newXeTeXintercharclass}。
8754 % \begin{macrocode}
8755 \cs_new_eq:NN \g_@@_xetex_allocator_int \xe@alloc@intercharclass
8756 % \end{macrocode}
8757 % \end{variable}
8758 %
8759 % \begin{macro}{\@@_set_others_toks:n}
8760 % 简单处理与同样使用 \tn{XeTeXinterchartoks} 机制的宏包的兼容问题。
8761 % \begin{macrocode}
8762 \@@_after_end_preamble:n
8763 {
8764 \int_compare:nNnF
8765 { \c_@@_class_begin_int + \seq_count:N \g_@@_new_class_seq } =
8766 { \g_@@_xetex_allocator_int }
8767 {
8768 \int_step_inline:nnn
8769 { \c_@@_class_begin_int + 1 }
8770 { \g_@@_xetex_allocator_int }
8771 {
8772 \seq_if_in:NnF \g_@@_new_class_seq {#1}
8773 { \@@_set_others_toks:n {#1} }
8774 }
8775 }
8776 }
8777 \cs_new_protected:Npn \@@_set_others_toks:n #1
8778 {
8779 \int_set:cn { \@@_class_csname:n { Others } } {#1}
8780 \seq_map_inline:Nn \g_@@_CJK_class_seq
8781 {
8782 \xeCJK_copy_inter_class_toks:nnnn {##1} { Others } {##1} { NormalSpace }
8783 \xeCJK_copy_inter_class_toks:nnnn { Others } {##1} { NormalSpace } {##1}
8784 \xeCJK_app_inter_class_toks:nne {##1} { Others }
8785 { \xeCJK_get_inter_class_toks:nn { Default } { Others } }
8786 \xeCJK_pre_inter_class_toks:nne { Others } {##1}
8787 { \xeCJK_get_inter_class_toks:nn { Others } { Default } }
8788 \tl_if_blank:eT
8789 { \xeCJK_get_inter_class_toks:nn { Others } { Boundary } }
8790 {
8791 \xeCJK_copy_inter_class_toks:nnnn
8792 { Others } { Boundary } { Default } { Boundary }
8793 }
8794 \tl_if_blank:eT
8795 { \xeCJK_get_inter_class_toks:nn { Boundary } { Others } }
8796 {
8797 \xeCJK_copy_inter_class_toks:nnnn
8798 { Boundary } { Others } { Boundary } { Default }
8799 }
8800 }
8801 }
8802 % \end{macrocode}
8803 % \end{macro}
8804 %
8805 % \begin{macro}{\@@_inactive_group_begin:,\@@_inactive_group_end:}
8806 % 用于保护下面歧义宽度标点的分组。
8807 % \begin{macrocode}
8808 \cs_new_protected:Npn \@@_inactive_group_begin:
8809 { \group_begin: \makexeCJKinactive }
8810 \cs_new_eq:NN \@@_inactive_group_end: \group_end:
8811 % \end{macrocode}
8812 % \end{macro}
8813 %
8814 % \begin{macro}{\@@_patch_text_command:}
8815 % \begin{variable}{\c_@@_ambiguous_char_prop}
8816 % 单独处理宽度有分歧的几个标点:包括省略号、破折号、间隔号、引号等中西文混用的
8817 % 符号, 保证其命令形式输出的是西文字体。
8818 % 如果 \pkg{xunicode} 宏包被载入,则通过 \pkg{xunicode-addon} 处理。
8819 % \begin{macrocode}
8820 \prop_const_from_keyval:Nn \c_@@_ambiguous_char_prop
8821 {
8822 "00B7 = \textperiodcentered \textcentereddot \textcdot ,
8823 "2013 = \textendash ,
8824 "2014 = \textemdash ,
8825 "2018 = \textquoteleft \textgrq ,
8826 "2019 = \textquoteright ,
8827 "201C = \textquotedblleft \textgrqq ,
8828 "201D = \textquotedblright ,
8829 "2025 = \texthdotfor ,
8830 "2026 = \textellipsis ,
8831 "2027 = \texthyphenationpoint ,
8832 "2E3A = \texttwoemdash
8833 }
8834 \@@_at_end_preamble:n { \@@_patch_text_command: }
8835 \cs_new_protected:Npn \@@_patch_text_command:
8836 {
8837 \xeCJK_if_package_loaded:nTF { xunicode }
8838 { \@@_patch_xunicode_ambiguous_char: }
8839 {
8840 \exp_args:Ne \@@_patch_tuenc_ambiguous_char:n
8841 { \UnicodeEncodingName }
8842 \@@_patch_tuenc_accent:
8843 \@@_patch_tuenc_composite:
8844 }
8845 }
8846 \cs_new_protected:Npn \@@_patch_xunicode_ambiguous_char:
8847 {
8848 \RequirePackage { xunicode-addon }
8849 \prop_map_inline:Nn \c_@@_ambiguous_char_prop
8850 {
8851 \tl_map_inline:nn { ##2 }
8852 {
8853 \xunadd_set_begin_hook:nn { ####1 }
8854 { \@@_inactive_group_begin: }
8855 \xunadd_set_end_hook:nn { ####1 }
8856 { \@@_inactive_group_end: }
8857 }
8858 }
8859 \xunadd_append_begin_hook:n { \xeCJK_make_boundary: }
8860 }
8861 \cs_new_protected:Npn \@@_patch_tuenc_ambiguous_char:n #1
8862 {
8863 \prop_map_inline:Nn \c_@@_ambiguous_char_prop
8864 {
8865 \tl_map_inline:nn { ##2 }
8866 {
8867 \cs_if_exist:NF ####1
8868 { \DeclareTextSymbol ####1 {#1} { ##1 } }
8869 \@@_patch_ambiguous_char:nN {#1} ####1
8870 }
8871 }
8872 }
8873 \cs_new_protected:Npn \@@_patch_ambiguous_char:nN #1#2
8874 {
8875 \exp_args:Ne \@@_patch_ambiguous_char:nn
8876 { #1 \token_to_str:N #2 }
8877 { #1 - #2 }
8878 }
8879 \cs_new_protected:Npx \@@_patch_ambiguous_char:nNn #1#2#3
8880 {
8881 \exp_not:N \exp_args:Ne
8882 \exp_not:N \@@_patch_ambiguous_char:nn
8883 {
8884 \c_backslash_str #1
8885 \exp_not:N \token_to_str:N #2 -
8886 \exp_not:N \token_to_str:N #3
8887 }
8888 { #1 - #2#3 }
8889 }
8890 \cs_new_protected:Npn \@@_patch_ambiguous_char:nn #1#2
8891 {
8892 \cs_if_free:cF {#1}
8893 { \exp_args:Nc \@@_patch_ambiguous_char:Nn {#1} {#2} }
8894 }
8895 \cs_new_protected:Npn \@@_patch_ambiguous_char:Nn #1#2
8896 {
8897 \token_if_chardef:NTF #1
8898 {
8899 \prop_gput:Nne \c_@@_ambiguous_slot_prop {#2}
8900 { \int_eval:n {#1} }
8901 \cs_set_protected:Npx #1
8902 { \@@_ambiguous_char:n { \tex_Uchar:D #1 } }
8903 }
8904 {
8905 \prop_gput:Nne \c_@@_ambiguous_slot_prop {#2}
8906 { \int_eval:n { \exp_after:wN ` #1 } }
8907 \cs_set_protected:Npx #1
8908 { \@@_ambiguous_char:n { \exp_not:o {#1} } }
8909 }
8910 }
8911 \cs_new_protected:Npn \@@_ambiguous_char:n #1
8912 {
8913 \int_compare:nNnTF \tex_XeTeXinterchartokenstate:D > \c_zero_int
8914 { \@@_inactive_group_begin: #1 \@@_inactive_group_end: }
8915 {#1}
8916 }
8917 \prop_new:N \c_@@_ambiguous_slot_prop
8918 % \end{macrocode}
8919 % \end{variable}
8920 % \end{macro}
8921 %
8922 % \begin{macro}{\@@_patch_tuenc_composite:}
8923 % \changes{v3.7.2}{2018/05/02}{修复补丁错误。}
8924 % \tn{DeclareUnicodeComposite} 具有检查字符是否存在的功能,
8925 % 当符号命令紧跟在 CJK 字符类后面时,需要使字体回到西文状态
8926 % \begin{macrocode}
8927 \cs_new_protected:Npn \xeCJK_text_composite_patch:
8928 {
8929 \str_if_eq:eeT { \f@encoding } { \UnicodeEncodingName }
8930 { \xeCJK_make_boundary: }
8931 }
8932 % \end{macrocode}
8933 % 注意 \cs{xeCJK_text_composite_patch:} 可能会结束分组,从而导致 |##1| 没有定义时是
8934 % \tn{undefined} 而不是 \tn{relax},所以不能将它与 \tn{relax} 作比较。
8935 % \begin{macrocode}
8936 \cs_new_protected:Npn \@@_patch_tuenc_composite:
8937 {
8938 \cs_set_nopar:Npn \@text@composite@x
8939 {
8940 \xeCJK_text_composite_patch:
8941 \cs_if_exist_use:NF
8942 }
8943 }
8944 % \end{macrocode}
8945 % \end{macro}
8946 %
8947 % \begin{macro}{\@@_patch_tuenc_accent:}
8948 % \tn{add@unicode@accent} 定义最后用于截断数字展开的 \tn{relax} 会造成边界,可能会影响组合标记。
8949 % \begin{macrocode}
8950 \group_begin:
8951 \char_set_catcode_other:n { "A0 }
8952 \cs_new_protected:Npn \@@_patch_tuenc_accent:
8953 {
8954 \cs_set_protected_nopar:Npn \add@unicode@accent ##1 ##2
8955 {
8956 \tl_if_blank:nTF { ##2 } { ^^a0 } { ##2 }
8957 \tex_Uchar:D \tex_numexpr:D ##1 \scan_stop:
8958 }
8959 }
8960 \group_end:
8961 % \end{macrocode}
8962 % \end{macro}
8963 %
8964 % \begin{macro}{\@@_patch_middle_dot:}
8965 % \begin{variable}{\c_@@_middle_dot_prop}
8966 % \changes{v3.2.9}{2013/12/08}
8967 % {完整处理 \file{encguide.pdf} 的编码符号表中,与旧编码的 \texttt{U+00B7} 冲突。}
8968 % 常被用作中文间隔号的 \texttt{U+00B7} 与 T1 等旧字体编码下定义的符号命令冲突。
8969 % 在 \file{encguide.pdf} 的编码符号表中,如下定义有冲突。
8970 % \begin{verbatim}
8971 % \DeclareTextComposite{\r}{T1}{u}{183}
8972 % \DeclareTextSymbol{\cyrchvcrs}{T2A}{183}
8973 % \DeclareTextSymbol{\cyrchldsc}{T2B}{183}
8974 % \DeclareTextSymbol{\cyrabhha}{T2C}{183}
8975 % \DeclareTextSymbol\textvibyy{T3}{183}
8976 % \DeclareTextComposite{\B}{T4}{t}{183}
8977 % \DeclareTextComposite{\`}{T5}{\ecircumflex}{183}
8978 % \DeclareTextDoubleComposite{\`}{T5}{\^}{e}{183}
8979 % \DeclareTextSymbol{\textperiodcentered}{TS1}{183}
8980 % \DeclareTextSymbol{\cyrchldsc}{X2}{183}
8981 % \DeclareTextSymbol{\textperiodcentered}{LY1}{183}
8982 % \end{verbatim}
8983 % LGR 编码的符号表有 \texttt{183} 号字符,但在 \file{lgrenc.def} 中未找到相应的
8984 % 符号命令。
8985 % \begin{macrocode}
8986 \prop_const_from_keyval:Nn \c_@@_middle_dot_prop
8987 {
8988 T2A = \cyrchvcrs ,
8989 T2B = \cyrchldsc ,
8990 T2C = \cyrabhha ,
8991 X2 = \cyrchldsc ,
8992 TS1 = \textperiodcentered ,
8993 LY1 = \textperiodcentered ,
8994 T1 = \r u ,
8995 T4 = \B t ,
8996 T5 = \` \ecircumflex
8997 }
8998 \@@_at_end_preamble:n { \@@_patch_middle_dot: }
8999 \cs_new_protected:Npn \@@_patch_middle_dot:
9000 {
9001 \prop_map_inline:Nn \c_@@_middle_dot_prop
9002 { \@@_patch_middle_dot:nw { ##1 } ##2 \q_stop }
9003 \@@_patch_ambiguous_char:nNn { T5 } \` { \^ - e }
9004 }
9005 \cs_new_protected:Npn \@@_patch_middle_dot:nw #1#2#3 \q_stop
9006 {
9007 \tl_if_empty:nTF {#3}
9008 { \@@_patch_ambiguous_char:nN {#1} #2 }
9009 { \@@_patch_ambiguous_char:nNn {#1} #2 {#3} }
9010 }
9011 % \end{macrocode}
9012 % \pkg{pifont} 宏包的符号 |\ding{183}| 也有冲突。
9013 % \begin{macrocode}
9014 \@@_package_hook:nn { pifont }
9015 {
9016 \RenewDocumentCommand \Pifont { m }
9017 { \makexeCJKinactive \usefont { U } {#1} { m } { n } }
9018 }
9019 % \end{macrocode}
9020 % \end{variable}
9021 % \end{macro}
9022 %
9023 % \changes{v3.8.3}{2020/04/09}{兼容 \pkg{unicode-math} 和 \opt{CJKmath} 选项。}
9024 %
9025 % \begin{macro}{\@@_save_um_char:, \@@_save_um_char:}
9026 % 兼容 \pkg{unicode-math} 和 \opt{CJKmath} 选项,
9027 % 避免将一些中西文混用的标点设置为 CJK 字体。
9028 % \begin{macrocode}
9029 \@@_package_hook:nn { unicode-math }
9030 {
9031 \prop_const_from_keyval:Nn \c_@@_um_ambiguous_char_prop
9032 {
9033 "00B7 = \cdotp ,
9034 "2025 = \enleadertwodots ,
9035 "2026 = \unicodeellipsis
9036 }
9037 \cs_new_protected:Npn \@@_save_um_char:
9038 {
9039 \cs_set_protected:Npx \@@_restore_um_char:
9040 {
9041 \prop_map_function:NN
9042 \c_@@_um_ambiguous_char_prop
9043 \@@_restore_um_char_aux:nn
9044 }
9045 }
9046 \cs_new_eq:NN \@@_restore_um_char: \prg_do_nothing:
9047 \cs_new:Npn \@@_restore_um_char_aux:nn #1#2
9048 {
9049 \@@_gset_mathcodenum:nn
9050 { \int_value:w #1 }
9051 { \int_value:w \tex_Umathcodenum:D #1 }
9052 }
9053 \cs_new_protected:Npn \@@_gset_mathcodenum:nn #1#2
9054 {
9055 \int_compare:nNnF { \tex_Umathcodenum:D #1 } = {#2}
9056 { \tex_global:D \tex_Umathcodenum:D #1 = #2 ~ }
9057 }
9058 }
9059 % \end{macrocode}
9060 % \end{macro}
9061 %
9062 % \changes{v3.8.5}{2020/06/25}{进一步兼容 \pkg{microtype}。}
9063 %
9064 % \begin{macro}{\@@_patch_microtype_get_slot:}
9065 % 兼容 \pkg{microtype}。
9066 % \begin{macrocode}
9067 \cs_new_protected:Npn \@@_patch_microtype_get_slot:
9068 {
9069 \cs_new_eq:NN \xeCJK@original@get@slot \MT@get@slot@
9070 \cs_set_eq:NN \MT@get@slot@ \xeCJK@microtype@get@slot
9071 \cs_set_eq:NN \MT@warn@unknown@once \use_none:n
9072 }
9073 \cs_new_protected_nopar:Npn \xeCJK@microtype@get@slot
9074 {
9075 \int_compare:nNnT \MT@char < \c_zero_int
9076 { \@@_get_ambiguous_slot: }
9077 \xeCJK@original@get@slot
9078 }
9079 \cs_new_protected:Npn \@@_get_ambiguous_slot:
9080 {
9081 \prop_get:NeNT \c_@@_ambiguous_slot_prop
9082 { \MT@encoding - \tex_the:D \MT@toks } \l_@@_tmp_tl
9083 { \cs_set_eq:NN \MT@char \l_@@_tmp_tl }
9084 }
9085 \cs_new_protected:Npn \xeCJK@microtype@restore@pickupfont
9086 { \@@_gadd_font_initial_hook:n { \MT@ltx@pickupfont } }
9087 \@@_package_hook:nn { microtype }
9088 {
9089 \cs_if_free:NF \MT@get@slot@
9090 { \@@_patch_microtype_get_slot: }
9091 \MT@addto@setup { \xeCJK@microtype@restore@pickupfont }
9092 }
9093 % \end{macrocode}
9094 % \end{macro}
9095 %
9096 % 简单处理与 \pkg{hyperref} 宏包的兼容问题。
9097 % \begin{macrocode}
9098 \@@_package_hook:nn { hyperref }
9099 {
9100 \pdfstringdefDisableCommands
9101 {
9102 \@@_gobble_CJKfamily:
9103 \xeCJK_cs_clear:N \@@_inactive_group_begin:
9104 \xeCJK_cs_clear:N \@@_inactive_group_end:
9105 \xeCJK_cs_clear:N \makexeCJKinactive
9106 \xeCJK_cs_clear:N \xeCJK_text_composite_patch:
9107 }
9108 }
9109 % \end{macrocode}
9110 %
9111 % \changes{v3.1.0}{2012/11/13}{取消 \tn{cprotect} 的外部宏限制。}
9112 % 当探测到 \pkg{cprotect} 宏包被引入时,则取消 \tn{cprotect} 宏的 \tn{outer} 定义。
9113 % \begin{macrocode}
9114 \@@_package_hook:nn { cprotect }
9115 {
9116 \cs_if_free:NF \icprotect
9117 { \exp_after:wN \tex_let:D \cs:w cprotect \cs_end: \icprotect }
9118 }
9119 % \end{macrocode}
9120 %
9121 % \changes{v3.2.11}{2014/03/14}{删除 \tn{xeCJKcaption}。}
9122 % \changes{v3.8.0}{2020/02/09}{删除 \pkg{CJKfntef} 补丁。}
9123 %
9124 % 在 \pkg{listings} 宏包后自动载入 \pkg{xeCJK-listings}。
9125 % \begin{macrocode}
9126 \@@_package_hook:nn { listings }
9127 { \RequirePackage { xeCJK-listings } }
9128 % \end{macrocode}
9129 %
9130 %
9131 % \changes{v3.3.3}{2015/12/12}{解决与 \pkg{microtype} 宏包的兼容问题。}
9132 % 由于 \pkg{xeCJK} 假装 \pkg{CJK} 已经被引入了,这会可能导致旧版本的 \pkg{everysel} 包判断错误。
9133 % 需要在它们判断之前取消定义。
9134 % \begin{macrocode}
9135 \@@_package_hook:nn { everysel }
9136 {
9137 \cs_if_exist:NF \@EverySelectfont@Legacy
9138 { \cs_undefine:c { ver@CJK . \c_@@_package_ext_tl } }
9139 }
9140 % \end{macrocode}
9141 %
9142 % \changes{v3.2.4}{2013/06/25}{不再使用 \texttt{CJKnumber} 选项,可以在
9143 % \pkg{xeCJK} 之后直接使用 \pkg{CJKnumb} 宏包得到中文数字。}
9144 % \changes{v3.8.7}{2021/06/04}{更好地兼容 \pkg{CJKnumb}。}
9145 %
9146 % \begin{macro}[int]{\CJKaddEncHook}
9147 % 为使用 \pkg{CJKnumb} 宏包而作一些处理。另外 \pkg{CJKnumb} 使用的是传统汉字“萬”
9148 % 和“億”,我们在这里把它们修正为简体字。
9149 % \changes{v3.2.10}{2014/03/01}{使用 \pkg{CJKnumb} 时,让 \tn{Unicode} 有定义。}
9150 % \changes{v3.3.1}{2015/05/08}{应用 \texttt{0.99992} 版的新原语 \tn{Ucharcat}。}
9151 % \begin{macrocode}
9152 \ctex_at_begin_package:nn { CJKnumb }
9153 {
9154 \tl_new:N \l_@@_CJK_version_tl
9155 \tl_set_eq:Nc \l_@@_CJK_version_tl { ver@CJK . \c_@@_package_ext_tl }
9156 \tl_set:cn { ver@CJK . \c_@@_package_ext_tl } { 9999/99/99 }
9157 \cs_new_protected:Npn \CJKaddEncHook #1#2
9158 {
9159 \str_if_eq:nnT {#1} { \CJK@UnicodeEnc }
9160 {
9161 \group_begin:
9162 \cs_set_eq:NN \Unicode \xeCJK_unicode_char:nn
9163 \cs_set_eq:NN \def \xdef
9164 #2
9165 \group_end:
9166 \str_gset:Nn \CJK@tenthousand { ^^^^4e07 }
9167 \str_gset:Nn \CJK@hundredmillion { ^^^^4ebf }
9168 \tl_if_exist:NF \CJK@UnicodeEnc
9169 { \tl_const:Nn \CJK@UnicodeEnc { UTF8 } }
9170 \cs_if_exist:NF \Unicode
9171 { \cs_new_eq:NN \Unicode \xeCJK_unicode_char:nn }
9172 }
9173 }
9174 \cs_new:Npn \xeCJK_unicode_char:nn #1#2
9175 { \tex_Uchar:D \tex_numexpr:D (#1) * 256 + (#2) \scan_stop: }
9176 }
9177 \ctex_at_end_package:nn { CJKnumb }
9178 { \tl_set_eq:cN { ver@CJK . \c_@@_package_ext_tl } \l_@@_CJK_version_tl }
9179 % \end{macrocode}
9180 % \end{macro}
9181 %
9182 % 最后引入本地配置文件。
9183 % \begin{macrocode}
9184 \bool_if:NT \g_@@_config_bool
9185 {
9186 \ExplSyntaxOff
9187 \file_input:n { \g_@@_config_name_tl .cfg }
9188 \ExplSyntaxOn
9189 }
9190 % \end{macrocode}
9191 %
9192 % \begin{macrocode}
9193 %</package>
9194 % \end{macrocode}
9195 %
9196 % \subsection{\pkg{xeCJKfntef}}
9197 %
9198 % \changes{v3.1.1}{2012/12/08}{增加小宏包 \pkg{xeCJKfntef},用于处理下划线的问题。}
9199 % \changes{v3.2.4}{2013/06/23}{修正 \pkg{xeCJKfntef} 与 \pkg{natbib} 等的冲突。}
9200 % \changes{v3.2.14}{2014/10/31}{完善 \tn{varCJKunderline} 的实现。}
9201 % \changes{v3.2.14}{2014/10/31}{解决下划线前后没有 \tn{CJKglue} 或 \tn{CJKecglue} 的问题。}
9202 % \changes{v3.2.14}{2014/11/03}{\pkg{xeCJKfntef} 不再依赖 \pkg{CJKfntef}。}
9203 % \changes{v3.2.15}{2014/11/07}{\pkg{xeCJKfntef} 增加 \texttt{hidden} 选项。}
9204 %
9205 % \begin{macrocode}
9206 %<*fntef>
9207 % \end{macrocode}
9208 %
9209 % \begin{macrocode}
9210 \PassOptionsToPackage { normalem } { ulem }
9211 \DeclareOption* { \PassOptionsToPackage { \CurrentOption } { ulem } }
9212 \ProcessOptions \scan_stop:
9213 % \end{macrocode}
9214 %
9215 % \begin{macrocode}
9216 \RequirePackage { xeCJK }
9217 \RequirePackage { ulem }
9218 % \end{macrocode}
9219 %
9220 % \begin{macrocode}
9221 \addto@hook \UL@hook { \xeCJK_hook_for_ulem: }
9222 % \end{macrocode}
9223 %
9224 % \changes{v3.4.1}{2016/06/03}{新的下划线选项 \texttt{textformat}。}
9225 %
9226 % \begin{macro}[int]{\xeCJK_hook_for_ulem:}
9227 % \changes{v3.1.0}{2012/11/16}{简化对 \pkg{ulem} 宏包的兼容补丁。}
9228 % \changes{v3.1.1}{2012/12/08}{完全处理下划线里的标点符号的有关问题。}
9229 % \begin{macrocode}
9230 \cs_new_protected:Npn \xeCJK_hook_for_ulem:
9231 {
9232 \xeCJK_ulem_detect_node:
9233 \l_@@_ulem_text_format_tl
9234 \bool_if:NF \l_@@_ulem_hook_used_bool
9235 {
9236 \bool_set_true:N \l_@@_ulem_hook_used_bool
9237 \@@_ulem_hook:
9238 }
9239 \xeCJK_ulem_begin_node:
9240 }
9241 \cs_new_protected:Npn \@@_ulem_hook:
9242 {
9243 \@@_ulem_initial:
9244 \bool_if:NT \l_@@_ulem_subtract_bool
9245 {
9246 \xeCJK_swap_cs:NN \UL@leaders \xeCJK_ulem_leaders:
9247 \cs_set_eq:NN \@@_ulem_var_leaders: \xeCJK_ulem_var_leaders:
9248 \cs_set_eq:NN \xeCJK_ulem_right_skip: \@@_ulem_right_skip:
9249 }
9250 \bool_if:NT \l_@@_ulem_hidden_bool
9251 { \cs_set_eq:NN \UL@putbox \@@_ulem_hidden_box: }
9252 \bool_if:NTF \l_@@_ulem_skip_bool
9253 {
9254 \cs_set_eq:NN \@@_ulem_putbox: \UL@putbox
9255 \cs_set_eq:NN \@@_ulem_hskip_aux:n \xeCJK_ulem_hskip:n
9256 }
9257 {
9258 \xeCJK_swap_cs:NN \@@_punct_hskip:n \@@_ulem_punct_hskip:n
9259 \xeCJK_cs_clear:N \@@_ulem_skip_punct_begin:
9260 \xeCJK_cs_clear:N \@@_ulem_skip_punct_end:
9261 }
9262 \xeCJK_glue_to_skip:nN
9263 {
9264 \cs_set_eq:NN \ \tex_space:D
9265 \cs_set_eq:NN \penalty \tex_penalty:D
9266 \cs_set_eq:NN \hskip \skip_horizontal:N
9267 \CJKglue
9268 } \l_@@_ccglue_skip
9269 \xeCJK_glue_to_skip:nN
9270 {
9271 \cs_set_eq:NN \ \tex_space:D
9272 \cs_set_eq:NN \penalty \tex_penalty:D
9273 \cs_set_eq:NN \hskip \skip_horizontal:N
9274 \CJKecglue
9275 } \l_@@_ecglue_skip
9276 \xeCJK_glue_to_skip:nN { \xeCJK_space_glue: } \l_@@_space_skip
9277 \cs_set_protected:Npn \CJKglue
9278 { \@@_ulem_glue:n \l_@@_ccglue_skip }
9279 \cs_set_protected:Npn \CJKecglue
9280 { \@@_ulem_glue:n \l_@@_ecglue_skip }
9281 \cs_set_protected:Npn \xeCJK_space_glue:
9282 { \@@_ulem_glue:n \l_@@_space_skip }
9283 \cs_set_eq:NN \xeCJK_punct_node:N \use_none:n
9284 \cs_set_eq:NN \xeCJK_if_last_punct:TF \use_ii:nn
9285 \keys_set:nn { xeCJK / options }
9286 { CheckFullRight = false , xCJKecglue = false }
9287 }
9288 \skip_new:N \l_@@_space_skip
9289 \bool_new:N \l_@@_ulem_hook_used_bool
9290 % \end{macrocode}
9291 % \end{macro}
9292 %
9293 % \begin{macro}[int]{\UL@word,\xeCJK_ulem_word:nw}
9294 % 修改 \tn{UL@word},目的是取得分组中的 \tn{UL@leadtype},以便加入 \cs{xeCJK_ulem_right_skip:}。
9295 % \begin{macrocode}
9296 \cs_new_protected:Npn \xeCJK_ulem_word:nw #1 ~
9297 {
9298 \@@_ulem_start:w #1 ~
9299 \exp_after:wN \if_meaning:w \exp_after:wN \UL@end #1
9300 \exp_after:wN \@@_ulem_end:
9301 \else:
9302 \exp_after:wN \@@_ulem_loop:nw
9303 \fi:
9304 }
9305 \cs_new_protected:Npn \@@_ulem_end:
9306 {
9307 \c_group_end_token
9308 \c_group_end_token
9309 \tex_unskip:D \tex_unskip:D \tex_unskip:D
9310 \xeCJK_ulem_right_skip:
9311 \xeCJK_ulem_group_end:
9312 \xeCJK_ulem_right_node:
9313 \int_set:Nn \tex_spacefactor:D { \UL@spfactor }
9314 }
9315 \cs_new_protected:Npn \@@_ulem_loop:nw
9316 {
9317 \reverse_if:N \if_mode_math:
9318 \reverse_if:N \if_dim:w \tex_lastskip:D = \c_zero_dim
9319 \skip_gset_eq:NN \UL@skip \tex_lastskip:D
9320 \tex_unskip:D
9321 \UL@stop \UL@leaders
9322 \fi:
9323 \fi:
9324 \xeCJK_ulem_word:nw \prg_do_nothing:
9325 }
9326 \cs_new_protected:Npn \@@_ulem_start:w
9327 { \exp_after:wN \UL@start }
9328 \cs_set_eq:NN \UL@word \xeCJK_ulem_word:nw
9329 % \end{macrocode}
9330 % \end{macro}
9331 %
9332 % \begin{macro}[int]{\xeCJK_ulem_left:, \xeCJK_ulem_detect_node:}
9333 % 在下划线开始之前探测之前的 \texttt{node},以便随后插入 \tn{CJKglue} 或 \tn{CJKecglue}。
9334 % \begin{macrocode}
9335 \cs_new_protected:Npn \xeCJK_ulem_left:
9336 {
9337 \xeCJK_ulem_left_node:
9338 \xeCJK_make_group_tag:
9339 }
9340 \cs_new_eq:NN \xeCJK_ulem_left_node: \prg_do_nothing:
9341 \cs_new_protected:Npn \xeCJK_ulem_detect_node:
9342 {
9343 \scan_stop:
9344 \dim_compare:nNnTF \tex_lastkern:D = \c_zero_dim
9345 {
9346 \xeCJK_cs_clear:N \xeCJK_ulem_left_node:
9347 \xeCJK_cs_clear:N \xeCJK_ulem_begin_node:
9348 \cs_set_eq:NN \@@_ulem_hskip:n \xeCJK_ulem_hskip:n
9349 }
9350 {
9351 \dim_set_eq:NN \l_@@_tmp_dim \tex_lastkern:D
9352 \tex_unkern:D
9353 \dim_compare:nNnTF \tex_lastkern:D = { - \l_@@_tmp_dim }
9354 {
9355 \tex_unkern:D
9356 \cs_set_protected:Npx \xeCJK_ulem_left_node:
9357 {
9358 \tex_kern:D - \dim_use:N \l_@@_tmp_dim \exp_stop_f:
9359 \tex_kern:D \dim_use:N \l_@@_tmp_dim \exp_stop_f:
9360 }
9361 \cs_set_protected:Npn \xeCJK_ulem_begin_node:
9362 { { \xeCJK_make_node:n { ulem-begin } } }
9363 \cs_set_eq:NN \@@_ulem_hskip:n \@@_ulem_hskip_first:n
9364 }
9365 {
9366 \tex_kern:D \l_@@_tmp_dim
9367 \xeCJK_cs_clear:N \xeCJK_ulem_left_node:
9368 \xeCJK_cs_clear:N \xeCJK_ulem_begin_node:
9369 \cs_set_eq:NN \@@_ulem_hskip:n \xeCJK_ulem_hskip:n
9370 }
9371 }
9372 }
9373 \xeCJK_declare_node:n { ulem-begin }
9374 \cs_new_eq:NN \xeCJK_ulem_begin_node: \prg_do_nothing:
9375 % \end{macrocode}
9376 % \end{macro}
9377 %
9378 % \begin{macro}{\@@_ulem_hskip_first:n, \xeCJK_ulem_hskip:n}
9379 % 如果第一次调用的 \tn{CJKglue} 或 \tn{CJKecglue} 由下划线中的第一个文字和之前的
9380 % 内容产生,就不用画下划线。
9381 % \begin{macrocode}
9382 \cs_new_protected:Npn \@@_ulem_hskip_first:n #1
9383 {
9384 \xeCJK_if_last_node:nTF { ulem-begin }
9385 {
9386 \xeCJK_remove_node:
9387 \skip_horizontal:n {#1}
9388 }
9389 { \xeCJK_ulem_hskip:n {#1} }
9390 \cs_set_eq:NN \@@_ulem_hskip:n \xeCJK_ulem_hskip:n
9391 }
9392 \cs_new_eq:NN \@@_ulem_hskip:n \@@_ulem_hskip_first:n
9393 \cs_new_protected:Npn \xeCJK_ulem_hskip:n #1
9394 { { \skip_set:Nn \UL@skip {#1} \UL@leaders } }
9395 % \end{macrocode}
9396 % \end{macro}
9397 %
9398 % \begin{macro}[int]{\xeCJK_ulem_right:, \xeCJK_ulem_right_node:}
9399 % 在下划线最后的位置保存 \texttt{node}。
9400 % \begin{macrocode}
9401 \cs_new_protected:Npn \xeCJK_ulem_right:
9402 {
9403 \scan_stop:
9404 \dim_compare:nNnTF \tex_lastkern:D = \c_zero_dim
9405 { \xeCJK_cs_gclear:N \xeCJK_ulem_right_node: }
9406 {
9407 \dim_compare:nNnTF \tex_lastkern:D = { 3sp }
9408 { \xeCJK_cs_gclear:N \xeCJK_ulem_right_node: }
9409 {
9410 \exp_args:NNo \tex_unkern:D
9411 \@@_ulem_right_aux:n { \dim_use:N \tex_lastkern:D }
9412 }
9413 }
9414 }
9415 \cs_new_protected:Npn \@@_ulem_right_aux:n #1
9416 {
9417 \dim_compare:nNnTF \tex_lastkern:D = { - #1 }
9418 {
9419 \tex_unkern:D
9420 \cs_gset_protected:Npn \xeCJK_ulem_right_node:
9421 {
9422 \tex_kern:D - #1 \exp_stop_f:
9423 \tex_kern:D #1 \exp_stop_f:
9424 }
9425 \tl_gset:Nx \UL@spfactor { \int_use:N \tex_spacefactor:D }
9426 }
9427 {
9428 \tex_kern:D #1 \exp_stop_f:
9429 \xeCJK_cs_gclear:N \xeCJK_ulem_right_node:
9430 }
9431 }
9432 \cs_new_eq:NN \xeCJK_ulem_right_node: \prg_do_nothing:
9433 % \end{macrocode}
9434 % \end{macro}
9435 %
9436 % \begin{macro}[int]{\xeCJK_ulem_var_leaders:}
9437 % 第一次画下划线时,不需要向左平移 \tn{UL@pixel},让左侧有间距。
9438 % \begin{macrocode}
9439 \cs_new_protected:Npn \xeCJK_ulem_leaders:
9440 { \@@_ulem_var_leaders: }
9441 \cs_new_protected:Npn \xeCJK_ulem_var_leaders:
9442 {
9443 \scan_stop:
9444 \skip_if_eq:nnF { \UL@skip } { \c_zero_skip }
9445 {
9446 \UL@leadtype \skip_horizontal:n { \UL@skip + \UL@pixel }
9447 \skip_horizontal:n { - \UL@pixel }
9448 \cs_gset_eq:NN \@@_ulem_var_leaders: \xeCJK_ulem_leaders:
9449 }
9450 }
9451 \cs_new_eq:NN \@@_ulem_var_leaders: \xeCJK_ulem_var_leaders:
9452 % \end{macrocode}
9453 % \end{macro}
9454 %
9455 % \begin{macro}[int]{\xeCJK_ulem_right_skip:}
9456 % 在下划线完全画好之后,我们检测最后的情况。用 \tn{unskip} 去掉最后一个下划线,再
9457 % 重新画一个减少 \tn{UL@pixel} 的。
9458 % \begin{macrocode}
9459 \cs_new_eq:NN \xeCJK_ulem_right_skip: \prg_do_nothing:
9460 \cs_new_protected:Npn \@@_ulem_right_skip:
9461 {
9462 \int_case:nn { \tex_lastnodetype:D }
9463 {
9464 { \c_@@_hlist_node } { \@@_ulem_right_skip_hbox: }
9465 { \c_@@_glue_node } { \@@_ulem_right_skip_glue: }
9466 { \c_@@_penalty_node } { \@@_ulem_right_skip_penalty: }
9467 }
9468 }
9469 \cs_new_protected:Npn \@@_ulem_right_skip_hbox:
9470 {
9471 \box_set_to_last:N \l_@@_tmp_box
9472 \@@_if_last_kern:TF
9473 { \@@_ulem_right_skip_kern: }
9474 { \@@_ulem_right_skip_glue: }
9475 \box_use_drop:N \l_@@_tmp_box
9476 }
9477 \cs_new_protected:Npn \@@_ulem_right_skip_kern:
9478 {
9479 \dim_set:Nn \l_@@_tmp_dim { - \box_wd:N \l_@@_tmp_box }
9480 \dim_compare:nNnT \tex_lastkern:D = \l_@@_tmp_dim
9481 {
9482 \tex_unkern:D
9483 \@@_ulem_right_skip_glue:
9484 \tex_kern:D \l_@@_tmp_dim
9485 }
9486 }
9487 \cs_new_protected:Npn \@@_ulem_right_skip_glue:
9488 {
9489 \skip_if_eq:nnT { \tex_lastskip:D } { - \UL@pixel }
9490 {
9491 \tex_unskip:D
9492 \skip_set:Nn \l_@@_tmp_skip { \tex_lastskip:D - \UL@pixel }
9493 \tex_unskip:D
9494 \UL@leadtype \skip_horizontal:N \l_@@_tmp_skip
9495 }
9496 }
9497 \cs_new_protected:Npn \@@_ulem_right_skip_penalty:
9498 {
9499 \int_set_eq:NN \l_@@_tmp_int \tex_lastpenalty:D
9500 \tex_unpenalty:D
9501 \@@_if_last_hlist:T
9502 { \@@_ulem_right_skip_hbox: }
9503 \tex_penalty:D \l_@@_tmp_int
9504 }
9505 % \end{macrocode}
9506 % \end{macro}
9507 %
9508 % \changes{v3.8.3}{2020/04/23}{\opt{hidden} 选项保留原内容的高度和深度。}
9509 %
9510 % \begin{macro}{\@@_ulem_hidden_box:}
9511 % 只画线,不输出盒子。
9512 % \begin{macrocode}
9513 \cs_new_protected:Npn \@@_ulem_hidden_box:
9514 {
9515 \tl_if_empty:NF \UL@start
9516 {
9517 \box_set_ht:Nn \l_@@_hidden_box { \box_ht:N \UL@box }
9518 \box_set_dp:Nn \l_@@_hidden_box { \box_dp:N \UL@box }
9519 \box_use:N \l_@@_hidden_box
9520 \xeCJK_no_break:
9521 \xeCJK_ulem_hskip:n { \box_wd:N \UL@box }
9522 \box_use:N \l_@@_hidden_box
9523 }
9524 }
9525 \box_new:N \l_@@_hidden_box
9526 \hbox_set:Nn \l_@@_hidden_box { }
9527 % \end{macrocode}
9528 % \end{macro}
9529 %
9530 % \begin{macro}{\@@_ulem_skip_punct_begin:,\@@_ulem_skip_punct_end:}
9531 % 让下划线跳过标点符号的设置。
9532 % \begin{macrocode}
9533 \cs_new_protected:Npn \@@_ulem_skip_punct_begin:
9534 {
9535 \cs_set_eq:NN \UL@putbox \@@_ulem_skip_putbox:
9536 \cs_set_eq:NN \xeCJK_ulem_hskip:n \skip_horizontal:n
9537 }
9538 \cs_new_protected:Npn \@@_ulem_skip_punct_end:
9539 {
9540 \cs_set_eq:NN \UL@putbox \@@_ulem_putbox:
9541 \cs_set_eq:NN \xeCJK_ulem_hskip:n \@@_ulem_hskip_aux:n
9542 }
9543 \cs_new_eq:NN \@@_ulem_putbox: \UL@putbox
9544 \cs_new_protected:Npn \@@_ulem_skip_putbox:
9545 {
9546 \tl_if_empty:NF \UL@start
9547 { \box_use_drop:N \UL@box }
9548 }
9549 % \end{macrocode}
9550 % \end{macro}
9551 %
9552 % \begin{macro}{\@@_ulem_initial:}
9553 % 这里的设置是为了在下划线状态下,下划线可以自动跳过全角标点符号和正确的在它们
9554 % 前/后断行,并且与行首行末对齐。
9555 % \begin{macrocode}
9556 \cs_new_protected:Npn \@@_ulem_initial:
9557 {
9558 \@@_ulem_swap_cs:NN
9559 \xeCJK_FullLeft_and_Default: \@@_ulem_FullLeft_and_Default:
9560 \xeCJK_FullLeft_and_CJK: \@@_ulem_FullLeft_and_CJK:
9561 \xeCJK_FullLeft_and_Boundary: \@@_ulem_FullLeft_and_Boundary:
9562 \xeCJK_FullRight_and_Default: \@@_ulem_FullRight_and_Default:
9563 \xeCJK_FullRight_and_CJK: \@@_ulem_FullRight_and_CJK:
9564 \xeCJK_FullRight_and_Boundary: \@@_ulem_FullRight_and_Boundary:
9565 \xeCJK_CJK_and_CJK:N \@@_ulem_CJK_and_CJK:N
9566 \xeCJK_CJK_and_Boundary:w \@@_ulem_CJK_and_Boundary:w
9567 \xeCJK@fix@penalty \@@_ulem_fix_penalty:
9568 \@@_punct_breakable_kern:n \@@_ulem_punct_breakable_kern:n
9569 \@@_Default_and_FullLeft_glue:N \@@_ulem_Default_and_FullLeft_glue:N
9570 \@@_Default_and_FullRight_glue:N \@@_ulem_Default_and_FullRight_glue:N
9571 \@@_CJK_and_FullLeft_glue:N \@@_ulem_CJK_and_FullLeft_glue:N
9572 \@@_CJK_and_FullRight_glue:N \@@_ulem_CJK_and_FullRight_glue:N
9573 \@@_Boundary_and_FullLeft_glue:N \@@_ulem_Boundary_and_FullLeft_glue:N
9574 \q_recursion_tail \q_nil \q_recursion_stop
9575 \seq_map_inline:Nn \g_@@_CJK_sub_class_seq
9576 {
9577 \seq_map_inline:Nn \g_@@_CJK_sub_class_seq
9578 {
9579 \str_if_eq:nnTF {##1} {####1}
9580 {
9581 \xeCJK_inter_class_toks:nnn { CJK } { CJK/##1 }
9582 { \@@_ulem_between_CJK_blocks:nnN { CJK } {##1} }
9583 \xeCJK_inter_class_toks:nnn { CJK/##1 } { CJK/##1 }
9584 { \@@_ulem_between_CJK_blocks:nnN { CJK } {##1} }
9585 }
9586 {
9587 \xeCJK_inter_class_toks:nnn { CJK/##1 } { CJK/####1 }
9588 { \@@_ulem_between_CJK_blocks:nnN {##1} {####1} }
9589 }
9590 }
9591 }
9592 }
9593 \cs_new_protected:Npn \@@_ulem_swap_cs:NN #1#2
9594 {
9595 \quark_if_recursion_tail_stop:N #1
9596 \xeCJK_swap_cs:NN #1#2
9597 \@@_ulem_swap_cs:NN
9598 }
9599 % \end{macrocode}
9600 % \end{macro}
9601 %
9602 % \changes{v3.1.2}{2012/12/27}{解决在下划线状态下使用 \tn{makebox} 时的错误。}
9603 %
9604 % \begin{macro}[int]{\xeCJK_if_ulem_patch:TF}
9605 % 在下划线状态下,\pkg{ulem} 宏包在数学模式或者盒子中使用 \tn{UL@hrest} 恢复
9606 % \verb*|\ | 等的定义,此时不需要使用 \tn{UL@stop} 和 \tn{UL@start} 来断开下划线而
9607 % 产生断点。
9608 % \begin{macrocode}
9609 \cs_new:Npn \xeCJK_if_ulem_patch:TF
9610 {
9611 \if_meaning:w \ \LA@space
9612 \exp_after:wN \use_ii:nn
9613 \else:
9614 \exp_after:wN \use_i:nn
9615 \fi:
9616 }
9617 % \end{macrocode}
9618 % \end{macro}
9619 %
9620 % \changes{v3.9.1}{2022/07/28}{修复下划线中数学公式的错误处理。}
9621 %
9622 % \begin{macro}{\@@_ulem_CJK_and_Boundary:w}
9623 % \begin{macrocode}
9624 \cs_new_protected:Npn \@@_ulem_CJK_and_Boundary:w
9625 {
9626 \xeCJK_if_ulem_patch:TF
9627 {
9628 \xeCJK_peek_catcode_ignore_spaces:NTF \c_math_toggle_token
9629 { \xeCJK_class_group_end: \CJKecglue }
9630 {
9631 \bool_if:NTF \l_@@_peek_ignore_spaces_bool
9632 { \@@_ulem_peek_math:w }
9633 { \@@_ulem_group_end:n { CJK } }
9634 }
9635 }
9636 { \@@_ulem_CJK_and_Boundary:w }
9637 }
9638 \cs_new_protected:Npn \@@_ulem_group_end:n #1
9639 {
9640 \xeCJK_class_group_end: \UL@stop
9641 \UL@start { \xeCJK_make_node:n {#1} }
9642 \xeCJK_make_group_tag:
9643 }
9644 % \end{macrocode}
9645 % \end{macro}
9646 %
9647 % \begin{macro}{\@@_ulem_peek_math:w}
9648 % 用于处理下划线中,汉字与 |$| 之间有空格的情况^^A
9649 % \footnote{\url{https://github.com/CTeX-org/ctex-kit/issues/614}}。
9650 % \begin{macrocode}
9651 \cs_new_protected:Npn \@@_ulem_peek_math:w
9652 {
9653 \cs_set_eq:NN \@@_ulem_start:w \@@_ulem_exp_stop:w
9654 \exp_after:wN \peek_after:Nw
9655 \exp_after:wN \@@_ulem_peek_math_branches:w
9656 \exp:w \exp_end_continue_f:w
9657 }
9658 \cs_new_protected:Npn \@@_ulem_peek_math_branches:w
9659 {
9660 \token_if_math_toggle:NTF \l_peek_token
9661 { \xeCJK_class_group_end: \CJKecglue }
9662 { \@@_ulem_group_end:n { CJK-space } }
9663 }
9664 \cs_new_protected:Npn \@@_ulem_exp_stop:w
9665 {
9666 \cs_if_eq:NNTF \UL@start \@empty
9667 { \exp_after:wN \exp_stop_f: }
9668 { \exp_after:wN \UL@start }
9669 }
9670 % \end{macrocode}
9671 % \end{macro}
9672 %
9673 % \begin{macro}{\@@_ulem_fix_penalty:}
9674 % \begin{macrocode}
9675 \cs_new_protected:Npn \@@_ulem_fix_penalty:
9676 {
9677 \xeCJK_if_ulem_patch:TF
9678 { \fix@penalty }
9679 { \@@_ulem_fix_penalty: }
9680 }
9681 % \end{macrocode}
9682 % \end{macro}
9683 %
9684 % \begin{macro}{\@@_ulem_CJK_and_CJK:N}
9685 % \begin{macrocode}
9686 \cs_new_protected:Npn \@@_ulem_CJK_and_CJK:N
9687 {
9688 \xeCJK_if_ulem_patch:TF
9689 {
9690 \xeCJK_class_group_end:
9691 \UL@stop \@@_ulem_ccglue: \UL@start
9692 \@@_ulem_class_group_begin:
9693 \xeCJK_select_font:
9694 \xeCJK_fallback_symbol:NN
9695 \CJKsymbol
9696 }
9697 { \@@_ulem_CJK_and_CJK:N }
9698 }
9699 % \end{macrocode}
9700 % \end{macro}
9701 %
9702 % \begin{macro}{\@@_ulem_class_group_begin:}
9703 % \begin{macrocode}
9704 \cs_new_protected:Npn \@@_ulem_class_group_begin:
9705 {
9706 \xeCJK_class_group_begin:
9707 \xeCJK_clear_Boundary_and_CJK_toks:
9708 }
9709 % \end{macrocode}
9710 % \end{macro}
9711 %
9712 % \begin{macro}{\@@_ulem_between_CJK_blocks:nnN}
9713 % \begin{macrocode}
9714 \cs_new_protected:Npn \@@_ulem_between_CJK_blocks:nnN #1#2
9715 {
9716 \xeCJK_if_ulem_patch:TF
9717 {
9718 \xeCJK_class_group_end:
9719 \UL@stop \@@_ulem_ccglue: \UL@start
9720 \xeCJK_class_group_begin:
9721 \xeCJK_clear_Boundary_and_CJK_toks:
9722 \@@_switch_font:nn {#1} {#2}
9723 \xeCJK_fallback_symbol:NN
9724 \CJKsymbol
9725 }
9726 {
9727 \skip_horizontal:N \l_@@_ccglue_skip
9728 \@@_switch_font:nn {#1} {#2}
9729 \xeCJK_fallback_symbol:NN
9730 \CJKsymbol
9731 }
9732 }
9733 % \end{macrocode}
9734 % \end{macro}
9735 %
9736 % \begin{macro}{\@@_ulem_Default_and_FullLeft_glue:N}
9737 % \begin{macrocode}
9738 \cs_new_protected:Npn \@@_ulem_Default_and_FullLeft_glue:N #1
9739 {
9740 \xeCJK_if_ulem_patch:TF
9741 {
9742 \UL@stop
9743 \@@_ulem_skip_punct_begin:
9744 \@@_punct_glue:NN \c_@@_left_tl #1
9745 \UL@start
9746 }
9747 { \@@_ulem_Default_and_FullLeft_glue:N #1 }
9748 }
9749 % \end{macrocode}
9750 % \end{macro}
9751 %
9752 % \begin{macro}{\@@_ulem_Boundary_and_FullLeft_glue:N}
9753 % \begin{macrocode}
9754 \cs_new_protected:Npn \@@_ulem_Boundary_and_FullLeft_glue:N #1
9755 {
9756 \xeCJK_if_ulem_patch:TF
9757 {
9758 \UL@stop
9759 \@@_ulem_skip_punct_begin:
9760 \@@_punct_glue:NN \c_@@_left_tl #1
9761 \UL@start
9762 }
9763 { \@@_ulem_Boundary_and_FullLeft_glue:N #1 }
9764 }
9765 % \end{macrocode}
9766 % \end{macro}
9767 %
9768 % \begin{macro}{\@@_ulem_CJK_and_FullLeft_glue:N}
9769 % \begin{macrocode}
9770 \cs_new_protected:Npn \@@_ulem_CJK_and_FullLeft_glue:N #1
9771 {
9772 \xeCJK_if_ulem_patch:TF
9773 {
9774 \xeCJK_class_group_end:
9775 \UL@stop
9776 \@@_ulem_skip_punct_begin:
9777 \@@_ulem_punct_ccglue:
9778 \@@_punct_glue:NN \c_@@_left_tl #1
9779 \UL@start
9780 \@@_ulem_class_group_begin:
9781 \xeCJK_select_punct_font:
9782 }
9783 { \@@_ulem_CJK_and_FullLeft_glue:N #1 }
9784 }
9785 % \end{macrocode}
9786 % \end{macro}
9787 %
9788 % \begin{macro}{\@@_ulem_Default_and_FullRight_glue:N}
9789 % \begin{macrocode}
9790 \cs_new_protected:Npn \@@_ulem_Default_and_FullRight_glue:N #1
9791 {
9792 \xeCJK_if_ulem_patch:TF
9793 {
9794 \UL@stop
9795 \@@_ulem_skip_punct_begin:
9796 \@@_punct_if_long:NTF #1
9797 { \xeCJK_allow_break: }
9798 { \xeCJK_no_break: }
9799 \@@_punct_if_middle:NT #1
9800 {
9801 \@@_punct_glue:NN \c_@@_right_tl #1
9802 \@@_punct_rule:NN \c_@@_left_tl #1
9803 }
9804 \UL@start
9805 }
9806 { \@@_ulem_Default_and_FullRight_glue:N #1 }
9807 }
9808 % \end{macrocode}
9809 % \end{macro}
9810 %
9811 % \begin{macro}{\@@_ulem_CJK_and_FullRight_glue:N}
9812 % \changes{v3.2.2}{2013/05/30}{修正下划线不能跳过全角右标点的问题。}
9813 % \begin{macrocode}
9814 \cs_new_protected:Npn \@@_ulem_CJK_and_FullRight_glue:N #1
9815 {
9816 \xeCJK_if_ulem_patch:TF
9817 {
9818 \xeCJK_class_group_end:
9819 \UL@stop
9820 \@@_ulem_skip_punct_begin:
9821 \@@_punct_if_long:NTF #1
9822 { \xeCJK_allow_break: }
9823 { \xeCJK_no_break: }
9824 \@@_punct_if_middle:NT #1
9825 {
9826 \@@_ulem_punct_ccglue:
9827 \@@_punct_glue:NN \c_@@_right_tl #1
9828 \@@_punct_rule:NN \c_@@_left_tl #1
9829 }
9830 \UL@start
9831 \@@_ulem_class_group_begin:
9832 \xeCJK_select_punct_font:
9833 }
9834 { \@@_ulem_CJK_and_FullRight_glue:N #1 }
9835 }
9836 % \end{macrocode}
9837 % \end{macro}
9838 %
9839 % \begin{macro}{\@@_ulem_FullLeft_and_Default:}
9840 % \begin{macrocode}
9841 \cs_new_protected:Npn \@@_ulem_FullLeft_and_Default:
9842 {
9843 \xeCJK_if_ulem_patch:TF
9844 {
9845 \@@_punct_if_middle:NTF \g_@@_last_punct_tl
9846 {
9847 \xeCJK_get_punct_bounds:No \c_@@_left_tl \g_@@_last_punct_tl
9848 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
9849 \xeCJK_class_group_end: \UL@stop \xeCJK_no_break:
9850 \@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
9851 }
9852 { \xeCJK_class_group_end: \UL@stop }
9853 \@@_ulem_skip_punct_end:
9854 \xeCJK_no_break:
9855 \UL@start
9856 }
9857 { \@@_ulem_FullLeft_and_Default: }
9858 }
9859 % \end{macrocode}
9860 % \end{macro}
9861 %
9862 % \begin{macro}{\@@_ulem_FullLeft_and_Boundary:}
9863 % \begin{macrocode}
9864 \cs_new_protected:Npn \@@_ulem_FullLeft_and_Boundary:
9865 {
9866 \xeCJK_if_ulem_patch:TF
9867 {
9868 \@@_punct_if_middle:NTF \g_@@_last_punct_tl
9869 {
9870 \xeCJK_get_punct_bounds:No \c_@@_left_tl \g_@@_last_punct_tl
9871 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
9872 \xeCJK_class_group_end: \UL@stop \xeCJK_no_break:
9873 \@@_punct_glue:NN \c_@@_left_tl \g_@@_last_punct_tl
9874 }
9875 { \xeCJK_class_group_end: \UL@stop }
9876 \@@_ulem_skip_punct_end:
9877 \xeCJK_no_break:
9878 \UL@start
9879 \tex_ignorespaces:D
9880 }
9881 { \@@_ulem_FullLeft_and_Boundary: }
9882 }
9883 % \end{macrocode}
9884 % \end{macro}
9885 %
9886 % \begin{macro}{\@@_ulem_FullLeft_and_CJK:}
9887 % \changes{v3.2.3}{2013/06/04}
9888 % {修正全角左标点后下划线与 \tn{CJKunderdot} 连用时结果不正常的问题。}
9889 % \begin{macrocode}
9890 \cs_new_protected:Npn \@@_ulem_FullLeft_and_CJK:
9891 {
9892 \xeCJK_if_ulem_patch:TF
9893 {
9894 \xeCJK_FullLeft_and_Default:
9895 \@@_ulem_class_group_begin:
9896 \xeCJK_select_font:
9897 }
9898 { \@@_ulem_FullLeft_and_CJK: }
9899 }
9900 % \end{macrocode}
9901 % \end{macro}
9902 %
9903 % \begin{macro}{\@@_ulem_FullRight_and_Default:}
9904 % \begin{macrocode}
9905 \cs_new_protected:Npn \@@_ulem_FullRight_and_Default:
9906 {
9907 \xeCJK_if_ulem_patch:TF
9908 {
9909 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
9910 \xeCJK_class_group_end:
9911 \UL@stop
9912 \@@_punct_glue:NN \c_@@_right_tl \g_@@_last_punct_tl
9913 \@@_ulem_skip_punct_end:
9914 \UL@start
9915 }
9916 { \@@_ulem_FullRight_and_Default: }
9917 }
9918 % \end{macrocode}
9919 % \end{macro}
9920 %
9921 % \begin{macro}{\@@_ulem_FullRight_and_Boundary:}
9922 % \begin{macrocode}
9923 \cs_new_protected:Npn \@@_ulem_FullRight_and_Boundary:
9924 {
9925 \xeCJK_if_ulem_patch:TF
9926 {
9927 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
9928 \xeCJK_class_group_end:
9929 \UL@stop
9930 \@@_punct_glue:NN \c_@@_right_tl \g_@@_last_punct_tl
9931 \@@_ulem_skip_punct_end:
9932 \UL@start
9933 \tex_ignorespaces:D
9934 }
9935 { \@@_ulem_FullRight_and_Boundary: }
9936 }
9937 % \end{macrocode}
9938 % \end{macro}
9939 %
9940 % \begin{macro}{\@@_ulem_FullRight_and_CJK:}
9941 % \begin{macrocode}
9942 \cs_new_protected:Npn \@@_ulem_FullRight_and_CJK:
9943 {
9944 \xeCJK_if_ulem_patch:TF
9945 {
9946 \@@_punct_rule:NN \c_@@_right_tl \g_@@_last_punct_tl
9947 \xeCJK_class_group_end:
9948 \UL@stop
9949 \@@_punct_glue:NN \c_@@_right_tl \g_@@_last_punct_tl
9950 \@@_ulem_punct_ccglue:
9951 \@@_ulem_skip_punct_end:
9952 \UL@start
9953 \@@_ulem_class_group_begin:
9954 \xeCJK_select_font:
9955 }
9956 { \@@_ulem_FullRight_and_CJK: }
9957 }
9958 % \end{macrocode}
9959 % \end{macro}
9960 %
9961 % \begin{macro}{\@@_ulem_punct_hskip:n}
9962 % \begin{macrocode}
9963 \cs_new_protected:Npn \@@_ulem_punct_hskip:n
9964 {
9965 \xeCJK_if_ulem_patch:TF
9966 { \xeCJK_ulem_hskip:n }
9967 { \@@_ulem_punct_hskip:n }
9968 }
9969 % \end{macrocode}
9970 % \end{macro}
9971 %
9972 % \begin{macro}{\@@_ulem_punct_breakable_kern:n}
9973 % \begin{macrocode}
9974 \cs_new_protected:Npn \@@_ulem_punct_breakable_kern:n #1
9975 {
9976 \xeCJK_if_ulem_patch:TF
9977 {
9978 \xeCJK_class_group_end:
9979 \UL@stop \xeCJK_ulem_hskip:n {#1} \UL@start
9980 \@@_ulem_class_group_begin:
9981 \xeCJK_select_punct_font:
9982 }
9983 { \@@_ulem_punct_breakable_kern:n {#1} }
9984 }
9985 % \end{macrocode}
9986 % \end{macro}
9987 %
9988 % \begin{macro}{\@@_ulem_glue:n,\@@_ulem_ccglue:,\@@_ulem_punct_ccglue:}
9989 % 在下划线状态下的分别代替 \tn{CJKglue} 等。
9990 % \begin{macrocode}
9991 \cs_new_protected:Npn \@@_ulem_glue:n #1
9992 {
9993 \xeCJK_if_ulem_patch:TF
9994 {
9995 \tl_if_empty:NTF \l_@@_group_tag_tl
9996 { \UL@stop \@@_ulem_hskip:n {#1} \UL@start }
9997 {
9998 \str_if_eq:eeTF { \l_@@_group_tag_tl } { \c_@@_group_tag_tl }
9999 { \UL@stop \@@_ulem_hskip:n {#1} \UL@start }
10000 { \skip_horizontal:n {#1} }
10001 }
10002 }
10003 { \skip_horizontal:n {#1} }
10004 }
10005 \cs_new_protected:Npn \xeCJK_make_group_tag:
10006 { \tl_set:Nx \l_@@_group_tag_tl { \c_@@_group_tag_tl } }
10007 \tl_new:N \l_@@_group_tag_tl
10008 \tl_const:Nn \c_@@_group_tag_tl
10009 {
10010 T \int_use:N \tex_currentgrouptype:D
10011 L \int_use:N \tex_currentgrouplevel:D
10012 }
10013 \cs_new_protected:Npn \@@_ulem_ccglue:
10014 { { \skip_set_eq:NN \UL@skip \l_@@_ccglue_skip \UL@leaders } }
10015 \cs_new_protected:Npn \@@_ulem_punct_ccglue:
10016 { \@@_punct_hskip:n { \l_@@_ccglue_skip } }
10017 % \end{macrocode}
10018 % \end{macro}
10019 %
10020 % \begin{macro}[int]{\xeCJK_ulem_group_begin:,\xeCJK_ulem_group_end:,\xeCJK_ulem_on:n}
10021 % \begin{macrocode}
10022 \cs_new_protected:Npn \xeCJK_ulem_group_begin:
10023 {
10024 \mode_leave_vertical:
10025 \c_group_begin_token
10026 }
10027 \cs_new_protected:Npn \xeCJK_ulem_group_end:
10028 { \c_group_end_token }
10029 \cs_new_protected:Npn \xeCJK_ulem_on:n
10030 { \ULon }
10031 \cs_new_eq:NN \@@_ulem_on:n \UL@on
10032 \cs_set_protected:Npn \UL@on #1
10033 { \@@_ulem_on:n { \xeCJK_ulem_left: #1 \xeCJK_ulem_right: } }
10034 % \end{macrocode}
10035 % \end{macro}
10036 %
10037 % \begin{macro}{\xeCJKfntefon}
10038 % \changes{v3.2.15}{2014/11/07}{完善选项。}
10039 % 扩展 \tn{ULon} 的参数。
10040 % \begin{macrocode}
10041 \NewDocumentCommand \xeCJKfntefon { s t- s o }
10042 {
10043 \mode_leave_vertical:
10044 \xeCJK_ulem_boot:NNNn #1#2#3 {#4}
10045 \xeCJK_ulem_on:n
10046 }
10047 % \end{macrocode}
10048 % \end{macro}
10049 %
10050 % \begin{macro}{\CJKunderline}
10051 % \begin{macrocode}
10052 \NewDocumentCommand \CJKunderline { s t- s o }
10053 {
10054 \xeCJK_ulem_group_begin:
10055 \xeCJK_fntef_boot:nnNNNn { underline } { uline } #1#2#3 {#4}
10056 \xeCJK_fntef_initial:nnn
10057 { \l_@@_uline_depth_tl }
10058 { \l_@@_uline_sep_tl }
10059 {
10060 \l_@@_uline_format_tl
10061 \tex_vrule:D
10062 height \dim_eval:n { \l_@@_uline_thickness_tl }
10063 depth \c_zero_dim
10064 width .2em
10065 }
10066 \xeCJK_ulem_on:n
10067 }
10068 \NewDocumentCommand \varCJKunderline { }
10069 { \CJKunderline - }
10070 % \end{macrocode}
10071 % \end{macro}
10072 %
10073 % \begin{macro}{\CJKunderwave}
10074 % \begin{macrocode}
10075 \NewDocumentCommand \CJKunderwave { s t- s o }
10076 {
10077 \xeCJK_ulem_group_begin:
10078 \xeCJK_fntef_boot:nnNNNn { underwave } { uwave } #1#2#3 {#4}
10079 \xeCJK_fntef_initial:nnn
10080 { \l_@@_uwave_depth_tl }
10081 { \l_@@_uwave_sep_tl }
10082 { \l_@@_uwave_format_tl \l_@@_uwave_symbol_tl }
10083 \xeCJK_ulem_on:n
10084 }
10085 % \end{macrocode}
10086 % \end{macro}
10087 %
10088 % \begin{macro}{\CJKunderdblline}
10089 % \begin{macrocode}
10090 \NewDocumentCommand \CJKunderdblline { s t- s o }
10091 {
10092 \xeCJK_ulem_group_begin:
10093 \xeCJK_fntef_boot:nnNNNn { underdblline } { udbline } #1#2#3 {#4}
10094 \xeCJK_fntef_initial:nnn
10095 { \l_@@_udbline_depth_tl }
10096 { \l_@@_udbline_sep_tl }
10097 {
10098 \l_@@_udbline_format_tl
10099 \vbox_top:n
10100 {
10101 \tex_hrule:D
10102 height \dim_eval:n { \l_@@_udbline_thickness_tl }
10103 depth \c_zero_dim
10104 width .2em
10105 \tex_kern:D \dim_eval:n { \l_@@_udbline_gap_tl }
10106 \tex_hrule:D
10107 height \dim_eval:n { \l_@@_udbline_thickness_tl }
10108 depth \c_zero_dim
10109 width .2em
10110 }
10111 }
10112 \xeCJK_ulem_on:n
10113 }
10114 % \end{macrocode}
10115 % \end{macro}
10116 %
10117 % \begin{macro}{\CJKsout}
10118 % \begin{macrocode}
10119 \NewDocumentCommand \CJKsout { s t- s o }
10120 {
10121 \xeCJK_ulem_group_begin:
10122 \xeCJK_fntef_boot:nnNNNn { sout } { sout } #1#2#3 {#4}
10123 \xeCJK_fntef_initial:nn
10124 {
10125 \l_@@_sout_format_tl
10126 \tex_vrule:D
10127 height \dim_eval:n { \l_@@_sout_thickness_tl }
10128 depth \c_zero_dim
10129 width .2em
10130 }
10131 {
10132 \box_move_up:nn
10133 { \l_@@_sout_height_tl - \box_ht:N \l_@@_fntef_box / 2 }
10134 { \box_use:N \l_@@_fntef_box }
10135 }
10136 \xeCJK_ulem_on:n
10137 }
10138 % \end{macrocode}
10139 % \end{macro}
10140 %
10141 % \begin{macro}{\CJKxout}
10142 % \begin{macrocode}
10143 \NewDocumentCommand \CJKxout { s t- s o }
10144 {
10145 \xeCJK_ulem_group_begin:
10146 \xeCJK_fntef_boot:nnNNNn { xout } { xout } #1#2#3 {#4}
10147 \xeCJK_fntef_initial:nn
10148 {
10149 \l_@@_xout_format_tl
10150 \tex_kern:D -.1 em $/$
10151 \tex_kern:D -.1 em
10152 }
10153 {
10154 \box_move_up:nn
10155 { \box_dp:N \l_@@_fntef_box / 2 }
10156 { \box_use:N \l_@@_fntef_box }
10157 }
10158 \xeCJK_ulem_on:n
10159 }
10160 % \end{macrocode}
10161 % \end{macro}
10162 %
10163 % \begin{macro}{\CJKunderanyline}
10164 % \changes{v3.2.15}{2014/11/07}{完善选项。}
10165 % \begin{macrocode}
10166 \NewDocumentCommand \CJKunderanyline { s t- s o m m }
10167 {
10168 \xeCJK_ulem_group_begin:
10169 \xeCJK_ulem_boot:NNNn #1#2#3 {#4}
10170 \xeCJK_fntef_initial:nn
10171 {#6}
10172 {
10173 \box_move_down:nn
10174 {#5}
10175 { \box_use:N \l_@@_fntef_box }
10176 }
10177 \tl_if_empty:NF \l_@@_ulem_boxdepth_tl
10178 { \box_set_dp:Nn \ULC@box { \l_@@_ulem_boxdepth_tl } }
10179 \tl_if_empty:NF \l_@@_ulem_sep_tl
10180 {
10181 \bool_set_true:N \l_@@_fntef_bool
10182 \dim_set:Nn \l_@@_fntef_dim
10183 { \l_@@_ulem_sep_tl + \box_dp:N \ULC@box }
10184 }
10185 \xeCJK_ulem_on:n
10186 }
10187 % \end{macrocode}
10188 % \end{macro}
10189 %
10190 % \begin{macro}[int]{\xeCJK_fntef_boot:nnNNNn}
10191 % 处理参数问题。
10192 % \begin{macrocode}
10193 \cs_new_protected:Npn \xeCJK_fntef_boot:nnNNNn #1#2#3#4#5#6
10194 {
10195 \bool_lazy_or:nnT {#3} {#5}
10196 { \bool_set_false:c { l_@@_#2_skip_bool } }
10197 \bool_if:NT #4
10198 { \bool_set_true:c { l_@@_#2_subtract_bool } }
10199 \tl_if_novalue:nF {#6}
10200 { \keys_set:nn { xeCJK / options / #1 } {#6} }
10201 \bool_set_eq:Nc \l_@@_ulem_skip_bool { l_@@_#2_skip_bool }
10202 \bool_set_eq:Nc \l_@@_ulem_hidden_bool { l_@@_#2_hidden_bool }
10203 \bool_set_eq:Nc \l_@@_ulem_subtract_bool { l_@@_#2_subtract_bool }
10204 \tl_set_eq:Nc \l_@@_ulem_text_format_tl { l_@@_#2_text_format_tl }
10205 }
10206 \cs_new_protected:Npn \xeCJK_ulem_boot:NNNn #1#2#3#4
10207 {
10208 \bool_lazy_or:nnT {#1} {#3}
10209 { \bool_set_false:N \l_@@_ulem_skip_bool }
10210 \bool_if:NT #2
10211 { \bool_set_true:N \l_@@_ulem_subtract_bool }
10212 \tl_if_novalue:nF {#4}
10213 { \keys_set:nn { xeCJK / options / ulem } {#4} }
10214 }
10215 % \end{macrocode}
10216 % \end{macro}
10217 %
10218 % \begin{macro}[int]{\xeCJK_fntef_initial:n}
10219 % 不支持下划线的嵌套使用。下划线嵌套使用时,里层的下划线会被放在盒子里,不能折行。
10220 % \begin{macrocode}
10221 \cs_new_protected:Npn \xeCJK_fntef_initial:n
10222 {
10223 \bool_if:NTF \l_@@_nest_bool
10224 { \@@_warning:n { fntef-nesting } }
10225 {
10226 \bool_set_true:N \l_@@_nest_bool
10227 \@@_restore_shipout_fntef:
10228 }
10229 \xeCJK_fntef_sbox:n
10230 }
10231 \cs_new_protected:Npn \xeCJK_fntef_initial:nn #1
10232 {
10233 \xeCJK_fntef_initial:n {#1}
10234 \bool_if:NF \l_@@_fntef_bool
10235 { \dim_zero:N \l_@@_fntef_dim }
10236 \markoverwith
10237 }
10238 \cs_new_protected:Npn \xeCJK_fntef_initial:nnn #1#2#3
10239 {
10240 \xeCJK_fntef_initial:n {#3}
10241 \bool_if:NF \l_@@_fntef_bool
10242 {
10243 \bool_set_true:N \l_@@_fntef_bool
10244 \dim_set:Nn \l_@@_fntef_dim {#1}
10245 }
10246 \markoverwith
10247 {
10248 \box_move_down:nn
10249 { \l_@@_fntef_dim + \box_ht:N \l_@@_fntef_box }
10250 { \box_use:N \l_@@_fntef_box }
10251 }
10252 \dim_set:Nn \l_@@_fntef_dim { #2 + \box_dp:N \ULC@box }
10253 }
10254 \box_new:N \l_@@_fntef_box
10255 \cs_new_eq:NN \xeCJKfntefbox \l_@@_fntef_box
10256 \bool_new:N \l_@@_nest_bool
10257 \bool_new:N \l_@@_fntef_bool
10258 \@@_msg_new:nn { fntef-nesting }
10259 { Nesting~is~not~supported. }
10260 % \end{macrocode}
10261 % \end{macro}
10262 %
10263 % \begin{variable}{\l_@@_fntef_dim}
10264 % 记录下划线或者下划符号的深度,以便它们嵌套使用时能自动调整好距离。
10265 % \tn{ULdepth} 被 \pkg{ulem} 初始化为 \tn{maxdimen}。下划线嵌套时,\pkg{ulem}
10266 % 要使用它作计算,可能会溢出。为简便起见,\cs{l_@@_fntef_dim} 与 \tn{ULdepth}
10267 % 共用一个寄存器。
10268 % \begin{macrocode}
10269 \cs_new_eq:NN \l_@@_fntef_dim \ULdepth
10270 % \end{macrocode}
10271 % \end{variable}
10272 %
10273 % \begin{macro}[int]{\xeCJK_fntef_sbox:n}
10274 % 与 \cs{hcoffin_set:Nn} 和 \LaTeXe{} 的 \tn{sbox} 功能类似,确保颜色的正确。
10275 % 虽然 \texttt{coffin} 可以更方便的操作盒子,但速度要慢一点。并且,我们的需求
10276 % 也比较简单,就不用它了。
10277 % \begin{macrocode}
10278 \cs_new_protected:Npn \xeCJK_fntef_sbox:n #1
10279 {
10280 \hbox_set:Nn \l_@@_fntef_box
10281 { \color_ensure_current: #1 }
10282 }
10283 % \end{macrocode}
10284 % \end{macro}
10285 %
10286 % 最合适的是用 \pkg{xtemplate} 宏包来实现,但是比较难于用 \tn{xeCJKsetup} 来统一
10287 % 设置,所以这里还是用土办法。
10288 % \begin{macrocode}
10289 \keys_define:nn { xeCJK / options }
10290 {
10291 underdot / symbol .tl_set:N = \l_@@_udot_symbol_tl ,
10292 underdot / depth .tl_set:N = \l_@@_udot_depth_tl ,
10293 underdot / sep .tl_set:N = \l_@@_udot_sep_tl ,
10294 underdot / format .tl_set:N = \l_@@_udot_format_tl ,
10295 underdot / textformat .tl_set:N = \l_@@_udot_text_format_tl ,
10296 underdot / boxdepth .tl_set:N = \l_@@_udot_boxdepth_tl ,
10297 symbol / sep .tl_set:N = \l_@@_symbol_sep_tl ,
10298 symbol / boxdepth .tl_set:N = \l_@@_symbol_boxdepth_tl ,
10299 symbol / textformat .tl_set:N = \l_@@_symbol_text_format_tl ,
10300 underline / skip .bool_set:N = \l_@@_uline_skip_bool ,
10301 underline / hidden .bool_set:N = \l_@@_uline_hidden_bool ,
10302 underline / subtract .bool_set:N = \l_@@_uline_subtract_bool ,
10303 underline / thickness .tl_set:N = \l_@@_uline_thickness_tl ,
10304 underline / depth .tl_set:N = \l_@@_uline_depth_tl ,
10305 underline / sep .tl_set:N = \l_@@_uline_sep_tl ,
10306 underline / format .tl_set:N = \l_@@_uline_format_tl ,
10307 underline / textformat .tl_set:N = \l_@@_uline_text_format_tl ,
10308 underdblline / skip .bool_set:N = \l_@@_udbline_skip_bool ,
10309 underdblline / hidden .bool_set:N = \l_@@_udbline_hidden_bool ,
10310 underdblline / subtract .bool_set:N = \l_@@_udbline_subtract_bool ,
10311 underdblline / thickness .tl_set:N = \l_@@_udbline_thickness_tl ,
10312 underdblline / depth .tl_set:N = \l_@@_udbline_depth_tl ,
10313 underdblline / sep .tl_set:N = \l_@@_udbline_sep_tl ,
10314 underdblline / format .tl_set:N = \l_@@_udbline_format_tl ,
10315 underdblline / textformat .tl_set:N = \l_@@_udbline_text_format_tl ,
10316 underdblline / gap .tl_set:N = \l_@@_udbline_gap_tl ,
10317 underwave / skip .bool_set:N = \l_@@_uwave_skip_bool ,
10318 underwave / hidden .bool_set:N = \l_@@_uwave_hidden_bool ,
10319 underwave / subtract .bool_set:N = \l_@@_uwave_subtract_bool ,
10320 underwave / symbol .tl_set:N = \l_@@_uwave_symbol_tl ,
10321 underwave / depth .tl_set:N = \l_@@_uwave_depth_tl ,
10322 underwave / sep .tl_set:N = \l_@@_uwave_sep_tl ,
10323 underwave / format .tl_set:N = \l_@@_uwave_format_tl ,
10324 underwave / textformat .tl_set:N = \l_@@_uwave_text_format_tl ,
10325 sout / skip .bool_set:N = \l_@@_sout_skip_bool ,
10326 sout / hidden .bool_set:N = \l_@@_sout_hidden_bool ,
10327 sout / subtract .bool_set:N = \l_@@_sout_subtract_bool ,
10328 sout / thickness .tl_set:N = \l_@@_sout_thickness_tl ,
10329 sout / height .tl_set:N = \l_@@_sout_height_tl ,
10330 sout / format .tl_set:N = \l_@@_sout_format_tl ,
10331 sout / textformat .tl_set:N = \l_@@_sout_text_format_tl ,
10332 xout / skip .bool_set:N = \l_@@_xout_skip_bool ,
10333 xout / hidden .bool_set:N = \l_@@_xout_hidden_bool ,
10334 xout / subtract .bool_set:N = \l_@@_xout_subtract_bool ,
10335 xout / format .tl_set:N = \l_@@_xout_format_tl ,
10336 xout / textformat .tl_set:N = \l_@@_xout_text_format_tl ,
10337 ulem / skip .bool_set:N = \l_@@_ulem_skip_bool ,
10338 ulem / hidden .bool_set:N = \l_@@_ulem_hidden_bool ,
10339 ulem / subtract .bool_set:N = \l_@@_ulem_subtract_bool ,
10340 ulem / sep .tl_set:N = \l_@@_ulem_sep_tl ,
10341 ulem / boxdepth .tl_set:N = \l_@@_ulem_boxdepth_tl ,
10342 ulem / textformat .tl_set:N = \l_@@_ulem_text_format_tl
10343 }
10344 \clist_map_inline:nn
10345 { underdot , underline , underdblline , underwave , sout , xout , ulem }
10346 {
10347 \keys_define:nn { xeCJK / options }
10348 { #1 .meta:nn = { xeCJK / options / #1 } { ##1 } }
10349 }
10350 \keys_set:nn { xeCJK / options }
10351 {
10352 underdot / symbol = \normalfont . ,
10353 underdot / depth = 0.20 em ,
10354 underdot / sep = 0.04 em ,
10355 symbol / sep = \c_zero_dim ,
10356 underline / skip = true ,
10357 underline / thickness = \ULthickness ,
10358 underline / depth = 0.20 em ,
10359 underline / sep = 0.07 em ,
10360 underdblline / skip = true ,
10361 underdblline / thickness = \ULthickness ,
10362 underdblline / depth = 0.20 em ,
10363 underdblline / sep = 0.17 em ,
10364 underdblline / gap = 1.1 pt ,
10365 underwave / skip = true ,
10366 underwave / symbol = \sixly \tex_char:D 58 \exp_stop_f: ,
10367 underwave / depth = 0.20 em ,
10368 underwave / sep = 0.00 em ,
10369 sout / skip = true ,
10370 sout / thickness = \ULthickness ,
10371 sout / height = 0.35 em ,
10372 xout / skip = true
10373 }
10374 % \end{macrocode}
10375 %
10376 % \changes{v3.8.3}{2020/04/07}{取消 \pkg{xeCJKfntef} 的初始彩色设置。}
10377 %
10378 % \begin{macro}{\CJKunderanysymbol}
10379 % \begin{macrocode}
10380 \NewDocumentCommand \CJKunderanysymbol { o m m m }
10381 {
10382 \xeCJK_under_symbol:nnnnnn { symbol } { symbol } {#1} {#2} {#3} {#4}
10383 \tex_ignorespaces:D
10384 }
10385 % \end{macrocode}
10386 % \end{macro}
10387 %
10388 % \begin{macro}{\CJKunderdot}
10389 % \tn{CJKunderdot} 是 \tn{CJKunderanysymbol} 的特殊情况。\pkg{CJKfntef} 原来使用
10390 % 的是数学符号 \tn{cdot},这里改成更合适的 |.|。
10391 % \begin{macrocode}
10392 \NewDocumentCommand \CJKunderdot { o m }
10393 {
10394 \xeCJK_under_symbol:nnnnnn { underdot } { udot }
10395 {#1}
10396 { \l_@@_udot_depth_tl }
10397 { \l_@@_udot_format_tl \l_@@_udot_symbol_tl }
10398 {#2}
10399 \tex_ignorespaces:D
10400 }
10401 % \end{macrocode}
10402 % \end{macro}
10403 %
10404 % \begin{macro}[int]{\xeCJK_under_symbol:nnnnnn}
10405 % 当处在下划线中时,我们先断开下划线,在分组外设置下划符号。
10406 % \begin{macrocode}
10407 \cs_new_protected:Npn \xeCJK_under_symbol:nnnnnn
10408 {
10409 \xeCJK_if_ulem_patch:TF
10410 { \@@_under_symbol_auxi:nnnnnn }
10411 { \@@_under_symbol_auxii:nnnnnn }
10412 }
10413 \cs_new_protected:Npn \@@_under_symbol_auxi:nnnnnn #1#2#3#4#5#6
10414 {
10415 \xeCJK_ulem_right: \UL@stop
10416 \group_begin:
10417 \xeCJK_under_symbol_initial:nnnnn {#1} {#2} {#3} {#4} {#5}
10418 \use:c { l_@@_#2_text_format_tl }
10419 \UL@start \xeCJK_ulem_right_node:
10420 #6
10421 \xeCJK_ulem_right: \UL@stop
10422 \group_end:
10423 \UL@start \xeCJK_ulem_right_node:
10424 }
10425 \cs_new_protected:Npn \@@_under_symbol_auxii:nnnnnn #1#2#3#4#5#6
10426 {
10427 \mode_leave_vertical:
10428 \group_begin:
10429 \xeCJK_under_symbol_initial:nnnnn {#1} {#2} {#3} {#4} {#5}
10430 \@@_under_symbol_text_format:c { l_@@_#2_text_format_tl }
10431 #6
10432 \xeCJK_ulem_right:
10433 \group_end:
10434 \xeCJK_ulem_right_node:
10435 }
10436 \cs_new_protected:Npn \xeCJK_under_symbol_initial:nnnnn #1#2#3#4#5
10437 {
10438 \tl_if_novalue:nF {#3}
10439 { \keys_set:nn { xeCJK / options / #1 } {#3} }
10440 \xeCJK_fntef_sbox:n {#5}
10441 \bool_if:NTF \l_@@_fntef_bool
10442 { \xeCJK_make_under_symbol:n { \l_@@_fntef_dim } }
10443 {
10444 \bool_set_true:N \l_@@_fntef_bool
10445 \xeCJK_make_under_symbol:n {#4}
10446 }
10447 \tl_if_empty:cF { l_@@_#2_boxdepth_tl }
10448 {
10449 \box_set_dp:Nn \l_@@_under_symbol_box
10450 { \use:c { l_@@_#2_boxdepth_tl } }
10451 }
10452 \dim_set:Nn \l_@@_fntef_dim
10453 { \use:c { l_@@_#2_sep_tl } + \box_dp:N \l_@@_under_symbol_box }
10454 \xeCJK_swap_cs:NN \CJKsymbol \@@_under_CJKsymbol:N
10455 \@@_restore_shipout_CJKsymbol:
10456 }
10457 \cs_new_protected:Npn \@@_under_symbol_text_format:N #1
10458 {
10459 \tl_if_empty:NF #1
10460 { \xeCJK_ulem_right: #1 \xeCJK_ulem_right_node: }
10461 }
10462 \cs_generate_variant:Nn \@@_under_symbol_text_format:N { c }
10463 \box_new:N \l_@@_under_symbol_box
10464 % \end{macrocode}
10465 % \end{macro}
10466 %
10467 % \begin{macro}[int]{\xeCJK_make_under_symbol:n}
10468 % 我们量取“一”的宽度作为汉字的宽度。
10469 % \begin{macrocode}
10470 \cs_new_protected:Npn \xeCJK_make_under_symbol:n #1
10471 {
10472 \hbox_set:Nn \l_@@_under_symbol_box
10473 {
10474 \box_move_down:nn { #1 + \box_ht:N \l_@@_fntef_box }
10475 {
10476 \hbox_to_zero:n
10477 {
10478 \xeCJK_select_font:
10479 \tex_kern:D \tex_fontcharwd:D \tex_font:D "4E00 \exp_stop_f:
10480 \tex_hss:D \box_use:N \l_@@_fntef_box \tex_hss:D
10481 }
10482 }
10483 }
10484 }
10485 % \end{macrocode}
10486 % \end{macro}
10487 %
10488 % \begin{macro}{\@@_restore_shipout_CJKsymbol:}
10489 % \changes{v3.2.3}{2013/06/04}{解决 \tn{CJKunderdot} 跨页使用时影响到页眉页脚的问题。}
10490 % \tn{CJKunderdot} 中对 \tn{CJKsymbol} 的修改会影响到页眉和页脚,需要小心处理。
10491 % \begin{macrocode}
10492 \cs_new_protected:Npn \@@_restore_shipout_CJKsymbol:
10493 {
10494 \tl_put_right:Nn \l_@@_fntef_shipout_tl
10495 { \xeCJK_swap_cs:NN \CJKsymbol \@@_under_CJKsymbol:N }
10496 \@@_restore_shipout_fntef:
10497 \xeCJK_cs_clear:N \@@_restore_shipout_CJKsymbol:
10498 }
10499 \cs_new_protected:Npn \@@_restore_shipout_fntef:
10500 {
10501 \tl_put_right:Nn \l_@@_fntef_shipout_tl
10502 {
10503 \bool_set_false:N \l_@@_fntef_bool
10504 \dim_zero:N \l_@@_fntef_dim
10505 }
10506 \xeCJK_cs_clear:N \@@_restore_shipout_fntef:
10507 }
10508 \tl_new:N \l_@@_fntef_shipout_tl
10509 \xeCJK_add_to_shipout:n { \l_@@_fntef_shipout_tl }
10510 % \end{macrocode}
10511 % \end{macro}
10512 %
10513 % \begin{macro}{\@@_under_CJKsymbol:N}
10514 % 盒子放在汉字的左侧,比较容易处理状态转移的问题。
10515 % \begin{macrocode}
10516 \cs_new_protected:Npn \@@_under_CJKsymbol:N
10517 {
10518 \box_use:N \l_@@_under_symbol_box
10519 \xeCJK_no_break: \@@_under_CJKsymbol:N
10520 }
10521 % \end{macrocode}
10522 % \end{macro}
10523 %
10524 % \changes{v3.7.2}{2019/03/24}{改用 \pkg{xparse} 的新参数类型 \texttt{b}
10525 % 定义 \env{CJKfilltwosides*} 环境,不再依赖 \pkg{environ} 包。}
10526 %
10527 % \begin{macro}{CJKfilltwosides}
10528 % \changes{v3.2.4}{2013/06/26}{改用 \texttt{minipage} 和 \LaTeX 表格(\texttt{tabular})来实现。}
10529 % \changes{v3.3.3}{2015/05/30}{确保进入水平模式。}
10530 % 使用 \texttt{minipage} 和 \LaTeX 表格(\texttt{tabular})来定义 |CJKfilltwosides| 环境。
10531 % 可选参数 |#1| 表示环境的垂直对齐位置,默认居中;参数 |#2| 表示环境的宽度。
10532 % 带星号的环境,如果 |#2| 不大于零或者不大于环境最长文本行的宽度,则取环境的自然宽度。
10533 % \begin{macrocode}
10534 \NewDocumentEnvironment { CJKfilltwosides } { O { c } m }
10535 {
10536 \use:e { \exp_not:N \minipage [#1] { \dim_eval:n {#2} } }
10537 \cs_set_eq:NN \CJKglue \xeCJK_fntef_hfilll:
10538 }
10539 {
10540 \endminipage
10541 \ignorespacesafterend
10542 }
10543 \NewDocumentEnvironment { CJKfilltwosides* } { O { c } m +b }
10544 {
10545 \mode_leave_vertical:
10546 \cs_set_eq:NN \CJKglue \xeCJK_fntef_hfilll:
10547 \tl_set:Nn \arraystretch { 1 }
10548 \cs_if_free:NF \extrarowheight
10549 { \cs_set_eq:NN \extrarowheight \c_zero_dim }
10550 \use:e { \@@_fill_two_sides:nnn {#1} { \dim_eval:n {#2} } } {#3}
10551 }
10552 { \ignorespacesafterend }
10553 \cs_new_protected:Npn \@@_fill_two_sides:nnn #1#2#3
10554 {
10555 \dim_compare:nNnTF {#2} > \c_zero_dim
10556 {
10557 \hbox_set:Nn \l_@@_tmp_box
10558 { \tabular [#1] { @ { } c @ { } } #3 \endtabular }
10559 \dim_compare:nNnTF {#2} > { \box_wd:N \l_@@_tmp_box }
10560 { \tabular [#1] { @ { } p {#2} @ { } } #3 \endtabular }
10561 { \box_use:N \l_@@_tmp_box }
10562 }
10563 { \tabular [#1] { @ { } c @ { } } #3 \endtabular }
10564 }
10565 % \end{macrocode}
10566 % \end{macro}
10567 %
10568 % \begin{macro}[int]{\xeCJK_fntef_hfilll:}
10569 % \pkg{colortbl} 将表格 |c| 列用于填充的 \tn{hfil} 改为了更高阶的 \texttt{fill},
10570 % 影响到了 \env{CJKfilltwosides*}。因此,我们也要用高阶的 \texttt{filll}。
10571 % \begin{macrocode}
10572 \cs_new_protected:Npn \xeCJK_fntef_hfilll:
10573 { \skip_horizontal:N \c_@@_filll_skip }
10574 \skip_const:Nn \c_@@_filll_skip { \c_zero_dim plus 1 filll }
10575 % \end{macrocode}
10576 % \end{macro}
10577 %
10578 % \begin{macrocode}
10579 %</fntef>
10580 % \end{macrocode}
10581 %
10582 % \subsection{\pkg{xeCJK-listings}}
10583 %
10584 % \changes{v3.2.2}{2013/06/04}{增加小宏包 \pkg{xeCJK-listings},用于支持 \pkg{listings} 宏包。}
10585 % \changes{v3.2.3}{2013/06/06}{完善对 \pkg{listings} 宏包的支持。}
10586 %
10587 % 仿照 \package{luatexja} 宏包中 \pkg{lltjp-listings} 的处理,支持 \package{listings} 宏包。
10588 %
10589 % \begin{macrocode}
10590 %<*listings>
10591 % \end{macrocode}
10592 %
10593 % \begin{macrocode}
10594 \DeclareOption* { \PassOptionsToPackage { \CurrentOption } { xeCJK } }
10595 \ProcessOptions \scan_stop:
10596 % \end{macrocode}
10597 %
10598 % \begin{macrocode}
10599 \RequirePackage { xeCJK }
10600 \RequirePackage { listings }
10601 % \end{macrocode}
10602 %
10603 % \begin{macrocode}
10604 \lst@AddToHook { Init } { \@@_listings_initial_hook: }
10605 \lst@AddToHook { SelectCharTable } { \@@_listings_toks_hook: }
10606 \lst@AddToHook { OutputBox }
10607 {
10608 \tl_set_eq:NN \l_xeCJK_punct_style_tl \c_@@_punct_style_plain_tl
10609 \l_@@_restore_listings_toks_tl
10610 \@@_listings_output_CM:
10611 }
10612 \lst@AddToHook { PreSet } { \bool_set_true:N \l_@@_listings_env_bool }
10613 % \end{macrocode}
10614 %
10615 % \begin{macro}{\@@_listings_initial_hook:}
10616 % \changes{v3.2.3}{2013/06/04}
10617 % {解决 \texttt{listings} 坏境中代码行号输出不正确的问题,并解决在其中跨页时对页眉
10618 % 和页脚的影响。}
10619 % \changes{v3.2.15}{2014/11/10}{修正 \texttt{breaklines} 无效的问题。}
10620 % \changes{v3.3.1}{2015/04/20}
10621 % {解决 \texttt{prebreak} 和 \texttt{postbreak} 功能失效的问题。}
10622 % 为使代码行号结果正确,需要在 \tn{lst@numberstyle} 中恢复 \tn{XeTeXinterchartoks}。
10623 % 在 \texttt{listings} 环境中换页时,对 \tn{XeTeXinterchartoks} 的修改会影响到
10624 % 页眉和页脚,需要在 \tn{shipout} 盒子中恢复成正常定义。加入 \cs{tex_noindent:D}
10625 % 是为了进入水平模式,防止汉字出现在首行的时候可能会产生额外空行。
10626 % \tn{lst@prebreak} 和 \tn{lst@postbreak} 是在 \tn{discretionary} 中直接输出的,
10627 % 应该恢复正常的 \tn{XeTeXinterchartoks}。
10628 % \begin{macrocode}
10629 \cs_new_protected:Npn \@@_listings_initial_hook:
10630 {
10631 \tex_noindent:D
10632 \bool_gset_false:N \g_@@_listings_CM_bool
10633 \tl_put_left:Nn \lst@numberstyle { \l_@@_restore_listings_toks_tl }
10634 \xeCJK_add_to_shipout:n { \l_@@_restore_listings_toks_tl }
10635 \lst@ifbreaklines
10636 \cs_set_eq:NN \@@_listings_CJK_toks_hook: \@@_listings_breaklines_toks:
10637 \tl_if_empty:NF \lst@prebreak
10638 { \tl_put_left:Nn \lst@prebreak { \l_@@_restore_listings_toks_tl } }
10639 \tl_if_empty:NF \lst@postbreak
10640 { \tl_put_left:Nn \lst@postbreak { \l_@@_restore_listings_toks_tl } }
10641 \fi:
10642 \int_set:Nn \l_@@_listings_max_char_int
10643 { \lst@ifec 255 \else: 127 \fi: }
10644 }
10645 \int_new:N \l_@@_listings_max_char_int
10646 % \end{macrocode}
10647 % \end{macro}
10648 %
10649 % \begin{macro}{\@@_listings_toks_hook:}
10650 % 采用不同的 \tn{XeTeXinterchartoks} 处理方式,输入的时候是将汉字加入到 \pkg{listings}
10651 % 的输出队列,实际输出的时候是普通文字。
10652 % \begin{macrocode}
10653 \cs_new_protected:Npn \@@_listings_toks_hook:
10654 {
10655 \tl_clear:N \l_@@_restore_listings_toks_tl
10656 \seq_map_function:NN
10657 \g_@@_class_seq \@@_backup_inter_class_toks:n
10658 \seq_map_inline:Nn \g_@@_non_CJK_class_seq
10659 {
10660 \str_if_eq:nnF { ##1 } { Boundary }
10661 {
10662 \xeCJK_inter_class_toks:nnn { Boundary } { ##1 }
10663 { \@@_listings_process_Default:nN { ##1 } }
10664 }
10665 }
10666 \xeCJK_inter_class_toks:nnn { Boundary } { CM }
10667 { \@@_listings_process_CM:nN { 0 } }
10668 \@@_listings_CJK_toks_hook:
10669 }
10670 % \end{macrocode}
10671 % \end{macro}
10672 %
10673 % \begin{macro}{\@@_backup_inter_class_toks:n}
10674 % 注意,给 \tn{XeTeXinterchartoks} 赋空值,会导致 \XeTeX 崩溃!
10675 % \begin{macrocode}
10676 \cs_new_protected:Npn \@@_backup_inter_class_toks:n #1
10677 {
10678 \tl_set:Nx \l_@@_tmp_tl
10679 { \xeCJK_get_inter_class_toks:nn { Boundary } {#1} }
10680 \tl_put_right:Nx \l_@@_restore_listings_toks_tl
10681 {
10682 \xeCJK_inter_class_toks:nnn { Boundary } {#1}
10683 {
10684 \tl_if_empty:NTF \l_@@_tmp_tl
10685 { \exp_not:N \prg_do_nothing: }
10686 { \exp_not:o \l_@@_tmp_tl }
10687 }
10688 }
10689 }
10690 \tl_new:N \l_@@_restore_listings_toks_tl
10691 % \end{macrocode}
10692 % \end{macro}
10693 %
10694 % \begin{macro}{\@@_listings_CJK_toks_hook:,\@@_listings_breaklines_toks:}
10695 % 根据 \texttt{breaklines} 选项的使用与否,选择不同的处理方式。
10696 % \begin{macrocode}
10697 \cs_new_protected:Npn \@@_listings_CJK_toks_hook:
10698 {
10699 \xeCJK_inter_class_toks:nnn { Boundary } { CJK }
10700 { \@@_listings_process_CJK:nN { 2 } }
10701 \xeCJK_inter_class_toks:nnn { Boundary } { FullLeft }
10702 { \@@_listings_process_CJK:nN { 2 } }
10703 \xeCJK_inter_class_toks:nnn { Boundary } { FullRight }
10704 { \@@_listings_process_CJK:nN { 2 } }
10705 \xeCJK_inter_class_toks:nnn { Boundary } { HangulJamo }
10706 { \@@_listings_process_CJK:nN { 2 } }
10707 \seq_map_inline:Nn \g_@@_CJK_sub_class_seq
10708 {
10709 \xeCJK_inter_class_toks:nnn { Boundary } { CJK/##1 }
10710 { \@@_listings_process_CJK:nN { 2 } }
10711 }
10712 }
10713 \cs_new_protected:Npn \@@_listings_breaklines_toks:
10714 {
10715 \xeCJK_inter_class_toks:nnn { Boundary } { CJK }
10716 { \@@_listings_process_breaklines_CJK:nN { 2 } }
10717 \xeCJK_inter_class_toks:nnn { Boundary } { HangulJamo }
10718 { \@@_listings_process_breaklines_CJK:nN { 2 } }
10719 \xeCJK_inter_class_toks:nnn { Boundary } { FullLeft }
10720 { \@@_listings_process_FullLeft:nN { 2 } }
10721 \xeCJK_inter_class_toks:nnn { Boundary } { FullRight }
10722 { \@@_listings_process_FullRight:nN { 2 } }
10723 \seq_map_inline:Nn \g_@@_CJK_sub_class_seq
10724 {
10725 \xeCJK_inter_class_toks:nnn { Boundary } { CJK/##1 }
10726 { \@@_listings_process_breaklines_CJK:nN { 2 } }
10727 }
10728 }
10729 % \end{macrocode}
10730 % \end{macro}
10731 %
10732 % \begin{macro}{\@@_listings_process_Default:nN}
10733 % \changes{v3.2.3}{2013/06/08}{在 \texttt{listings} 坏境中对 \tn{charcode} 大于
10734 % $255$ 的字符根据其 \tn{catcode} 区分 \texttt{letter} 和 \texttt{other}。}
10735 % \changes{v3.3.1}{2015/01/27}{对 \pkg{listings} 的字符扩展不影响到其符号表中的
10736 % 七位或八位字符。}
10737 % 对于 \tn{charcode} 大于 $255$ 的字符,根据 \tn{catcode} 进行处理。
10738 % \begin{macrocode}
10739 \cs_new_protected:Npn \@@_listings_process_Default:nN #1#2
10740 {
10741 \int_compare:nNnTF
10742 { \xeCJK_token_value_charcode:N #2 } > \l_@@_listings_max_char_int
10743 {
10744 \token_if_letter:NTF #2
10745 { \lst@ProcessLetter #2 }
10746 { \lst@ProcessOther #2 }
10747 }
10748 { \@@_listings_output_Default:nN {#1} #2 }
10749 }
10750 % \end{macrocode}
10751 % 输出时,要注意把对应的 \tn{XeTeXinterchartoks} 清空掉,否则会造成死循环。
10752 % \cs{scan_stop:} 是造边界,输出 \cs{group_end:}。
10753 % \begin{macrocode}
10754 \cs_new_protected:Npn \@@_listings_output_Default:nN #1#2
10755 {
10756 \group_begin:
10757 \xeCJK_clear_inter_class_toks:nn { Boundary } {#1}
10758 \xeCJK_inter_class_toks:nnn {#1} { Boundary } { \group_end: }
10759 #2
10760 \scan_stop:
10761 }
10762 % \end{macrocode}
10763 % \end{macro}
10764 %
10765 % \begin{macro}{\@@_listings_process_CJK:nN}
10766 % 对 CJK 字符类的处理。
10767 % \begin{macrocode}
10768 \cs_new_protected:Npn \@@_listings_process_CJK:nN #1#2
10769 {
10770 \token_if_letter:NTF #2
10771 { \@@_listings_process_letter:nN {#1} #2 }
10772 { \@@_listings_process_other:nN {#1} #2 }
10773 }
10774 % \end{macrocode}
10775 % \end{macro}
10776 %
10777 % \begin{macro}{\@@_listings_append:nN}
10778 % 普通 CJK 字符的宽度为一般基本宽度的两倍,CM 类不增加宽度。这里有一个问题,
10779 % 对 CJK 字符类中的一些半角字符(例如半角日文假名)没有区分开。\pkg{listings} 通过
10780 % 重定义 \tn{lst@Append} 将代码写入外部文件,因此需要保留。
10781 % \begin{macrocode}
10782 \cs_new_protected:Npn \@@_listings_append:nN #1#2
10783 {
10784 \int_add:Nn \lst@length { #1 - 1 }
10785 \lst@Append #2
10786 }
10787 % \end{macrocode}
10788 % \end{macro}
10789 %
10790 % \begin{macro}{\@@_listings_process_letter:nN,\@@_listings_process_other:nN}
10791 % 在 \texttt{letter} 类中区分汉字和西文字母。
10792 % \begin{macrocode}
10793 \cs_new_protected:Npn \@@_listings_process_letter:nN
10794 {
10795 \lst@whitespacefalse
10796 \bool_if:NTF \l_@@_listings_letter_bool
10797 { \lst@lettertrue }
10798 {
10799 \lst@ifletter \lst@Output \else: \lst@OutputOther \lst@lettertrue \fi:
10800 \bool_set_true:N \l_@@_listings_letter_bool
10801 }
10802 \@@_listings_append:nN
10803 }
10804 \bool_new:N \l_@@_listings_letter_bool
10805 \cs_new_protected:Npn \@@_listings_process_other:nN #1#2
10806 {
10807 \lst@whitespacefalse
10808 \bool_if:NTF \l_@@_listings_letter_bool
10809 {
10810 \lst@Output \lst@letterfalse
10811 \bool_set_false:N \l_@@_listings_letter_bool
10812 }
10813 { \lst@ifletter \lst@Output \lst@letterfalse \fi: }
10814 \cs_set_eq:NN \lst@lastother #2
10815 \@@_listings_append:nN {#1} #2
10816 }
10817 % \end{macrocode}
10818 % \end{macro}
10819 %
10820 % \changes{v3.2.4}{2013/07/05}
10821 % {使 \pkg{listings} 的 \texttt{breaklines} 选项对 CJK 字符类可用,并保持标点符号的禁则。}
10822 %
10823 % \begin{macro}
10824 % {\@@_listings_process_breaklines_CJK:nN,
10825 % \@@_listings_process_FullLeft:nN,
10826 % \@@_listings_process_FullRight:nN}
10827 % 当使用 \texttt{breaklines} 选项时,立即输出之前的单个文字,以便于断行。并将标点
10828 % 与它前/后的 CJK 文字放在同一个盒子中,以保持禁则。但是不能区分 letter 和 other。
10829 % \begin{macrocode}
10830 \cs_new_protected:Npn \@@_listings_process_breaklines_CJK:nN
10831 {
10832 \lst@whitespacefalse
10833 \bool_if:NTF \l_@@_listings_letter_bool
10834 {
10835 \int_compare:nNnF \l_@@_listings_flag_int = 2 { \lst@Output }
10836 \lst@lettertrue
10837 }
10838 {
10839 \lst@ifletter \lst@Output \else: \lst@OutputOther \lst@lettertrue \fi:
10840 \bool_set_true:N \l_@@_listings_letter_bool
10841 }
10842 \int_set_eq:NN \l_@@_listings_flag_int \c_one_int
10843 \@@_listings_append:nN
10844 }
10845 \cs_new_protected:Npn \@@_listings_process_FullLeft:nN #1#2
10846 {
10847 \lst@whitespacefalse
10848 \bool_if:NTF \l_@@_listings_letter_bool
10849 {
10850 \int_compare:nNnF \l_@@_listings_flag_int = 2
10851 {
10852 \int_compare:nNnTF \l_@@_listings_flag_int = 3
10853 { \bool_if:NT \l_@@_punct_breakable_bool { \lst@Output } }
10854 { \lst@Output }
10855 }
10856 \lst@lettertrue
10857 }
10858 {
10859 \lst@ifletter \lst@Output \else: \lst@OutputOther \lst@lettertrue \fi:
10860 \bool_set_true:N \l_@@_listings_letter_bool
10861 }
10862 \int_set:Nn \l_@@_listings_flag_int { 2 }
10863 \@@_listings_append:nN {#1} #2
10864 }
10865 \cs_new_protected:Npn \@@_listings_process_FullRight:nN #1#2
10866 {
10867 \lst@whitespacefalse
10868 \bool_if:NTF \l_@@_listings_letter_bool
10869 {
10870 \int_compare:nNnT \l_@@_listings_flag_int < 2
10871 { \@@_punct_if_long:NT #2 { \lst@Output } }
10872 \lst@lettertrue
10873 }
10874 {
10875 \lst@ifletter \lst@Output \else: \lst@OutputOther \lst@lettertrue \fi:
10876 \bool_set_true:N \l_@@_listings_letter_bool
10877 }
10878 \int_set:Nn \l_@@_listings_flag_int { 3 }
10879 \@@_listings_append:nN {#1} #2
10880 }
10881 \int_new:N \l_@@_listings_flag_int
10882 % \end{macrocode}
10883 % \end{macro}
10884 %
10885 % \begin{macro}[int]{\lst@AppendLetter,\lst@AppendOther}
10886 % \begin{macrocode}
10887 \cs_set_protected:Npn \lst@AppendLetter
10888 {
10889 \bool_if:NTF \l_@@_listings_letter_bool
10890 {
10891 \lst@Output \lst@lettertrue
10892 \bool_set_false:N \l_@@_listings_letter_bool
10893 }
10894 { \reverse_if:N \lst@ifletter \lst@OutputOther \lst@lettertrue \fi: }
10895 \lst@ifbreaklines \int_zero:N \l_@@_listings_flag_int \fi:
10896 \lst@Append
10897 }
10898 \cs_set_protected:Npn \lst@AppendOther
10899 {
10900 \bool_if:NTF \l_@@_listings_letter_bool
10901 {
10902 \lst@Output \lst@letterfalse
10903 \bool_set_false:N \l_@@_listings_letter_bool
10904 }
10905 { \lst@ifletter \lst@Output \lst@letterfalse \fi: }
10906 \lst@ifbreaklines \int_zero:N \l_@@_listings_flag_int \fi:
10907 \tex_futurelet:D \lst@lastother \lst@Append
10908 }
10909 % \end{macrocode}
10910 % \end{macro}
10911 %
10912 % \begin{macro}{\@@_listings_process_CM:nN}
10913 % \texttt{CM} 类作为 \texttt{letter} 处理,不用增加 \tn{lst@length}。
10914 % \begin{macrocode}
10915 \cs_new_protected:Npn \@@_listings_process_CM:nN
10916 {
10917 \reverse_if:N \lst@ifflexible
10918 \bool_gset_true:N \g_@@_listings_CM_bool
10919 \fi:
10920 \@@_listings_process_letter:nN
10921 }
10922 % \end{macrocode}
10923 % \end{macro}
10924 %
10925 % \begin{macro}{\@@_listings_output_CM:}
10926 % 在使用 \texttt{columns=fixed} 选项时,\pkg{listings} 会在输出盒子里的每个字符
10927 % 之间加入 \tn{hss},这就破坏了 \XeTeX 将基本字和组合标识正确的组合起来。
10928 % \begin{macrocode}
10929 \cs_new_protected:Npn \@@_listings_output_CM:
10930 {
10931 \reverse_if:N \lst@ifflexible
10932 \bool_if:NT \g_@@_listings_CM_bool
10933 {
10934 \bool_gset_false:N \g_@@_listings_CM_bool
10935 \xeCJK_cs_clear:N \lst@FillOutputBox
10936 \cs_set_eq:NN \CJKglue \tex_hss:D
10937 }
10938 \fi:
10939 }
10940 \bool_new:N \g_@@_listings_CM_bool
10941 % \end{macrocode}
10942 % \end{macro}
10943 %
10944 % \begin{macro}{\@@_listings_peek_active_loop:TF}
10945 % \tn{lstinline} 通过判断参数中第一个字符是否是 \texttt{active} 类来区分
10946 % 它是否被用在其他宏的参数之中。如果这第一个字符不在 \pkg{listings} 预定义的
10947 % 符号表中,判断就会出问题。我们在这里通过一个循环跳过这些字符。
10948 % \begin{macrocode}
10949 \cs_new_protected:Npn \@@_listings_peek_active_loop:TF #1#2#3
10950 {
10951 \token_if_active:NTF #3
10952 { #1#3 }
10953 {
10954 \token_if_cs:NTF #3
10955 { #2#3 }
10956 {
10957 \int_compare:nNnTF { `#3 } > { \l_@@_listings_max_char_int }
10958 { \@@_listings_peek_active_loop:TF { #1#3 } { #2#3 } }
10959 { #2#3 }
10960 }
10961 }
10962 }
10963 \cs_set_eq:NN \lst@IfNextCharActive \@@_listings_peek_active_loop:TF
10964 % \end{macrocode}
10965 % \end{macro}
10966 %
10967 % \begin{macro}{\@@_listings_rescan:Nn,
10968 % \@@_listings_inside_convert:nw,\@@_listings_inline_group:w}
10969 % 当 \tn{lstinline} 被使用在参数中时,\pkg{listings} 会使用一个循环逐个将
10970 % \tn{lstinline} 参数中的字符设置为活动字符。我们可以通过 \cs{tl_set_rescan:Nnn}
10971 % 来完成这里的 \tn{catcode} 转换,避免将 \tn{charcode} 超过 $255$ 的字符都设置为
10972 % 活动字符。
10973 % \begin{macrocode}
10974 \cs_new_protected:Npn \@@_listings_rescan:Nn #1#2
10975 {
10976 \@@_listings_set_escape:
10977 \tl_set:Nn \l_@@_tmp_tl {#2}
10978 \@@_listings_escape_backslash:
10979 \tl_set_rescan:Nno #1 { } { \l_@@_tmp_tl }
10980 }
10981 \cs_new_protected:Npn \@@_listings_inside_convert:nw #1 ~ \@empty
10982 {
10983 \@@_listings_rescan:Nn \l_@@_tmp_tl {#1}
10984 \tl_put_right:No \lst@arg { \l_@@_tmp_tl }
10985 }
10986 \cs_set_eq:NN \lst@InsideConvert@ \@@_listings_inside_convert:nw
10987 \cs_new_protected:Npn \@@_listings_inline_group:w
10988 {
10989 \exp_after:wN \@@_listings_inline_group:n
10990 \exp_after:wN { \if_int_compare:w `} = \c_zero_int \fi:
10991 }
10992 \cs_set_eq:NN \lst@InlineGJ \@@_listings_inline_group:w
10993 \cs_new_protected:Npn \@@_listings_inline_group:n #1
10994 {
10995 \@@_listings_rescan:Nn \lst@arg {#1}
10996 \lst@InlineGJEnd
10997 }
10998 % \end{macrocode}
10999 % \end{macro}
11000 %
11001 % \begin{macro}{\@@_listings_set_escape:}
11002 % 由于我们在上面的修改,需要保留 |\| 用于转义 \tn{lstinline} 参数中的某些 \TeX
11003 % 特殊字符,与原来宏包一致。
11004 % \begin{macrocode}
11005 \group_begin:
11006 \cs_set:Npn \@@_tmp:w #1
11007 {
11008 \group_end:
11009 \cs_new_protected:Npn \@@_listings_set_escape:
11010 { \xeCJK_swap_cs:NN #1 \@@_listings_escape:N }
11011 \cs_new_protected:Npn \@@_listings_escape:N ##1
11012 { \cs_if_eq:NNTF #1 ##1 { \@@_listings_escape:N } {##1} }
11013 }
11014 \use:n
11015 {
11016 \char_set_catcode_active:N \\
11017 \@@_tmp:w
11018 }
11019 { \ }
11020 % \end{macrocode}
11021 % \end{macro}
11022 %
11023 %
11024 % \changes{v3.4.8}{2017/05/15}{转义 \tn{lstinline} 参数中的 $\texttt{\textbackslash}_{12}$。}
11025 % \begin{macro}{\@@_listings_escape_backslash:}
11026 % \tn{catcode} 为 $12$ 的 |\| 需要双写转义。
11027 % \begin{macrocode}
11028 \cs_new_protected:Npx \@@_listings_escape_backslash:
11029 {
11030 \tl_replace_all:Nnn \exp_not:N \l_@@_tmp_tl
11031 { \c_backslash_str }
11032 { \c_backslash_str \c_backslash_str }
11033 }
11034 % \end{macrocode}
11035 % \end{macro}
11036 %
11037 % \begin{macrocode}
11038 %</listings>
11039 % \end{macrocode}
11040 %
11041 % \begin{macrocode}
11042 %<@@=xunadd>
11043 % \end{macrocode}
11044 %
11045 % \subsection{\pkg{xunicode-addon}}
11046 %
11047 % \changes{v3.2.5}{2013/07/18}
11048 % {增加小宏包 \pkg{xunicode-addon},为 \pkg{xunicode} 提供判断字符是否存在的功能。}
11049 % \changes{v3.2.9}{2013/12/08}
11050 % {文档部分增加 \pkg{xunicode} 定义的符号表。}
11051 %
11052 % \begin{macrocode}
11053 %<*xunicode>
11054 % \end{macrocode}
11055 %
11056 % \pkg{xunicode} 对编码相关的符号命令的定义中用的是诸如 |\char"0022\relax| 的形式。
11057 % 例如 \tn{textbar} 被展开为 |\char"007C\relax|。并且诸如下述的定义是无效的:
11058 % \begin{verbatim}
11059 % \DeclareUTFcomposite[\UTFencname]{x1EBF}{\'}{\^e}
11060 % \end{verbatim}
11061 % 我们在这里做的修改是把符号命令定义为实际的字符并且使上述定义生效。另外在使用
11062 % 这些符号命令的时候,先判断当前字体中是否存在对应的字符,如果不存在,则使用这
11063 % 些符号命令的默认设置。
11064 %
11065 % \begin{macrocode}
11066 \bool_lazy_or:nnF
11067 { \sys_if_engine_xetex_p: }
11068 { \sys_if_engine_luatex_p: }
11069 {
11070 \msg_new:nnnn { xunicode-addon } { xetex-luatex }
11071 { This~package~requires~either~XeTeX~or~LuaTeX~to~function.}
11072 {
11073 You~must~change~your~typesetting~engine~to,~e.g.,\\
11074 "xelatex"~or~"lualatex"~instead~of~plain~"latex"~or~"pdflatex".
11075 }
11076 \msg_critical:nn { xunicode-addon } { xetex-luatex }
11077 }
11078 \RequirePackage { xparse }
11079 % \end{macrocode}
11080 %
11081 % 宏包选项是编码的名字。
11082 %
11083 % \begin{macrocode}
11084 \clist_new:N \g_@@_encname_clist
11085 \tl_if_exist:NT \UTFencname
11086 { \clist_gput_right:Nx \g_@@_encname_clist { \UTFencname } }
11087 \DeclareOption*
11088 { \clist_gput_right:No \g_@@_encname_clist \CurrentOption }
11089 \ProcessOptions \scan_stop:
11090 % \end{macrocode}
11091 %
11092 % 若 \pkg{xunicode} 已经被调用,则在宏包结束的时候,重新设置 \tn{UTFencname}
11093 % 对应的编码命令。否则设置 \tn{UTFencname},如果使用的是 \hologo{LuaLaTeX},则
11094 % 需要作一些设置,使得 \pkg{xunicode} 可用。
11095 %
11096 % \changes{v3.3.3}{2016/02/01}{使用新的 Unicode 编码名称 \texttt{TU}。}
11097 %
11098 % \begin{macrocode}
11099 \@ifpackageloaded { xunicode } { }
11100 {
11101 \clist_get:NNF \g_@@_encname_clist \UTFencname
11102 {
11103 \cs_if_exist:NTF \UnicodeEncodingName
11104 { \tl_set:Nx \UTFencname { \UnicodeEncodingName } }
11105 {
11106 \sys_if_engine_xetex:TF
11107 { \tl_set:Nn \UTFencname { EU1 } }
11108 { \tl_set:Nn \UTFencname { EU2 } }
11109 }
11110 \clist_gset_eq:NN \g_@@_encname_clist \UTFencname
11111 }
11112 \sys_if_engine_xetex:TF
11113 { \RequirePackage { xunicode } }
11114 {
11115 \cs_set_eq:NN \@@_tmp:w \XeTeXpicfile
11116 \cs_set_eq:NN \XeTeXpicfile \prg_do_nothing:
11117 \RequirePackage { xunicode }
11118 \cs_set_eq:NN \XeTeXpicfile \@@_tmp:w
11119 }
11120 }
11121 \AtEndOfPackage { \@@_reload:N \g_@@_encname_clist }
11122 % \end{macrocode}
11123 %
11124 % \begin{macro}[int]{\ReloadXunicode}
11125 % 参数可以是多个编码,设置这些编码对应的命令。如果编码没有预先声明,则给出
11126 % 一个错误警告。
11127 % \begin{macrocode}
11128 \RenewDocumentCommand \ReloadXunicode { m }
11129 {
11130 \clist_set:Nx \l_@@_encname_clist {#1}
11131 \@@_reload:N \l_@@_encname_clist
11132 }
11133 \cs_new_protected:Npn \@@_reload:N #1
11134 {
11135 \cs_set_eq:NN \@@_tmp:w \iftipaonetoken
11136 \cs_set_eq:NN \iftipaonetoken \scan_stop:
11137 \use:e
11138 {
11139 \ExplSyntaxOff
11140 \char_set_catcode_letter:n { 64 }
11141 \exp_not:N \clist_map_function:NN \exp_not:N #1 \@@_reload_aux:n
11142 \bool_if:NTF \l__kernel_expl_bool
11143 { \ExplSyntaxOn }
11144 { \ExplSyntaxOff }
11145 \char_set_catcode:nn { 64 } { \char_value_catcode:n { 64 } }
11146 }
11147 \cs_set_eq:NN \iftipaonetoken \@@_tmp:w
11148 }
11149 \cs_new_protected:Npn \@@_reload_aux:n #1
11150 {
11151 \cs_if_exist:cTF { T@ #1 }
11152 {
11153 \tl_set:Nn \UTFencname {#1}
11154 \clist_if_in:NnF \g_@@_encname_clist {#1}
11155 { \clist_gput_right:Nn \g_@@_encname_clist {#1} }
11156 \file_input:n { xunicode.sty }
11157 \file_input:n { xunicode-extra.def }
11158 }
11159 { \msg_error:nnn { xunicode-addon } { encoding-unknown } {#1} }
11160 }
11161 \clist_new:N \l_@@_encname_clist
11162 \msg_new:nnnn { xunicode-addon } { encoding-unknown }
11163 { Encoding~scheme~"#1"~unknown. }
11164 {
11165 You~may~use \\\\
11166 \token_to_str:N \usepackage [ #1 , \encodingdefault ] \{fontenc\} \\\\
11167 before~xunicode-addon~or~xunicode.
11168 }
11169 % \end{macrocode}
11170 % \end{macro}
11171 %
11172 % \begin{macro}[int]{\DeclareUTFmathsymbols}
11173 % \changes{v3.2.8}{2013/12/04}{修正 \tn{UseMathAsText} 的功能,恢复 \tn{hbar}
11174 % 和增加以 \texttt{text} 打头的文本符号命令。}
11175 % 将文本符号定义为 \tn{protected} 宏后,为了与 \pkg{hyperref} 的书签功能兼容
11176 % 需要作一点额外处理。
11177 % \begin{macrocode}
11178 \RenewDocumentCommand \DeclareUTFmathsymbols { m }
11179 {
11180 \bool_if:NT \l_@@_math_as_UTF_text_bool
11181 {
11182 \seq_map_inline:Nn \l_@@_math_as_UTF_text_seq
11183 { \@@_declare_math_as_UTF_text:n {##1} }
11184 \bool_set_false:N \l_@@_math_as_UTF_text_bool
11185 }
11186 }
11187 \seq_new:N \l_@@_math_as_UTF_text_seq
11188 \seq_set_from_clist:Nn \l_@@_math_as_UTF_text_seq
11189 { hbar , Finv , aleph , beth , gimel , daleth , Game }
11190 \bool_new:N \l_@@_math_as_UTF_text_bool
11191 \RenewDocumentCommand \UseMathAsText { }
11192 {
11193 \math@s@text@true
11194 \bool_set_true:N \l_@@_math_as_UTF_text_bool
11195 }
11196 \@onlypreamble \UseMathAsText
11197 \cs_new_protected:Npn \@@_declare_math_as_UTF_text:n #1
11198 {
11199 \cs_if_exist:cTF {#1}
11200 {
11201 \cs_new_eq:cc { keepmathUTF #1 } {#1}
11202 \cs_gset_protected:cpx {#1}
11203 {
11204 \exp_not:N \mode_if_math:TF
11205 { \exp_not:c { keepmathUTF #1 } }
11206 { \exp_not:c { text #1 } }
11207 }
11208 \tl_put_right:Nx \l_@@_hyperref_hook_tl
11209 { \cs_set_eq:NN \exp_not:c {#1} \exp_not:c { text #1 } }
11210 }
11211 { \cs_new:cpx {#1} { \exp_not:c { text #1 } } }
11212 }
11213 \tl_new:N \l_@@_hyperref_hook_tl
11214 \AtBeginDocument
11215 {
11216 \cs_if_free:NF \pdfstringdefDisableCommands
11217 { \pdfstringdefDisableCommands { \l_@@_hyperref_hook_tl } }
11218 }
11219 % \end{macrocode}
11220 % \end{macro}
11221 %
11222 % \begin{macro}[pTF]{\@@_glyph_if_exist:n}
11223 % 判断字符在当前字体中是否存在。
11224 % \begin{macrocode}
11225 \prg_new_conditional:Npnn \@@_glyph_if_exist:n #1 { p , T , F , TF }
11226 {
11227 \tex_iffontchar:D \tex_font:D \tex_numexpr:D #1 \scan_stop:
11228 \prg_return_true: \else: \prg_return_false: \fi:
11229 }
11230 % \end{macrocode}
11231 % \end{macro}
11232 %
11233 % \begin{macro}[int]{\UndeclareUTFcharacter}
11234 % 取消编码 |#1| 下的符号命令 |#3|。
11235 % \begin{macrocode}
11236 \RenewDocumentCommand \UndeclareUTFcharacter { O { \UTFencname } m m }
11237 {
11238 \@@_if_csname:nTF {#3}
11239 { \UndeclareTextCommand {#3} }
11240 { \exp_args:Nc \UndeclareTextCommand { \tl_to_str:n {#3} } }
11241 {#1}
11242 }
11243 % \end{macrocode}
11244 % \end{macro}
11245 %
11246 % \begin{macro}[int]{\UndeclareUTFcomposite}
11247 % 取消编码 |#1| 下的复合符号命令 |#3{#4}|。
11248 % \begin{macrocode}
11249 \RenewDocumentCommand \UndeclareUTFcomposite { O { \UTFencname } m m m }
11250 {
11251 \@@_if_csname:nTF {#3}
11252 { \@@_undeclare_composite:Nnnn #3 }
11253 { \exp_args:Nc \@@_undeclare_composite:Nnnn { \tl_to_str:n {#3} } }
11254 {#1} {#4} {#2}
11255 }
11256 \cs_new_protected:Npn \@@_undeclare_composite:Nnnn #1#2#3#4
11257 { \cs_undefine:c { \@@_composite_cs:Nnn #1 {#2} {#3} } }
11258 % \end{macrocode}
11259 % \end{macro}
11260 %
11261 % \begin{macro}{\@@_composite_cs:Nnn,\@@_composite_cs:nnn}
11262 % \begin{macrocode}
11263 \cs_new:Npx \@@_composite_cs:Nnn #1#2#3
11264 { \c_backslash_str #2 \exp_not:N \token_to_str:N #1 - \exp_not:N \tl_to_str:n {#3} }
11265 \cs_new:Npx \@@_composite_cs:nnn #1#2#3
11266 { \c_backslash_str #2 #1 - \exp_not:N \tl_to_str:n {#3} }
11267 % \end{macrocode}
11268 % \end{macro}
11269 %
11270 % \begin{macro}{\@@_if_csname:nTF}
11271 % 判断 |#1| 是否可以作为控制序列的名字。这是因为 \pkg{xunicide} 使用了下面的定义。
11272 % \begin{verbatim}
11273 % \DeclareUTFcharacter[\UTFencname]{x0149}{'n}
11274 % \end{verbatim}
11275 % \begin{macrocode}
11276 \prg_new_conditional:Npnn \@@_if_csname:n #1 { TF }
11277 {
11278 \tl_if_single_token:nTF {#1}
11279 {
11280 \token_if_cs:NTF #1
11281 { \prg_return_true: }
11282 {
11283 \token_if_active:NTF #1
11284 { \prg_return_true: }
11285 { \prg_return_false: }
11286 }
11287 }
11288 { \prg_return_false: }
11289 }
11290 % \end{macrocode}
11291 % \end{macro}
11292 %
11293 % \begin{macro}[int]{\DeclareUTFcharacter}
11294 % 定义编码 |#1| 下的符号命令 |#3|,其对应符号的 Unicode 是 |#2|。
11295 % \begin{macrocode}
11296 \RenewDocumentCommand \DeclareUTFcharacter { O { \UTFencname } m m }
11297 {
11298 \cs_if_exist_use:cF
11299 { @@_restore_ \tl_to_str:n {#3} : }
11300 {
11301 \@@_if_csname:nTF {#3}
11302 { \@@_declare_character:Nnn #3 }
11303 { \@@_declare_character:cnn { \tl_to_str:n {#3} } }
11304 {#1} {#2}
11305 }
11306 }
11307 % \end{macrocode}
11308 % \end{macro}
11309 %
11310 % \begin{macro}{\@@_restore_cmd:N}
11311 % 恢复 \tn{hbar} 和 \tn{nobreakspace} 为原本定义。
11312 % \begin{macrocode}
11313 \cs_new_protected:cpn
11314 { @@_restore_ \tl_to_str:n { \hbar } : }
11315 { \@@_restore_cmd:N \hbar }
11316 \cs_new_protected:cpn
11317 { @@_restore_ \tl_to_str:n { \nobreakspace } : }
11318 { \@@_restore_cmd:N \nobreakspace }
11319 \cs_new_protected:Npn \@@_restore_cmd:N #1
11320 { \@@_restore_cmd:Ne #1 { ? - \token_to_str:N #1 } }
11321 \cs_new_protected:Npn \@@_restore_cmd:Nn #1#2
11322 {
11323 \cs_if_free:cF {#2}
11324 { \@@_restore_cmd:Nc #1 {#2} }
11325 }
11326 \cs_new_protected:Npn \@@_restore_cmd:NN #1#2
11327 {
11328 \cs_gset_eq:NN #1 #2
11329 \cs_undefine:N #2
11330 }
11331 \cs_generate_variant:Nn \@@_restore_cmd:Nn { Ne }
11332 \cs_generate_variant:Nn \@@_restore_cmd:NN { Nc }
11333 % \end{macrocode}
11334 % \end{macro}
11335 %
11336 % \begin{macro}{\@@_declare_character:Nnn}
11337 % 通过 \cs{tex_Uchar:D} 直接由 Unicode |#3| 得到编码 |#2| 下的符号命令
11338 % |#1| 对应的实际字符。\tn{DeclareUTFSymbol} 的参数格式与 \tn{DeclareTextSymbol}
11339 % 完全一致。
11340 % \begin{macrocode}
11341 \cs_new_protected:Npn \@@_declare_character:Nnn #1#2#3
11342 {
11343 \@@_provide_text_command_default:N #1
11344 \exp_after:wN \@@_declare_character:NNen
11345 \tex_Uchar:D \@@_check_slot:n {#3} \exp_stop_f:
11346 #1 { \token_to_str:N #1 } {#2}
11347 }
11348 \cs_generate_variant:Nn \@@_declare_character:Nnn { c }
11349 % \end{macrocode}
11350 % \end{macro}
11351 %
11352 % \begin{macro}[int]{\DeclareUTFSymbol,\DeclareUTFCommand}
11353 % \tn{DeclareUTFCommand} 只能用于定义不带参数的符号命令。
11354 % \begin{macrocode}
11355 \NewDocumentCommand \DeclareUTFSymbol { m O { \UTFencname } m }
11356 { \@@_declare_character:Nnn #1 {#2} {#3} }
11357 \NewDocumentCommand \DeclareUTFCommand { m O { \UTFencname } m }
11358 { \@@_text_command:Nonn #1 { \token_to_str:N #1 } {#2} {#3} }
11359 \cs_new_protected:Npn \@@_text_command:Nnnn #1#2#3#4
11360 { \DeclareTextCommand #1 {#3} { \@@_text_command:nn {#2} {#4} } }
11361 \cs_generate_variant:Nn \@@_text_command:Nnnn { No }
11362 \cs_new_protected:Npn \@@_text_command:nn #1#2
11363 {
11364 \@@_begin_hook:nn {#1} {#2}
11365 #2
11366 \@@_end_hook:nn {#1} {#2}
11367 }
11368 % \end{macrocode}
11369 % \end{macro}
11370 %
11371 % \begin{macro}{\@@_provide_text_command_default:N}
11372 % 如果控制序列 |#1| 已经存在,但不是符号命令,\pkg{xunicode} 会将它定义为
11373 % \tn{UTFencname} 编码下的符号命令。但是编码被转换之后,再使用这些控制序列,
11374 % \pkg{NFSS} 就会报错。为此需要给出这些符号命令的默认定义,与原来的意义相同。
11375 % 这些命令包括
11376 % \begin{verbatim}
11377 % \nobreakspace macro:->\protect \nobreakspace
11378 % \copyright macro:->\protect \copyright
11379 % \AA macro:->\r A
11380 % \aa macro:->\r a
11381 % \textrhookopeno \long macro:->\textrethookbelow {\textopeno }
11382 % \hbar macro:->{\mathchar '26\mkern -9muh}
11383 % \textaolig macro:->{a\kern -.25em o}
11384 % \end{verbatim}
11385 % 影响比较大的是 \tn{nobreakspace}、\tn{copyright} 和 \tn{hbar}。
11386 % \begin{macrocode}
11387 \cs_new_protected:Npn \@@_provide_text_command_default:N #1
11388 {
11389 \cs_if_exist:cF { ? \token_to_str:N #1 }
11390 {
11391 \cs_if_free:cF { ? - \token_to_str:N #1 }
11392 {
11393 \exp_args:NNv \ProvideTextCommandDefault #1
11394 { ? - \token_to_str:N #1 }
11395 }
11396 }
11397 }
11398 % \end{macrocode}
11399 % \end{macro}
11400 %
11401 % \begin{macro}{\@@_declare_character:NNnn}
11402 % 使用编码 |#4| 下的符号命令 |#2| 的时候先判断它对应的实际字符 |#1| 在当前字体中
11403 % 是否存在。如果不存在则转换到 \tn{DeclareTextSymbolDefault} 中设置的编码或者使用
11404 % \cs{Declare\-Text\-Command\-Default} 中设置的命令。
11405 % \begin{macrocode}
11406 \cs_new_protected:Npn \@@_declare_character:NNnn #1#2#3#4
11407 { \DeclareTextCommand #2 {#4} { \@@_text_character:nN {#3} {#1} } }
11408 \cs_new_protected:Npn \@@_text_character:nN #1#2
11409 {
11410 \@@_begin_hook:nn {#1} {#2}
11411 \@@_glyph_if_exist:nTF { `#2 }
11412 {#2} { \cs_if_exist_use:cF { ? #1 } {#2} }
11413 \@@_end_hook:nn {#1} {#2}
11414 }
11415 \cs_generate_variant:Nn \@@_declare_character:NNnn { NNe }
11416 % \end{macrocode}
11417 % \end{macro}
11418 %
11419 % \begin{macro}{\@@_check_slot:n}
11420 % \pkg{xunicode} 中使用的 Unicode 格式是诸如 |x0022| 的形式,这就需要一些转换。
11421 % \begin{macrocode}
11422 \cs_new:Npn \@@_check_slot:n #1
11423 {
11424 \int_eval:n
11425 {
11426 \tl_if_head_eq_charcode:nNTF {#1} x
11427 { " \use_none:n #1 } {#1}
11428 }
11429 }
11430 % \end{macrocode}
11431 % \end{macro}
11432 %
11433 % \begin{macro}[int]{\DeclareUTFcomposite}
11434 % 设置编码 |#1| 下的符号命令 |#3| 与它的参数 |#4| 的复合对应的符号的 Unicode 是 |#2|。
11435 % \begin{macrocode}
11436 \RenewDocumentCommand \DeclareUTFcomposite { O { \UTFencname } m m m }
11437 {
11438 \@@_if_csname:nTF {#3}
11439 { \@@_declare_composite:Nnnn #3 }
11440 { \@@_declare_composite:cnnn { \tl_to_str:n {#3} } }
11441 {#1} {#4} {#2}
11442 }
11443 % \end{macrocode}
11444 % \end{macro}
11445 %
11446 % \begin{macro}{\@@_declare_composite:Nnnn}
11447 % 这里使用 \cs{tex_afterassignment:D} 是因为 \pkg{xunicode} 有如下的定义。
11448 % \begin{verbatim}
11449 % \DeclareUTFcomposite[\UTFencname]{x02E8\char"02E5}{\tonebar}{25}
11450 % \DeclareUTFcomposite[\UTFencname]{x02E5\char"02E8}{\tonebar}{52}
11451 % \end{verbatim}
11452 % 对复合符号命令的定义用的是 \tn{chardef},这有利于下面字符是否存在的判断。
11453 % \begin{macrocode}
11454 \cs_new_protected:Npn \@@_declare_composite:Nnnn #1#2#3#4
11455 {
11456 \tex_afterassignment:D \use_none_delimit_by_q_stop:w
11457 \@@_chardef:cn { \@@_composite_cs:Nnn #1 {#2} {#3} }
11458 { \@@_check_slot:n {#4} }
11459 \q_stop
11460 }
11461 \cs_new_protected:Npn \@@_chardef:Nn #1#2
11462 { \tex_chardef:D #1 = \tex_numexpr:D #2 \scan_stop: }
11463 \cs_generate_variant:Nn \@@_chardef:Nn { c }
11464 \cs_generate_variant:Nn \@@_declare_composite:Nnnn { c }
11465 % \end{macrocode}
11466 % \end{macro}
11467 %
11468 % \begin{macro}[int]{\DeclareUTFCompositeCommand}
11469 % 设置编码 |#2| 下的符号命令 |#1| 与它的参数 |#3| 的复合对应结果是 |#4|。不能直接用
11470 % \cs{Declare\-Text\-Composite\-Command} 来定义,它与我们的机制冲突。
11471 % \begin{macrocode}
11472 \NewDocumentCommand \DeclareUTFCompositeCommand { m O { \UTFencname } m m }
11473 { \cs_set_protected:cpn { \@@_composite_cs:Nnn #1 {#2} {#3} } {#4} }
11474 % \end{macrocode}
11475 % \end{macro}
11476 %
11477 % \begin{macro}[int]{\DeclareUTFCompositeSymbol}
11478 % 设置编码 |#2| 下的符号命令 |#1| 与它的参数 |#3| 的复合对应结果是 |#4|。不能直接用
11479 % \cs{Declare\-Text\-Composite} 来定义,它与我们的机制冲突。
11480 % \begin{macrocode}
11481 \NewDocumentCommand \DeclareUTFCompositeSymbol { m O { \UTFencname } m m }
11482 {
11483 \@@_chardef:cn { \@@_composite_cs:Nnn #1 {#2} {#3} }
11484 { \@@_check_slot:n {#4} }
11485 }
11486 % \end{macrocode}
11487 % \end{macro}
11488 %
11489 % \begin{macro}[int]{\DeclareUTFComposite}
11490 % 将 |#1| 设置为编码 |#2| 下的带一个参数的复合符号命令。
11491 % \begin{macrocode}
11492 \NewDocumentCommand \DeclareUTFComposite { m O { \UTFencname } }
11493 { \use:e { \@@_declare_composite:Nnn \exp_not:N #1 { \token_to_str:N #1 } {#2} } }
11494 % \end{macrocode}
11495 % \end{macro}
11496 %
11497 % \begin{macro}[int]{\DeclareUTFEncodedAccent}
11498 % |#1| 是重音命令,|#2| 是编码,|#3| 是组合重音符号的 Unicode,|#4| 是基本重音符号
11499 % 的 Unicode。当 |#1| 的参数为空时,输出 |#4|,否则是 |#1| 的参数与 |#3| 的组合。
11500 % \begin{macrocode}
11501 \NewDocumentCommand \DeclareUTFEncodedAccent { m O { \UTFencname } m m }
11502 { \@@_declare_encoded:NNnnn \@@_combine_accent:nnNNn #1 {#2} {#3} {#4} }
11503 % \end{macrocode}
11504 % \end{macro}
11505 %
11506 % \begin{macro}[int]{\DeclareUTFEncodedAccents}
11507 % |#1| 是重音命令,|#2| 是编码,|#3| 和 |#4| 都是组合重音符号的 Unicode。
11508 % 输出 |#1| 与 |#3|、|#4| 的组合。
11509 % \begin{macrocode}
11510 \NewDocumentCommand \DeclareUTFEncodedAccents { m O { \UTFencname } m m }
11511 { \@@_declare_encoded:NNnnn \@@_combine_accents:nnNNn #1 {#2} {#3} {#4} }
11512 % \end{macrocode}
11513 % \end{macro}
11514 %
11515 % \begin{macro}[int]{\DeclareUTFEncodedSymbol}
11516 % |#1| 是带参数的符号命令,|#2| 是编码,|#3| 是组合符号的 Unicode,|#4| 是基本符号的
11517 % Unicode。当 |#1| 的参数为空时,输出 |#4|,否则是 |#1| 的参数与 |#3| 的组合。
11518 % \begin{macrocode}
11519 \NewDocumentCommand \DeclareUTFEncodedSymbol { m O { \UTFencname } m m }
11520 { \@@_declare_encoded:NNnnn \@@_combine_symbol:nnNNn #1 {#2} {#3} {#4} }
11521 % \end{macrocode}
11522 % \end{macro}
11523 %
11524 % \begin{macro}[int]{\DeclareUTFEncodedCircle}
11525 % |#1| 是带参数的圆圈符号命令,|#2| 是编码,|#3| 是组合圆圈符号的 Unicode,|#4|
11526 % 是圆圈符号的 Unicode。当 |#1| 的参数为空时,输出 |#4|,否则是 |#1| 的参数与 |#4| 的组合。
11527 % \begin{macrocode}
11528 \NewDocumentCommand \DeclareUTFEncodedCircle { m O { \UTFencname } m m }
11529 { \@@_declare_encoded:NNnnn \@@_combine_circle:nnNNn #1 {#2} {#3} {#4} }
11530 % \end{macrocode}
11531 % \end{macro}
11532 %
11533 % \begin{macro}[int]{\DeclareEncodedCompositeCharacter}
11534 % \begin{macrocode}
11535 \RenewDocumentCommand \DeclareEncodedCompositeCharacter { m m m m }
11536 { \DeclareUTFEncodedSymbol #2 [#1] { "#3 } { "0#4 } }
11537 % \end{macrocode}
11538 % \end{macro}
11539 %
11540 % \begin{macro}[int]{\DeclareEncodedCompositeAccents}
11541 % \changes{v3.2.9}{2013/12/07}{修正 \pkg{xunicode} 中的错误定义。}
11542 % \begin{macrocode}
11543 \RenewDocumentCommand \DeclareEncodedCompositeAccents { m m m m }
11544 { \DeclareUTFEncodedAccents #2 [#1] { "#4 } { "#3 } }
11545 % \end{macrocode}
11546 % \end{macro}
11547 %
11548 % \begin{macro}[int]{\DeclareUTFDoubleEncodedAccent}
11549 % \changes{v3.2.10}{2014/02/20}{改进 \tn{t} 等的定义方式。}
11550 % \begin{macrocode}
11551 \NewDocumentCommand \DeclareUTFDoubleEncodedAccent { m O { \UTFencname } m m }
11552 { \@@_declare_encoded:NNnnn \@@_combine_double_accent:nnNNn #1 {#2} {#3} {#4} }
11553 % \end{macrocode}
11554 % \end{macro}
11555 %
11556 % \begin{macro}[int]{\DeclareUTFDoubleEncodedSymbol}
11557 % \changes{v3.2.10}{2014/02/21}{改进 \tn{sliding} 等的定义方式。}
11558 % \begin{macrocode}
11559 \NewDocumentCommand \DeclareUTFDoubleEncodedSymbol { m O { \UTFencname } m m }
11560 { \@@_declare_encoded:NNnnn \@@_combine_double_symbol:nnNNn #1 {#2} {#3} {#4} }
11561 % \end{macrocode}
11562 % \end{macro}
11563 %
11564 % \begin{macro}{\@@_declare_composite:Nnn}
11565 % 通过 \texttt{lowercase} 技巧,直接由重音符号的 Unicode 得到实际字符。
11566 % \begin{macrocode}
11567 \cs_new_protected:Npn \@@_declare_composite:Nnn #1#2#3
11568 { \DeclareTextCommand #1 {#3} { \@@_text_composite:nnn {#2} {#3} } }
11569 % \end{macrocode}
11570 % \end{macro}
11571 %
11572 % \begin{macro}{\@@_text_composite:nnn}
11573 % \begin{macrocode}
11574 \cs_new_protected:Npn \@@_text_composite:nnn #1#2#3
11575 {
11576 \@@_begin_hook:nn {#1} {#3}
11577 \cs_if_exist:cTF { \@@_composite_cs:nnn {#1} {#2} {#3} }
11578 {
11579 \@@_text_composite:cnn
11580 { \@@_composite_cs:nnn {#1} {#2} {#3} } {#1} {#3}
11581 }
11582 { \cs_if_exist_use:cTF { ? #1 } { {#3} } {#3} }
11583 \@@_end_hook:nn {#1} {#3}
11584 }
11585 \cs_new_protected:Npn \@@_text_composite:Nnn #1#2#3
11586 {
11587 \token_if_chardef:NTF #1
11588 {
11589 \@@_glyph_if_exist:nTF {#1}
11590 {#1} { \cs_if_exist_use:cTF { ? #2 } { {#3} } {#3} }
11591 }
11592 {#1}
11593 }
11594 \cs_generate_variant:Nn \@@_text_composite:Nnn { c }
11595 % \end{macrocode}
11596 % \end{macro}
11597 %
11598 % \begin{macro}{\@@_declare_encoded:NNnnn}
11599 % 通过 \cs{tex_Uchar:D} 直接由重音符号的 Unicode 得到实际字符。
11600 % \begin{macrocode}
11601 \cs_new_protected:Npn \@@_declare_encoded:NNnnn #1#2#3#4#5
11602 {
11603 \exp_after:wN \@@_declare_encoded:NNNNee
11604 \tex_Uchar:D \@@_check_slot:n {#4} \exp_after:wN \exp_stop_f:
11605 \tex_Uchar:D \@@_check_slot:n {#5} \exp_stop_f:
11606 #1 #2 { \token_to_str:N #2 } {#3}
11607 }
11608 \cs_new_protected:Npn \@@_declare_encoded:NNNNnn #1#2#3#4#5#6
11609 { \DeclareTextCommand #4 {#6} { #3 {#5} {#6} {#1} {#2} } }
11610 \cs_generate_variant:Nn \@@_declare_encoded:NNnnn { c }
11611 \cs_generate_variant:Nn \@@_declare_encoded:NNNNnn { NNNNee }
11612 % \end{macrocode}
11613 % \end{macro}
11614 %
11615 % \begin{macro}{\@@_text_combine:NnnNNn}
11616 % 若重音命令 |#2| 与它的参数 |#6| 的复合已经由 \tn{DeclareUTFcomposite} 设置,
11617 % 并且在当前字体中存在该字符,则直接使用。否则使用组合命令。
11618 % \begin{macrocode}
11619 \cs_new_protected:Npn \@@_text_combine:NnnNNn #1#2#3#4#5#6
11620 {
11621 \@@_begin_hook:nn {#2} {#6}
11622 \cs_if_exist:cTF { \@@_composite_cs:nnn {#2} {#3} {#6} }
11623 {
11624 \@@_text_combine:cNnNNn
11625 { \@@_composite_cs:nnn {#2} {#3} {#6} } #1 {#2} {#4} {#5} {#6}
11626 }
11627 { #1 {#6} {#2} {#4} {#5} }
11628 \@@_end_hook:nn {#2} {#6}
11629 }
11630 \cs_new_protected:Npn \@@_text_combine:NNnNNn #1#2#3#4#5#6
11631 {
11632 \token_if_chardef:NTF #1
11633 { \@@_glyph_if_exist:nTF {#1} {#1} { #2 {#6} {#3} {#4} {#5} } }
11634 {#1}
11635 }
11636 \cs_generate_variant:Nn \@@_text_combine:NNnNNn { c }
11637 % \end{macrocode}
11638 % \end{macro}
11639 %
11640 % \begin{macro}{\@@_combine_symbol:nnNNn}
11641 % \begin{macrocode}
11642 \cs_new_protected:Npn \@@_combine_symbol:nnNNn
11643 { \@@_text_combine:NnnNNn \@@_add_symbol:nnNN }
11644 \cs_new_protected:Npn \@@_add_symbol:nnNN #1#2#3#4
11645 {
11646 \tl_if_blank:nTF {#1}
11647 {
11648 \@@_glyph_if_exist:nTF { `#4 }
11649 {#4}
11650 { \cs_if_exist_use:cTF { ? #2 } { {#1} } {#4} }
11651 }
11652 {
11653 \@@_glyph_if_exist:nTF { `#3 }
11654 { #1#3 }
11655 { \cs_if_exist_use:cTF { ? #2 } { {#1} } { #1#3 } }
11656 }
11657 }
11658 % \end{macrocode}
11659 % \end{macro}
11660 %
11661 % \begin{macro}{\@@_combine_accent:nnNNn,\@@_add_accent:nnNN}
11662 % 若组合重音符号的 |#3| 和基本重音符号 |#4| 在当前字体中都不存在,则转换到
11663 % \cs{Declare\-Text\-Accent\-Default} 设置的编码或者使用
11664 % \tn{DeclareTextCommandDefault} 中设置的命令。\texttt{0.9999} 版以前的 \XeTeX
11665 % 需要设置 \tn{XeTeXinputnormalization} 为 $1$,才能使用字体中由基础字符和组合符号
11666 % 对应的实际字符;而 \texttt{0.9999} 版以后的 \XeTeX 默认就启用这个功能,^^A
11667 % \tn{XeTeXinputnormalization} 似乎是无效的,怀疑是使用 HarfBuzz 库替代 ICU 进行
11668 % 字体排版的缘故\footnote{\url{http://tug.org/pipermail/xetex/2013-July/024579.html}}。
11669 % \begin{macrocode}
11670 \cs_new_protected:Npn \@@_combine_accent:nnNNn
11671 { \@@_text_combine:NnnNNn \@@_add_accent:nnNN }
11672 \cs_new_protected:Npn \@@_add_accent:nnNN #1#2#3#4
11673 {
11674 \tl_if_blank:nTF {#1}
11675 {
11676 \@@_glyph_if_exist:nTF { `#4 }
11677 {#4}
11678 { \cs_if_exist_use:cTF { ? #2 } { {#1} } {#4} }
11679 }
11680 {
11681 \@@_glyph_if_exist:nTF { `#3 }
11682 { #1#3 }
11683 {
11684 \@@_glyph_if_exist:nTF { `#4 }
11685 { \add@accent { `#4 } {#1} }
11686 { \cs_if_exist_use:cTF { ? #2 } { {#1} } { #1#3 } }
11687 }
11688 }
11689 }
11690 % \end{macrocode}
11691 % \end{macro}
11692 %
11693 % \begin{macro}{\@@_combine_accents:nnNNn,\@@_add_accents:nnNN}
11694 % \begin{macrocode}
11695 \cs_new_protected:Npn \@@_combine_accents:nnNNn
11696 { \@@_text_combine:NnnNNn \@@_add_accents:nnNN }
11697 \cs_new_protected:Npn \@@_add_accents:nnNN #1#2#3#4
11698 {
11699 \tl_if_blank:nTF {#1}
11700 { \cs_if_exist_use:cTF { ? #2 } { {#1} } {#1} }
11701 {
11702 \@@_glyph_if_exist:nTF { `#3 }
11703 { \@@_glyph_if_exist:nTF { `#4 } }
11704 { \use_ii:nn }
11705 { #1#3#4 }
11706 { \cs_if_exist_use:cTF { ? #2 } { {#1} } { #1#3#4 } }
11707 }
11708 }
11709 % \end{macrocode}
11710 % \end{macro}
11711 %
11712 % \begin{macro}{\@@_combine_circle:nnNNn,\@@_add_circle:nnNN,\@@_add_circle:nN}
11713 % 对圆圈中的数字或者字母适当缩小,以适合圆圈的大小。只有字体中存在
11714 % \texttt{U+25EF} 时,才使用这里的设置,否则还还是 \LaTeX\ 中的设置。
11715 % \begin{macrocode}
11716 \cs_new_protected:Npn \@@_combine_circle:nnNNn
11717 { \@@_text_combine:NnnNNn \@@_add_circle:nnNN }
11718 \cs_new_protected:Npn \@@_add_circle:nnNN #1#2#3#4
11719 {
11720 \tl_if_blank:nTF {#1}
11721 {
11722 \@@_glyph_if_exist:nTF { `#4 }
11723 {#4}
11724 { \cs_if_exist_use:cTF { ? #2 } { {#1} } {#4} }
11725 }
11726 {
11727 \@@_glyph_if_exist:nTF { `#4 }
11728 { \@@_add_circle:nN {#1} #4 }
11729 { \cs_if_exist_use:cTF { ? #2 } { {#1} } {#1} }
11730 }
11731 }
11732 \cs_new_protected:Npn \@@_add_circle:nN #1#2
11733 {
11734 \hcoffin_set:Nn \l_@@_tmp_coffin {#1}
11735 \hcoffin_set:Nn \l_@@_circle_coffin {#2}
11736 \fp_set:Nn \l_@@_circle_scale_fp
11737 {
11738 \dim_to_decimal_in_unit:nn
11739 {
11740 \fp_use:N \l_@@_circle_ratio_fp
11741 \coffin_wd:N \l_@@_circle_coffin
11742 }
11743 { \coffin_wd:N \l_@@_tmp_coffin }
11744 }
11745 \coffin_scale:Nnn \l_@@_tmp_coffin
11746 { \l_@@_circle_scale_fp } { \l_@@_circle_scale_fp }
11747 \coffin_attach:NnnNnnnn
11748 \l_@@_circle_coffin { hc } { vc }
11749 \l_@@_tmp_coffin { hc } { vc } { \c_zero_dim } { \c_zero_dim }
11750 \coffin_typeset:Nnnnn \l_@@_circle_coffin
11751 { H } { l } { \c_zero_dim } { \c_zero_dim }
11752 }
11753 \fp_new:N \l_@@_circle_scale_fp
11754 \coffin_new:N \l_@@_tmp_coffin
11755 \coffin_new:N \l_@@_circle_coffin
11756 % \end{macrocode}
11757 % \end{macro}
11758 %
11759 % \begin{macro}[int]{\settextcircledratio}
11760 % 设置圆圈中文字的宽度与圆圈宽度的比例,预设为 \texttt{0.7}。
11761 % \begin{macrocode}
11762 \NewDocumentCommand \settextcircledratio { m }
11763 { \fp_set:Nn \l_@@_circle_ratio_fp {#1} }
11764 \fp_new:N \l_@@_circle_ratio_fp
11765 \settextcircledratio { 0.7 }
11766 % \end{macrocode}
11767 % \end{macro}
11768 %
11769 % \begin{macro}{\@@_combine_double_accent:nnNNn}
11770 % 使 \tn{t} 等组合重音符号放在参数的第一个字母的右边。
11771 % \begin{macrocode}
11772 \cs_new_protected:Npn \@@_combine_double_accent:nnNNn
11773 { \@@_text_combine:NnnNNn \@@_add_double_accent:nnNN }
11774 \cs_new_protected:Npn \@@_add_double_accent:nnNN #1#2#3#4
11775 {
11776 \tl_if_blank:nTF {#1}
11777 {
11778 \@@_glyph_if_exist:nTF { `#4 }
11779 {#4}
11780 { \cs_if_exist_use:cTF { ? #2 } { {#1} } {#4} }
11781 }
11782 {
11783 \@@_glyph_if_exist:nTF { `#3 }
11784 { \@@_add_double_symbol:nN {#1} #3 }
11785 {
11786 \@@_glyph_if_exist:nTF { `#4 }
11787 { \add@accent { `#4 } {#1} }
11788 { \cs_if_exist_use:cTF { ? #2 } { {#1} } { #1#3 } }
11789 }
11790 }
11791 }
11792 % \end{macrocode}
11793 % \end{macro}
11794 %
11795 % \begin{macro}{\@@_combine_double_symbol:nnNNn}
11796 % 使 \tn{sliding} 等组合重音符号放在参数的第一个字母的右边。
11797 % \begin{macrocode}
11798 \cs_new_protected:Npn \@@_combine_double_symbol:nnNNn
11799 { \@@_text_combine:NnnNNn \@@_add_double_symbol:nnNN }
11800 \cs_new_protected:Npn \@@_add_double_symbol:nnNN #1#2#3#4
11801 {
11802 \tl_if_blank:nTF {#1}
11803 {
11804 \@@_glyph_if_exist:nTF { `#4 }
11805 {#4}
11806 { \cs_if_exist_use:cTF { ? #2 } { {#1} } {#4} }
11807 }
11808 {
11809 \@@_glyph_if_exist:nTF { `#3 }
11810 { \@@_add_double_symbol:nN {#1} #3 }
11811 { \cs_if_exist_use:cTF { ? #2 } { {#1} } { #1#3 } }
11812 }
11813 }
11814 % \end{macrocode}
11815 % \end{macro}
11816 %
11817 % \begin{macro}{\@@_add_double_symbol:nN}
11818 % 如果参数的第一个记号是字母类、其他符号类或者由 \tn{chardef} 定义,则将组合符号
11819 % 放在它的右边,否则不作处理。
11820 % \begin{macrocode}
11821 \cs_new_protected:Npn \@@_add_double_symbol:nN #1#2
11822 {
11823 \tl_if_head_is_N_type:nTF {#1}
11824 {
11825 \exp_after:wN \exp_after:wN \exp_after:wN
11826 \@@_add_double_symbol_aux:NnN \exp_after:wN \exp_after:wN
11827 \tl_head:w #1 \q_stop \exp_after:wN { \use_none:n #1 } #2
11828 }
11829 { #1#2 }
11830 }
11831 \cs_new_protected:Npn \@@_add_double_symbol_aux:NnN #1#2#3
11832 {
11833 \bool_lazy_any:nTF
11834 {
11835 { \token_if_letter_p:N #1 }
11836 { \token_if_other_p:N #1 }
11837 { \token_if_chardef_p:N #1 }
11838 }
11839 { #1#3#2 }
11840 { #1#2#3 }
11841 }
11842 % \end{macrocode}
11843 % \end{macro}
11844 %
11845 % \begin{macro}[int]{\AtBeginUTFCommand,\AtEndUTFCommand}
11846 % 设置在符号命令前后使用的钩子,可选参数用于指定单个符号命名。可以用 |#1|
11847 % 引用带参数的组合符号命令的参数或者符号命令对应的符号。
11848 % \changes{v3.2.6}{2013/08/15}{可以指定特定符号命令使用的钩子。}
11849 % \changes{v3.7.1}{2018/04/30}{修复代码重构而引入的新错误。}
11850 % \begin{macrocode}
11851 \NewDocumentCommand \AtBeginUTFCommand { s O { } +m }
11852 {
11853 \tl_if_blank:nTF {#2}
11854 {
11855 \IfBooleanTF {#1}
11856 { \xunadd_set_begin_hook:n }
11857 { \xunadd_append_begin_hook:n }
11858 }
11859 { \xunadd_set_begin_hook:nn {#2} }
11860 {#3}
11861 }
11862 \NewDocumentCommand \AtEndUTFCommand { s O { } +m }
11863 {
11864 \tl_if_blank:nTF {#2}
11865 {
11866 \IfBooleanTF {#1}
11867 { \xunadd_set_end_hook:n }
11868 { \xunadd_append_end_hook:n }
11869 }
11870 { \xunadd_set_end_hook:nn {#2} }
11871 {#3}
11872 }
11873 % \end{macrocode}
11874 % \end{macro}
11875 %
11876 % \begin{macro}[int]{\xunadd_set_begin_hook:n,\xunadd_set_end_hook:n}
11877 % \begin{macrocode}
11878 \cs_new_protected:Npn \xunadd_set_begin_hook:n
11879 { \tl_set:Nn \l_@@_begin_hook_tl }
11880 \cs_new_protected:Npn \xunadd_append_begin_hook:n
11881 { \tl_put_right:Nn \l_@@_begin_hook_tl }
11882 \cs_new_protected:Npn \xunadd_set_end_hook:n
11883 { \tl_set:Nn \l_@@_end_hook_tl }
11884 \cs_new_protected:Npn \xunadd_append_end_hook:n
11885 { \tl_put_right:Nn \l_@@_end_hook_tl }
11886 \cs_new_protected:Npn \xunadd_set_begin_hook:nn
11887 { \@@_set_cmd_hook:nnn { begin } }
11888 \cs_new_protected:Npn \xunadd_set_end_hook:nn
11889 { \@@_set_cmd_hook:nnn { end } }
11890 \cs_new_protected:Npn \@@_set_cmd_hook:nnn #1#2#3
11891 {
11892 \cs_set_protected:cpn
11893 {
11894 \tl_if_single:nTF {#2}
11895 { \use:c { @@_#1_csname:n } { \token_to_str:N #2 } }
11896 { \@@_set_cmd_hook_aux:Nnwn #2 \q_stop {#1} }
11897 } ##1
11898 {#3}
11899 }
11900 \cs_new:Npn \@@_set_cmd_hook_aux:Nnwn #1#2 \q_stop #3
11901 { \use:c { @@_#3_csname:n } { \token_to_str:N #1 - \tl_to_str:n {#2} } }
11902 \cs_new:Npn \@@_begin_csname:n #1 { @@_begin_#1_hook:n }
11903 \cs_new:Npn \@@_end_csname:n #1 { @@_end_#1_hook:n }
11904 \tl_new:N \l_@@_begin_hook_tl
11905 \tl_new:N \l_@@_end_hook_tl
11906 % \end{macrocode}
11907 % \end{macro}
11908 %
11909 % \begin{macro}{\@@_begin_hook:nn,\@@_end_hook:nn}
11910 % \begin{macrocode}
11911 \cs_new_protected:Npn \@@_begin_hook:nn #1#2
11912 {
11913 \tl_use:N \l_@@_begin_hook_tl
11914 \cs_if_exist_use:cF { \@@_begin_csname:n { #1 - \tl_to_str:n {#2} } }
11915 { \cs_if_exist_use:cF { \@@_begin_csname:n {#1} } { \use_none:n } }
11916 {#2}
11917 }
11918 \cs_new_protected:Npn \@@_end_hook:nn #1#2
11919 {
11920 \cs_if_exist_use:cF { \@@_end_csname:n { #1 - \tl_to_str:n {#2} } }
11921 { \cs_if_exist_use:cF { \@@_end_csname:n {#1} } { \use_none:n } }
11922 {#2}
11923 \tl_use:N \l_@@_end_hook_tl
11924 }
11925 % \end{macrocode}
11926 % \end{macro}
11927 %
11928 % \begin{macro}[int]{\DeclareUTFTIPACommand}
11929 % \changes{v3.2.10}{2014/02/20}{检查 \tn{t} 和 \tn{sliding} 的参数是否以 \tn{textipa} 开头。}
11930 % \begin{macrocode}
11931 \NewDocumentCommand \DeclareUTFTIPACommand { O { \UTFencname } m }
11932 { \use:e { \@@_text_tipa_command:Nnn \exp_not:N #2 { \token_to_str:N #2 } {#1} } }
11933 \cs_new_protected:Npn \@@_text_tipa_command:Nnn #1#2#3
11934 {
11935 \cs_set_eq:cc { UTF/#3#2 } { #3#2 }
11936 \DeclareTextCommand #1 {#3} { \@@_text_tipa_command:nnn {#3} {#2} }
11937 }
11938 \cs_new_protected:Npn \@@_text_tipa_command:nnn #1#2#3
11939 {
11940 \exp_args:Ncc \@@_check_for_tipa:NNn
11941 { \use_none:n #2 } { UTF/#1#2 } {#3}
11942 }
11943 \cs_new_protected:Npn \@@_check_for_tipa:NNn #1#2#3
11944 {
11945 \tl_if_head_eq_meaning:nNTF {#3} \textipa
11946 {
11947 \exp_after:wN \tipacatchonechar \exp_after:wN
11948 { \exp_after:wN #1 \use_none:n #3 }
11949 }
11950 { #2 {#3} }
11951 }
11952 % \end{macrocode}
11953 % \end{macro}
11954 %
11955 % \begin{macro}[int]{\xunadd_get_slot:nn}
11956 % |#1| 是编码,|#2| 是诸如 \tn{textendash} 或 |\v C| 等形式的文本命令,取得他们对应的字符编码。
11957 % \begin{macrocode}
11958 \cs_new_protected:Npn \xunadd_get_slot:nn #1#2
11959 { \@@_get_slot:wn #2 \q_nil \q_stop {#1} }
11960 \cs_new_protected:Npn \@@_get_slot:wn #1#2#3 \q_stop #4
11961 {
11962 \int_set:Nn \l_xunadd_slot_int { -1 }
11963 \bool_set_false:N \l_xunadd_rest_bool
11964 \group_begin: \exp_args:Nccc \group_end:
11965 { @@_get_slot:NNnn }
11966 { #4 \token_to_str:N #1 }
11967 { \@@_composite_cs:Nnn #1 {#4} {#2} }
11968 {#2}
11969 {#3}
11970 }
11971 \int_new:N \l_xunadd_slot_int
11972 \bool_new:N \l_xunadd_rest_bool
11973 \cs_new_protected:Npn \@@_get_slot:NNnn #1#2#3#4
11974 {
11975 \cs_if_free:NF #1
11976 {
11977 \cs_if_exist:NTF #2
11978 { \@@_get_composite_slot:Nn #2 {#4} }
11979 { \@@_get_character_slot:Nn #1 { #3 #4 } }
11980 }
11981 }
11982 \cs_new_protected:Npn \@@_get_composite_slot:Nn #1#2
11983 {
11984 \token_if_chardef:NT #1
11985 {
11986 \int_set:Nn \l_xunadd_slot_int {#1}
11987 \quark_if_nil:nF {#2}
11988 { \bool_set_true:N \l_xunadd_rest_bool }
11989 }
11990 }
11991 \cs_new_protected:Npn \@@_get_character_slot:Nn #1
11992 {
11993 \exp_after:wN \@@_get_character_slot_aux:wn #1
11994 \@@_text_character:nN \q_nil \q_nil \q_stop
11995 }
11996 \cs_new_protected:Npn \@@_get_character_slot_aux:wn
11997 #1 \@@_text_character:nN #2#3#4 \q_stop #5
11998 {
11999 \quark_if_nil:nF {#2}
12000 {
12001 \int_set:Nn \l_xunadd_slot_int { `#3 }
12002 \quark_if_nil:nF {#5}
12003 { \bool_set_true:N \l_xunadd_rest_bool }
12004 }
12005 }
12006 % \end{macrocode}
12007 % \end{macro}
12008 %
12009 % \changes{v3.7.2}{2018/05/12}{解决与 \pkg{microtype} 宏包的兼容问题。}
12010 %
12011 % \begin{macro}[int]{\xunadd@microtype@is@charx}
12012 % \pkg{microtype} 宏包中使用的函数,我们通过对 \tn{MT@is@charx} 打补丁来实现功能。
12013 % \begin{macrocode}
12014 \cs_new_protected_nopar:Npn \xunadd@microtype@is@charx #1 \relax
12015 {
12016 \use:e
12017 { \xunadd_get_slot:nn { \MT@encoding } { \tex_the:D \MT@toks } }
12018 \int_compare:nNnTF \l_xunadd_slot_int < \c_zero_int
12019 { \xunadd@original@is@charx #1 \relax }
12020 {
12021 \cs_set_nopar:Npx \MT@char@ { \int_use:N \l_xunadd_slot_int }
12022 \bool_if:NT \l_xunadd_rest_bool { \MT@norestfalse }
12023 }
12024 }
12025 \cs_new_protected_nopar:Npn \xunadd@microtype@hook
12026 {
12027 \cs_if_free:NF \MT@is@charx
12028 {
12029 \cs_new_eq:NN \xunadd@original@is@charx \MT@is@charx
12030 \cs_set_eq:NN \MT@is@charx \xunadd@microtype@is@charx
12031 \cs_set_eq:NN \MT@warn@unknown@once \use_none:n
12032 }
12033 }
12034 \@ifpackageloaded { microtype }
12035 { \use:n } { \AtBeginDocument }
12036 { \xunadd@microtype@hook }
12037 % \end{macrocode}
12038 % \end{macro}
12039 %
12040 % \changes{v3.2.8}{2013/12/05}{启用 \pkg{xunicode} 中的带圈数字和字母设置。}
12041 %
12042 % \begin{macrocode}
12043 %</xunicode>
12044 %<*xunextra>
12045 % \end{macrocode}
12046 %
12047 % \changes{v3.7.0}{2018/03/16}{补充定义 \tn{texthyphenationpoint} 和 \tn{texttwoemdash}。}
12048 %
12049 % 我们补充定义 HYPHENATION POINT 和 TWO-EM DASH,他们默认被归入 CJK 标点符号。
12050 % \begin{macrocode}
12051 \DeclareUTFSymbol\texthyphenationpoint{"2027}
12052 \DeclareUTFSymbol\texttwoemdash{"2E3A}
12053 % \end{macrocode}
12054 %
12055 % 以下内容选自 \pkg{xunicode},并做了适当修改。
12056 % \begin{macrocode}
12057 \DeclareUTFComposite\textsuperscript
12058 \DeclareUTFComposite\textsubscript
12059 \DeclareUTFEncodedAccent\textsbleftarrow{"20EE}{"20FF}
12060 \DeclareUTFEncodedAccent\`{"0300}{"02CB}
12061 \DeclareUTFEncodedAccent\capitalgrave{"0300}{"02CB}
12062 \DeclareUTFEncodedAccent\'{"0301}{"02CA}
12063 \DeclareUTFEncodedAccent\capitalacute{"0301}{"02CA}
12064 \DeclareUTFEncodedAccent\^{"0302}{"02C6}
12065 \DeclareUTFEncodedAccent\capitalcircumflex{"0302}{"02C6}
12066 \DeclareUTFEncodedAccent\~{"0303}{"02DC}
12067 \DeclareUTFEncodedAccent\capitaltilde{"0303}{"02DC}
12068 \DeclareUTFEncodedAccent\={"0304}{"02C9}
12069 \DeclareUTFEncodedAccent\capitalmacron{"0304}{"02C9}
12070 \DeclareUTFEncodedAccent\textoverline{"0305}{"203E}
12071 \DeclareUTFEncodedAccent\u{"0306}{"02D8}
12072 \DeclareUTFEncodedAccent\capitalbreve{"0306}{"02D8}
12073 \DeclareUTFEncodedAccent\.{"0307}{"02D9}
12074 \DeclareUTFEncodedAccent\capitaldotaccent{"0307}{"02D9}
12075 \DeclareUTFEncodedAccent\"{"0308}{"00A8}
12076 \DeclareUTFEncodedAccent\capitaldieresis{"0308}{"00A8}
12077 \DeclareUTFEncodedAccent\m{"0309}{"0309}
12078 \DeclareUTFEncodedAccent\texthookabove{"0309}{"0309}
12079 \DeclareUTFEncodedAccent\r{"030A}{"02DA}
12080 \DeclareUTFEncodedAccent\capitalring{"030A}{"02DA}
12081 \DeclareUTFEncodedAccent\H{"030B}{"02DD}
12082 \DeclareUTFEncodedAccent\capitalhungarumlaut{"030B}{"02DD}
12083 \DeclareUTFEncodedAccent\v{"030C}{"02C7}
12084 \DeclareUTFEncodedAccent\capitalcaron{"030C}{"02C7}
12085 \DeclareUTFEncodedAccent\textvbaraccent{"030D}{"02C8}
12086 \DeclareUTFEncodedAccent\textdoublevbaraccent{"030E}{"0022}
12087 \DeclareUTFEncodedAccent\U{"030E}{"0022}
12088 \DeclareUTFEncodedAccent\textdoublegrave{"030F}{"02F5}
12089 \DeclareUTFEncodedAccent\G{"030F}{"02F5}
12090 \DeclareUTFEncodedAccent\textdotbreve{"0310}{"0310}
12091 \DeclareUTFEncodedAccent\textroundcap{"0311}{"0311}
12092 \DeclareUTFEncodedAccent\newtie{"0311}{"0311}
12093 \DeclareUTFEncodedAccent\capitalnewtie{"0311}{"0311}
12094 \DeclareUTFEncodedAccent\textturncommaabove{"0312}{"02BB}
12095 \DeclareUTFEncodedAccent\textcommaabove{"0313}{"02BC}
12096 \DeclareUTFEncodedAccent\textrevcommaabove{"0314}{"02BD}
12097 \DeclareUTFEncodedAccent\overbridge{"0346}{"0346}
12098 \DeclareUTFEncodedAccent\crtilde{"034A}{"034A}
12099 \DeclareUTFEncodedAccent\dottedtilde{"034B}{"034B}
12100 \DeclareUTFEncodedAccent\doubletilde{"034C}{"034C}
12101 \DeclareUTFEncodedAccent\textrightarrowhead{"0350}{"02C3}
12102 \DeclareUTFEncodedAccent\textlefthalfring{"0351}{"02D3}
12103 \DeclareUTFEncodedAccent\textrighthalfring{"0357}{"02D2}
12104 \DeclareUTFDoubleEncodedSymbol\textdoublebrevebelow{"035C}{"035C}
12105 \DeclareUTFDoubleEncodedAccent\textdoublebreve{"035D}{"035D}
12106 \DeclareUTFDoubleEncodedAccent\textdoublemacron{"035E}{"035E}
12107 \DeclareUTFDoubleEncodedSymbol\textdoublemacronbelow{"035F}{"035F}
12108 \DeclareUTFDoubleEncodedAccent\textdoubletilde{"0360}{"0360}
12109 \DeclareUTFDoubleEncodedAccent\t{"0361}{"0361}
12110 \DeclareUTFDoubleEncodedAccent\capitaltie{"0361}{"0361}
12111 \DeclareUTFDoubleEncodedAccent\texttoptiebar{"0361}{"0361}
12112 \DeclareUTFDoubleEncodedSymbol\sliding{"0362}{"0362}
12113 \DeclareUTFTIPACommand\t
12114 \DeclareUTFTIPACommand\capitaltie
12115 \DeclareUTFTIPACommand\texttoptiebar
12116 \DeclareUTFTIPACommand\sliding
12117 \DeclareUTFEncodedAccent\texthighrise{"1DC4}{"1DC4}
12118 \DeclareUTFEncodedAccent\textlowrise{"1DC5}{"1DC5}
12119 \DeclareUTFEncodedAccent\textrisefall{"1DC8}{"1DC8}
12120 \DeclareUTFEncodedAccent\textfallrise{"1DC9}{"1DC9}
12121 \DeclareUTFEncodedAccent\textaolig{"1DD5}{"1DD5}
12122 \DeclareUTFCompositeSymbol\textundertie{H}{"1E2A}
12123 \DeclareUTFCompositeSymbol\textundertie{h}{"1E2B}
12124 \DeclareUTFEncodedAccents\textcircumgrave{"0302}{"0301}
12125 \DeclareUTFSymbol\textFinv{"2132}
12126 \DeclareUTFSymbol\textaleph{"2135}
12127 \DeclareUTFSymbol\textbeth{"2136}
12128 \DeclareUTFSymbol\textgimel{"2137}
12129 \DeclareUTFSymbol\textdaleth{"2138}
12130 \DeclareUTFSymbol\textGame{"2141}
12131 \DeclareUTFCompositeCommand\tonebar{25}{\tonebar{2}\tonebar{5}}
12132 \DeclareUTFCompositeCommand\tonebar{52}{\tonebar{5}\tonebar{2}}
12133 \DeclareUTFSymbol\textbigcircle{"25EF}
12134 \DeclareUTFEncodedCircle\textcircled{"20DD}{"25EF}
12135 \DeclareUTFCompositeSymbol\textcircled{0}{"24EA}
12136 \DeclareUTFCompositeSymbol\textcircled{1}{"2460}
12137 \DeclareUTFCompositeSymbol\textcircled{2}{"2461}
12138 \DeclareUTFCompositeSymbol\textcircled{3}{"2462}
12139 \DeclareUTFCompositeSymbol\textcircled{4}{"2463}
12140 \DeclareUTFCompositeSymbol\textcircled{5}{"2464}
12141 \DeclareUTFCompositeSymbol\textcircled{6}{"2465}
12142 \DeclareUTFCompositeSymbol\textcircled{7}{"2466}
12143 \DeclareUTFCompositeSymbol\textcircled{8}{"2467}
12144 \DeclareUTFCompositeSymbol\textcircled{9}{"2468}
12145 \DeclareUTFCompositeSymbol\textcircled{10}{"2469}
12146 \DeclareUTFCompositeSymbol\textcircled{11}{"246A}
12147 \DeclareUTFCompositeSymbol\textcircled{12}{"246B}
12148 \DeclareUTFCompositeSymbol\textcircled{13}{"246C}
12149 \DeclareUTFCompositeSymbol\textcircled{14}{"246D}
12150 \DeclareUTFCompositeSymbol\textcircled{15}{"246E}
12151 \DeclareUTFCompositeSymbol\textcircled{16}{"246F}
12152 \DeclareUTFCompositeSymbol\textcircled{17}{"2470}
12153 \DeclareUTFCompositeSymbol\textcircled{18}{"2471}
12154 \DeclareUTFCompositeSymbol\textcircled{19}{"2472}
12155 \DeclareUTFCompositeSymbol\textcircled{20}{"2473}
12156 \DeclareUTFCompositeSymbol\textcircled{21}{"3251}
12157 \DeclareUTFCompositeSymbol\textcircled{22}{"3252}
12158 \DeclareUTFCompositeSymbol\textcircled{23}{"3253}
12159 \DeclareUTFCompositeSymbol\textcircled{24}{"3254}
12160 \DeclareUTFCompositeSymbol\textcircled{25}{"3255}
12161 \DeclareUTFCompositeSymbol\textcircled{26}{"3256}
12162 \DeclareUTFCompositeSymbol\textcircled{27}{"3257}
12163 \DeclareUTFCompositeSymbol\textcircled{28}{"3258}
12164 \DeclareUTFCompositeSymbol\textcircled{29}{"3259}
12165 \DeclareUTFCompositeSymbol\textcircled{30}{"325A}
12166 \DeclareUTFCompositeSymbol\textcircled{31}{"325B}
12167 \DeclareUTFCompositeSymbol\textcircled{32}{"325C}
12168 \DeclareUTFCompositeSymbol\textcircled{33}{"325D}
12169 \DeclareUTFCompositeSymbol\textcircled{34}{"325E}
12170 \DeclareUTFCompositeSymbol\textcircled{35}{"325F}
12171 \DeclareUTFCompositeSymbol\textcircled{36}{"32B1}
12172 \DeclareUTFCompositeSymbol\textcircled{37}{"32B2}
12173 \DeclareUTFCompositeSymbol\textcircled{38}{"32B3}
12174 \DeclareUTFCompositeSymbol\textcircled{39}{"32B4}
12175 \DeclareUTFCompositeSymbol\textcircled{40}{"32B5}
12176 \DeclareUTFCompositeSymbol\textcircled{41}{"32B6}
12177 \DeclareUTFCompositeSymbol\textcircled{42}{"32B7}
12178 \DeclareUTFCompositeSymbol\textcircled{43}{"32B8}
12179 \DeclareUTFCompositeSymbol\textcircled{44}{"32B9}
12180 \DeclareUTFCompositeSymbol\textcircled{45}{"32BA}
12181 \DeclareUTFCompositeSymbol\textcircled{46}{"32BB}
12182 \DeclareUTFCompositeSymbol\textcircled{47}{"32BC}
12183 \DeclareUTFCompositeSymbol\textcircled{48}{"32BD}
12184 \DeclareUTFCompositeSymbol\textcircled{49}{"32BE}
12185 \DeclareUTFCompositeSymbol\textcircled{50}{"32BF}
12186 \DeclareUTFCompositeSymbol\textcircled{A}{"24B6}
12187 \DeclareUTFCompositeSymbol\textcircled{B}{"24B7}
12188 \DeclareUTFCompositeSymbol\textcircled{C}{"24B8}
12189 \DeclareUTFCompositeSymbol\textcircled{D}{"24B9}
12190 \DeclareUTFCompositeSymbol\textcircled{E}{"24BA}
12191 \DeclareUTFCompositeSymbol\textcircled{F}{"24BB}
12192 \DeclareUTFCompositeSymbol\textcircled{G}{"24BC}
12193 \DeclareUTFCompositeSymbol\textcircled{H}{"24BD}
12194 \DeclareUTFCompositeSymbol\textcircled{I}{"24BE}
12195 \DeclareUTFCompositeSymbol\textcircled{J}{"24BF}
12196 \DeclareUTFCompositeSymbol\textcircled{K}{"24C0}
12197 \DeclareUTFCompositeSymbol\textcircled{L}{"24C1}
12198 \DeclareUTFCompositeSymbol\textcircled{M}{"24C2}
12199 \DeclareUTFCompositeSymbol\textcircled{N}{"24C3}
12200 \DeclareUTFCompositeSymbol\textcircled{O}{"24C4}
12201 \DeclareUTFCompositeSymbol\textcircled{P}{"24C5}
12202 \DeclareUTFCompositeSymbol\textcircled{Q}{"24C6}
12203 \DeclareUTFCompositeSymbol\textcircled{R}{"24C7}
12204 \DeclareUTFCompositeSymbol\textcircled{S}{"24C8}
12205 \DeclareUTFCompositeSymbol\textcircled{T}{"24C9}
12206 \DeclareUTFCompositeSymbol\textcircled{U}{"24CA}
12207 \DeclareUTFCompositeSymbol\textcircled{V}{"24CB}
12208 \DeclareUTFCompositeSymbol\textcircled{W}{"24CC}
12209 \DeclareUTFCompositeSymbol\textcircled{X}{"24CD}
12210 \DeclareUTFCompositeSymbol\textcircled{Y}{"24CE}
12211 \DeclareUTFCompositeSymbol\textcircled{Z}{"24CF}
12212 \DeclareUTFCompositeSymbol\textcircled{a}{"24D0}
12213 \DeclareUTFCompositeSymbol\textcircled{b}{"24D1}
12214 \DeclareUTFCompositeSymbol\textcircled{c}{"24D2}
12215 \DeclareUTFCompositeSymbol\textcircled{d}{"24D3}
12216 \DeclareUTFCompositeSymbol\textcircled{e}{"24D4}
12217 \DeclareUTFCompositeSymbol\textcircled{f}{"24D5}
12218 \DeclareUTFCompositeSymbol\textcircled{g}{"24D6}
12219 \DeclareUTFCompositeSymbol\textcircled{h}{"24D7}
12220 \DeclareUTFCompositeSymbol\textcircled{i}{"24D8}
12221 \DeclareUTFCompositeSymbol\textcircled{j}{"24D9}
12222 \DeclareUTFCompositeSymbol\textcircled{k}{"24DA}
12223 \DeclareUTFCompositeSymbol\textcircled{l}{"24DB}
12224 \DeclareUTFCompositeSymbol\textcircled{m}{"24DC}
12225 \DeclareUTFCompositeSymbol\textcircled{n}{"24DD}
12226 \DeclareUTFCompositeSymbol\textcircled{o}{"24DE}
12227 \DeclareUTFCompositeSymbol\textcircled{p}{"24DF}
12228 \DeclareUTFCompositeSymbol\textcircled{q}{"24E0}
12229 \DeclareUTFCompositeSymbol\textcircled{r}{"24E1}
12230 \DeclareUTFCompositeSymbol\textcircled{s}{"24E2}
12231 \DeclareUTFCompositeSymbol\textcircled{t}{"24E3}
12232 \DeclareUTFCompositeSymbol\textcircled{u}{"24E4}
12233 \DeclareUTFCompositeSymbol\textcircled{v}{"24E5}
12234 \DeclareUTFCompositeSymbol\textcircled{w}{"24E6}
12235 \DeclareUTFCompositeSymbol\textcircled{x}{"24E7}
12236 \DeclareUTFCompositeSymbol\textcircled{y}{"24E8}
12237 \DeclareUTFCompositeSymbol\textcircled{z}{"24E9}
12238 \DeclareUTFCompositeSymbol\textsuperscript{h}{"02B0}
12239 \DeclareUTFCompositeSymbol\textsuperscript{\texthth}{"02B1}
12240 \DeclareUTFCompositeSymbol\textsuperscript{j}{"02B2}
12241 \DeclareUTFCompositeSymbol\textsuperscript{r}{"02B3}
12242 \DeclareUTFCompositeSymbol\textsuperscript{\textturnr}{"02B4}
12243 \DeclareUTFCompositeSymbol\textsuperscript{\textturnrrtail}{"02B5}
12244 \DeclareUTFCompositeSymbol\textsuperscript{\textinvscr}{"02B6}
12245 \DeclareUTFCompositeSymbol\textsuperscript{w}{"02B7}
12246 \DeclareUTFCompositeSymbol\textsuperscript{y}{"02B8}
12247 \DeclareUTFCompositeSymbol\textsuperscript{\textbabygamma}{"02E0}
12248 \DeclareUTFCompositeSymbol\textsuperscript{\textgammalatinsmall}{"02E0}
12249 \DeclareUTFCompositeSymbol\textsuperscript{l}{"02E1}
12250 \DeclareUTFCompositeSymbol\textsuperscript{s}{"02E2}
12251 \DeclareUTFCompositeSymbol\textsuperscript{x}{"02E3}
12252 \DeclareUTFCompositeSymbol\textsuperscript{\textrevglotstop}{"02E4}
12253 \DeclareUTFCompositeSymbol\textsuperscript{\textrevepsilon}{"1D4C}
12254 \DeclareUTFCompositeSymbol\textsuperscript{\cyrn}{"1D78}
12255 \DeclareUTFCompositeSymbol\textsuperscript{\textbarsci}{"1DA7}
12256 \DeclareUTFCompositeSymbol\textsuperscript{V}{"2C7D}
12257 \DeclareUTFCompositeSymbol\textsuperscript{\textHbar}{"A7F8}
12258 \DeclareUTFCompositeSymbol\textsuperscript{\textHslash}{"A7F8}
12259 \DeclareUTFCompositeSymbol\textsuperscript{\oe}{"A7F9}
12260 \DeclareUTFCompositeSymbol\textsubscript{h}{"2095}
12261 \DeclareUTFCompositeSymbol\textsubscript{k}{"2096}
12262 \DeclareUTFCompositeSymbol\textsubscript{l}{"2097}
12263 \DeclareUTFCompositeSymbol\textsubscript{m}{"2098}
12264 \DeclareUTFCompositeSymbol\textsubscript{n}{"2099}
12265 \DeclareUTFCompositeSymbol\textsubscript{p}{"209A}
12266 \DeclareUTFCompositeSymbol\textsubscript{s}{"209B}
12267 \DeclareUTFCompositeSymbol\textsubscript{t}{"209C}
12268 % \end{macrocode}
12269 %
12270 % \changes{v3.2.9}{2013/12/07}
12271 % {增加 \file{xunicode-extra.def} 中,用于加入 \file{puenc.def} 中的符号定义。}
12272 %
12273 % 以下定义取自 \pkg{hyperref} 的 \file{puenc.def}。
12274 % \begin{macrocode}
12275 \DeclareUTFEncodedAccent\textinvbreve{"0311}{"0311}
12276 \DeclareUTFEncodedSymbol\textsubbreve{"032E}{"203F}
12277 \DeclareUTFSymbol\textHT{"0009}
12278 \DeclareUTFSymbol\textLF{"000A}
12279 \DeclareUTFSymbol\textCR{"000D}
12280 \DeclareUTFSymbol\textnumbersign{"0023}
12281 \DeclareUTFSymbol\textparenleft{"0028}
12282 \DeclareUTFSymbol\textparenright{"0029}
12283 \DeclareUTFSymbol\textMVPlus{"002B}
12284 \DeclareUTFSymbol\textMVComma{"002C}
12285 \DeclareUTFSymbol\textMVMinus{"002D}
12286 \DeclareUTFSymbol\textMVPeriod{"002E}
12287 \DeclareUTFSymbol\textMVDivision{"002F}
12288 \DeclareUTFSymbol\textMVZero{"0030}
12289 \DeclareUTFSymbol\textMVOne{"0031}
12290 \DeclareUTFSymbol\textMVTwo{"0032}
12291 \DeclareUTFSymbol\textMVThree{"0033}
12292 \DeclareUTFSymbol\textMVFour{"0034}
12293 \DeclareUTFSymbol\textMVFive{"0035}
12294 \DeclareUTFSymbol\textMVSix{"0036}
12295 \DeclareUTFSymbol\textMVSeven{"0037}
12296 \DeclareUTFSymbol\textMVEight{"0038}
12297 \DeclareUTFSymbol\textMVNine{"0039}
12298 \DeclareUTFSymbol\textMVAt{"0040}
12299 \DeclareUTFCompositeCommand\.{\i}{i}
12300 \DeclareUTFCompositeCommand\.{i}{i}
12301 \DeclareUTFSymbol\textlnot{"00AC}
12302 \DeclareUTFSymbol\textplusminus{"00B1}
12303 \DeclareUTFSymbol\textcedilla{"00B8}
12304 \DeclareUTFSymbol\textmultiply{"00D7}
12305 \DeclareUTFSymbol\textThorn{"00DE}
12306 \DeclareUTFSymbol\textdivide{"00F7}
12307 \DeclareUTFSymbol\textHslash{"0126}
12308 \DeclareUTFCompositeSymbol\k{\i}{"012F}
12309 \DeclareUTFCompositeSymbol\.{L}{"013F}
12310 \DeclareUTFCompositeSymbol\.{l}{"0140}
12311 \DeclareUTFSymbol\textnapostrophe{"0149}
12312 \DeclareUTFSymbol\textTslash{"0166}
12313 \DeclareUTFSymbol\texttslash{"0167}
12314 \DeclareUTFSymbol\textlongs{"017F}
12315 \DeclareUTFSymbol\texthausaB{"0181}
12316 \DeclareUTFSymbol\texthausaD{"018A}
12317 \DeclareUTFSymbol\textrevE{"018E}
12318 \DeclareUTFSymbol\texthausaK{"0198}
12319 \DeclareUTFSymbol\textPUnrleg{"019E}
12320 \DeclareUTFSymbol\textinve{"01DD}
12321 \DeclareUTFSymbol\textGslash{"01E4}
12322 \DeclareUTFSymbol\textgslash{"01E5}
12323 \DeclareUTFCompositeSymbol\textinvbreve{E}{"0206}
12324 \DeclareUTFCompositeSymbol\textinvbreve{e}{"0207}
12325 \DeclareUTFCompositeSymbol\textinvbreve{I}{"020A}
12326 \DeclareUTFCompositeSymbol\textinvbreve{i}{"020B}
12327 \DeclareUTFCompositeSymbol\textinvbreve{\i}{"020B}
12328 \DeclareUTFCompositeSymbol\textinvbreve{O}{"020E}
12329 \DeclareUTFCompositeSymbol\textinvbreve{o}{"020F}
12330 \DeclareUTFCompositeSymbol\textinvbreve{U}{"0216}
12331 \DeclareUTFCompositeSymbol\textinvbreve{u}{"0217}
12332 \DeclareUTFSymbol\j{"0237}
12333 \DeclareUTFSymbol\textPUdblig{"0238}
12334 \DeclareUTFSymbol\textPUqplig{"0239}
12335 \DeclareUTFSymbol\textslashc{"023C}
12336 \DeclareUTFSymbol\textniepsilon{"025B}
12337 \DeclareUTFSymbol\textipagamma{"0263}
12338 \DeclareUTFSymbol\textniiota{"0269}
12339 \DeclareUTFSymbol\textniphi{"0278}
12340 \DeclareUTFSymbol\textniupsilon{"028A}
12341 \DeclareUTFSymbol\textring{"02DA}
12342 \DeclareUTFSymbol\texttilde{"02DC}
12343 \DeclareUTFSymbol\texthungarumlaut{"02DD}
12344 \DeclareUTFSymbol\textringlow{"02F3}
12345 \DeclareUTFSymbol\texttildelow{"02F7}
12346 \DeclareUTFCommand\textnewtie{\textinvbreve\ }
12347 \DeclareUTFCommand\textdotbelow{\d\ }
12348 \DeclareUTFSymbol\textmacronbelow{"02CD}
12349 \DeclareUTFCommand\texttie{\t\ }
12350 \DeclareUTFSymbol\textnumeralsigngreek{"0374}
12351 \DeclareUTFSymbol\textnumeralsignlowergreek{"0375}
12352 \DeclareUTFCompositeSymbol\'{\textAlpha}{"0386}
12353 \DeclareUTFCompositeSymbol\'{\textEpsilon}{"0388}
12354 \DeclareUTFCompositeSymbol\'{\textEta}{"0389}
12355 \DeclareUTFCompositeSymbol\'{\textIota}{"038A}
12356 \DeclareUTFCompositeSymbol\'{\textOmicron}{"038C}
12357 \DeclareUTFCompositeSymbol\'{\textUpsilon}{"038E}
12358 \DeclareUTFCompositeSymbol\'{\textOmega}{"038F}
12359 \DeclareUTFCompositeSymbol\'{\textIotadieresis}{"0390}
12360 \DeclareUTFSymbol\textIotadieresis{"03AA}
12361 \DeclareUTFCompositeSymbol\"{\textIota}{"03AA}
12362 \DeclareUTFCompositeSymbol\"{\textUpsilon}{"03AB}
12363 \DeclareUTFCompositeSymbol\'{\textalpha}{"03AC}
12364 \DeclareUTFCompositeSymbol\'{\textepsilon}{"03AD}
12365 \DeclareUTFCompositeSymbol\'{\texteta}{"03AE}
12366 \DeclareUTFCompositeSymbol\'{\textiota}{"03AF}
12367 \DeclareUTFCompositeSymbol\"{\textupsilonacute}{"03B0}
12368 \DeclareUTFSymbol\textmugreek{"03BC}
12369 \DeclareUTFSymbol\textvarsigma{"03C2}
12370 \DeclareUTFCompositeSymbol\"{\textiota}{"03CA}
12371 \DeclareUTFCompositeSymbol\"{\textupsilon}{"03CB}
12372 \DeclareUTFCompositeSymbol\'{\textomicron}{"03CC}
12373 \DeclareUTFSymbol\textupsilonacute{"03CD}
12374 \DeclareUTFCompositeSymbol\'{\textupsilon}{"03CD}
12375 \DeclareUTFCompositeSymbol\'{\textomega}{"03CE}
12376 \DeclareUTFSymbol\textStigmagreek{"03DA}
12377 \DeclareUTFSymbol\textstigmagreek{"03DB}
12378 \DeclareUTFSymbol\textDigammagreek{"03DC}
12379 \DeclareUTFSymbol\textdigammagreek{"03DD}
12380 \DeclareUTFSymbol\textKoppagreek{"03DE}
12381 \DeclareUTFSymbol\textkoppagreek{"03DF}
12382 \DeclareUTFSymbol\textSampigreek{"03E0}
12383 \DeclareUTFSymbol\textsampigreek{"03E1}
12384 \DeclareUTFSymbol\textbackepsilon{"03F6}
12385 \DeclareUTFCompositeSymbol\`{\CYRE}{"0400}
12386 \DeclareUTFSymbol\CYRYO{"0401}
12387 \DeclareUTFCompositeSymbol\"{\CYRE}{"0401}
12388 \DeclareUTFSymbol\CYRDJE{"0402}
12389 \DeclareUTFCompositeSymbol\'{\CYRG}{"0403}
12390 \DeclareUTFSymbol\CYRIE{"0404}
12391 \DeclareUTFSymbol\CYRDZE{"0405}
12392 \DeclareUTFSymbol\CYRII{"0406}
12393 \DeclareUTFSymbol\CYRYI{"0407}
12394 \DeclareUTFCompositeSymbol\"{\CYRII}{"0407}
12395 \DeclareUTFSymbol\CYRJE{"0408}
12396 \DeclareUTFSymbol\CYRLJE{"0409}
12397 \DeclareUTFSymbol\CYRNJE{"040A}
12398 \DeclareUTFSymbol\CYRTSHE{"040B}
12399 \DeclareUTFCompositeSymbol\'{\CYRK}{"040C}
12400 \DeclareUTFCompositeSymbol\`{\CYRI}{"040D}
12401 \DeclareUTFSymbol\CYRUSHRT{"040E}
12402 \DeclareUTFCompositeSymbol\U{\CYRU}{"040E}
12403 \DeclareUTFSymbol\CYRDZHE{"040F}
12404 \DeclareUTFSymbol\CYRA{"0410}
12405 \DeclareUTFSymbol\CYRB{"0411}
12406 \DeclareUTFSymbol\CYRV{"0412}
12407 \DeclareUTFSymbol\CYRG{"0413}
12408 \DeclareUTFSymbol\CYRD{"0414}
12409 \DeclareUTFSymbol\CYRE{"0415}
12410 \DeclareUTFSymbol\CYRZH{"0416}
12411 \DeclareUTFSymbol\CYRZ{"0417}
12412 \DeclareUTFSymbol\CYRI{"0418}
12413 \DeclareUTFSymbol\CYRISHRT{"0419}
12414 \DeclareUTFCompositeSymbol\U{\CYRI}{"0419}
12415 \DeclareUTFSymbol\CYRK{"041A}
12416 \DeclareUTFSymbol\CYRL{"041B}
12417 \DeclareUTFSymbol\CYRM{"041C}
12418 \DeclareUTFSymbol\CYRN{"041D}
12419 \DeclareUTFSymbol\CYRO{"041E}
12420 \DeclareUTFSymbol\CYRP{"041F}
12421 \DeclareUTFSymbol\CYRR{"0420}
12422 \DeclareUTFSymbol\CYRS{"0421}
12423 \DeclareUTFSymbol\CYRT{"0422}
12424 \DeclareUTFSymbol\CYRU{"0423}
12425 \DeclareUTFSymbol\CYRF{"0424}
12426 \DeclareUTFSymbol\CYRH{"0425}
12427 \DeclareUTFSymbol\CYRC{"0426}
12428 \DeclareUTFSymbol\CYRCH{"0427}
12429 \DeclareUTFSymbol\CYRSH{"0428}
12430 \DeclareUTFSymbol\CYRSHCH{"0429}
12431 \DeclareUTFSymbol\CYRHRDSN{"042A}
12432 \DeclareUTFSymbol\CYRERY{"042B}
12433 \DeclareUTFSymbol\CYRSFTSN{"042C}
12434 \DeclareUTFSymbol\CYREREV{"042D}
12435 \DeclareUTFSymbol\CYRYU{"042E}
12436 \DeclareUTFSymbol\CYRYA{"042F}
12437 \DeclareUTFSymbol\cyra{"0430}
12438 \DeclareUTFSymbol\cyrb{"0431}
12439 \DeclareUTFSymbol\cyrv{"0432}
12440 \DeclareUTFSymbol\cyrg{"0433}
12441 \DeclareUTFSymbol\cyrd{"0434}
12442 \DeclareUTFSymbol\cyre{"0435}
12443 \DeclareUTFSymbol\cyrzh{"0436}
12444 \DeclareUTFSymbol\cyrz{"0437}
12445 \DeclareUTFSymbol\cyri{"0438}
12446 \DeclareUTFSymbol\cyrishrt{"0439}
12447 \DeclareUTFCompositeSymbol\U{\cyri}{"0439}
12448 \DeclareUTFSymbol\cyrk{"043A}
12449 \DeclareUTFSymbol\cyrl{"043B}
12450 \DeclareUTFSymbol\cyrm{"043C}
12451 \DeclareUTFSymbol\cyrn{"043D}
12452 \DeclareUTFSymbol\cyro{"043E}
12453 \DeclareUTFSymbol\cyrp{"043F}
12454 \DeclareUTFSymbol\cyrr{"0440}
12455 \DeclareUTFSymbol\cyrs{"0441}
12456 \DeclareUTFSymbol\cyrt{"0442}
12457 \DeclareUTFSymbol\cyru{"0443}
12458 \DeclareUTFSymbol\cyrf{"0444}
12459 \DeclareUTFSymbol\cyrh{"0445}
12460 \DeclareUTFSymbol\cyrc{"0446}
12461 \DeclareUTFSymbol\cyrch{"0447}
12462 \DeclareUTFSymbol\cyrsh{"0448}
12463 \DeclareUTFSymbol\cyrshch{"0449}
12464 \DeclareUTFSymbol\cyrhrdsn{"044A}
12465 \DeclareUTFSymbol\cyrery{"044B}
12466 \DeclareUTFSymbol\cyrsftsn{"044C}
12467 \DeclareUTFSymbol\cyrerev{"044D}
12468 \DeclareUTFSymbol\cyryu{"044E}
12469 \DeclareUTFSymbol\cyrya{"044F}
12470 \DeclareUTFCompositeSymbol\`{\cyre}{"0450}
12471 \DeclareUTFSymbol\cyryo{"0451}
12472 \DeclareUTFCompositeSymbol\"{\cyre}{"0451}
12473 \DeclareUTFSymbol\cyrdje{"0452}
12474 \DeclareUTFCompositeSymbol\'{\cyrg}{"0453}
12475 \DeclareUTFSymbol\cyrie{"0454}
12476 \DeclareUTFSymbol\cyrdze{"0455}
12477 \DeclareUTFSymbol\cyrii{"0456}
12478 \DeclareUTFSymbol\cyryi{"0457}
12479 \DeclareUTFCompositeSymbol\"{\cyrii}{"0457}
12480 \DeclareUTFSymbol\cyrje{"0458}
12481 \DeclareUTFSymbol\cyrlje{"0459}
12482 \DeclareUTFSymbol\cyrnje{"045A}
12483 \DeclareUTFSymbol\cyrtshe{"045B}
12484 \DeclareUTFCompositeSymbol\'{\cyrk}{"045C}
12485 \DeclareUTFCompositeSymbol\`{\cyri}{"045D}
12486 \DeclareUTFSymbol\cyrushrt{"045E}
12487 \DeclareUTFCompositeSymbol\U{\curu}{"045E}
12488 \DeclareUTFSymbol\cyrdzhe{"045F}
12489 \DeclareUTFSymbol\CYROMEGA{"0460}
12490 \DeclareUTFSymbol\cyromega{"0461}
12491 \DeclareUTFSymbol\CYRYAT{"0462}
12492 \DeclareUTFSymbol\cyryat{"0463}
12493 \DeclareUTFSymbol\CYRIOTE{"0464}
12494 \DeclareUTFSymbol\cyriote{"0465}
12495 \DeclareUTFSymbol\CYRLYUS{"0466}
12496 \DeclareUTFSymbol\cyrlyus{"0467}
12497 \DeclareUTFSymbol\CYRIOTLYUS{"0468}
12498 \DeclareUTFSymbol\cyriotlyus{"0469}
12499 \DeclareUTFSymbol\CYRBYUS{"046A}
12500 \DeclareUTFSymbol\cyrbyus{"046B}
12501 \DeclareUTFSymbol\CYRIOTBYUS{"046C}
12502 \DeclareUTFSymbol\cyriotbyus{"046D}
12503 \DeclareUTFSymbol\CYRKSI{"046E}
12504 \DeclareUTFSymbol\cyrksi{"046F}
12505 \DeclareUTFSymbol\CYRPSI{"0470}
12506 \DeclareUTFSymbol\cyrpsi{"0471}
12507 \DeclareUTFSymbol\CYRFITA{"0472}
12508 \DeclareUTFSymbol\cyrfita{"0473}
12509 \DeclareUTFSymbol\CYRIZH{"0474}
12510 \DeclareUTFSymbol\cyrizh{"0475}
12511 \DeclareUTFCompositeSymbol\C{\CYRIZH}{"0476}
12512 \DeclareUTFCompositeSymbol\C{\cyrizh}{"0477}
12513 \DeclareUTFSymbol\CYRUK{"0478}
12514 \DeclareUTFSymbol\cyruk{"0479}
12515 \DeclareUTFSymbol\CYROMEGARND{"047A}
12516 \DeclareUTFSymbol\cyromegarnd{"047B}
12517 \DeclareUTFSymbol\CYROMEGATITLO{"047C}
12518 \DeclareUTFSymbol\cyromegatitlo{"047D}
12519 \DeclareUTFSymbol\CYROT{"047E}
12520 \DeclareUTFSymbol\cyrot{"047F}
12521 \DeclareUTFSymbol\CYRKOPPA{"0480}
12522 \DeclareUTFSymbol\cyrkoppa{"0481}
12523 \DeclareUTFSymbol\cyrthousands{"0482}
12524 \DeclareUTFSymbol\CYRISHRTDSC{"048A}
12525 \DeclareUTFSymbol\cyrishrtdsc{"048B}
12526 \DeclareUTFSymbol\CYRSEMISFTSN{"048C}
12527 \DeclareUTFSymbol\cyrsemisftsn{"048D}
12528 \DeclareUTFSymbol\CYRRTICK{"048E}
12529 \DeclareUTFSymbol\cyrrtick{"048F}
12530 \DeclareUTFSymbol\CYRGUP{"0490}
12531 \DeclareUTFSymbol\cyrgup{"0491}
12532 \DeclareUTFSymbol\CYRGHCRS{"0492}
12533 \DeclareUTFSymbol\cyrghcrs{"0493}
12534 \DeclareUTFSymbol\CYRGHK{"0494}
12535 \DeclareUTFSymbol\cyrghk{"0495}
12536 \DeclareUTFSymbol\CYRZHDSC{"0496}
12537 \DeclareUTFSymbol\cyrzhdsc{"0497}
12538 \DeclareUTFSymbol\CYRZDSC{"0498}
12539 \DeclareUTFCompositeSymbol\c{\CYRZ}{"0498}
12540 \DeclareUTFSymbol\cyrzdsc{"0499}
12541 \DeclareUTFCompositeSymbol\c{\cyrz}{"0499}
12542 \DeclareUTFSymbol\CYRKDSC{"049A}
12543 \DeclareUTFSymbol\cyrkdsc{"049B}
12544 \DeclareUTFSymbol\CYRKVCRS{"049C}
12545 \DeclareUTFSymbol\cyrkvcrs{"049D}
12546 \DeclareUTFSymbol\CYRKHCRS{"049E}
12547 \DeclareUTFSymbol\cyrkhcrs{"049F}
12548 \DeclareUTFSymbol\CYRKBEAK{"04A0}
12549 \DeclareUTFSymbol\cyrkbeak{"04A1}
12550 \DeclareUTFSymbol\CYRNDSC{"04A2}
12551 \DeclareUTFSymbol\cyrndsc{"04A3}
12552 \DeclareUTFSymbol\CYRNG{"04A4}
12553 \DeclareUTFSymbol\cyrng{"04A5}
12554 \DeclareUTFSymbol\CYRPHK{"04A6}
12555 \DeclareUTFSymbol\cyrphk{"04A7}
12556 \DeclareUTFSymbol\CYRABHHA{"04A8}
12557 \DeclareUTFSymbol\cyrabhha{"04A9}
12558 \DeclareUTFSymbol\CYRSDSC{"04AA}
12559 \DeclareUTFCompositeSymbol\CYRSDSC{\CYRS}{"04AA}
12560 \DeclareUTFSymbol\cyrsdsc{"04AB}
12561 \DeclareUTFCompositeSymbol\k{\cyrs}{"04AB}
12562 \DeclareUTFSymbol\CYRTDSC{"04AC}
12563 \DeclareUTFSymbol\cyrtdsc{"04AD}
12564 \DeclareUTFSymbol\CYRY{"04AE}
12565 \DeclareUTFSymbol\cyry{"04AF}
12566 \DeclareUTFSymbol\CYRYHCRS{"04B0}
12567 \DeclareUTFSymbol\cyryhcrs{"04B1}
12568 \DeclareUTFSymbol\CYRHDSC{"04B2}
12569 \DeclareUTFSymbol\cyrhdsc{"04B3}
12570 \DeclareUTFSymbol\CYRTETSE{"04B4}
12571 \DeclareUTFSymbol\cyrtetse{"04B5}
12572 \DeclareUTFSymbol\CYRCHRDSC{"04B6}
12573 \DeclareUTFSymbol\cyrchrdsc{"04B7}
12574 \DeclareUTFSymbol\CYRCHVCRS{"04B8}
12575 \DeclareUTFSymbol\cyrchvcrs{"04B9}
12576 \DeclareUTFSymbol\CYRSHHA{"04BA}
12577 \DeclareUTFSymbol\cyrshha{"04BB}
12578 \DeclareUTFSymbol\CYRABHCH{"04BC}
12579 \DeclareUTFSymbol\cyrabhch{"04BD}
12580 \DeclareUTFSymbol\CYRABHCHDSC{"04BE}
12581 \DeclareUTFCompositeSymbol\k{\CYRABHCH}{"04BE}
12582 \DeclareUTFSymbol\cyrabhchdsc{"04BF}
12583 \DeclareUTFCompositeSymbol\k{\cyrabhch}{"04BF}
12584 \DeclareUTFSymbol\CYRpalochka{"04C0}
12585 \DeclareUTFCompositeSymbol\U{\CYRZH}{"04C1}
12586 \DeclareUTFCompositeSymbol\U{\cyrzh}{"04C2}
12587 \DeclareUTFSymbol\CYRKHK{"04C3}
12588 \DeclareUTFSymbol\cyrkhk{"04C4}
12589 \DeclareUTFSymbol\CYRLDSC{"04C5}
12590 \DeclareUTFSymbol\cyrldsc{"04C6}
12591 \DeclareUTFSymbol\CYRNHK{"04C7}
12592 \DeclareUTFSymbol\cyrnhk{"04C8}
12593 \DeclareUTFSymbol\CYRCHLDSC{"04CB}
12594 \DeclareUTFSymbol\cyrchldsc{"04CC}
12595 \DeclareUTFSymbol\CYRMDSC{"04CD}
12596 \DeclareUTFSymbol\cyrmdsc{"04CE}
12597 \DeclareUTFCompositeSymbol\U{\CYRA}{"04D0}
12598 \DeclareUTFCompositeSymbol\U{\cyra}{"04D1}
12599 \DeclareUTFCompositeSymbol\"{\CYRA}{"04D2}
12600 \DeclareUTFCompositeSymbol\"{\cyra}{"04D3}
12601 \DeclareUTFSymbol\CYRAE{"04D4}
12602 \DeclareUTFSymbol\cyrae{"04D5}
12603 \DeclareUTFCompositeSymbol\U{\CYRE}{"04D6}
12604 \DeclareUTFCompositeSymbol\U{\cyre}{"04D7}
12605 \DeclareUTFSymbol\CYRSCHWA{"04D8}
12606 \DeclareUTFSymbol\cyrschwa{"04D9}
12607 \DeclareUTFCompositeSymbol\"{\CYRSCHWA}{"04DA}
12608 \DeclareUTFCompositeSymbol\"{\cyrschwa}{"04DB}
12609 \DeclareUTFCompositeSymbol\"{\CYRZH}{"04DC}
12610 \DeclareUTFCompositeSymbol\"{\cyrzh}{"04DD}
12611 \DeclareUTFCompositeSymbol\"{\CYRZ}{"04DE}
12612 \DeclareUTFCompositeSymbol\"{\cyrz}{"04DF}
12613 \DeclareUTFSymbol\CYRABHDZE{"04E0}
12614 \DeclareUTFSymbol\cyrabhdze{"04E1}
12615 \DeclareUTFCompositeSymbol\={\CYRI}{"04E2}
12616 \DeclareUTFCompositeSymbol\={\cyri}{"04E3}
12617 \DeclareUTFCompositeSymbol\"{\CYRI}{"04E4}
12618 \DeclareUTFCompositeSymbol\"{\cyri}{"04E5}
12619 \DeclareUTFCompositeSymbol\"{\CYRO}{"04E6}
12620 \DeclareUTFCompositeSymbol\"{\cyro}{"04E7}
12621 \DeclareUTFSymbol\CYROTLD{"04E8}
12622 \DeclareUTFSymbol\cyrotld{"04E9}
12623 \DeclareUTFCompositeSymbol\"{\CYROTLD}{"04EA}
12624 \DeclareUTFCompositeSymbol\"{\cyrotld}{"04EB}
12625 \DeclareUTFCompositeSymbol\"{\CYREREV}{"04EC}
12626 \DeclareUTFCompositeSymbol\"{\cyreref}{"04ED}
12627 \DeclareUTFCompositeSymbol\={\CYRU}{"04EE}
12628 \DeclareUTFCompositeSymbol\={\cyru}{"04EF}
12629 \DeclareUTFCompositeSymbol\"{\CYRU}{"04F0}
12630 \DeclareUTFCompositeSymbol\"{\cyru}{"04F1}
12631 \DeclareUTFCompositeSymbol\H{\CYRU}{"04F2}
12632 \DeclareUTFCompositeSymbol\H{\cyru}{"04F3}
12633 \DeclareUTFCompositeSymbol\"{\CYRCH}{"04F4}
12634 \DeclareUTFCompositeSymbol\"{\cyrch}{"04F5}
12635 \DeclareUTFSymbol\CYRGDSC{"04F6}
12636 \DeclareUTFSymbol\cyrgdsc{"04F7}
12637 \DeclareUTFCompositeSymbol\"{\CYRERY}{"04F8}
12638 \DeclareUTFCompositeSymbol\"{\cyrery}{"04F9}
12639 \DeclareUTFSymbol\CYRHHK{"04FC}
12640 \DeclareUTFSymbol\cyrhhk{"04FD}
12641 \DeclareUTFSymbol\sofpasuq{"05C3}
12642 \DeclareUTFSymbol\hebalef{"05D0}
12643 \DeclareUTFSymbol\hebbet{"05D1}
12644 \DeclareUTFSymbol\hebgimel{"05D2}
12645 \DeclareUTFSymbol\hebdalet{"05D3}
12646 \DeclareUTFSymbol\hebhe{"05D4}
12647 \DeclareUTFSymbol\hebvav{"05D5}
12648 \DeclareUTFSymbol\hebzayin{"05D6}
12649 \DeclareUTFSymbol\hebhet{"05D7}
12650 \DeclareUTFSymbol\hebtet{"05D8}
12651 \DeclareUTFSymbol\hebyod{"05D9}
12652 \DeclareUTFSymbol\hebfinalkaf{"05DA}
12653 \DeclareUTFSymbol\hebkaf{"05DB}
12654 \DeclareUTFSymbol\heblamed{"05DC}
12655 \DeclareUTFSymbol\hebfinalmem{"05DD}
12656 \DeclareUTFSymbol\hebmem{"05DE}
12657 \DeclareUTFSymbol\hebfinalnun{"05DF}
12658 \DeclareUTFSymbol\hebnun{"05E0}
12659 \DeclareUTFSymbol\hebsamekh{"05E1}
12660 \DeclareUTFSymbol\hebayin{"05E2}
12661 \DeclareUTFSymbol\hebfinalpe{"05E3}
12662 \DeclareUTFSymbol\hebpe{"05E4}
12663 \DeclareUTFSymbol\hebfinaltsadi{"05E5}
12664 \DeclareUTFSymbol\hebtsadi{"05E6}
12665 \DeclareUTFSymbol\hebqof{"05E7}
12666 \DeclareUTFSymbol\hebresh{"05E8}
12667 \DeclareUTFSymbol\hebshin{"05E9}
12668 \DeclareUTFSymbol\hebtav{"05EA}
12669 \DeclareUTFSymbol\doublevav{"05F0}
12670 \DeclareUTFSymbol\vavyod{"05F1}
12671 \DeclareUTFSymbol\doubleyod{"05F2}
12672 \DeclareUTFSymbol\textscd{"1D05}
12673 \DeclareUTFSymbol\textPUsck{"1D0B}
12674 \DeclareUTFSymbol\textPUscm{"1D0D}
12675 \DeclareUTFSymbol\textPUscp{"1D18}
12676 \DeclareUTFSymbol\textPUrevscr{"1D19}
12677 \DeclareUTFSymbol\textiinferior{"1D62}
12678 \DeclareUTFSymbol\textrinferior{"1D63}
12679 \DeclareUTFSymbol\textuinferior{"1D64}
12680 \DeclareUTFSymbol\textvinferior{"1D65}
12681 \DeclareUTFSymbol\textbetainferior{"1D66}
12682 \DeclareUTFSymbol\textgammainferior{"1D67}
12683 \DeclareUTFSymbol\textrhoinferior{"1D68}
12684 \DeclareUTFSymbol\textphiinferior{"1D69}
12685 \DeclareUTFSymbol\textchiinferior{"1D6A}
12686 \DeclareUTFSymbol\textbarsci{"1D7B}
12687 \DeclareUTFSymbol\textbarp{"1D7D}
12688 \DeclareUTFSymbol\textbarscu{"1D7E}
12689 \DeclareUTFSymbol\textPUrhooka{"1D8F}
12690 \DeclareUTFSymbol\textPUrhooke{"1D92}
12691 \DeclareUTFSymbol\textPUrhookepsilon{"1D93}
12692 \DeclareUTFSymbol\textPUrhookopeno{"1D97}
12693 \DeclareUTFCompositeSymbol\textsubbreve{H}{"1E2A}
12694 \DeclareUTFCompositeSymbol\textsubbreve{h}{"1E2B}
12695 \DeclareUTFCompositeSymbol\.{\textlongs}{"1E9B}
12696 \DeclareUTFSymbol\textcompwordmark{"200C}
12697 \DeclareUTFSymbol\texthdotfor{"2025}
12698 \DeclareUTFSymbol\textprime{"2032}
12699 \DeclareUTFSymbol\textsecond{"2033}
12700 \DeclareUTFSymbol\textthird{"2034}
12701 \DeclareUTFSymbol\textbackprime{"2035}
12702 \DeclareUTFSymbol\textlefttherefore{"2056}
12703 \DeclareUTFSymbol\textfourth{"2057}
12704 \DeclareUTFSymbol\textdiamonddots{"2058}
12705 \DeclareUTFSymbol\textzerosuperior{"2070}
12706 \DeclareUTFSymbol\textisuperior{"2071}
12707 \DeclareUTFSymbol\textfoursuperior{"2074}
12708 \DeclareUTFSymbol\textfivesuperior{"2075}
12709 \DeclareUTFSymbol\textsixsuperior{"2076}
12710 \DeclareUTFSymbol\textsevensuperior{"2077}
12711 \DeclareUTFSymbol\texteightsuperior{"2078}
12712 \DeclareUTFSymbol\textninesuperior{"2079}
12713 \DeclareUTFSymbol\textplussuperior{"207A}
12714 \DeclareUTFSymbol\textminussuperior{"207B}
12715 \DeclareUTFSymbol\textequalsuperior{"207C}
12716 \DeclareUTFSymbol\textparenleftsuperior{"207D}
12717 \DeclareUTFSymbol\textparenrightsuperior{"207E}
12718 \DeclareUTFSymbol\textnsuperior{"207F}
12719 \DeclareUTFSymbol\textzeroinferior{"2080}
12720 \DeclareUTFSymbol\textoneinferior{"2081}
12721 \DeclareUTFSymbol\texttwoinferior{"2082}
12722 \DeclareUTFSymbol\textthreeinferior{"2083}
12723 \DeclareUTFSymbol\textfourinferior{"2084}
12724 \DeclareUTFSymbol\textfiveinferior{"2085}
12725 \DeclareUTFSymbol\textsixinferior{"2086}
12726 \DeclareUTFSymbol\textseveninferior{"2087}
12727 \DeclareUTFSymbol\texteightinferior{"2088}
12728 \DeclareUTFSymbol\textnineinferior{"2089}
12729 \DeclareUTFSymbol\textplusinferior{"208A}
12730 \DeclareUTFSymbol\textminusinferior{"208B}
12731 \DeclareUTFSymbol\textequalsinferior{"208C}
12732 \DeclareUTFSymbol\textparenleftinferior{"208D}
12733 \DeclareUTFSymbol\textparenrightinferior{"208E}
12734 \DeclareUTFSymbol\textainferior{"2090}
12735 \DeclareUTFSymbol\texteinferior{"2091}
12736 \DeclareUTFSymbol\textoinferior{"2092}
12737 \DeclareUTFSymbol\textxinferior{"2093}
12738 \DeclareUTFSymbol\textschwainferior{"2094}
12739 \DeclareUTFSymbol\texthinferior{"2095}
12740 \DeclareUTFSymbol\textkinferior{"2096}
12741 \DeclareUTFSymbol\textlinferior{"2097}
12742 \DeclareUTFSymbol\textminferior{"2098}
12743 \DeclareUTFSymbol\textninferior{"2099}
12744 \DeclareUTFSymbol\textpinferior{"209A}
12745 \DeclareUTFSymbol\textsinferior{"209B}
12746 \DeclareUTFSymbol\texttinferior{"209C}
12747 \DeclareUTFSymbol\textpeseta{"20A7}
12748 \DeclareUTFSymbol\textDeleatur{"20B0}
12749 \DeclareUTFSymbol\textguarani{"20B2}
12750 \DeclareUTFSymbol\texthslash{"210F}
12751 \DeclareUTFSymbol\textIm{"2111}
12752 \DeclareUTFSymbol\textell{"2113}
12753 \DeclareUTFSymbol\textwp{"2118}
12754 \DeclareUTFSymbol\textRe{"211C}
12755 \DeclareUTFSymbol\textriota{"2129}
12756 \DeclareUTFSymbol\textangstrom{"212B}
12757 \DeclareUTFSymbol\textfax{"213B}
12758 \DeclareUTFSymbol\textinvamp{"214B}
12759 \DeclareUTFSymbol\textoneseventh{"2150}
12760 \DeclareUTFSymbol\textoneninth{"2151}
12761 \DeclareUTFSymbol\textonetenth{"2152}
12762 \DeclareUTFSymbol\textonethird{"2153}
12763 \DeclareUTFSymbol\texttwothirds{"2154}
12764 \DeclareUTFSymbol\textonefifth{"2155}
12765 \DeclareUTFSymbol\texttwofifths{"2156}
12766 \DeclareUTFSymbol\textthreefifths{"2157}
12767 \DeclareUTFSymbol\textfourfifths{"2158}
12768 \DeclareUTFSymbol\textonesixth{"2159}
12769 \DeclareUTFSymbol\textfivesixths{"215A}
12770 \DeclareUTFSymbol\textoneeighth{"215B}
12771 \DeclareUTFSymbol\textthreeeighths{"215C}
12772 \DeclareUTFSymbol\textfiveeighths{"215D}
12773 \DeclareUTFSymbol\textseveneighths{"215E}
12774 \DeclareUTFSymbol\textrevc{"2184}
12775 \DeclareUTFSymbol\textzerothirds{"2189}
12776 \DeclareUTFSymbol\textnleftarrow{"219A}
12777 \DeclareUTFSymbol\textnrightarrow{"219B}
12778 \DeclareUTFSymbol\texttwoheadleftarrow{"219E}
12779 \DeclareUTFCommand\textntwoheadleftarrow{\textlstrikethru\texttwoheadleftarrow}
12780 \DeclareUTFSymbol\texttwoheaduparrow{"219F}
12781 \DeclareUTFSymbol\texttwoheadrightarrow{"21A0}
12782 \DeclareUTFCommand\textntwoheadrightarrow{\textlstrikethru\texttwoheadrightarrow}
12783 \DeclareUTFSymbol\texttwoheaddownarrow{"21A1}
12784 \DeclareUTFSymbol\textleftarrowtail{"21A2}
12785 \DeclareUTFSymbol\textrightarrowtail{"21A3}
12786 \DeclareUTFSymbol\textmapsto{"21A6}
12787 \DeclareUTFSymbol\texthookleftarrow{"21A9}
12788 \DeclareUTFSymbol\texthookrightarrow{"21AA}
12789 \DeclareUTFSymbol\textlooparrowleft{"21AB}
12790 \DeclareUTFSymbol\textlooparrowright{"21AC}
12791 \DeclareUTFSymbol\textnleftrightarrow{"21AE}
12792 \DeclareUTFSymbol\textlightning{"21AF}
12793 \DeclareUTFSymbol\textdlsh{"21B5}
12794 \DeclareUTFSymbol\textcurvearrowleft{"21B6}
12795 \DeclareUTFSymbol\textcurvearrowright{"21B7}
12796 \DeclareUTFSymbol\textleftharpoonup{"21BC}
12797 \DeclareUTFSymbol\textleftharpoondown{"21BD}
12798 \DeclareUTFSymbol\textupharpoonright{"21BE}
12799 \DeclareUTFSymbol\textupharpoonleft{"21BF}
12800 \DeclareUTFSymbol\textrightharpoonup{"21C0}
12801 \DeclareUTFSymbol\textrightharpoondown{"21C1}
12802 \DeclareUTFSymbol\textdownharpoonright{"21C2}
12803 \DeclareUTFSymbol\textdownharpoonleft{"21C3}
12804 \DeclareUTFSymbol\textrightleftarrows{"21C4}
12805 \DeclareUTFSymbol\textupdownarrows{"21C5}
12806 \DeclareUTFSymbol\textleftrightarrows{"21C6}
12807 \DeclareUTFSymbol\textleftleftarrows{"21C7}
12808 \DeclareUTFSymbol\textupuparrows{"21C8}
12809 \DeclareUTFSymbol\textrightrightarrows{"21C9}
12810 \DeclareUTFSymbol\textdowndownarrows{"21CA}
12811 \DeclareUTFSymbol\textleftrightharpoons{"21CB}
12812 \DeclareUTFSymbol\textrightleftharpoons{"21CC}
12813 \DeclareUTFSymbol\textnLeftarrow{"21CD}
12814 \DeclareUTFSymbol\textnLeftrightarrow{"21CE}
12815 \DeclareUTFSymbol\textnRightarrow{"21CF}
12816 \DeclareUTFSymbol\textLeftarrow{"21D0}
12817 \DeclareUTFSymbol\textUparrow{"21D1}
12818 \DeclareUTFSymbol\textRightarrow{"21D2}
12819 \DeclareUTFSymbol\textDownarrow{"21D3}
12820 \DeclareUTFSymbol\textLeftrightarrow{"21D4}
12821 \DeclareUTFSymbol\textUpdownarrow{"21D5}
12822 \DeclareUTFSymbol\textNwarrow{"21D6}
12823 \DeclareUTFSymbol\textNearrow{"21D7}
12824 \DeclareUTFSymbol\textSearrow{"21D8}
12825 \DeclareUTFSymbol\textSwarrow{"21D9}
12826 \DeclareUTFSymbol\textLleftarrow{"21DA}
12827 \DeclareUTFSymbol\textRrightarrow{"21DB}
12828 \DeclareUTFSymbol\textleftsquigarrow{"21DC}
12829 \DeclareUTFSymbol\textrightsquigarrow{"21DD}
12830 \DeclareUTFSymbol\textdashleftarrow{"21E0}
12831 \DeclareUTFSymbol\textdasheduparrow{"21E1}
12832 \DeclareUTFSymbol\textdashrightarrow{"21E2}
12833 \DeclareUTFSymbol\textdasheddownarrow{"21E3}
12834 \DeclareUTFSymbol\textpointer{"21E8}
12835 \DeclareUTFSymbol\textdownuparrows{"21F5}
12836 \DeclareUTFSymbol\textleftarrowtriangle{"21FD}
12837 \DeclareUTFSymbol\textrightarrowtriangle{"21FE}
12838 \DeclareUTFSymbol\textleftrightarrowtriangle{"21FF}
12839 \DeclareUTFSymbol\textforall{"2200}
12840 \DeclareUTFSymbol\textcomplement{"2201}
12841 \DeclareUTFSymbol\textpartial{"2202}
12842 \DeclareUTFSymbol\textexists{"2203}
12843 \DeclareUTFSymbol\textnexists{"2204}
12844 \DeclareUTFSymbol\textemptyset{"2205}
12845 \DeclareUTFSymbol\texttriangle{"2206}
12846 \DeclareUTFSymbol\textnabla{"2207}
12847 \DeclareUTFSymbol\textin{"2208}
12848 \DeclareUTFSymbol\textnotin{"2209}
12849 \DeclareUTFSymbol\textsmallin{"220A}
12850 \DeclareUTFSymbol\textni{"220B}
12851 \DeclareUTFSymbol\textnotowner{"220C}
12852 \DeclareUTFSymbol\textsmallowns{"220D}
12853 \DeclareUTFSymbol\textprod{"220F}
12854 \DeclareUTFSymbol\textamalg{"2210}
12855 \DeclareUTFSymbol\textsum{"2211}
12856 \DeclareUTFSymbol\textmp{"2213}
12857 \DeclareUTFSymbol\textdotplus{"2214}
12858 \DeclareUTFSymbol\textDivides{"2215}
12859 \DeclareUTFSymbol\textsetminus{"2216}
12860 \DeclareUTFSymbol\textast{"2217}
12861 \DeclareUTFSymbol\textcirc{"2218}
12862 \DeclareUTFSymbol\textbulletoperator{"2219}
12863 \DeclareUTFSymbol\textpropto{"221D}
12864 \DeclareUTFSymbol\textinfty{"221E}
12865 \DeclareUTFSymbol\textangle{"2220}
12866 \DeclareUTFSymbol\textmeasuredangle{"2221}
12867 \DeclareUTFSymbol\textsphericalangle{"2222}
12868 \DeclareUTFSymbol\textmid{"2223}
12869 \DeclareUTFSymbol\textnmid{"2224}
12870 \DeclareUTFSymbol\textparallel{"2225}
12871 \DeclareUTFSymbol\textnparallel{"2226}
12872 \DeclareUTFSymbol\textwedge{"2227}
12873 \DeclareUTFCommand\textowedge{\textcircled\textwedge}
12874 \DeclareUTFSymbol\textvee{"2228}
12875 \DeclareUTFCommand\textovee{\textcircled\textvee}
12876 \DeclareUTFSymbol\textcap{"2229}
12877 \DeclareUTFSymbol\textcup{"222A}
12878 \DeclareUTFSymbol\textint{"222B}
12879 \DeclareUTFSymbol\textiint{"222C}
12880 \DeclareUTFSymbol\textiiint{"222D}
12881 \DeclareUTFSymbol\textoint{"222E}
12882 \DeclareUTFSymbol\textoiint{"222F}
12883 \DeclareUTFSymbol\textointclockwise{"2232}
12884 \DeclareUTFSymbol\textointctrclockwise{"2233}
12885 \DeclareUTFSymbol\texttherefore{"2234}
12886 \DeclareUTFSymbol\textbecause{"2235}
12887 \DeclareUTFSymbol\textvdotdot{"2236}
12888 \DeclareUTFSymbol\textsquaredots{"2237}
12889 \DeclareUTFSymbol\textdotminus{"2238}
12890 \DeclareUTFSymbol\texteqcolon{"2239}
12891 \DeclareUTFSymbol\textsim{"223C}
12892 \DeclareUTFSymbol\textbacksim{"223D}
12893 \DeclareUTFCommand\textnbacksim{\textlstrikethru\textnbacksim}
12894 \DeclareUTFSymbol\textwr{"2240}
12895 \DeclareUTFSymbol\textnsim{"2241}
12896 \DeclareUTFSymbol\texteqsim{"2242}
12897 \DeclareUTFCommand\textneqsim{\textlstrikethru\texteqsim}
12898 \DeclareUTFSymbol\textsimeq{"2243}
12899 \DeclareUTFSymbol\textnsimeq{"2244}
12900 \DeclareUTFSymbol\textcong{"2245}
12901 \DeclareUTFSymbol\textncong{"2247}
12902 \DeclareUTFSymbol\textapprox{"2248}
12903 \DeclareUTFSymbol\textnapprox{"2249}
12904 \DeclareUTFSymbol\textapproxeq{"224A}
12905 \DeclareUTFCommand\textnapproxeq{\textlstrikethru\textapproxeq}
12906 \DeclareUTFSymbol\texttriplesim{"224B}
12907 \DeclareUTFCommand\textntriplesim{\textlstrikethru\texttriplesim}
12908 \DeclareUTFSymbol\textbackcong{"224C}
12909 \DeclareUTFCommand\textnbackcong{\textlstrikethru\textbackcong}
12910 \DeclareUTFSymbol\textasymp{"224D}
12911 \DeclareUTFCommand\textnasymp{\textlstrikethru\textasymp}
12912 \DeclareUTFSymbol\textBumpeq{"224E}
12913 \DeclareUTFCommand\textnBumpeq{\textlstrikethru\textBumpeq}
12914 \DeclareUTFSymbol\textbumpeq{"224F}
12915 \DeclareUTFCommand\textnbumpeq{\textlstrikethru\textbumpeq}
12916 \DeclareUTFSymbol\textdoteq{"2250}
12917 \DeclareUTFCommand\textndoteq{\textlstrikethru\textdoteq}
12918 \DeclareUTFSymbol\textdoteqdot{"2251}
12919 \DeclareUTFCommand\textnDoteq{\textlstrikethru\textdoteqdot}
12920 \DeclareUTFSymbol\textfallingdoteq{"2252}
12921 \DeclareUTFCommand\textnfallingdoteq{\textlstrikethru\textfallingdoteq}
12922 \DeclareUTFSymbol\textrisingdoteq{"2253}
12923 \DeclareUTFCommand\textnrisingdoteq{\textlstrikethru\textrisingdoteq}
12924 \DeclareUTFSymbol\textcolonequals{"2254}
12925 \DeclareUTFSymbol\textequalscolon{"2255}
12926 \DeclareUTFSymbol\texteqcirc{"2256}
12927 \DeclareUTFCommand\textneqcirc{\textlstrikethru\texteqcirc}
12928 \DeclareUTFSymbol\textcirceq{"2257}
12929 \DeclareUTFCommand\textncirceq{\textlstrikethru\textcirceq}
12930 \DeclareUTFSymbol\texthateq{"2259}
12931 \DeclareUTFCommand\textnhateq{\textlstrikethru\texthateq}
12932 \DeclareUTFSymbol\texttriangleeq{"225C}
12933 \DeclareUTFSymbol\textneq{"2260}
12934 \DeclareUTFSymbol\textne{"2260}
12935 \DeclareUTFSymbol\textequiv{"2261}
12936 \DeclareUTFSymbol\textnequiv{"2262}
12937 \DeclareUTFSymbol\textleq{"2264}
12938 \DeclareUTFSymbol\textle{"2264}
12939 \DeclareUTFSymbol\textgeq{"2265}
12940 \DeclareUTFSymbol\textge{"2265}
12941 \DeclareUTFSymbol\textleqq{"2266}
12942 \DeclareUTFCommand\textnleqq{\textlstrikethru\textleqq}
12943 \DeclareUTFSymbol\textgeqq{"2267}
12944 \DeclareUTFCommand\textngeqq{\textlstrikethru\textgeqq}
12945 \DeclareUTFSymbol\textlneqq{"2268}
12946 \DeclareUTFSymbol\textgneqq{"2269}
12947 \DeclareUTFSymbol\textll{"226A}
12948 \DeclareUTFCommand\textnll{\textlstrikethru\textll}
12949 \DeclareUTFSymbol\textgg{"226B}
12950 \DeclareUTFCommand\textngg{\textlstrikethru\textgg}
12951 \DeclareUTFSymbol\textbetween{"226C}
12952 \DeclareUTFSymbol\textnless{"226E}
12953 \DeclareUTFSymbol\textngtr{"226F}
12954 \DeclareUTFSymbol\textnleq{"2270}
12955 \DeclareUTFSymbol\textngeq{"2271}
12956 \DeclareUTFSymbol\textlesssim{"2272}
12957 \DeclareUTFSymbol\textgtrsim{"2273}
12958 \DeclareUTFSymbol\textnlesssim{"2274}
12959 \DeclareUTFSymbol\textngtrsim{"2275}
12960 \DeclareUTFSymbol\textlessgtr{"2276}
12961 \DeclareUTFSymbol\textgtrless{"2277}
12962 \DeclareUTFSymbol\textngtrless{"2278}
12963 \DeclareUTFSymbol\textnlessgtr{"2279}
12964 \DeclareUTFSymbol\textprec{"227A}
12965 \DeclareUTFSymbol\textsucc{"227B}
12966 \DeclareUTFSymbol\textpreccurlyeq{"227C}
12967 \DeclareUTFSymbol\textsucccurlyeq{"227D}
12968 \DeclareUTFSymbol\textprecsim{"227E}
12969 \DeclareUTFCommand\textnprecsim{\textlstrikethru\textprecsim}
12970 \DeclareUTFSymbol\textsuccsim{"227F}
12971 \DeclareUTFCommand\textnsuccsim{\textlstrikethru\textsuccsim}
12972 \DeclareUTFSymbol\textnprec{"2280}
12973 \DeclareUTFSymbol\textnsucc{"2281}
12974 \DeclareUTFSymbol\textsubset{"2282}
12975 \DeclareUTFSymbol\textsupset{"2283}
12976 \DeclareUTFSymbol\textnsubset{"2284}
12977 \DeclareUTFSymbol\textnsupset{"2285}
12978 \DeclareUTFSymbol\textsubseteq{"2286}
12979 \DeclareUTFSymbol\textsupseteq{"2287}
12980 \DeclareUTFSymbol\textnsubseteq{"2288}
12981 \DeclareUTFSymbol\textnsupseteq{"2289}
12982 \DeclareUTFSymbol\textsubsetneq{"228A}
12983 \DeclareUTFSymbol\textsupsetneq{"228B}
12984 \DeclareUTFSymbol\textcupdot{"228D}
12985 \DeclareUTFSymbol\textcupplus{"228E}
12986 \DeclareUTFSymbol\textsqsubset{"228F}
12987 \DeclareUTFCommand\textnsqsubset{\textlstrikethru\textsqsubset}
12988 \DeclareUTFSymbol\textsqsupset{"2290}
12989 \DeclareUTFCommand\textnsqsupset{\textlstrikethru\textsqsupset}
12990 \DeclareUTFSymbol\textsqsubseteq{"2291}
12991 \DeclareUTFCommand\textnsqsubseteq{\textlstrikethru\textsqsubseteq}
12992 \DeclareUTFSymbol\textsqsupseteq{"2292}
12993 \DeclareUTFCommand\textnsqsupseteq{\textlstrikethru\textsqsupseteq}
12994 \DeclareUTFSymbol\textsqcap{"2293}
12995 \DeclareUTFSymbol\textsqcup{"2294}
12996 \DeclareUTFSymbol\textoplus{"2295}
12997 \DeclareUTFSymbol\textominus{"2296}
12998 \DeclareUTFSymbol\textotimes{"2297}
12999 \DeclareUTFSymbol\textoslash{"2298}
13000 \DeclareUTFSymbol\textodot{"2299}
13001 \DeclareUTFSymbol\textcircledcirc{"229A}
13002 \DeclareUTFSymbol\textcircledast{"229B}
13003 \DeclareUTFSymbol\textcircleddash{"229D}
13004 \DeclareUTFSymbol\textboxplus{"229E}
13005 \DeclareUTFSymbol\textboxminus{"229F}
13006 \DeclareUTFSymbol\textboxtimes{"22A0}
13007 \DeclareUTFSymbol\textboxdot{"22A1}
13008 \DeclareUTFSymbol\textvdash{"22A2}
13009 \DeclareUTFSymbol\textdashv{"22A3}
13010 \DeclareUTFCommand\textndashv{\textlstrikethru\textdashv}
13011 \DeclareUTFSymbol\texttop{"22A4}
13012 \DeclareUTFCommand\textndownvdash{\textlstrikethru\texttop}
13013 \DeclareUTFSymbol\textbot{"22A5}
13014 \DeclareUTFCommand\textnupvdash{\textlstrikethru\textbot}
13015 \DeclareUTFSymbol\textvDash{"22A8}
13016 \DeclareUTFSymbol\textVdash{"22A9}
13017 \DeclareUTFSymbol\textVvdash{"22AA}
13018 \DeclareUTFCommand\textnVvash{\textlstrikethru\textVvdash}
13019 \DeclareUTFSymbol\textVDash{"22AB}
13020 \DeclareUTFSymbol\textnvdash{"22AC}
13021 \DeclareUTFSymbol\textnvDash{"22AD}
13022 \DeclareUTFSymbol\textnVdash{"22AE}
13023 \DeclareUTFSymbol\textnVDash{"22AF}
13024 \DeclareUTFSymbol\textlhd{"22B2}
13025 \DeclareUTFSymbol\textrhd{"22B3}
13026 \DeclareUTFSymbol\textunlhd{"22B4}
13027 \DeclareUTFSymbol\textunrhd{"22B5}
13028 \DeclareUTFSymbol\textmultimapdotbothA{"22B6}
13029 \DeclareUTFSymbol\textmultimapdotbothB{"22B7}
13030 \DeclareUTFSymbol\textmultimap{"22B8}
13031 \DeclareUTFSymbol\textveebar{"22BB}
13032 \DeclareUTFSymbol\textbarwedge{"22BC}
13033 \DeclareUTFSymbol\textstar{"22C6}
13034 \DeclareUTFSymbol\textdivideontimes{"22C7}
13035 \DeclareUTFSymbol\textbowtie{"22C8}
13036 \DeclareUTFSymbol\textltimes{"22C9}
13037 \DeclareUTFSymbol\textrtimes{"22CA}
13038 \DeclareUTFSymbol\textleftthreetimes{"22CB}
13039 \DeclareUTFSymbol\textrightthreetimes{"22CC}
13040 \DeclareUTFSymbol\textbacksimeq{"22CD}
13041 \DeclareUTFCommand\textnbacksimeq{\textlstrikethru\textbacksimeq}
13042 \DeclareUTFSymbol\textcurlyvee{"22CE}
13043 \DeclareUTFSymbol\textcurlywedge{"22CF}
13044 \DeclareUTFSymbol\textSubset{"22D0}
13045 \DeclareUTFCommand\textnSubset{\textlstrikethru\textSubset}
13046 \DeclareUTFSymbol\textSupset{"22D1}
13047 \DeclareUTFCommand\textnSupset{\textlstrikethru\textSupset}
13048 \DeclareUTFSymbol\textCap{"22D2}
13049 \DeclareUTFSymbol\textCup{"22D3}
13050 \DeclareUTFSymbol\textpitchfork{"22D4}
13051 \DeclareUTFSymbol\textlessdot{"22D6}
13052 \DeclareUTFSymbol\textgtrdot{"22D7}
13053 \DeclareUTFSymbol\textlll{"22D8}
13054 \DeclareUTFSymbol\textggg{"22D9}
13055 \DeclareUTFSymbol\textlesseqgtr{"22DA}
13056 \DeclareUTFSymbol\textgtreqless{"22DB}
13057 \DeclareUTFSymbol\textcurlyeqprec{"22DE}
13058 \DeclareUTFCommand\textncurlyeqprec{\textlstrikethru\textcurlyeqprec}
13059 \DeclareUTFSymbol\textcurlyeqsucc{"22DF}
13060 \DeclareUTFCommand\textncurlyeqsucc{\textlstrikethru\textcurlyeqsucc}
13061 \DeclareUTFSymbol\textnpreccurlyeq{"22E0}
13062 \DeclareUTFSymbol\textnsucccurlyeq{"22E1}
13063 \DeclareUTFSymbol\textnqsubseteq{"22E2}
13064 \DeclareUTFSymbol\textnqsupseteq{"22E3}
13065 \DeclareUTFSymbol\textsqsubsetneq{"22E4}
13066 \DeclareUTFSymbol\textsqsupsetneq{"22E5}
13067 \DeclareUTFSymbol\textlnsim{"22E6}
13068 \DeclareUTFSymbol\textgnsim{"22E7}
13069 \DeclareUTFSymbol\textprecnsim{"22E8}
13070 \DeclareUTFSymbol\textsuccnsim{"22E9}
13071 \DeclareUTFSymbol\textntriangleleft{"22EA}
13072 \DeclareUTFSymbol\textntriangleright{"22EB}
13073 \DeclareUTFSymbol\textntrianglelefteq{"22EC}
13074 \DeclareUTFSymbol\textntrianglerighteq{"22ED}
13075 \DeclareUTFSymbol\textvdots{"22EE}
13076 \DeclareUTFSymbol\textcdots{"22EF}
13077 \DeclareUTFSymbol\textudots{"22F0}
13078 \DeclareUTFSymbol\textddots{"22F1}
13079 \DeclareUTFSymbol\textbarin{"22F6}
13080 \DeclareUTFSymbol\textdiameter{"2300}
13081 \DeclareUTFSymbol\textbackneg{"2310}
13082 \DeclareUTFSymbol\textwasylozenge{"2311}
13083 \DeclareUTFSymbol\textinvbackneg{"2319}
13084 \DeclareUTFSymbol\textclock{"231A}
13085 \DeclareUTFSymbol\textulcorner{"231C}
13086 \DeclareUTFSymbol\texturcorner{"231D}
13087 \DeclareUTFSymbol\textllcorner{"231E}
13088 \DeclareUTFSymbol\textlrcorner{"231F}
13089 \DeclareUTFSymbol\textfrown{"2322}
13090 \DeclareUTFSymbol\textsmile{"2323}
13091 \DeclareUTFSymbol\textKeyboard{"2328}
13092 \DeclareUTFSymbol\textlangle{"2329}
13093 \DeclareUTFSymbol\textrangle{"232A}
13094 \DeclareUTFSymbol\textAPLinv{"2339}
13095 \DeclareUTFSymbol\textTumbler{"233C}
13096 \DeclareUTFSymbol\textstmaryrdbaro{"233D}
13097 \DeclareUTFSymbol\textnotslash{"233F}
13098 \DeclareUTFSymbol\textnotbackslash{"2340}
13099 \DeclareUTFSymbol\textboxbackslash{"2342}
13100 \DeclareUTFSymbol\textAPLleftarrowbox{"2347}
13101 \DeclareUTFSymbol\textAPLrightarrowbox{"2348}
13102 \DeclareUTFSymbol\textAPLuparrowbox{"2350}
13103 \DeclareUTFSymbol\textAPLdownarrowbox{"2357}
13104 \DeclareUTFSymbol\textAPLinput{"235E}
13105 \DeclareUTFSymbol\textRequest{"2370}
13106 \DeclareUTFSymbol\textBeam{"2393}
13107 \DeclareUTFSymbol\texthexagon{"2394}
13108 \DeclareUTFSymbol\textAPLbox{"2395}
13109 \DeclareUTFSymbol\textForwardToIndex{"23ED}
13110 \DeclareUTFSymbol\textRewindToIndex{"23EE}
13111 \DeclareUTFSymbol\textbbslash{"244A}
13112 \DeclareUTFSymbol\textCircledA{"24B6}
13113 \DeclareUTFSymbol\textCleaningF{"24BB}
13114 \DeclareUTFCommand\textCleaningFF{\b\textCleaningF}
13115 \DeclareUTFSymbol\textCleaningP{"24C5}
13116 \DeclareUTFCommand\textCleaningPP{\b\textCleaningP}
13117 \DeclareUTFSymbol\textCuttingLine{"2504}
13118 \DeclareUTFSymbol\textUParrow{"25B2}
13119 \DeclareUTFSymbol\textbigtriangleup{"25B3}
13120 \DeclareUTFSymbol\textForward{"25B6}
13121 \DeclareUTFSymbol\texttriangleright{"25B7}
13122 \DeclareUTFSymbol\textRHD{"25BA}
13123 \DeclareUTFSymbol\textDOWNarrow{"25BC}
13124 \DeclareUTFSymbol\textbigtriangledown{"25BD}
13125 \DeclareUTFSymbol\textRewind{"25C0}
13126 \DeclareUTFSymbol\texttriangleleft{"25C1}
13127 \DeclareUTFSymbol\textLHD{"25C4}
13128 \DeclareUTFSymbol\textdiamond{"25C7}
13129 \DeclareUTFSymbol\textlozenge{"25CA}
13130 \DeclareUTFSymbol\textLEFTCIRCLE{"25D6}
13131 \DeclareUTFSymbol\textRIGHTCIRCLE{"25D7}
13132 \DeclareUTFSymbol\textboxbar{"25EB}
13133 \DeclareUTFSymbol\textCloud{"2601}
13134 \DeclareUTFSymbol\textFiveStar{"2605}
13135 \DeclareUTFSymbol\textFiveStarOpen{"2606}
13136 \DeclareUTFSymbol\textPhone{"260E}
13137 \DeclareUTFSymbol\textboxempty{"2610}
13138 \DeclareUTFSymbol\textCheckedbox{"2611}
13139 \DeclareUTFSymbol\textCrossedbox{"2612}
13140 \DeclareUTFSymbol\textCoffeecup{"2615}
13141 \DeclareUTFSymbol\textHandCuffLeft{"261A}
13142 \DeclareUTFSymbol\textHandCuffRight{"261B}
13143 \DeclareUTFSymbol\textHandLeft{"261C}
13144 \DeclareUTFSymbol\textHandRight{"261E}
13145 \DeclareUTFSymbol\textRadioactivity{"2622}
13146 \DeclareUTFSymbol\textBiohazard{"2623}
13147 \DeclareUTFSymbol\textAnkh{"2625}
13148 \DeclareUTFSymbol\textYinYang{"262F}
13149 \DeclareUTFSymbol\textfrownie{"2639}
13150 \DeclareUTFSymbol\textsmiley{"263A}
13151 \DeclareUTFSymbol\textblacksmiley{"263B}
13152 \DeclareUTFSymbol\textsun{"263C}
13153 \DeclareUTFSymbol\textleftmoon{"263D}
13154 \DeclareUTFSymbol\textrightmoon{"263E}
13155 \DeclareUTFSymbol\textmercury{"263F}
13156 \DeclareUTFSymbol\textPUfemale{"2640}
13157 \DeclareUTFSymbol\textearth{"2641}
13158 \DeclareUTFSymbol\textmale{"2642}
13159 \DeclareUTFSymbol\textjupiter{"2643}
13160 \DeclareUTFSymbol\textsaturn{"2644}
13161 \DeclareUTFSymbol\texturanus{"2645}
13162 \DeclareUTFSymbol\textneptune{"2646}
13163 \DeclareUTFSymbol\textpluto{"2647}
13164 \DeclareUTFSymbol\textaries{"2648}
13165 \DeclareUTFSymbol\texttaurus{"2649}
13166 \DeclareUTFSymbol\textgemini{"264A}
13167 \DeclareUTFSymbol\textcancer{"264B}
13168 \DeclareUTFSymbol\textleo{"264C}
13169 \DeclareUTFSymbol\textvirgo{"264D}
13170 \DeclareUTFSymbol\textlibra{"264E}
13171 \DeclareUTFSymbol\textscorpio{"264F}
13172 \DeclareUTFSymbol\textsagittarius{"2650}
13173 \DeclareUTFSymbol\textcapricornus{"2651}
13174 \DeclareUTFSymbol\textaquarius{"2652}
13175 \DeclareUTFSymbol\textpisces{"2653}
13176 \DeclareUTFSymbol\textspadesuitblack{"2660}
13177 \DeclareUTFSymbol\textheartsuitwhite{"2661}
13178 \DeclareUTFSymbol\textdiamondsuitwhite{"2662}
13179 \DeclareUTFSymbol\textclubsuitblack{"2663}
13180 \DeclareUTFSymbol\textspadesuitwhite{"2664}
13181 \DeclareUTFSymbol\textheartsuitblack{"2665}
13182 \DeclareUTFSymbol\textdiamondsuitblack{"2666}
13183 \DeclareUTFSymbol\textclubsuitwhite{"2667}
13184 \DeclareUTFSymbol\textquarternote{"2669}
13185 \DeclareUTFSymbol\texttwonotes{"266B}
13186 \DeclareUTFSymbol\textsixteenthnote{"266C}
13187 \DeclareUTFSymbol\textflat{"266D}
13188 \DeclareUTFSymbol\textnatural{"266E}
13189 \DeclareUTFSymbol\textsharp{"266F}
13190 \DeclareUTFSymbol\textrecycle{"2672}
13191 \DeclareUTFSymbol\textWheelchair{"267F}
13192 \DeclareUTFSymbol\textFlag{"2691}
13193 \DeclareUTFSymbol\textMineSign{"2692}
13194 \DeclareUTFSymbol\textdsmilitary{"2694}
13195 \DeclareUTFSymbol\textdsmedical{"2695}
13196 \DeclareUTFSymbol\textdsjuridical{"2696}
13197 \DeclareUTFSymbol\textdschemical{"2697}
13198 \DeclareUTFSymbol\textdsbiological{"2698}
13199 \DeclareUTFSymbol\textdscommercial{"269A}
13200 \DeclareUTFSymbol\textmanstar{"269D}
13201 \DeclareUTFSymbol\textdanger{"26A0}
13202 \DeclareUTFSymbol\textFemaleFemale{"26A2}
13203 \DeclareUTFSymbol\textMaleMale{"26A3}
13204 \DeclareUTFSymbol\textFemaleMale{"26A4}
13205 \DeclareUTFSymbol\textHermaphrodite{"26A5}
13206 \DeclareUTFSymbol\textNeutral{"26AA}
13207 \DeclareUTFSymbol\textPUuncrfemale{"26B2}
13208 \DeclareUTFSymbol\texthexstar{"26B9}
13209 \DeclareUTFSymbol\textSoccerBall{"26BD}
13210 \DeclareUTFSymbol\textSunCload{"26C5}
13211 \DeclareUTFSymbol\textRain{"26C6}
13212 \DeclareUTFSymbol\textnoway{"26D4}
13213 \DeclareUTFSymbol\textMountain{"26F0}
13214 \DeclareUTFSymbol\textTent{"26FA}
13215 \DeclareUTFSymbol\textScissorRightBrokenBottom{"2701}
13216 \DeclareUTFSymbol\textScissorRight{"2702}
13217 \DeclareUTFSymbol\textScissorRightBrokenTop{"2703}
13218 \DeclareUTFSymbol\textScissorHollowRight{"2704}
13219 \DeclareUTFSymbol\textPhoneHandset{"2706}
13220 \DeclareUTFSymbol\textTape{"2707}
13221 \DeclareUTFSymbol\textPlane{"2708}
13222 \DeclareUTFSymbol\textEnvelope{"2709}
13223 \DeclareUTFSymbol\textPeace{"270C}
13224 \DeclareUTFSymbol\textWritingHand{"270D}
13225 \DeclareUTFSymbol\textPencilRightDown{"270E}
13226 \DeclareUTFSymbol\textPencilRight{"270F}
13227 \DeclareUTFSymbol\textPencilRightUp{"2710}
13228 \DeclareUTFSymbol\textNibRight{"2711}
13229 \DeclareUTFSymbol\textNibSolidRight{"2712}
13230 \DeclareUTFSymbol\textCheckmark{"2713}
13231 \DeclareUTFSymbol\textCheckmarkBold{"2714}
13232 \DeclareUTFSymbol\textXSolid{"2715}
13233 \DeclareUTFSymbol\textXSolidBold{"2716}
13234 \DeclareUTFSymbol\textXSolidBrush{"2717}
13235 \DeclareUTFSymbol\textPlusOutline{"2719}
13236 \DeclareUTFSymbol\textPlus{"271A}
13237 \DeclareUTFSymbol\textPlusThinCenterOpen{"271B}
13238 \DeclareUTFSymbol\textPlusCenterOpen{"271C}
13239 \DeclareUTFSymbol\textCross{"271D}
13240 \DeclareUTFSymbol\textCrossOpenShadow{"271E}
13241 \DeclareUTFSymbol\textCrossOutline{"271F}
13242 \DeclareUTFSymbol\textCrossMaltese{"2720}
13243 \DeclareUTFSymbol\textDavidStar{"2721}
13244 \DeclareUTFSymbol\textFourAsterisk{"2722}
13245 \DeclareUTFSymbol\textJackStar{"2723}
13246 \DeclareUTFSymbol\textJackStarBold{"2724}
13247 \DeclareUTFSymbol\textClowerTips{"2725}
13248 \DeclareUTFSymbol\textFourStar{"2726}
13249 \DeclareUTFSymbol\textFourStarOpen{"2727}
13250 \DeclareUTFSymbol\textFiveStarOpenCircled{"272A}
13251 \DeclareUTFSymbol\textFiveStarCenterOpen{"272B}
13252 \DeclareUTFSymbol\textFiveStarOpenDotted{"272C}
13253 \DeclareUTFSymbol\textFiveStarOutline{"272D}
13254 \DeclareUTFSymbol\textFiveStarOutlineHeavy{"272E}
13255 \DeclareUTFSymbol\textFiveStarConvex{"272F}
13256 \DeclareUTFSymbol\textFiveStarShadow{"2730}
13257 \DeclareUTFSymbol\textAsteriskBold{"2731}
13258 \DeclareUTFSymbol\textAsteriskCenterOpen{"2732}
13259 \DeclareUTFSymbol\textEightStarTaper{"2734}
13260 \DeclareUTFSymbol\textEightStarConvex{"2735}
13261 \DeclareUTFSymbol\textSixStar{"2736}
13262 \DeclareUTFSymbol\textEightStar{"2737}
13263 \DeclareUTFSymbol\textEightStarBold{"2738}
13264 \DeclareUTFSymbol\textTwelveStar{"2739}
13265 \DeclareUTFSymbol\textSixteenStarLight{"273A}
13266 \DeclareUTFSymbol\textSixFlowerPetalRemoved{"273B}
13267 \DeclareUTFSymbol\textSixFlowerOpenCenter{"273C}
13268 \DeclareUTFSymbol\textAsterisk{"273D}
13269 \DeclareUTFSymbol\textSixFlowerAlternate{"273E}
13270 \DeclareUTFSymbol\textFiveFlowerPetal{"273F}
13271 \DeclareUTFSymbol\textFiveFlowerOpen{"2740}
13272 \DeclareUTFSymbol\textEightFlowerPetal{"2741}
13273 \DeclareUTFSymbol\textSunshineOpenCircled{"2742}
13274 \DeclareUTFSymbol\textSixFlowerAltPetal{"2743}
13275 \DeclareUTFSymbol\textSnowflakeChevron{"2744}
13276 \DeclareUTFSymbol\textSnowflake{"2745}
13277 \DeclareUTFSymbol\textSnowflakeChevronBold{"2746}
13278 \DeclareUTFSymbol\textSparkle{"2747}
13279 \DeclareUTFSymbol\textSparkleBold{"2748}
13280 \DeclareUTFSymbol\textAsteriskRoundedEnds{"2749}
13281 \DeclareUTFSymbol\textEightFlowerPetalRemoved{"274A}
13282 \DeclareUTFSymbol\textEightAsterisk{"274B}
13283 \DeclareUTFSymbol\textCircleShadow{"274D}
13284 \DeclareUTFSymbol\textSquareShadowBottomRight{"274F}
13285 \DeclareUTFSymbol\textSquareTopRight{"2750}
13286 \DeclareUTFSymbol\textSquareCastShadowBottomRight{"2751}
13287 \DeclareUTFSymbol\textSquareCastShadowTopRight{"2752}
13288 \DeclareUTFSymbol\textDiamandSolid{"2756}
13289 \DeclareUTFSymbol\textRectangleThin{"2758}
13290 \DeclareUTFSymbol\textRectangle{"2759}
13291 \DeclareUTFSymbol\textRectangleBold{"275A}
13292 \DeclareUTFSymbol\textperp{"27C2}
13293 \DeclareUTFCommand\textnotperp{\textlstrikethru\textperp}
13294 \DeclareUTFSymbol\textveedot{"27C7}
13295 \DeclareUTFSymbol\textwedgedot{"27D1}
13296 \DeclareUTFSymbol\textleftspoon{"27DC}
13297 \DeclareUTFSymbol\textlbrackdbl{"27E6}
13298 \DeclareUTFSymbol\textrbrackdbl{"27E7}
13299 \DeclareUTFSymbol\textcirclearrowleft{"27F2}
13300 \DeclareUTFSymbol\textcirclearrowright{"27F3}
13301 \DeclareUTFSymbol\textlongleftarrow{"27F5}
13302 \DeclareUTFSymbol\textlongrightarrow{"27F6}
13303 \DeclareUTFSymbol\textlongleftrightarrow{"27F7}
13304 \DeclareUTFSymbol\textLongleftarrow{"27F8}
13305 \DeclareUTFSymbol\textLongrightarrow{"27F9}
13306 \DeclareUTFSymbol\textLongleftrightarrow{"27FA}
13307 \DeclareUTFSymbol\textlongmapsto{"27FC}
13308 \DeclareUTFSymbol\textLongmapsfrom{"27FD}
13309 \DeclareUTFSymbol\textLongmapsto{"27FE}
13310 \DeclareUTFSymbol\textnwsearrow{"2921}
13311 \DeclareUTFSymbol\textneswarrow{"2922}
13312 \DeclareUTFSymbol\textlhooknwarrow{"2923}
13313 \DeclareUTFSymbol\textrhooknearrow{"2924}
13314 \DeclareUTFSymbol\textlhooksearrow{"2925}
13315 \DeclareUTFSymbol\textrhookswarrow{"2926}
13316 \DeclareUTFSymbol\textleadsto{"2933}
13317 \DeclareUTFSymbol\textrcurvearrowne{"2934}
13318 \DeclareUTFSymbol\textlcurvearrowse{"2935}
13319 \DeclareUTFSymbol\textlcurvearrowsw{"2936}
13320 \DeclareUTFSymbol\textrcurvearrowse{"2937}
13321 \DeclareUTFSymbol\textlcurvearrowdown{"2938}
13322 \DeclareUTFSymbol\textrcurvearrowdown{"2939}
13323 \DeclareUTFSymbol\textrcurvearrowleft{"293A}
13324 \DeclareUTFSymbol\textrcurvearrowright{"293B}
13325 \DeclareUTFSymbol\textleftrightharpoon{"294A}
13326 \DeclareUTFSymbol\textrightleftharpoon{"294B}
13327 \DeclareUTFSymbol\textupdownharpoonrightleft{"294C}
13328 \DeclareUTFSymbol\textupdownharpoonleftright{"294D}
13329 \DeclareUTFSymbol\textleftleftharpoons{"2962}
13330 \DeclareUTFSymbol\textupupharpoons{"2963}
13331 \DeclareUTFSymbol\textrightrightharpoons{"2964}
13332 \DeclareUTFSymbol\textdowndownharpoons{"2965}
13333 \DeclareUTFSymbol\textleftbarharpoon{"296A}
13334 \DeclareUTFSymbol\textbarleftharpoon{"296B}
13335 \DeclareUTFSymbol\textrightbarharpoon{"296C}
13336 \DeclareUTFSymbol\textbarrightharpoon{"296D}
13337 \DeclareUTFSymbol\textupdownharpoons{"296E}
13338 \DeclareUTFSymbol\textdownupharpoons{"296F}
13339 \DeclareUTFSymbol\textllparenthesis{"2987}
13340 \DeclareUTFSymbol\textrrparenthesis{"2988}
13341 \DeclareUTFSymbol\textinvdiameter{"29B0}
13342 \DeclareUTFSymbol\textobar{"29B6}
13343 \DeclareUTFSymbol\textobslash{"29B8}
13344 \DeclareUTFSymbol\textobot{"29BA}
13345 \DeclareUTFSymbol\textNoChemicalCleaning{"29BB}
13346 \DeclareUTFSymbol\textolessthan{"29C0}
13347 \DeclareUTFSymbol\textogreaterthan{"29C1}
13348 \DeclareUTFSymbol\textboxslash{"29C4}
13349 \DeclareUTFSymbol\textboxbslash{"29C5}
13350 \DeclareUTFSymbol\textboxast{"29C6}
13351 \DeclareUTFSymbol\textboxcircle{"29C7}
13352 \DeclareUTFSymbol\textboxbox{"29C8}
13353 \DeclareUTFSymbol\textValve{"29D3}
13354 \DeclareUTFSymbol\textmultimapboth{"29DF}
13355 \DeclareUTFSymbol\textshuffle{"29E2}
13356 \DeclareUTFSymbol\textuplus{"2A04}
13357 \DeclareUTFSymbol\textbigdoublewedge{"2A07}
13358 \DeclareUTFSymbol\textbigdoublevee{"2A08}
13359 \DeclareUTFSymbol\textJoin{"2A1D}
13360 \DeclareUTFSymbol\textfatsemi{"2A1F}
13361 \DeclareUTFSymbol\textcircplus{"2A22}
13362 \DeclareUTFSymbol\textminusdot{"2A2A}
13363 \DeclareUTFSymbol\textdottimes{"2A30}
13364 \DeclareUTFSymbol\textdtimes{"2A32}
13365 \DeclareUTFSymbol\textodiv{"2A38}
13366 \DeclareUTFSymbol\textinvneg{"2A3C}
13367 \DeclareUTFSymbol\textsqdoublecap{"2A4E}
13368 \DeclareUTFSymbol\textcapdot{"2A40}
13369 \DeclareUTFSymbol\textsqdoublecup{"2A4F}
13370 \DeclareUTFSymbol\textdoublewedge{"2A55}
13371 \DeclareUTFSymbol\textdoublevee{"2A56}
13372 \DeclareUTFSymbol\textdoublebarwedge{"2A5E}
13373 \DeclareUTFSymbol\textveedoublebar{"2A63}
13374 \DeclareUTFSymbol\texteqdot{"2A66}
13375 \DeclareUTFCommand\textneqdot{\textlstrikethru\texteqdot}
13376 \DeclareUTFSymbol\textcoloncolonequals{"2A74}
13377 \DeclareUTFSymbol\textleqslant{"2A7D}
13378 \DeclareUTFCommand\textnleqslant{\textlstrikethrux\textleqslant}
13379 \DeclareUTFSymbol\textgeqslant{"2A7E}
13380 \DeclareUTFCommand\textngeqslant{\textlstrikethru\textgeqslant}
13381 \DeclareUTFSymbol\textlessapprox{"2A85}
13382 \DeclareUTFCommand\textnlessapprox{\textlstrikethru\textnlessapprox}
13383 \DeclareUTFSymbol\textgtrapprox{"2A86}
13384 \DeclareUTFCommand\textngtrapprox{\textlstrikethru\textgtrapprox}
13385 \DeclareUTFSymbol\textlneq{"2A87}
13386 \DeclareUTFSymbol\textgneq{"2A88}
13387 \DeclareUTFSymbol\textlnapprox{"2A89}
13388 \DeclareUTFSymbol\textgnapprox{"2A8A}
13389 \DeclareUTFSymbol\textlesseqqgtr{"2A8B}
13390 \DeclareUTFSymbol\textgtreqqless{"2A8C}
13391 \DeclareUTFSymbol\texteqslantless{"2A95}
13392 \DeclareUTFSymbol\texteqslantgtr{"2A96}
13393 \DeclareUTFSymbol\textleftslice{"2AA6}
13394 \DeclareUTFSymbol\textrightslice{"2AA7}
13395 \DeclareUTFSymbol\textpreceq{"2AAF}
13396 \DeclareUTFCommand\textnpreceq{\textlstrikethru\textpreceq}
13397 \DeclareUTFSymbol\textsucceq{"2AB0}
13398 \DeclareUTFCommand\textnsucceq{\textlstrikethru\textsucceq}
13399 \DeclareUTFSymbol\textprecneq{"2AB1}
13400 \DeclareUTFSymbol\textsuccneq{"2AB2}
13401 \DeclareUTFSymbol\textpreceqq{"2AB3}
13402 \DeclareUTFCommand\textnpreceqq{\textlstrikethru\textpreceqq}
13403 \DeclareUTFSymbol\textsucceqq{"2AB4}
13404 \DeclareUTFCommand\textnsucceqq{\textlstrikethru\textsucceqq}
13405 \DeclareUTFSymbol\textprecneqq{"2AB5}
13406 \DeclareUTFSymbol\textsuccneqq{"2AB6}
13407 \DeclareUTFSymbol\textprecapprox{"2AB7}
13408 \DeclareUTFCommand\textnprecapprox{\textlstrikethru\textprecapprox}
13409 \DeclareUTFSymbol\textsuccapprox{"2AB8}
13410 \DeclareUTFCommand\textnsuccapprox{\textlstrikethru\textsuccapprox}
13411 \DeclareUTFSymbol\textprecnapprox{"2AB9}
13412 \DeclareUTFSymbol\textsuccnapprox{"2ABA}
13413 \DeclareUTFSymbol\textsubseteqq{"2AC5}
13414 \DeclareUTFCommand\textnsubseteqq{\textlstrikethru\textsubseteqq}
13415 \DeclareUTFSymbol\textsupseteqq{"2AC6}
13416 \DeclareUTFCommand\textnsupseteqq{\textlstrikethru\textsupseteqq}
13417 \DeclareUTFSymbol\textdashV{"2AE3}
13418 \DeclareUTFCommand\textndashV{\textlstrikethru\textdashV}
13419 \DeclareUTFSymbol\textDashv{"2AE4}
13420 \DeclareUTFCommand\textnDashv{\textlstrikethru\textDashv}
13421 \DeclareUTFSymbol\textDashV{"2AE5}
13422 \DeclareUTFCommand\textnDashV{\textlstrikethru\textDashV}
13423 \DeclareUTFSymbol\textdownmodels{"2AEA}
13424 \DeclareUTFCommand\textndownmodels{\textlstrikethru\textdownmodels}
13425 \DeclareUTFSymbol\textupmodels{"2AEB}
13426 \DeclareUTFCommand\textnupmodels{\textlstrikethru\textupmodels}
13427 \DeclareUTFSymbol\textupspoon{"2AEF}
13428 \DeclareUTFSymbol\textinterleave{"2AF4}
13429 \DeclareUTFSymbol\textsslash{"2AFD}
13430 \DeclareUTFSymbol\textpentagon{"2B20}
13431 \DeclareUTFSymbol\textvarhexagon{"2B21}
13432 \DeclareUTFSymbol\textjinferior{"2C7C}
13433 \DeclareUTFSymbol\textslashdiv{"2E13}
13434 \DeclareUTFSymbol\textinterrobangdown{"2E18}
13435 \DeclareUTFSymbol\textfivedots{"2E2D}
13436 \DeclareUTFSymbol\textPUheng{"A727}
13437 \DeclareUTFSymbol\textPUlhookfour{"A72C}
13438 \DeclareUTFSymbol\textPUscf{"A730}
13439 \DeclareUTFSymbol\textPUaolig{"A735}
13440 \DeclareUTFSymbol\textoo{"A74F}
13441 \DeclareUTFSymbol\textcircumlow{"A788}
13442 \DeclareUTFSymbol\textfi{"FB01}
13443 \DeclareUTFSymbol\textfl{"FB02}
13444 \DeclareUTFSymbol\textGaPa{"1D13B}
13445 \DeclareUTFSymbol\textHaPa{"1D13C}
13446 \DeclareUTFSymbol\textViPa{"1D13D}
13447 \DeclareUTFSymbol\textAcPa{"1D13E}
13448 \DeclareUTFSymbol\textSePa{"1D13F}
13449 \DeclareUTFSymbol\textZwPa{"1D140}
13450 \DeclareUTFSymbol\textfullnote{"1D15D}
13451 \DeclareUTFSymbol\texthalfnote{"1D15E}
13452 \DeclareUTFSymbol\textVier{"1D15F}
13453 \DeclareUTFSymbol\textAcht{"1D160}
13454 \DeclareUTFSymbol\textSech{"1D161}
13455 \DeclareUTFSymbol\textZwdr{"1D162}
13456 \DeclareUTFSymbol\textMundus{"1F30D}
13457 \DeclareUTFSymbol\textMoon{"1F319}
13458 \DeclareUTFSymbol\textManFace{"1F468}
13459 \DeclareUTFSymbol\textWomanFace{"1F469}
13460 \DeclareUTFSymbol\textFax{"1F4E0}
13461 \DeclareUTFSymbol\textFire{"1F525}
13462 \DeclareUTFSymbol\textBicycle{"1F6B2}
13463 \DeclareUTFSymbol\textGentsroom{"1F6B9}
13464 \DeclareUTFSymbol\textLadiesroom{"1F6BA}
13465 \DeclareUTFCommand\textcopyleft{\textcircled\textrevc}
13466 \DeclareUTFCommand\textccsa{\textcircled\textcirclearrowleft}
13467 \DeclareUTFSymbol\textglqq{"201E}
13468 \DeclareUTFSymbol\textgrqq{"201C}
13469 \DeclareUTFSymbol\textglq{"201A}
13470 \DeclareUTFSymbol\textgrq{"2018}
13471 \DeclareUTFSymbol\textflqq{"00AB}
13472 \DeclareUTFSymbol\textfrqq{"00BB}
13473 \DeclareUTFSymbol\textflq{"2039}
13474 \DeclareUTFSymbol\textfrq{"203A}
13475 \DeclareUTFSymbol\textneg{"00AC}
13476 \DeclareUTFSymbol\textcdot{"00B7}
13477 % \end{macrocode}
13478 %
13479 % \begin{macrocode}
13480 %</xunextra>
13481 % \end{macrocode}
13482 %
13483 % \end{implementation}
13484 %
13485 % \begin{macrocode}
13486 %<@@=xeCJK>
13487 % \end{macrocode}
13488 %
13489 % \subsection{\pkg{xeCJK.cfg}}
13490 %
13491 % \begin{macrocode}
13492 %<*config>
13493 % \end{macrocode}
13494 %
13495 % 预设的配置文件 \file{xeCJK.cfg} 为一个空文件。可以在里面增加设置,然后保存到
13496 % 本地目录下面。
13497 % \begin{macrocode}
13498
13499 % \end{macrocode}
13500 %
13501 % \begin{macrocode}
13502 %</config>
13503 % \end{macrocode}
13504 %
13505 % \Finale
13506 %
13507 % \endinput
13508 %
13509 % \DisableImplementation
13510 %
13511 % \begin{implementation}
13512 %
13513 % \makeatletter
13514 % \let\special@index\@gobble
13515 % \makeatother
13516 %
13517 % \section{例子}
13518 %
13519 % \subsection{\pkg{xeCJK-example-autofake.tex}}
13520 %
13521 % \begin{macrocode}
13522 %<*ex-autofake>
13523 % \end{macrocode}
13524 %
13525 % \begin{macrocode}
13526 \documentclass{article}
13527 \usepackage[AutoFakeBold,AutoFakeSlant]{xeCJK}
13528 \setCJKmainfont[BoldFont=simhei.ttf, SlantedFont=simkai.ttf]{simsun.ttc}
13529 \setCJKsansfont[AutoFakeSlant=false,
13530 BoldFont=simhei.ttf, SlantedFont=simkai.ttf]{simsun.ttc}
13531 \setCJKmonofont[ItalicFont=simkai.ttf]{simsun.ttc}
13532 \begin{document}
13533 \centering
13534 \begin{tabular}{lllll}
13535 \hline
13536 {\bf rm} & md & up & \verb|\rmfamily\mdseries\upshape| &
13537 {\rmfamily\mdseries\upshape English 中文字体} \\
13538 & md & it & \verb|\rmfamily\mdseries\itshape| &
13539 {\rmfamily\mdseries\itshape English 中文字体} \\
13540 & md & sl & \verb|\rmfamily\mdseries\slshape| &
13541 {\rmfamily\mdseries\slshape English 中文字体} \\ \cline{2-5}
13542 & bf & up & \verb|\rmfamily\bfseries\upshape| &
13543 {\rmfamily\bfseries\upshape English 中文字体} \\
13544 & bf & it & \verb|\rmfamily\bfseries\itshape| &
13545 {\rmfamily\bfseries\itshape English 中文字体} \\
13546 & bf & sl & \verb|\rmfamily\bfseries\slshape| &
13547 {\rmfamily\bfseries\slshape English 中文字体} \\ \hline
13548 {\bf sf} & md & up & \verb|\sffamily\mdseries\upshape| &
13549 {\sffamily\mdseries\upshape English 中文字体} \\
13550 & md & it & \verb|\sffamily\mdseries\itshape| &
13551 {\sffamily\mdseries\itshape English 中文字体} \\
13552 & md & sl & \verb|\sffamily\mdseries\slshape| &
13553 {\sffamily\mdseries\slshape English 中文字体} \\ \cline{2-5}
13554 & bf & up & \verb|\sffamily\bfseries\upshape| &
13555 {\sffamily\bfseries\upshape English 中文字体} \\
13556 & bf & it & \verb|\sffamily\bfseries\itshape| &
13557 {\sffamily\bfseries\itshape English 中文字体} \\
13558 & bf & sl & \verb|\sffamily\bfseries\slshape| &
13559 {\sffamily\bfseries\slshape English 中文字体} \\ \hline
13560 {\bf tt} & md & up & \verb|\ttfamily\mdseries\upshape| &
13561 {\ttfamily\mdseries\upshape English 中文字体} \\
13562 & md & it & \verb|\ttfamily\mdseries\itshape| &
13563 {\ttfamily\mdseries\itshape English 中文字体} \\
13564 & md & sl & \verb|\ttfamily\mdseries\slshape| &
13565 {\ttfamily\mdseries\slshape English 中文字体} \\ \cline{2-5}
13566 & bf & up & \verb|\ttfamily\bfseries\upshape| &
13567 {\ttfamily\bfseries\upshape English 中文字体} \\
13568 & bf & it & \verb|\ttfamily\bfseries\itshape| &
13569 {\ttfamily\bfseries\itshape English 中文字体} \\
13570 & bf & sl & \verb|\ttfamily\bfseries\slshape| &
13571 {\ttfamily\bfseries\slshape English 中文字体} \\ \hline
13572 \end{tabular}
13573 \end{document}
13574 % \end{macrocode}
13575 %
13576 % \begin{macrocode}
13577 %</ex-autofake>
13578 % \end{macrocode}
13579 %
13580 % \subsection{\pkg{xeCJK-example-fallback.tex}}
13581 %
13582 % \begin{macrocode}
13583 %<*ex-fallback>
13584 % \end{macrocode}
13585 %
13586 % \begin{macrocode}
13587 \documentclass{article}
13588 \usepackage[AutoFallBack]{xeCJK}
13589 \usepackage{xeCJKfntef}
13590 \usepackage{array}
13591 \setCJKmainfont[AutoFakeBold,AutoFakeSlant]{KaiTi_GB2312}
13592 \setCJKfallbackfamilyfont{\CJKrmdefault}[BoldFont=SimHei]
13593 { [SlantedFont=FangSong]{SimSun} ,
13594 [BoldFont=*] {SimSun-ExtB} }
13595 \begin{document}
13596 漢字源𣴑考
13597
13598 \textbf{漢字源𣴑考}
13599
13600 \textsl{漢字源𣴑考}
13601
13602 \CJKunderwave{漢字源𣴑考}
13603 \begin{table}[ht]
13604 \caption{生僻字测试}
13605 \medskip\centering
13606 \begin{tabular}{*4{|c>{\ttfamily U+}l}|}
13607 㐀 & 3400 & 㐁 & 3401 & 㐂 & 3402 & 㐃 & 3403 \\
13608 㐄 & 3404 & 㐅 & 3405 & 㐆 & 3406 & 㐇 & 3407 \\
13609 㐈 & 3408 & 㐉 & 3409 & 㐊 & 340A & 㐋 & 340B \\
13610 㐌 & 340C & 㐍 & 340D & 㐎 & 340E & 㐏 & 341F \\
13611 㐐 & 3410 & 㐑 & 3411 & 㐒 & 3412 & 㐓 & 3413 \\
13612 㐔 & 3414 & 㐕 & 3415 & 㐖 & 3416 & 㐗 & 3417 \\
13613 㐘 & 3418 & 㐙 & 3419 & 㐚 & 341A & 㐛 & 341B \\
13614 㐜 & 341C & 㐝 & 341D & 㐞 & 341E & 㐟 & 341F \\[1ex]
13615 𠀀 & 20000 & 𠀁 & 20001 & 𠀂 & 20002 & 𠀃 & 20003 \\
13616 𠀄 & 20004 & 𠀅 & 20005 & 𠀆 & 20006 & 𠀇 & 20007 \\
13617 𠀈 & 20008 & 𠀉 & 20009 & 𠀊 & 2000A & 𠀋 & 2000B \\
13618 𠀌 & 2000C & 𠀍 & 2000D & 𠀎 & 2000E & 𠀏 & 2000F \\
13619 𠀐 & 20010 & 𠀑 & 20011 & 𠀒 & 20012 & 𠀓 & 20013 \\
13620 𠀔 & 20014 & 𠀕 & 20015 & 𠀖 & 20016 & 𠀗 & 20017 \\
13621 𠀘 & 20018 & 𠀙 & 20019 & 𠀚 & 2001A & 𠀛 & 2001B \\
13622 𠀜 & 2001C & 𠀝 & 2001D & 𠀞 & 2001E & 𠀟 & 2001F \\
13623 \end{tabular}
13624 \end{table}
13625 \end{document}
13626 % \end{macrocode}
13627 %
13628 % \begin{macrocode}
13629 %</ex-fallback>
13630 % \end{macrocode}
13631 %
13632 % \subsection{\pkg{xeCJK-example-subCJKblock.tex}}
13633 %
13634 % \begin{macrocode}
13635 %<*ex-block>
13636 % \end{macrocode}
13637 %
13638 % \begin{macrocode}
13639 \documentclass{article}
13640 \usepackage{xeCJK}
13641 \usepackage{array}
13642 \xeCJKDeclareSubCJKBlock{Ext-A} { "3400 -> "4DBF }
13643 \xeCJKDeclareSubCJKBlock{Ext-B} { "20000 -> "2A6DF }
13644 \xeCJKDeclareSubCJKBlock{Kana} { "3040 -> "309F, "30A0 -> "30FF, "31F0 -> "31FF, }
13645 \xeCJKDeclareSubCJKBlock{Hangul}{ "1100 -> "11FF, "3130 -> "318F, "A960 -> "A97F, "AC00 -> "D7AF }
13646 \setCJKmainfont[Ext-A=SimHei,Ext-B=SimSun-ExtB]{SimSun}
13647 \setCJKmainfont[Kana]{Meiryo}
13648 \setCJKmainfont[Hangul]{Malgun Gothic}
13649 \parindent=2em
13650 \begin{document}
13651 \long\def\showtext{%
13652 中日韩越统一表意文字(英语:CJKV Unified Ideographs),旧称中日韩统一表意文字(英语:CJK Unified Ideographs),也称统一汉字(英语:Unihan),目的是要把分别来自中文、日文、韩文、越文、壮文中,对于相同起源、本义相同、形状一样或稍异的表意文字(主要为汉字,但也有仿汉字如:方块壮字、日文汉字(かんじ / kanji)、韩文汉字(한자 / hanja)、越南的喃字(Chữ Nôm)与越文汉字(Chữ Nho,在越南也称作儒字),应赋予其在ISO 10646及统一码标准中有相同编码。此计划原本只包含中文、日文及韩文中所使用的汉字,是以旧称中日韩统一表意文字(CJK)。后来,此计划加入了越文的喃字,所以合称中日韩越统一表意文字(CJKV)。
13653
13654 CJK統合漢字(シージェーケーとうごうかんじ、CJK Unified Ideographs)は、ISO/IEC 10646 (Universal Multiple-Octet Coded Character Set, 略称 UCS) および Unicodeにて採用されている符号化用漢字集合およびその符号表である。CJK統合漢字の名称は、中国語(Chinese)、日本語(Japanese)、韓国語(Korean)で使われている漢字をひとまとめにしたことからきている。CJK統合漢字の初版である Unified Repertoire and Ordering (URO) 第二版は1992年に制定されたが、1994年にベトナムで使われていた漢字も含めることにしたため、CJKVと呼ばれる事もある。CJKVは、中国語・日本語・韓国語・ベトナム語 (英語: Chinese-Japanese-Korean-Vietnamese) の略。特に、その4言語で共通して使われる、または使われていた文字体系である漢字(チュノムを含む)のこと。ソフトウェアの国際化、中でも文字コードに関する分野で用いられる。
13655
13656 \CJKspace
13657 한중일월 통합 한자(또는 한중일 통합 한자)는 유니코드에 담겨 있는 한자들의 집합으로, 한국, 중국, 일본에서 쓰이는 한자를 묶은 것이기 때문에 머리 글자를 따서 한중일(CJK) 통합 한자라고 불렀는데, 최근에는 베트남에서 쓰이는 한자도 추가되었기에 한중일월(CJKV) 통합 한자로 부르게 되었다.
13658
13659 처음에 유니코드에는 65,536($=2^{16}$)자만 들어갈 수 있었기 때문에, 가장 많은 문자가 배당되는 한자를 위해서 한국, 중국, 일본에서 사용하는 한자 중에 모양이 유사하며 그 뜻이 같은 글자를 같은 코드로 통합했다. 따라서 문자 코드만으로 그 한자가 사용되는 언어를 알아 낼 수 없는데, 다만 중국의 간체자나 번체자, 일본의 구자체나 신자체 등 분명하게 모양이 다른 글자는 별도의 부호를 할당하고 있다. 이런 문자 할당 정책에 반발하여 TRON과 같은 인코딩이 만들어지기도 했으나, 실제로 통합된 한자의 차이가 별로 크지 않기 때문에 문제가 되지 않는다는 의견도 있다.
13660 \CJKnospace}
13661 \showtext
13662
13663 \bigskip
13664 \xeCJKCancelSubCJKBlock{Kana,Hangul}
13665 \showtext
13666
13667 \bigskip
13668 \xeCJKRestoreSubCJKBlock{Hangul}
13669 \showtext
13670
13671 \begin{table}[ht]
13672 \caption{生僻字测试}
13673 \medskip\centering
13674 \begin{tabular}{*4{|c>{\ttfamily U+}l}|}
13675 㐀 & 3400 & 㐁 & 3401 & 㐂 & 3402 & 㐃 & 3403 \\
13676 㐄 & 3404 & 㐅 & 3405 & 㐆 & 3406 & 㐇 & 3407 \\
13677 㐈 & 3408 & 㐉 & 3409 & 㐊 & 340A & 㐋 & 340B \\
13678 㐌 & 340C & 㐍 & 340D & 㐎 & 340E & 㐏 & 341F \\
13679 㐐 & 3410 & 㐑 & 3411 & 㐒 & 3412 & 㐓 & 3413 \\
13680 㐔 & 3414 & 㐕 & 3415 & 㐖 & 3416 & 㐗 & 3417 \\
13681 㐘 & 3418 & 㐙 & 3419 & 㐚 & 341A & 㐛 & 341B \\
13682 㐜 & 341C & 㐝 & 341D & 㐞 & 341E & 㐟 & 341F \\[1ex]
13683 𠀀 & 20000 & 𠀁 & 20001 & 𠀂 & 20002 & 𠀃 & 20003 \\
13684 𠀄 & 20004 & 𠀅 & 20005 & 𠀆 & 20006 & 𠀇 & 20007 \\
13685 𠀈 & 20008 & 𠀉 & 20009 & 𠀊 & 2000A & 𠀋 & 2000B \\
13686 𠀌 & 2000C & 𠀍 & 2000D & 𠀎 & 2000E & 𠀏 & 2000F \\
13687 𠀐 & 20010 & 𠀑 & 20011 & 𠀒 & 20012 & 𠀓 & 20013 \\
13688 𠀔 & 20014 & 𠀕 & 20015 & 𠀖 & 20016 & 𠀗 & 20017 \\
13689 𠀘 & 20018 & 𠀙 & 20019 & 𠀚 & 2001A & 𠀛 & 2001B \\
13690 𠀜 & 2001C & 𠀝 & 2001D & 𠀞 & 2001E & 𠀟 & 2001F \\
13691 \end{tabular}
13692 \end{table}
13693 \end{document}
13694 % \end{macrocode}
13695 %
13696 % \begin{macrocode}
13697 %</ex-block>
13698 % \end{macrocode}
13699 %
13700 %
13701 % \subsection{\pkg{xeCJK-example-CJKecglue.tex}}
13702 %
13703 % \begin{macrocode}
13704 %<*ex-ecglue>
13705 % \end{macrocode}
13706 %
13707 % \begin{macrocode}
13708 \documentclass{minimal}
13709 \usepackage{xeCJK}
13710 \setCJKmainfont[BoldFont=SimHei]{SimSun}
13711 \long\def\showtext{%
13712 这是 English 中文 {\itshape Chinese} 中文 \TeX\
13713 间隔 \textit{Italic} 中文\textbf{字体} a 数学 $b$ 数学 $c$ $d$\par
13714 这是English中文{\itshape Chinese}中文\TeX\
13715 间隔\textit{Italic}中文\textbf{字体}a数学$b$数学$c$ $d$\par
13716 This is an example. 这是一个例子}
13717 \begin{document}
13718 \showtext
13719
13720 \hrulefill\bigskip
13721
13722 \xeCJKsetup{xCJKecglue=\quad}
13723 \showtext
13724 \end{document}
13725 % \end{macrocode}
13726 %
13727 % \begin{macrocode}
13728 %</ex-ecglue>
13729 % \end{macrocode}
13730 %
13731 % \subsection{\pkg{xeCJK-example-checksingle.tex}}
13732 %
13733 % \begin{macrocode}
13734 %<*ex-single>
13735 % \end{macrocode}
13736 %
13737 % \begin{macrocode}
13738 \documentclass{minimal}
13739 \usepackage{xeCJK}
13740 \setCJKmainfont{SimSun}
13741 \long\def\showtext{一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十。
13742 \[x^2+y^2\]
13743 一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十。
13744 $$x^2+y^2$$
13745 一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十。
13746 \begin{equation}
13747 x^2+y^2
13748 \end{equation}
13749 一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十。}
13750 \begin{document}
13751 \hsize=30em
13752 \parindent=0pt
13753 \showtext
13754
13755 \hrulefill\bigskip
13756
13757 \xeCJKsetup{CheckSingle}
13758 \showtext
13759
13760 \hrulefill\bigskip
13761
13762 \xeCJKsetup{PlainEquation}
13763 \showtext
13764 \end{document}
13765 % \end{macrocode}
13766 %
13767 % \begin{macrocode}
13768 %</ex-single>
13769 % \end{macrocode}
13770 %
13771 % \subsection{\pkg{xeCJK-example-CJKfntef.tex}}
13772 %
13773 % \begin{macrocode}
13774 %<*ex-fntef>
13775 % \end{macrocode}
13776 %
13777 % \begin{macrocode}
13778 \documentclass{ctexart}
13779 \usepackage{xcolor}
13780 \usepackage{xeCJKfntef}
13781 \xeCJKDeclareSubCJKBlock{test}{ `殆 , `已 }
13782 \setCJKmainfont[test=SimHei]{SimSun}
13783
13784 \def\showtext{%
13785 庄子曰:“吾生也有涯,而知也无涯。以有涯随无涯,殆已!已而为知者,殆而已矣!%
13786 为善无近名,为恶无近刑,缘督以为经,可以保身,可以全生,可以养亲,可以尽年。”}
13787 \newcommand\CJKfntef[1]{%
13788 \csname#1\endcsname{\showtext}\par
13789 \csname#1\endcsname*{\showtext}\par
13790 \CJKunderdot{\showtext\csname#1\endcsname{\showtext}}\par
13791 \CJKunderdot{\showtext\csname#1\endcsname*{\showtext}}\par
13792 \csname#1\endcsname{\showtext\CJKunderdot{\showtext}}\par
13793 \csname#1\endcsname*{\showtext\CJKunderdot{\showtext}}\par\bigskip}
13794
13795 \begin{document}
13796
13797 \section{\textsf{xeCJKfntef} 的\CJKunderdot{简单测试文件}}
13798
13799 \CJKunderline{汉 字}\CJKunderline{加下划线}
13800 \varCJKunderline{汉字}\varCJKunderline{加下划线}
13801 \CJKunderanyline{0.5em}{\sixly \kern-.021em\char58 \kern-.021em}{自定义下划线}
13802 \CJKunderanyline{0.2em}{\kern-.03em\vtop{\kern.2ex\hrule width.2em\kern 0.11em
13803 \hrule height 0.1em}\kern-.03em}{自定义下划线}
13804
13805 \CJKunderanyline{0.5em}{-}{\showtext}
13806
13807 \CJKunderanysymbol{0.2em}{-}{\showtext}
13808
13809 \CJKunderdot{\showtext}
13810
13811 \hrule depth \dp\strutbox width 0 pt \relax
13812
13813 \begin{CJKfilltwosides}{40mm}
13814 两端分散对齐\\
13815 分散对齐\\
13816 \CJKunderdot{汉字可加点}\\
13817 \CJKunderline{汉字可加下划线}
13818 \end{CJKfilltwosides}
13819
13820 \hrule depth \dp\strutbox width 0 pt \relax
13821
13822 \CJKfntef{CJKunderline}
13823 \CJKfntef{CJKunderwave}
13824 \CJKfntef{CJKunderdblline}
13825 \CJKfntef{CJKsout}
13826 \CJKfntef{CJKxout}
13827
13828 \def\Book{\CJKunderwave-}
13829 \def\Noun{\CJKunderline-}
13830
13831 如上所述,\Book{中國文學史}原是\Noun{復旦大學出版社}出版的,\Book{中國文學史新著}則由\Noun{上海文藝出版社}出版。現承\Noun{復旦大學出版社}\Noun{賀聖遂}先生的盛情和\Noun{上海文藝出版總社}\Noun{楊益萍}、\Noun{何承偉}先生以及有關負責人\Noun{陳鳴華}先生的高誼,此書增訂本改由兩社聯合出版。\Noun{賀聖遂}先生並與\Noun{杜榮根}副社長、\Noun{韓結根}編審共同擔任此書的責任編輯。對上述諸位先生謹在這裡表示衷心的感謝。對\Book{中國文學史新著}原版的責任編輯\Noun{戴俊}先生(現為\Noun{上海三聯書店}副總經理)也在此一併致謝。
13832
13833 \Noun{與文學史的}\Noun{應有任務}\Noun{對文學發展過程}\Noun{的內在聯繫的描述}\Noun{還有很大的距離}\Noun{至於距離的所在}\Noun{本書原已有說明}\Book{此不贅述}\Book{為了對學術負責}\Book{我們決定重寫一部並迅即出版}
13834
13835 \Noun{南朝}\Noun{梁}\Noun{劉勰}\Book{文心雕龍}\Book{養氣}
13836
13837 \Noun{鎌池和馬}\Book{魔法禁書目錄}\Book{某科學的超電磁砲}
13838
13839 \Noun{西尾維新}\Book{化物語}\Book{偽物語}\Book{貓物語}%
13840 \Book{傾物语}\Book{囤物語}\Book{鬼物語}\Book{戀物語}\Book{花物語}
13841
13842 \Noun{岡田麿里}\Book{我們仍未知道那天所看見的花的名字。}\Book{絕園的暴風雨}
13843
13844 \Noun{虚淵玄}\Book{Fate/Zero}\Book{PSYCHO-PASS}\Book{ALDNOAH.ZERO}
13845
13846 \Noun{劉海洋}\Book{\LaTeX 入門}
13847
13848 \def\NAME{%
13849 \x{御坂美琴}\x{白井黑子}\x{戰場原緋多木}\x{阿良良木歷}%
13850 \x{宿海仁太}\x{本間芽衣子}\x{瀧川吉野}\x{鎖部葉風}%
13851 \x{衛宮切嗣}\x{言峰綺禮}\x{常守朱}\x{狡嚙慎也}%
13852 \x{界塚伊奈帆}\x*{艾瑟依拉姆·沃斯·艾莉歐斯亞}}
13853
13854 \let\x\Noun\NAME
13855
13856 \let\x\Book\NAME
13857
13858 \end{document}
13859 % \end{macrocode}
13860 %
13861 % \begin{macrocode}
13862 %</ex-fntef>
13863 % \end{macrocode}
13864 %
13865 % \subsection{\pkg{xeCJK-example-punctstyle.tex}}
13866 %
13867 % \begin{macrocode}
13868 %<*ex-punctstyle>
13869 % \end{macrocode}
13870 %
13871 % \begin{macrocode}
13872 \documentclass{article}
13873 \usepackage[draft,columns=1,margin=false,headings=false]{typogrid}
13874 \usepackage{xeCJK}
13875 \usepackage{xeCJKfntef}
13876 \setCJKmainfont{SimSun}
13877 \xeCJKsetup{AllowBreakBetweenPuncts}
13878 \xeCJKDeclarePunctStyle { mine }
13879 {
13880 fixed-punct-ratio = nan ,
13881 fixed-margin-width = 0 pt ,
13882 mixed-margin-width = \maxdimen ,
13883 mixed-margin-ratio = 0.5 ,
13884 middle-margin-width = \maxdimen ,
13885 middle-margin-ratio = 0.5 ,
13886 add-min-bound-to-margin = true ,
13887 min-bound-to-kerning = true ,
13888 kerning-margin-minimum = 0.1 em ,
13889 bound-punct-width = 0 em ,
13890 enabled-hanging = true
13891 }
13892 \xeCJKDeclarePunctStyle { JIS } { bound-punct-ratio = .5 }
13893
13894 \begin{document}
13895 \setlength\parindent{2em}
13896 \newcommand\showexample[1]{%
13897 \texttt{------ #1 ------}\par\xeCJKsetup{PunctStyle=#1}\showtexts\par}
13898
13899 \newcommand\showtexts{%
13900 《第一回\quad 甄士隐梦幻识通灵\quad 贾雨村风尘怀闺秀》\\
13901 《第一回\quad 甄士隐梦幻识通灵\quad 贾雨村风尘怀闺秀》
13902
13903 列位看官:你道此书从何而来?说起根由,虽近荒唐,细按则深有趣味。待在下将此来历注明,方使阅者了然不惑。
13904
13905 \CJKunderline*{原来女娲氏炼石补天之时,于大荒山无稽崖炼成高经十二丈、方经二十四丈顽石三万六千五百零一块。娲皇氏只用了三万六千五百块,只单单剩了一块未用,便弃在此山青埂峰下。谁知此石自经煆炼之后,灵性已通,因见众石俱得补天,独自己无材不堪入选,遂自怨自叹,日夜悲号惭愧。}
13906
13907 一日,正当嗟悼之际,俄见一僧一道远远而来,生得骨格不凡,丰神迥别,说说笑笑,来至峰下,坐于石边,高谈快论:先是说些云山雾海、神仙玄幻之事,后便说到红尘中荣华富贵。此石听了,不觉打动凡心,也想要到人间去享一享这荣华富贵,但自恨粗蠢,不得已,便口吐人言,向那僧道说道:“大师,弟子蠢物,不能见礼了!适闻二位谈那人世间荣耀繁华,心切慕之。弟子质虽粗蠢,性却稍通,况见二师仙形道体,定非凡品,必有补天济世之材,利物济人之德。如蒙发一点慈心,携带弟子得入红尘,在那富贵场中,温柔乡里受享几年,自当永佩洪恩,万劫不忘也!”二仙师听毕,齐憨笑道:“善哉,善哉!那红尘中有却有些乐事,但不能永远依恃;况又有‘美中不足,好事多磨’八个字紧相连属,瞬息间则又乐极悲生,人非物换,究竟是到头一梦,万境归空,倒不如不去的好。”这石凡心已炽,那里听得进这话去,乃复苦求再四。二仙知不可强制,乃叹道:“此亦静极思动,无中生有之数也!既如此,我们便携你去受享受享,只是到不得意时,切莫后悔!”石道:“自然,自然。”那僧又道:“若说你性灵,却又如此质蠢,并更无奇贵之处。如此也只好踮脚而已。也罢!我如今大施佛法,助你助,待劫终之日,复还本质,以了此案。你道好否?”石头听了,感谢不尽。那僧便念咒书符,大展幻术,将一块大石登时变成一块鲜明莹洁的美玉,且又缩成扇坠大小的可佩可拿。那僧托于掌上,笑道:“形体倒也是个宝物了!还只没有实在的好处,须得再镌上数字,使人一见便知是奇物方妙。然后好携你到那昌明隆盛之邦、诗礼簪缨之族、花柳繁华地、温柔富贵乡去安身乐业。”石头听了,喜不能禁,乃问:“不知赐了弟子那哪几件奇处?又不知携了弟子到何地方?望乞明示,使弟子不惑。”那僧笑道:“你且莫问,日后自然明白的。”说着,便袖了这石,同那道人飘然而去,竟不知投奔何方何舍。
13908
13909 \hfill
13910 ——曹雪芹《红楼梦》\unskip\unkern}
13911
13912
13913 \showexample{mine}
13914 \showexample{quanjiao}
13915 \showexample{JIS}
13916 \showexample{banjiao}
13917 \showexample{CCT}
13918 \showexample{kaiming}
13919 \showexample{hangmobanjiao}
13920 \showexample{plain}
13921
13922 \end{document}
13923 % \end{macrocode}
13924 %
13925 % \begin{macrocode}
13926 %</ex-punctstyle>
13927 % \end{macrocode}
13928 %
13929 % \subsection{\pkg{xeCJK-example-verbatim.tex}}
13930 %
13931 % \begin{macrocode}
13932 %<*ex-verb>
13933 % \end{macrocode}
13934 %
13935 % \begin{macrocode}
13936 \documentclass[a4paper]{article}
13937 \usepackage{xeCJK}
13938 \usepackage{fullpage}
13939 \xeCJKDeclareSubCJKBlock{Hangul}
13940 { "1100 -> "11FF, "3130 -> "318F, "A960 -> "A97F, "AC00 -> "D7AF }
13941 \setCJKmainfont{Adobe Song Std}
13942 \setCJKmainfont[Hangul]{Adobe Myungjo Std}
13943 %%\setmonofont{Inconsolata}
13944 %%\setmonofont{Source Code Pro}
13945 %%\setCJKmonofont{Adobe Kaiti Std}
13946 \setmonofont{TeX Gyre Cursor}
13947 \setCJKmonofont{Adobe Fangsong Std}
13948 \begin{document}
13949
13950 \begin{verbatim}
13951 *************************************************************
13952 * *
13953 * 精致甲版红楼梦 - 精致工作室特别奉献(2010年9月) *
13954 * *
13955 * GBK简体、GBK繁体、Big5繁体、PDF简体、PDF繁体 *
13956 * *
13957 * 为 GBK、Big5 特别度身订制,并经反复修订,方便纯文本阅读 *
13958 * *
13959 * 精致甲、乙版红楼梦下载专页 *
13960 * http://www.speedy7.com/cn/stguru/gb2312/redmansions.htm *
13961 * http://www.speedy7.com/cn/stguru/big5/redmansions.htm *
13962 * *
13963 * 此电子文件可随意传播、发布、下载。 *
13964 * 传播时建议保留此版本说明供查阅与识别。 *
13965 * 未经修订者同意,不得将此版本用于商业用途。 *
13966 * 如您对红楼梦不具深入了解,请勿随便修改其中的内容。 *
13967 * *
13968 *************************************************************
13969 \end{verbatim}
13970
13971 \verb|a 汉 字 b|
13972
13973 \verb*|a 汉 字 b|
13974
13975 \begin{verbatim}
13976 lang_set = {
13977 ["English"] = lang.en,
13978 ["Français"] = lang.fr,
13979 ["Español"] = lang.es,
13980 ["中文"] = lang.zh,
13981 ["日本語"] = lang.ja,
13982 ["한국어"] = lang.ko,
13983 }
13984 \end{verbatim}
13985
13986 \end{document}
13987 % \end{macrocode}
13988 %
13989 % \begin{macrocode}
13990 %</ex-verb>
13991 % \end{macrocode}
13992 %
13993 % \subsection{\pkg{xeCJK-example-CM.tex}}
13994 %
13995 % \begin{macrocode}
13996 %<*ex-cm>
13997 % \end{macrocode}
13998 %
13999 % \begin{macrocode}
14000 \documentclass{article}
14001 \usepackage{xeCJK}
14002 \usepackage{hologo}
14003
14004 \setCJKmainfont{HanaMinA} %% http://fonts.jp/hanazono/
14005
14006 \begin{document}
14007
14008 \hologo{XeTeX} でIVSを使うテスト。
14009
14010 消󠄀化󠄀器󠄂 / 消󠄁火器󠄃 / 消󠄂化󠄁器󠄄
14011
14012 消󠄃火器󠄅 / 消化󠄂器󠄆 / 消火器󠄇
14013
14014 消化󠄃器󠄈 / 消火器󠄉 / 辻󠄂辻󠄃辻󠄄辻󠄅 
14015
14016 \CJKfontspec{Meiryo}
14017
14018 か
14019
14020 がか゚
14021
14022 ぼぽ
14023
14024 ぼぽ
14025
14026 ばぱ
14027
14028 ばぱ
14029
14030 \end{document}
14031 % \end{macrocode}
14032 %
14033 % \begin{macrocode}
14034 %</ex-cm>
14035 % \end{macrocode}
14036 %
14037 % \subsection{\pkg{xeCJK-example-listings.tex}}
14038 %
14039 % \begin{macrocode}
14040 %<*ex-listings>
14041 % \end{macrocode}
14042 %
14043 % \begin{macrocode}
14044 \documentclass{article}
14045 \usepackage[margin=1in]{geometry}
14046 \usepackage{listings,xcolor}
14047 \usepackage{showexpl}
14048
14049 \usepackage{xeCJK}
14050 \setCJKmainfont{HanaMinA}
14051 \setCJKmonofont{SimSun}
14052 \xeCJKDeclareSubCJKBlock{Kana} { "3040 -> "309F, "30A0 -> "30FF, "31F0 -> "31FF }
14053 \setCJKmonofont[Kana]{Meiryo}
14054 \setmonofont{Latin Modern Mono Light}
14055
14056 \makeatletter
14057 \lstset{%
14058 basicstyle=\small\ttfamily,breakindent=4\lst@width,
14059 numbers=left,numberstyle=\tiny\color{gray},
14060 commentstyle=\color{green!50!black},keywordstyle=\color{blue}\bfseries,
14061 identifierstyle=\color{violet},stringstyle=\color{brown},
14062 escapebegin=\normalfont}
14063 \lstnewenvironment{cppcode}[1][]
14064 {\lstset{language=C++,#1}}
14065 {}
14066 \makeatother
14067
14068 \begin{document}
14069
14070 \section{\lstinline{\\lstinline} 测试}
14071
14072 \section{\lstinline|甲*乙| 测试}
14073
14074 \lstinline|abc汉字abc|
14075
14076 \lstinline|甲*乙|
14077
14078 \lstinline[mathescape]|数学公式$x^2+y^2$|
14079
14080 \section{\lstinline{lstlisting} 环境测试}
14081
14082 \begin{lstlisting}[basicstyle=\rmfamily]
14083 纯文字text测试
14084 纯文字text测试
14085 文字+文字
14086 文字(符号)文字
14087 辻󠄂辻󠄃辻󠄄辻󠄅
14088 かがか゚
14089 \end{lstlisting}
14090
14091 \begin{lstlisting}
14092 text纯文字测试
14093 \end{lstlisting}
14094
14095 \begin{lstlisting}
14096 text 纯文字测试
14097 \end{lstlisting}
14098
14099 \begin{lstlisting}
14100 text,纯文字测试
14101 \end{lstlisting}
14102
14103 \section{自定义环境测试}
14104
14105 \begin{LTXexample}[pos=t,varwidth,numbersep=5pt,columns=fixed]
14106 \begin{cppcode}[escapechar=`,morekeywords=返回]
14107 #define 返回 return
14108 #include <iostream>
14109 /*
14110 * 块注释
14111 * `逃逸字符,测试$f(x)$`
14112 */
14113 int main()
14114 {
14115 // 行注释
14116 const char *欢迎 = "hello 世界(ワールド)";
14117 std::cout << 欢迎 << std::endl;
14118 返回 0;
14119 }
14120 \end{cppcode}
14121 \end{LTXexample}
14122
14123 \section{\texttt{breaklines} 测试}
14124
14125 \begin{lstlisting}[linewidth=10em,frame=single,rulecolor=\color{black},breaklines]
14126 断行文字text测试,断行文字text测试,断行文字text测试,断行文字text测试
14127 断行文字text测试,断行文字text测试,断行文字text测试,断行文字text测试
14128 \end{lstlisting}
14129
14130 \section{\lstinline|\\lstinputlisting| 测试}
14131
14132 \lstinputlisting[language={[AlLaTeX]TeX}]{\jobname}
14133
14134 \end{document}
14135 % \end{macrocode}
14136 %
14137 % \begin{macrocode}
14138 %</ex-listings>
14139 % \end{macrocode}
14140 %
14141 % \subsection{\pkg{xeCJK-example-mathblock.tex}}
14142 %
14143 % \begin{macrocode}
14144 %<*ex-mathblock>
14145 % \end{macrocode}
14146 %
14147 % \begin{macrocode}
14148 \documentclass{article}
14149
14150 \usepackage{url}
14151 \usepackage[CJKmath]{xeCJK}
14152
14153 \setCJKmainfont[BoldFont=SimHei]{SimSun}
14154 \setCJKmonofont{KaiTi}
14155
14156 \ExplSyntaxOn
14157 \tl_const:Nn \c_test_text_tl { 天地玄黃宇宙洪荒日月盈昃辰宿列張寒來暑往秋收冬藏閏餘成歲律呂調陽 }
14158 \cs_new:Npn \test_color:n #1
14159 { \exp_args:No \str_range:nnn { \mdfivesum {#1} } { 1 } { 6 } }
14160 \tl_map_inline:Nn \c_test_text_tl
14161 {
14162 \xeCJKDeclareSubCJKBlock {#1} { `#1 }
14163 \setCJKmainfont
14164 [ #1 , Color = \test_color:n {#1} , BoldFont = SimHei ] { SimSun }
14165 \setCJKmonofont [ #1 ] { KaiTi }
14166 }
14167 \cs_new_protected:Npn \TEST
14168 {
14169 \exp_args:No \path { \c_test_text_tl } \par
14170 \c_test_text_tl \par
14171 $ \c_test_text_tl $
14172 }
14173 \ExplSyntaxOff
14174
14175 \begin{document}
14176
14177 \TEST
14178
14179 \bigskip
14180
14181 \bfseries\mathversion{bold}\TEST
14182
14183 \end{document}
14184 % \end{macrocode}
14185 %
14186 % \begin{macrocode}
14187 %</ex-mathblock>
14188 % \end{macrocode}
14189 %
14190 % \subsection{\pkg{xunicode-symbols.tex}}
14191 %
14192 % \begin{macrocode}
14193 %<*xunicode-symbols>
14194 % \end{macrocode}
14195 %
14196 % \begin{macrocode}
14197 %<@@=xunsym>
14198 % \end{macrocode}
14199 %
14200 % \begin{macrocode}
14201 \documentclass[a4paper]{article}
14202 \usepackage[margin=2cm]{geometry}
14203 \usepackage{fontspec}
14204 \usepackage{xunicode-addon}
14205 \usepackage{array,longtable,booktabs}
14206 \usepackage{zref-base}
14207
14208 \setmainfont{FreeSerif}
14209 \newfontfamily\falllbackfont{Segoe UI Symbol}
14210
14211 \makeatletter
14212 \ExplSyntaxOn
14213 \cs_new_protected:Npx \@@_restore_catcode:
14214 { \char_set_catcode:nn { 0 } { \char_value_catcode:n { 0 } } }
14215 \file_if_exist:nTF { xunicode-commands.tex }
14216 { \char_set_catcode_comment:n { 0 } }
14217 { \char_set_catcode_ignore:n { 0 } }
14218 ^^@ \tl_new:N \l_@@_command_tl
14219 ^^@ \int_new:N \l_@@_command_int
14220 ^^@ \iow_new:N \g_@@_command_iow
14221 ^^@ \iow_new:N \g_@@_combine_mark_iow
14222 ^^@ \ior_new:N \g_@@_unicode_ior
14223 ^^@ \prop_new:N \l_@@_command_prop
14224 ^^@ \prop_new:N \l_@@_combine_mark_prop
14225 ^^@ \prop_new:N \l_@@_combine_marks_prop
14226 ^^@ \cs_new_protected:Npn \SaveUTFCommands
14227 ^^@ {
14228 ^^@ \group_begin:
14229 ^^@ \@@_restore_catcode:
14230 ^^@ \cs_set_eq:NN \DeclareTextAccent \use_none:nnn
14231 ^^@ \cs_set_eq:NN \DeclareUTFComposite \use_none:n
14232 ^^@ \cs_set_eq:NN \DeclareUTFEncodedAccent \use_none:nnn
14233 ^^@ \cs_set_eq:NN \DeclareUTFDoubleEncodedAccent \use_none:nnn
14234 ^^@ \cs_set_eq:NN \DeclareUTFDoubleEncodedSymbol \use_none:nnn
14235 ^^@ \cs_set_eq:NN \DeclareUTFCommand \use_none:nn
14236 ^^@ \cs_set_eq:NN \DeclareUTFTIPACommand \use_none:n
14237 ^^@ \cs_set_eq:NN \DeclareUTFCompositeCommand \use_none:nnn
14238 ^^@ \cs_set_eq:NN \DeclareUTFSymbol \@@_save_UTF_command:Nn
14239 ^^@ \cs_set_eq:NN \DeclareUTFCompositeSymbol \@@_save_UTF_command:Nnn
14240 ^^@ \cs_set_eq:NN \DeclareEncodedCompositeCharacter \@@_save_combine_mark:nnnn
14241 ^^@ \cs_set_eq:NN \DeclareEncodedCompositeAccents \@@_save_combine_marks:nnnn
14242 ^^@ \DeclareDocumentCommand \DeclareUTFcharacter { O { \UTFencname } m m }
14243 ^^@ { \@@_save_UTF_command:NNn \l_@@_command_prop {##3} {##2} }
14244 ^^@ \DeclareDocumentCommand \DeclareUTFcomposite { O { \UTFencname } m m m }
14245 ^^@ { \@@_save_UTF_command:NNnn \l_@@_command_prop {##3} {##4} {##2} }
14246 ^^@ \ReloadXunicode { \UTFencname }
14247 ^^@ \ior_open:NnTF \g_@@_unicode_ior { UnicodeData.txt }
14248 ^^@ {
14249 ^^@ \iow_open:Nn \g_@@_command_iow { xunicode-commands.tex }
14250 ^^@ \iow_open:Nn \g_@@_combine_mark_iow { xunicode-combine-marks.tex }
14251 ^^@ \ior_map_inline:Nn \g_@@_unicode_ior { \@@_make_table:w ##1 \q_stop }
14252 ^^@ \@@_write_combine_marks:
14253 ^^@ \ior_close:N \g_@@_unicode_ior
14254 ^^@ \iow_close:N \g_@@_command_iow
14255 ^^@ \iow_close:N \g_@@_combine_mark_iow
14256 ^^@ \group_end:
14257 ^^@ }
14258 ^^@ {
14259 ^^@ \group_end:
14260 ^^@ \msg_fatal:nn { @@ } { UnicodeData }
14261 ^^@ }
14262 ^^@ }
14263 ^^@ \msg_new:nnn { @@ } { UnicodeData }
14264 ^^@ { File~`UnicodeData.txt`~not~found. }
14265 ^^@ \cs_new_protected:Npn \@@_save_UTF_command:Nn
14266 ^^@ { \@@_save_UTF_command:NNn \l_@@_command_prop }
14267 ^^@ \cs_new_protected:Npn \@@_save_UTF_command:Nnn
14268 ^^@ { \@@_save_UTF_command:NNnn \l_@@_command_prop }
14269 ^^@ \cs_new_protected:Npn \@@_save_UTF_command:NNn #1#2#3
14270 ^^@ { \@@_save_UTF_text_command:Nxx #1 { \use_none:n #3 } { \token_to_str:N #2 } }
14271 ^^@ \cs_new_protected:Npn \@@_save_UTF_command:NNnn #1#2#3#4
14272 ^^@ {
14273 ^^@ \@@_save_UTF_text_command:Nxx #1 { \use_none:n #4 }
14274 ^^@ {
14275 ^^@ \token_to_str:N #2 \c_left_brace_str
14276 ^^@ \tl_if_single:nTF {#3} { \token_to_str:N #3 } { \tl_to_str:n {#3} }
14277 ^^@ \c_right_brace_str
14278 ^^@ }
14279 ^^@ }
14280 ^^@ \cs_new_protected:Npn \@@_save_combine_mark:nnnn #1#2#3#4
14281 ^^@ { \@@_save_UTF_text_command:Nxx \l_@@_combine_mark_prop {#3} { \token_to_str:N #2 } }
14282 ^^@ \cs_new_protected:Npn \@@_save_combine_marks:nnnn #1#2#3#4
14283 ^^@ { \@@_save_UTF_text_command:Nxx \l_@@_combine_marks_prop { { "#4 } { "#3 } } { \token_to_str:N #2 } }
14284 ^^@ \cs_new_protected:Npn \@@_save_UTF_text_command:Nxx #1#2#3
14285 ^^@ { \use:e { \@@_save_UTF_text_command:Nnn \exp_not:N #1 {#2} {#3} } }
14286 ^^@ \cs_new_protected:Npn \@@_save_UTF_text_command:Nnn #1#2#3
14287 ^^@ {
14288 ^^@ \prop_get:NnNTF #1 {#2} \l_@@_command_tl
14289 ^^@ { \prop_put:Nno #1 {#2} { \l_@@_command_tl , #3 } }
14290 ^^@ { \prop_put:Nnn #1 {#2} {#3} }
14291 ^^@ }
14292 ^^@ \cs_new_protected:Npn \@@_make_table:w #1 ; #2 ; #3 \q_stop
14293 ^^@ {
14294 ^^@ \prop_get:NnNT \l_@@_command_prop {#1} \l_@@_command_tl
14295 ^^@ {
14296 ^^@ \iow_now:Nx \g_@@_command_iow
14297 ^^@ { \token_to_str:N \UnicodeTextSymbol { "#1 } { \l_@@_command_tl } {#2} }
14298 ^^@ }
14299 ^^@ \prop_get:NnNT \l_@@_combine_mark_prop {#1} \l_@@_command_tl
14300 ^^@ {
14301 ^^@ \iow_now:Nx \g_@@_combine_mark_iow
14302 ^^@ { \token_to_str:N \UnicodeCombineMark { "#1 } { \l_@@_command_tl } {#2} }
14303 ^^@ }
14304 ^^@ }
14305 ^^@ \cs_new_protected:Npn \@@_write_combine_marks:
14306 ^^@ {
14307 ^^@ \prop_map_inline:Nn \l_@@_combine_marks_prop
14308 ^^@ {
14309 ^^@ \iow_now:Nx \g_@@_combine_mark_iow
14310 ^^@ { \token_to_str:N \UnicodeCombineMarks ##1 {##2} }
14311 ^^@ }
14312 ^^@ }
14313 ^^@ \ExplSyntaxOff
14314 ^^@ \SaveUTFCommands
14315 ^^@ \ExplSyntaxOn
14316 \@@_restore_catcode:
14317 \int_new:N \g_@@_symbol_int
14318 \int_new:N \g_@@_table_int
14319 \DeclareDocumentCommand \UnicodeTextSymbol { m v m }
14320 {
14321 \int_gincr:N \g_@@_symbol_int
14322 \use_none:n #1 &
14323 \scan_stop:
14324 \reverse_if:N \tex_iffontchar:D \tex_font:D #1 \exp_stop_f: \falllbackfont \fi:
14325 \tex_char:D #1 \exp_stop_f: &
14326 \tl_set:Nn \l_tmpa_clist {#2}
14327 \clist_use:Nn \l_tmpa_clist { \par }
14328 \strut
14329 & #3 \\
14330 }
14331 \cs_set_eq:NN \UnicodeCombineMark \UnicodeTextSymbol
14332 \DeclareDocumentCommand \UnicodeCombineMarks { m m v }
14333 {
14334 \int_gincr:N \g_@@_symbol_int
14335 \use_none:n #1 ~ \use_none:n #2 &
14336 \tex_char:D #1 \exp_stop_f: \tex_char:D #2 \exp_stop_f: &
14337 \tl_set:Nn \l_tmpa_clist {#3}
14338 \clist_use:Nn \l_tmpa_clist { \par }
14339 \strut \\
14340 }
14341 \DeclareDocumentCommand \UTFTABLE { m m }
14342 {
14343 \int_gincr:N \g_@@_table_int
14344 \exp_args:Nx \@@_make_table:nnn { UTFTABLE - \int_use:N \g_@@_table_int } {#1} {#2}
14345 }
14346 \cs_new_protected:Npn \@@_make_table:nnn #1#2#3
14347 {
14348 \section{#2~(\zref@extractdefault{#1}{default}{0})}
14349 \zref@refused{#1}
14350 \noindent
14351 \begin{longtable}[c]{>{\ttfamily\footnotesize}rc>{\ttfamily\footnotesize}p{55mm}>{\tiny}l}
14352 \toprule
14353 \multicolumn1c{\normalfont\normalsize USV} &
14354 \normalfont\normalsize Symbol &
14355 \normalfont\normalsize Macro(s) &
14356 \normalfont\normalsize Description \\
14357 \midrule \endhead
14358 \bottomrule \endfoot
14359 \int_gzero:N \g_@@_symbol_int
14360 \input{#3}
14361 \end{longtable}
14362 \group_begin:
14363 \zref@setcurrent{default}{\int_use:N\g_@@_symbol_int}
14364 \zref@wrapper@immediate{\zref@labelbyprops{#1}{default}}
14365 \group_end:
14366 }
14367 \cs_generate_variant:Nn \@@_make_table:nnn { x }
14368 \ExplSyntaxOff
14369
14370 \begin{document}
14371
14372 \UTFTABLE{Symbols}{xunicode-commands.tex}
14373
14374 \UTFTABLE{Combining Marks}{xunicode-combine-marks.tex}
14375
14376 \end{document}
14377 % \end{macrocode}
14378 %
14379 % \begin{macrocode}
14380 %</xunicode-symbols>
14381 % \end{macrocode}
14382 %
14383 % \end{implementation}
14384 %
14385 \endinput