summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/ctex/ctex.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/ctex/ctex.dtx')
-rw-r--r--Master/texmf-dist/source/latex/ctex/ctex.dtx822
1 files changed, 494 insertions, 328 deletions
diff --git a/Master/texmf-dist/source/latex/ctex/ctex.dtx b/Master/texmf-dist/source/latex/ctex/ctex.dtx
index 353a630cdd8..8a702ca8d30 100644
--- a/Master/texmf-dist/source/latex/ctex/ctex.dtx
+++ b/Master/texmf-dist/source/latex/ctex/ctex.dtx
@@ -2,7 +2,7 @@
% !TeX program = XeLaTeX
% !TeX encoding = UTF-8
%
-% Copyright (C) 2003--2015
+% Copyright (C) 2003--2016
% CTEX.ORG and any individual authors listed elsewhere in this file.
% --------------------------------------------------------------------------
%
@@ -478,7 +478,7 @@ This package consists of the file ctex.dtx, and the derived files
%<founder>\ProvidesExplFile{ctex-fontset-founder.def}
%<ubuntu> {Ubuntu fonts definition (CTEX)}
%<ubuntu>\ProvidesExplFile{ctex-fontset-ubuntu.def}
- {\ExplFileDate}{2.2}{\ExplFileDescription}
+ {\ExplFileDate}{2.3}{\ExplFileDescription}
%</!(c19|c70|ctexspa)>
%<rm&c19>\ProvidesFile{c19rm.fd}%
%<sf&c19>\ProvidesFile{c19sf.fd}%
@@ -487,8 +487,8 @@ This package consists of the file ctex.dtx, and the derived files
%<sf&c70>\ProvidesFile{c70sf.fd}%
%<tt&c70>\ProvidesFile{c70tt.fd}%
%<ctexspa>\ProvidesFile{ctexspa.def}%
-%<c19|c70> [2015/07/01 v2.2 Chinese font definition (CTEX)]
-%<ctexspa> [2015/07/01 v2.2 Space info for CJKpunct (CTEX)]
+%<c19|c70> [2016/02/02 v2.3 Chinese font definition (CTEX)]
+%<ctexspa> [2016/02/02 v2.3 Space info for CJKpunct (CTEX)]
%</!(readme|install|zhmap|spa)>
%<*driver>
\ExplSyntaxOff
@@ -772,7 +772,7 @@ This package consists of the file ctex.dtx, and the derived files
% \changes{v2.2}{2015/06/24}{不再依赖 \pkg{etoolbox} 宏包。}
%
%
-% \CheckSum{5026}
+% \CheckSum{5056}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -1704,7 +1704,6 @@ This package consists of the file ctex.dtx, and the derived files
%
% 多级选项之间用斜线分开,例如,\opt{part/name} 选项设置 \tn{part} 标题的在数
% 字前后的名称,而 \opt{section/number} 选项设置 \tn{section} 标题的数字类型。
-% 注意斜线前后都不要有空格。
%
% 使用 \tn{ctexset} 设置多级选项时,可以在同一个上级选项下设置多个下级选项。
%
@@ -2624,12 +2623,12 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{ctexexam}
% % 略复杂的 ctex.cfg 内容示例:禁止段末孤字成行。
% % 在使用 XeTeX 编译时,打开 xeCJK 的 CheckSingle 选项。
-% \xetex_if_engine:T
+% \sys_if_engine_xetex:T
% {
% \xeCJKsetup { CheckSingle }
% }
% % 在使用 LuaTeX 编译时,设置 LuaTeX-ja 的 jcharwidowpenalty 参数。
-% \luatex_if_engine:T
+% \sys_if_engine_luatex:T
% {
% \ltjsetparameter { jcharwidowpenalty = 10000 }
% }
@@ -3003,9 +3002,14 @@ This package consists of the file ctex.dtx, and the derived files
%</class|style>
% \end{macrocode}
%
+% \begin{macrocode}
+%<*class|ctex>
+% \end{macrocode}
+%
+% \changes{v2.3}{2015/12/20}{与 \LaTeXiii{} (2015/12/20) 同步。}
+%
% 检查 \pkg{expl3} 和 \pkg{l3keys2e} 的版本。
% \begin{macrocode}
-%<*class>
\msg_new:nnnn { ctex } { l3-too-old }
{ Support~package~`#1'~too~old. }
{
@@ -3013,13 +3017,33 @@ This package consists of the file ctex.dtx, and the derived files
`l3kernel'~and~`l3packages'\\\\
using~your~TeX~package~manager~or~from~CTAN.
}
-\@ifpackagelater { expl3 } { 2014/07/20 } { }
+\@ifpackagelater { expl3 } { 2015/12/20 } { }
{ \msg_error:nnn { ctex } { l3-too-old } { expl3 } }
-\@ifpackagelater { l3keys2e } { 2014/05/05 } { }
+%<*class>
+\@ifpackagelater { l3keys2e } { 2015/12/20 } { }
{ \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } }
%</class>
% \end{macrocode}
%
+% \begin{variable}[int]{\c_@@_engine_file_str}
+% 引擎检查,暂不支持 \pTeX{} 系。
+% \begin{macrocode}
+\msg_new:nnnn { ctex } { engine-not-supported }
+ { Engine~`#1'~is~not~yet~supported,~ctex~will~abort! }
+ { You~can~switch~to~xelatex,~lualatex~or~pdflatex.}
+\file_if_exist:nTF { ctex-engine- \c_sys_engine_str .def }
+ {
+ \str_const:Nx \c_@@_engine_file_str
+ { ctex-engine- \c_sys_engine_str .def }
+ }
+ { \msg_critical:nnx { ctex } { engine-not-supported } { \c_sys_engine_str } }
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{macrocode}
+%</class|ctex>
+% \end{macrocode}
+%
% \begin{macrocode}
%<*class|ctex|ctexheading>
% \end{macrocode}
@@ -3114,31 +3138,14 @@ This package consists of the file ctex.dtx, and the derived files
}
% \end{macrocode}
%
-% \begin{macro}[int]{\ctex_lua_now_x:n}
-% 最新的 \pkg{expl3} 去掉了 \pkg{l3luatex} 模块,因而 \cs{lua_now_x:n} 不再有定义。
-% \begin{macrocode}
-\cs_new_eq:NN \ctex_lua_now_x:n \luatex_directlua:D
-% \end{macrocode}
-% \end{macro}
-%
% \changes{v2.1}{2015/05/25}{不依赖 \pkg{ifpdf} 宏包。}
%
-% \begin{macro}[int]{\ctex_if_pdfmode:TF}
-% \pkg{ifpdf} 宏包的简单实现。
+% \begin{macro}[int]{\ifctexpdf}
+% 在 \pkg{zhmetrics} 映射文件中使用。
% \begin{macrocode}
-\cs_if_exist:NTF \pdftex_pdfoutput:D
- {
- \int_compare:nNnTF \pdftex_pdfoutput:D > \c_zero
- {
- \cs_new_eq:NN \ifctexpdf \tex_iftrue:D
- \cs_new_eq:NN \ctex_if_pdfmode:TF \use_i:nn
- }
- }
- { \use:n }
- {
- \cs_new_eq:NN \ifctexpdf \tex_iffalse:D
- \cs_new_eq:NN \ctex_if_pdfmode:TF \use_ii:nn
- }
+\sys_if_output_pdf:TF
+ { \cs_new_eq:NN \ifctexpdf \if_true: }
+ { \cs_new_eq:NN \ifctexpdf \if_false: }
% \end{macrocode}
% \end{macro}
%
@@ -3165,6 +3172,8 @@ This package consists of the file ctex.dtx, and the derived files
% \end{macrocode}
% \end{macro}
%
+% \changes{v2.3}{2015/09/17}{代码实现避免使用 \tn{lowercase} 技巧(Joseph Wright)。}
+%
% \begin{macro}[int]{\ctex_default_pt:n}
% 最新版本的 \pkg{expl3} 已经不允许 \cs{dim_to_decimal:n} 的参数带额外的单位。
% 然而我们需要这个特性实现可展的 \tn{@defaultunits}。
@@ -3174,13 +3183,11 @@ This package consists of the file ctex.dtx, and the derived files
\exp_after:wN \@@_default_pt:w
\dim_use:N \etex_dimexpr:D #1 pt \scan_stop: \q_stop
}
-\group_begin:
- \char_set_catcode_other:N \P
- \char_set_catcode_other:N \T
-\tex_lowercase:D
+\use:x
{
- \group_end:
- \cs_new:Npn \@@_default_pt:w #1 PT #2 \q_stop { #1 PT }
+ \cs_new:Npn \exp_not:N \@@_default_pt:w
+ ##1 \tl_to_str:n { pt } ##2 \exp_not:N \q_stop
+ { ##1 \tl_to_str:n { pt } }
}
% \end{macrocode}
% \end{macro}
@@ -3190,7 +3197,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
\tl_new:N \l_@@_encoding_tl
\tl_set:Nx \l_@@_encoding_tl
- { \pdftex_if_engine:TF { GBK } { UTF8 } }
+ { \sys_if_engine_pdftex:TF { GBK } { UTF8 } }
% \end{macrocode}
% \end{variable}
%
@@ -3272,6 +3279,9 @@ This package consists of the file ctex.dtx, and the derived files
%
% \subsection{宏包选项}
%
+% \changes{v2.3}{2015/09/25}
+% {\texttt{.value_required:} 和 \texttt{.value_forbidden:} 已过时。}
+%
% \begin{macrocode}
%<*class|style>
\keys_define:nn { ctex / option }
@@ -3305,8 +3315,8 @@ This package consists of the file ctex.dtx, and the derived files
{ Option~ `zihao=-4'~ is~ set. }
\keys_set:nn { ctex / option } { zihao = -4 }
} ,
- c5size .value_forbidden: ,
- cs4size .value_forbidden: ,
+ c5size .value_forbidden:n = true ,
+ cs4size .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3317,7 +3327,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
linespread .fp_set:N = \l_@@_line_spread_fp ,
linespread .initial:n = { \c_nan_fp } ,
- linespread .value_required: ,
+ linespread .value_required:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3359,7 +3369,7 @@ This package consists of the file ctex.dtx, and the derived files
options.~
}
} ,
- indent .value_forbidden: ,
+ indent .value_forbidden:n = true ,
noindent .code:n =
{
\msg_warning:nnn { ctex } { deprecated-option }
@@ -3369,7 +3379,7 @@ This package consists of the file ctex.dtx, and the derived files
options.
}
} ,
- noindent .value_forbidden: ,
+ noindent .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3377,8 +3387,8 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
GBK .code:n = { \tl_set:Nn \l_@@_encoding_tl { GBK } } ,
UTF8 .code:n = { \tl_set:Nn \l_@@_encoding_tl { UTF8 } } ,
- GBK .value_forbidden: ,
- UTF8 .value_forbidden: ,
+ GBK .value_forbidden:n = true ,
+ UTF8 .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3418,9 +3428,9 @@ This package consists of the file ctex.dtx, and the derived files
}
\keys_set:nn { ctex / option } { fontset = windows }
} ,
- nofonts .value_forbidden: ,
- winfonts .value_forbidden: ,
- adobefonts .value_forbidden: ,
+ nofonts .value_forbidden:n = true ,
+ winfonts .value_forbidden:n = true ,
+ adobefonts .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3452,7 +3462,7 @@ This package consists of the file ctex.dtx, and the derived files
{ Option~ `zhmap=false'~ is~ set. }
\keys_set:nn { ctex / option } { zhmap = false }
} ,
- nozhmap .value_forbidden: ,
+ nozhmap .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3471,7 +3481,7 @@ This package consists of the file ctex.dtx, and the derived files
{ Option~ `punct=plain'~ is~ set. }
\keys_set:nn { ctex / option } { punct = plain }
} ,
- nopunct .value_forbidden: ,
+ nopunct .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3491,7 +3501,7 @@ This package consists of the file ctex.dtx, and the derived files
{ Option~ `space=false'~ is~ set. }
\keys_set:nn { ctex / option } { space = false }
} ,
- nospace .value_forbidden: ,
+ nospace .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3514,8 +3524,8 @@ This package consists of the file ctex.dtx, and the derived files
{ \cs_gset_eq:NN \g_@@_section_depth_flag \c_three } ,
sub4section .code:n =
{ \cs_gset_eq:NN \g_@@_section_depth_flag \c_four } ,
- sub3section .value_forbidden: ,
- sub4section .value_forbidden: ,
+ sub3section .value_forbidden:n = true ,
+ sub4section .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3553,8 +3563,8 @@ This package consists of the file ctex.dtx, and the derived files
{ Option~ `scheme = plain' ~ is~ set. }
\keys_set:nn { ctex / option } { scheme = plain }
} ,
- cap .value_forbidden: ,
- nocap .value_forbidden: ,
+ cap .value_forbidden:n = true ,
+ nocap .value_forbidden:n = true ,
% \end{macrocode}
% \end{macro}
%
@@ -3622,7 +3632,7 @@ This package consists of the file ctex.dtx, and the derived files
\clist_gput_right:Nn \g_@@_std_options_clist {#1}
} ,
%</class>
- #1 .value_forbidden: ,
+ #1 .value_forbidden:n = true ,
}
}
\use:x { \keys_define:nn { ctex / option } { \exp_not:o { \l_@@_tmp_tl } } }
@@ -3772,7 +3782,7 @@ This package consists of the file ctex.dtx, and the derived files
\cs_generate_variant:Nn \ctex_add_cmap:Nn { c }
\cs_new_protected_nopar:Npn \@@_save_cmap:Nn #1#2
{
- \tex_lowercase:D { \tl_set:Nx \l_@@_tmp_tl { #2 \CJK@plane } }
+ \tl_set:Nx \l_@@_tmp_tl { \str_lower_case:n {#2} \CJK@plane }
\tex_immediate:D \pdfobj stream ~ file { \l_@@_tmp_tl .cmap }
\cs_new_protected_nopar:Npx #1
{
@@ -3788,7 +3798,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
\group_begin:
\char_set_catcode_other:N \#
-\ctex_if_pdfmode:TF
+\sys_if_output_pdf:TF
{
\group_end:
\ctex_appto_cmd:NnnTF \DeclareFontFamily { \ExplSyntaxOff }
@@ -4146,6 +4156,7 @@ This package consists of the file ctex.dtx, and the derived files
% \end{macrocode}
%
% \changes{v2.0}{2014/03/08}{通过 \pkg{LuaTeX-ja} 宏包支持 \LuaLaTeX。}
+% \changes{v2.3}{2015/09/25}{更新 \pkg{LuaTeX-ja} 支持(20150922.0)。}
%
% \pkg{LuaTeX-ja} 为了兼容 p\LaTeX 的使用习惯,对 \LaTeXe 的 \pkg{NFSS} 作了不少
% 修改和扩充,这对于简体中文用户来说不是必要的。我们在这里禁用它。
@@ -4162,7 +4173,7 @@ This package consists of the file ctex.dtx, and the derived files
%
% \begin{macrocode}
\RequirePackage { luatexja }
-\@ifpackagelater { luatexja-core } { 2015/02/22 } { }
+\@ifpackagelater { luatexja } { 2015/09/21 } { }
{ \msg_error:nnn { ctex } { package-too-old } { luatexja } }
% \end{macrocode}
%
@@ -4196,7 +4207,7 @@ This package consists of the file ctex.dtx, and the derived files
"1100-"11FF, "2F00-"2FFF, "3100-"31EF, "A000-"A4CF, "A830-"A83F,
"AC00-"D7FF}
\ltjdefcharrange{8}{"A7, "A8, "B0, "B1, "B4, "B6, "D7, "F7}
-\ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, +8}}
+\ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, -8}}
\directlua{for x=128,255 do luatexja.math.is_math_letters[x] = true end}
% \end{macrocode}
%
@@ -4224,6 +4235,8 @@ This package consists of the file ctex.dtx, and the derived files
%<@@=ctex_ltj>
% \end{macrocode}
%
+% \changes{v2.3}{2015/09/26}{更新 \pkg{unicode-math} 宏包补丁。}
+%
% 在 \LaTeX{} 下,\pkg{LuaTeX-ja} 对 \pkg{fontspec}、\pkg{xunicode}、\pkg{unicode-math}
% 和 \pkg{listings} 打了补丁。其中前三个是把 \tn{char} 换成 \tn{ltjalchar},确保
% 字符是 ALchar 类。我们这里用 \pkg{xunicode-addon} 来处理 \pkg{xunicode}。
@@ -4232,7 +4245,7 @@ This package consists of the file ctex.dtx, and the derived files
\AtBeginUTFCommand
{
\group_begin:
- \ctex_lua_now_x:n { tex.globaldefs = 0 }
+ \lua_now_x:n { tex.globaldefs = 0 }
\ltj@allalchar
}
\AtEndUTFCommand { \group_end: }
@@ -4244,31 +4257,52 @@ This package consists of the file ctex.dtx, and the derived files
% \pkg{lltjp-unicode-math} 让数学符号命令成为普通的文字宏。为了避免它被展开,应该
% 用 \tn{protected} 来定义。
% \begin{macrocode}
-\group_begin:
-\char_set_catcode_other:n { \c_zero }
-\cs_new_protected:Npn \@@_um_char:Nw #1 = #2 \q_nil
+\cs_new_protected_nopar:Npn \@@_um_define_math_chars:
{
\group_begin:
- \char_set_lccode:nn { \c_zero } {#2}
- \tex_lowercase:D
+ \cs_set_protected:Npn \__um_sym:nnn ##1##2##3
{
- \group_end:
- \cs_gset_protected_nopar:Npn #1
+ \tl_if_in:nnT
{
- \mode_if_math:TF { ^^@ }
- { {
- \ctex_lua_now_x:n { tex.globaldefs = 0 }
- \ltj@allalchar ^^@
- } }
+ \mathord \mathalpha \mathbin \mathrel
+ \mathpunct \mathop \mathfence
}
+ { ##3 }
+ { \@@_um_char:Nn ##2 { ##1 } }
}
+ \__um_input_math_symbol_table:
+ \group_end:
+ }
+\cs_new_protected:Npn \@@_um_char:Nn #1#2
+ {
+ \@@_um_char_aux:Nx #1 { \char_generate:nn {#2} { 12 } }
\ltjsetmathletter {#2}
}
-\group_end:
+\cs_new_protected:Npn \@@_um_char_aux:Nn #1#2
+ {
+ \cs_gset_protected_nopar:Npn #1
+ {
+ \mode_if_math:TF
+ {#2}
+ {
+ {
+ \lua_now_x:n { tex.globaldefs = 0 }
+ \ltj@allalchar #2
+ }
+ }
+ }
+ }
+\cs_generate_variant:Nn \@@_um_char_aux:Nn { Nx }
\ctex_at_end_package:nn { unicode-math }
{
- \cs_if_free:NF \um_cs_set_eq_active_char:Nw
- { \cs_set_eq:NN \um_cs_set_eq_active_char:Nw \@@_um_char:Nw }
+ \cs_set_eq:NN \__um_define_math_chars: \@@_um_define_math_chars:
+ \@ifpackagelater { unicode-math } { 2015/06/28 }
+ {
+ \cs_set_eq:NN \use@mathgroup \ctex_ltj_use_math_group:Nn
+ \cs_set_protected_nopar:Npn \ctex_ltj_math_group_hook:
+ { \__um_switchto_literal: }
+ }
+ { }
}
% \end{macrocode}
% 对 \pkg{listings} 的补丁是让代码环境支持 JAchar 类。\pkg{LuaTeX-ja} 的补丁会将
@@ -4359,17 +4393,19 @@ This package consists of the file ctex.dtx, and the derived files
% \pkg{LuaTeX-ja} 的 \tn{globaljfont} 在 \pkg{luatexja-core} 中定义:
% \begin{verbatim}
% %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont
-% \protected\def\jfont{%
-% \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(false, 'yoko')}}
-% \protected\def\globaljfont{%
-% \afterassignment\ltj@@jfont\directlua{luatexja.jfont.jfontdefX(true, 'yoko')}}
+% \protected\def\jfont#1{%
+% \afterassignment\ltj@@jfont
+% \directlua{luatexja.jfont.jfontdefX(false, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
+% \protected\def\globaljfont#1{%
+% \afterassignment\ltj@@jfont
+% \directlua{luatexja.jfont.jfontdefX(true, 'yoko','\luatexluaescapestring{\noexpand#1}')}}
% \def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY()}}
% \end{verbatim}
% \texttt{jfontdefX} 函数的作用是把 \tn{CS} 定义为其后的字体,\texttt{jfontdefY}
% 的作用是更新 \texttt{JFM} 和记录相关字体信息。最后的工作是:
% \begin{verbatim}
% tex.sprint(cat_lp, global_flag, '\\protected\\expandafter\\def\\csname ',
-% cstemp , '\\endcsname{\\ltj@cur'..
+% (cstemp==' ') and '\\space' or cstemp, '\\endcsname{\\ltj@cur'..
% (jfm_dir == 'yoko' and 'j' or 't') .. 'fnt', fn, '\\relax}')
% \end{verbatim}
% \tn{CS} 的作用就是把 \tn{ltj@curjfnt} 设置为刚才定义的字体的 \texttt{font.id}。
@@ -4390,7 +4426,7 @@ This package consists of the file ctex.dtx, and the derived files
% 赋值总是全局的,不会受到分组的影响。
% \begin{macrocode}
\font@name
- \ctex_lua_now_x:n { font.current(tex.getattribute('ltj@curjfnt')) }
+ \lua_now_x:n { font.current(tex.getattribute('ltj@curjfnt')) }
\use:c { \f@encoding + \f@family }
\use:c { \curr@fontshape }
}
@@ -4442,7 +4478,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
\prg_new_conditional:Npnn \ctex_ltj_if_alternate_shape_exist:n #1 { T , F , TF }
{
- \ctex_lua_now_x:n { luatexja.jfont.does_alt_set ('\luatexluaescapestring {#1}') }
+ \lua_now_x:n { luatexja.jfont.does_alt_set ('\lua_escape_x:n {#1}') }
\prg_return_true: \else: \prg_return_false: \fi:
}
% \end{macrocode}
@@ -4461,7 +4497,7 @@ This package consists of the file ctex.dtx, and the derived files
% \texttt{font.id} 唯一。
% \begin{macrocode}
\cs_new_nopar:Npn \@@_patch_external_font:w #1 ~ at
- { #1 \ctex_lua_now_x:n { luatexja.jfont.print_aftl_address() } ~ at }
+ { #1 \lua_now_x:n { luatexja.jfont.print_aftl_address() } ~ at }
% \end{macrocode}
% \end{macro}
%
@@ -4472,12 +4508,12 @@ This package consists of the file ctex.dtx, and the derived files
{
\ctex_ltj_if_alternate_shape_exist:nT { \l_@@_current_shape_tl }
{
- \ctex_lua_now_x:n
+ \lua_now_x:n
{
luatexja.jfont.output_alt_font_cmd
- ('y', '\luatexluaescapestring { \l_@@_current_shape_tl }')
+ ('y', '\lua_escape_x:n { \l_@@_current_shape_tl }')
}
- \ctex_lua_now_x:n { luatexja.jfont.pickup_alt_font_a ('\f@size') }
+ \lua_now_x:n { luatexja.jfont.pickup_alt_font_a ('\f@size') }
}
}
\tl_new:N \l_@@_current_shape_tl
@@ -4515,65 +4551,115 @@ This package consists of the file ctex.dtx, and the derived files
\cs_new_protected_nopar:Npn \ltj@pickup@altfont@copy #1#2
{
\ltj@@getjfontnumber #1
- \ctex_lua_now_x:n
+ \lua_now_x:n
{
luatexja.jfont.pickup_alt_font_b
- ( \the\ltj@tempcntc, '\luatexluaescapestring {#2}' )
+ ( \int_use:N \ltj@tempcntc, '\lua_escape_x:n {#2}' )
}
}
% \end{macrocode}
% \end{macro}
%
+% \paragraph{数学字体族}
+%
% \begin{macrocode}
-\ExplSyntaxOff
+%<@@=ctex_ltj>
% \end{macrocode}
%
-% 以下内容抄录自 \file{lltjfont.sty},目的是让汉字可以在数学环境中直接使用。
-% \begin{macrocode}
-\def\ltj@@IsFontJapanese#1{%
- \directlua{luatexja.jfont.is_kenc(string.match(
- '\luatexluaescapestring{#1}', '[^/]+'))}}
-{\catcode`M=12%
-\gdef\ltj@@mathJapaneseFonts#1M#2#3\relax{\ltj@@IsFontJapanese{#3}}}
-\let\ltj@@al@getanddefine@fonts=\getanddefine@fonts
-\def\ltj@@ja@getanddefine@fonts#1#2{%
- \xdef\font@name{\csname \string#2/\tf@size\endcsname}%
- \pickup@jfont\let\textfont@name\font@name
- \xdef\font@name{\csname \string#2/\sf@size\endcsname}%
- \pickup@jfont\let\scriptfont@name\font@name
- \xdef\font@name{\csname \string#2/\ssf@size\endcsname}%
- \pickup@jfont
- \edef\math@fonts{\math@fonts\ltj@setpar@global%
- \ltj@@set@stackfont#1,\textfont@name:{MJT}%
- \ltj@@set@stackfont#1,\scriptfont@name:{MJS}%
- \ltj@@set@stackfont#1,\font@name:{MJSS}%
- }%
-}
-\def\getanddefine@fonts#1#2{%
- \ltj@tempcnta=#1\ltj@@IsFontJapanese{\string#2}%
- \ifin@\let\ltj@temp=\ltj@@ja@getanddefine@fonts%
- \else \let\ltj@temp=\ltj@@al@getanddefine@fonts\fi
- \ltj@temp{#1}{#2}%
-}
-\def\use@mathgroup#1#2{\relax\ifmmode
- \math@bgroup
- \expandafter\ifx\csname M@\f@encoding\endcsname#1\else
- #1\fi\ltj@tempcnta=#2 \expandafter\ltj@@mathJapaneseFonts\string#1\relax%
- \ifin@\jfam#2\relax\else\mathgroup#2\relax\fi
- \expandafter\math@egroup\fi}%
+% 以下内容来自 \file{lltjfont.sty},目的是让汉字可以在数学环境中直接使用。
+%
+% \begin{macro}[int]{\ctex_ltj_if_jfont:nTF}
+% 参数 |#1| 是一个 \LaTeXe{} 编码名称或者字体命令。\LaTeXe{} 字体命令的一般形式是:
+% \begin{quote}\ttfamily\small
+% \textbackslash\meta{encoding}/\meta{family}/\meta{series}/\meta{shape}
+% \end{quote}
+% 通过截取名字中的 \meta{encoding} 来判断是否是 jfont。
+% 最后会设置 \tn{ifin@} 为对应的 \tn{iftrue} 或者 \tn{iffalse}。
+% \begin{macrocode}
+\cs_new:Npn \ctex_ltj_if_jfont:nTF #1
+ {
+ \lua_now_x:n
+ { luatexja.jfont.is_kenc( string.match('\lua_escape_x:n {#1}', '[^/]+') ) }
+ \ifin@ \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[int]{\ctex_ltj_if_jfont_math:NTF}
+% |#1| 是一个形式为 |\M@|\meta{encoding} 的命令,它由 \tn{DeclareFontEncoding} 的
+% 第三个参数来定义。
+% \begin{macrocode}
+\cs_new:Npn \ctex_ltj_if_jfont_math:NTF #1
+ { \exp_after:wN \@@_if_jfont_math:w \token_to_str:N #1 \q_stop }
+\group_begin:
+ \char_set_catcode_other:N M
+ \cs_new:Npn \@@_if_jfont_math:w #1 M #2#3 \q_stop
+ { \ctex_ltj_if_jfont:nTF {#3} }
+\group_end:
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%<@@=>
% \end{macrocode}
%
+% \begin{macro}[int]{\getanddefine@fonts,\ctex_ltj_get_and_define_fonts:nN}
+% 在使用的场合,\tn{escapechar} 已经被设置成 $-1$,使用 \cs{token_to_str:N} 就
+% 可以得到名字,不必使用 \cs{cs_to_str:N}。
% \begin{macrocode}
-\let\@@italiccorr=\/
+\cs_new_protected_nopar:Npn \ctex_ltj_get_and_define_fonts:nN #1#2
+ {
+ \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 }
+ { \ctex_ltj_get_and_define_fonts_ja:nN }
+ { \ctex_ltj_get_and_define_fonts_al:nN }
+ {#1} #2
+ }
+\cs_new_eq:NN \ctex_ltj_get_and_define_fonts_al:nN \getanddefine@fonts
+\cs_set_eq:NN \getanddefine@fonts \ctex_ltj_get_and_define_fonts:nN
+\cs_new_protected_nopar:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2
+ {
+ \tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \tf@size } }
+ \ctex_ltj_pickup_font: \tl_set_eq:NN \textfont@name \font@name
+ \tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \sf@size } }
+ \ctex_ltj_pickup_font: \tl_set_eq:NN \scriptfont@name \font@name
+ \tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \ssf@size } }
+ \ctex_ltj_pickup_font:
+ \tl_put_right:Nx \math@fonts
+ {
+ \ltj@setpar@global
+ \ltj@@set@stackfont #1 , \textfont@name \c_colon_str { MJT }
+ \ltj@@set@stackfont #1 , \scriptfont@name \c_colon_str { MJS }
+ \ltj@@set@stackfont #1 , \font@name \c_colon_str { MJSS }
+ }
+ }
% \end{macrocode}
+% \end{macro}
%
% \begin{macrocode}
%<@@=ctex_ltj>
% \end{macrocode}
%
+% \begin{macro}[int]{\use@mathgroup,\ctex_ltj_use_math_group:Nn}
+% 在使用 \pkg{unicode-math} 宏包时,\cs{ctex_ltj_math_group_hook:} 将被重定义。
% \begin{macrocode}
-\ExplSyntaxOn
+\cs_new_protected_nopar:Npn \ctex_ltj_use_math_group:Nn #1#2
+ {
+ \mode_if_math:T
+ {
+ \math@bgroup
+ \cs_if_eq:cNF { M@ \f@encoding } #1 {#1}
+ \ctex_ltj_math_group_hook:
+ \ctex_ltj_if_jfont_math:NTF #1
+ { \jfam } { \mathgroup } #2 \scan_stop:
+ \math@egroup
+ }
+ }
+\cs_new_eq:NN \ctex_ltj_math_group_hook: \prg_do_nothing:
+\cs_set_eq:NN \use@mathgroup \ctex_ltj_use_math_group:Nn
% \end{macrocode}
+% \end{macro}
+%
+% \paragraph{字体族的定义与使用}
%
% \begin{macro}[int]{\ctex_mono_jfm:n,\l_@@_jfm_tl}
% \pkg{LuaTeX-ja} 中与标点格式 \opt{plain} 对应的 \texttt{JFM} 是 \opt{mono}。
@@ -4592,14 +4678,18 @@ This package consists of the file ctex.dtx, and the derived files
%
% \begin{macro}[int]{\CJK@encoding,\@@_change_encoding:}
% 在 \LaTeX 下,\pkg{LuaTeX-ja} 依赖字体编码来实现特殊设置。例如上述的
-% \tn{ltj@@IsFontJapanese} 就是通过判断编码来实现的,它在设置数学字体时会用到。所以
+% \cs{ctex_ltj_if_jfont:nTF} 就是通过判断编码来实现的,它在设置数学字体时会用到。所以
% 不应该与西文共用 \texttt{EU2}。定义字体族 song 为 \tn{CJK@encoding} 的默认替换
% 字体。下划线 |_| 不在 \tn{nfss@catcodes} 里,可以放心使用。
% \begin{macrocode}
\tl_const:Nn \CJK@encoding { LTJY3 }
\DeclareFontEncoding { \CJK@encoding } { } { }
-\DeclareFontSubstitution { LTJY3 } { song } { \mddefault } { \updefault }
-\ctex_lua_now_x:n { luatexja.jfont.add_kyenc_list('\CJK@encoding') }
+\use:x
+ {
+ \exp_not:N \DeclareFontSubstitution
+ { \CJK@encoding } { song } { \mddefault } { \updefault }
+ }
+\lua_now_x:n { luatexja.jfont.add_kyenc_list('\CJK@encoding') }
\cs_new_protected_nopar:Npn \@@_change_encoding:
{ \tl_set_eq:NN \g_fontspec_encoding_tl \CJK@encoding }
\DeclareFontFamily { \CJK@encoding } { song } { }
@@ -4617,8 +4707,6 @@ This package consists of the file ctex.dtx, and the derived files
% \end{macrocode}
% \end{macro}
%
-% \paragraph{字体族的定义与使用}
-%
% 这是 \pkg{luatexja-fontspec} 中新增的一些字体选项。
% \begin{macrocode}
\newfontfeature { CID } { cid = #1 }
@@ -5049,9 +5137,9 @@ This package consists of the file ctex.dtx, and the derived files
\keys_define:nn { ctex_ltj / fontspec }
{
AlternateFont .code:n = \ctex_ltj_set_alternate_seq:n {#1} ,
- AlternateFont .value_required: ,
+ AlternateFont .value_required:n = true ,
CharRange .clist_set:N = \l_@@_char_range_clist ,
- CharRange .value_required:
+ CharRange .value_required:n = true
}
% \end{macrocode}
% \end{macro}
@@ -5061,25 +5149,26 @@ This package consists of the file ctex.dtx, and the derived files
% 需要先“消毒”,同时过滤掉空元素。
% \begin{macrocode}
\group_begin:
-\char_set_catcode_active:N \/
-\char_set_lccode:nn { `\/ } { `\| }
-\tex_lowercase:D
- {
- \group_end:
- \cs_new_protected:Npn \ctex_ltj_set_alternate_seq:n #1
- {
- \clist_if_empty:NT \l_@@_char_range_clist
- {
- \tl_set:Nn \l_@@_tmp_tl {#1}
- \tl_replace_all:Nnn \l_@@_tmp_tl { // } { || }
- \seq_set_split:NnV \l_@@_tmp_seq { || } \l_@@_tmp_tl
- \seq_set_filter:NNn \l_@@_tmp_seq \l_@@_tmp_seq
- { ! \tl_if_blank_p:n { ##1 } }
- \seq_concat:NNN \l_@@_alternate_seq
- \l_@@_alternate_seq \l_@@_tmp_seq
- }
- }
- }
+ \char_set_catcode_other:N \|
+ \cs_set:Npn \@@_tmp:w #1
+ {
+ \cs_new_protected:Npn \ctex_ltj_set_alternate_seq:n ##1
+ {
+ \clist_if_empty:NT \l_@@_char_range_clist
+ {
+ \tl_set:Nn \l_@@_tmp_tl { ##1 }
+ \tl_replace_all:Nnn \l_@@_tmp_tl {#1} { || }
+ \seq_set_split:NnV \l_@@_tmp_seq { || } \l_@@_tmp_tl
+ \seq_set_filter:NNn \l_@@_tmp_seq \l_@@_tmp_seq
+ { ! \tl_if_blank_p:n { ####1 } }
+ \seq_concat:NNN \l_@@_alternate_seq
+ \l_@@_alternate_seq \l_@@_tmp_seq
+ }
+ }
+ }
+ \char_set_catcode_active:N \|
+ \@@_tmp:w { || }
+\group_end:
\seq_new:N \l_@@_tmp_seq
\seq_new:N \l_@@_alternate_seq
% \end{macrocode}
@@ -5250,7 +5339,7 @@ This package consists of the file ctex.dtx, and the derived files
\@@_save_alternate_shape:cnn
{ \@@_alternate_cs:n { clear / \l_@@_base_CJKfamily_tl } }
{ luatexja.jfont.clear_alt_font_latex }
- { '\luatexluaescapestring { \CJK@encoding/#2/#3/#4 }' }
+ { '\lua_escape_x:n { \CJK@encoding/#2/#3/#4 }' }
}
% \end{macrocode}
% \end{macro}
@@ -5274,13 +5363,13 @@ This package consists of the file ctex.dtx, and the derived files
\int_eval:n { \tl_if_blank:nTF {#3} { "80 } {#3} } ,
\int_eval:n { \tl_if_blank:nTF {#4} { "10FFFF } {#4} } ,
}
- '\luatexluaescapestring { \CJK@encoding/#2 }' ,
- '\luatexluaescapestring { \CJK@encoding/#1 }'
+ '\lua_escape_x:n { \CJK@encoding/#2 }' ,
+ '\lua_escape_x:n { \CJK@encoding/#1 }'
}
}
\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:n #1
{
- \ctex_lua_now_x:n { luatexja.jfont.set_alt_font_latex ( #1 ) }
+ \lua_now_x:n { luatexja.jfont.set_alt_font_latex ( #1 ) }
\@@_save_alternate_shape:cnn
{ \@@_alternate_cs:n { reset / \l_@@_base_CJKfamily_tl } }
{ luatexja.jfont.set_alt_font_latex } {#1}
@@ -5298,8 +5387,8 @@ This package consists of the file ctex.dtx, and the derived files
\ctex_ltj_set_alternate_shape:n
{
##1 ,
- '\luatexluaescapestring { \CJK@encoding/#2 }' ,
- '\luatexluaescapestring { \CJK@encoding/#1 }'
+ '\lua_escape_x:n { \CJK@encoding/#2 }' ,
+ '\lua_escape_x:n { \CJK@encoding/#1 }'
}
}
}
@@ -5316,9 +5405,9 @@ This package consists of the file ctex.dtx, and the derived files
\group_begin:
\cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: }
\cs_set_eq:NN \l_@@_base_family_tl \scan_stop:
- \cs_set_eq:NN \luatexluaescapestring \scan_stop:
+ \cs_set_eq:NN \lua_escape_x:n \scan_stop:
\cs_gset_protected_nopar:Npx #1
- { \exp_not:o {#1} \exp_not:N \ctex_lua_now_x:n { #2 ( #3 ) } }
+ { \exp_not:o {#1} \exp_not:N \lua_now_x:n { #2 ( #3 ) } }
\group_end:
}
\cs_generate_variant:Nn \@@_save_alternate_shape:Nnn { c }
@@ -5375,7 +5464,7 @@ This package consists of the file ctex.dtx, and the derived files
\keys_define:nn { ctex }
{
declarecharrange .code:n = \ctex_ltj_declare_char_range:x {#1} ,
- declarecharrange .value_required:
+ declarecharrange .value_required:n = true
}
\cs_new_protected_nopar:Npn \ctex_ltj_declare_char_range:n #1
{ \clist_map_inline:nn {#1} { \@@_declare_char_range:nn ##1 } }
@@ -5533,6 +5622,17 @@ This package consists of the file ctex.dtx, and the derived files
% \end{macrocode}
%
% \begin{macrocode}
+%<@@=>
+% \end{macrocode}
+%
+% \begin{macro}[int]{\@@italiccorr}
+% \LaTeX{} 的倾斜校正也要重新定义。
+% \begin{macrocode}
+\cs_set_eq:NN \@@italiccorr \/
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
%<@@=ctex>
% \end{macrocode}
%
@@ -5604,7 +5704,7 @@ This package consists of the file ctex.dtx, and the derived files
{
\tl_gset:Nx \g_@@_fontset_tl
{
- \ctex_lua_now_x:n
+ \lua_now_x:n
{
if ~ os.name == 'windows' then ~
tex.sprint ( 'windows' )
@@ -5629,7 +5729,7 @@ This package consists of the file ctex.dtx, and the derived files
{
\file_if_exist:nTF { nul: }
{
- \file_if_exist:nTF { \c_@@_engine_file_tl }
+ \file_if_exist:nTF { \c_@@_upper_case_file_str }
{ \ctex_if_macosx:TF { mac } { windows } }
{ \ctex_if_macosx:TF { mac } { fandol } }
}
@@ -5637,11 +5737,8 @@ This package consists of the file ctex.dtx, and the derived files
}
{ \tl_gset:Nn \g_@@_fontset_tl { windows } }
}
-\tex_uppercase:D \exp_after:wN
- {
- \exp_after:wN \tl_const:Nn \exp_after:wN \c_@@_engine_file_tl
- \exp_after:wN { \g_file_current_name_tl }
- }
+\str_const:Nx \c_@@_upper_case_file_str
+ { \exp_args:No \str_upper_case:n { \g_file_current_name_tl } }
% \end{macrocode}
% \end{macro}
%
@@ -5651,11 +5748,11 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
\cs_new_protected_nopar:Npn \ctex_if_macosx:TF #1#2
{
- \file_if_exist:nTF { \c_@@_macosx_file_tl }
+ \file_if_exist:nTF { \c_@@_macosx_file_str }
{ \tl_gset:Nn \g_@@_fontset_tl {#1} }
{ \tl_gset:Nn \g_@@_fontset_tl {#2} }
}
-\tl_const:Nn \c_@@_macosx_file_tl { /Library/Fonts/Songti.ttc }
+\str_const:Nn \c_@@_macosx_file_str { /Library/Fonts/Songti.ttc }
%</xetex|pdftex>
% \end{macrocode}
% \end{macro}
@@ -5698,7 +5795,7 @@ This package consists of the file ctex.dtx, and the derived files
\str_if_eq:onTF { \l_@@_encoding_tl } { GBK }
{
\ctex_hypersetup:n { CJKbookmarks = true }
- \ctex_if_pdfmode:TF
+ \sys_if_output_pdf:TF
{ \ctex_at_end_package:nn { hyperref } { \RequirePackage { xCJK2uni } } }
{
\ctex_at_end_package:nn { hyperref }
@@ -5791,7 +5888,6 @@ This package consists of the file ctex.dtx, and the derived files
\RequirePackage { xeCJKfntef }
\@ifpackagelater { xeCJKfntef } { 2014/11/04 }
{
-
\cs_new_protected_nopar:Npn \@@_clear_fntef_color:n #1
{ \xeCJKsetup { #1 / format = { } } }
}
@@ -6021,6 +6117,13 @@ This package consists of the file ctex.dtx, and the derived files
% \end{macrocode}
% \end{macro}
%
+% \XeLaTeX{} 和 \LuaLaTeX{} 总是使用 \texttt{UTF8} 编码。
+% \begin{macrocode}
+%<*xetex|luatex>
+\tl_set:Nn \l_@@_encoding_tl { UTF8 }
+%</xetex|luatex>
+% \end{macrocode}
+%
% \begin{macrocode}
%</pdftex|xetex|luatex>
%<*class|ctex>
@@ -6030,17 +6133,7 @@ This package consists of the file ctex.dtx, and the derived files
%
% 最后载入各个编译引擎的定义文件。
% \begin{macrocode}
-\pdftex_if_engine:TF
- {
- \tl_set:Nx \l_@@_encoding_tl { \l_@@_encoding_tl }
- \ctex_file_input:n { ctex-engine-pdftex.def }
- }
- {
- \tl_set:Nn \l_@@_encoding_tl { UTF8 }
- \xetex_if_engine:TF
- { \ctex_file_input:n { ctex-engine-xetex.def } }
- { \ctex_file_input:n { ctex-engine-luatex.def } }
- }
+\ctex_file_input:n { \c_@@_engine_file_str }
% \end{macrocode}
%
% \subsection{字距与缩进}
@@ -6115,7 +6208,7 @@ This package consists of the file ctex.dtx, and the derived files
\ctex_set_default_ccwd:Nn \l_@@_line_stretch_tl {#1}
\ctex_select_size:
} ,
- linestretch .value_required:
+ linestretch .value_required:n = true
}
\tl_new:N \l_@@_line_stretch_tl
\tl_set:Nn \l_@@_line_stretch_tl { \ccwd }
@@ -6384,7 +6477,6 @@ This package consists of the file ctex.dtx, and the derived files
% \end{macrocode}
%
% \subsubsection{定义标题格式选项}
-
%
% \begin{variable}[int]{\c_@@_section_headings_seq}
% 保存 \tn{section} 级以下标题名字。
@@ -6405,6 +6497,7 @@ This package consists of the file ctex.dtx, and the derived files
% \end{variable}
%
% \changes{v2.1}{2015/06/19}{\opt{nameformat} 可以接受章节名字为参数。}
+% \changes{v2.3}{2016/01/05}{修复 \opt{nameformat} 作用域问题。}
%
% \begin{macro}[int]{\@@_initial_heading:n}
% \begin{macrocode}
@@ -6420,20 +6513,22 @@ This package consists of the file ctex.dtx, and the derived files
}
\tl_const:cx { CTEX@#1name }
{
- \exp_not:c { CTEX@#1@nameformat }
- {
- \exp_not:c { CTEX@pre#1 }
- \exp_not:N \tl_if_empty:NTF \exp_not:c { CTEX@#1@numberformat }
- { \exp_not:c { CTEX@the#1 } }
- {
- \group_begin:
- \exp_not:c { CTEX@#1@numberformat }
- \exp_not:c { CTEX@the#1 }
- \group_end:
- }
- \exp_not:c { CTEX@post#1 }
- }
- \exp_not:c { CTEX@#1@aftername }
+ \group_begin:
+ \exp_not:c { CTEX@#1@nameformat }
+ {
+ \exp_not:c { CTEX@pre#1 }
+ \exp_not:N \tl_if_empty:NTF
+ \exp_not:c { CTEX@#1@numberformat }
+ { \exp_not:c { CTEX@the#1 } }
+ {
+ \group_begin:
+ \exp_not:c { CTEX@#1@numberformat }
+ \exp_not:c { CTEX@the#1 }
+ \group_end:
+ }
+ \exp_not:c { CTEX@post#1 }
+ }
+ \group_end:
}
}
% \end{macrocode}
@@ -6472,35 +6567,23 @@ This package consists of the file ctex.dtx, and the derived files
#1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } ,
#1 / format+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } ,
- #1 / format~+ .code:n =
- { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } ,
#1 / nameformat+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } ,
- #1 / nameformat~+ .code:n =
- { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } ,
#1 / numberformat+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } ,
- #1 / numberformat~+ .code:n =
- { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } ,
#1 / aftername+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } ,
- #1 / aftername~+ .code:n =
- { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } ,
#1 / titleformat+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } ,
- #1 / titleformat~+ .code:n =
- { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } ,
#1 / aftertitle+ .code:n =
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } ,
- #1 / aftertitle~+ .code:n =
- { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } ,
#1 / numbering .initial:n = true ,
#1 / beforeskip .initial:n = \c_zero_skip ,
#1 / afterskip .initial:n = \c_zero_skip ,
#1 / indent .initial:n = \c_zero_dim ,
- #1 / beforeskip .value_required: ,
- #1 / afterskip .value_required: ,
- #1 / indent .value_required: ,
+ #1 / beforeskip .value_required:n = true ,
+ #1 / afterskip .value_required:n = true ,
+ #1 / indent .value_required:n = true ,
}
}
% \end{macrocode}
@@ -6634,7 +6717,7 @@ This package consists of the file ctex.dtx, and the derived files
\normalfont \parindent \dimexpr \CTEX@part@indent \relax \CTEX@part@format
\ifnum \c@secnumdepth >\m@ne \ifodd \CTEX@part@numbering
% \Large\bfseries\partname\nobreakspace\thepart\par\nobreak
- \CTEX@partname
+ \CTEX@partname \CTEX@part@aftername
\fi \fi
% \huge\bfseries #2%
\CTEX@part@titleformat{#2}%
@@ -6665,7 +6748,7 @@ This package consists of the file ctex.dtx, and the derived files
\normalfont \CTEX@part@format
\ifnum \c@secnumdepth >-2\relax \ifodd \CTEX@part@numbering
% \huge\bfseries\partname\nobreakspace\thepart\par\vskip 20\p@
- \CTEX@partname
+ \CTEX@partname \CTEX@part@aftername
\fi \fi
% \Huge\bfseries #2\par}%
\CTEX@part@titleformat{#2}%
@@ -6793,7 +6876,7 @@ This package consists of the file ctex.dtx, and the derived files
%<book> \if@mainmatter
\ifodd \CTEX@chapter@numbering
% \huge\bfseries\@chapapp\space\thechapter\par\nobreak\vskip 20\p@
- \CTEX@chaptername
+ \CTEX@chaptername \CTEX@chapter@aftername
\fi
%<book> \fi
\fi
@@ -6864,9 +6947,8 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macro}[int]{\@seccntformat}
% \begin{macrocode}
\def\@seccntformat#1{%
- \@ifundefined{CTEX@#1name}%
- {\csname the#1\endcsname\quad}%
- {\csname CTEX@#1name\endcsname}}
+% \csname the#1\endcsname\quad}%
+ \csname CTEX@#1name\endcsname \csname CTEX@#1@aftername\endcsname}
% \end{macrocode}
% \end{macro}
%
@@ -6900,9 +6982,7 @@ This package consists of the file ctex.dtx, and the derived files
\ifnum #2>\c@secnumdepth \else
\ifodd \csname CTEX@#1@numbering\endcsname
% \protect\numberline{\csname the#1\endcsname}%
- \protect\numberline{\@ifundefined{CTEXthe#1}%
- {\csname the#1\endcsname}%
- {\csname CTEXthe#1\endcsname}}%
+ \protect\numberline{\csname CTEXthe#1\endcsname}%
\fi
\fi
#7}%
@@ -6918,9 +6998,7 @@ This package consists of the file ctex.dtx, and the derived files
\ifnum #2>\c@secnumdepth \else
\ifodd \csname CTEX@#1@numbering\endcsname
% \protect\numberline{\csname the#1\endcsname}%
- \protect\numberline{\@ifundefined{CTEXthe#1}%
- {\csname the#1\endcsname}%
- {\csname CTEXthe#1\endcsname}}%
+ \protect\numberline{\csname CTEXthe#1\endcsname}%
\fi
\fi
#7}}%
@@ -7073,14 +7151,14 @@ This package consists of the file ctex.dtx, and the derived files
%
% \begin{macro}[int]{\ctex_titlesec_hook:}
% \tn{titleformat} 的设置保存在名为 |\ttlf@|\meta{section} 的宏中备用,它的内容是
-% \begin{center}\small
+% \begin{quote}\small
% |\ttlh@|\meta{shape}\Arg{format}\Arg{label}\Arg{sep}\Arg{before}\Arg{after}
-% \end{center}
+% \end{quote}
% 我们这里的 \meta{shape} 为 |hang| 或者 |runin|。\tn{titlespacing} 的设置保存在
% |\ttls@|\meta{section} 之中,它的内容是
-% \begin{center}\small
+% \begin{quote}\small
% \Arg{left}\Arg{right}\Arg{before}\Arg{after}\Arg{afterindent}
-% \end{center}
+% \end{quote}
% 其中 \meta{afterindent} 为 |1| 或 |0|,分别对应是否保留段首缩进。
% 我们需要根据 \CTeX{} 的 \opt{runin} 和 \opt{afterindent} 选项调整
% |\ttlh@|\meta{shape} 和 \meta{afterindent}。注意,由 \tn{ttl@extract} 得的
@@ -7162,6 +7240,75 @@ This package consists of the file ctex.dtx, and the derived files
}
% \end{macrocode}
%
+% \paragraph{兼容 \pkg{titleps} 宏包}
+%
+% \changes{v2.3}{2015/12/25}{兼容 \pkg{titleps} 宏包。}
+%
+% 按照 \pkg{titleps} 宏包的实现机制,|\CTEXtheXXX| 等宏直到页眉排版时才会被展开,
+% 这可能会造成问题\footnote{\url{https://github.com/CTeX-org/ctex-kit/issues/217}}。
+%
+% \begin{macro}[int]{\ctex_titleps_hook:}
+% 我们修改 \pkg{titleps} 包的内部命令 \tn{ttl@settopmark} 和 \tn{ttl@setsubmark},
+% 将 |\CTEXtheXXX| 等加入更新队列中。
+% \begin{macrocode}
+\group_begin:
+\char_set_catcode_other:N \#
+\cs_new_protected_nopar:Npn \ctex_titleps_hook:
+ {
+ \ctex_patch_cmd:Nnn \ttl@settopmark
+ { \protect \@namedef { the#1 } { \@nameuse { the#1 } } }
+ {
+ \protect \@namedef { the#1 } { \@nameuse { the#1 } }
+ \CTEX@titlepslabel@set {#1}
+ }
+ \ctex_patch_cmd:Nnn \ttl@setsubmark
+ { \protect \@namedef { the#1 } { } }
+ {
+ \protect \@namedef { the#1 } { }
+ \CTEX@titlepslabel@clear {#1}
+ }
+ \ctex_patch_cmd:Nnn \ttl@setsubmark
+ { \protect \@namedef { the#2 } { \@nameuse { the#2 } } }
+ {
+ \protect \@namedef { the#2 } { \@nameuse { the#2 } }
+ \CTEX@titlepslabel@set {#2}
+ }
+ }
+\group_end:
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[aux]{\CTEX@titlepslabel@set,\CTEX@titlepslabel@clear}
+% 这两个函数要在随后被 \tn{xdef} 展开来获得 |\CTEXtheXXX| 的内容,不应该用
+% \tn{protected} 来定义。
+% \begin{macrocode}
+\cs_new_nopar:Npn \CTEX@titlepslabel@set #1
+ {
+ \cs_if_free:cF { CTEXthe#1 }
+ { \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } }
+ }
+\cs_new_nopar:Npn \CTEX@titlepslabel@clear #1
+ {
+ \cs_if_free:cF { CTEXthe#1 }
+ { \protect \@namedef { CTEXthe#1 } { } }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \pkg{titleps} 宏包的功能可以由 \pkg{titlesec} 的选项 \opt{pagestyles} 引入。
+% \begin{macrocode}
+\ctex_at_end_package:nn { titlesec }
+ { \cs_if_free:NF \ttl@settopmark { \ctex_titleps_hook: } }
+\ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: }
+% \end{macrocode}
+%
+% 除此之外,也可以使用 \pkg{titleps} 提供的命令 \tn{newtitlemark} 来完成:
+% \begin{verbatim}
+% \newtitlemark { \CTEXthechapter }
+% \newtitlemark { \CTEXthesection }
+% \end{verbatim}
+% 但 \tn{newtitlemark} 不包含章节间的层次信息,功能上不及修改内部命令完整。
+%
%
% \subsubsection{目录标签的宽度}
%
@@ -8289,7 +8436,7 @@ This package consists of the file ctex.dtx, and the derived files
% Windows 字体设置使用微软雅黑作为无衬线体,楷体和仿宋是大字库。
% \begin{macrocode}
%<*windowsnew|windowsold>
-\pdftex_if_engine:TF
+\sys_if_engine_pdftex:TF
{
\ctex_zhmap_case:nnn
{
@@ -8383,9 +8530,9 @@ This package consists of the file ctex.dtx, and the derived files
% \tn{pdfmapline} 不支持 OpenType 字体,因而 \opt{adobe} 字体集在 pdf 模式下
% 就没有定义。\opt{fandol} 的情况类似。
% \begin{macrocode}
-\pdftex_if_engine:TF
+\sys_if_engine_pdftex:TF
{
- \ctex_if_pdfmode:TF
+ \sys_if_output_pdf:TF
{ \ctex_fontset_error:n { adobe } }
{
\ctex_zhmap_case:nnn
@@ -8446,9 +8593,9 @@ This package consists of the file ctex.dtx, and the derived files
% \subsubsection{\pkg{ctex-fontset-fandol.def}}
%
% \begin{macrocode}
-\pdftex_if_engine:TF
+\sys_if_engine_pdftex:TF
{
- \ctex_if_pdfmode:TF
+ \sys_if_output_pdf:TF
{ \ctex_fontset_error:n { fandol } }
{
\ctex_zhmap_case:nnn
@@ -8584,7 +8731,7 @@ This package consists of the file ctex.dtx, and the derived files
% \footnote{\url{http://www.newsmth.net/bbscon.php?bid=460&id=312640}}。
% 华文细黑和华文仿宋的情况类似。
% \begin{macrocode}
-\pdftex_if_engine:TF
+\sys_if_engine_pdftex:TF
{ \ctex_fontset_error:n { mac } }
{
\setCJKmainfont [ BoldFont = STHeiti , ItalicFont = STKaiti ] { STSong }
@@ -8605,7 +8752,7 @@ This package consists of the file ctex.dtx, and the derived files
% \subsubsection{\pkg{ctex-fontset-founder.def}}
%
% \begin{macrocode}
-\pdftex_if_engine:TF
+\sys_if_engine_pdftex:TF
{
\ctex_zhmap_case:nnn
{
@@ -8651,7 +8798,7 @@ This package consists of the file ctex.dtx, and the derived files
% 速度不受影响。
% \begin{macrocode}
\setCJKsansfont [ BoldFont = FZHei-B01 ]
- { \xetex_if_engine:TF { 方正细黑一_GBK } { FZXH1K--GBK1-0 } }
+ { \sys_if_engine_xetex:TF { 方正细黑一_GBK } { FZXH1K--GBK1-0 } }
\setCJKmonofont { FZFangSong-Z02 }
\setCJKfamilyfont { zhsong } [ BoldFont = FZXiaoBiaoSong-B05 ] { FZShuSong-Z01 }
\setCJKfamilyfont { zhhei } { FZHei-B01 }
@@ -8678,7 +8825,7 @@ This package consists of the file ctex.dtx, and the derived files
% 其实只有“令”和“骨”这区区两个字有新字形,其余都取旧字形^^A
% \footnote{\url{http://www.freedesktop.org/wiki/Software/CJKUnifonts/Download/}}。
% \begin{macrocode}
-\pdftex_if_engine:TF
+\sys_if_engine_pdftex:TF
{
\ctex_zhmap_case:nnn
{
@@ -8811,7 +8958,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
%<*windows>
\ProvidesFile{zhwindowsfonts.tex}%
- [2015/07/01 v2.2 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)]
+ [2016/02/02 v2.3 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)]
\ifzhmappdf
\pdfmapline{=gbk@UGBK@ <simsun.ttc}
@@ -8883,7 +9030,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
%<*adobe>
\ProvidesFile{zhadobefonts.tex}%
- [2015/07/01 v2.2 Adobe font map loader for DVIPDFMx (CTEX)]
+ [2016/02/02 v2.3 Adobe font map loader for DVIPDFMx (CTEX)]
\ifzhmappdf
%% pdfTeX does not support OTF fonts
@@ -8919,7 +9066,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
%<*fandol>
\ProvidesFile{zhfandolfonts.tex}%
- [2015/07/01 v2.2 Fandol font map loader for DVIPDFMx (CTEX)]
+ [2016/02/02 v2.3 Fandol font map loader for DVIPDFMx (CTEX)]
\ifzhmappdf
%% pdfTeX does not support OTF fonts
@@ -8955,7 +9102,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
%<*founder>
\ProvidesFile{zhfounderfonts.tex}%
- [2015/07/01 v2.2 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)]
+ [2016/02/02 v2.3 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)]
\ifzhmappdf
\pdfmapline{=gbk@UGBK@ <FZSSK.TTF}
@@ -9027,7 +9174,7 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
%<*ubuntu>
\ProvidesFile{zhubuntufonts.tex}%
- [2015/07/01 v2.2 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)]
+ [2016/02/02 v2.3 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)]
\ifzhmappdf
\pdfmapline{=gbk@UGBK@ <uming.ttc}
@@ -9099,7 +9246,7 @@ This package consists of the file ctex.dtx, and the derived files
%<*macro>
\input expl3-generic %
\ExplSyntaxOn
-\xetex_if_engine:F
+\sys_if_engine_xetex:F
{
\msg_new:nn { ctex } { xetex }
{ XeTeX~is~required~to~compile~this~document! }
@@ -9148,7 +9295,7 @@ This package consists of the file ctex.dtx, and the derived files
\l_@@_punct_font
\clist_clear:N \l_@@_punct_bounds_clist
\seq_map_inline:Nn \c_@@_punct_seq
- { \exp_args:No \@@_save_bounds:n { \int_use:N \XeTeXcharglyph ##1 } }
+ { \exp_args:No \@@_save_bounds:n { \int_use:N \xetex_charglyph:D ##1 } }
\iow_now:Nx \g_@@_spa_iow
{
\token_to_str:N \ctexspadef {#1}
@@ -9179,7 +9326,7 @@ This package consists of the file ctex.dtx, and the derived files
round
(
\dim_to_decimal_in_unit:nn
- { 100 \XeTeXglyphbounds #1 ~ #2 }
+ { 100 \xetex_glyphbounds:D #1 ~ #2 }
{ 1 em }
)
}
@@ -9354,6 +9501,10 @@ This package consists of the file ctex.dtx, and the derived files
%<*ctexpatch>
% \end{macrocode}
%
+% \begin{macrocode}
+\cs_if_exist:NF \str_new:N { \RequirePackage { l3str } }
+% \end{macrocode}
+%
% \begin{macro}[int]{\ctex_patch_cmd_once:NnnnTF}
% 只进行第一次匹配进行替换。参数 |#2| 是宏重建时的 \tn{catcode} 设置。
% \begin{macrocode}
@@ -9459,66 +9610,77 @@ This package consists of the file ctex.dtx, and the derived files
\cs_new_protected:Npn \ctex_parse_name:NN #1#2
{ \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } }
\group_begin:
-\char_set_lccode:nn { `\< } { `\{ }
-\char_set_lccode:nn { `\/ } { `\\ }
-\char_set_lccode:nn { `\A } { `\t }
-\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N
-\tex_lowercase:D
+\cs_set_protected:Npn \@@_tmp:w #1#2#3
{
- \group_end:
- \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3
+ \cs_new_protected:Npn \ctex_parse_name:NNn ##1##2##3
{
- \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } }
+ \bool_if:nTF
+ {
+ \cs_if_exist_p:c { ##3 ~ } ||
+ \cs_if_exist_p:c { #1##3 }
+ }
{
\group_begin:
\use:x
{
\group_end:
- \@@_parse_name:nNNNnN { \token_get_replacement_spec:N #2 }
- \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 }
- } {#3} #1
+ \@@_parse_name:nNNNnN
+ { \token_get_replacement_spec:N ##2 }
+ \exp_not:N ##2
+ \exp_not:c { ##3 ~ }
+ \exp_not:c { #1##3 }
+ } {##3} ##1
}
- { #1#2 }
+ { ##1##2 }
}
- \cs_new_protected:Npn \@@_parse_name:nNNNnN #1#2#3#4#5#6
+ \cs_new_protected:Npn \@@_parse_name:nNNNnN ##1##2##3##4##5##6
{
- \exp_args:Nc #6
+ \exp_args:Nc ##6
{
- \str_case:nnTF {#1}
+ \str_case:nnTF {##1}
{
- { \protect #3 } { }
- { \x@protect #2 \protect #3 } { }
+ { \protect ##3 } { }
+ { \x@protect ##2 \protect ##3 } { }
}
{
- \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } }
+ \str_if_eq_x:nnTF
+ { \exp_not:n { #1@protected@ ##3 #1##3 } }
{
\exp_last_unbraced:Nf \@@_parse_name:w
- \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop
+ \token_get_replacement_spec:N ##3 #2 ~ #1 \q_stop
}
- { /#5 ~ } { #5 ~ }
+ { #1##5 ~ } { ##5 ~ }
}
{
- \str_case:onTF { \@@_parse_name:w #1 AESAOPA ~ < \q_stop }
+ \str_case:onTF { \@@_parse_name:w ##1 #2 ~ #1 \q_stop }
{
- { /@protected@ #2 #4 } { }
- { /@ #4 } { }
+ { #1@protected@ ##2 ##4 } { }
+ { #1@ ##4 } { }
}
- { /#5 } {#5}
+ { #1##5 } {##5}
}
}
}
- \cs_new:Npn \@@_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 }
+ \cs_new:Npn \@@_parse_name:w ##1 #2 ~ ##2 #1 ##3 \q_stop { ##1##2 }
}
+\use:x
+ {
+ \@@_tmp:w
+ { \c_backslash_str }
+ { \c_left_brace_str }
+ { \tl_to_str:n { testopt } }
+ }
+\group_end:
\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx }
% \end{macrocode}
% \end{macro}
%
-% \begin{variable}[int]{\l_@@_prefix_tl,\l_@@_parameter_tl,\l_@@_replacement_tl}
+% \begin{variable}[int]{\l_@@_prefix_str,\l_@@_parameter_str,\l_@@_replacement_str}
% 分别保存宏的 \tn{meaning} 中的前缀、参数文本和替换文本。
% \begin{macrocode}
-\tl_new:N \l_@@_prefix_tl
-\tl_new:N \l_@@_parameter_tl
-\tl_new:N \l_@@_replacement_tl
+\str_new:N \l_@@_prefix_str
+\str_new:N \l_@@_parameter_str
+\str_new:N \l_@@_replacement_str
% \end{macrocode}
% \end{variable}
%
@@ -9527,28 +9689,30 @@ This package consists of the file ctex.dtx, and the derived files
% 解构待补丁宏的 \tn{meaning}。若命令不是宏,则走向 |false| 分支。
% \begin{macrocode}
\group_begin:
- \char_set_lccode:nn { `\; } { `\: }
- \tl_map_function:nN { \M \A \C \R \O \; } \char_set_catcode_other:N
-\tex_lowercase:D
- {
- \group_end:
- \cs_new_protected:Npn \ctex_get_macro_meaning:NTF #1
- {
- \exp_after:wN \@@_get_macro_meaning:w
- \token_to_meaning:N #1 \q_stop MACRO ; -> \q_no_value \q_stop
- }
- \cs_new_protected:Npn \@@_get_macro_meaning:w #1 MACRO ; #2 -> #3 \q_stop
- {
- \tl_set:Nn \l_@@_replacement_tl {#3}
- \quark_if_no_value:NTF \l_@@_replacement_tl
- { \use_ii:nn }
- {
- \tl_set:Nn \l_@@_prefix_tl {#1}
- \tl_set:Nn \l_@@_parameter_tl {#2}
- \use_i_delimit_by_q_stop:nw { \use_i:nn }
- }
- }
- }
+ \cs_set_protected:Npn \@@_tmp:w #1
+ {
+ \prg_new_protected_conditional:Npnn
+ \ctex_get_macro_meaning:N ##1 { TF }
+ {
+ \exp_after:wN \@@_get_macro_meaning:w
+ \token_to_meaning:N ##1 \q_mark #1 -> \q_no_value \q_mark \q_stop
+ }
+ \cs_new_protected:Npn \@@_get_macro_meaning:w
+ ##1 #1 ##2 -> ##3 \q_mark ##4 \q_stop
+ {
+ \tl_set:Nn \l_@@_replacement_tl {##3}
+ \quark_if_no_value:NTF \l_@@_replacement_tl
+ { \prg_return_false: }
+ {
+ \str_set:Nn \l_@@_prefix_str {##1}
+ \str_set:Nn \l_@@_parameter_str {##2}
+ \str_set:Nn \l_@@_replacement_str {##3}
+ \prg_return_true:
+ }
+ }
+ }
+ \exp_args:No \@@_tmp:w { \tl_to_str:n { macro: } }
+\group_end:
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -9560,12 +9724,12 @@ This package consists of the file ctex.dtx, and the derived files
{
\ctex_get_macro_meaning:NTF #1
{
- \@@_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#2}
- \cs_if_eq:NNTF #1 \CTEXPATCHRESCANCMD {#3} {#4}
+ \@@_patch_rebuild:Nn \@@_rebuild_cmd:w {#2}
+ \cs_if_eq:NNTF #1 \@@_rebuild_cmd:w {#3} {#4}
}
{#4}
}
-\cs_new_eq:NN \CTEXPATCHRESCANCMD \prg_do_nothing:
+\cs_new_eq:NN \@@_rebuild_cmd:w \prg_do_nothing:
% \end{macrocode}
% \end{macro}
%
@@ -9574,22 +9738,25 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_rebuild:Nn #1#2
{
- \tl_if_empty:nTF {#2}
- { \tl_rescan:nx {#2} }
- {
- \tl_rescan:nx
- {
- #2 \scan_stop:
- \int_set_eq:NN \tex_endlinechar:D \c_minus_one
- \int_set_eq:NN \tex_newlinechar:D \c_minus_one
- }
- }
+ \@@_patch_rescan:NNn \l_@@_prefix_tl \l_@@_prefix_str {#2}
+ \@@_patch_rescan:NNn \l_@@_parameter_tl \l_@@_parameter_str {#2}
+ \@@_patch_rescan:NNn \l_@@_replacement_tl \l_@@_replacement_str {#2}
+ \use:x
{
- \l_@@_prefix_tl \exp_not:N \def \exp_not:N #1 \l_@@_parameter_tl
- { \l_@@_replacement_tl }
+ \exp_not:o { \l_@@_prefix_tl } \tex_def:D \exp_not:N #1
+ \exp_not:o { \l_@@_parameter_tl }
+ { \exp_not:o { \l_@@_replacement_tl } }
}
}
-\cs_generate_variant:Nn \tl_rescan:nn { nx }
+\cs_new_protected:Npn \@@_patch_rescan:NNn #1#2#3
+ {
+ \str_if_empty:NTF #2
+ { \tl_clear:N #1 }
+ { \tl_set_rescan:Nnx #1 {#3} {#2} }
+ }
+\tl_new:N \l_@@_prefix_tl
+\tl_new:N \l_@@_parameter_tl
+\tl_new:N \l_@@_replacement_tl
% \end{macrocode}
% \end{macro}
%
@@ -9608,8 +9775,7 @@ This package consists of the file ctex.dtx, and the derived files
{ \tl_to_str:n {#5} }
}
{
- \@@_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3}
- \cs_set_eq:NN #1 \CTEXPATCHRESCANCMD
+ \@@_patch_rebuild:Nn #1 {#3}
\@@_patch_true:w
}
{ \@@_patch_false:w }
@@ -9624,8 +9790,8 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_replace:nnnTF #1#2#3#4
{
- \tl_if_in:NnTF \l_@@_replacement_tl {#2}
- { \use:c { tl_replace_ #1 :Nnn } \l_@@_replacement_tl {#2} {#3} #4 }
+ \tl_if_in:NnTF \l_@@_replacement_str {#2}
+ { \use:c { tl_replace_ #1 :Nnn } \l_@@_replacement_str {#2} {#3} #4 }
}
% \end{macrocode}
% \end{macro}
@@ -9638,7 +9804,7 @@ This package consists of the file ctex.dtx, and the derived files
\group_end:
\ctex_get_macro_meaning:NTF #1
{
- \tl_if_empty:NTF \l_@@_parameter_tl
+ \str_if_empty:NTF \l_@@_parameter_str
{ \@@_hookto_cmd_parameterless:Nnnw #1 {#2} {#4} }
{ \@@_hookto_cmd_parameter:Nnnnw #1 {#2} {#3} {#4} }
}
@@ -9652,9 +9818,9 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
\cs_new_protected:Npn \@@_hookto_cmd_parameterless:Nnnw #1#2#3
{
- \tl_if_empty:NF \l_@@_prefix_tl
- { \tl_rescan:nx { } { \l_@@_prefix_tl } }
- \edef #1
+ \str_if_empty:NF \l_@@_prefix_str
+ { \tl_rescan:nx { } { \l_@@_prefix_str } }
+ \tex_edef:D #1
{
\use:c { @@_ #2 _hook_aux:nn }
{ \exp_not:o {#1} }
@@ -9662,6 +9828,7 @@ This package consists of the file ctex.dtx, and the derived files
}
\@@_patch_true:w
}
+\cs_generate_variant:Nn \tl_rescan:nn { nx }
\cs_new:Npn \@@_left_hook_aux:nn #1#2 { #2#1 }
\cs_new_eq:NN \@@_right_hook_aux:nn \use:nn
% \end{macrocode}
@@ -9672,12 +9839,11 @@ This package consists of the file ctex.dtx, and the derived files
% \begin{macrocode}
\cs_new_protected:Npn \@@_hookto_cmd_parameter:Nnnnw #1#2#3#4
{
- \@@_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3}
- \cs_if_eq:NNTF #1 \CTEXPATCHRESCANCMD
+ \@@_patch_rebuild:Nn \@@_rebuild_cmd:w {#3}
+ \cs_if_eq:NNTF #1 \@@_rebuild_cmd:w
{
- \use:c { tl_put_ #2 :Nx } \l_@@_replacement_tl { \tl_to_str:n {#4} }
- \@@_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3}
- \cs_set_eq:NN #1 \CTEXPATCHRESCANCMD
+ \use:c { str_put_ #2 :Nn } \l_@@_replacement_str {#4}
+ \@@_patch_rebuild:Nn #1 {#3}
\@@_patch_true:w
}
{ \@@_patch_false:w }