| 1 |
% \iffalse meta-comment |
| 2 |
% !TeX program = XeLaTeX |
| 3 |
% !TeX encoding = UTF-8 |
| 4 |
% |
| 5 |
% Copyright (C) 2003--2022 |
| 6 |
% CTEX.ORG and any individual authors listed elsewhere in this file. |
| 7 |
% -------------------------------------------------------------------------- |
| 8 |
% |
| 9 |
% This work may be distributed and/or modified under the |
| 10 |
% conditions of the LaTeX Project Public License, either |
| 11 |
% version 1.3c of this license or (at your option) any later |
| 12 |
% version. This version of this license is in |
| 13 |
% http://www.latex-project.org/lppl/lppl-1-3c.txt |
| 14 |
% and the latest version of this license is in |
| 15 |
% http://www.latex-project.org/lppl.txt |
| 16 |
% and version 1.3 or later is part of all distributions of |
| 17 |
% LaTeX version 2005/12/01 or later. |
| 18 |
% |
| 19 |
% This work has the LPPL maintenance status "maintained". |
| 20 |
% |
| 21 |
% -------------------------------------------------------------------------- |
| 22 |
% |
| 23 |
%<*internal> |
| 24 |
\iffalse |
| 25 |
%</internal> |
| 26 |
%<*readme> |
| 27 |
ctex |
| 28 |
==== |
| 29 |
|
| 30 |
`ctex` is a collection of macro packages and document classes |
| 31 |
for LaTeX Chinese typesetting. |
| 32 |
|
| 33 |
Authors and Contributors |
| 34 |
------------------------ |
| 35 |
|
| 36 |
* Wu Lingyun <[email protected]> |
| 37 |
* Jiang Jiang <[email protected]> |
| 38 |
* Wang Yue <[email protected]> |
| 39 |
* Liu Haiyang <[email protected]> |
| 40 |
* Li Yanrui <[email protected]> |
| 41 |
* Chen Zhichu <[email protected]> |
| 42 |
* Li Qing <[email protected]> |
| 43 |
* Liam Huang <[email protected]> |
| 44 |
* Zeng Xiangdong <[email protected]> |
| 45 |
* Li Zeping <[email protected]> |
| 46 |
* Zhou Yukai <[email protected]> |
| 47 |
* Zhang Ruixi <[email protected]> |
| 48 |
|
| 49 |
Contributing |
| 50 |
------------ |
| 51 |
|
| 52 |
This package is a part of the [ctex-kit](https://github.com/CTeX-org/ctex-kit) project. |
| 53 |
|
| 54 |
Issues and pull requests are welcome. |
| 55 |
|
| 56 |
Copyright and Licence |
| 57 |
--------------------- |
| 58 |
|
| 59 |
Copyright (C) 2003--2022 |
| 60 |
CTEX.ORG and any individual authors listed elsewhere in this file. |
| 61 |
---------------------------------------------------------------------- |
| 62 |
|
| 63 |
This work may be distributed and/or modified under the |
| 64 |
conditions of the LaTeX Project Public License, either |
| 65 |
version 1.3c of this license or (at your option) any later |
| 66 |
version. This version of this license is in |
| 67 |
http://www.latex-project.org/lppl/lppl-1-3c.txt |
| 68 |
and the latest version of this license is in |
| 69 |
http://www.latex-project.org/lppl.txt |
| 70 |
and version 1.3 or later is part of all distributions of |
| 71 |
LaTeX version 2005/12/01 or later. |
| 72 |
|
| 73 |
This work has the LPPL maintenance status "maintained". |
| 74 |
|
| 75 |
This package consists of the files ctex.dtx, |
| 76 |
ctxdoc.cls, |
| 77 |
ctxdocstrip.tex, |
| 78 |
ctex-zhconv.lua, |
| 79 |
ctex-zhconv-make.lua, |
| 80 |
and the derived files ctex.pdf, |
| 81 |
ctex.ins, |
| 82 |
ctex.sty, |
| 83 |
ctexsize.sty, |
| 84 |
ctexheading.sty, |
| 85 |
ctexart.cls, |
| 86 |
ctexbook.cls, |
| 87 |
ctexrep.cls, |
| 88 |
ctexbeamer.cls, |
| 89 |
ctexcap.sty, |
| 90 |
ctexhook.sty, |
| 91 |
ctexpatch.sty, |
| 92 |
ctex-c5size.clo, |
| 93 |
ctex-cs4size.clo, |
| 94 |
ctex-heading-article.def, |
| 95 |
ctex-heading-book.def, |
| 96 |
ctex-heading-report.def, |
| 97 |
ctex-heading-beamer.def, |
| 98 |
ctex-scheme-plain.def, |
| 99 |
ctex-scheme-plain-article.def, |
| 100 |
ctex-scheme-plain-book.def, |
| 101 |
ctex-scheme-plain-report.def, |
| 102 |
ctex-scheme-plain-beamer.def, |
| 103 |
ctex-scheme-chinese.def, |
| 104 |
ctex-scheme-chinese-article.def, |
| 105 |
ctex-scheme-chinese-book.def, |
| 106 |
ctex-scheme-chinese-report.def, |
| 107 |
ctex-scheme-chinese-beamer.def, |
| 108 |
ctex-name-gbk.cfg, |
| 109 |
ctex-name-utf8.cfg, |
| 110 |
ctex.cfg, |
| 111 |
ctexopts.cfg, |
| 112 |
ctexbackend.cfg, |
| 113 |
ctex-engine-pdftex.def, |
| 114 |
ctex-engine-xetex.def, |
| 115 |
ctex-engine-luatex.def, |
| 116 |
ctex-engine-aptex.def, |
| 117 |
ctex-engine-uptex.def, |
| 118 |
c19rm.fd, |
| 119 |
c19sf.fd, |
| 120 |
c19tt.fd, |
| 121 |
c70rm.fd, |
| 122 |
c70sf.fd, |
| 123 |
c70tt.fd, |
| 124 |
jy2zhrm.fd, |
| 125 |
jy2zhsf.fd, |
| 126 |
jy2zhtt.fd, |
| 127 |
jt2zhrm.fd, |
| 128 |
jt2zhsf.fd, |
| 129 |
jt2zhtt.fd, |
| 130 |
ctex-fontset-adobe.def, |
| 131 |
ctex-fontset-fandol.def, |
| 132 |
ctex-fontset-founder.def, |
| 133 |
ctex-fontset-mac.def, |
| 134 |
ctex-fontset-macnew.def, |
| 135 |
ctex-fontset-macold.def, |
| 136 |
ctex-fontset-ubuntu.def, |
| 137 |
ctex-fontset-windows.def, |
| 138 |
ctexspa.def, |
| 139 |
ctexpunct.spa, |
| 140 |
ctex-spa-make.tex, |
| 141 |
ctex-spa-macro.tex, |
| 142 |
ctex-zhmap-adobe.tex, |
| 143 |
ctex-zhmap-fandol.tex, |
| 144 |
ctex-zhmap-founder.tex, |
| 145 |
ctex-zhmap-mac.tex, |
| 146 |
ctex-zhmap-ubuntu.tex, |
| 147 |
ctex-zhmap-windows.tex, |
| 148 |
ctex-zhconv-index.lua, |
| 149 |
translator-theorem-dictionary-ChineseGBK.dict, |
| 150 |
translator-theorem-dictionary-ChineseUTF8.dict, and |
| 151 |
README.md (this file). |
| 152 |
%</readme> |
| 153 |
%<*internal> |
| 154 |
\fi |
| 155 |
\begingroup |
| 156 |
\def\temp{LaTeX2e} |
| 157 |
\expandafter\endgroup\ifx\temp\fmtname\else |
| 158 |
\csname fi\endcsname |
| 159 |
%</internal> |
| 160 |
%<*install> |
| 161 |
|
| 162 |
\input ctxdocstrip % |
| 163 |
|
| 164 |
\preamble |
| 165 |
|
| 166 |
Copyright (C) 2003--2022 |
| 167 |
CTEX.ORG and any individual authors listed in the documentation. |
| 168 |
--------------------------------------------------------------------- |
| 169 |
|
| 170 |
This work may be distributed and/or modified under the |
| 171 |
conditions of the LaTeX Project Public License, either |
| 172 |
version 1.3c of this license or (at your option) any later |
| 173 |
version. This version of this license is in |
| 174 |
http://www.latex-project.org/lppl/lppl-1-3c.txt |
| 175 |
and the latest version of this license is in |
| 176 |
http://www.latex-project.org/lppl.txt |
| 177 |
and version 1.3 or later is part of all distributions of |
| 178 |
LaTeX version 2005/12/01 or later. |
| 179 |
|
| 180 |
This work has the LPPL maintenance status "maintained". |
| 181 |
|
| 182 |
--------------------------------------------------------------------- |
| 183 |
|
| 184 |
\endpreamble |
| 185 |
\postamble |
| 186 |
|
| 187 |
This package consists of the files ctex.dtx, |
| 188 |
ctxdoc.cls, |
| 189 |
ctxdocstrip.tex, |
| 190 |
ctex-zhconv.lua, |
| 191 |
ctex-zhconv-make.lua, |
| 192 |
and the derived files ctex.pdf, |
| 193 |
ctex.ins, |
| 194 |
ctex.sty, |
| 195 |
ctexsize.sty, |
| 196 |
ctexheading.sty, |
| 197 |
ctexart.cls, |
| 198 |
ctexbook.cls, |
| 199 |
ctexrep.cls, |
| 200 |
ctexbeamer.cls, |
| 201 |
ctexcap.sty, |
| 202 |
ctexhook.sty, |
| 203 |
ctexpatch.sty, |
| 204 |
ctex-c5size.clo, |
| 205 |
ctex-cs4size.clo, |
| 206 |
ctex-heading-article.def, |
| 207 |
ctex-heading-book.def, |
| 208 |
ctex-heading-report.def, |
| 209 |
ctex-heading-beamer.def, |
| 210 |
ctex-scheme-plain.def, |
| 211 |
ctex-scheme-plain-article.def, |
| 212 |
ctex-scheme-plain-book.def, |
| 213 |
ctex-scheme-plain-report.def, |
| 214 |
ctex-scheme-plain-beamer.def, |
| 215 |
ctex-scheme-chinese.def, |
| 216 |
ctex-scheme-chinese-article.def, |
| 217 |
ctex-scheme-chinese-book.def, |
| 218 |
ctex-scheme-chinese-report.def, |
| 219 |
ctex-scheme-chinese-beamer.def, |
| 220 |
ctex-name-gbk.cfg, |
| 221 |
ctex-name-utf8.cfg, |
| 222 |
ctex.cfg, |
| 223 |
ctexopts.cfg, |
| 224 |
ctexbackend.cfg, |
| 225 |
ctex-engine-pdftex.def, |
| 226 |
ctex-engine-xetex.def, |
| 227 |
ctex-engine-luatex.def, |
| 228 |
ctex-engine-aptex.def, |
| 229 |
ctex-engine-uptex.def, |
| 230 |
c19rm.fd, |
| 231 |
c19sf.fd, |
| 232 |
c19tt.fd, |
| 233 |
c70rm.fd, |
| 234 |
c70sf.fd, |
| 235 |
c70tt.fd, |
| 236 |
jy2zhrm.fd, |
| 237 |
jy2zhsf.fd, |
| 238 |
jy2zhtt.fd, |
| 239 |
jt2zhrm.fd, |
| 240 |
jt2zhsf.fd, |
| 241 |
jt2zhtt.fd, |
| 242 |
ctex-fontset-adobe.def, |
| 243 |
ctex-fontset-fandol.def, |
| 244 |
ctex-fontset-founder.def, |
| 245 |
ctex-fontset-mac.def, |
| 246 |
ctex-fontset-macnew.def, |
| 247 |
ctex-fontset-macold.def, |
| 248 |
ctex-fontset-ubuntu.def, |
| 249 |
ctex-fontset-windows.def, |
| 250 |
ctexspa.def, |
| 251 |
ctexpunct.spa, |
| 252 |
ctex-spa-make.tex, |
| 253 |
ctex-spa-macro.tex, |
| 254 |
ctex-zhmap-adobe.tex, |
| 255 |
ctex-zhmap-fandol.tex, |
| 256 |
ctex-zhmap-founder.tex, |
| 257 |
ctex-zhmap-mac.tex, |
| 258 |
ctex-zhmap-ubuntu.tex, |
| 259 |
ctex-zhmap-windows.tex, |
| 260 |
ctex-zhconv-index.lua, |
| 261 |
translator-theorem-dictionary-ChineseGBK.dict, |
| 262 |
translator-theorem-dictionary-ChineseUTF8.dict, and |
| 263 |
README.md. |
| 264 |
\endpostamble |
| 265 |
|
| 266 |
\generate |
| 267 |
{ |
| 268 |
\usedir{tex/latex/ctex} |
| 269 |
\file{ctex.sty} {\from{\jobname.dtx}{style,ctex}} |
| 270 |
\file{ctexsize.sty} {\from{\jobname.dtx}{style,ctexsize}} |
| 271 |
\file{ctexheading.sty} {\from{\jobname.dtx}{style,ctexheading}} |
| 272 |
\file{ctexart.cls} {\from{\jobname.dtx}{class,article}} |
| 273 |
\file{ctexbook.cls} {\from{\jobname.dtx}{class,book}} |
| 274 |
\file{ctexrep.cls} {\from{\jobname.dtx}{class,report}} |
| 275 |
\file{ctexbeamer.cls} {\from{\jobname.dtx}{class,beamer}} |
| 276 |
\usepostamble\emptypostamble |
| 277 |
\file{ctexcap.sty} {\from{\jobname.dtx}{ctexcap}} |
| 278 |
\file{ctexhook.sty} {\from{\jobname.dtx}{ctexhook}} |
| 279 |
\file{ctexpatch.sty} {\from{\jobname.dtx}{ctexpatch}} |
| 280 |
\file{ctex-c5size.clo} {\from{\jobname.dtx}{c5size}} |
| 281 |
\file{ctex-cs4size.clo} {\from{\jobname.dtx}{cs4size}} |
| 282 |
\file{ctex-heading-article.def} {\from{\jobname.dtx}{heading,article}} |
| 283 |
\file{ctex-heading-book.def} {\from{\jobname.dtx}{heading,book}} |
| 284 |
\file{ctex-heading-report.def} {\from{\jobname.dtx}{heading,report}} |
| 285 |
\file{ctex-heading-beamer.def} {\from{\jobname.dtx}{heading,beamer}} |
| 286 |
\file{ctex-scheme-plain.def} {\from{\jobname.dtx}{scheme,generic,plain}} |
| 287 |
\file{ctex-scheme-plain-article.def} {\from{\jobname.dtx}{scheme,article,plain}} |
| 288 |
\file{ctex-scheme-plain-book.def} {\from{\jobname.dtx}{scheme,book,plain}} |
| 289 |
\file{ctex-scheme-plain-report.def} {\from{\jobname.dtx}{scheme,report,plain}} |
| 290 |
\file{ctex-scheme-plain-beamer.def} {\from{\jobname.dtx}{scheme,beamer,plain}} |
| 291 |
\file{ctex-scheme-chinese.def} {\from{\jobname.dtx}{scheme,generic,chinese}} |
| 292 |
\file{ctex-scheme-chinese-article.def} {\from{\jobname.dtx}{scheme,article,chinese}} |
| 293 |
\file{ctex-scheme-chinese-book.def} {\from{\jobname.dtx}{scheme,book,chinese}} |
| 294 |
\file{ctex-scheme-chinese-report.def} {\from{\jobname.dtx}{scheme,report,chinese}} |
| 295 |
\file{ctex-scheme-chinese-beamer.def} {\from{\jobname.dtx}{scheme,beamer,chinese}} |
| 296 |
\ctxfile{GBK}{ctex-name-gbk.cfg} {\from{\jobname.dtx}{name,GBK}} |
| 297 |
\file{ctex-name-utf8.cfg} {\from{\jobname.dtx}{name,UTF8}} |
| 298 |
\file{ctex.cfg} {\from{\jobname.dtx}{config}} |
| 299 |
\file{ctexopts.cfg} {\from{\jobname.dtx}{ctexopts}} |
| 300 |
\file{ctexbackend.cfg} {\from{\jobname.dtx}{backend}} |
| 301 |
\file{ctex-engine-pdftex.def} {\from{\jobname.dtx}{pdftex}} |
| 302 |
\file{ctex-engine-xetex.def} {\from{\jobname.dtx}{xetex}} |
| 303 |
\file{ctex-engine-luatex.def} {\from{\jobname.dtx}{luatex}} |
| 304 |
\file{ctex-engine-aptex.def} {\from{\jobname.dtx}{aptex}} |
| 305 |
\file{ctex-engine-uptex.def} {\from{\jobname.dtx}{uptex}} |
| 306 |
\file{c19rm.fd} {\from{\jobname.dtx}{fd,rm,c19}} |
| 307 |
\file{c19sf.fd} {\from{\jobname.dtx}{fd,sf,c19}} |
| 308 |
\file{c19tt.fd} {\from{\jobname.dtx}{fd,tt,c19}} |
| 309 |
\file{c70rm.fd} {\from{\jobname.dtx}{fd,rm,c70}} |
| 310 |
\file{c70sf.fd} {\from{\jobname.dtx}{fd,sf,c70}} |
| 311 |
\file{c70tt.fd} {\from{\jobname.dtx}{fd,tt,c70}} |
| 312 |
\file{jy2zhrm.fd} {\from{\jobname.dtx}{fd,rm,jy2}} |
| 313 |
\file{jy2zhsf.fd} {\from{\jobname.dtx}{fd,sf,jy2}} |
| 314 |
\file{jy2zhtt.fd} {\from{\jobname.dtx}{fd,tt,jy2}} |
| 315 |
\file{jt2zhrm.fd} {\from{\jobname.dtx}{fd,rm,jt2}} |
| 316 |
\file{jt2zhsf.fd} {\from{\jobname.dtx}{fd,sf,jt2}} |
| 317 |
\file{jt2zhtt.fd} {\from{\jobname.dtx}{fd,tt,jt2}} |
| 318 |
\file{ctex-fontset-adobe.def} {\from{\jobname.dtx}{fontset,adobe}} |
| 319 |
\file{ctex-fontset-fandol.def} {\from{\jobname.dtx}{fontset,fandol}} |
| 320 |
\file{ctex-fontset-founder.def} {\from{\jobname.dtx}{fontset,founder}} |
| 321 |
\file{ctex-fontset-mac.def} {\from{\jobname.dtx}{fontset,mac}} |
| 322 |
\file{ctex-fontset-macnew.def} {\from{\jobname.dtx}{fontset,macnew}} |
| 323 |
\file{ctex-fontset-macold.def} {\from{\jobname.dtx}{fontset,macold}} |
| 324 |
\file{ctex-fontset-ubuntu.def} {\from{\jobname.dtx}{fontset,ubuntu}} |
| 325 |
\file{ctex-fontset-windows.def} {\from{\jobname.dtx}{fontset,windows}} |
| 326 |
\ctxfile{GBK}{translator-theorem-dictionary-ChineseGBK.dict} |
| 327 |
{\from{\jobname.dtx}{dict,theorem,GBK}} |
| 328 |
\file{translator-theorem-dictionary-ChineseUTF8.dict} |
| 329 |
{\from{\jobname.dtx}{dict,theorem,UTF8}} |
| 330 |
\file{ctexspa.def} {\from{\jobname.dtx}{ctexspa} |
| 331 |
\from{ctexpunct.spa}{}} |
| 332 |
\usedir{tex/generic/ctex} |
| 333 |
\file{ctex-spa-make.tex} {\from{\jobname.dtx}{spa,make}} |
| 334 |
\file{ctex-spa-macro.tex} {\from{\jobname.dtx}{spa,macro}} |
| 335 |
\file{ctex-zhmap-adobe.tex} {\from{\jobname.dtx}{zhmap,adobe}} |
| 336 |
\file{ctex-zhmap-fandol.tex} {\from{\jobname.dtx}{zhmap,fandol}} |
| 337 |
\file{ctex-zhmap-founder.tex} {\from{\jobname.dtx}{zhmap,founder}} |
| 338 |
\file{ctex-zhmap-mac.tex} {\from{\jobname.dtx}{zhmap,mac}} |
| 339 |
\file{ctex-zhmap-ubuntu.tex} {\from{\jobname.dtx}{zhmap,ubuntu}} |
| 340 |
\file{ctex-zhmap-windows.tex} {\from{\jobname.dtx}{zhmap,windows}} |
| 341 |
%</install> |
| 342 |
%<*internal> |
| 343 |
\usedir{source/latex/ctex} |
| 344 |
\file{\jobname.ins} {\from{\jobname.dtx}{install}} |
| 345 |
%</internal> |
| 346 |
%<*install> |
| 347 |
\nopreamble\nopostamble |
| 348 |
\usedir{doc/latex/ctex} |
| 349 |
\file{README.md} {\from{\jobname.dtx}{readme}} |
| 350 |
} |
| 351 |
|
| 352 |
\catcode32=12\space |
| 353 |
|
| 354 |
\Msg{*************************************************************} |
| 355 |
\Msg{* *} |
| 356 |
\Msg{* To finish the installation you have to move the following *} |
| 357 |
\Msg{* file into proper directories searched by TeX: *} |
| 358 |
\Msg{* *} |
| 359 |
\Msg{* The recommended directory is TDS:tex/latex/ctex *} |
| 360 |
\Msg{* *} |
| 361 |
\Msg{* ctex.sty *} |
| 362 |
\Msg{* ctexsize.sty *} |
| 363 |
\Msg{* ctexheading.sty *} |
| 364 |
\Msg{* ctexart.cls *} |
| 365 |
\Msg{* ctexbook.cls *} |
| 366 |
\Msg{* ctexrep.cls *} |
| 367 |
\Msg{* ctexbeamer.cls *} |
| 368 |
\Msg{* ctexcap.sty *} |
| 369 |
\Msg{* ctexhook.sty *} |
| 370 |
\Msg{* ctexpatch.sty *} |
| 371 |
\Msg{* ctex-c5size.clo *} |
| 372 |
\Msg{* ctex-cs4size.clo *} |
| 373 |
\Msg{* ctex-heading-article.def *} |
| 374 |
\Msg{* ctex-heading-book.def *} |
| 375 |
\Msg{* ctex-heading-report.def *} |
| 376 |
\Msg{* ctex-heading-beamer.def *} |
| 377 |
\Msg{* ctex-scheme-plain.def *} |
| 378 |
\Msg{* ctex-scheme-plain-article.def *} |
| 379 |
\Msg{* ctex-scheme-plain-book.def *} |
| 380 |
\Msg{* ctex-scheme-plain-report.def *} |
| 381 |
\Msg{* ctex-scheme-plain-beamer.def *} |
| 382 |
\Msg{* ctex-scheme-chinese.def *} |
| 383 |
\Msg{* ctex-scheme-chinese-article.def *} |
| 384 |
\Msg{* ctex-scheme-chinese-book.def *} |
| 385 |
\Msg{* ctex-scheme-chinese-report.def *} |
| 386 |
\Msg{* ctex-scheme-chinese-beamer.def *} |
| 387 |
\Msg{* ctex-name-gbk.cfg *} |
| 388 |
\Msg{* ctex-name-utf8.cfg *} |
| 389 |
\Msg{* ctex.cfg *} |
| 390 |
\Msg{* ctexopts.cfg *} |
| 391 |
\Msg{* ctexbackend.cfg *} |
| 392 |
\Msg{* ctex-engine-pdftex.def *} |
| 393 |
\Msg{* ctex-engine-xetex.def *} |
| 394 |
\Msg{* ctex-engine-luatex.def *} |
| 395 |
\Msg{* ctex-engine-aptex.def *} |
| 396 |
\Msg{* ctex-engine-uptex.def *} |
| 397 |
\Msg{* c19rm.fd *} |
| 398 |
\Msg{* c19sf.fd *} |
| 399 |
\Msg{* c19tt.fd *} |
| 400 |
\Msg{* c70rm.fd *} |
| 401 |
\Msg{* c70sf.fd *} |
| 402 |
\Msg{* c70tt.fd *} |
| 403 |
\Msg{* jy2zhrm.fd *} |
| 404 |
\Msg{* jy2zhsf.fd *} |
| 405 |
\Msg{* jy2zhtt.fd *} |
| 406 |
\Msg{* jt2zhrm.fd *} |
| 407 |
\Msg{* jt2zhsf.fd *} |
| 408 |
\Msg{* jt2zhtt.fd *} |
| 409 |
\Msg{* ctex-fontset-adobe.def *} |
| 410 |
\Msg{* ctex-fontset-fandol.def *} |
| 411 |
\Msg{* ctex-fontset-founder.def *} |
| 412 |
\Msg{* ctex-fontset-mac.def *} |
| 413 |
\Msg{* ctex-fontset-macnew.def *} |
| 414 |
\Msg{* ctex-fontset-macold.def *} |
| 415 |
\Msg{* ctex-fontset-ubuntu.def *} |
| 416 |
\Msg{* ctex-fontset-windows.def *} |
| 417 |
\Msg{* ctexspa.def *} |
| 418 |
\Msg{* ctex-spa-make.tex *} |
| 419 |
\Msg{* ctex-spa-macro.tex *} |
| 420 |
\Msg{* ctex-zhmap-adobe.tex *} |
| 421 |
\Msg{* ctex-zhmap-fandol.tex *} |
| 422 |
\Msg{* ctex-zhmap-founder.tex *} |
| 423 |
\Msg{* ctex-zhmap-mac.tex *} |
| 424 |
\Msg{* ctex-zhmap-ubuntu.tex *} |
| 425 |
\Msg{* ctex-zhmap-windows.tex *} |
| 426 |
\Msg{* translator-theorem-dictionary-ChineseGBK.dict *} |
| 427 |
\Msg{* translator-theorem-dictionary-ChineseUTF8.dict *} |
| 428 |
\Msg{* *} |
| 429 |
\Msg{* To produce the documentation run the file ctex.dtx *} |
| 430 |
\Msg{* through XeLaTeX. *} |
| 431 |
\Msg{* *} |
| 432 |
\Msg{* Happy TeXing! *} |
| 433 |
\Msg{* *} |
| 434 |
\Msg{*************************************************************} |
| 435 |
|
| 436 |
\endbatchfile |
| 437 |
%</install> |
| 438 |
%<*internal> |
| 439 |
\fi |
| 440 |
%</internal> |
| 441 |
%<*!(driver|readme|install|zhmap|spa|docstrip)> |
| 442 |
%<*!(fd|ctexspa|dict|backend)> |
| 443 |
%<class|style|ctexcap|ctexhook|ctexpatch>\NeedsTeXFormat{LaTeX2e} |
| 444 |
%<class>\input{ctexbackend.cfg} |
| 445 |
%<class|style|ctexcap|ctexhook|ctexpatch>\RequirePackage{expl3} |
| 446 |
%<+!driver>\GetIdInfo$Id: ctex.dtx 13a2256 2022-07-14 18:54:09 +0800 Qing Lee <[email protected]> $ |
| 447 |
%<ctex> {Chinese adapter in LaTeX (CTEX)} |
| 448 |
%<ctex>\ProvidesExplPackage{\ExplFileName} |
| 449 |
%<ctexsize> {Chinese font size definition (CTEX)} |
| 450 |
%<ctexsize>\ProvidesExplPackage{ctexsize} |
| 451 |
%<ctexheading> {Heading style modification (CTEX)} |
| 452 |
%<ctexheading>\ProvidesExplPackage{ctexheading} |
| 453 |
%<class&article> {Chinese adapter for class article (CTEX)} |
| 454 |
%<class&article>\ProvidesExplClass{ctexart} |
| 455 |
%<class&book> {Chinese adapter for class book (CTEX)} |
| 456 |
%<class&book>\ProvidesExplClass{ctexbook} |
| 457 |
%<class&report> {Chinese adapter for class report (CTEX)} |
| 458 |
%<class&report>\ProvidesExplClass{ctexrep} |
| 459 |
%<class&beamer> {Chinese adapter for class beamer (CTEX)} |
| 460 |
%<class&beamer>\ProvidesExplClass{ctexbeamer} |
| 461 |
%<ctexcap> {Chinese adapter in LaTeX (CTEX)} |
| 462 |
%<ctexcap>\ProvidesExplPackage{ctexcap} |
| 463 |
%<ctexhook> {Document and package hooks (CTEX)} |
| 464 |
%<ctexhook>\ProvidesExplPackage{ctexhook} |
| 465 |
%<ctexpatch> {Patching commands (CTEX)} |
| 466 |
%<ctexpatch>\ProvidesExplPackage{ctexpatch} |
| 467 |
%<c5size> {c5size option (CTEX)} |
| 468 |
%<c5size>\ProvidesExplFile{ctex-c5size.clo} |
| 469 |
%<cs4size> {cs4size option (CTEX)} |
| 470 |
%<cs4size>\ProvidesExplFile{ctex-cs4size.clo} |
| 471 |
%<heading&article> {Heading modification for article (CTEX)} |
| 472 |
%<heading&article>\ProvidesExplFile{ctex-article.def} |
| 473 |
%<heading&book> {Heading modification for book (CTEX)} |
| 474 |
%<heading&book>\ProvidesExplFile{ctex-book.def} |
| 475 |
%<heading&report> {Heading modification for report (CTEX)} |
| 476 |
%<heading&report>\ProvidesExplFile{ctex-report.def} |
| 477 |
%<heading&beamer> {Heading modification for beamer (CTEX)} |
| 478 |
%<heading&beamer>\ProvidesExplFile{ctex-beamer.def} |
| 479 |
%<scheme&plain&generic> {Plain scheme for generic (CTEX)} |
| 480 |
%<scheme&plain&generic>\ProvidesExplFile{ctex-scheme-plain.def} |
| 481 |
%<scheme&plain&article> {Plain scheme for article (CTEX)} |
| 482 |
%<scheme&plain&article>\ProvidesExplFile{ctex-scheme-plain-article.def} |
| 483 |
%<scheme&plain&book> {Plain scheme for book (CTEX)} |
| 484 |
%<scheme&plain&book>\ProvidesExplFile{ctex-scheme-plain-book.def} |
| 485 |
%<scheme&plain&report> {Plain scheme for report (CTEX)} |
| 486 |
%<scheme&plain&report>\ProvidesExplFile{ctex-scheme-plain-report.def} |
| 487 |
%<scheme&plain&beamer> {Plain scheme for beamer (CTEX)} |
| 488 |
%<scheme&plain&beamer>\ProvidesExplFile{ctex-scheme-plain-beamer.def} |
| 489 |
%<scheme&chinese&generic> {Chinese scheme for generic (CTEX)} |
| 490 |
%<scheme&chinese&generic>\ProvidesExplFile{ctex-scheme-chinese.def} |
| 491 |
%<scheme&chinese&article> {Chinese scheme for article (CTEX)} |
| 492 |
%<scheme&chinese&article>\ProvidesExplFile{ctex-scheme-chinese-article.def} |
| 493 |
%<scheme&chinese&book> {Chinese scheme for book (CTEX)} |
| 494 |
%<scheme&chinese&book>\ProvidesExplFile{ctex-scheme-chinese-book.def} |
| 495 |
%<scheme&chinese&report> {Chinese scheme for report (CTEX)} |
| 496 |
%<scheme&chinese&report>\ProvidesExplFile{ctex-scheme-chinese-report.def} |
| 497 |
%<scheme&chinese&beamer> {Chinese scheme for beamer (CTEX)} |
| 498 |
%<scheme&chinese&beamer>\ProvidesExplFile{ctex-scheme-chinese-beamer.def} |
| 499 |
%<name&GBK> {Caption with encoding GBK (CTEX)} |
| 500 |
%<name&GBK>\ProvidesExplFile{ctex-name-gbk.cfg} |
| 501 |
%<name&UTF8> {Caption with encoding UTF-8 (CTEX)} |
| 502 |
%<name&UTF8>\ProvidesExplFile{ctex-name-utf8.cfg} |
| 503 |
%<config> {Configuration file (CTEX)} |
| 504 |
%<config>\ProvidesExplFile{\ExplFileName.cfg} |
| 505 |
%<ctexopts> {Option configuration file (CTEX)} |
| 506 |
%<ctexopts>\ProvidesExplFile{ctexopts.cfg} |
| 507 |
%<pdftex> {(pdf)LaTeX adapter (CTEX)} |
| 508 |
%<pdftex>\ProvidesExplFile{ctex-engine-pdftex.def} |
| 509 |
%<xetex> {XeLaTeX adapter (CTEX)} |
| 510 |
%<xetex>\ProvidesExplFile{ctex-engine-xetex.def} |
| 511 |
%<luatex> {LuaLaTeX adapter (CTEX)} |
| 512 |
%<luatex>\ProvidesExplFile{ctex-engine-luatex.def} |
| 513 |
%<aptex> {Asian pTeX adapter (CTEX)} |
| 514 |
%<aptex>\ProvidesExplFile{ctex-engine-aptex.def} |
| 515 |
%<uptex> {upTeX adapter (CTEX)} |
| 516 |
%<uptex>\ProvidesExplFile{ctex-engine-uptex.def} |
| 517 |
%<windows> {Windows fonts definition (CTEX)} |
| 518 |
%<windows>\ProvidesExplFile{ctex-fontset-windows.def} |
| 519 |
%<adobe> {Adobe fonts definition (CTEX)} |
| 520 |
%<adobe>\ProvidesExplFile{ctex-fontset-adobe.def} |
| 521 |
%<fandol> {Fandol fonts definition (CTEX)} |
| 522 |
%<fandol>\ProvidesExplFile{ctex-fontset-fandol.def} |
| 523 |
%<mac> {macOS fonts definition (CTEX)} |
| 524 |
%<mac>\ProvidesExplFile{ctex-fontset-mac.def} |
| 525 |
%<macnew> {macOS fonts definition for El Capitan or later version (CTEX)} |
| 526 |
%<macnew>\ProvidesExplFile{ctex-fontset-macnew.def} |
| 527 |
%<macold> {macOS fonts definition for Yosemite or earlier version (CTEX)} |
| 528 |
%<macold>\ProvidesExplFile{ctex-fontset-macold.def} |
| 529 |
%<founder> {Founder fonts definition (CTEX)} |
| 530 |
%<founder>\ProvidesExplFile{ctex-fontset-founder.def} |
| 531 |
%<ubuntu> {Ubuntu fonts definition (CTEX)} |
| 532 |
%<ubuntu>\ProvidesExplFile{ctex-fontset-ubuntu.def} |
| 533 |
%<!driver> {\ExplFileDate}{2.5.10}{\ExplFileDescription} |
| 534 |
%</!(fd|ctexspa|dict|backend)> |
| 535 |
%<c19&rm>\ProvidesFile{c19rm.fd}% |
| 536 |
%<c19&sf>\ProvidesFile{c19sf.fd}% |
| 537 |
%<c19&tt>\ProvidesFile{c19tt.fd}% |
| 538 |
%<c70&rm>\ProvidesFile{c70rm.fd}% |
| 539 |
%<c70&sf>\ProvidesFile{c70sf.fd}% |
| 540 |
%<c70&tt>\ProvidesFile{c70tt.fd}% |
| 541 |
%<jy2&rm>\ProvidesFile{jy2zhrm.fd}% |
| 542 |
%<jy2&sf>\ProvidesFile{jy2zhsf.fd}% |
| 543 |
%<jy2&tt>\ProvidesFile{jy2zhtt.fd}% |
| 544 |
%<jt2&rm>\ProvidesFile{jt2zhrm.fd}% |
| 545 |
%<jt2&sf>\ProvidesFile{jt2zhsf.fd}% |
| 546 |
%<jt2&tt>\ProvidesFile{jt2zhtt.fd}% |
| 547 |
%<ctexspa>\ProvidesFile{ctexspa.def}% |
| 548 |
%<backend>\ProvidesFile{ctexbackend.cfg}% |
| 549 |
%<dict&theorem&GBK>\ProvidesDictionary{translator-theorem-dictionary}{ChineseGBK}% |
| 550 |
%<dict&theorem&UTF8>\ProvidesDictionary{translator-theorem-dictionary}{ChineseUTF8}% |
| 551 |
%<fd> [2022/07/14 v2.5.10 Chinese font definition (CTEX)] |
| 552 |
%<ctexspa> [2022/07/14 v2.5.10 Space info for CJKpunct (CTEX)] |
| 553 |
%<backend> [2022/07/14 v2.5.10 Backend configuration file (CTEX)] |
| 554 |
%<dict&theorem> [2022/07/14 v2.5.10 Chinese translation for theorem name (CTEX)] |
| 555 |
%</!(driver|readme|install|zhmap|spa|docstrip)> |
| 556 |
%<*driver> |
| 557 |
\documentclass{ctxdoc} |
| 558 |
\begin{document} |
| 559 |
\DocInput{\jobname.dtx} |
| 560 |
\IndexLayout |
| 561 |
\PrintChanges |
| 562 |
\PrintIndex |
| 563 |
\end{document} |
| 564 |
%</driver> |
| 565 |
% |
| 566 |
% \fi |
| 567 |
% |
| 568 |
% \changes{v2.0}{2014/03/06}{应用 \LaTeXiii{} 重新整理代码。} |
| 569 |
% \changes{v2.0}{2014/03/12}{删除 \file{c19gbsn.fd} 和 \file{c19gkai.fd}。} |
| 570 |
% \changes{v2.1}{2015/05/18}{将章节标题设置功能提取到可以独立使用的宏包 |
| 571 |
% \pkg{ctexheading} 中。} |
| 572 |
% \changes{v2.2}{2015/06/24}{不再依赖 \pkg{etoolbox} 宏包。} |
| 573 |
% \changes{v2.4}{2015/02/19}{加强 \pkg{beamer} 宏包支持。} |
| 574 |
% \changes{v2.4.12}{2018/01/13}{同步 \LaTeXiii{} 2017/12/16。} |
| 575 |
% \changes{v2.4.15}{2019/03/23}{同步 \LaTeXiii{} 2019/03/05。} |
| 576 |
% \changes{v2.5.1}{2020/05/02}{\pkg{zhconv} 更名为 \pkg{ctex-zhconv}。} |
| 577 |
% |
| 578 |
% \CheckSum{6630} |
| 579 |
% |
| 580 |
% \CharacterTable |
| 581 |
% {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 |
| 582 |
% Lower-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 |
| 583 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 584 |
% Exclamation \! Double quote \" Hash (number) \# |
| 585 |
% Dollar \$ Percent \% Ampersand \& |
| 586 |
% Acute accent \' Left paren \( Right paren \) |
| 587 |
% Asterisk \* Plus \+ Comma \, |
| 588 |
% Minus \- Point \. Solidus \/ |
| 589 |
% Colon \: Semicolon \; Less than \< |
| 590 |
% Equals \= Greater than \> Question mark \? |
| 591 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 592 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 593 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 594 |
% Right brace \} Tilde \~} |
| 595 |
% |
| 596 |
% \GetFileId{ctex.sty} |
| 597 |
% |
| 598 |
% \title{\bfseries \CTeX{} 宏集手册} |
| 599 |
% \author{\href{http://www.ctex.org}{CTEX.ORG}} |
| 600 |
% \date{\filedate\qquad\fileversion\thanks{\ctexkitrev{\ExplFileVersion}.}} |
| 601 |
% \maketitle |
| 602 |
% |
| 603 |
% \begin{abstract} |
| 604 |
% \CTeX{} 宏集是面向中文排版的通用 \LaTeX{} 排版框架,为中文 \LaTeX{} 文档 |
| 605 |
% 提供了汉字输出支持、标点压缩、字体字号命令、标题文字汉化、中文版式调整、数字 |
| 606 |
% 日期转换等支持功能,可适应论文、报告、书籍、幻灯片等不同类型的中文文档。 |
| 607 |
% |
| 608 |
% \CTeX{} 宏集支持 \LaTeX、\pdfLaTeX、\XeLaTeX、\LuaLaTeX、\upLaTeX{} 等多种不同 |
| 609 |
% 的编译方式,并为它们提供了统一的界面。主要功能由宏包 \pkg{ctex} 以及中文文档类 |
| 610 |
% \cls{ctexart}、\cls{ctexrep}、\cls{ctexbook} 和 \cls{ctexbeamer} 实现。 |
| 611 |
% \end{abstract} |
| 612 |
% |
| 613 |
% \tableofcontents |
| 614 |
% |
| 615 |
% \bigskip |
| 616 |
% \setlength{\parskip}{0.8ex} |
| 617 |
% |
| 618 |
% \begin{documentation} |
| 619 |
% |
| 620 |
% \section{介绍} |
| 621 |
% |
| 622 |
% \subsection*{历史} |
| 623 |
% |
| 624 |
% \CTeX{} 宏集的源头有两个:一是王磊编写的 \cls{cjkbook} 文档类,二是吴凌云编写的 |
| 625 |
% \file{GB.cap}。 |
| 626 |
% 这些工作没有经过认真系统的设计,也没有用户文档,不利于维护和改进。 |
| 627 |
% |
| 628 |
% 2003 年,吴凌云使用 \pkg{doc} 和 \pkg{DocStrip} 重构了整个工程,并增加了许多新的功能, |
| 629 |
% 称为 \pkg{ctex} 宏包。2007 年,oseen 和王越在 \pkg{ctex} 宏包的基础上, |
| 630 |
% 增加了对 UTF-8 编码的支持,开发出了 \pkg{ctexutf8} 宏包。 |
| 631 |
% |
| 632 |
% 2009 年 5 月,我们在 Google Code 建立了 ctex-kit 项目^^A |
| 633 |
% \footnote{\nolinkurl{http://code.google.com/p/ctex-kit/},该链接现已失效。}, |
| 634 |
% 对 \pkg{ctex} 宏包及相关脚本进行了整合,并加入了对 \XeTeX{} 引擎的支持。 |
| 635 |
% 在开发新版本时,考虑到合作开发和调试的方便,我们放弃了 \pkg{doc} 和 \pkg{DocStrip}, |
| 636 |
% 采取了直接编写宏包代码的方式。 |
| 637 |
% |
| 638 |
% 2014 年 3 月,为了适应 \LaTeX{} 的最新发展,特别是 \LaTeXiii{} 的逐渐成熟,李清用 |
| 639 |
% \LaTeXiii{} 重构了整个宏包的代码,并重新使用 \pkg{doc} 和 \pkg{DocStrip} 工具进行代码 |
| 640 |
% 的管理,升级版本号为 2.0,并改称 \CTeX{} 宏集。 |
| 641 |
% |
| 642 |
% 2015 年 3 月,由于 Google Code 即将停止服务,ctex-kit 项目迁移至 |
| 643 |
% \href{https://github.com/CTeX-org/ctex-kit}{GitHub}^^A |
| 644 |
% \footnote{\url{https://github.com/CTeX-org/ctex-kit}}。 |
| 645 |
% |
| 646 |
% 最初,Knuth 在设计开发 \TeX{} 的时候没有考虑到多国文字支持,特别是对多字节的中日韩 |
| 647 |
% 表意文字的支持。这使得 \TeX{} 以至后来的 \LaTeX{} 对中文的支持一直不是很好。即使在 |
| 648 |
% \pkg{CJK} 宏包解决了中文字符处理的问题以后,中文用户使用 \LaTeX{} 仍然要面对许 |
| 649 |
% 多困难。 |
| 650 |
% 这些困难里,以章节标题的中文化为最。由于中文和西文书写习惯的差异,用户很难使用标准 |
| 651 |
% 文档类中的代码结构来表达中文标题。于是,用户不得不对标准文档类做较大的修改。 |
| 652 |
% 除此之外,日期格式、首行缩进、中文字号和字距等细节问题,也需要精细的调校。 |
| 653 |
% 我们设计 \CTeX{} 宏集的目的之一就是解决这些 \LaTeX{} 文档的汉化难题。 |
| 654 |
% |
| 655 |
% 另一方面,随着 \TeX{} 引擎和 \LaTeX{} 宏包的不断发展,\LaTeX{} 的中文支持方式从早期的 |
| 656 |
% 专用系统(如 \pkg{CCT})发展为适用于不同引擎的多种方式^^A |
| 657 |
% \footnote{比如:\pdfTeX{} 引擎下的 \pkg{CJK}、\pkg{zhmCJK}宏包, |
| 658 |
% \XeTeX{} 引擎下的 \pkg{xeCJK} 宏包和 \LuaTeX{} 引擎下的 \pkg{LuaTeX-ja} 宏包。}。 |
| 659 |
% 这些方式的适用情况和使用方式有不少细节上的差异,同时操作系统的不同、语言环境的不同等 |
| 660 |
% 客观情况又进一步带来了更多的细节差异。我们设计 \CTeX{} 宏集的另一个主要目的就是 |
| 661 |
% 尽可能消除这些差异带来的影响,使用户能够以一个统一的接口来使用不同的中文支持方式, |
| 662 |
% 使得同一份文档能够在不同环境下交换使用。 |
| 663 |
% |
| 664 |
% \CTeX{} 宏集的许多实现细节离不开热心朋友们在 \nolinkurl{bbs.ctex.org} 论坛^^A |
| 665 |
% \footnote{2018 年,\CTeX{} 论坛因故无限期关闭,此链接现已失效。}^^A |
| 666 |
% 上的讨论,在此对参与讨论的朋友们表示感谢。 |
| 667 |
% |
| 668 |
% \subsection*{关于宏集名字的说明} |
| 669 |
% |
| 670 |
% \CTeX{} 之名是英文单词 China(中国)或 Chinese(中文)的首字母“C”与 “\TeX{}” |
| 671 |
% 结合而成的。在纯文本环境下,该名字应写作“CTeX”。 |
| 672 |
% |
| 673 |
% \CTeX{} 宏集是由 \href{https://github.com/CTeX-org}{\CTeX{} 社区}发起并维护的 |
| 674 |
% \LaTeX{} \emph{宏包和文档类的集合}。 |
| 675 |
% 社区另有发布名为 \href{http://www.ctex.org/CTeX}{\CTeX{} 套装}^^A |
| 676 |
% 的 \TeX{} 发行版,与本文档所述的 \CTeX{} 宏集并非是同一事物。 |
| 677 |
% |
| 678 |
% \pkg{ctex} 则是本宏集中的 \pkg{ctex.sty} 的名字。这一完全小写的名称,在过去 |
| 679 |
% 也被用来指代整个 \CTeX{} 宏集,不过现在则特指 \pkg{ctex.sty} 这一宏包。 |
| 680 |
% 在不引起歧义的情况下,它也可以沿用过去的习惯,代指整个宏集。 |
| 681 |
% |
| 682 |
% \section{简明教程} |
| 683 |
% |
| 684 |
% \subsection{\CTeX{} 宏集的组成} |
| 685 |
% |
| 686 |
% 为了适应用户不同的需求,我们将 \CTeX{} 宏集的主要功能设计安排在四个中文文档类和 |
| 687 |
% 三个宏包当中,具体的组成见表~\ref{tab:ctex}。 |
| 688 |
% |
| 689 |
% \begin{table}[htbp] |
| 690 |
% \centering |
| 691 |
% \caption{\CTeX{} 宏集的组成}\label{tab:ctex} |
| 692 |
% \begin{tabularx}{\linewidth}{llX} |
| 693 |
% \toprule |
| 694 |
% 类别 & 文件 & 说明 \\ |
| 695 |
% \midrule |
| 696 |
% 文档类 & \file{ctexart.cls} & 标准文档类 \cls{article} 的汉化版本, |
| 697 |
% 一般适用于短篇幅的文章 \\ |
| 698 |
% & \file{ctexrep.cls} & 标准文档类 \cls{report} 的汉化版本, |
| 699 |
% 一般适用于中篇幅的报告 \\ |
| 700 |
% & \file{ctexbook.cls} & 标准文档类 \cls{book} 的汉化版本, |
| 701 |
% 一般适用于长篇幅的书籍 \\ |
| 702 |
% & \file{ctexbeamer.cls} & 文档类 \cls{beamer} 的汉化版本, |
| 703 |
% 适用于幻灯片演示 \\ |
| 704 |
% \midrule |
| 705 |
% 宏包 & \file{ctex.sty} & 提供全部功能,但\emph{默认不开启章节标题设置功能}, |
| 706 |
% 需要使用 \opt{heading} 选项来开启 \\ |
| 707 |
% & \file{ctexsize.sty} & 定义和调整中文字号,可以在 \pkg{ctex} 宏包 |
| 708 |
% 或 \CTeX{} 中文文档类之外单独调用 \\ |
| 709 |
% & \file{ctexheading.sty} & 提供章节标题设置功能(见 \ref{sec:secstyle} |
| 710 |
% 节),可以在 \pkg{ctex} 宏包或 \CTeX{} 中文 |
| 711 |
% 文档类之外单独调用 \\ |
| 712 |
% \bottomrule |
| 713 |
% \end{tabularx} |
| 714 |
% \end{table} |
| 715 |
% |
| 716 |
% \subsection{\CTeX{} 宏集的安装和更新} |
| 717 |
% \label{subsec:easy-ins} |
| 718 |
% 最常见的 \TeX{} 发行版(\TeXLive{} 和 \MiKTeX{})已收录 \CTeX{} 宏集及其依赖的宏包和宏集。 |
| 719 |
% \footnote{\pkg{zhmCJK} 宏包是个例外。当用户显式指定选项 \opt{zhmap = zhmCJK} 时,^^A |
| 720 |
% \CTeX{} 宏集依赖它。由于,它没有被 \TeXLive{} 和 \MiKTeX{} 收录,用户可能需要遵照其说明文档 |
| 721 |
% 自行安装。}如果本地安装 \TeXLive{} 或 \MiKTeX{} 不是完整版本,则可能需要通过这 |
| 722 |
% 两个发行版提供的\emph{包管理器}来安装宏包。 |
| 723 |
% |
| 724 |
% \TeXLive{} 的包管理器是 tlmgr(\TeXLive{} Manager)。用户可以在系统命令行中^^A |
| 725 |
% \footnote{Windows 系统的命令行是 CMD 命令提示符,你可以使用 Win + R 组合键 |
| 726 |
% 打开“运行”对话框,然后输入 cmd 确认打开命令提示符窗口。}执行 |
| 727 |
% \begin{frameverb} |
| 728 |
% tlmgr gui |
| 729 |
% \end{frameverb} |
| 730 |
% 启动管理器的图形界面(Windows 用户也可以通过开始菜单的 TeX Live 20XX(年份) |
| 731 |
% \ding{212} TeX Live Manager 打开)。连接上远程仓库之后,搜索 |ctex| 即可安装。 |
| 732 |
% tlmgr 的图形界面使用 Perl 编写,在实践中发现容易造成系统假死。遇到这种问题的用户, |
| 733 |
% 也可以直接在系统命令行执行 |
| 734 |
% \begin{frameverb} |
| 735 |
% tlmgr install ctex |
| 736 |
% \end{frameverb} |
| 737 |
% 来安装 \CTeX{} 宏集^^A |
| 738 |
% \footnote{*nix 用户可能需要超级用户权限(sudo)才能正确安装宏集。}。 |
| 739 |
% |
| 740 |
% \MiKTeX{} 通常会在缺失宏包时自动完成安装。如需手动安装,可以使用其管理维护 |
| 741 |
% 工具 \MiKTeX{} Console。用户可以打开管理器,连接上远程仓库之后,在“Package” |
| 742 |
% 选项卡中搜索“ctex”并安装即可。 |
| 743 |
% 也可以使用 mpm(\MiKTeX{} Package Manager),在命令行执行 |
| 744 |
% \begin{frameverb} |
| 745 |
% mpm --admin --install=ctex |
| 746 |
% \end{frameverb} |
| 747 |
% 来安装 \CTeX{} 宏集。 |
| 748 |
% |
| 749 |
% 若希望了解 \CTeX{} 宏集具体的依赖情况或手工安装宏集的方法, |
| 750 |
% 请参阅第 \ref{sec:dep-ins}~节。 |
| 751 |
% |
| 752 |
% 当我们将宏集的新版本发布于 CTAN,且为发行版的远程仓库更新后,用户就可以在本地 |
| 753 |
% 通过包管理器获取新版本。 |
| 754 |
% |
| 755 |
% 对于 \TeXLive{},可以在 tlmgr 的图形界面点击“更新全部已安装的”按钮或者在 |
| 756 |
% 命令行执行 |
| 757 |
% \begin{frameverb} |
| 758 |
% tlmgr update --all |
| 759 |
% \end{frameverb} |
| 760 |
% 来完整更新已安装的宏包。 |
| 761 |
% |
| 762 |
% 对于 \MiKTeX{},在 \MiKTeX{} Console 中找到“Updates”选项卡,检查更新后即可 |
| 763 |
% 选择升级宏包。也可以使用 mpm,在命令行执行 |
| 764 |
% \begin{frameverb} |
| 765 |
% mpm --admin --update |
| 766 |
% \end{frameverb} |
| 767 |
% 来进行更新。 |
| 768 |
% |
| 769 |
% \subsection{使用 \CTeX{} 文档类} |
| 770 |
% |
| 771 |
% \emph{如果用户需要在三个标准文档类或 \cls{beamer} 的基础上添加中文及版式的支持, |
| 772 |
% 我们建议用户使用 \CTeX{} 宏集提供的四个中文文档类。} |
| 773 |
% |
| 774 |
% \CTeX{} 宏集提供了四个中文文档类:\cls{ctexart}、\cls{ctexrep}、\cls{ctexbook} 和 |
| 775 |
% \cls{ctexbeamer},分别对应 \LaTeX{} 的标准文档类 \cls{article}、\cls{report}、 |
| 776 |
% \cls{book} 和 \cls{beamer}。使用它们的时候,需要将涉及到的所有源文件使用 UTF-8 |
| 777 |
% 编码保存\footnote{使用 (pdf)\LaTeX{} 时也能够使用 GBK 编码,但不推荐。(见 |
| 778 |
% \ref{subs:encoding}~节)}。 |
| 779 |
% |
| 780 |
% \begin{ctexexam} |
| 781 |
% \documentclass{ctexart} |
| 782 |
% \begin{document} |
| 783 |
% 中文文档类测试。你需要将所有源文件保存为 UTF-8 编码。 |
| 784 |
% |
| 785 |
% 你可以使用 XeLaTeX、LuaLaTeX 或 upLaTeX 编译,也可以使用 (pdf)LaTeX 编译。 |
| 786 |
% 推荐使用 XeLaTeX 或 LuaLaTeX 编译。对高级用户,我们也推荐使用 upLaTeX 编译。 |
| 787 |
% \end{document} |
| 788 |
% \end{ctexexam} |
| 789 |
% |
| 790 |
% 以下是使用 \cls{ctexbeamer} 文档类编写中文演示文稿的一个示例。 |
| 791 |
% \begin{ctexexam} |
| 792 |
% \documentclass{ctexbeamer} |
| 793 |
% \begin{document} |
| 794 |
% \begin{frame}{中文演示文档} |
| 795 |
% \begin{itemize} |
| 796 |
% \item 你需要将所有源文件保存为 UTF-8 编码 |
| 797 |
% \item 你可以使用 XeLaTeX、LuaLaTeX 或 upLaTeX 编译 |
| 798 |
% \item 也可以使用 (pdf)LaTeX 编译 |
| 799 |
% \item 推荐使用 XeLaTeX 或 LuaLaTeX 编译 |
| 800 |
% \item 对高级用户,我们也推荐使用 upLaTeX 编译 |
| 801 |
% \end{itemize} |
| 802 |
% \end{frame} |
| 803 |
% \end{document} |
| 804 |
% \end{ctexexam} |
| 805 |
% |
| 806 |
% \subsection{使用 \pkg{ctex} 宏包} |
| 807 |
% |
| 808 |
% \emph{用户在使用非标准文档类及 \cls{beamer} 时,如果需要添加中文及版式的支持, |
| 809 |
% 则可以使用 \pkg{ctex} 宏包。} |
| 810 |
% |
| 811 |
% 对于建立在 \LaTeX{} 标准文档类之上开发的文档类,在使用 \pkg{ctex} 宏包时 |
| 812 |
% 加上 \opt{heading} 选项,可以将章节标题设置为中文风格。 |
| 813 |
% \begin{ctexexam} |
| 814 |
% \documentclass{ltxdoc} |
| 815 |
% \usepackage[heading = true]{ctex} |
| 816 |
% \begin{document} |
| 817 |
% \section{简介} |
| 818 |
% 章节标题中文化的 \LaTeX{} 手册。 |
| 819 |
% \end{document} |
| 820 |
% \end{ctexexam} |
| 821 |
% |
| 822 |
% \section{宏包选项与 \tn{ctexset} 命令} |
| 823 |
% \label{sec:options} |
| 824 |
% |
| 825 |
% \CTeX{} 宏集已经尽可能就中文的行文和版式习惯做了调整和配置,通常而言,这些配置 |
| 826 |
% 已经够用。因此,除非必要,我们不建议普通用户修改这些默认配置。如果你认为 \CTeX{} 宏集 |
| 827 |
% 的默认配置还可以完善,可以在项目主页上^^A |
| 828 |
% \href{https://github.com/CTeX-org/ctex-kit/issues}{提交 issue}, |
| 829 |
% 向我们反映,我们会酌情在后续版本中予以改进。 |
| 830 |
% |
| 831 |
% 不过,\CTeX{} 宏集也提供了一系列选项。用户可以使用这些选项来控制 \CTeX{} 宏集的行为。 |
| 832 |
% 按形式分类,这些选项有的以传统的方式提供,有的以 \meta{key}|=|\meta{value} 的形式提供。 |
| 833 |
% 按指定位置分类,这些选项又可以分为以下三类: |
| 834 |
% \begin{itemize} |
| 835 |
% \item 名字后带有 \rexptarget\rexpstar{} 号的选项,只能作为宏包/文档类选项,需要 |
| 836 |
% 在引入宏包/文档类的时候指定; |
| 837 |
% \item 名字后带有 \exptarget\expstar{} 号的选项,只能通过 \CTeX{} 宏集提供的 |
| 838 |
% 用户接口 \tn{ctexset} 来设定; |
| 839 |
% \item 名字后不带有特殊符号的选项,既可以作为宏包/文档类选项,也可以通过 |
| 840 |
% \tn{ctexset} 来设定。 |
| 841 |
% \end{itemize} |
| 842 |
% 后续文档将在使用说明中对某些特殊的选项加以说明。 |
| 843 |
% |
| 844 |
% \begin{function}[added=2014-03-18]{\ctexset} |
| 845 |
% \begin{syntax} |
| 846 |
% \tn{ctexset} \Arg{键值列表} |
| 847 |
% \end{syntax} |
| 848 |
% 是 \CTeX{} 宏集的通用控制命令,用来在宏包载入后控制宏包的各项功能。 |
| 849 |
% \tn{ctexset} 的参数是一个键值列表,以通用的接口完成各项设置。 |
| 850 |
% \end{function} |
| 851 |
% |
| 852 |
% \tn{ctexset} 的参数是一组由逗号分隔的选项列表,列表中的选项通常是一个 |
| 853 |
% \meta{key}|=|\meta{value} 格式的定义。例如设置摘要与参考文献标题名称 |
| 854 |
% (\ref{subs:capname}~节)就可以使用: |
| 855 |
% \begin{ctexexam}[labelref=exam:capname] |
| 856 |
% \ctexset{ |
| 857 |
% abstractname = {本文概要}, |
| 858 |
% bibname = {文\quad 献} |
| 859 |
% } |
| 860 |
% \end{ctexexam} |
| 861 |
% |
| 862 |
% \tn{ctexset} 采用 \LaTeXiii{} 风格的键值设置,支持不同类型的选项与层次化的选 |
| 863 |
% 项设置,相关示例见 \ref{sec:secstyle}~节。 |
| 864 |
% |
| 865 |
% \section{编译方式、编码与中文字库} |
| 866 |
% \label{sec:chinese} |
| 867 |
% |
| 868 |
% \subsection{编译方式} |
| 869 |
% \label{subs:compile} |
| 870 |
% |
| 871 |
% \CTeX{} 宏集会根据用户使用的编译方式\footnote{\LaTeX、\pdfLaTeX、\XeLaTeX、 |
| 872 |
% \LuaLaTeX{} 及 \upLaTeX。},在底层选择不同的中文支持方式(见 |
| 873 |
% 表~\ref{tab:chinese-support})。 |
| 874 |
% |
| 875 |
% \begin{table}[htbp] |
| 876 |
% \centering |
| 877 |
% \begin{threeparttable} |
| 878 |
% \caption{\CTeX{} 宏集的中文支持方式} |
| 879 |
% \label{tab:chinese-support} |
| 880 |
% \begin{tabular}{*6c} |
| 881 |
% \toprule |
| 882 |
% 编译方式 & (pdf)\LaTeX & \XeLaTeX & \LuaLaTeX & \upLaTeX\tnote{*} \\ |
| 883 |
% \midrule |
| 884 |
% 支持宏包 & \pkg{CJK} & \pkg{xeCJK} & \pkg{LuaTeX-ja} & 原生 \\ |
| 885 |
% \bottomrule |
| 886 |
% \end{tabular} |
| 887 |
% \begin{tablenotes} |
| 888 |
% \item[*] p\LaTeX-ng(或称 \ApLaTeX)与 \upLaTeX{} 兼容。使用 p\LaTeX-ng 编译 |
| 889 |
% 时,\pkg{ctex} 采用与 \upLaTeX{} 相同的设置。 |
| 890 |
% \end{tablenotes} |
| 891 |
% \end{threeparttable} |
| 892 |
% \end{table} |
| 893 |
% |
| 894 |
% 不同的编译方式和中文支持方式会在一定程度上影响 \CTeX{} 宏集的行为,比如宏包对 |
| 895 |
% 文档编码、字体选择、空格、标点等的处理。具体细节将在本文档后续内容中进行阐述。 |
| 896 |
% |
| 897 |
% \subsection{中文编码} |
| 898 |
% \label{subs:encoding} |
| 899 |
% |
| 900 |
% \begin{function}[rEXP,updated=2019-11-10]{GBK, UTF8} |
| 901 |
% 指明编写文档时使用的编码。\CTeX{} 宏集无法检测文档源文件的实际编码格式,因此需要 |
| 902 |
% 用户通过选项声明。如果没有显式指定,则默认采用 UTF-8 编码。 |
| 903 |
% |
| 904 |
% 使用 \XeLaTeX{}、\LuaLaTeX{} 或 \upLaTeX{} 编译时,\CTeX{} 宏集强制使用 |
| 905 |
% UTF-8 编码,此时 \opt{GBK} 选项无效;使用 (pdf)\LaTeX{} 编译时, |
| 906 |
% \CTeX{} 宏集默认使用 UTF-8 编码,但用户也可以显式声明 \opt{GBK} 选项, |
| 907 |
% 使 \CTeX{} 宏集按 GBK 编码处理文档。 |
| 908 |
% |
| 909 |
% 用户需要\emph{保证编译方式、源文件编码、宏包编码选项三者一致}。 |
| 910 |
% |
| 911 |
% \emph{我们建议编写新文档时始终使用 UTF-8 编码,而仅把 GBK 编码留给 |
| 912 |
% 历史遗留文档。} |
| 913 |
% \end{function} |
| 914 |
% |
| 915 |
% \subsection{中文字库} |
| 916 |
% \label{subs:options-CJK-font} |
| 917 |
% |
| 918 |
% 以往,为 \LaTeX{} 文档配置中文支持是一件相当繁琐的事情。默认情况下, |
| 919 |
% \CTeX{} 宏集能自动检测用户使用的编译方式(参见 \ref{subs:compile}~节)和 |
| 920 |
% 操作系统\footnote{\CTeX{} 宏集现在能够识别 macOS 及 Windows 系统, |
| 921 |
% 并将其他系统统一归为 Linux。},选择合适的底层支持和字库,从而简化配置过程。 |
| 922 |
% 自动配置的情况参见表~\ref{tab:default-font-select}。 |
| 923 |
% |
| 924 |
% \begin{table}[htbp] |
| 925 |
% \centering |
| 926 |
% \begin{threeparttable} |
| 927 |
% \caption{\CTeX{} 宏集自动配置字体策略} |
| 928 |
% \label{tab:default-font-select} |
| 929 |
% \begin{tabular}{*{5}{c}} |
| 930 |
% \toprule |
| 931 |
% & macOS Old\tnote{1} |
| 932 |
% & macOS New\tnote{2} |
| 933 |
% & Windows\tnote{3} |
| 934 |
% & 其他 \\ |
| 935 |
% \midrule |
| 936 |
% \XeLaTeX & \makecell{\pkg{xeCJK}\\华文字库} |
| 937 |
% & \makecell{\pkg{xeCJK}\\华文字库 + 苹方} |
| 938 |
% & \makecell{\pkg{xeCJK}\\中易字库 + 微软雅黑} |
| 939 |
% & \makecell{\pkg{xeCJK}\\Fandol 字库\tnote{4}} \\ |
| 940 |
% \cmidrule(lr){1-5} |
| 941 |
% \LuaLaTeX\tnote{5} |
| 942 |
% & \makecell{\pkg{LuaTeX-ja}\\华文字库} |
| 943 |
% & \makecell{\pkg{LuaTeX-ja}\\华文字库 + 苹方} |
| 944 |
% & \makecell{\pkg{LuaTeX-ja}\\中易字库 + 微软雅黑} |
| 945 |
% & \makecell{\pkg{LuaTeX-ja}\\Fandol 字库} \\ |
| 946 |
% \cmidrule(lr){1-5} |
| 947 |
% \pdfLaTeX |
| 948 |
% & 不可用 |
| 949 |
% & 不可用 |
| 950 |
% & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑\tnote{6}} |
| 951 |
% & 不可用 \\ |
| 952 |
% \cmidrule(lr){1-5} |
| 953 |
% \makecell{\LaTeX{} + \\\dvipdfmx} |
| 954 |
% & 不可用 |
| 955 |
% & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\华文字库 + 苹方} |
| 956 |
% & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑\tnote{6}} |
| 957 |
% & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\Fandol 字库} \\ |
| 958 |
% \cmidrule(lr){1-5} |
| 959 |
% \makecell{\upLaTeX{} + \\\dvipdfmx} |
| 960 |
% & 不可用 |
| 961 |
% & \makecell{\pkg{zhmetrics-uptex}\\华文字库 + 苹方} |
| 962 |
% & \makecell{\pkg{zhmetrics-uptex}\\中易字库 + 微软雅黑} |
| 963 |
% & \makecell{\pkg{zhmetrics-uptex}\\Fandol 字库} \\ |
| 964 |
% \bottomrule |
| 965 |
% \end{tabular} |
| 966 |
% \begin{tablenotes} |
| 967 |
% \item [1] Yosemite (10.10) 及以前的 macOS 系统。 |
| 968 |
% \item [2] El Capitan (10.11) 及以后的 macOS 系统。 |
| 969 |
% \item [3] 仅支持 Windows Vista 及以后的 Windows 操作系统。 |
| 970 |
% \item [4] 由马起园、苏杰、黄晨成等人开发的开源中文字体, |
| 971 |
% 参见:\url{https://www.ctan.org/pkg/fandol}。 |
| 972 |
% \item [5] \LuaLaTeX{} 编译时使用 \pkg{LuaTeX-ja} 宏包。对此, |
| 973 |
% 第 \ref{sec:lualatex-chinese}~节有特别说明。 |
| 974 |
% \item [6] 微软雅黑字体并不总是有效,这和选项 \opt{zhmap} 的取值有关。 |
| 975 |
% \end{tablenotes} |
| 976 |
% \end{threeparttable} |
| 977 |
% \end{table} |
| 978 |
% |
| 979 |
% 通常,由 \CTeX{} 宏集进行的自动配置已经足够使用,无需用户手工干预;但 |
| 980 |
% 是 \CTeX{} 仍然提供了一系列选项,供在 \CTeX{} 的自动选择机制因为 |
| 981 |
% 意外情况失效,或者在用户有特殊需求的情况下使用。\emph{除非必要,用户不 |
| 982 |
% 应使用这些选项。} |
| 983 |
% |
| 984 |
% \begin{function}[rEXP,updated=2014-03-08]{zhmap} |
| 985 |
% \begin{syntax} |
| 986 |
% zhmap = <\TTF|zhmCJK> |
| 987 |
% \end{syntax} |
| 988 |
% 指定字体映射机制。本选项只在使用 (pdf)\LaTeX{} 编译时有意义。 |
| 989 |
% \end{function} |
| 990 |
% \begin{optdesc} |
| 991 |
% \item[true] 这是该选项的默认值。^^A |
| 992 |
% \footnote{对于以键值对形式提供的选项,文档以\textbf{粗体}来表示其默认值。^^A |
| 993 |
% 下同,不再额外解释。}使用 \pkg{zhmetrics} 宏包,将 CJK 字库通过 \tn{special} |
| 994 |
% 命令映射到 \file{.ttf} 文件。 |
| 995 |
% |
| 996 |
% \item[false] 使用传统的 CJK 字库(Type 1)^^A |
| 997 |
% \footnote{使用 (pdf)\LaTeX{} 编译时,如果需要使用自定义的字体映射文件(比如需要 |
| 998 |
% 使用 \LaTeX{} + Dvips 编译),或者希望使用 Type1 字库,请禁用本选项。为此,你 |
| 999 |
% 可能需要安装 CJK 字体。参考 \pkg{zhmetrics} 宏包提供的脚本 |
| 1000 |
% \href{https://github.com/CTeX-org/ctex-kit/blob/master/zhmetrics/CTeXFonts.lua} |
| 1001 |
% {\file{CTeXFonts.lua}}。}。 |
| 1002 |
% |
| 1003 |
% \item[zhmCJK] 载入 \pkg{zhmCJK} 宏包^^A |
| 1004 |
% \footnote{\pkg{zhmCJK} 宏包基于 \pkg{zhmetrics} 和 \pkg{CJK} 宏包,提供与 |
| 1005 |
% \pkg{xeCJK} 宏包类似的用户接口。}^^A |
| 1006 |
% ,由 \pkg{zhmCJK} 宏包提供从 CJK 字库到 \file{.ttf} 的映射。 |
| 1007 |
% \end{optdesc} |
| 1008 |
% |
| 1009 |
% \begin{function}[added=2014-03-08]{fontset} |
| 1010 |
% \begin{syntax} |
| 1011 |
% fontset = <adobe|fandol|founder|mac|macnew|macold|ubuntu|windows|none|...> |
| 1012 |
% \end{syntax} |
| 1013 |
% 指定 \CTeX{} 宏集加载的字库。 |
| 1014 |
% |
| 1015 |
% 如果没有指定 \opt{fontset} 的值,\CTeX{} 宏集将自动检测用户使用的操作系统,配置 |
| 1016 |
% 相应的字体(参见表~\ref{tab:default-font-select})。 |
| 1017 |
% \end{function} |
| 1018 |
% |
| 1019 |
% \CTeX{} 预定义了以下六种中文字库。 |
| 1020 |
% |
| 1021 |
% \begin{optdesc} |
| 1022 |
% \item[adobe] 使用 Adobe 公司的四款中文字体,\emph{不支持 \pdfLaTeX}。 |
| 1023 |
% \item[fandol] 使用 Fandol 中文字体,\emph{不支持 \pdfLaTeX}。 |
| 1024 |
% \item[founder] 使用方正公司的中文字体。 |
| 1025 |
% \item[mac] 使用 macOS 系统下的字体,\emph{不支持 \pdfLaTeX},根据版本分为 |
| 1026 |
% |macnew| 和 |macold| 两种。 |
| 1027 |
% \item[macnew] 使用 El Capitan 或之后的多字重华文字体和苹方字体。 |
| 1028 |
% \item[macold] 使用 Yosemite 或之前的华文字体。 |
| 1029 |
% \item[ubuntu] 使用 Ubuntu 系统下的思源宋体、思源黑体和 \TeX{} 发行版自带的 |
| 1030 |
% 文鼎楷体,\emph{不支持 \pdfLaTeX}。 |
| 1031 |
% \item[windows] 使用 Windows 系统下的中易字体和微软雅黑字体。 |
| 1032 |
% 当使用 (pdf)\LaTeX{} 编译时,微软雅黑仅在以下两种情形有效: |
| 1033 |
% 安装有 \pkg{zhmCJK} 宏包且选项 \opt{zhmap=zhmCJK} 时,或者 |
| 1034 |
% 安装有微软雅黑的 Type1 字体且选项 \opt{zhmap=false} 时。 |
| 1035 |
% \end{optdesc} |
| 1036 |
% |
| 1037 |
% 如果不想使用 \CTeX{} 预定义的中文字库,可以设置 \opt{fontset} 为下述值之一。 |
| 1038 |
% |
| 1039 |
% \begin{optdesc} |
| 1040 |
% \item[none] 不配置中文字体,需要用户自己配置。 |
| 1041 |
% \item[\meta{name}] 这里 \meta{name} 为自定义的名字。 |
| 1042 |
% \CTeX{} 宏集将载入名为 |ctex-fontset-|\meta{name}|.def| 的文件作为字体配置 |
| 1043 |
% 文件。因此,请先保证文件的存在。可以在当前工作目录或者本地 \texttt{TDS} 目录 |
| 1044 |
% 树下合适位置建立一个名为 |ctex-fontset-|\meta{name}|.def| 的文件,在这个文件 |
| 1045 |
% 里面自定义中文字体。然后通过使用 |fontset=|\meta{name} 选项来调用它。字体配置 |
| 1046 |
% 文件的具体写法可以参考 \CTeX{} 宏集 \texttt{fontset} 目录下的字体配置文件。 |
| 1047 |
% \end{optdesc} |
| 1048 |
% |
| 1049 |
% 注意:\emph{如果希望使用 \tn{ctexset} 在导言区指定字库,则需要先在宏包/文档类选项中指定 |
| 1050 |
% \opt{fontset = none}}(这会禁用 \CTeX{} 宏集的操作系统检测功能和自动设定字库功能)。例如: |
| 1051 |
% \begin{ctexexam} |
| 1052 |
% \documentclass[fontset = none]{ctexart} |
| 1053 |
% \ctexset{fontset = founder} |
| 1054 |
% \begin{document} |
| 1055 |
% 在文档类选项中声明 \verb|fontset = none|,随后在导言区用 \verb|\ctexset| |
| 1056 |
% 指定字体。 |
| 1057 |
% \end{document} |
| 1058 |
% \end{ctexexam} |
| 1059 |
% |
| 1060 |
% \CTeX{} 宏集预定义的中文字库还定义了一些字体命令。除了在 \opt{ubuntu} 字库中没有 |
| 1061 |
% \tn{fangsong} 的定义外,所有字库都有以下四个字体命令: |
| 1062 |
% \begin{optdesc} |
| 1063 |
% \item[\tn{songti}] 宋体,CJK 等价命令 |\CJKfamily{zhsong}|。 |
| 1064 |
% \item[\tn{heiti}] 黑体,CJK 等价命令 |\CJKfamily{zhhei}|。 |
| 1065 |
% \item[\tn{fangsong}] 仿宋,CJK 等价命令 |\CJKfamily{zhfs}|。 |
| 1066 |
% \item[\tn{kaishu}] 楷书,CJK 等价命令 |\CJKfamily{zhkai}|。 |
| 1067 |
% \end{optdesc} |
| 1068 |
% 在 \opt{windows}、\opt{founder} 和 \opt{macnew} 字库中,额外定义了 \tn{lishu} |
| 1069 |
% 和 \tn{youyuan}: |
| 1070 |
% \begin{optdesc} |
| 1071 |
% \item[\tn{lishu}] 隶书,CJK 等价命令 |\CJKfamily{zhli}|。 |
| 1072 |
% \item[\tn{youyuan}] 圆体,CJK 等价命令 |\CJKfamily{zhyou}|。 |
| 1073 |
% \end{optdesc} |
| 1074 |
% 在 \opt{windows} 字库中还定义了 \tn{yahei}。出于兼容性的考虑,\tn{yahei} 命令 |
| 1075 |
% 在 \opt{macnew} 字库中也有定义,但实际调用苹方黑体: |
| 1076 |
% \begin{optdesc} |
| 1077 |
% \item[\tn{yahei}] 微软雅黑,CJK 等价命令 |\CJKfamily{zhyahei}|。 |
| 1078 |
% \end{optdesc} |
| 1079 |
% 在 \opt{macnew} 字库中,还定义了 \tn{pingfang}: |
| 1080 |
% \begin{optdesc} |
| 1081 |
% \item[\tn{pingfang}] 苹方黑体,CJK 等价命令 |\CJKfamily{zhpf}|。 |
| 1082 |
% \end{optdesc} |
| 1083 |
% |
| 1084 |
% \section{排版格式设定} |
| 1085 |
% \label{sec:format-settings} |
| 1086 |
% \subsection{文档默认字号} |
| 1087 |
% \label{subs:options-class} |
| 1088 |
% |
| 1089 |
% \begin{function}[rEXP,added=2015-05-06]{zihao} |
| 1090 |
% \begin{syntax} |
| 1091 |
% zihao = <-4|5|false> |
| 1092 |
% \end{syntax} |
| 1093 |
% 将文章默认字号(\tn{normalsize})设置为小四号字或五号字, |
| 1094 |
% 具体情况见表 \ref{tab:fontsize}。\opt{false} 禁用本功能。 |
| 1095 |
% 本选项可以用于四个 \CTeX{} 文档类和 \pkg{ctex} 宏包, |
| 1096 |
% 也可以用于 \pkg{ctexsize} 宏包。 |
| 1097 |
% |
| 1098 |
% 该选项的默认值与 \opt{scheme} 的取值有关。 |
| 1099 |
% 当 \opt{scheme = chinese} 时,对标准文档类默认值为 |5|,即设置 |
| 1100 |
% \tn{normalsize} 为五号字;对 \cls{beamer} 则为 |false|,使用文档类原有的设置。 |
| 1101 |
% 当 \opt{scheme = plain} 时,该选项不设默认值,沿用标准文档类或 \cls{beamer} 的原有设置。 |
| 1102 |
% \end{function} |
| 1103 |
% |
| 1104 |
% \begin{table}[htbp] |
| 1105 |
% \centering |
| 1106 |
% \setlength\tabcolsep{1em} |
| 1107 |
% \caption{标准字体命令与字号的对应}\label{tab:fontsize} |
| 1108 |
% \begin{tabular}{l*2{c>{\ttfamily}r}*3{>{\ttfamily}c}} |
| 1109 |
% \toprule |
| 1110 |
% & \multicolumn2c{|zihao = 5|} & \multicolumn2c{|zihao = -4|} & |
| 1111 |
% \multicolumn1c{|10pt|} & \multicolumn1c{|11pt|} & \multicolumn1c{|12pt|} \\ |
| 1112 |
% \cmidrule(lr){2-3} \cmidrule(lr){4-5} |
| 1113 |
% \cmidrule(lr){6-6} \cmidrule(lr){7-7} \cmidrule(lr){8-8} |
| 1114 |
% 字体命令 & 字号 & \si{bp} & 字号 & \si{bp} |
| 1115 |
% & \si{pt} & \si{pt} & \si{pt} \\ |
| 1116 |
% \midrule |
| 1117 |
% |\tiny| & 七号 & 5.5 & 小六 & 6.5 & ~5 & ~6 & ~6 \\ |
| 1118 |
% |\scriptsize| & 小六 & 6.5 & 六号 & 7.5 & ~7 & ~8 & ~8 \\ |
| 1119 |
% |\footnotesize| & 六号 & 7.5 & 小五 & 9~~ & ~8 & ~9 & 10 \\ |
| 1120 |
% |\small| & 小五 & 9~~ & 五号 & 10.5 & ~9 & 10 & 11 \\ |
| 1121 |
% |\normalsize| & 五号 & 10.5 & 小四 & 12~~ & 10 & 11 & 12 \\ |
| 1122 |
% |\large| & 小四 & 12~~ & 小三 & 15~~ & 12 & 12 & 14 \\ |
| 1123 |
% |\Large| & 小三 & 15~~ & 小二 & 18~~ & 14 & 14 & 17 \\ |
| 1124 |
% |\LARGE| & 小二 & 18~~ & 二号 & 22~~ & 17 & 17 & 20 \\ |
| 1125 |
% |\huge| & 二号 & 22~~ & 小一 & 24~~ & 20 & 20 & 25 \\ |
| 1126 |
% |\Huge| & 一号 & 26~~ & 一号 & 26~~ & 25 & 25 & 25 \\ |
| 1127 |
% \bottomrule |
| 1128 |
% \end{tabular} |
| 1129 |
%\end{table} |
| 1130 |
% |
| 1131 |
% \begin{function}[rEXP]{10pt, 11pt, 12pt} |
| 1132 |
% \CTeX{} 文档类是在 \LaTeX{} 标准文档类之上开发的。因此,除了可以使用 \CTeX{} |
| 1133 |
% 宏包定义的字号选项之外,还可以使用标准文档类的同类选项(\opt{10pt}、\opt{11pt} |
| 1134 |
% 和 \opt{12pt})。在使用这些来自标准文档类的选项的时候,\CTeX{} 文档类的字号 |
| 1135 |
% 选项会被抑制。亦即,在 \opt{zihao} 选项之后设置 \opt{10pt} 选项, |
| 1136 |
% \opt{zihao} 选项将不再起作用。 |
| 1137 |
% \end{function} |
| 1138 |
% |
| 1139 |
% 标准文档类的其他选项在 \CTeX{} 文档类中依旧有效。例如,设置纸张大小和方向的 |
| 1140 |
% \opt{a4paper} 和 \opt{landscape},设置单双面的 \opt{oneside} 和 |
| 1141 |
% \opt{twoside} 等。\CTeX{} 会将这些选项传给标准文档类^^A |
| 1142 |
% \footnote{事实上,\LaTeX{} 在文档类中的选项是全局设定的,除了对使用的文档类有 |
| 1143 |
% 影响外,也可能会影响到随后使用的宏包。如果这些宏包中有某些选项出现在文档类的 |
| 1144 |
% 选项列表中,那么该选项将会被自动激活。}。 |
| 1145 |
% |
| 1146 |
% \subsection{章节标题风格} |
| 1147 |
% \label{subs:options-heading} |
| 1148 |
% |
| 1149 |
% \begin{function}[rEXP,added=2014-03-08]{heading} |
| 1150 |
% \begin{syntax} |
| 1151 |
% heading = <\TFF> |
| 1152 |
% \end{syntax} |
| 1153 |
% 本选项只能在调用 \pkg{ctex.sty} 时作为宏包选项使用。 |
| 1154 |
% |
| 1155 |
% \CTeX{} 宏集提供了一套用于修改文档章节标题格式的接口。该选项用于选择是否 |
| 1156 |
% 启用该功能。详细的设置方法请参见第 \ref{subs:pagestyle}~节和第 \ref{sec:secstyle}~节。 |
| 1157 |
% \end{function} |
| 1158 |
% |
| 1159 |
% \CTeX{} 宏集提供的四个文档类总是启用该功能。如果在 \pkg{ctex.sty} 下启用该选项, |
| 1160 |
% 将会检查当前是否使用 \LaTeX{} 标准文档类。 |
| 1161 |
% 若然,则该选项将会使得 \pkg{ctex.sty} 宏包的行为和 \CTeX{} 宏集提供的 |
| 1162 |
% 四个中文文档类\emph{完全}一致;若不然,则会根据 \tn{chapter} |
| 1163 |
% 是否有定义来使用 \cls{ctexbook} 或者 \cls{ctexart} 的标题设置。 |
| 1164 |
% |
| 1165 |
% \begin{function}[rEXP]{sub3section, sub4section} |
| 1166 |
% 修改 \tn{paragraph} 和 \tn{subparagraph} 的格式。 |
| 1167 |
% |
| 1168 |
% 默认情况下,\tn{paragraph} 和 \tn{subparagraph} 会将标题与随后的正文 |
| 1169 |
% 排版在同一个段落。启用 \opt{sub3section} 会将 \tn{paragraph} 的格式修改为 |
| 1170 |
% 类似 \tn{section} 的格式,并将 \tn{subparagraph} 的格式修改为原本 \tn{paragraph} |
| 1171 |
% 的格式。启用 \opt{sub4section} 会将 \tn{paragraph} 和 \tn{subparagraph} 的格式 |
| 1172 |
% 都修改为类似 \tn{section} 的格式。 |
| 1173 |
% |
| 1174 |
% 启用该选项通常还需要将计数器 |secnumdepth| 的值为设置为 |4| 或 |5|。 |
| 1175 |
% |
| 1176 |
% 具体格式可参考 \ref{subsec:sec-spacing}~小节中的 \opt{runin} 和 \opt{afterskip} 选项。 |
| 1177 |
% |
| 1178 |
% 注意,上述两个选项只有在非 \cls{beamer} 文档类下 \opt{heading} 选项启用的时候 |
| 1179 |
% 才有意义。亦即,只有在使用除了 \cls{ctexbeamer} 的三个 \CTeX{} 文档类或启用了 |
| 1180 |
% \opt{heading} 的 \pkg{ctex.sty} 的时候才有意义。 |
| 1181 |
% \end{function} |
| 1182 |
% |
| 1183 |
% \subsection{排版方案选项} |
| 1184 |
% \label{subs:options-type-style} |
| 1185 |
% |
| 1186 |
% \begin{function}[rEXP,added=2015-04-15]{scheme} |
| 1187 |
% \begin{syntax} |
| 1188 |
% scheme = <(chinese)|plain> |
| 1189 |
% \end{syntax} |
| 1190 |
% 选择文章的排版方案,预设有 \opt{chinese} 和 \opt{plain} 两种方案。 |
| 1191 |
% \end{function} |
| 1192 |
% \begin{optdesc}[itemsep=\medskipamount] |
| 1193 |
% \item[chinese] 对 \cls{beamer} 以外的文档类,调整默认字号为五号字,并调 |
| 1194 |
% 整行距为 |1.3|;汉化文档中的标题名字(如“图”、“表”、“目录”和“参 |
| 1195 |
% 考文献”等,见 \ref{subs:capname}~节); |
| 1196 |
% 在 \opt{heading = true} 的情况下^^A |
| 1197 |
% \footnote{使用 \CTeX{} 文档类,或者使用 \pkg{ctex} 宏包且开启该选项时。}^^A |
| 1198 |
% (\ref{subs:options-heading}~节),还会将章节标题的风格修改为 |
| 1199 |
% 中文样式(见 \ref{sec:secstyle}~节)。 |
| 1200 |
% |
| 1201 |
% 当关闭 \opt{heading} 选项的 \pkg{ctex} 宏包与标准文档类或其衍生文档类 |
| 1202 |
% 联用时,会载入 \pkg{indentfirst} 宏包,以实现章节标题后的段首缩进。 |
| 1203 |
% \item[plain] 不调整默认字号和行距,不会汉化文档中的标题名字,也不会将章节 |
| 1204 |
% 标题风格修改为中文样式,同时不会调整 \tn{pagestyle},并禁用 \opt{autoindent} |
| 1205 |
% 选项。事实上,此时的 \CTeX{} 宏集只提供了中文支持功能,而不对文章版式进行任何修改。 |
| 1206 |
% \end{optdesc} |
| 1207 |
% |
| 1208 |
% \begin{function}[updated=2014-04-11]{punct} |
| 1209 |
% \begin{syntax} |
| 1210 |
% punct = <(quanjiao)|banjiao|kaiming|CCT|plain> |
| 1211 |
% \end{syntax} |
| 1212 |
% 设置标点处理格式。预定义好的格式有: |
| 1213 |
% \end{function} |
| 1214 |
% \begin{optdesc} |
| 1215 |
% \item[quanjiao] 全角式:所有标点占一个汉字宽度,相邻两个标点占 1.5 汉字宽度; |
| 1216 |
% \item[banjiao] 半角式:所有标点占半个汉字宽度; |
| 1217 |
% \item[kaiming] 开明式:句末点号^^A |
| 1218 |
% \footnote{标点符号分为标号与点号。点号分为两类,一共七种:句末点号有^^A |
| 1219 |
% 句号、问号和叹号;句内点号有逗号、顿号、冒号和分号。}用占一个汉字宽度,标^^A |
| 1220 |
% 号和句内点号占半个汉字宽度; |
| 1221 |
% \item[CCT] CCT 式:所有标点符号的宽度略小于一个汉字宽度; |
| 1222 |
% \item[plain] 原样(不调整标点间距)。 |
| 1223 |
% \end{optdesc} |
| 1224 |
% |
| 1225 |
% \begin{function}[updated=2014-03-08]{space} |
| 1226 |
% \begin{syntax} |
| 1227 |
% space = <\TF|(auto)> |
| 1228 |
% \end{syntax} |
| 1229 |
% 是否在生成的 PDF 中保留汉字后面的空格。该选项仅在使用 \XeLaTeX{}/(pdf)\LaTeX{} 编译时有效。 |
| 1230 |
% \end{function} |
| 1231 |
% |
| 1232 |
% \begin{optdesc} |
| 1233 |
% \item[true] 总是保留汉字后的空格。此时,用户需要自行在行尾加上~|%|~处理换行产生 |
| 1234 |
% 的空格\footnote{\LaTeX{} 将单个换行视作一个空格。}。 |
| 1235 |
% \item[false] 使用 (pdf)\LaTeX{} 编译时:总是忽略掉汉字后面的空格,不论汉字后是什么; |
| 1236 |
% 使用 \XeLaTeX{} 编译时,等同于 \opt{auto} 的效果。不建议使用该选项。 |
| 1237 |
% \item[auto] 根据空格后面的情况决定是否保留:如果空格后面是汉字,则忽略该 |
| 1238 |
% 空格,否则保留。 |
| 1239 |
% \end{optdesc} |
| 1240 |
% |
| 1241 |
% 例如,使用 |
| 1242 |
% \begin{ctexexam} |
| 1243 |
% \ctexset{space=true} |
| 1244 |
% 汉字 分词 |
| 1245 |
% 技术 English |
| 1246 |
% \end{ctexexam} |
| 1247 |
% 将得到“{\ctexset{space=true}汉字 分词 技术 English}”;使用 |
| 1248 |
% \begin{ctexexam} |
| 1249 |
% \ctexset{space=auto} |
| 1250 |
% 汉字 分词 |
| 1251 |
% 技术 English |
| 1252 |
% \end{ctexexam} |
| 1253 |
% 则会得到“{\ctexset{space=auto}汉字 分词 技术 English}”。 |
| 1254 |
% |
| 1255 |
% \emph{使用 \textup{\LuaLaTeX{} 及 \upLaTeX} 编译的时候,该选项无效:汉字间的 |
| 1256 |
% 空格以及汉字与西文字符之间的空格总是有效,不会被忽略,但可以自动忽略掉由换行 |
| 1257 |
% 产生的空格。} |
| 1258 |
% |
| 1259 |
% \begin{function}[rEXP,added=2014-04-23]{linespread} |
| 1260 |
% \begin{syntax} |
| 1261 |
% linespread = <数值> |
| 1262 |
% \end{syntax} |
| 1263 |
% 接受一个浮点数值,设置行距倍数。本选项的初始值与 \opt{scheme} 有关。 |
| 1264 |
% \end{function} |
| 1265 |
% \begin{optdesc} |
| 1266 |
% \item[scheme = chinese] 对标准文档类初始值为 $1.3$,即 $1.3$ 倍行距。此 |
| 1267 |
% 时,相邻两行的基线(\tn{baselineskip})距离为 $1.3\times 1.2=1.56$ 倍字体 |
| 1268 |
% 高度。对 \cls{beamer} 不改变行距,即使用默认的单倍行距。 |
| 1269 |
% |
| 1270 |
% \item[scheme = plain] \CTeX{} 宏集默认不调整行距倍数,文档中的行距由所选文档类和 |
| 1271 |
% 其他宏包或用户设置决定。 |
| 1272 |
% \end{optdesc} |
| 1273 |
% |
| 1274 |
% \begin{function}[added=2014-03-13]{autoindent} |
| 1275 |
% \begin{syntax} |
| 1276 |
% autoindent = <\TTF|数值|带单位的数值> |
| 1277 |
% \end{syntax} |
| 1278 |
% 在字体大小发生变化时,是否自动调整段首缩进(\tn{parindent})的大小。 |
| 1279 |
% \end{function} |
| 1280 |
% \begin{optdesc} |
| 1281 |
% \item[\meta{数值或带单位的数值}] 用于设置段首缩进的长度。如果不带单位,则默认 |
| 1282 |
% 单位是单个汉字字宽 \tn{ccwd};如果带单位,则使用该单位。 |
| 1283 |
% 若要显式使用 \tn{ccwd} 为单位,则必须在导言区进行设置。 |
| 1284 |
% |
| 1285 |
% \item[true] 等价于设置 \opt{autoindent = 2} 或 |
| 1286 |
% 在导言区设置 \opt{autoindent = 2\tn{ccwd}}。 |
| 1287 |
% |
| 1288 |
% \item[false] 禁用自动调整功能,可以设置固定长度的段首缩进。如设置每段缩进 40 点: |
| 1289 |
% \begin{ctexexam} |
| 1290 |
% \ctexset{autoindent=false} |
| 1291 |
% \setlength\parindent{40pt} |
| 1292 |
% \end{ctexexam} |
| 1293 |
% \end{optdesc} |
| 1294 |
% |
| 1295 |
% \begin{function}[EXP,added=2014-03-26]{linestretch} |
| 1296 |
% \begin{syntax} |
| 1297 |
% linestretch = <数值或长度> |
| 1298 |
% \end{syntax} |
| 1299 |
% \opt{linestretch} 是一个比较特殊的选项,它用来设置汉字之间弹性间距的弹性程 |
| 1300 |
% 度。如果有单位,则可以在选项中直接写;如果是数字,单位则是汉字宽度 |
| 1301 |
% \tn{ccwd} 的倍数。 |
| 1302 |
% \end{function} |
| 1303 |
% |
| 1304 |
% 如果行宽不是汉字宽度的整数倍,为了让段落左右两端对齐,自然就要求伸展汉字之 |
| 1305 |
% 间的间距,而 \opt{linestretch} 选项就是设置每行总的允许伸行量。初始值是允 |
| 1306 |
% 许每行伸行一个汉字的宽度 \tn{ccwd},并且此宽度能根据字号变化动态调整。 |
| 1307 |
% |
| 1308 |
% 过小的 \opt{linestretch} 可能导致段落文字右侧可能参差不齐;较大的 |
| 1309 |
% \opt{linestretch} 选项则可以帮助拥有较长不可断行内容的复杂段落方便地断行, |
| 1310 |
% 而不会产生大量编译警告;但很大的 \opt{linestretch} 则会掩盖段落不良断行产 |
| 1311 |
% 生的坏盒子警告。 |
| 1312 |
% |
| 1313 |
% 如果将 \opt{linestretch} 选项的值设置为 \tn{maxdimen},则可以禁止按字号自 |
| 1314 |
% 动修改每行的允许伸长量。此时汉字间的弹性间距则固定为 \tn{baselineskip} 的 |
| 1315 |
% $0.08$ 倍。 |
| 1316 |
% |
| 1317 |
% \section{文档汉化} |
| 1318 |
% \label{sec:chinese-localization} |
| 1319 |
% \subsection{日期汉化} |
| 1320 |
% |
| 1321 |
% \CTeX 宏包对显示当前日期的 \tn{today} 命令进行了汉化,使之以中文的方式显示今 |
| 1322 |
% 天的日期。如本文档编译时的日期是“\today”。 |
| 1323 |
% |
| 1324 |
% \begin{function}[EXP]{today} |
| 1325 |
% \begin{syntax} |
| 1326 |
% today = <(small)|big|old> |
| 1327 |
% \end{syntax} |
| 1328 |
% 该选项用来控制 \tn{today} 命令的输出格式: |
| 1329 |
% \begin{optdesc} |
| 1330 |
% \item[small] \ctexset{today=small} |
| 1331 |
% 效果为“\today”。使用阿拉伯数字和汉字的日期格式。 |
| 1332 |
% \item[big] \ctexset{today=big} |
| 1333 |
% 效果为“\today”。使用全汉字的日期格式。 |
| 1334 |
% \item[old] \ctexset{today=old} |
| 1335 |
% 效果为“\today”。使用文档原来的(英文)日期格式。 |
| 1336 |
% \ctexset{today=small} ^^A NOTE(Liam): 复原设定是好习惯。 |
| 1337 |
% \end{optdesc} |
| 1338 |
% \end{function} |
| 1339 |
% |
| 1340 |
% 设置日期格式使用 \tn{ctexset} 命令完成,例如设置全汉字的日期格式: |
| 1341 |
% \begin{ctexexam} |
| 1342 |
% \ctexset{today=big} |
| 1343 |
% \end{ctexexam} |
| 1344 |
% |
| 1345 |
% \CTeX 宏包的中文日期功能实际上是调用 \pkg{zhnumber} 宏包完成的。如果需要更 |
| 1346 |
% 多有关日期、时间的命令和更复杂的设置,可以查阅 \pkg{zhnumber} 宏包的文档。 |
| 1347 |
% |
| 1348 |
% \subsection{文档标题汉化} |
| 1349 |
% \label{subs:capname} |
| 1350 |
% |
| 1351 |
% 这里主要介绍由 \opt{scheme} 选项(\ref{subs:options-type-style}~节)控制 |
| 1352 |
% 的文档标题汉化功能。 |
| 1353 |
% |
| 1354 |
% 设置文档标题名的示例可见例~\ref{exam:capname}。下面的选项(如 |
| 1355 |
% \opt{contentsname})主要用来重新定义与选项同名的宏(如 \tn{contentsname})的 |
| 1356 |
% 定义。 |
| 1357 |
% |
| 1358 |
% \begin{defaultcapconfig} |
| 1359 |
% |
| 1360 |
% \begin{function}[EXP]{contentsname} |
| 1361 |
% \begin{syntax} |
| 1362 |
% contentsname = <名字> |
| 1363 |
% \end{syntax} |
| 1364 |
% 设置目录标题名 \tn{contentsname}。中文默认为“\contentsname”。 |
| 1365 |
% \end{function} |
| 1366 |
% |
| 1367 |
% \begin{function}[EXP]{listfigurename} |
| 1368 |
% \begin{syntax} |
| 1369 |
% listfigurename = <名字> |
| 1370 |
% \end{syntax} |
| 1371 |
% 设置插图目录标题名 \tn{listfigurename}。中文默认为“\listfigurename”。 |
| 1372 |
% \end{function} |
| 1373 |
% |
| 1374 |
% \begin{function}[EXP]{listtablename} |
| 1375 |
% \begin{syntax} |
| 1376 |
% listtablename = <名字> |
| 1377 |
% \end{syntax} |
| 1378 |
% 设置表格目录标题名 \tn{listtablename}。中文默认为“\listtablename”。 |
| 1379 |
% \end{function} |
| 1380 |
% |
| 1381 |
% \begin{function}[EXP]{figurename} |
| 1382 |
% \begin{syntax} |
| 1383 |
% figurename = <名字> |
| 1384 |
% \end{syntax} |
| 1385 |
% 设置图片环境标题名 \tn{figurename}。中文默认为“\figurename”。 |
| 1386 |
% \end{function} |
| 1387 |
% |
| 1388 |
% \begin{function}[EXP]{tablename} |
| 1389 |
% \begin{syntax} |
| 1390 |
% tablename = <名字> |
| 1391 |
% \end{syntax} |
| 1392 |
% 设置表格环境标题名 \tn{tablename}。中文默认为“\tablename”。 |
| 1393 |
% \end{function} |
| 1394 |
% |
| 1395 |
% \begin{function}[EXP]{abstractname} |
| 1396 |
% \begin{syntax} |
| 1397 |
% abstractname = <名字> |
| 1398 |
% \end{syntax} |
| 1399 |
% 设置摘要 \env{abstract} 环境标题名 \tn{abstractname}。中文默认 |
| 1400 |
% 为“\abstractname”。注意 \cls{book} 类没有摘要,该选项无效。 |
| 1401 |
% \end{function} |
| 1402 |
% |
| 1403 |
% \begin{function}[EXP]{indexname} |
| 1404 |
% \begin{syntax} |
| 1405 |
% indexname = <名字> |
| 1406 |
% \end{syntax} |
| 1407 |
% 设置索引标题名 \tn{indexname}。中文默认为“\indexname”。 |
| 1408 |
% \end{function} |
| 1409 |
% |
| 1410 |
% \begin{function}[EXP]{appendixname} |
| 1411 |
% \begin{syntax} |
| 1412 |
% appendixname = <名字> |
| 1413 |
% \end{syntax} |
| 1414 |
% 设置附录标题名 \tn{appendixname}。中文默认为“\appendixname”。 |
| 1415 |
% \end{function} |
| 1416 |
% |
| 1417 |
% \begin{function}[EXP]{bibname} |
| 1418 |
% \begin{syntax} |
| 1419 |
% bibname = <名字> |
| 1420 |
% \end{syntax} |
| 1421 |
% 设置参考文献标题名。中文默认为“\refname”。 |
| 1422 |
% |
| 1423 |
% 在标准文档类中 \cls{article} 的参考文献名使用宏 \tn{refname},而 |
| 1424 |
% \cls{book} 和 \cls{report} 使用宏 \tn{bibname}。本选项会根据标准文档类的不同,自动 |
| 1425 |
% 设定 \tn{refname} 或是 \tn{bibname}。因此,对于标准文档类及对应的 \CTeX{} 文档类 |
| 1426 |
% 可以统一地使用 \opt{bibname} 选项来控制参考文献标题名。 |
| 1427 |
% |
| 1428 |
% 对于 \cls{beamer} 及对应的 \cls{ctexbeamer} 来说,它们同时具有宏 \tn{bibname} 和 |
| 1429 |
% 宏 \tn{refname}。本选项仅控制其中的 \tn{bibname}; |
| 1430 |
% \tn{refname} 则交由 \opt{refname} 选项控制。 |
| 1431 |
% \end{function} |
| 1432 |
% |
| 1433 |
% \begin{function}[EXP]{proofname} |
| 1434 |
% \begin{syntax} |
| 1435 |
% proofname = <名字> |
| 1436 |
% \end{syntax} |
| 1437 |
% 设置证明环境的名称 \tn{proofname}。中文默认为“\proofname”。 |
| 1438 |
% \end{function} |
| 1439 |
% |
| 1440 |
% 如果使用 \cls{ctexbeamer} 文档类或者在 \cls{beamer} 文档类下使用 \pkg{ctex} 包, |
| 1441 |
% 还会汉化常用定理类环境的诸如“定义”、“定理”和“引理”等名称。此时,还有下列 |
| 1442 |
% 三个选项。 |
| 1443 |
% |
| 1444 |
% \begin{function}[EXP]{refname} |
| 1445 |
% \begin{syntax} |
| 1446 |
% refname = <名字> |
| 1447 |
% \end{syntax} |
| 1448 |
% 设置参考文献标题名 \tn{refname}。中文默认为“\refname”。 |
| 1449 |
% |
| 1450 |
% 注意,三个标准文档类(及相应的 \CTeX{} 文档类)的参考文献标题名由 \opt{bibname} 选项 |
| 1451 |
% 统一设置,本选项仅适用于 \cls{beamer} 及其对应的 \cls{ctexbeamer}。 |
| 1452 |
% 在三个标准文档类(及相应的 \CTeX{} 文档类)中使用 \opt{refname} 选项会报错。 |
| 1453 |
% \end{function} |
| 1454 |
% |
| 1455 |
% \begin{function}[EXP]{algorithmname} |
| 1456 |
% \begin{syntax} |
| 1457 |
% algorithmname = <名字> |
| 1458 |
% \end{syntax} |
| 1459 |
% 设置算法环境标题名 \tn{algorithmname}。中文默认为“算法”。 |
| 1460 |
% \end{function} |
| 1461 |
% |
| 1462 |
% \begin{function}[EXP]{continuation} |
| 1463 |
% \begin{syntax} |
| 1464 |
% continuation = <名字> |
| 1465 |
% \end{syntax} |
| 1466 |
% 设置 \cls{beamer} 可断页的帧在续页标题中的延续标识 \tn{insertcontinuationtext}。 |
| 1467 |
% 中文默认为“(续)”。 |
| 1468 |
% \end{function} |
| 1469 |
% |
| 1470 |
% \end{defaultcapconfig} |
| 1471 |
% |
| 1472 |
% \subsection{页面格式设置与汉化} |
| 1473 |
% \label{subs:pagestyle} |
| 1474 |
% |
| 1475 |
% 页面格式设置与汉化的功能(及章节标题样式设置功能,见第 \ref{sec:secstyle} 节)^^A |
| 1476 |
% 由 \pkg{ctexheading} 宏包完成。加载该宏包时,或者使用 \CTeX{} 文档类时,^^A |
| 1477 |
% 或者是使用 \pkg{ctex} 宏包并设定选项 \opt{heading = true} 时,相关功能被激活。 |
| 1478 |
% 此时,整个文档的页面格式(page style)被设定为 |headings|,即相当于设置了 |
| 1479 |
% \begin{frameverb} |
| 1480 |
% \pagestyle{headings} |
| 1481 |
% \end{frameverb} |
| 1482 |
% 在页眉中显示当前章节的编号与标题。 |
| 1483 |
% |
| 1484 |
% 同时,\CTeX 宏包也会对默认的 |headings| 页面格式进行修改,使之调用 |
| 1485 |
% \tn{CTEXthechapter}、\tn{CTEXthesection} 等宏来正确显示中文的章节编号。 |
| 1486 |
% |
| 1487 |
% \CTeX 宏包的默认页面格式设置是经过汉化的 |headings|,其基本效果如本文档所 |
| 1488 |
% 示,只在页眉一侧显示章节编号和标题,另一侧显示页码。 |
| 1489 |
% |
| 1490 |
% 更复杂的页面格式可以通过调用 \pkg{fancyhdr}、\pkg{titleps} 等宏包来设 |
| 1491 |
% 置。\CTeX 宏包同时也为这些自定义页面格式 |
| 1492 |
% 的包提供了以下宏供使用: |
| 1493 |
% \begin{itemize} |
| 1494 |
% \item \tn{CTEXthechapter}、\tn{CTEXthesection} 等章节编号(见 |
| 1495 |
% \ref{subsec:sec-commands}~小节)。它们用来代替英文文档类中的 |
| 1496 |
% \tn{thechapter}、\tn{thesection} 等宏。 |
| 1497 |
% |
| 1498 |
% \item \tn{leftmark}、\tn{rightmark},它们是在使用章节标题命令后,自动设置的 |
| 1499 |
% 宏。它们实际是在与章节标题命令对应的标记命令 |
| 1500 |
% \tn{chaptermark}、\tn{sectionmark} 中调用 \tn{markright} 或 \tn{markboth} 生 |
| 1501 |
% 成的。 |
| 1502 |
% \end{itemize} |
| 1503 |
% 有关 \LaTeX 页面标记的含义与使用细节,已经超出了本文档讨论的范围。可以参考 |
| 1504 |
% \cite[Chapter~23]{knuthtex1986}、\cite[\S4.3, \S4.4]{mittelbach2004} 等书籍。 |
| 1505 |
% |
| 1506 |
% 这里举一个例子,说明通过重定义 \tn{sectionmark},在 \cls{ctexart} 文档类中的 |
| 1507 |
% 标准 |headings| 页面格式下控制页眉的方式: |
| 1508 |
% \begin{ctexexam} |
| 1509 |
% \documentclass{ctexart} |
| 1510 |
% \pagestyle{headings} |
| 1511 |
% \ctexset{section={ |
| 1512 |
% name={第,节}, |
| 1513 |
% number=\arabic{section}, |
| 1514 |
% } |
| 1515 |
% } |
| 1516 |
% \renewcommand\sectionmark[1]{% |
| 1517 |
% \markright{\CTEXifname{\CTEXthesection——}{}#1}} |
| 1518 |
% |
| 1519 |
% \begin{document} |
| 1520 |
% |
| 1521 |
% \section{天地玄黄} |
| 1522 |
% \newpage |
| 1523 |
% |
| 1524 |
% \section{宇宙洪荒} |
| 1525 |
% |
| 1526 |
% \end{document} |
| 1527 |
% \end{ctexexam} |
| 1528 |
% 在上例中,我们设置了页眉的形式是用破折号分开的节编号与节标题,即“第 1 节 |
| 1529 |
% ——天地玄黄”、“第 2 节——宇宙洪荒”。 |
| 1530 |
% |
| 1531 |
% \CTeX 宏包已经对 \pkg{fancyhdr} 宏包进行了补丁,载入 \pkg{fancyhdr} 后,其 |
| 1532 |
% |fancy| 页面格式将使用 \tn{CTEXthechapter} 等宏显示中文章节编号。 |
| 1533 |
% |
| 1534 |
% 关于 \pkg{fancyhdr} 的具体用法可以参见其宏包手册。通常也只要像在标准的英文文 |
| 1535 |
% 档类中使用 \pkg{fancyhdr} 一样定义页眉页脚格式即可,并不需要额外的定义。 |
| 1536 |
% |
| 1537 |
% 下面我则给出一个与前例类似而稍复杂的例子,展示如何在文档中设置页眉内容与页眉 |
| 1538 |
% 的格式。 |
| 1539 |
% \begin{ctexexam} |
| 1540 |
% \documentclass{ctexart} |
| 1541 |
% \ctexset{section={ |
| 1542 |
% name={第,节}, |
| 1543 |
% number=\arabic{section}, |
| 1544 |
% } |
| 1545 |
% } |
| 1546 |
% \usepackage{fancyhdr} |
| 1547 |
% \fancyhf{} |
| 1548 |
% \lhead{\textnormal{\kaishu\rightmark}} |
| 1549 |
% \rhead{--\ \thepage\ --} |
| 1550 |
% \pagestyle{fancy} |
| 1551 |
% % \sectionmark 的重定义需要在 \pagestyle 之后生效 |
| 1552 |
% \renewcommand\sectionmark[1]{% |
| 1553 |
% \markright{\CTEXifname{\CTEXthesection——}{}#1}} |
| 1554 |
% |
| 1555 |
% \begin{document} |
| 1556 |
% |
| 1557 |
% \section{天地玄黄} |
| 1558 |
% \newpage |
| 1559 |
% |
| 1560 |
% \section{宇宙洪荒} |
| 1561 |
% |
| 1562 |
% \end{document} |
| 1563 |
% \end{ctexexam} |
| 1564 |
% 本例的页眉效果大致如下(有页眉线): |
| 1565 |
% \begin{trivlist}\item |
| 1566 |
% \textnormal{\kaishu 第 1 节——天地玄黄}\hfill -- 1 --\par |
| 1567 |
% \smallskip\hrule |
| 1568 |
% \end{trivlist} |
| 1569 |
% |
| 1570 |
% \section{章节标题样式设置} |
| 1571 |
% \label{sec:secstyle} |
| 1572 |
% |
| 1573 |
% \CTeX{} 宏集对 \LaTeX{} 的标准文档类(\cls{article}、\cls{report}、 |
| 1574 |
% \cls{book})和 \cls{beamer} 进行了章节标题样式设置功能的扩充。 |
| 1575 |
% 章节标题样式设置功能(及页面格式设置与汉化功能,见第 \ref{subs:pagestyle} 节)^^A |
| 1576 |
% 由 \pkg{ctexheading} 宏包完成。加载该宏包时,或者使用 \CTeX{} 文档类时,^^A |
| 1577 |
% 或者是使用 \pkg{ctex} 宏包并设定选项 \opt{heading = true} 时,相关功能被激活。 |
| 1578 |
% 其中,独立使用 \pkg{ctexheading} 宏包时,本节介绍各选项的默认值与指定 |
| 1579 |
% \opt{scheme = plain} 时相同。 |
| 1580 |
% |
| 1581 |
% 本节涉及的所有选项均需使用 \tn{ctexset} 命令设置。 |
| 1582 |
% |
| 1583 |
% \changes{v2.0}{2015/03/21}{\tn{CTEXsetup}, \tn{CTEXoptions} 是过时命令。} |
| 1584 |
% |
| 1585 |
% 章节标题的样式选项是分层设置的。顶层的选项是章节标题名称(例如 |section|), |
| 1586 |
% 次一层的选项是章节标题的样式(例如 \opt{nameformat})。章节标题名称包括 |
| 1587 |
% |part|, |chapter|, |section|, |subsection|, |subsubsection|, |paragraph|, |
| 1588 |
% |subparagraph|。可用的样式选项包括: |
| 1589 |
% \begin{itemize} |
| 1590 |
% \item 编号相关(\ref{subsec:sec-number}~小节): |
| 1591 |
% \opt{numbering}, \opt{name}, \opt{number} |
| 1592 |
% \item 格式相关(\ref{subsec:sec-format}~小节): |
| 1593 |
% \opt{format}, \opt{nameformat}, \opt{numberformat}, \opt{titleformat}, |
| 1594 |
% \opt{aftername}, \opt{aftertitle}, \opt{pagestyle} |
| 1595 |
% \item 间距、缩进相关(\ref{subsec:sec-spacing}~小节): |
| 1596 |
% \opt{runin}, \opt{hang}, \opt{indent}, \opt{beforeskip}, \opt{afterskip}, |
| 1597 |
% \opt{fixskip}, \opt{break}, \opt{afterindent} |
| 1598 |
% \item 目录、附录相关(\ref{subsec:sec-toc-appendix}~小节): |
| 1599 |
% \opt{tocline}, \opt{lofskip}, \opt{lotskip}, \opt{appendix/numbering}, |
| 1600 |
% \opt{appendix/name}, \opt{appendix/number} |
| 1601 |
% \end{itemize} |
| 1602 |
% |
| 1603 |
% 注意,对 \cls{article} 及其衍生的 \cls{ctexart} 等文档类,没有 |chapter| |
| 1604 |
% 级别的标题;而对于 \cls{beamer} 文档类,这些选项控制的是由 \tn{partpage}, |
| 1605 |
% \tn{sectionpage} 和 \tn{subsectionpage} 产生的标题样式,此时只有 |part|, |
| 1606 |
% |section| 和 |subsection| 这三层级别,并且 \opt{runin}, \opt{afterindent}, |
| 1607 |
% \opt{fixskip}, \opt{hang}, \opt{break} 和 \opt{tocline} 这六个选项无效。 |
| 1608 |
% |
| 1609 |
% 多层选项之间用斜线分开,例如,\opt{part/name} 选项设置 \tn{part} 标题的在数 |
| 1610 |
% 字前后的名称,而 \opt{section/number} 选项设置 \tn{section} 标题的数字类型。 |
| 1611 |
% |
| 1612 |
% 使用 \tn{ctexset} 设置多级选项时,还可以在同一个上级选项下设置多个下级选项。 |
| 1613 |
% 例如,同时设置 |part| 一级标题的 \opt{pagestyle} 选项,|chapter| 一级标题的 |
| 1614 |
% \opt{format} 与 \opt{pagestyle} 选项和 |section| 一级标题的 \opt{name} 与 |
| 1615 |
% \opt{number} 选项: |
| 1616 |
% \begin{ctexexam} |
| 1617 |
% \ctexset { |
| 1618 |
% part/pagestyle = empty, |
| 1619 |
% chapter = { |
| 1620 |
% format = \raggedright, |
| 1621 |
% pagestyle = empty, |
| 1622 |
% }, |
| 1623 |
% section = { |
| 1624 |
% name = {第,节}, |
| 1625 |
% number = \chinese{section}, |
| 1626 |
% } |
| 1627 |
% } |
| 1628 |
% \end{ctexexam} |
| 1629 |
% |
| 1630 |
% \subsection{编号相关} |
| 1631 |
% \label{subsec:sec-number} |
| 1632 |
% |
| 1633 |
% \begin{function}[EXP,added=2015-06-21]{part/numbering, chapter/numbering, |
| 1634 |
% section/numbering, subsection/numbering, subsubsection/numbering, |
| 1635 |
% paragraph/numbering, subparagraph/numbering} |
| 1636 |
% \begin{syntax} |
| 1637 |
% numbering = \TTF |
| 1638 |
% \end{syntax} |
| 1639 |
% 控制是否对\emph{不带星号}的章节标题进行编号。 |
| 1640 |
% 各级标题的默认值均为 \opt{true}。 |
| 1641 |
% |
| 1642 |
% \LaTeX{} 标准的章节标题命令(如 \tn{section})大体上完成四项工作: |
| 1643 |
% 输出标题内容、对标题编号(计数器增加 1)、将标题列入目录(若调用了 |
| 1644 |
% \pkg{hyperref} 宏包还会添加 PDF 书签)、更新页眉页脚标记。带星号的 |
| 1645 |
% 章节标题命令(如 \tn{section*})只简单地输出章节标题内容,但不对标题编号, |
| 1646 |
% 不将标题列入目录或 PDF 书签,也不写入页眉页脚标记。与之不同的是, |
| 1647 |
% 本选项仅仅是否对\emph{不带星号}的章节标题进行编号。因此,当设置本选项为 |
| 1648 |
% \opt{false} 时,除了不对标题编号以外,其余功能与正常标题一致:可以 |
| 1649 |
% 编入目录,并生成正确的 \pkg{hyperref} 目录超链接位置和页眉页脚标记。例如: |
| 1650 |
% \begin{ctexexam} |
| 1651 |
% \documentclass{ctexbook} |
| 1652 |
% \begin{document} |
| 1653 |
% \tableofcontents |
| 1654 |
% \chapter{A} |
| 1655 |
% \chapter*{B} |
| 1656 |
% \ctexset{chapter/numbering=false} |
| 1657 |
% \chapter{C} |
| 1658 |
% \end{document} |
| 1659 |
% \end{ctexexam} |
| 1660 |
% 三章的标题分别为“第一章\quad A”、“B”和“C”,但在目录中则只出现 |
| 1661 |
% “第一章\quad A”和“C”。 |
| 1662 |
% |
| 1663 |
% 注意,章节标题是否编号还要受到 \LaTeX{} 计数器 |secnumdepth| 的控制^^A |
| 1664 |
% (可通过以下介绍的 \opt{secnumdepth} 选项设置)。 |
| 1665 |
% 例如,对于 |section| 而言,其深度为 1。因此,|section| 会被编号,当且仅当 |
| 1666 |
% |secnumdepth| 不小于 1,并且 \opt{section/numbering} 为 \opt{true}, |
| 1667 |
% 并且使用不带星号的章节标题命令(即 \tn{section})。 |
| 1668 |
% \end{function} |
| 1669 |
% |
| 1670 |
% \begin{function}[EXP,added=2020-05-06]{secnumdepth} |
| 1671 |
% \begin{syntax} |
| 1672 |
% secnumdepth = <整数或章节名称> |
| 1673 |
% \end{syntax} |
| 1674 |
% 设置对章节标题进行编号的层次数。\opt{secnumdepth} 的值可以是一个整数,也可以是 |
| 1675 |
% |part|, |chapter| 等名称。 |
| 1676 |
% 层次数与名称的对应关系见表~\ref{tab:heading-level}。 |
| 1677 |
% 章节层次的默认设置见表~\ref{tab:heading-level-default}。 |
| 1678 |
% |
| 1679 |
% 本选项对 \cls{beamer}/\cls{ctexbeamer} 文档类无效。 |
| 1680 |
% \end{function} |
| 1681 |
% |
| 1682 |
% \begin{table}[htbp] |
| 1683 |
% \begin{minipage}[t]{.43\linewidth} |
| 1684 |
% \small\centering |
| 1685 |
% \caption{章节层次} |
| 1686 |
% \label{tab:heading-level} |
| 1687 |
% \begin{tabular}{rll} |
| 1688 |
% \toprule |
| 1689 |
% 层次 & 名称 & 注 \\ |
| 1690 |
% \midrule |
| 1691 |
% |-1| & part & \cls{book}/\cls{report} 类 \\ |
| 1692 |
% |0| & chapter & \cls{book}/\cls{report} 类 \\ |
| 1693 |
% |0| & part & \cls{article} 类 \\ |
| 1694 |
% |1| & section \\ |
| 1695 |
% |2| & subsection \\ |
| 1696 |
% |3| & subsubsection \\ |
| 1697 |
% |4| & paragraph \\ |
| 1698 |
% |5| & subparagraph \\ |
| 1699 |
% \bottomrule |
| 1700 |
% \end{tabular} |
| 1701 |
% \end{minipage}^^A |
| 1702 |
% \begin{minipage}[t]{.57\linewidth} |
| 1703 |
% \small\centering |
| 1704 |
% \caption{章节层次的默认设置} |
| 1705 |
% \label{tab:heading-level-default} |
| 1706 |
% \begin{tabular}{lll} |
| 1707 |
% \toprule |
| 1708 |
% 文档类 & \opt{secnumdepth} & \opt{tocdepth} \\ |
| 1709 |
% \midrule |
| 1710 |
% \cls{article} & |3| (subsubsection) & |3| (subsubsection) \\ |
| 1711 |
% \cls{book}/\cls{report} & |2| (subsection) & |2| (subsection) \\ |
| 1712 |
% \cls{beamer} & 无效 & |3| (subsubsection) \\ |
| 1713 |
% \bottomrule |
| 1714 |
% \end{tabular} |
| 1715 |
% \end{minipage} |
| 1716 |
% \end{table} |
| 1717 |
% |
| 1718 |
% 如果没有特别说明,以下将用 “|...|” 代表各级章节标题名。 |
| 1719 |
% |
| 1720 |
% \begin{function}[EXP,updated=2014-03-08]{.../name} |
| 1721 |
% \begin{syntax} |
| 1722 |
% name = \{<前名字>,<后名字>\} |
| 1723 |
% name = \Arg{前名字} |
| 1724 |
% \end{syntax} |
| 1725 |
% 设置章节的名字。所谓“章节的名字”,可以分为前后两部分,即章节编号前后的 |
| 1726 |
% 词语,两个词之间用一个半角逗号分开;也可以只有一部分,表示只有章节编号之前 |
| 1727 |
% 的名字。例如: |
| 1728 |
% \begin{ctexexam} |
| 1729 |
% \ctexset{ |
| 1730 |
% chapter/name = {第,章}, |
| 1731 |
% section/name = {\S}, |
| 1732 |
% } |
| 1733 |
% \end{ctexexam} |
| 1734 |
% 会使得 \tn{chapter} 标题使用形如“第一章”的名字,而 \tn{section} 标题则使 |
| 1735 |
% 用形如“\S1”的名字。该选项的默认设置见表~\ref{tab:name-default}。 |
| 1736 |
% \end{function} |
| 1737 |
% |
| 1738 |
% \begin{table}[htbp] |
| 1739 |
% \small\centering |
| 1740 |
% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} |
| 1741 |
% \caption{\opt{name} 选项的默认设置} |
| 1742 |
% \label{tab:name-default} |
| 1743 |
% \begin{tabular}{llll} |
| 1744 |
% \toprule |
| 1745 |
% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} & 注 \\ |
| 1746 |
% \midrule |
| 1747 |
% part & |{第,部分}| & |{\partname\space}| & 原 \tn{partname} 为 Part \\ |
| 1748 |
% chapter & |{第,章}| & |{\chaptername\space}| |
| 1749 |
% & 原 \tn{chaptername} 为 Chapter \\ |
| 1750 |
% section (beamer) & |{}| & |{\sectionname\space}| |
| 1751 |
% & \BSTACK 原 \tn{sectionname} 为\\ |\translate{Section}| \ESTACK \\ |
| 1752 |
% section & 同右 & |{}| & \\ |
| 1753 |
% subsection (beamer) & |{}| & |{\subsectionname\space}| |
| 1754 |
% & \BSTACK 原 \tn{subsectionname} 为\\ |\translate{Subsection}| \ESTACK \\ |
| 1755 |
% subsection & 同右 & |{}| & \\ |
| 1756 |
% subsubsection & 同右 & |{}| & \\ |
| 1757 |
% paragraph & 同右 & |{}| & \\ |
| 1758 |
% subparagraph & 同右 & |{}| & \\ |
| 1759 |
% \bottomrule |
| 1760 |
% \end{tabular} |
| 1761 |
% \end{table} |
| 1762 |
% |
| 1763 |
% \begin{function}[EXP]{.../number} |
| 1764 |
% \begin{syntax} |
| 1765 |
% number = \Arg{数字输出命令} |
| 1766 |
% \end{syntax} |
| 1767 |
% 设置章节编号的数字输出格式。\meta{数字输出命令} 通常是对应章节编号计数器的 |
| 1768 |
% 输出命令,如 \tn{thesection} 或 |\chinese{chapter}| 之类。例如: |
| 1769 |
% \begin{ctexexam} |
| 1770 |
% \ctexset{ |
| 1771 |
% section/number = \Roman{section} |
| 1772 |
% } |
| 1773 |
% \end{ctexexam} |
| 1774 |
% 将会使 \tn{section} 的编号变为大写罗马数字(如 I、II 等)。 |
| 1775 |
% |
| 1776 |
% \opt{number} 选项定义的同时将控制对章节计数器的交叉引用。在引用计数器时, |
| 1777 |
% 记录在 \LaTeX{} 辅助文件中的是 \opt{number} 选项的定义。 |
| 1778 |
% |
| 1779 |
% 但是,\opt{number} 选项不会影响计数器本身的输出。即设置 |section/number| |
| 1780 |
% 不会影响 \tn{thesection} 的定义(但该选项会影响 \tn{CTEXthesection} 的定 |
| 1781 |
% 义,见后)。该选项的默认设置见表~\ref{tab:number-default}。 |
| 1782 |
% \end{function} |
| 1783 |
% |
| 1784 |
% \begin{table}[htbp] |
| 1785 |
% \small\centering |
| 1786 |
% \caption{\opt{number} 选项的默认设置} |
| 1787 |
% \label{tab:number-default} |
| 1788 |
% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} |
| 1789 |
% \begin{tabular}{llll} |
| 1790 |
% \toprule |
| 1791 |
% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} |
| 1792 |
% & 原 |\the|\meta{标题} 等价定义 \\ |
| 1793 |
% \midrule |
| 1794 |
% part (beamer) & |\chinese{part}| & |\insertromanpartnumber| & 意义为 |\Roman{part}| \\ |
| 1795 |
% part & |\chinese{part}| & |\thepart| & |\Roman{part}| \\ |
| 1796 |
% chapter & |\chinese{chapter}| & |\thechapter| & |\arabic{chapter}| \\ |
| 1797 |
% section (beamer) & 同右 & |\insertsectionnumber| & 意义为 |\arabic{section}| \\ |
| 1798 |
% section & 同右 & |\thesection| & |\arabic{section}| \\ |
| 1799 |
% subsection (beamer) |
| 1800 |
% & \BSTACK |\arabic{section}.|\\ |\arabic{subsection}| \ESTACK |
| 1801 |
% & |\insertsubsectionnumber| & 意义为 |\arabic{subsection}| \\ |
| 1802 |
% subsection & 同右 & |\thesubsection| & |\thesection.\arabic{subsection}| \\ |
| 1803 |
% subsubsection & 同右 & |\thesubsubsection| |
| 1804 |
% & |\thesubsection.\arabic{subsubsection}| \\ |
| 1805 |
% paragraph & 同右 & |\theparagraph| |
| 1806 |
% & |\thesubsubsection.\arabic{paragraph}| \\ |
| 1807 |
% subparagraph & 同右 & |\thesubparagraph| |
| 1808 |
% & |\theparagraph.\arabic{subparagraph}| \\ |
| 1809 |
% \bottomrule |
| 1810 |
% \end{tabular} |
| 1811 |
% \end{table} |
| 1812 |
% |
| 1813 |
% \subsection{格式相关} |
| 1814 |
% \label{subsec:sec-format} |
| 1815 |
% |
| 1816 |
% \CTeX{} 宏集提供了 \opt{numberformat}, \opt{nameformat}, \opt{titleformat}, |
| 1817 |
% \opt{format} 这几个选项用来控制章节标题的格式。 |
| 1818 |
% 它们的作用范围如图~\ref{fig:heading-format} 所示。具体用法见下文。 |
| 1819 |
% |
| 1820 |
% \begin{figure}[htbp] |
| 1821 |
% \centering |
| 1822 |
% \[ |
| 1823 |
% \underbrace{ |
| 1824 |
% \overbrace{ |
| 1825 |
% \text{\huge\bfseries 第} |
| 1826 |
% \mspace{-25mu} |
| 1827 |
% \underbrace{\text{\huge\bfseries 1}}_{\text{\small\opt{numberformat}}} |
| 1828 |
% \mspace{-25mu} |
| 1829 |
% \text{\huge\bfseries 章} |
| 1830 |
% }^{\text{\small\opt{nameformat}}} \quad |
| 1831 |
% \overbrace{\text{\huge\bfseries 熟悉 \LaTeX}}^{\text{\small\opt{titleformat}}} |
| 1832 |
% }_{\text{\small\opt{format}}} |
| 1833 |
% \] |
| 1834 |
% \caption{\opt{numberformat}, \opt{nameformat}, \opt{titleformat}, |
| 1835 |
% \opt{format} 几个选项的作用范围示意} |
| 1836 |
% \label{fig:heading-format} |
| 1837 |
% \end{figure} |
| 1838 |
% |
| 1839 |
% \begin{function}[EXP,updated=2020-04-22]{.../format, .../format+} |
| 1840 |
% \begin{syntax} |
| 1841 |
% format = \Arg{格式命令} |
| 1842 |
% format+= \Arg{格式命令} |
| 1843 |
% \end{syntax} |
| 1844 |
% \opt{format} 选项用于控制章节标题的全局格式,作用域为章节名字和随后的标题 |
| 1845 |
% 内容。可以用于控制章节标题的对齐方式、整体字体字号等格式。 |
| 1846 |
% 带加号的 \opt{format+} 选项用于在已有的格式命令后附加内容。 |
| 1847 |
% |
| 1848 |
% \opt{format} 选项的最后一个格式命令可以带有一个参数。 |
| 1849 |
% 这一参数用于接受章节名字、编号和标题内容(以及由 \opt{nameformat}, \opt{numberformat}, |
| 1850 |
% \opt{aftername}, \opt{titleformat}, \opt{aftertitle}, \opt{indent} |
| 1851 |
% 及 \opt{hang} 选项设定的,应用于这些内容之上的格式),以实现特殊效果。 |
| 1852 |
% |
| 1853 |
% 例如,设置章标题为无衬线字体左对齐、为节标题增加无衬线字体设置、 |
| 1854 |
% 为小节标题加框(\tn{fbox} 命令本身需带一个参数): |
| 1855 |
% \begin{ctexexam} |
| 1856 |
% \ctexset{ |
| 1857 |
% chapter/format = \sffamily\raggedright, |
| 1858 |
% section/format += \sffamily, |
| 1859 |
% subsection/format += \fbox, |
| 1860 |
% } |
| 1861 |
% \end{ctexexam} |
| 1862 |
% |
| 1863 |
% \opt{format} 选项的默认设置见表~\ref{tab:format-default}。 |
| 1864 |
% \end{function} |
| 1865 |
% |
| 1866 |
% \begin{table}[htbp] |
| 1867 |
% \small\centering |
| 1868 |
% \begin{threeparttable} |
| 1869 |
% \caption{\opt{format} 选项的默认设置} |
| 1870 |
% \label{tab:format-default} |
| 1871 |
% \begin{tabular}{lll} |
| 1872 |
% \toprule |
| 1873 |
% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ |
| 1874 |
% \midrule |
| 1875 |
% part (article) & |\Large\bfseries\centering| & |\raggedright|\tnote{*} \\ |
| 1876 |
% part (beamer) & 同右 & |\centering| \\ |
| 1877 |
% part & |\huge\bfseries\centering| & |\centering| \\ |
| 1878 |
% chapter & |\huge\bfseries\centering| & |\raggedright| \\ |
| 1879 |
% section (beamer) & 同右 & |\centering| \\ |
| 1880 |
% section & |\Large\bfseries\centering| & |\Large\bfseries| \\ |
| 1881 |
% subsection (beamer) & 同右 & |\centering| \\ |
| 1882 |
% subsection & 同右 & |\large\bfseries| \\ |
| 1883 |
% subsubsection & 同右 & |\normalsize\bfseries| \\ |
| 1884 |
% paragraph & 同右 & |\normalsize\bfseries| \\ |
| 1885 |
% subparagraph & 同右 & |\normalsize\bfseries| \\ |
| 1886 |
% \bottomrule |
| 1887 |
% \end{tabular} |
| 1888 |
% \begin{tablenotes} |
| 1889 |
% \item[*] 为了与 \LaTeXe{} 的默认效果保持一致,在 \opt{scheme = plain} |
| 1890 |
% 时,part 和 chapter 的 \opt{nameformat} 和 \opt{titleformat} |
| 1891 |
% 并不一样,因此没有使用 \opt{format} 选项统一设置名字和标题的格式。 |
| 1892 |
% \end{tablenotes} |
| 1893 |
% \end{threeparttable} |
| 1894 |
% \end{table} |
| 1895 |
% |
| 1896 |
% \begin{function}[EXP,updated=2015-06-30]{.../nameformat, .../nameformat+} |
| 1897 |
% \begin{syntax} |
| 1898 |
% nameformat = \Arg{格式命令} |
| 1899 |
% nameformat+= \Arg{格式命令} |
| 1900 |
% \end{syntax} |
| 1901 |
% \opt{nameformat} 用于控制章节名字的格式,作用域为章节名字,包括编号。它一 |
| 1902 |
% 般用于章节名(包括编号)与章节标题的字体、字号等设置不一致的情形。参见 |
| 1903 |
% 下面的 \opt{titleformat} 选项。\opt{nameformat+} 用于在已有的章节名字 |
| 1904 |
% 格式命令后附加内容。 |
| 1905 |
% |
| 1906 |
% \opt{nameformat} 选项的最后一个格式命令可以带有一个参数。 |
| 1907 |
% 这一参数用于接受章节名字和编号,以实现特殊效果(见例~\ref{exam:miscopt})。 |
| 1908 |
% |
| 1909 |
% \opt{nameformat} 选项的默认设置见表~\ref{tab:nameformat-default}。 |
| 1910 |
% \end{function} |
| 1911 |
% |
| 1912 |
% \begin{table}[htbp] |
| 1913 |
% \small\centering |
| 1914 |
% \caption{\opt{nameformat} 选项的默认设置} |
| 1915 |
% \label{tab:nameformat-default} |
| 1916 |
% \begin{tabular}{lll} |
| 1917 |
% \toprule |
| 1918 |
% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ |
| 1919 |
% \midrule |
| 1920 |
% part (article) & |{}| & |\Large\bfseries| \\ |
| 1921 |
% part (beamer) & 同右 |
| 1922 |
% & \BSTACK |\usebeamerfont{part name}| \\ |
| 1923 |
% |\usebeamercolor[fg]{part name}| \ESTACK \\ |
| 1924 |
% part & |{}| & |\huge\bfseries| \\ |
| 1925 |
% chapter & |{}| & |\huge\bfseries| \\ |
| 1926 |
% section (beamer) & 同右 |
| 1927 |
% & \BSTACK |\usebeamerfont{section name}| \\ |
| 1928 |
% |\usebeamercolor[fg]{section name}| \ESTACK \\ |
| 1929 |
% section & 同右 & |{}| \\ |
| 1930 |
% subsection (beamer) & 同右 |
| 1931 |
% & \BSTACK |\usebeamerfont{subsection name}| \\ |
| 1932 |
% |\usebeamercolor[fg]{subsection name}| \ESTACK \\ |
| 1933 |
% subsection & 同右 & |{}| \\ |
| 1934 |
% subsubsection & 同右 & |{}| \\ |
| 1935 |
% paragraph & 同右 & |{}| \\ |
| 1936 |
% subparagraph & 同右 & |{}| \\ |
| 1937 |
% \bottomrule |
| 1938 |
% \end{tabular} |
| 1939 |
% \end{table} |
| 1940 |
% |
| 1941 |
% \begin{function}[EXP,updated=2015-06-19]{.../numberformat, .../numberformat+} |
| 1942 |
% \begin{syntax} |
| 1943 |
% numberformat = \Arg{格式命令} |
| 1944 |
% numberformat+= \Arg{格式命令} |
| 1945 |
% \end{syntax} |
| 1946 |
% \opt{numberformat} 选项用于控制章节编号的格式,作用域仅为编号数字本身。对 |
| 1947 |
% 各级标题默认均为空,当需要编号的格式和前后的章节名字不一样时可以使用。 |
| 1948 |
% \opt{numberformat+} 用于在已有的编号格式命令后附加内容。 |
| 1949 |
% |
| 1950 |
% \opt{numberformat} 选项的最后一个格式命令可以带有一个参数。这一参数用于接受 |
| 1951 |
% 编号数字。例如,我们可以使用 \opt{numberformat} 特别强调章标题中的数字: |
| 1952 |
% \begin{ctexexam} |
| 1953 |
% \ctexset{ |
| 1954 |
% chapter/number = \arabic{chapter}, |
| 1955 |
% chapter/numberformat = \color{blue}\zihao{0}\emph, |
| 1956 |
% } |
| 1957 |
% \end{ctexexam} |
| 1958 |
% 上面的代码在 \opt{scheme = chinese} 时可以做出类似这样的章标题效果: |
| 1959 |
% \begin{center} |
| 1960 |
% \huge\bfseries 第 \emph{\color{blue}\zihao{0}4} 章 |
| 1961 |
% \end{center} |
| 1962 |
% |
| 1963 |
% \opt{numberformat} 选项默认均设置为空,故章节编号默认与章节名字使用 |
| 1964 |
% 相同的格式。 |
| 1965 |
% \end{function} |
| 1966 |
% |
| 1967 |
% \begin{function}[EXP,updated=2015-06-30]{.../titleformat, .../titleformat+} |
| 1968 |
% \begin{syntax} |
| 1969 |
% titleformat = \Arg{格式命令} |
| 1970 |
% titleformat+= \Arg{格式命令} |
| 1971 |
% \end{syntax} |
| 1972 |
% \opt{titleformat} 选项用于控制标题内容的格式,作用域为章节标题内容。 |
| 1973 |
% \opt{titleformat+} 选项用于在已有的标题格式命令后附加内容。 |
| 1974 |
% |
| 1975 |
% \opt{titleformat} 选项的最后一个格式命令可以带有一个参数。这一参数用于接受 |
| 1976 |
% 标题内容。例如,实现多行标题的居中悬挂对齐: |
| 1977 |
% \begin{ctexexam} |
| 1978 |
% \usepackage{varwidth} %% 提供 varwidth 环境 |
| 1979 |
% \ctexset{ |
| 1980 |
% chapter/name = {第,回}, |
| 1981 |
% chapter/titleformat = \chaptertitleformat |
| 1982 |
% } |
| 1983 |
% \newcommand\chaptertitleformat[1]{%% 以标题内容为参数 |
| 1984 |
% \begin{varwidth}[t]{.7\linewidth}#1\end{varwidth}} |
| 1985 |
% ...... |
| 1986 |
% \chapter{情中情因情感妹妹\\错里错以错劝哥哥} |
| 1987 |
% \end{ctexexam} |
| 1988 |
% 上面的代码可以做出类似这样的章标题效果: |
| 1989 |
% \begin{center}\Large\bfseries |
| 1990 |
% 第三十四回\quad |
| 1991 |
% \begin{tabular}[t]{l} |
| 1992 |
% 情中情因情感妹妹\\ |
| 1993 |
% 错里错以错劝哥哥 |
| 1994 |
% \end{tabular} |
| 1995 |
% \end{center} |
| 1996 |
% |
| 1997 |
% \opt{titleformat} 选项的默认设置见表~\ref{tab:titleformat-default}。 |
| 1998 |
% \end{function} |
| 1999 |
% |
| 2000 |
% \begin{table}[htbp] |
| 2001 |
% \small\centering |
| 2002 |
% \caption{\opt{titleformat} 选项的默认设置} |
| 2003 |
% \label{tab:titleformat-default} |
| 2004 |
% \begin{tabular}{lll} |
| 2005 |
% \toprule |
| 2006 |
% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ |
| 2007 |
% \midrule |
| 2008 |
% part (article) & |{}| & |\huge\bfseries| \\ |
| 2009 |
% part (beamer) & 同右 & |\usebeamerfont{part title}| \\ |
| 2010 |
% part & |{}| & |\Huge\bfseries| \\ |
| 2011 |
% chapter & |{}| & |\Huge\bfseries| \\ |
| 2012 |
% section (beamer) & 同右 & |\usebeamerfont{section title}| \\ |
| 2013 |
% section & 同右 & |{}| \\ |
| 2014 |
% subsection (beamer) & 同右 & |\usebeamerfont{subsection title}| \\ |
| 2015 |
% subsection & 同右 & |{}| \\ |
| 2016 |
% subsubsection & 同右 & |{}| \\ |
| 2017 |
% paragraph & 同右 & |{}| \\ |
| 2018 |
% subparagraph & 同右 & |{}| \\ |
| 2019 |
% \bottomrule |
| 2020 |
% \end{tabular} |
| 2021 |
% \end{table} |
| 2022 |
% |
| 2023 |
% \begin{function}[EXP,updated=2014-03-08]{.../aftername, .../aftername+} |
| 2024 |
% \begin{syntax} |
| 2025 |
% aftername = \Arg{代码} |
| 2026 |
% aftername+= \Arg{代码} |
| 2027 |
% \end{syntax} |
| 2028 |
% \opt{aftername} 选项的参数 \meta{代码} 将被插入到章节编号与其后的标题内容之 |
| 2029 |
% 间,用于控制格式变换。常用于控制章节编号与标题内容之间的距离,或者控制标题 |
| 2030 |
% 是否另起一行。\opt{aftername+} 用于在已有的代码后附加内容。该选项的默认设置 |
| 2031 |
% 见表~\ref{tab:aftername-default}。 |
| 2032 |
% \end{function} |
| 2033 |
% |
| 2034 |
% \begin{function}[EXP,added=2015-06-19]{.../aftertitle, .../aftertitle+} |
| 2035 |
% \begin{syntax} |
| 2036 |
% aftertitle = \Arg{代码} |
| 2037 |
% aftertitle+= \Arg{代码} |
| 2038 |
% \end{syntax} |
| 2039 |
% \opt{aftertitle} 选项的参数 \meta{代码} 将被插入到章节标题内容之后。 |
| 2040 |
% \opt{aftertitle+} 用于在已有的代码后附加内容。该选项的默认设置 |
| 2041 |
% 见表~\ref{tab:aftertitle-default}。需注意,\opt{sub3section} 或 |
| 2042 |
% \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)会影响 |
| 2043 |
% \opt{aftertitle} 选项的默认值。 |
| 2044 |
% \end{function} |
| 2045 |
% |
| 2046 |
% \begin{table}[htbp] |
| 2047 |
% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} |
| 2048 |
% \begin{minipage}[t]{.75\linewidth} |
| 2049 |
% \small\centering |
| 2050 |
% \caption{\opt{aftername} 选项的默认设置} |
| 2051 |
% \label{tab:aftername-default} |
| 2052 |
% \begin{tabular}{lll} |
| 2053 |
% \toprule |
| 2054 |
% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ |
| 2055 |
% \midrule |
| 2056 |
% part (article) & |\quad| & |\par\nobreak| \\ |
| 2057 |
% part (beamer) & 同右 & |\vskip 1em \par| \\ |
| 2058 |
% part & 同右 & |\par\vskip 20pt| \\ |
| 2059 |
% chapter & |\quad| & |\par\nobreak\vskip 20pt| \\ |
| 2060 |
% section (beamer) & 同右 & |\vskip 1em \par| \\ |
| 2061 |
% section & 同右 & |\quad| \\ |
| 2062 |
% subsection (beamer) & 同右 & |\vskip 1em \par| \\ |
| 2063 |
% subsection & 同右 & |\quad| \\ |
| 2064 |
% subsubsection & 同右 & |\quad| \\ |
| 2065 |
% paragraph & 同右 & |\quad| \\ |
| 2066 |
% subparagraph & 同右 & |\quad| \\ |
| 2067 |
% \bottomrule |
| 2068 |
% \end{tabular} |
| 2069 |
% \end{minipage}\nobreak\quad |
| 2070 |
% \begin{minipage}[t]{.42\linewidth} |
| 2071 |
% \small\centering |
| 2072 |
% \caption{\opt{aftertitle} 选项的默认设置} |
| 2073 |
% \label{tab:aftertitle-default} |
| 2074 |
% \begin{tabular}{p{\dimexpr .58\linewidth - 2\tabcolsep\relax}p{\dimexpr .4\linewidth - 2\tabcolsep\relax}} |
| 2075 |
% \toprule |
| 2076 |
% 标题名 & 默认值 \\ |
| 2077 |
% \midrule |
| 2078 |
% part & |\par| \\ |
| 2079 |
% chapter & |\par| \\ |
| 2080 |
% section & |\@@par| \\ |
| 2081 |
% subsection & |\@@par| \\ |
| 2082 |
% subsubsection & |\@@par| \\ |
| 2083 |
% paragraph & |{}| \\ |
| 2084 |
% \qquad(sub3section) & |\@@par| \\ |
| 2085 |
% \qquad(sub4section) & 同上 \\ |
| 2086 |
% subparagraph & |{}| \\ |
| 2087 |
% \qquad(sub4section) & |\@@par| \\ |
| 2088 |
% \bottomrule |
| 2089 |
% \end{tabular} |
| 2090 |
% \end{minipage} |
| 2091 |
% \end{table} |
| 2092 |
% |
| 2093 |
% \begin{function}[EXP,added=2014-03-21]{part/pagestyle, chapter/pagestyle} |
| 2094 |
% \begin{syntax} |
| 2095 |
% pagestyle = \Arg{页面格式} |
| 2096 |
% \end{syntax} |
| 2097 |
% 设置 \cls{book}/\cls{ctexbook} 或 \cls{report}/\cls{ctexrep} 文档类 |
| 2098 |
% 中,\tn{part} 与 \tn{chapter} 标题所在页的页面格式(page style)。 |
| 2099 |
% 该选项的默认设置见表~\ref{tab:pagestyle-default}。 |
| 2100 |
% \end{function} |
| 2101 |
% |
| 2102 |
% \begin{table}[htbp] |
| 2103 |
% \small\centering |
| 2104 |
% \caption{\opt{pagestyle} 选项的默认设置} |
| 2105 |
% \label{tab:pagestyle-default} |
| 2106 |
% \begin{tabular}{ll} |
| 2107 |
% \toprule |
| 2108 |
% 标题名 & 默认值 \\ |
| 2109 |
% \midrule |
| 2110 |
% part (article) & 无效 \\ |
| 2111 |
% part & |plain| \\ |
| 2112 |
% chapter & |plain| \\ |
| 2113 |
% \bottomrule |
| 2114 |
% \end{tabular} |
| 2115 |
% \end{table} |
| 2116 |
% |
| 2117 |
% \subsection{间距、缩进相关} |
| 2118 |
% \label{subsec:sec-spacing} |
| 2119 |
% |
| 2120 |
% \begin{function}[EXP,added=2015-06-27]{section/runin, subsection/runin, |
| 2121 |
% subsubsection/runin, paragraph/runin, subparagraph/runin} |
| 2122 |
% \begin{syntax} |
| 2123 |
% runin = \TF |
| 2124 |
% \end{syntax} |
| 2125 |
% \opt{runin} 选项只对 \tn{section} 级以下标题有意义,用于确定标题与随后的 |
| 2126 |
% 正文是否排在同一段之上。该选项的默认设置见表~\ref{tab:runin-default}。 |
| 2127 |
% |
| 2128 |
% 默认情况下,\tn{paragraph}、\tn{subparagraph} 两级标题是与后面正文排在同一 |
| 2129 |
% 段的,\opt{runin} 选项为 \opt{true};但使用 \opt{sub3section} 或 |
| 2130 |
% \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)后,将对 |
| 2131 |
% 这两级标题设 \opt{runin} 选项为 \opt{false},这两级标题会改为排在不同段。 |
| 2132 |
% \end{function} |
| 2133 |
% |
| 2134 |
% \begin{table}[htbp] |
| 2135 |
% \small\centering |
| 2136 |
% \caption{\opt{runin} 选项的默认设置} |
| 2137 |
% \label{tab:runin-default} |
| 2138 |
% \begin{tabular}{ll} |
| 2139 |
% \toprule |
| 2140 |
% 标题名 & 默认值 \\ |
| 2141 |
% \midrule |
| 2142 |
% part & 无效 \\ |
| 2143 |
% chapter & 无效 \\ |
| 2144 |
% section & |false| \\ |
| 2145 |
% subsection & |false| \\ |
| 2146 |
% subsubsection & |false| \\ |
| 2147 |
% paragraph & |true| \\ |
| 2148 |
% \qquad(sub3section) & |false| \\ |
| 2149 |
% \qquad(sub4section) & 同上 \\ |
| 2150 |
% subparagraph & |true| \\ |
| 2151 |
% \qquad(sub4section) & |false| \\ |
| 2152 |
% \bottomrule |
| 2153 |
% \end{tabular} |
| 2154 |
% \end{table} |
| 2155 |
% |
| 2156 |
% \begin{function}[EXP,updated=2020-04-23]{.../hang} |
| 2157 |
% \begin{syntax} |
| 2158 |
% hang = \TF |
| 2159 |
% \end{syntax} |
| 2160 |
% \opt{hang} 选项用于设置是否对章节标题实施悬挂缩进(缩进的宽度为名字宽度 |
| 2161 |
% 和 \opt{indent} 选项设置的宽度之和)。 |
| 2162 |
% |
| 2163 |
% 注意,当 \opt{hang = true} 时,不恰当地设置选项 \opt{aftername} 的值,可能会引发 |
| 2164 |
% 错误。这是因为当 \opt{hang = true} 时,\LaTeX{} 内部会构造一个 \tn{hbox} 而 |
| 2165 |
% 进入受限水平模式(restricted horizontal mode)。若在 \opt{aftername} 中加入 |
| 2166 |
% 包含 \tn{vskip} 等会导致从受限水平模式切出的垂直命令(vertical command)时,就会报错。 |
| 2167 |
% 特别地,\opt{aftername} 的默认值也可能导致这种情形(见表~\ref{tab:aftername-default})。 |
| 2168 |
% 因此,当设置 \opt{hang = true} 时,用户必须恰当地设置选项 \opt{aftername} 的值。 |
| 2169 |
% |
| 2170 |
% 本选项对 \cls{beamer}/\cls{ctexbeamer} 文档类无效。 |
| 2171 |
% 对于 \tn{section} 级以下标题,若设置了 \opt{runin} 选项为 \opt{true}, |
| 2172 |
% 即标题与随后正文排在同一段,\opt{hang} 选项没有意义。 |
| 2173 |
% 该选项的默认设置见表~\ref{tab:hang-default}。 |
| 2174 |
% \end{function} |
| 2175 |
% |
| 2176 |
% \begin{table}[htbp] |
| 2177 |
% \begin{minipage}[t]{.5\linewidth} |
| 2178 |
% \small\centering |
| 2179 |
% \caption{\opt{hang} 选项的默认设置} |
| 2180 |
% \label{tab:hang-default} |
| 2181 |
% \begin{tabular}{ll} |
| 2182 |
% \toprule |
| 2183 |
% 标题名 & 默认值 \\ |
| 2184 |
% \midrule |
| 2185 |
% part & |false| \\ |
| 2186 |
% chapter & |false| \\ |
| 2187 |
% section & |true| \\ |
| 2188 |
% subsection & |true| \\ |
| 2189 |
% subsubsection & |true| \\ |
| 2190 |
% paragraph & 无意义 \\ |
| 2191 |
% \qquad(sub3section) & |true| \\ |
| 2192 |
% \qquad(sub4section) & |true| \\ |
| 2193 |
% subparagraph & 无意义 \\ |
| 2194 |
% \qquad(sub4section) & |true| \\ |
| 2195 |
% \bottomrule |
| 2196 |
% \end{tabular} |
| 2197 |
% \end{minipage}^^A |
| 2198 |
% \begin{minipage}[t]{.5\linewidth} |
| 2199 |
% \small\centering |
| 2200 |
% \caption{\opt{indent} 选项的默认设置} |
| 2201 |
% \label{tab:indent-default} |
| 2202 |
% \begin{tabular}{ll} |
| 2203 |
% \toprule |
| 2204 |
% 标题名 & 默认值 \\ |
| 2205 |
% \midrule |
| 2206 |
% part & |0pt| \\ |
| 2207 |
% chapter & |0pt| \\ |
| 2208 |
% section & |0pt| \\ |
| 2209 |
% subsection & |0pt| \\ |
| 2210 |
% subsubsection & |0pt| \\ |
| 2211 |
% paragraph & |0pt| \\ |
| 2212 |
% subparagraph & |\parindent| \\ |
| 2213 |
% \qquad(sub3section) & |0pt| \\ |
| 2214 |
% \qquad(sub4section) & 同上 \\ |
| 2215 |
% \bottomrule |
| 2216 |
% \end{tabular} |
| 2217 |
% \end{minipage} |
| 2218 |
% \end{table} |
| 2219 |
% |
| 2220 |
% \begin{function}[EXP,updated=2020-04-23]{.../indent} |
| 2221 |
% \begin{syntax} |
| 2222 |
% indent = \Arg{缩进间距} |
| 2223 |
% \end{syntax} |
| 2224 |
% \opt{indent} 选项用于设置章节标题本身的首行缩进。 |
| 2225 |
% 该选项的默认设置见表~\ref{tab:indent-default}。 |
| 2226 |
% |
| 2227 |
% 如果 \opt{indent} 的值是以 \texttt{em}、\texttt{ex} 或 \cs{ccwd} 为单位, |
| 2228 |
% 那么缩进间距的大小是相对于 \opt{format} 中指定的字号大小。 |
| 2229 |
% 例如,设置 \tn{part} 标题缩进三个字、\tn{section} 标题缩进 \SI{20}{pt}: |
| 2230 |
% \begin{ctexexam} |
| 2231 |
% \ctexset{ |
| 2232 |
% part = { |
| 2233 |
% format += \raggedright, |
| 2234 |
% indent = 3\ccwd, |
| 2235 |
% }, |
| 2236 |
% section = { |
| 2237 |
% format = \Large\bfseries, |
| 2238 |
% indent = 20pt, |
| 2239 |
% } |
| 2240 |
% } |
| 2241 |
% \part{首行缩进的标题} |
| 2242 |
% \noindent 无缩进的正文。 |
| 2243 |
% \section{首行缩进的标题} |
| 2244 |
% \noindent 无缩进的正文。 |
| 2245 |
% \end{ctexexam} |
| 2246 |
% \end{function} |
| 2247 |
% |
| 2248 |
% \begin{function}[EXP,updated=2016-05-10]{.../beforeskip} |
| 2249 |
% \begin{syntax} |
| 2250 |
% beforeskip = \Arg{弹性间距} |
| 2251 |
% \end{syntax} |
| 2252 |
% \opt{beforeskip} 选项用于设置章节标题前的垂直间距。 |
| 2253 |
% 该选项的默认设置见表~\ref{tab:beforeskip-default}。 |
| 2254 |
% \end{function} |
| 2255 |
% |
| 2256 |
% \begin{function}[EXP,updated=2015-06-27]{.../afterskip} |
| 2257 |
% \begin{syntax} |
| 2258 |
% afterskip = \Arg{弹性间距} |
| 2259 |
% \end{syntax} |
| 2260 |
% \opt{afterskip} 选项控制章节标题与后面下方之间的距离。 |
| 2261 |
% |
| 2262 |
% 对于 \tn{section} 级以下标题,\opt{runin} 选项会影响 \opt{afterskip} 选项的意义: |
| 2263 |
% 若 \opt{runin} 为 \opt{true},标题与随后正文排在同一段,\meta{弹性间距} 给出水平间距。 |
| 2264 |
% 否则,正文另起一段,\meta{弹性间距} 给出的是垂直间距。 |
| 2265 |
% |
| 2266 |
% 该选项的默认设置见表~\ref{tab:afterskip-default}。 |
| 2267 |
% 注意 \opt{sub3section} 或 \opt{sub4section} 宏包选项(见 |
| 2268 |
% \ref{subs:options-heading}~节)会影响 \opt{aftertitle} 选项的默认值。 |
| 2269 |
% \end{function} |
| 2270 |
% |
| 2271 |
% \begin{table}[htbp] |
| 2272 |
% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} |
| 2273 |
% \begin{minipage}[t]{.6\linewidth} |
| 2274 |
% \small\centering |
| 2275 |
% \caption{\opt{beforeskip} 选项的默认设置} |
| 2276 |
% \label{tab:beforeskip-default} |
| 2277 |
% \begin{tabular}{ll} |
| 2278 |
% \toprule |
| 2279 |
% 标题名 & 默认值 \\ |
| 2280 |
% \midrule |
| 2281 |
% part (article) & |4ex| \\ |
| 2282 |
% part (beamer) & |0pt| \\ |
| 2283 |
% part & |0pt plus 1fil| \\ |
| 2284 |
% chapter & |50pt| \\ |
| 2285 |
% section (beamer) & |0pt| \\ |
| 2286 |
% section & |3.5ex plus 1ex minus .2ex| \\ |
| 2287 |
% subsection (beamer) & |0pt| \\ |
| 2288 |
% subsection & |3.25ex plus 1ex minus .2ex| \\ |
| 2289 |
% subsubsection & |3.25ex plus 1ex minus .2ex| \\ |
| 2290 |
% paragraph & |3.25ex plus 1ex minus .2ex| \\ |
| 2291 |
% subparagraph & |3.25ex plus 1ex minus .2ex| \\ |
| 2292 |
% \bottomrule |
| 2293 |
% \end{tabular} |
| 2294 |
% \end{minipage}\nobreak\quad |
| 2295 |
% \begin{minipage}[t]{.5\linewidth} |
| 2296 |
% \small\centering |
| 2297 |
% \caption{\opt{afterskip} 选项的默认设置} |
| 2298 |
% \label{tab:afterskip-default} |
| 2299 |
% \begin{tabular}{ll} |
| 2300 |
% \toprule |
| 2301 |
% 标题名 & 默认值 \\ |
| 2302 |
% \midrule |
| 2303 |
% part (article) & |3ex| \\ |
| 2304 |
% part (beamer) & |0pt| \\ |
| 2305 |
% part & |0pt plus 1fil| \\ |
| 2306 |
% chapter & |40pt| \\ |
| 2307 |
% section (beamer) & |0pt| \\ |
| 2308 |
% section & |2.3ex plus .2ex| \\ |
| 2309 |
% subsection (beamer) & |0pt| \\ |
| 2310 |
% subsection & |1.5ex plus .2ex| \\ |
| 2311 |
% subsubsection & |1.5ex plus .2ex| \\ |
| 2312 |
% paragraph & |1em| \\ |
| 2313 |
% \qquad(sub3section) & |1ex plus .2ex| \\ |
| 2314 |
% \qquad(sub4section) & 同上 \\ |
| 2315 |
% subparagraph & |1em| \\ |
| 2316 |
% \qquad(sub4section) & |1ex plus .2ex| \\ |
| 2317 |
% \bottomrule |
| 2318 |
% \end{tabular} |
| 2319 |
% \end{minipage} |
| 2320 |
% \end{table} |
| 2321 |
% |
| 2322 |
% \begin{function}[EXP,added=2016-06-03]{.../fixskip} |
| 2323 |
% \begin{syntax} |
| 2324 |
% fixskip = \TFF |
| 2325 |
% \end{syntax} |
| 2326 |
% 默认情况下,\cls{article}、\cls{book} 和 \cls{report} 类的标题与正文的距离 |
| 2327 |
% 除了由 \opt{beforeskip} 和 \opt{afterskip} 选项设置的垂直间距外,还会有 |
| 2328 |
% 一些多余的间距。\opt{fixskip} 选项用于抑制这些多余间距。该选项默认不开启。 |
| 2329 |
% \end{function} |
| 2330 |
% |
| 2331 |
% \begin{function}[EXP,added=2016-09-19]{.../break, .../break+} |
| 2332 |
% \begin{syntax} |
| 2333 |
% break = \Arg{格式命令} |
| 2334 |
% break+= \Arg{格式命令} |
| 2335 |
% \end{syntax} |
| 2336 |
% \opt{break} 选项用于控制章节标题与\emph{之前}正文的分隔关系。 |
| 2337 |
% 一般用于设置是否在标题之前分页或者设置行间罚点。 |
| 2338 |
% \opt{break+} 用于在已有的格式命令后附加内容。 |
| 2339 |
% |
| 2340 |
% 例如,若当前页剩余高度小于正文高度的一半时,则另起一页输出 |
| 2341 |
% \tn{section} 标题: |
| 2342 |
% \begin{ctexexam} |
| 2343 |
% \usepackage{needspace} |
| 2344 |
% \ctexset{section/break = \Needspace{.5\textheight}} |
| 2345 |
% \end{ctexexam} |
| 2346 |
% |
| 2347 |
% 该选项的默认设置见表~\ref{tab:break-default}。 |
| 2348 |
% \end{function} |
| 2349 |
% |
| 2350 |
% \begin{table}[htbp] |
| 2351 |
% \small\centering |
| 2352 |
% \caption{\opt{break} 选项的默认设置} |
| 2353 |
% \label{tab:break-default} |
| 2354 |
% \begin{tabular}{ll} |
| 2355 |
% \toprule |
| 2356 |
% 标题名 & 默认值 \\ |
| 2357 |
% \midrule |
| 2358 |
% part (article) & |{}| \\ |
| 2359 |
% part & |\if@openright\cleardoublepage\else\clearpage\fi| \\ |
| 2360 |
% chapter & 同上 \\ |
| 2361 |
% section & |\addpenalty{\@secpenalty}| \\ |
| 2362 |
% subsection & 同上 \\ |
| 2363 |
% subsubsection & 同上 \\ |
| 2364 |
% paragraph & 同上 \\ |
| 2365 |
% subparagraph & 同上 \\ |
| 2366 |
% \bottomrule |
| 2367 |
% \end{tabular} |
| 2368 |
% \end{table} |
| 2369 |
% |
| 2370 |
% \begin{function}[EXP,added=2015-06-27]{.../afterindent} |
| 2371 |
% \begin{syntax} |
| 2372 |
% afterindent = \TF |
| 2373 |
% \end{syntax} |
| 2374 |
% \opt{afterindent} 选项用于设置章节标题后首段的缩进。 |
| 2375 |
% |
| 2376 |
% \cls{book} 和 \cls{report} 类的 \tn{part} 标题被单独排在一页之上, |
| 2377 |
% \opt{afterindent} 选项没有意义。 |
| 2378 |
% 对于 \tn{section} 级以下标题,若设置了 \opt{runin} 选项为 \opt{true}, |
| 2379 |
% 即标题与随后正文排在同一段,\opt{afterindent} 选项也就没有了意义。 |
| 2380 |
% |
| 2381 |
% 该选项的默认设置见表~\ref{tab:afterindent-default}。 |
| 2382 |
% \end{function} |
| 2383 |
% |
| 2384 |
% \begin{table}[htbp] |
| 2385 |
% \small\centering |
| 2386 |
% \caption{\opt{afterindent} 选项的默认设置} |
| 2387 |
% \label{tab:afterindent-default} |
| 2388 |
% \begin{tabular}{lll} |
| 2389 |
% \toprule |
| 2390 |
% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ |
| 2391 |
% \midrule |
| 2392 |
% part (article) & |true| & |false| \\ |
| 2393 |
% part & 无效 & 无效 \\ |
| 2394 |
% chapter & |true| & |false| \\ |
| 2395 |
% section & |true| & |false| \\ |
| 2396 |
% subsection & |true| & |false| \\ |
| 2397 |
% subsubsection & |true| & |false| \\ |
| 2398 |
% paragraph & |true| & |false| \\ |
| 2399 |
% subparagraph & |true| & |false| \\ |
| 2400 |
% \bottomrule |
| 2401 |
% \end{tabular} |
| 2402 |
% \end{table} |
| 2403 |
% |
| 2404 |
% \subsection{目录、附录相关} |
| 2405 |
% \label{subsec:sec-toc-appendix} |
| 2406 |
% |
| 2407 |
% \begin{function}[EXP,added=2020-05-06]{tocdepth} |
| 2408 |
% \begin{syntax} |
| 2409 |
% tocdepth = <整数或章节名称> |
| 2410 |
% \end{syntax} |
| 2411 |
% 设置对章节标题编入目录的层次数。\opt{tocdepth} 的值可以是一个整数,也可以是 |
| 2412 |
% |part|, |chapter| 等名称。 |
| 2413 |
% 层次数与名称的对应关系见表~\ref{tab:heading-level}。 |
| 2414 |
% 章节层次的默认设置见表~\ref{tab:heading-level-default}。 |
| 2415 |
% \end{function} |
| 2416 |
% |
| 2417 |
% \begin{function}[EXP,added=2016-10-25]{.../tocline} |
| 2418 |
% \begin{syntax} |
| 2419 |
% tocline = \Arg{格式定义} |
| 2420 |
% \end{syntax} |
| 2421 |
% \opt{tocline} 选项用于定义章节标题在目录文件(\file{.toc})中的格式。 |
| 2422 |
% \meta{格式定义}有两个参数:参数 |#1| 是 |part|、|chapter| 等名字, |
| 2423 |
% 参数 |#2| 是标题内容。该选项的默认设置见表~\ref{tab:tocline-default}。 |
| 2424 |
% \end{function} |
| 2425 |
% |
| 2426 |
% \begin{table}[htbp] |
| 2427 |
% \small\centering |
| 2428 |
% \caption{\opt{tocline} 选项的默认设置} |
| 2429 |
% \label{tab:tocline-default} |
| 2430 |
% \begin{tabular}{ll} |
| 2431 |
% \toprule |
| 2432 |
% 标题名 & 默认值 \\ |
| 2433 |
% \midrule |
| 2434 |
% part & |\CTEXifname{\CTEXthepart\hspace{1em}}{}#2| \\ |
| 2435 |
% chapter (\opt{chinese}) |
| 2436 |
% & |\CTEXifname{\protect\numberline{\CTEXthechapter\hspace{.3em}}}{}#2| \\ |
| 2437 |
% chapter (\opt{plain}) |
| 2438 |
% & |\CTEXnumberline{#1}#2| \\ |
| 2439 |
% section & |\CTEXnumberline{#1}#2| \\ |
| 2440 |
% subsection & 同上 \\ |
| 2441 |
% subsubsection & 同上 \\ |
| 2442 |
% paragraph & 同上 \\ |
| 2443 |
% subparagraph & 同上 \\ |
| 2444 |
% \bottomrule |
| 2445 |
% \end{tabular} |
| 2446 |
% |
| 2447 |
% \medskip |
| 2448 |
% \raggedright |
| 2449 |
% 这里 \tn{CTEXnumberline} 的意义是,若标题 |#1| 没有名字,则不输出 |
| 2450 |
% |\numberline{\CTEXthe#1}| 等编号: |
| 2451 |
% \begin{verbatim} |
| 2452 |
% \CTEXifname{\protect\numberline{\csname CTEXthe#1\endcsname}}{} |
| 2453 |
% \end{verbatim} |
| 2454 |
% 其中,\tn{CTEXifname} 的定义见 \ref{subsec:sec-commands}~小节。 |
| 2455 |
% \end{table} |
| 2456 |
% |
| 2457 |
% \begin{function}[EXP,added=2016-10-01]{chapter/lofskip, chapter/lotskip} |
| 2458 |
% \begin{syntax} |
| 2459 |
% lofskip = \Arg{弹性间距} |
| 2460 |
% lotskip = \Arg{弹性间距} |
| 2461 |
% \end{syntax} |
| 2462 |
% \opt{lofskip} 选项控制插图目录(\file{.lof})中,章之间的插图标题的距离。 |
| 2463 |
% 同样,\opt{lotskip} 选项控制表格目录(\file{.lot})中,章之间的表格标题 |
| 2464 |
% 的距离。 |
| 2465 |
% |
| 2466 |
% 目前,这两个选项只在 \opt{chapter} 标题下有定义。 |
| 2467 |
% 它们的默认值,在 \opt{scheme} 选项的不同取值下都为 \SI{10}{pt}。 |
| 2468 |
% \end{function} |
| 2469 |
% |
| 2470 |
% \begin{function}[EXP,added=2015-06-21]{appendix/numbering} |
| 2471 |
% \begin{syntax} |
| 2472 |
% numbering = \TTF |
| 2473 |
% \end{syntax} |
| 2474 |
% 控制是否对附录章(对应 \cls{book} 与 \cls{report})或附录节 |
| 2475 |
% (对应 \cls{article})进行编号,用法与普通章节对应的 \opt{numbering} |
| 2476 |
% 选项相同。该选项默认值为 \opt{true}。 |
| 2477 |
% \end{function} |
| 2478 |
% |
| 2479 |
% \begin{function}[EXP,updated=2014-03-08]{appendix/name} |
| 2480 |
% \begin{syntax} |
| 2481 |
% name = \{<前名字>,<后名字>\} |
| 2482 |
% name = \Arg{前名字} |
| 2483 |
% \end{syntax} |
| 2484 |
% 设置附录章(对应 \cls{book} 与 \cls{report})或附录节(对应 \cls{article}) |
| 2485 |
% 的名字,用法与普通章节对应的 \opt{name} 选项相同。 |
| 2486 |
% |
| 2487 |
% 注意该选项与 \opt{appendixname} 选项(\ref{subs:capname}~节)在意义上有 |
| 2488 |
% 些重叠,但不完全相同。\opt{appendixname} 选项只用来重定义 |
| 2489 |
% \tn{appendixname},而不管 \tn{appendixname} 如何使用;该选项则决定在章节 |
| 2490 |
% 标题中输出的名字,可以调用 \tn{appendixname} 设置。 |
| 2491 |
% |
| 2492 |
% 该选项的默认设置见表~\ref{tab:appendix-name-default}。 |
| 2493 |
% \end{function} |
| 2494 |
% |
| 2495 |
% \begin{table}[htbp] |
| 2496 |
% \small\centering |
| 2497 |
% \caption{\opt{appendix/name} 选项的默认设置} |
| 2498 |
% \label{tab:appendix-name-default} |
| 2499 |
% \begin{tabular}{llllll} |
| 2500 |
% \toprule |
| 2501 |
% 文档类 & 影响命令 & \opt{scheme = chinese} & 实际定义 |
| 2502 |
% & \opt{scheme = plain} & 实际定义 \\ |
| 2503 |
% \midrule |
| 2504 |
% \cls{article} & \tn{section} & |{}| & & |{}| & \\ |
| 2505 |
% \cls{book}, \cls{report} |
| 2506 |
% & \tn{chapter} & |\appendixname\space| & \verb*|附录 | |
| 2507 |
% & |\appendixname\space| & \verb*|Appendix | \\ |
| 2508 |
% \bottomrule |
| 2509 |
% \end{tabular} |
| 2510 |
% \end{table} |
| 2511 |
% |
| 2512 |
% \begin{function}[EXP]{appendix/number} |
| 2513 |
% \begin{syntax} |
| 2514 |
% number = \Arg{数字输出命令} |
| 2515 |
% \end{syntax} |
| 2516 |
% 设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article}) |
| 2517 |
% 编号的数字输出格式,用法与普通章节对应的 \opt{number} 选项相同。 |
| 2518 |
% |
| 2519 |
% \opt{appendix/number} 选项同时也会控制附录章节计数器的交叉引用。 |
| 2520 |
% 与普通章节的 \opt{number} 选项类似,同样需要注意,该选项不会影响计数器本身 |
| 2521 |
% 的输出,即不影响 \tn{thesection} 或 \tn{thechapter} 的定义。 |
| 2522 |
% |
| 2523 |
% 该选项的默认设置见表~\ref{tab:appendix-number-default}。 |
| 2524 |
% \end{function} |
| 2525 |
% |
| 2526 |
% \begin{table}[htbp] |
| 2527 |
% \small\centering |
| 2528 |
% \caption{\opt{appendix/number} 选项的默认设置} |
| 2529 |
% \label{tab:appendix-number-default} |
| 2530 |
% \begin{tabular}{llllll} |
| 2531 |
% \toprule |
| 2532 |
% 文档类 & 影响命令 & 默认值 \\ |
| 2533 |
% \midrule |
| 2534 |
% \cls{article} & \tn{section} & |\Alph{section}| \\ |
| 2535 |
% \cls{book}, \cls{report} & \tn{chapter} & |\Alph{chapter}| \\ |
| 2536 |
% \bottomrule |
| 2537 |
% \end{tabular} |
| 2538 |
% \end{table} |
| 2539 |
% |
| 2540 |
% \subsection{辅助命令} |
| 2541 |
% \label{subsec:sec-commands} |
| 2542 |
% |
| 2543 |
% \CTeX{} 宏集还提供了一些辅助命令(宏),用于存储章节标题格式,或进行一些条件判断。 |
| 2544 |
% |
| 2545 |
% \begin{function}{\CTEXthepart, \CTEXthechapter, \CTEXthesection, |
| 2546 |
% \CTEXthesubsection, \CTEXthesubsubsection, \CTEXtheparagraph, |
| 2547 |
% \CTEXthesubparagraph} |
| 2548 |
% 以 |\CTEXthe| 开头的这组宏给出结合了 \opt{name} 与 \opt{number} 选项的章节 |
| 2549 |
% 编号输出格式。例如在 \opt{scheme = chinese} 时,默认章编号输出格式就是 |
| 2550 |
% \tn{CTEXthechapter},形如“第一章”。 |
| 2551 |
% |
| 2552 |
% 这组宏在 \CTeX 文档类中将代替 \tn{thechapter} 等宏的作用,在章节中引用本章 |
| 2553 |
% 节的完整编号。例如用于帮助定义自定义的目录格式、页眉格式等。 |
| 2554 |
% \end{function} |
| 2555 |
% |
| 2556 |
% \begin{function}[added=2016-09-18]{\CTEXifname} |
| 2557 |
% \begin{syntax} |
| 2558 |
% \tn{CTEXifname} \Arg{有名字时的内容} \Arg{无名字时的内容} |
| 2559 |
% \end{syntax} |
| 2560 |
% \tn{CTEXifname} 会根据当前章节有无名字展开得到不同内容(通常是格式命令)。 |
| 2561 |
% 由于章节名字总是与编号一起出现,章节有无名字通常也表达为“章节是否编号”。 |
| 2562 |
% 在 \LaTeX{} 中,后者取决于以下几个方面:章节深度是否不大于计数器 |
| 2563 |
% |secnumdepth| 的值,章节标题是否使用不带星号的命令。在 \CTeX{} 宏集中, |
| 2564 |
% 后者还取决于 \opt{.../numbering} 是否为 \opt{true}。 |
| 2565 |
% |
| 2566 |
% \tn{CTEXifname} 可用于 \opt{format}, \opt{titleformat}, \opt{aftertitle}, |
| 2567 |
% \opt{afterskip}, \opt{indent} 这五个选项和 \tn{chapter} 标题 |
| 2568 |
% \opt{beforeskip} 选项的格式设置之中。也可用于帮助定义自定义的目录格式、 |
| 2569 |
% 页眉格式等。 |
| 2570 |
% |
| 2571 |
% 例如,设置章的标题有名字时左对齐,无名字时居中对齐,并且在标题后画一条横线。 |
| 2572 |
% \begin{ctexexam} |
| 2573 |
% \ctexset{ |
| 2574 |
% chapter/format = \CTEXifname{\raggedright}{\centering}, |
| 2575 |
% chapter/aftertitle = \par\CTEXifname{}{\hrule}, |
| 2576 |
% } |
| 2577 |
% \end{ctexexam} |
| 2578 |
% \end{function} |
| 2579 |
% |
| 2580 |
% \subsection{示例} |
| 2581 |
% |
| 2582 |
% 我们最后举一个稍微复杂的例子,来看看上述选项的综合应用。 |
| 2583 |
% |
| 2584 |
% \begin{ctexexam}[labelref=exam:miscopt] |
| 2585 |
% \ctexset { |
| 2586 |
% chapter = { |
| 2587 |
% beforeskip = 0pt, |
| 2588 |
% fixskip = true, |
| 2589 |
% format = \Huge\bfseries, |
| 2590 |
% nameformat = \rule{\linewidth}{1bp}\par\bigskip\hfill\chapternamebox, |
| 2591 |
% number = \arabic{chapter}, |
| 2592 |
% aftername = \par\medskip, |
| 2593 |
% aftertitle = \par\bigskip\nointerlineskip\rule{\linewidth}{2bp}\par |
| 2594 |
% } |
| 2595 |
% } |
| 2596 |
% \newcommand\chapternamebox[1]{% |
| 2597 |
% \parbox{\ccwd}{\linespread{1}\selectfont\centering #1}} |
| 2598 |
% ...... |
| 2599 |
% \chapter{熟悉 \LaTeX} |
| 2600 |
% \end{ctexexam} |
| 2601 |
% 本例的设置效果大致如下: |
| 2602 |
% \begin{center} |
| 2603 |
% \begin{minipage}{.75\linewidth}\Large\bfseries |
| 2604 |
% \hrule height .5bp \relax |
| 2605 |
% \medskip |
| 2606 |
% \hfill\parbox{\ccwd}{\linespread{1}\selectfont\centering 第 1 章} |
| 2607 |
% \par\smallskip |
| 2608 |
% \noindent 熟悉 \LaTeX |
| 2609 |
% \medskip\hrule height 1bp \relax |
| 2610 |
% \end{minipage} |
| 2611 |
% \end{center} |
| 2612 |
% |
| 2613 |
% \section{实用命令} |
| 2614 |
% \label{sec:useful-commands} |
| 2615 |
% \subsection{字号与间距} |
| 2616 |
% |
| 2617 |
% \begin{function}[updated = 2014-03-08, label = ]{\zihao} |
| 2618 |
% \begin{syntax} |
| 2619 |
% \tn{zihao} \Arg{字号} |
| 2620 |
% \end{syntax} |
| 2621 |
% 用于调整字号大小。其中 \meta{字号} 的有效值共有 16 个,如表 \ref{tab:zihao} |
| 2622 |
% 所示。使用 \tn{zihao} 命令调整字体大小时,西文字号大小会始终和中文字号保持一致。 |
| 2623 |
% \end{function} |
| 2624 |
% |
| 2625 |
% \begin{table}[!htbp] |
| 2626 |
% \centering |
| 2627 |
% \def\ZH#1{\zihaopt{#1} & \zihao{#1}} |
| 2628 |
% \tabcolsep=1em |
| 2629 |
% \caption{中文字号}\label{tab:zihao} |
| 2630 |
% \begin{tabular}{>{\ttfamily}S[mode=text,detect-family,table-format=-1] |
| 2631 |
% S[table-format=2.1]S[table-format=2.5]l} |
| 2632 |
% \toprule |
| 2633 |
% {\meta{字号}} & {大小(bp)} & {大小(pt)} & 意义 \\ |
| 2634 |
% \midrule |
| 2635 |
% 0 & 42 & \ZH{0} 初号 \\ |
| 2636 |
% {−0} & 36 & \ZH{-0} 小初号 \\ |
| 2637 |
% 1 & 26 & \ZH{1} 一号 \\ |
| 2638 |
% -1 & 24 & \ZH{-1} 小一号 \\ |
| 2639 |
% 2 & 22 & \ZH{2} 二号 \\ |
| 2640 |
% -2 & 18 & \ZH{-2} 小二号 \\ |
| 2641 |
% 3 & 16 & \ZH{3} 三号 \\ |
| 2642 |
% -3 & 15 & \ZH{-3} 小三号 \\ |
| 2643 |
% 4 & 14 & \ZH{4} 四号 \\ |
| 2644 |
% -4 & 12 & \ZH{-4} 小四号 \\ |
| 2645 |
% 5 & 10.5 & \ZH{5} 五号 \\ |
| 2646 |
% -5 & 9 & \ZH{-5} 小五号 \\ |
| 2647 |
% 6 & 7.5 & \ZH{6} 六号 \\ |
| 2648 |
% -6 & 6.5 & \ZH{-6} 小六号 \\ |
| 2649 |
% 7 & 5.5 & \ZH{7} 七号 \\ |
| 2650 |
% 8 & 5 & \ZH{8} 八号 \\ |
| 2651 |
% \bottomrule |
| 2652 |
% \end{tabular} |
| 2653 |
% \end{table} |
| 2654 |
% |
| 2655 |
% \begin{function}[updated=2014-03-28]{\ziju} |
| 2656 |
% \begin{syntax} |
| 2657 |
% \tn{ziju} \Arg{中文字符宽度的倍数} |
| 2658 |
% \end{syntax} |
| 2659 |
% 用于调整相邻汉字之间的间距,即(在正常中文行文中)前一个汉字的右边缘与后一个汉字 |
| 2660 |
% 的左边缘之间的距离。其中参数可以是任意浮点数值;而中文字符宽度指的是实际汉字的 |
| 2661 |
% 宽度,不包含当前字距。 |
| 2662 |
% |
| 2663 |
% 这个命令会影响 \tn{ccwd} 的值,但不会影响英文字距。 |
| 2664 |
% \end{function} |
| 2665 |
% |
| 2666 |
% \begin{function}[updated=2014-03-27]{\ccwd} |
| 2667 |
% 当前汉字的字宽保存在长度寄存器 \tn{ccwd} 之中。汉字字宽是相邻两个汉字中心 |
| 2668 |
% 之间的距离,包含字距在内。因此修改字距会间接修改字宽。 |
| 2669 |
% \end{function} |
| 2670 |
% |
| 2671 |
% \subsection{中文数字转换} |
| 2672 |
% |
| 2673 |
% \CTeX{} 宏集的中文数字转换功能实际上是调用 \pkg{zhnumber} 宏包来完成。下面只 |
| 2674 |
% 介绍一些基本的用法,更高级的用法可以查阅 \pkg{zhnumber} 宏包的文档。 |
| 2675 |
% |
| 2676 |
% \begin{function}[updated=2016-05-01]{\chinese} |
| 2677 |
% \begin{syntax} |
| 2678 |
% \tn{chinese} \Arg{counter} |
| 2679 |
% \tn{pagenumbering} \{chinese\} |
| 2680 |
% \end{syntax} |
| 2681 |
% \tn{chinese} 命令与 \tn{roman} 等命令的用法类似,作用在一个 \LaTeX{} |
| 2682 |
% 计数器上,将计数器的值以中文数字的形式输出。 |
| 2683 |
% \end{function} |
| 2684 |
% |
| 2685 |
% \begin{function}[added=2014-03-08]{\zhnumber} |
| 2686 |
% \begin{syntax} |
| 2687 |
% \tn{zhnumber} \Arg{number} |
| 2688 |
% \end{syntax} |
| 2689 |
% 以中文格式输出数字。这里的数字可以是整数、小数和分数。 |
| 2690 |
% \end{function} |
| 2691 |
% |
| 2692 |
% \begin{function}[added=2014-03-08]{\zhdigits} |
| 2693 |
% \begin{syntax} |
| 2694 |
% \tn{zhdigits} \Arg{number} |
| 2695 |
% \end{syntax} |
| 2696 |
% 将阿拉伯数字转换为中文数字串。 |
| 2697 |
% \end{function} |
| 2698 |
% |
| 2699 |
% \begin{function}{\CTEXnumber} |
| 2700 |
% \begin{syntax} |
| 2701 |
% \tn{CTEXnumber} "\"<macro> \Arg{number} |
| 2702 |
% \end{syntax} |
| 2703 |
% |\|<macro> 必须是一个 \TeX{} 宏,不需预先定义。\tn{CTEXnumber} 通过 |
| 2704 |
% \tn{zhnumber} 将 \meta{number} 转为中文数字,最后将结果存储在 |\|<macro> |
| 2705 |
% 里。对 |\|<macro> 的定义是局部的,将它展开一次就可以得到转换结果。 |
| 2706 |
% \end{function} |
| 2707 |
% |
| 2708 |
% 一般来说,并不需要使用 \tn{CTEXnumber},直接使用 \tn{zhnumber} 即可。但是,如果 |
| 2709 |
% 在文档中需要多次使用同一个数字 \meta{number} 的中文形式,就可以先用 |
| 2710 |
% \tn{CTEXnumber} 将结果保存起来备用,而不是每次使用时都用 \tn{zhnumber} 现场 |
| 2711 |
% 转换一次。 |
| 2712 |
% |
| 2713 |
% \begin{function}{\CTEXdigits} |
| 2714 |
% \begin{syntax} |
| 2715 |
% \tn{CTEXdigits} "\"<macro> \Arg{number} |
| 2716 |
% \end{syntax} |
| 2717 |
% \tn{CTEXdigits} 与 \tn{CTEXnumber} 类似,但其转换的结果是中文数字串,而不是 |
| 2718 |
% 中文数字。 |
| 2719 |
% \end{function} |
| 2720 |
% |
| 2721 |
% \subsection{杂项} |
| 2722 |
% |
| 2723 |
% \begin{function}{\CTeX} |
| 2724 |
% 用于显示 \CTeX 标志。 |
| 2725 |
% \end{function} |
| 2726 |
% |
| 2727 |
% \section{\LuaLaTeX{} 下的中文支持方式} |
| 2728 |
% \label{sec:lualatex-chinese} |
| 2729 |
% |
| 2730 |
% 在 \LuaLaTeX{} 下,\CTeX{} 宏集依赖 \pkg{LuaTeX-ja} 宏包来完成中文支持。 |
| 2731 |
% 该宏包是日本 \TeX{} 社区的北川弘典、前田一贵、八登崇之等人开发的,设计目的主要 |
| 2732 |
% 是在 \LuaTeX{} 引擎下实现日本 p\TeX{} 引擎的(大部分)功能。它为了兼容 p\LaTeX |
| 2733 |
% 的使用习惯,对 \LaTeXe 的 \pkg{NFSS} 作了不少修改和扩充。这对于简体中文用户来说 |
| 2734 |
% 不是必要的,因而 \CTeX{} 禁用了它在 \LaTeX{} 格式下的大部分设置,只保留了必要的 |
| 2735 |
% 部分。同时修改了它的字体设置方式,使得相关命令与 \pkg{xeCJK} 宏包大致相同。 |
| 2736 |
% |
| 2737 |
% 20150420 版以后的 \pkg{LuaTeX-ja} 宏包开始支持竖排,但 \CTeX{} 暂不支持竖排。 |
| 2738 |
% |
| 2739 |
% \subsection{\LuaLaTeX{} 下替代字体的设置} |
| 2740 |
% |
| 2741 |
% \begin{function}[updated=2020-04-30]{AlternateFont} |
| 2742 |
% \begin{syntax} |
| 2743 |
% \tn{setCJKfamilyfont} \Arg{family} \Arg{base font name} |
| 2744 |
% \ [ |
| 2745 |
% \ <base font features> , |
| 2746 |
% \ AlternateFont = |
| 2747 |
% \ \{ |
| 2748 |
% \ \Arg{character range_1} \Arg{alternate font name_1} , |
| 2749 |
% \ \Arg{character range_2} \Arg{alternate font name_2} \Arg{alternate font features_2} , |
| 2750 |
% \ ...... |
| 2751 |
% \ \} |
| 2752 |
% \ ] |
| 2753 |
% \end{syntax} |
| 2754 |
% 在设置字体族 \meta{family} 的时候,同时设置该字体族在字符范围 |
| 2755 |
% \meta{character range_n} 内,对应字形的替代字体。 |
| 2756 |
% \end{function} |
| 2757 |
% |
| 2758 |
% \begin{function}[added=2014-04-14]{CharRange} |
| 2759 |
% \begin{syntax} |
| 2760 |
% \tn{setCJKfamilyfont} \Arg{family} \Arg{alternate font name} |
| 2761 |
% \ [ |
| 2762 |
% \ CharRange = \Arg{character range} , |
| 2763 |
% \ <alternate font features> |
| 2764 |
% \ ] |
| 2765 |
% \end{syntax} |
| 2766 |
% 只设置字体族 \meta{family} 在字符范围 \meta{character range} 内,对应字形的 |
| 2767 |
% 替代字体。 |
| 2768 |
% \end{function} |
| 2769 |
% |
| 2770 |
% 一个 \tn{setCJKfamilyfont} 里只能使用一次 \opt{CharRange} 或者 |
| 2771 |
% \opt{AlternateFont},但可以将它们分开重叠使用。例如下面的方式是有效的。 |
| 2772 |
% |
| 2773 |
% \begin{ctexexam} |
| 2774 |
% \setCJKmainfont[AlternateFont={...}{...}, ...]{...} |
| 2775 |
% \setCJKmainfont[CharRange={"4E00->"67FF,-2}, ...]{...} |
| 2776 |
% \setCJKmainfont[CharRange={"6800->"9FFF}, ...]{...} |
| 2777 |
% \end{ctexexam} |
| 2778 |
% |
| 2779 |
% \begin{function}[EXP,added=2020-04-30]{declarecharrange} |
| 2780 |
% \begin{syntax} |
| 2781 |
% \tn{ctexset} |
| 2782 |
% \ \{ |
| 2783 |
% \ declarecharrange = |
| 2784 |
% \ \{ |
| 2785 |
% \ \Arg{name_1} \Arg{character range_1} , |
| 2786 |
% \ \Arg{name_2} \Arg{character range_2} , |
| 2787 |
% \ ... |
| 2788 |
% \ \} |
| 2789 |
% \ \} |
| 2790 |
% \end{syntax} |
| 2791 |
% 预先声明字符范围。声明字符范围 \meta{name} 之后,它的名字 \meta{name} 可以 |
| 2792 |
% 用在 \opt{AlternateFont} 和 \opt{CharRange} 选项的 \meta{character range} |
| 2793 |
% 之中,表示对应的字符范围。 |
| 2794 |
% \end{function} |
| 2795 |
% |
| 2796 |
% 在声明字符范围 \meta{name} 的同时,还为 \tn{setCJKmainfont} 等字体设置命令定义 |
| 2797 |
% 了选项 \meta{name},用于设置对应字符的替代字体: |
| 2798 |
% \begin{syntax} |
| 2799 |
% \meta{name} = \Arg{alternate font name} |
| 2800 |
% \meta{name} = \Arg{alternate font name} \Arg{alternate font features} |
| 2801 |
% \end{syntax} |
| 2802 |
% \meta{name} 选项可以与 \opt{AlternateFont} 共同使用,但不能与 \opt{CharRange} |
| 2803 |
% 一起使用。如果没有给 \meta{name} 设置值,则等价于设置 \opt{CharRange=\meta{name}}, |
| 2804 |
% 即只设置 \meta{name} 对应的字符范围的替代字体。 |
| 2805 |
% |
| 2806 |
% \begin{function}[EXP,added=2014-04-15]{clearalternatefont,resetalternatefont} |
| 2807 |
% \begin{syntax} |
| 2808 |
% \tn{ctexset} |
| 2809 |
% \ \{ |
| 2810 |
% \ clearalternatefont = \Arg{family_1, family_2, ...} , |
| 2811 |
% \ resetalternatefont = \Arg{family_1, family_2, ...} , |
| 2812 |
% \ clearalternatefont , |
| 2813 |
% \ resetalternatefont |
| 2814 |
% \ \} |
| 2815 |
% \end{syntax} |
| 2816 |
% 清除与重置 CJK 字体族 \meta{family} 的替换字体设置。如果没有给定值,则作用于 |
| 2817 |
% 当前 CJK 字体族。清除与重置操作总是全局的。 |
| 2818 |
% \end{function} |
| 2819 |
% |
| 2820 |
% \section{\CTeX{} 宏集的配置文件} |
| 2821 |
% |
| 2822 |
% \CTeX{} 宏集提供了不同的配置文件,可以通过修改配置文件来改变 \CTeX{} 宏集的 |
| 2823 |
% 默认行为。 |
| 2824 |
% |
| 2825 |
% 在多数情况下,并不需要修改配置文件,\CTeX{} 宏集的默认设置已经能满足大多数用 |
| 2826 |
% 户的需要。不恰当地修改 \CTeX{} 宏集的默认行为也可能导致同一文件在别处无法正 |
| 2827 |
% 常编译或排版效果完全不同,因此修改应该慎重。 |
| 2828 |
% |
| 2829 |
% 但在一些情况下,直接修改配置文件仍是必要的,例如: |
| 2830 |
% \begin{itemize} |
| 2831 |
% \item 系统没有安装默认设置的字体文件,无法编译。 |
| 2832 |
% \item 需要经常编译来自其他系统的中文 \TeX{} 文件,但对方的操作系统或默认设置 |
| 2833 |
% 与本机不同。 |
| 2834 |
% \end{itemize} |
| 2835 |
% |
| 2836 |
% 与 \CTeX{} 宏集的源代码一样,配置文件采用 \LaTeXiii{} 的语法编写。 |
| 2837 |
% |
| 2838 |
% \CTeX{} 宏集的配置文件随宏包其他文件一起安装在 \TeX{} 系统 TDS 目录树中,文 |
| 2839 |
% 件后缀是 \file{.cfg}。为了避免本地配置文件内容因 \CTeX{} 宏集的更新而丢失, |
| 2840 |
% 不要直接修改系统 TDS 目录树中的配置文件,而应该将系统自带的配置文件复制到本 |
| 2841 |
% 地的或用户私有的 TDS 目录树中修改,并运行 \bashcmd{texhash} 命令刷新文件名数据库。 |
| 2842 |
% |
| 2843 |
% 例如对于 \TeX{} Live,系统自带的配置文件就在 \TeX{} Live 安装目录下的 |
| 2844 |
% \path{texmf-dist/tex/latex/ctex/config/} 子目录下,可以修改它的副本,保存在 |
| 2845 |
% 本地 TDS 树的 \path{texmf-local/tex/latex/ctex/} 目录下,或者用户 TDS 树的 |
| 2846 |
% \path{~/texmf/tex/latex/ctex/} 目录下,作为本地/用户专有的 |
| 2847 |
% 配置文件。复制配置文件后需要运行 |texhash| 命令使本地配置文件生效。 |
| 2848 |
% |
| 2849 |
% \MiKTeX{} 的配置文件也保存在类似的目录结构中,\MiKTeX{} 管理的 |
| 2850 |
% 几个 TDS 根目录可以在 \MiKTeX{} Options 设置项中查看到,这里不再赘述。 |
| 2851 |
% |
| 2852 |
% 除了修改本地 \TeX{} 系统中的配置文件,对于特定文档,也可以将修改过的配置文件 |
| 2853 |
% 保存在文档的工作目录下。此时配置文件就只对工作目录下的所有文档生效。 |
| 2854 |
% |
| 2855 |
% \subsection{修改宏包默认选项} |
| 2856 |
% |
| 2857 |
% 配置文件 \file{ctexopts.cfg} 可以用来修改宏包的默认选项。随系统安装的配置文 |
| 2858 |
% 件除了文件信息声明外没有实际的内容,但在注释中给出了一个简单的示例,只要取消 |
| 2859 |
% 注释就可以生效。 |
| 2860 |
% |
| 2861 |
% \begin{ctexexam} |
| 2862 |
% % 系统自带 ctexopts.cfg 注释中的示例语句,固定默认字体集为 windows。 |
| 2863 |
% % 该设置可以用在安装了 Windows 字体的非 Windows 系统中。 |
| 2864 |
% \ctex_set:nn { option } { fontset = windows } |
| 2865 |
% \end{ctexexam} |
| 2866 |
% 如上例所示,宏包选项通常使用 \LaTeXiii{} 的 \cs{ctex_set:nn} 命令完成键值设置, |
| 2867 |
% 第一个参数是固定的子模块 |option|,第二个参数中是用户定义的新的默认宏包选项。 |
| 2868 |
% |
| 2869 |
% \file{ctexopts.cfg} 中的设置将在 \CTeX{} 宏集的开始处,定义过宏包选项之后, |
| 2870 |
% \tn{ProcessKeysOptions} 命令之前生效。最好只使用此配置文件修改宏包默认选项。 |
| 2871 |
% |
| 2872 |
% \subsection{宏包载入后的配置} |
| 2873 |
% |
| 2874 |
% 配置文件 \file{ctex.cfg} 将在宏包的末尾被载入生效。可以用它完成任意的设置, |
| 2875 |
% 或是覆盖已有的定义。随系统安装的配置文件除版本信息外没有实际内容,注意配置文 |
| 2876 |
% 件中也使用 \LaTeXiii{} 语法。 |
| 2877 |
% |
| 2878 |
% \begin{ctexexam} |
| 2879 |
% % 简单的 ctex.cfg 内容示例。 |
| 2880 |
% % 修改默认的页面格式设置。 |
| 2881 |
% \pagestyle{plain} |
| 2882 |
% \end{ctexexam} |
| 2883 |
% |
| 2884 |
% \begin{ctexexam} |
| 2885 |
% % 略复杂的 ctex.cfg 内容示例:禁止段末孤字成行。 |
| 2886 |
% % 在使用 XeTeX 编译时,打开 xeCJK 的 CheckSingle 选项。 |
| 2887 |
% \sys_if_engine_xetex:T |
| 2888 |
% { |
| 2889 |
% \xeCJKsetup { CheckSingle } |
| 2890 |
% } |
| 2891 |
% % 在使用 LuaTeX 编译时,设置 LuaTeX-ja 的 jcharwidowpenalty 参数。 |
| 2892 |
% \sys_if_engine_luatex:T |
| 2893 |
% { |
| 2894 |
% \ltjsetparameter { jcharwidowpenalty = 10000 } |
| 2895 |
% } |
| 2896 |
% \end{ctexexam} |
| 2897 |
% |
| 2898 |
% \subsection{配置标题中文翻译} |
| 2899 |
% |
| 2900 |
% 由于 \CTeX{} 宏集需要同时支持 GBK 和 UTF-8 两种编码,因此对标题的中文翻译写 |
| 2901 |
% 在两个配置文件当中:\file{ctex-name-gbk.cfg} 和 \file{ctex-name-utf8.cfg}。 |
| 2902 |
% 两个文件的设置相同,只是编码不同。 |
| 2903 |
% |
| 2904 |
% 为了同一文档在不同电脑上编译效果的一致性,通常不建议修改默认的中文翻译。 |
| 2905 |
% |
| 2906 |
% \subsection{自定义字体集} |
| 2907 |
% |
| 2908 |
% \ref{subs:options-CJK-font}~节介绍的用于 |fontset| 选项的自定义字库文件, |
| 2909 |
% 类似于 \CTeX{} 宏集的配置文件,也应该与其他本地配置文件一起保存在本地 |
| 2910 |
% \texttt{TDS} 目录树下,并可以配合 \file{ctexopts.cfg} 等配置文件使用。 |
| 2911 |
% |
| 2912 |
% \section{对旧版本的兼容性} |
| 2913 |
% |
| 2914 |
% \subsection{\CTeX\ 0.8a 及以前的版本} |
| 2915 |
% |
| 2916 |
% 在 ctex-kit 项目成立之前,\CTeX 宏包的最后一个版本是 \CTeX\ |
| 2917 |
% 0.8a(2007/05/06)。 |
| 2918 |
% |
| 2919 |
% 第 2 版未考虑对这些很早版本的兼容性。 |
| 2920 |
% |
| 2921 |
% \subsection{\CTeX\ 0.9--\CTeX\ 1.0d} |
| 2922 |
% |
| 2923 |
% 在 2009 年在 ctex-kit 项目成立后,新增了 \XeTeX{} 引擎的支持,并增加了不少控 |
| 2924 |
% 制字体的命令和选项。 |
| 2925 |
% |
| 2926 |
% 这里主要介绍新版本 \CTeX 宏包相对 1.02d 版本(2014/06/09)的兼容性。 |
| 2927 |
% |
| 2928 |
% 第 2 版的 \CTeX 宏包已尽力保证对 1.0x 版本的兼容性,原有为 1.0x 编写的代码, |
| 2929 |
% 在第 2 版的 \CTeX 宏包下保证仍能编译,并且在大多数情况下保持编译效果不变。 |
| 2930 |
% |
| 2931 |
% \CTeX 宏包在 0.8a 以前的版本支持以 \pkg{CCT} 作为底层中文支持方式,从 0.9 版 |
| 2932 |
% 之后即不再推荐使用,只保留向后兼容。在 \CTeX 宏包第 2 版中则完全不再支持 |
| 2933 |
% \pkg{CCT}。 |
| 2934 |
% |
| 2935 |
% 下面这些是在旧版本 \CTeX 宏包中存在,而在新版本中已不建议使用的选项和命令, |
| 2936 |
% 在未来版本中可能会删去它们的支持。 |
| 2937 |
% |
| 2938 |
% 在多数情况下它们的功能仍将保留,但也有部分选项命令功能已失效。 |
| 2939 |
% |
| 2940 |
% \begin{function}{cs4size, c5size} |
| 2941 |
% 分别相当于 |zihao=-4| 和 |zihao=5|,过时选项。 |
| 2942 |
% \end{function} |
| 2943 |
% |
| 2944 |
% \begin{function}{CCT, CCTfont} |
| 2945 |
% 相关选项已删除。 |
| 2946 |
% \end{function} |
| 2947 |
% |
| 2948 |
% \begin{function}{indent, noindent} |
| 2949 |
% \opt{indent} 和 \opt{noindent} 什么也不做,过时选项。 |
| 2950 |
% |
| 2951 |
% 在中文版式下,\pkg{ctex} 宏包的相关功能在与标准文档类及其衍生文档类联用时 |
| 2952 |
% 默认打开。\CTeX{} 文档类的相关功能由章节标题的 \opt{afterindent} 选项的值 |
| 2953 |
% 来确定。 |
| 2954 |
% \end{function} |
| 2955 |
% |
| 2956 |
% \begin{function}[label = ]{zhmap, nozhmap} |
| 2957 |
% \opt{zhmap} 宏包选项增加了参数,扩充了功能,除了支持真假值参数外,还支持选择 |
| 2958 |
% \pkg{zhmCJK} 作为底层中文处理宏包。(\ref{subs:options-CJK-font}~节) |
| 2959 |
% |
| 2960 |
% \opt{nozhmap} 选项相当于 |zhmap=false|。过时选项。 |
| 2961 |
% \end{function} |
| 2962 |
% |
| 2963 |
% \begin{function}{winfonts, adobefonts, nofonts} |
| 2964 |
% 宏包选项 \opt{winfonts} 相当于 |fontset=windows|,\opt{adobefonts} 相当于 |
| 2965 |
% |fontset=adobe|,\opt{nofonts} 相当于 |fontset=none|。这几个选项是过时选项, |
| 2966 |
% 对于新文档,应使用 \opt{fontset} 选项设置不同字体集。 |
| 2967 |
% |
| 2968 |
% 另外,第 2 版 \CTeX 宏包的默认字体不再是 Windows 系统字体,而是根据检测到的 |
| 2969 |
% 操作系统选择使用 Windows、Mac 的系统字体还是 Fandol 字体 |
| 2970 |
% (\ref{subs:options-CJK-font}~节)。 |
| 2971 |
% \end{function} |
| 2972 |
% |
| 2973 |
% \begin{function}[label = ]{punct, nopunct} |
| 2974 |
% 旧版本中宏包 \opt{punct} 选项没有参数,现在可以用参数设定标点风格 |
| 2975 |
% (\ref{subs:options-type-style}~节)。原有无参形式的 \opt{punct} 选项相当 |
| 2976 |
% 于 |punct=quanjiao|。 |
| 2977 |
% |
| 2978 |
% 旧版宏包中 \opt{nopunct} 选项的效果大致相当于 |punct=plain|。过时选项,不推荐使用。 |
| 2979 |
% \end{function} |
| 2980 |
% |
| 2981 |
% \begin{function}{cap, nocap} |
| 2982 |
% 原有的 \opt{cap} 和 \opt{nocap} 选项由新的 \opt{scheme} 选项代替。 |
| 2983 |
% (\ref{subs:options-type-style}~节) |
| 2984 |
% |
| 2985 |
% \opt{cap} 选项相当于 |scheme = chinese|,\opt{nocap} 选项相当 |
| 2986 |
% 于 |scheme = plain|。它们均已过时,仅因兼容性而保留。 |
| 2987 |
% \end{function} |
| 2988 |
% |
| 2989 |
% \begin{function}[label = ]{space, nospace} |
| 2990 |
% 新版本宏包 \opt{space} 选项增加真假值参数。 |
| 2991 |
% (\ref{subs:options-type-style}~节) |
| 2992 |
% |
| 2993 |
% \opt{nospace} 选项相当于 |space=false|,成为过时选项。 |
| 2994 |
% \end{function} |
| 2995 |
% |
| 2996 |
% \begin{function}{fancyhdr} |
| 2997 |
% 新版本宏包中总是自动处理对 \pkg{fancyhdr} 宏包的兼容性,而由用户自己使用 |
| 2998 |
% \tn{usepackage} 载入 \pkg{fancyhdr} 宏包。 |
| 2999 |
% |
| 3000 |
% \opt{fancyhdr} 选项过时,因兼容性保留,功能是载入 \pkg{fancyhdr} 宏包。 |
| 3001 |
% \end{function} |
| 3002 |
% |
| 3003 |
% \begin{function}{hyperref} |
| 3004 |
% 新版本宏包中总是自动处理对 \pkg{hyperref} 宏包的兼容性,而由用户自己使用 |
| 3005 |
% \tn{usepackage} 载入 \pkg{hyperref} 宏包。 |
| 3006 |
% |
| 3007 |
% \opt{hyperref} 选项过时,因兼容性保留,功能是在导言区末尾载入 \pkg{hyperref} |
| 3008 |
% 宏包。 |
| 3009 |
% \end{function} |
| 3010 |
% |
| 3011 |
% \begin{function}{fntef} |
| 3012 |
% 旧版本的 \opt{fntef} 选项用于统一 \pkg{CCTfntef} 与 \pkg{CJKfntef} 的界面, |
| 3013 |
% 新版本 \CTeX{} 宏集不再支持 \pkg{CCT},也不再自动载入 \pkg{CJKfntef} 或 |
| 3014 |
% \pkg{xeCJKfntef} 宏包,而仅在其末尾做适当格式调整。 |
| 3015 |
% |
| 3016 |
% \opt{fntef} 选项过时,因兼容性保留,功能是根据引擎载入 \pkg{CJKfntef} |
| 3017 |
% (\pdfTeX{}) 或 \pkg{xeCJKfntef} (\XeTeX{}) 宏包。 |
| 3018 |
% \end{function} |
| 3019 |
% |
| 3020 |
% \begin{function}{\CTEXunderdot, \CTEXunderline, \CTEXunderdblline, |
| 3021 |
% \CTEXunderwave, \CTEXsout, \CTEXxout, CTEXfilltwosides} |
| 3022 |
% 在调用 \opt{fntef} 宏包选项的同时,旧版本 \CTeX{} 宏包由于需要支持 \pkg{CCT} |
| 3023 |
% 系统,会将以 |\CJK| 开头的 \tn{CJKunderline} 等宏换名为以 |\CTEX| 开头的 |
| 3024 |
% \tn{CTEXunderline} 等宏。此功能在新版本的 \CTeX{} 宏集中已失去意义。此外, |
| 3025 |
% 在 \pdfTeX{} 引擎下,用于设置格式的 \tn{CJKunderdotbasesep} 等宏也被更名为 |
| 3026 |
% \tn{CTEXunderdotbasesep} 等宏。 |
| 3027 |
% |
| 3028 |
% 在新版本中,上述由 \opt{fntef} 衍生的相关命令和环境均被移除。 |
| 3029 |
% \end{function} |
| 3030 |
% |
| 3031 |
% \begin{function}{\CTEXsetfont} |
| 3032 |
% 更新当前的中文字体信息,包括当前字距(\tn{ccwd})和段首缩进(\tn{parindent})。 |
| 3033 |
% 一般来说,用户无需使用这个命令。 |
| 3034 |
% \end{function} |
| 3035 |
% |
| 3036 |
% \begin{function}{\CTEXindent} |
| 3037 |
% 更新 \tn{ccwd} 宽度后设置 |\parindent=2\ccwd|。过时命令。 |
| 3038 |
% \end{function} |
| 3039 |
% |
| 3040 |
% \begin{function}{\CTEXnoindent} |
| 3041 |
% 设置 |\parindent=0pt|。过时命令。 |
| 3042 |
% \end{function} |
| 3043 |
% |
| 3044 |
% \begin{function}{\CTEXsetup} |
| 3045 |
% \begin{syntax} |
| 3046 |
% \tn{CTEXsetup}\oarg{选项}\Arg{标题} |
| 3047 |
% \end{syntax} |
| 3048 |
% 相当于设置了 |
| 3049 |
% \texttt{\tn{ctexset}\{ \meta{标题} = \Arg{选项} \}}。 |
| 3050 |
% 过时命令。 |
| 3051 |
% \end{function} |
| 3052 |
% |
| 3053 |
% \begin{function}{\CTEXoptions} |
| 3054 |
% \begin{syntax} |
| 3055 |
% \tn{CTEXoptions}\oarg{选项} |
| 3056 |
% \end{syntax} |
| 3057 |
% 相当于设置了 |
| 3058 |
% \texttt{\tn{ctexset}\Arg{选项}}。 |
| 3059 |
% 过时命令。 |
| 3060 |
% \end{function} |
| 3061 |
% |
| 3062 |
% \begin{function}{\Chinese} |
| 3063 |
% \begin{syntax} |
| 3064 |
% \tn{Chinese}\Arg{counter} |
| 3065 |
% \end{syntax} |
| 3066 |
% 新版宏集中 \tn{chinese} 统一了旧版本中 \tn{chinese} 和 \tn{Chinese} 的功能。因此, |
| 3067 |
% 该命令已过时。 |
| 3068 |
% \end{function} |
| 3069 |
% |
| 3070 |
% \begin{function}{captiondelimiter} |
| 3071 |
% 原为 \tn{CTEXoptions} 命令的选项,用于控制 \tn{caption} 编号后面的标点。此选 |
| 3072 |
% 项已过时,并在新版本的 \CTeX 宏包中失效。 |
| 3073 |
% |
| 3074 |
% 可以使用 \pkg{caption} 宏包的 \opt{labelsep} 选项来完成同样的功能。 |
| 3075 |
% \begin{ctexexam} |
| 3076 |
% % 代替 \CTEXoptions[captiondelimiter={:}] |
| 3077 |
% \usepackage{caption} |
| 3078 |
% \captionsetup{labelsep=colon} |
| 3079 |
% \end{ctexexam} |
| 3080 |
% \end{function} |
| 3081 |
% |
| 3082 |
% \subsection{\CTeX\ 1.02c 以后的 SVN 开发版} |
| 3083 |
% |
| 3084 |
% \CTeX 宏包在 1.02c 版本(2011/03/11)之后在 Google code 上的 SVN 开发版本, |
| 3085 |
% 内部版本号一直升到 1.11 版,但从未正式发布。SVN 开发版在 1.02c 版本的基础上 |
| 3086 |
% 新增的功能在第 2 版中大多继承了过来,但新增的命令与选项都不再保持兼容。 |
| 3087 |
% |
| 3088 |
% \CTeX 宏包第 2 版不保证对未发布的 SVN 开发版兼容。 |
| 3089 |
% |
| 3090 |
% \subsection{\CTeX\ 2.2 之前的版本} |
| 3091 |
% |
| 3092 |
% \begin{function}{part/beforeskip, chapter/beforeskip, section/beforeskip, |
| 3093 |
% subsection/beforeskip, subsubsection/beforeskip, paragraph/beforeskip, |
| 3094 |
% subparagraph/beforeskip} |
| 3095 |
% 在 \CTeX\ 2.2 之前的版本中,\opt{beforeskip} 选项的符号还用于确定章节标题后 |
| 3096 |
% 首段的缩进。当 \opt{beforeskip} 是负值时,章节标题后的第一段按英文文档的排版 |
| 3097 |
% 习惯,没有首行缩进,否则保留首行缩进。 |
| 3098 |
% |
| 3099 |
% 这一特性在 2.2 版和后续版本中不再保留,相应的功能通过新的 \opt{afterindent} |
| 3100 |
% 选项来设置。如果原先设置 \opt{beforeskip} 为负值,在新版本中需要改为正值, |
| 3101 |
% 并设置相应的 \opt{afterindent} 选项为 \opt{false}。 |
| 3102 |
% \end{function} |
| 3103 |
% |
| 3104 |
% \begin{function}{section/afterskip, subsection/afterskip, |
| 3105 |
% subsubsection/afterskip, paragraph/afterskip, subparagraph/afterskip} |
| 3106 |
% 在 \CTeX\ 2.2 之前的版本中,对于 \tn{section} 级以下标题,\opt{afterskip} |
| 3107 |
% 选项的符号用于确定标题与随后正文是否排在同一段。 |
| 3108 |
% 如果是正值,则正文另起一段,否则标题与随后正文排在同一段, |
| 3109 |
% \opt{afterskip} 的绝对值给出水平间距。 |
| 3110 |
% |
| 3111 |
% 这一特性在 2.2 版和后续版本中不再保留,相应的功能通过新的 \opt{runin} |
| 3112 |
% 选项来设置。如果原先设置 \opt{afterskip} 为负值,在新版本中需要改为正值, |
| 3113 |
% 并设置相应的 \opt{runin} 选项为 \opt{true}。 |
| 3114 |
% \end{function} |
| 3115 |
% |
| 3116 |
% \subsection{\CTeX\ 2.4.1 和 2.4.2} |
| 3117 |
% |
| 3118 |
% \begin{function}{part/fixbeforeskip, chapter/fixbeforeskip} |
| 3119 |
% 这两个选项已经被删除,相应功能由新的选项 \opt{fixskip} 提供。 |
| 3120 |
% \end{function} |
| 3121 |
% |
| 3122 |
% \subsection{\CTeX\ 2.5 之前的版本} |
| 3123 |
% |
| 3124 |
% \CTeX\ 2.5 有一些比较大的变动。 |
| 3125 |
% |
| 3126 |
% \begin{function}[label =]{UTF8, GBK} |
| 3127 |
% (pdf)\LaTeX{} 格式下,文档编码初始值统一设置成 UTF-8。因此,仍旧使用 GBK |
| 3128 |
% 编码的文档,需要在文档类或宏包选项中显式指定 \opt{GBK}。 |
| 3129 |
% \end{function} |
| 3130 |
% |
| 3131 |
% \begin{function}[label =]{\CTEXunderdot, \CTEXunderline, \CTEXunderdblline, |
| 3132 |
% \CTEXunderwave, \CTEXsout, \CTEXxout, CTEXfilltwosides} |
| 3133 |
% 不再默认载入 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 宏包,同步移除有关命令 |
| 3134 |
% 和环境。若需使用相关宏包,建议用户使用 \tn{usepackage} 命令主动载入。 |
| 3135 |
% \end{function} |
| 3136 |
% |
| 3137 |
% \begin{function}[label =]{fntef} |
| 3138 |
% 作为兼容性保留,会视编译引擎载入相应宏包。 |
| 3139 |
% \end{function} |
| 3140 |
% |
| 3141 |
% \begin{function}{windows} |
| 3142 |
% 不再支持 Windows XP 系统,默认要求 Windows 系统有微软雅黑字体。 |
| 3143 |
% 建议 Windows XP 系统的用户及时更新操作系统。若一定要在 Windows XP 中使用, |
| 3144 |
% 请使用 2.5 以前的版本。 |
| 3145 |
% \end{function} |
| 3146 |
% |
| 3147 |
% \begin{function}{windowsold, windowsnew} |
| 3148 |
% 过时字库选项,作为兼容性保留,功能是载入 \opt{windows} 字库。 |
| 3149 |
% \end{function} |
| 3150 |
% |
| 3151 |
% \begin{function}{ubuntu} |
| 3152 |
% 改用思源(Noto CJK)和文鼎字库。该字库不再支持 \pdfLaTeX 编译。 |
| 3153 |
% \end{function} |
| 3154 |
% |
| 3155 |
% \begin{function}[label =]{AlternateFont} |
| 3156 |
% 不再支持将替代字体的可选项放在字体名之前的方括号中, |
| 3157 |
% 新的语法是将可选项放在字体名之后的花括号之内。 |
| 3158 |
% \end{function} |
| 3159 |
% |
| 3160 |
% 除了以上列出的选项以外,当用户使用 \CTeX{} 系列文档类,且使用 \LaTeX 或 |
| 3161 |
% \upLaTeX 编译时,若用户没有在文档类选项中显式指定 |dvips|/|dvipdfmx|/|dvisvgm| |
| 3162 |
% 等驱动选项,则文档类指定默认驱动为 \dvipdfmx。 |
| 3163 |
% |
| 3164 |
% \section{宏集依赖情况与手工安装方法} |
| 3165 |
% \label{sec:dep-ins} |
| 3166 |
% |
| 3167 |
% 本节介绍 \CTeX{} 宏集的依赖情况,并介绍手工编译安装的具体方法。 |
| 3168 |
% 通常用户只需参照第 \ref{subsec:easy-ins}~节介绍的方法,使用发行版自带的包管理器安装 |
| 3169 |
% 本宏集。 |
| 3170 |
% |
| 3171 |
% \CTeX{} 宏集有两个源文件:\file{ctex.dtx}、\file{ctexpunct.spa}。 |
| 3172 |
% 使用不同的编译方式时,\CTeX{} 依赖的宏包略有不同。在手工安装 \CTeX{} 宏集之前,请确保 |
| 3173 |
% 你的 \TeX{} 发行版中已经正确安装了这些宏包。\CTeX{} 依赖宏包的详情叙述如下: |
| 3174 |
% |
| 3175 |
% \begin{itemize} |
| 3176 |
% \item \pkg{expl3}、\pkg{xparse} 和 \pkg{l3keys2e} 宏包。它们属于 \pkg{l3kernel} |
| 3177 |
% 和 \pkg{l3packages} 宏集。 |
| 3178 |
% \item \pkg{indentfirst} 宏包,属于 \pkg{tools} 宏集。 |
| 3179 |
% \item \pkg{zhnumber} 宏包。 |
| 3180 |
% \item[\ding{229}] 以上是各种编译方式都必需的依赖项。 |
| 3181 |
% \item \pkg{CJK} 宏集。 |
| 3182 |
% \item \pkg{CJKpunct} 宏包。 |
| 3183 |
% \item \pkg{xCJK2uni} 宏包。 |
| 3184 |
% \item \pkg{zhmetrics} 宏包。 |
| 3185 |
% \item \pkg{zhmCJK} 宏包,它还依赖 |
| 3186 |
% \begin{itemize} |
| 3187 |
% \item \pkg{iftex} 宏包。 |
| 3188 |
% \item \pkg{ltxcmds} 宏包。 |
| 3189 |
% \item \pkg{kvoptions} 宏包。 |
| 3190 |
% \item \pkg{kvsetkeys} 宏包。 |
| 3191 |
% \item \pkg{keyval} 宏包,\pkg{graphics} 宏集。 |
| 3192 |
% \end{itemize} |
| 3193 |
% \item[\ding{229}] 以上是使用 \pdfLaTeX{} 或 \LaTeX{} + \dvipdfmx{} 的编译方式所需要 |
| 3194 |
% 的依赖项,其中 \pkg{zhmCJK} 是可选的。 |
| 3195 |
% \item \pkg{xeCJK} 宏集,它还依赖 |
| 3196 |
% \begin{itemize} |
| 3197 |
% \item \pkg{xtemplate} 宏包,它属于 \pkg{l3packages} 宏集。 |
| 3198 |
% \item \pkg{fontspec} 宏包。 |
| 3199 |
% \end{itemize} |
| 3200 |
% \item[\ding{229}] 以上是使用 \XeLaTeX{} 编译时的依赖项。 |
| 3201 |
% \item \pkg{luatexja} 宏包,它还依赖 |
| 3202 |
% \begin{itemize} |
| 3203 |
% \item \pkg{adobemapping} 宏包。 |
| 3204 |
% \item \pkg{luaotfload} 宏包,它还依赖 \pkg{lualibs} 宏包。 |
| 3205 |
% \item \pkg{luatexbase} 宏包,它还依赖 \pkg{ctablestack} 宏包。 |
| 3206 |
% \item \pkg{atbegshi} 宏包。 |
| 3207 |
% \item \pkg{etoolbox} 宏包。 |
| 3208 |
% \item \pkg{iftex} 宏包。 |
| 3209 |
% \item \pkg{infwarerr} 宏包。 |
| 3210 |
% \item \pkg{ltxcmds} 宏包。 |
| 3211 |
% \item \pkg{pdftexcmds} 宏包。 |
| 3212 |
% \item \pkg{xkeyval} 宏包。 |
| 3213 |
% \item \pkg{chinese-jfm} 宏包。 |
| 3214 |
% \end{itemize} |
| 3215 |
% \item \pkg{fontspec} 宏包。 |
| 3216 |
% \item[\ding{229}] 以上是使用 \LuaLaTeX{} 编译时的依赖项。 |
| 3217 |
% \item \pkg{zhmetrics-uptex} 宏包。 |
| 3218 |
% \item[\ding{229}] 以上是使用 \upLaTeX{} 编译时的依赖项。 |
| 3219 |
% \end{itemize} |
| 3220 |
% |
| 3221 |
% 出于一些原因,\pkg{zhmCJK} 尚未被收入 \TeXLive{} 和 \MiKTeX。因此,若 |
| 3222 |
% 你希望使用 \pkg{zhmCJK} 作为 \CTeX{} 宏集的底层中文支持方式,那么你需要自行安装该宏包。 |
| 3223 |
% \pkg{zhmCJK} 的安装较为复杂。我们建议你 |
| 3224 |
% \begin{enumerate} |
| 3225 |
% \item 从 CTAN 下载 \pkg{zhmCJK} 宏包的 |
| 3226 |
% \href{http://mirrors.ctan.org/install/language/chinese/zhmcjk.tds.zip} |
| 3227 |
% {TDS 安装包}, |
| 3228 |
% \item 按目录结构将文件复制到 \TeX{} 发行版的本地 TDS 根目录, |
| 3229 |
% \item 最后执行 \bashcmd{texhash} 刷新 \TeX{} 发行版的 ls-R 数据库以完成安装。 |
| 3230 |
% \end{enumerate} |
| 3231 |
% 其他细节,可参照其 |
| 3232 |
% \href{http://mirrors.ctan.org/language/chinese/zhmcjk/zhmCJK.pdf}{宏包手册} |
| 3233 |
% 中第 3 节的指导。 |
| 3234 |
% |
| 3235 |
% \emph{\CTeX{} 宏集已被 \TeXLive{} 和 \MiKTeX{} 收录,若无特别理由, |
| 3236 |
% 我们强烈建议用户使用包管理器安装本宏集。} |
| 3237 |
% |
| 3238 |
% 若要手工安装,请遵循如下步骤: |
| 3239 |
% \begin{enumerate} |
| 3240 |
% \item 从 CTAN 下载 \CTeX{} 宏集的 |
| 3241 |
% \href{http://mirrors.ctan.org/install/language/chinese/ctex.tds.zip} |
| 3242 |
% {TDS 安装包}, |
| 3243 |
% \item 按目录结构将文件复制到 \TeX{} 发行版的本地 TDS 根目录, |
| 3244 |
% \item 最后执行 \bashcmd{texhash} 刷新 \TeX{} 发行版的 ls-R 数据库以完成安装。 |
| 3245 |
% \end{enumerate} |
| 3246 |
% |
| 3247 |
% \section{开发人员} |
| 3248 |
% |
| 3249 |
% \begin{itemize} |
| 3250 |
% \item 吴凌云 (\email{[email protected]}) |
| 3251 |
% \item 江疆 (\email{[email protected]}) |
| 3252 |
% \item 王越 (\email{[email protected]}) |
| 3253 |
% \item 刘海洋 (\email{[email protected]}) |
| 3254 |
% \item 李延瑞 (\email{[email protected]}) |
| 3255 |
% \item 陈之初 (\email{[email protected]}) |
| 3256 |
% \item 李清 (\email{[email protected]}) |
| 3257 |
% \item 黄晨成 (\email{[email protected]}) |
| 3258 |
% \item 曾祥东 (\email{[email protected]}) |
| 3259 |
% \item 李泽平 (\email{[email protected]}) |
| 3260 |
% \item 周宇恺 (\email{[email protected]}) |
| 3261 |
% \item 张瑞熹 (\email{[email protected]}) |
| 3262 |
% \end{itemize} |
| 3263 |
% |
| 3264 |
% |
| 3265 |
% |
| 3266 |
% \begin{thebibliography}{9} |
| 3267 |
% \bibitem{knuthtex1986} |
| 3268 |
% \textsc{Donald~Ervin Knuth}. |
| 3269 |
% \newblock \textit{The {{\TeX{}book}}}, \textit{Computers \& Typesetting}, |
| 3270 |
% volume~A. |
| 3271 |
% \newblock Addison-Wesley, 1986 |
| 3272 |
% |
| 3273 |
% \bibitem{mittelbach2004} |
| 3274 |
% \textsc{Frank Mittelbach} and \textsc{Michel Goossens}. |
| 3275 |
% \newblock \textit{The {{\LaTeX}} Companion}. |
| 3276 |
% \newblock Tools and Techniques for Computer Typesetting. Boston: |
| 3277 |
% Addison-Wesley, second edition, 2004 |
| 3278 |
% |
| 3279 |
% \end{thebibliography} |
| 3280 |
% |
| 3281 |
% \end{documentation} |
| 3282 |
% |
| 3283 |
% |
| 3284 |
% \StopEventually{} |
| 3285 |
% |
| 3286 |
% |
| 3287 |
%\begin{implementation} |
| 3288 |
% \clearpage |
| 3289 |
% \section{代码实现} |
| 3290 |
% |
| 3291 |
% \begin{macrocode} |
| 3292 |
%<@@=ctex> |
| 3293 |
% \end{macrocode} |
| 3294 |
% |
| 3295 |
% \changes{v2.5.9}{2022/05/27}{设置消息模块的名字和类型。} |
| 3296 |
% \changes{v2.5.10}{2022/06/10}{更新一些内部函数。} |
| 3297 |
% \changes{v2.5.10}{2022/07/08}{不直接依赖 \pkg{xparse} 和 \pkg{l3keys2e}。} |
| 3298 |
% |
| 3299 |
% \begin{macrocode} |
| 3300 |
%<*class|style> |
| 3301 |
\cs_if_exist:NF \NewDocumentCommand |
| 3302 |
{ \RequirePackage { xparse } } |
| 3303 |
%<class>\prop_gput:Nnn \g_msg_module_type_prop { ctex } { Class } |
| 3304 |
%<article>\prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexart } |
| 3305 |
%<book>\prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexbook } |
| 3306 |
%<report>\prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexrep } |
| 3307 |
%<beamer>\prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexbeamer } |
| 3308 |
%<ctexsize>\prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexsize } |
| 3309 |
%<ctexheading>\prop_gput:Nnn \g_msg_module_name_prop { ctex } { ctexheading } |
| 3310 |
%</class|style> |
| 3311 |
% \end{macrocode} |
| 3312 |
% |
| 3313 |
% \begin{macrocode} |
| 3314 |
%<*class|ctex> |
| 3315 |
% \end{macrocode} |
| 3316 |
% |
| 3317 |
% \changes{v2.3}{2015/12/20}{与 \LaTeXiii{} (2015/12/20) 同步。} |
| 3318 |
% \changes{v2.4.10}{2017/07/19}{常数 \cs{c_minus_one} 已过时。} |
| 3319 |
% \changes{v2.4.10}{2017/07/22}{使用 \texttt{lazy} 函数对 Boolean 表达式 |
| 3320 |
% 进行最小化运算(\LaTeXiii{} 2017/07/19)。} |
| 3321 |
% |
| 3322 |
% 检查 \pkg{expl3} 的版本。 |
| 3323 |
% \begin{macrocode} |
| 3324 |
\msg_new:nnnn { ctex } { l3-too-old } |
| 3325 |
{ Support~package~`#1'~too~old. } |
| 3326 |
{ |
| 3327 |
Please~update~an~up-to-date~version~of~the~bundles\\\\ |
| 3328 |
`l3kernel'~and~`l3packages'\\\\ |
| 3329 |
using~your~TeX~package~manager~or~from~CTAN. |
| 3330 |
} |
| 3331 |
\@ifpackagelater { expl3 } { 2021/02/10 } { } |
| 3332 |
{ \msg_error:nnn { ctex } { l3-too-old } { expl3 } } |
| 3333 |
% \end{macrocode} |
| 3334 |
% |
| 3335 |
% \begin{variable}{\c_@@_engine_str,\c_@@_engine_file_str} |
| 3336 |
% 引擎检查。目前 \LaTeXiii{} 将 \ApTeX{} 识别为 \upTeX。 |
| 3337 |
% \begin{macrocode} |
| 3338 |
\str_const:Nx \c_@@_engine_str |
| 3339 |
{ \cs_if_exist:NTF \ngostype { aptex } { \c_sys_engine_str } } |
| 3340 |
\msg_new:nnnn { ctex } { engine-not-supported } |
| 3341 |
{ Engine~`#1'~is~not~yet~supported,~ctex~will~abort! } |
| 3342 |
{ You~can~switch~to~xelatex,~lualatex,~pdflatex,~uplatex,~or~aplatex. } |
| 3343 |
\file_if_exist:nTF { ctex-engine- \c_@@_engine_str .def } |
| 3344 |
{ |
| 3345 |
\str_const:Nx \c_@@_engine_file_str |
| 3346 |
{ ctex-engine- \c_@@_engine_str .def } |
| 3347 |
} |
| 3348 |
{ \msg_critical:nnx { ctex } { engine-not-supported } { \c_@@_engine_str } } |
| 3349 |
% \end{macrocode} |
| 3350 |
% \end{variable} |
| 3351 |
% |
| 3352 |
% \begin{macrocode} |
| 3353 |
%</class|ctex> |
| 3354 |
% \end{macrocode} |
| 3355 |
% |
| 3356 |
% \changes{v2.5}{2020/04/19} |
| 3357 |
% {处理 \cs{ctex_file_input:n} 在 \pkg{ctexsize} 中未定义的错误。} |
| 3358 |
% \changes{v2.5}{2020/04/21}{在 \pkg{ctexsize} 也载入 \pkg{fix-cm}。} |
| 3359 |
% |
| 3360 |
% \begin{macrocode} |
| 3361 |
%<*class|ctex|ctexheading|ctexsize> |
| 3362 |
% \end{macrocode} |
| 3363 |
% |
| 3364 |
% \pkg{ctexsize} 也要载入 \pkg{fix-cm} 包解决传统 cm 字体字号缺失的问题。 |
| 3365 |
% \begin{macrocode} |
| 3366 |
%<!ctexsize>\RequirePackage { ctexhook , ctexpatch } |
| 3367 |
%<!ctexheading>\RequirePackage { fix-cm } |
| 3368 |
% \end{macrocode} |
| 3369 |
% |
| 3370 |
% 宏包载入检查。 |
| 3371 |
% \begin{macrocode} |
| 3372 |
%<*class|ctex> |
| 3373 |
%<*class> |
| 3374 |
\ctex_disable_package:n { ctex } |
| 3375 |
\ctex_disable_package:n { ctexcap } |
| 3376 |
%</class> |
| 3377 |
\ctex_disable_package:n { ctexsize } |
| 3378 |
\ctex_disable_package:n { ctexheading } |
| 3379 |
%</class|ctex> |
| 3380 |
% \end{macrocode} |
| 3381 |
% |
| 3382 |
% \changes{v2.5.7}{2021/06/04}{兼容 \LaTeX \ 2021/06/01 的字体钩子。} |
| 3383 |
% |
| 3384 |
% \begin{variable}{\c_@@_everysel_loaded_bool} |
| 3385 |
% \LaTeX \ 2021-06-01 以后的版本内建了 \pkg{everysel} 包的功能。 |
| 3386 |
% \begin{macrocode} |
| 3387 |
%<*!ctexsize> |
| 3388 |
%<*!ctexheading> |
| 3389 |
\ctex_if_format_at_least:nTF { 2021/06/01 } |
| 3390 |
{ \bool_const:Nn \c_@@_everysel_loaded_bool { \c_false_bool } } |
| 3391 |
{ |
| 3392 |
\RequirePackage { everysel } |
| 3393 |
\bool_const:Nn \c_@@_everysel_loaded_bool { \c_true_bool } |
| 3394 |
} |
| 3395 |
%</!ctexheading> |
| 3396 |
% \end{macrocode} |
| 3397 |
% \end{variable} |
| 3398 |
% |
| 3399 |
% \subsection{内部函数与变量} |
| 3400 |
% |
| 3401 |
% \begin{variable}{\l_@@_tmp_tl,\l_@@_tmp_int,\l_@@_tmp_box,\l_@@_tmp_dim} |
| 3402 |
% 临时变量。 |
| 3403 |
% \begin{macrocode} |
| 3404 |
\tl_clear_new:N \l_@@_tmp_tl |
| 3405 |
\int_new:N \l_@@_tmp_int |
| 3406 |
\box_new:N \l_@@_tmp_box |
| 3407 |
%<!ctexheading>\dim_new:N \l_@@_tmp_dim |
| 3408 |
% \end{macrocode} |
| 3409 |
% \end{variable} |
| 3410 |
% |
| 3411 |
% \begin{macro}[int]{\ctex_define_option:n, |
| 3412 |
% \ctex_define:n,\ctex_set:n,\ctex_set:nn} |
| 3413 |
% 在宏包内部使用的键值选项定义、设置命令。 |
| 3414 |
% \begin{macrocode} |
| 3415 |
%</!ctexsize> |
| 3416 |
\cs_new_protected:Npn \ctex_define_option:n |
| 3417 |
{ \keys_define:nn { ctex / option } } |
| 3418 |
%<*!ctexsize> |
| 3419 |
\cs_new_protected:Npn \ctex_define:n |
| 3420 |
{ \keys_define:nn { ctex } } |
| 3421 |
\cs_new_protected:Npn \ctex_set:n |
| 3422 |
{ \keys_set:nn { ctex } } |
| 3423 |
\cs_new_protected:Npn \ctex_set:nn #1 |
| 3424 |
{ \keys_set:nn { ctex / #1 } } |
| 3425 |
% \end{macrocode} |
| 3426 |
% \end{macro} |
| 3427 |
% |
| 3428 |
% \changes{v2.5.3}{2020/06/06}{正确关闭和恢复 \LaTeXiii 语法环境。} |
| 3429 |
% \changes{v2.5.4}{2020/08/02}{应用 \pkg{l3cctab}。} |
| 3430 |
% \changes{v2.5.5}{2020/10/17}{放弃应用 \pkg{l3cctab}。} |
| 3431 |
% |
| 3432 |
% \begin{macro}[int]{\ctex_scheme_input:n} |
| 3433 |
% 输入 \opt{scheme} 文件。先查找当前文档类下的 \meta{scheme},找不到再查找一般的文件。 |
| 3434 |
% \begin{macrocode} |
| 3435 |
\cs_new_protected:Npn \ctex_scheme_input:n #1 |
| 3436 |
{ |
| 3437 |
\ctex_push_file: |
| 3438 |
\tl_if_exist:NTF \c_@@_class_tl |
| 3439 |
{ |
| 3440 |
\file_if_exist_input:nF { ctex-scheme- #1 - \c_@@_class_tl .def } |
| 3441 |
{ \file_input:n { ctex-scheme- #1 .def } } |
| 3442 |
} |
| 3443 |
{ \file_input:n { ctex-scheme- #1 .def } } |
| 3444 |
\ctex_pop_file: |
| 3445 |
} |
| 3446 |
\cs_generate_variant:Nn \ctex_scheme_input:n { o } |
| 3447 |
% \end{macrocode} |
| 3448 |
% \end{macro} |
| 3449 |
% |
| 3450 |
% \begin{variable}{\g_@@_section_depth_int} |
| 3451 |
% 若大于 |3|,则 \tn{paragraph} 和 \tn{subparagraph} 标题单独占一行;若为 |3|,则 |
| 3452 |
% \tn{paragraph} 单独占一行。 |
| 3453 |
% \begin{macrocode} |
| 3454 |
%<*!beamer> |
| 3455 |
\int_new:N \g_@@_section_depth_int |
| 3456 |
\int_gset:Nn \g_@@_section_depth_int { 2 } |
| 3457 |
%</!beamer> |
| 3458 |
% \end{macrocode} |
| 3459 |
% \end{variable} |
| 3460 |
% |
| 3461 |
% \begin{macrocode} |
| 3462 |
%</!ctexsize> |
| 3463 |
%</class|ctex|ctexheading|ctexsize> |
| 3464 |
%<*class|ctex> |
| 3465 |
% \end{macrocode} |
| 3466 |
% |
| 3467 |
% 对旧版本的宏包给出错误信息。 |
| 3468 |
% \begin{macrocode} |
| 3469 |
\msg_new:nnnn { ctex } { package-too-old } |
| 3470 |
{ Support~package~`#1'~too~old. } |
| 3471 |
{ |
| 3472 |
Please~update~an~up-to-date~version~of~the~package~`#1'\\ |
| 3473 |
using~your~TeX~package~manager~or~from~CTAN. |
| 3474 |
} |
| 3475 |
% \end{macrocode} |
| 3476 |
% |
| 3477 |
% \changes{v2.1}{2015/05/25}{不依赖 \pkg{ifpdf} 宏包。} |
| 3478 |
% |
| 3479 |
% \begin{macro}[int]{\ifctexpdf} |
| 3480 |
% 在 \pkg{zhmetrics} 映射文件中使用。 |
| 3481 |
% \begin{macrocode} |
| 3482 |
\sys_if_output_pdf:TF |
| 3483 |
{ \cs_new_eq:NN \ifctexpdf \if_true: } |
| 3484 |
{ \cs_new_eq:NN \ifctexpdf \if_false: } |
| 3485 |
% \end{macrocode} |
| 3486 |
% \end{macro} |
| 3487 |
% |
| 3488 |
% \begin{macro}[int]{\ctex_if_preamble:TF} |
| 3489 |
% 测试是否在 \LaTeXe{} 的导言区。在宏包内部初始为真,文档最开始位置再设置为假。 |
| 3490 |
% 注意,钩子 \cs{ctex_after_end_preamble:n} 在 \tn{AtBeginDocument} 之后执行, |
| 3491 |
% 可以与 \tn{@onlypreamble} 的行为一致。 |
| 3492 |
% \begin{macrocode} |
| 3493 |
\cs_new_eq:NN \ctex_if_preamble:TF \use_i:nn |
| 3494 |
\ctex_after_end_preamble:n { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } |
| 3495 |
% \end{macrocode} |
| 3496 |
% \end{macro} |
| 3497 |
% |
| 3498 |
% \changes{v2.3}{2015/09/17}{代码实现避免使用 \tn{lowercase} 技巧(Joseph Wright)。} |
| 3499 |
% |
| 3500 |
% \changes{v2.4.16}{2019/05/11}{允许设置 \texttt{autoindent} 为 $0$。} |
| 3501 |
% |
| 3502 |
% \begin{macro}[int]{\ctex_set_default_ccwd:Nn} |
| 3503 |
% 若参数 |#2| 带长度单位,则设置它为 |tl| 变量 |#1| 的值,否则以 \tn{ccwd} 为单位。 |
| 3504 |
% \begin{macrocode} |
| 3505 |
\cs_new_protected:Npn \ctex_set_default_ccwd:Nn #1#2 |
| 3506 |
{ \tl_set:Nx #1 { \@@_default_ccwd_aux:n {#2} } } |
| 3507 |
\cs_new:Npn \@@_default_ccwd_aux:n #1 |
| 3508 |
{ |
| 3509 |
\exp_not:n {#1} |
| 3510 |
\exp_after:wN \@@_default_ccwd_aux:w |
| 3511 |
\dim_use:N \tex_dimexpr:D #1 pt \scan_stop: \q_stop |
| 3512 |
} |
| 3513 |
\exp_last_unbraced:NNNNo |
| 3514 |
\cs_new:Npn \@@_default_ccwd_aux:w #1 { \tl_to_str:n { pt } } #2 \q_stop |
| 3515 |
{ \tl_if_empty:nT {#2} { \ccwd } } |
| 3516 |
% \end{macrocode} |
| 3517 |
% \end{macro} |
| 3518 |
% |
| 3519 |
% \begin{variable}{\g_@@_encoding_tl} |
| 3520 |
% 所有引擎下默认编码均设为 UTF-8,初始值为空,\tn{ProcessKeysOptions} 再判断。 |
| 3521 |
% \begin{macrocode} |
| 3522 |
\tl_new:N \g_@@_encoding_tl |
| 3523 |
% \end{macrocode} |
| 3524 |
% \end{variable} |
| 3525 |
% |
| 3526 |
% \begin{variable}{\g_@@_zhmCJK_bool} |
| 3527 |
% 是否使用 \pkg{zhmCJK} 宏包。 |
| 3528 |
% \begin{macrocode} |
| 3529 |
\bool_new:N \g_@@_zhmCJK_bool |
| 3530 |
% \end{macrocode} |
| 3531 |
% \end{variable} |
| 3532 |
% |
| 3533 |
% \begin{variable}{\l_@@_autoindent_tl} |
| 3534 |
% 保存 \opt{autoindent} 选项的值,空值表示不自动调整首行缩进。 |
| 3535 |
% \begin{macrocode} |
| 3536 |
\tl_new:N \l_@@_autoindent_tl |
| 3537 |
% \end{macrocode} |
| 3538 |
% \end{variable} |
| 3539 |
% |
| 3540 |
% \begin{macro}[int]{\ctex_if_autoindent_touched:F} |
| 3541 |
% 检查 \opt{autoindent} 选项是否被用户设置。 |
| 3542 |
% \begin{macrocode} |
| 3543 |
\cs_new_eq:NN \ctex_if_autoindent_touched:F \use:n |
| 3544 |
% \end{macrocode} |
| 3545 |
% \end{macro} |
| 3546 |
% |
| 3547 |
% \begin{macro}[int]{\ctex_zhmap_case:nnn} |
| 3548 |
% 参数 |#1| 是 \pkg{zhmCJK} 的内容,|#2| 是 \pkg{zhmetrics}。 |
| 3549 |
% \begin{macrocode} |
| 3550 |
\cs_new_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn |
| 3551 |
% \end{macrocode} |
| 3552 |
% \end{macro} |
| 3553 |
% |
| 3554 |
% \begin{macro}[int]{\ctex_at_end:n} |
| 3555 |
% 区分 \tn{AtEndOfClass} 和 \tn{AtEndOfPackage},虽然它们的意思都是一样的。 |
| 3556 |
% \begin{macrocode} |
| 3557 |
%<class>\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfClass } |
| 3558 |
%<ctex>\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfPackage } |
| 3559 |
% \end{macrocode} |
| 3560 |
% \end{macro} |
| 3561 |
% |
| 3562 |
% \begin{variable}{\ctex_load_std_class:n,\g_@@_std_options_clist} |
| 3563 |
% 保存传递给标准文档类的选项。 |
| 3564 |
% 使用 \tn{PassOptionsToClass} 是为了预防可能存在的选项冲突,选项列表展开后再传递。 |
| 3565 |
% \begin{macrocode} |
| 3566 |
%<*class> |
| 3567 |
\cs_new_protected:Npn \ctex_load_std_class:n #1 |
| 3568 |
{ |
| 3569 |
\tl_const:Nn \c_@@_class_tl {#1} |
| 3570 |
\exp_args:No \PassOptionsToClass |
| 3571 |
{ \g_@@_std_options_clist } |
| 3572 |
{#1} |
| 3573 |
\LoadClass {#1} |
| 3574 |
} |
| 3575 |
\clist_new:N \g_@@_std_options_clist |
| 3576 |
%</class> |
| 3577 |
% \end{macrocode} |
| 3578 |
% \end{variable} |
| 3579 |
% |
| 3580 |
% 对无效选项给出警告。 |
| 3581 |
% \begin{macrocode} |
| 3582 |
\msg_new:nnn { ctex } { invalid-option } |
| 3583 |
{ Option~`\l_keys_key_tl'~is~invalid~in~current~mode. } |
| 3584 |
\msg_new:nnn { ctex } { invalid-value } |
| 3585 |
{ Value~`#1'~is~invalid~for~the~key~`\l_keys_key_tl'. } |
| 3586 |
% \end{macrocode} |
| 3587 |
% |
| 3588 |
% \begin{macro}[int]{\ctex_deprecated_option:nn, |
| 3589 |
% \ctex_set_deprecated_option:n,\ctex_deprecated_command:Nn} |
| 3590 |
% 对过时选项或命令给出警告。 |
| 3591 |
% \begin{macrocode} |
| 3592 |
\cs_new_protected:Npn \ctex_deprecated_option:n |
| 3593 |
{ \msg_warning:nnn { ctex } { deprecated-option } } |
| 3594 |
\cs_new_protected:Npn \ctex_set_deprecated_option:n #1 |
| 3595 |
{ |
| 3596 |
\ctex_deprecated_option:n { Option~`#1'~is~set. } |
| 3597 |
\ctex_set:nn { option } {#1} |
| 3598 |
} |
| 3599 |
\cs_new_protected:Npn \ctex_deprecated_command:Nn #1#2 |
| 3600 |
{ |
| 3601 |
\msg_warning:nnxx { ctex } { deprecated-command } |
| 3602 |
{ \token_to_str:N #1 } { \exp_not:n {#2} } |
| 3603 |
} |
| 3604 |
\msg_new:nnn { ctex } { deprecated-option } |
| 3605 |
{ Option~`\l_keys_key_tl'~is~deprecated.\\ #1 } |
| 3606 |
\msg_new:nnn { ctex } { deprecated-command } |
| 3607 |
{ Command~`#1'~is~deprecated.\\ #2 } |
| 3608 |
% \end{macrocode} |
| 3609 |
% \end{macro} |
| 3610 |
% |
| 3611 |
% \begin{macrocode} |
| 3612 |
%</class|ctex> |
| 3613 |
% \end{macrocode} |
| 3614 |
% |
| 3615 |
% \begin{variable}{\g_@@_font_size_int} |
| 3616 |
% |0| 表示修改默认字体大小为五号,|1| 为小四号,大于 1 则不作修改。初始值 |-1| |
| 3617 |
% 表示 \opt{zihao} 选项未初始化,会在将来根据文档类决定初值。 |
| 3618 |
% \begin{macrocode} |
| 3619 |
%<*class|ctex|ctexsize> |
| 3620 |
\int_new:N \g_@@_font_size_int |
| 3621 |
\int_gset:Nn \g_@@_font_size_int { -1 } |
| 3622 |
%</class|ctex|ctexsize> |
| 3623 |
% \end{macrocode} |
| 3624 |
% \end{variable} |
| 3625 |
% |
| 3626 |
% \subsection{宏包选项} |
| 3627 |
% |
| 3628 |
% \changes{v2.3}{2015/09/25} |
| 3629 |
% {\texttt{.value_required:} 和 \texttt{.value_forbidden:} 已过时。} |
| 3630 |
% |
| 3631 |
% \begin{macrocode} |
| 3632 |
%<*class|style> |
| 3633 |
\ctex_define_option:n |
| 3634 |
{ |
| 3635 |
%</class|style> |
| 3636 |
% \end{macrocode} |
| 3637 |
% |
| 3638 |
% \changes{v2.0}{2015/05/06}{新增 \opt{zihao} 选项。} |
| 3639 |
% \changes{v2.0}{2015/05/06}{\opt{c5size}, \opt{cs4size} 是过时选项。} |
| 3640 |
% |
| 3641 |
% \begin{macro}{zihao} |
| 3642 |
% \changes{v2.4.1}{2016/05/13}{不允许无参 \opt{zihao} 选项。} |
| 3643 |
% \begin{macrocode} |
| 3644 |
%<*class|ctex|ctexsize> |
| 3645 |
zihao .choice: , |
| 3646 |
zihao .value_required:n = true , |
| 3647 |
zihao / 5 .code:n = { \int_gset:Nn \g_@@_font_size_int { 0 } } , |
| 3648 |
zihao / -4 .code:n = { \int_gset:Nn \g_@@_font_size_int { 1 } } , |
| 3649 |
zihao / false .code:n = { \int_gset:Nn \g_@@_font_size_int { 2 } } , |
| 3650 |
%<ctexsize> } |
| 3651 |
%</class|ctex|ctexsize> |
| 3652 |
%<*class|ctex> |
| 3653 |
c5size .code:n = { \ctex_set_deprecated_option:n { zihao = 5 } } , |
| 3654 |
cs4size .code:n = { \ctex_set_deprecated_option:n { zihao = -4 } } , |
| 3655 |
c5size .value_forbidden:n = true , |
| 3656 |
cs4size .value_forbidden:n = true , |
| 3657 |
% \end{macrocode} |
| 3658 |
% \end{macro} |
| 3659 |
% |
| 3660 |
% \changes{v2.0}{2014/04/23}{新增 \opt{linespread} 选项。} |
| 3661 |
% |
| 3662 |
% \begin{macro}{linespread} |
| 3663 |
% 行距初始值为标志 \texttt{nan},用于检查用户是否设置了 \opt{linespread} 选项。 |
| 3664 |
% \begin{macrocode} |
| 3665 |
linespread .fp_set:N = \l_@@_line_spread_fp , |
| 3666 |
linespread .initial:n = { \c_nan_fp } , |
| 3667 |
linespread .value_required:n = true , |
| 3668 |
% \end{macrocode} |
| 3669 |
% \end{macro} |
| 3670 |
% |
| 3671 |
% \changes{v2.0}{2014/03/13}{新增 \opt{autoindent} 选项。} |
| 3672 |
% |
| 3673 |
% \begin{macro}{autoindent} |
| 3674 |
% 自动调整段落的首行缩进功能。 |
| 3675 |
% \begin{macrocode} |
| 3676 |
autoindent .choice: , |
| 3677 |
autoindent .default:n = { true } , |
| 3678 |
autoindent / true .code:n = |
| 3679 |
{ |
| 3680 |
\tl_set:Nn \l_@@_autoindent_tl { 2 \ccwd } |
| 3681 |
\cs_set_eq:NN \ctex_if_autoindent_touched:F \use_none:n |
| 3682 |
} , |
| 3683 |
autoindent / false .code:n = |
| 3684 |
{ |
| 3685 |
\tl_clear:N \l_@@_autoindent_tl |
| 3686 |
\cs_set_eq:NN \ctex_if_autoindent_touched:F \use_none:n |
| 3687 |
} , |
| 3688 |
autoindent / unknown .code:n = |
| 3689 |
{ |
| 3690 |
\ctex_set_default_ccwd:Nn \l_@@_autoindent_tl {#1} |
| 3691 |
\cs_set_eq:NN \ctex_if_autoindent_touched:F \use_none:n |
| 3692 |
} , |
| 3693 |
% \end{macrocode} |
| 3694 |
% \end{macro} |
| 3695 |
% |
| 3696 |
% \changes{v2.0}{2015/03/21}{\opt{indent}, \opt{noindent} 是过时选项。} |
| 3697 |
% \begin{macro}{indent} |
| 3698 |
% 仅为兼容性保留,已过时。 |
| 3699 |
% \begin{macrocode} |
| 3700 |
indent .code:n = |
| 3701 |
{ |
| 3702 |
\ctex_deprecated_option:n |
| 3703 |
{ |
| 3704 |
The~functionality~has~been~removed.\\ |
| 3705 |
It's~better~to~set~the~heading~styles~via~`afterindent'~option. |
| 3706 |
} |
| 3707 |
} , |
| 3708 |
indent .value_forbidden:n = true , |
| 3709 |
noindent .code:n = |
| 3710 |
{ |
| 3711 |
\ctex_deprecated_option:n |
| 3712 |
{ |
| 3713 |
The~functionality~has~been~removed.\\ |
| 3714 |
It's~better~to~set~the~heading~styles~via~`afterindent'~option. |
| 3715 |
} |
| 3716 |
} , |
| 3717 |
noindent .value_forbidden:n = true , |
| 3718 |
% \end{macrocode} |
| 3719 |
% \end{macro} |
| 3720 |
% |
| 3721 |
% \changes{v2.5}{2019/11/10}{所有引擎下默认编码均设为 UTF-8。} |
| 3722 |
% |
| 3723 |
% \begin{macro}{GBK,UTF8} |
| 3724 |
% 文档编码,默认为 UTF-8。 |
| 3725 |
% \begin{macrocode} |
| 3726 |
GBK .code:n = |
| 3727 |
{ |
| 3728 |
\sys_if_engine_pdftex:TF |
| 3729 |
{ \tl_gset:Nn \g_@@_encoding_tl { GBK } } |
| 3730 |
{ |
| 3731 |
\msg_warning:nn { ctex } { invalid-option } |
| 3732 |
\tl_gset:Nn \g_@@_encoding_tl { UTF8 } |
| 3733 |
} |
| 3734 |
} , |
| 3735 |
UTF8 .code:n = { \tl_gset:Nn \g_@@_encoding_tl { UTF8 } } , |
| 3736 |
GBK .value_forbidden:n = true , |
| 3737 |
UTF8 .value_forbidden:n = true , |
| 3738 |
% \end{macrocode} |
| 3739 |
% \end{macro} |
| 3740 |
% |
| 3741 |
% \changes{v2.0}{2014/03/08}{新增 \opt{fontset} 选项。} |
| 3742 |
% \changes{v2.0}{2015/03/21}{\opt{nofonts}, \opt{adobefonts}, \opt{winfonts} |
| 3743 |
% 是过时选项。} |
| 3744 |
% |
| 3745 |
% \begin{macro}{fontset} |
| 3746 |
% 初始值为空。若用户未指定,则根据操作系统载入对应字体配置,可以区分 Windows、 |
| 3747 |
% macOS 和其他。 |
| 3748 |
% \begin{macrocode} |
| 3749 |
fontset .tl_gset:N = \g_@@_fontset_tl , |
| 3750 |
nofonts .code:n = { \ctex_set_deprecated_option:n { fontset = none } } , |
| 3751 |
adobefonts .code:n = { \ctex_set_deprecated_option:n { fontset = adobe } } , |
| 3752 |
winfonts .code:n = { \ctex_set_deprecated_option:n { fontset = windows } } , |
| 3753 |
nofonts .value_forbidden:n = true , |
| 3754 |
winfonts .value_forbidden:n = true , |
| 3755 |
adobefonts .value_forbidden:n = true , |
| 3756 |
% \end{macrocode} |
| 3757 |
% \end{macro} |
| 3758 |
% |
| 3759 |
% \changes{v2.0}{2014/03/08}{新增 \opt{zhmCJK} 支持选项。} |
| 3760 |
% \changes{v2.0}{2015/03/22}{\opt{nozhmap} 是过时选项。} |
| 3761 |
% |
| 3762 |
% \begin{macro}{zhmap} |
| 3763 |
% \begin{macrocode} |
| 3764 |
zhmap .choice: , |
| 3765 |
zhmap .default:n = { true } , |
| 3766 |
zhmap / zhmCJK .code:n = |
| 3767 |
{ |
| 3768 |
\bool_gset_true:N \g_@@_zhmCJK_bool |
| 3769 |
\cs_gset_eq:NN \ctex_zhmap_case:nnn \use_i:nnn |
| 3770 |
} , |
| 3771 |
zhmap / true .code:n = |
| 3772 |
{ |
| 3773 |
\bool_gset_false:N \g_@@_zhmCJK_bool |
| 3774 |
\cs_gset_eq:NN \ctex_zhmap_case:nnn \use_ii:nnn |
| 3775 |
} , |
| 3776 |
zhmap / false .code:n = |
| 3777 |
{ |
| 3778 |
\bool_gset_false:N \g_@@_zhmCJK_bool |
| 3779 |
\cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn |
| 3780 |
} , |
| 3781 |
nozhmap .code:n = |
| 3782 |
{ \ctex_set_deprecated_option:n { zhmap = false } } , |
| 3783 |
nozhmap .value_forbidden:n = true , |
| 3784 |
% \end{macrocode} |
| 3785 |
% \end{macro} |
| 3786 |
% |
| 3787 |
% \changes{v2.0}{2014/04/11}{\opt{punct} 选项可以设置标点格式。} |
| 3788 |
% \changes{v2.0}{2015/03/21}{\opt{nopunct} 是过时选项。} |
| 3789 |
% |
| 3790 |
% \begin{macro}{punct} |
| 3791 |
% 设置标点符号输出格式。 |
| 3792 |
% \begin{macrocode} |
| 3793 |
punct .tl_set:N = \l_@@_punct_tl , |
| 3794 |
punct .default:n = { quanjiao } , |
| 3795 |
punct .initial:n = { quanjiao } , |
| 3796 |
nopunct .code:n = \ctex_set_deprecated_option:n { punct = plain } , |
| 3797 |
nopunct .value_forbidden:n = true , |
| 3798 |
% \end{macrocode} |
| 3799 |
% \end{macro} |
| 3800 |
% |
| 3801 |
% \changes{v2.0}{2015/03/22}{\opt{nospace} 是过时选项。} |
| 3802 |
% \begin{macro}{space} |
| 3803 |
% \begin{macrocode} |
| 3804 |
space .choices:nn = |
| 3805 |
{ true , auto , false } |
| 3806 |
{ |
| 3807 |
\exp_args:Ne \ctex_at_end:n |
| 3808 |
{ \ctex_set:n { space = \l_keys_choice_tl } } |
| 3809 |
} , |
| 3810 |
space .default:n = { true } , |
| 3811 |
nospace .code:n = { \ctex_deprecated_option:nn { space = false } } , |
| 3812 |
nospace .value_forbidden:n = true , |
| 3813 |
% \end{macrocode} |
| 3814 |
% \end{macro} |
| 3815 |
% |
| 3816 |
% \changes{v2.0}{2014/03/08}{\pkg{ctex} 宏包新增 \opt{heading} 选项。} |
| 3817 |
% |
| 3818 |
% \begin{macro}{heading} |
| 3819 |
% \begin{macrocode} |
| 3820 |
heading .bool_set:N = \l_@@_heading_bool , |
| 3821 |
% \end{macrocode} |
| 3822 |
% \end{macro} |
| 3823 |
% |
| 3824 |
% \begin{macrocode} |
| 3825 |
%</class|ctex> |
| 3826 |
%<*class|ctex|ctexheading> |
| 3827 |
% \end{macrocode} |
| 3828 |
% |
| 3829 |
% \begin{macro}{sub3section,sub4section} |
| 3830 |
% \begin{macrocode} |
| 3831 |
%<*!beamer> |
| 3832 |
sub3section .code:n = |
| 3833 |
{ \int_gset:Nn \g_@@_section_depth_int { 3 } } , |
| 3834 |
sub4section .code:n = |
| 3835 |
{ \int_gset:Nn \g_@@_section_depth_int { 4 } } , |
| 3836 |
sub3section .value_forbidden:n = true , |
| 3837 |
sub4section .value_forbidden:n = true , |
| 3838 |
%</!beamer> |
| 3839 |
% \end{macrocode} |
| 3840 |
% \end{macro} |
| 3841 |
% |
| 3842 |
% \changes{v2.0}{2015/04/15}{新增 \opt{scheme} 选项,并将 \opt{cap} 和 \opt{nocap} |
| 3843 |
% 列为过时选项。} |
| 3844 |
% |
| 3845 |
% \begin{macro}{scheme} |
| 3846 |
% \begin{macrocode} |
| 3847 |
scheme .tl_set:N = \l_@@_scheme_tl , |
| 3848 |
%<*ctexheading> |
| 3849 |
scheme .default:n = { plain } , |
| 3850 |
scheme .initial:n = { plain } |
| 3851 |
} |
| 3852 |
%</ctexheading> |
| 3853 |
%<*!ctexheading> |
| 3854 |
scheme .default:n = { chinese } , |
| 3855 |
scheme .initial:n = { chinese } , |
| 3856 |
%</!ctexheading> |
| 3857 |
% \end{macrocode} |
| 3858 |
% \end{macro} |
| 3859 |
% |
| 3860 |
% \begin{macrocode} |
| 3861 |
%</class|ctex|ctexheading> |
| 3862 |
%<*class|ctex> |
| 3863 |
% \end{macrocode} |
| 3864 |
% |
| 3865 |
% \begin{macro}{cap,nocap} |
| 3866 |
% \opt{cap} 和 \opt{nocap} 是过时选项。 |
| 3867 |
% \begin{macrocode} |
| 3868 |
cap .code:n = { \ctex_set_deprecated_option:n { scheme = chinese } } , |
| 3869 |
nocap .code:n = { \ctex_set_deprecated_option:n { scheme = plain } } , |
| 3870 |
cap .value_forbidden:n = true , |
| 3871 |
nocap .value_forbidden:n = true , |
| 3872 |
% \end{macrocode} |
| 3873 |
% \end{macro} |
| 3874 |
% |
| 3875 |
% \changes{v2.0}{2015/04/20}{\opt{hyperref} 成为过时选项,原选项功能总是打开。} |
| 3876 |
% \changes{v2.0}{2015/04/20}{\opt{fancyhdr} 成为过时选项,原选项功能总是打开。} |
| 3877 |
% \changes{v2.0}{2015/04/20}{\opt{fntef} 成为过时选项,原选项功能总是打开。} |
| 3878 |
% |
| 3879 |
% 以下三项都是过时的兼容选项,它们会载入有关宏包。 |
| 3880 |
% |
| 3881 |
% \begin{macro}{fntef} |
| 3882 |
% \changes{v2.5}{2019/11/10}{仅在该选项启用时会载入 \pkg{CJKfntef} 或 |
| 3883 |
% \pkg{xeCJKfntef} 宏包。} |
| 3884 |
% \begin{macrocode} |
| 3885 |
fntef .code:n = |
| 3886 |
{ |
| 3887 |
\sys_if_engine_xetex:TF |
| 3888 |
{ |
| 3889 |
\ctex_deprecated_option:n { `xeCJKfntef'~package~is~loaded. } |
| 3890 |
\ctex_at_end:n { \RequirePackage { xeCJKfntef } } |
| 3891 |
} |
| 3892 |
{ |
| 3893 |
\sys_if_engine_pdftex:TF |
| 3894 |
{ |
| 3895 |
\ctex_deprecated_option:n { `CJKfntef'~package~is~loaded. } |
| 3896 |
\ctex_at_end:n { \RequirePackage { CJKfntef } } |
| 3897 |
} |
| 3898 |
{ |
| 3899 |
\ctex_deprecated_option:n |
| 3900 |
{ Furthermore,~option~`fntef'~is~invalid~in~current~mode. } |
| 3901 |
} |
| 3902 |
} |
| 3903 |
} , |
| 3904 |
% \end{macrocode} |
| 3905 |
% \end{macro} |
| 3906 |
% |
| 3907 |
% \begin{macro}{fancyhdr} |
| 3908 |
% \begin{macrocode} |
| 3909 |
fancyhdr .code:n = |
| 3910 |
{ |
| 3911 |
\ctex_deprecated_option:n { `fancyhdr'~package~is~loaded. } |
| 3912 |
\ctex_at_end:n { \RequirePackage { fancyhdr } } |
| 3913 |
} , |
| 3914 |
% \end{macrocode} |
| 3915 |
% \end{macro} |
| 3916 |
% |
| 3917 |
% \begin{macro}{hyperref} |
| 3918 |
% \changes{v2.1}{2015/06/03}{补充定义 \tn{hypersetup}。} |
| 3919 |
% \begin{macrocode} |
| 3920 |
hyperref .code:n = |
| 3921 |
{ |
| 3922 |
\ctex_deprecated_option:n { `hyperref'~package~will~be~loaded. } |
| 3923 |
\ctex_at_end:n |
| 3924 |
{ |
| 3925 |
\cs_if_exist:NF \hypersetup |
| 3926 |
{ \cs_new_eq:NN \hypersetup \ctex_hypersetup:n } |
| 3927 |
} |
| 3928 |
\ctex_at_end_preamble:n { \RequirePackage { hyperref } } |
| 3929 |
} , |
| 3930 |
} |
| 3931 |
% \end{macrocode} |
| 3932 |
% \end{macro} |
| 3933 |
% |
| 3934 |
% \begin{macrocode} |
| 3935 |
%</class|ctex> |
| 3936 |
%<*class|ctex|ctexsize> |
| 3937 |
% \end{macrocode} |
| 3938 |
% |
| 3939 |
% \changes{v2.0}{2015/05/06}{兼容 \pkg{extsizes} 宏包、\cls{beamer}、\pkg{memoir} |
| 3940 |
% 等提供的更多字号选项。} |
| 3941 |
% \changes{v2.0.1}{2015/05/15}{修复 \opt{10pt}、\opt{11pt} 等选项无效的问题。} |
| 3942 |
% \begin{macro}{10pt,11pt,12pt} |
| 3943 |
% 使 \pkg{ctex} 和 \pkg{ctexsize} 可以接受文档类的全局选项,不修改默认字体大小。 |
| 3944 |
% 在文档类下还将参数传给标准文档类。 |
| 3945 |
% \begin{macrocode} |
| 3946 |
\tl_clear_new:N \l_@@_tmp_tl |
| 3947 |
\clist_map_inline:nn |
| 3948 |
{ |
| 3949 |
10pt , 11pt , 12pt , |
| 3950 |
8pt , 9pt , 14pt , 17pt , 20pt , 25pt , 30pt , 36pt , 48pt , 60pt |
| 3951 |
} |
| 3952 |
{ |
| 3953 |
\tl_put_right:Nn \l_@@_tmp_tl |
| 3954 |
{ |
| 3955 |
#1 .code:n = |
| 3956 |
%<*!class> |
| 3957 |
{ \int_gset:Nn \g_@@_font_size_int { 2 } } , |
| 3958 |
%</!class> |
| 3959 |
%<*class> |
| 3960 |
{ |
| 3961 |
\int_gset:Nn \g_@@_font_size_int { 2 } |
| 3962 |
\clist_gput_right:Nn \g_@@_std_options_clist {#1} |
| 3963 |
} , |
| 3964 |
%</class> |
| 3965 |
#1 .value_forbidden:n = true , |
| 3966 |
} |
| 3967 |
} |
| 3968 |
\exp_args:No \ctex_define_option:n { \l_@@_tmp_tl } |
| 3969 |
\tl_clear:N \l_@@_tmp_tl |
| 3970 |
% \end{macrocode} |
| 3971 |
% \end{macro} |
| 3972 |
% |
| 3973 |
% 将未知选项传给标准文档类。 |
| 3974 |
% \begin{macrocode} |
| 3975 |
%<*class> |
| 3976 |
\ctex_define_option:n |
| 3977 |
{ |
| 3978 |
unknown .code:n = |
| 3979 |
{ \clist_gput_right:No \g_@@_std_options_clist { \CurrentOption } } |
| 3980 |
} |
| 3981 |
%</class> |
| 3982 |
% \end{macrocode} |
| 3983 |
% |
| 3984 |
% 载入选项配置文件。 |
| 3985 |
% \begin{macrocode} |
| 3986 |
%<!ctexsize>\ctex_file_input:n { ctexopts.cfg } |
| 3987 |
%</class|ctex|ctexsize> |
| 3988 |
% \end{macrocode} |
| 3989 |
% |
| 3990 |
% 处理宏包选项。 |
| 3991 |
% \begin{macrocode} |
| 3992 |
%<*class|style> |
| 3993 |
\cs_if_exist:NTF \ProcessKeyOptions |
| 3994 |
{ \ProcessKeyOptions [ ctex / option ] } |
| 3995 |
{ |
| 3996 |
\RequirePackage { l3keys2e } |
| 3997 |
\ProcessKeysOptions { ctex / option } |
| 3998 |
} |
| 3999 |
%</class|style> |
| 4000 |
% \end{macrocode} |
| 4001 |
% |
| 4002 |
% \pdfLaTeX{} 下,如果没有显式指定编码为 |UTF8|,则给出警告信息。 |
| 4003 |
% \begin{macrocode} |
| 4004 |
%<*class|ctex> |
| 4005 |
\msg_new:nnn { ctex } { pdftex-utf8 } |
| 4006 |
{ UTF8~will~be~used~as~the~default~encoding. } |
| 4007 |
\tl_if_empty:NT \g_@@_encoding_tl |
| 4008 |
{ |
| 4009 |
\sys_if_engine_pdftex:T |
| 4010 |
{ \msg_warning:nn { ctex } { pdftex-utf8 } } |
| 4011 |
\tl_gset:Nn \g_@@_encoding_tl { UTF8 } |
| 4012 |
} |
| 4013 |
%</class|ctex> |
| 4014 |
% \end{macrocode} |
| 4015 |
% |
| 4016 |
% \begin{macrocode} |
| 4017 |
%<*class> |
| 4018 |
% \end{macrocode} |
| 4019 |
% |
| 4020 |
% 五号字使用标准文档类的 |10pt| 字体大小设置,小四号字则使用 |12pt|。 |
| 4021 |
% \begin{macrocode} |
| 4022 |
\int_case:nn { \g_@@_font_size_int } |
| 4023 |
{ |
| 4024 |
{ 0 } { \clist_gput_right:Nn \g_@@_std_options_clist { 10pt } } |
| 4025 |
{ 1 } { \clist_gput_right:Nn \g_@@_std_options_clist { 12pt } } |
| 4026 |
} |
| 4027 |
% \end{macrocode} |
| 4028 |
% |
| 4029 |
% 载入标准文档类。 |
| 4030 |
% \begin{macrocode} |
| 4031 |
%<*article> |
| 4032 |
\ctex_load_std_class:n { article } |
| 4033 |
%</article> |
| 4034 |
%<*book> |
| 4035 |
\ctex_load_std_class:n { book } |
| 4036 |
%</book> |
| 4037 |
%<*report> |
| 4038 |
\ctex_load_std_class:n { report } |
| 4039 |
%</report> |
| 4040 |
%<*beamer> |
| 4041 |
\ctex_load_std_class:n { beamer } |
| 4042 |
%</beamer> |
| 4043 |
% \end{macrocode} |
| 4044 |
% |
| 4045 |
% \begin{macrocode} |
| 4046 |
%</class> |
| 4047 |
% \end{macrocode} |
| 4048 |
% |
| 4049 |
% \subsection{特定引擎支持与设置} |
| 4050 |
% |
| 4051 |
% \changes{v2.5}{2020/04/22}{给 \LaTeX 和 \upLaTeX 下的文档类指定驱动为 \dvipdfmx。} |
| 4052 |
% |
| 4053 |
% \subsubsection{\pkg{ctexbackend.cfg}} |
| 4054 |
% |
| 4055 |
% 对于 \XeLaTeX{}/\pdfLaTeX{}/\LuaLaTeX{} 等默认直接输出 PDF 的编译方式,用户 |
| 4056 |
% 无需为涉及驱动的宏包指定驱动选项。对于 \LaTeX 和 \upLaTeX{} 等默认不直接输出 PDF 的编译方式, |
| 4057 |
% 用户则需要指定驱动选项。 |
| 4058 |
% |
| 4059 |
% 由于历史遗留问题,在使用 \LaTeX{} 或 \upLaTeX{} 等编译时, |
| 4060 |
% 大多数涉及驱动的宏包选定的默认输出驱动都是 Dvips。 |
| 4061 |
% 考虑当前实际使用频率,以及考虑到 \CTeX{} 宏集对中文支持的默认方式, |
| 4062 |
% 我们在用户使用 \CTeX{} 系列文档类时,将默认的输出驱动改为 \dvipdfmx。 |
| 4063 |
% |
| 4064 |
% 具体来说,如果 |dvips|,|dvipdfmx|,|dvisvgm| 等驱动没有在文档类的全局选项中被明确指定, |
| 4065 |
% 我们就在 \tn{@classoptionslist} 开头加入 |dvipdfmx|。 |
| 4066 |
% |
| 4067 |
% 本段代码只在 \cls{ctexart} 等文档类开头载入,不在 \pkg{ctex} 中使用。 |
| 4068 |
% 并且需要放在 \pkg{expl3} 之前载入,保证它载入正确的 backend 文件。 |
| 4069 |
% \begin{macrocode} |
| 4070 |
%<*backend> |
| 4071 |
\begingroup |
| 4072 |
\expandafter\ifx\csname Umathchardef\endcsname\relax |
| 4073 |
\else\expandafter\endgroup\expandafter\endinput\fi |
| 4074 |
\ifodd |
| 4075 |
\expandafter\ifx\csname pdfoutput\endcsname\relax |
| 4076 |
\expandafter\ifx\csname enablecjktoken\endcsname\relax 0\else 1\fi |
| 4077 |
\else\ifnum\pdfoutput>0 0\else 1\fi\fi\space |
| 4078 |
\def\x#1{% |
| 4079 |
\if\relax\detokenize{#1}\relax |
| 4080 |
\gdef\@classoptionslist{dvipdfmx}% |
| 4081 |
\else |
| 4082 |
\let\CTEX@add\@ne |
| 4083 |
\@tfor\x:={dvips}{dvipdfmx}{dvisvgm}\do{% |
| 4084 |
\expandafter\in@\expandafter{\expandafter,\x,}{,#1,}% |
| 4085 |
\ifin@ \let\CTEX@add\tw@ \@break@tfor \fi}% |
| 4086 |
\ifodd\CTEX@add \gdef\@classoptionslist{dvipdfmx,#1}\fi |
| 4087 |
\fi} |
| 4088 |
\expandafter\x\expandafter{\@classoptionslist} |
| 4089 |
\fi |
| 4090 |
\endgroup |
| 4091 |
%</backend> |
| 4092 |
% \end{macrocode} |
| 4093 |
% |
| 4094 |
% \subsubsection{\pkg{ctex-engine-pdftex.def}} |
| 4095 |
% |
| 4096 |
% \begin{macro}[int]{\ctex_set_zhmap:n} |
| 4097 |
% 设置 \upTeX{} 字体映射,同时作用于 \tn{AtBeginDvi} 与 |
| 4098 |
% \tn{AtBeginShipoutFirst}。该宏对 \pdfTeX{} 和 \upTeX{} 均有用。 |
| 4099 |
% \tn{AtBeginDvi} 直接将 \tn{special} 保存到盒子中, |
| 4100 |
% \tn{AtBeginShipoutFirst} 是保存到到宏中,并且不展开参数。 |
| 4101 |
% |
| 4102 |
% 可以使用 \LaTeX\ 2020/10/01 的钩子机制来统一设置。 |
| 4103 |
% \begin{macrocode} |
| 4104 |
%<*pdftex|uptex|aptex> |
| 4105 |
\cs_new_protected:Npn \ctex_set_zhmap:n |
| 4106 |
{ \tl_gput_right:Nx \g_@@_zhmap_tl } |
| 4107 |
\cs_new_protected:Npn \ctex_use_zhmap: |
| 4108 |
{ \tl_use:N \g_@@_zhmap_tl } |
| 4109 |
\cs_if_exist:NTF \ctex_gadd_ltxhook:nn |
| 4110 |
{ |
| 4111 |
\cs_new_protected:Npn \ctex_at_shipout_first:n |
| 4112 |
{ \ctex_gadd_ltxhook:nn { shipout/firstpage } } |
| 4113 |
\ctex_at_shipout_first:n { \ctex_use_zhmap: } |
| 4114 |
} |
| 4115 |
{ |
| 4116 |
\cs_new_protected:Npn \ctex_add_dvi_zhmap: |
| 4117 |
{ \AtBeginDvi { \ctex_use_zhmap: } } |
| 4118 |
\ctex_after_end_preamble:n { \ctex_add_dvi_zhmap: } |
| 4119 |
\ctex_at_end_package:nn { atbegshi } |
| 4120 |
{ |
| 4121 |
\cs_new_protected:Npn \ctex_at_shipout_first:n |
| 4122 |
{ \AtBeginShipoutFirst } |
| 4123 |
\ctex_at_shipout_first:n { \ctex_use_zhmap: } |
| 4124 |
\cs_gset_eq:NN \ctex_add_dvi_zhmap: \prg_do_nothing: |
| 4125 |
} |
| 4126 |
} |
| 4127 |
\tl_new:N \g_@@_zhmap_tl |
| 4128 |
\@onlypreamble \ctex_set_zhmap:n |
| 4129 |
%</pdftex|uptex|aptex> |
| 4130 |
% \end{macrocode} |
| 4131 |
% \end{macro} |
| 4132 |
% |
| 4133 |
% \begin{macrocode} |
| 4134 |
%<*pdftex> |
| 4135 |
% \end{macrocode} |
| 4136 |
% |
| 4137 |
% \changes{v2.1}{2015/05/18}{给 \pdfLaTeX{} 下的非 UTF-8 编码 CJK 字体族加上 CMap。} |
| 4138 |
% |
| 4139 |
% \begin{variable}{\c_@@_cmap_encoding_seq} |
| 4140 |
% 需要加上 CMap 的 CJK 字体编码。 |
| 4141 |
% \begin{macrocode} |
| 4142 |
\seq_const_from_clist:Nn \c_@@_cmap_encoding_seq |
| 4143 |
{ C19 , C10 , C00 , C09 , C40 , C60 } |
| 4144 |
% \end{macrocode} |
| 4145 |
% \end{variable} |
| 4146 |
% |
| 4147 |
% \begin{macro}[int]{\ctex_family_cmap:nn} |
| 4148 |
% 在 \tn{DeclareFontFamily} 的 \meta{loading-settings} 中给 CJK 字体族加上 CMap。 |
| 4149 |
% \begin{macrocode} |
| 4150 |
\cs_new_protected:Npn \ctex_family_cmap:nn #1#2 |
| 4151 |
{ |
| 4152 |
\cs_if_free:cF { #1 + #2 } |
| 4153 |
{ |
| 4154 |
\seq_if_in:NnT \c_@@_cmap_encoding_seq {#1} |
| 4155 |
{ \tl_gput_right:cn { #1 + #2 } { \ctex_add_cmap:n {#1} } } |
| 4156 |
} |
| 4157 |
} |
| 4158 |
\cs_generate_variant:Nn \ctex_family_cmap:nn { ee } |
| 4159 |
\cs_new_eq:NN \CTEX@Family@CMap \ctex_family_cmap:ee |
| 4160 |
% \end{macrocode} |
| 4161 |
% \end{macro} |
| 4162 |
% |
| 4163 |
% \changes{v2.5.7}{2021/06/06}{更好地兼容 \pkg{cmap} 包。} |
| 4164 |
% |
| 4165 |
% \begin{macro}[int]{\ctex_add_cmap:n} |
| 4166 |
% \changes{v2.5.7}{2021/06/06}{确保 cmap 文件存在。} |
| 4167 |
% \changes{v2.5.10}{2022/07/11}{使用封装好的函数。} |
| 4168 |
% 给 |#1| 编码的 CJK 字体加上 CMap。 |
| 4169 |
% \begin{macrocode} |
| 4170 |
\cs_new_protected:Npn \ctex_add_cmap:n #1 |
| 4171 |
{ |
| 4172 |
\cs_if_free:NF \CJK@plane |
| 4173 |
{ \exp_args:Ne \@@_add_cmap_auxi:n { #1 \CJK@plane } } |
| 4174 |
} |
| 4175 |
\cs_new_protected:Npn \@@_add_cmap_auxi:n #1 |
| 4176 |
{ \exp_args:Nc \@@_add_cmap_auxii:Nn { @@_add_cmap_ #1 : } {#1} } |
| 4177 |
\cs_new_protected:Npn \@@_add_cmap_auxii:Nn #1#2 |
| 4178 |
{ |
| 4179 |
\cs_if_exist:NF #1 { \@@_save_cmap:Nn #1 {#2} } |
| 4180 |
#1 |
| 4181 |
} |
| 4182 |
\cs_new_protected:Npn \@@_save_cmap:Nn #1#2 |
| 4183 |
{ |
| 4184 |
\exp_args:Ne \file_get_full_name:nNTF |
| 4185 |
{ \str_lowercase:n {#2} .cmap } \l_@@_cmap_file_tl |
| 4186 |
{ |
| 4187 |
\pdf_object_unnamed_write:nx |
| 4188 |
{ fstream } |
| 4189 |
{ { } { \l_@@_cmap_file_tl } } |
| 4190 |
\cs_new_protected:Npx #1 |
| 4191 |
{ |
| 4192 |
\pdfnobuiltintounicode \tex_font:D |
| 4193 |
\tex_pdffontattr:D \tex_font:D |
| 4194 |
{ /ToUnicode ~ \pdf_object_ref_last: } |
| 4195 |
} |
| 4196 |
} |
| 4197 |
{ \cs_new_eq:NN #1 \prg_do_nothing: } |
| 4198 |
} |
| 4199 |
\tl_new:N \l_@@_cmap_file_tl |
| 4200 |
% \end{macrocode} |
| 4201 |
% \end{macro} |
| 4202 |
% |
| 4203 |
% \begin{macro}[int]{\DeclareFontFamily} |
| 4204 |
% 只在 \pdfLaTeX{} 下加 CMap。如 \pkg{cmap} 宏包被引入,则不重复设置。 |
| 4205 |
% \begin{macrocode} |
| 4206 |
\sys_if_output_pdf:T |
| 4207 |
{ |
| 4208 |
\exp_args:Nno \use:n |
| 4209 |
{ \cs_gset_protected:Npn \DeclareFontFamily #1#2#3 } |
| 4210 |
{ |
| 4211 |
\DeclareFontFamily {#1} {#2} {#3} |
| 4212 |
\CTEX@Family@CMap {#1} {#2} |
| 4213 |
} |
| 4214 |
\ctex_at_end_package:nn { cmap } |
| 4215 |
{ |
| 4216 |
\cs_gset_eq:NN \ctex_add_cmap:n \use_none:n |
| 4217 |
\cs_gset_eq:NN \CTEX@Family@CMap \use_none:nn |
| 4218 |
} |
| 4219 |
} |
| 4220 |
% \end{macrocode} |
| 4221 |
% \end{macro} |
| 4222 |
% |
| 4223 |
% 首先检查选项,决定是否载入 \pkg{zhmCJK} 宏包。 |
| 4224 |
% \begin{macrocode} |
| 4225 |
\bool_if:NTF \g_@@_zhmCJK_bool |
| 4226 |
{ |
| 4227 |
\exp_args:Ne \PassOptionsToPackage |
| 4228 |
{ encoding = \g_@@_encoding_tl } |
| 4229 |
{ zhmCJK } |
| 4230 |
\RequirePackage { zhmCJK } |
| 4231 |
} |
| 4232 |
% \end{macrocode} |
| 4233 |
% 不载入 \pkg{zhmCJK} 宏包时直接调用 \pkg{CJK} 及相关宏包。 |
| 4234 |
% \begin{macrocode} |
| 4235 |
{ |
| 4236 |
\str_if_eq:onTF { \g_@@_encoding_tl } { GBK } |
| 4237 |
{ \RequirePackage { CJK } } |
| 4238 |
{ \RequirePackage { CJKutf8 } } |
| 4239 |
\RequirePackage { CJKpunct , CJKspace } |
| 4240 |
% \end{macrocode} |
| 4241 |
% |
| 4242 |
% \changes{v2.4.4}{2016/09/09}{解决 \opt{zhmap} 文件的 \tn{catcode} 问题。} |
| 4243 |
% |
| 4244 |
% \begin{macro}[int]{\ctex_load_zhmap:nnnn} |
| 4245 |
% 载入 \pkg{zhmetrics} 的字体映射文件,同时设置 \tn{CJKrmdefault} 等。 |
| 4246 |
% \begin{macrocode} |
| 4247 |
\cs_new_protected:Npn \ctex_load_zhmap:nnnn #1#2#3#4 |
| 4248 |
{ |
| 4249 |
\tl_set:Nn \CJKrmdefault {#1} |
| 4250 |
\tl_set:Nn \CJKsfdefault {#2} |
| 4251 |
\tl_set:Nn \CJKttdefault {#3} |
| 4252 |
\ctex_set_zhmap:n { \ctex_file_input:n { ctex-zhmap- #4 .tex } } |
| 4253 |
} |
| 4254 |
\@onlypreamble \ctex_load_zhmap:nnnn |
| 4255 |
} |
| 4256 |
% \end{macrocode} |
| 4257 |
% \end{macro} |
| 4258 |
% |
| 4259 |
% \changes{v2.5.10}{2022/06/10}{取消 \LaTeX\ 2022-06-01 对书名号的定义。} |
| 4260 |
% |
| 4261 |
% \begin{macro}{\ctex_undeclare_unicode_character:n,\ctex_utfviii_char:n} |
| 4262 |
% \LaTeX\ 2022-06-01 将通常用作中文书名号的 U+3008 和 U+3009 分别定义为 |
| 4263 |
% \tn{textlangle} 和 \tn{textrangle},这个定义会被 \pkg{CJKutf8} 包会优先使用。 |
| 4264 |
% 我们总是使用中文书名号,需要取消 \LaTeX\ 的定义,作用是局部的,不使用 \cs{cs_undefine:N}。 |
| 4265 |
% \begin{macrocode} |
| 4266 |
\cs_new_protected:Npn \ctex_undeclare_unicode_character:n #1 |
| 4267 |
{ \cs_set_eq:cN { u8 : \ctex_utfviii_char:n {#1} } \tex_undefined:D } |
| 4268 |
\cs_new:Npn \ctex_utfviii_char:n #1 |
| 4269 |
{ |
| 4270 |
\exp_last_unbraced:Ne \@@_utfviii_char_aux:nnnn |
| 4271 |
{ \char_to_utfviii_bytes:n {#1} } |
| 4272 |
} |
| 4273 |
\cs_new:Npn \@@_utfviii_char_aux:nnnn #1#2#3#4 |
| 4274 |
{ |
| 4275 |
\char_generate:nn {#1} { 12 } |
| 4276 |
\tl_if_empty:nF {#2} { \char_generate:nn {#2} { 12 } } |
| 4277 |
\tl_if_empty:nF {#3} { \char_generate:nn {#3} { 12 } } |
| 4278 |
\tl_if_empty:nF {#4} { \char_generate:nn {#4} { 12 } } |
| 4279 |
} |
| 4280 |
\CJKaddEncHook { UTF8 } |
| 4281 |
{ |
| 4282 |
\ctex_undeclare_unicode_character:n { "3008 } |
| 4283 |
\ctex_undeclare_unicode_character:n { "3009 } |
| 4284 |
} |
| 4285 |
% \end{macrocode} |
| 4286 |
% \end{macro} |
| 4287 |
% |
| 4288 |
% \begin{macro}[int]{\ctex_CJK_input:n,\CJK@input} |
| 4289 |
% 载入 \pkg{CJK} 包的 \file{.enc} 和 \file{.bdg} 等文件时,需要设置 \tn{endlinechar} 为 $-1$。 |
| 4290 |
% \begin{macrocode} |
| 4291 |
\cs_new_protected:Npn \ctex_CJK_input:n #1 |
| 4292 |
{ |
| 4293 |
\ctex_push_file: |
| 4294 |
\int_set:Nn \tex_endlinechar:D { -1 } |
| 4295 |
\file_input:n {#1} |
| 4296 |
\ctex_pop_file: |
| 4297 |
} |
| 4298 |
\cs_set_eq:NN \CJK@input \ctex_CJK_input:n |
| 4299 |
% \end{macrocode} |
| 4300 |
% \end{macro} |
| 4301 |
% |
| 4302 |
% \begin{macro}[int]{\ctex_plane_to_utfxvibe:Nn,\CJK@surr} |
| 4303 |
% \changes{v2.0}{2014/04/08}{解决与 \tn{nouppercase} 的冲突。} |
| 4304 |
% \pkg{fancyhdr} 宏包的 \tn{nouppercase} 会将 \tn{uppercase} 定义为 \tn{relax},而 |
| 4305 |
% \tn{CJK@surr} 需要用它将 \tn{CJK@plane} 转化成大写字母,这就造成了冲突^^A |
| 4306 |
% \footnote{\url{https://github.com/CTeX-org/ctex-kit/issues/146}}。 |
| 4307 |
% 我们在这里给出 \tn{CJK@surr} 的一个不依赖 \tn{uppercase} 的实现。 |
| 4308 |
% \begin{macrocode} |
| 4309 |
\cs_if_free:NF \CJK@surr |
| 4310 |
{ |
| 4311 |
\cs_new_protected:Npn \ctex_plane_to_utfxvibe:Nn #1#2 |
| 4312 |
{ |
| 4313 |
\int_set:Nn \l_@@_tmp_int |
| 4314 |
{ \exp_args:Ne \int_from_hex:n {#2} } |
| 4315 |
\int_compare:nNnTF \l_@@_tmp_int < { 256 } |
| 4316 |
{ \tl_gset:Nx #1 { \int_to_Hex:n { \l_@@_tmp_int } } } |
| 4317 |
{ |
| 4318 |
\int_sub:Nn \l_@@_tmp_int { 256 } |
| 4319 |
\tl_gset:Nx #1 |
| 4320 |
{ |
| 4321 |
\int_to_Hex:n |
| 4322 |
{ \int_div_truncate:nn { \l_@@_tmp_int } { 4 } + "D800 } |
| 4323 |
\int_to_Hex:n |
| 4324 |
{ \int_mod:nn { \l_@@_tmp_int } { 4 } + "DC } |
| 4325 |
} |
| 4326 |
} |
| 4327 |
} |
| 4328 |
\cs_set_eq:NN \CJK@surr \ctex_plane_to_utfxvibe:Nn |
| 4329 |
} |
| 4330 |
% \end{macrocode} |
| 4331 |
% \end{macro} |
| 4332 |
% |
| 4333 |
% \begin{macro}[int]{\CJK@addcmap} |
| 4334 |
% \changes{v2.5.7}{2021/06/06}{应用 \tn{pdfnobuiltintounicode}。} |
| 4335 |
% \LaTeX \ 2021-06-01 默认载入 \file{glyphtounicode.tex},我们对 CJK 字体禁用这一内建设置。 |
| 4336 |
% \begin{macrocode} |
| 4337 |
\cs_if_free:NF \CJK@addcmap |
| 4338 |
{ |
| 4339 |
\ctex_patch_cmd:Nnn \CJK@addcmap |
| 4340 |
{ \pdffontattr \font@name } |
| 4341 |
{ |
| 4342 |
\pdfnobuiltintounicode \font@name |
| 4343 |
\pdffontattr \font@name |
| 4344 |
} |
| 4345 |
} |
| 4346 |
% \end{macrocode} |
| 4347 |
% \end{macro} |
| 4348 |
% |
| 4349 |
% \pkg{CJKpunct} 宏包会在 \tn{AtBeginDocument} 的里设置标点格式为 \opt{quanjiao}。 |
| 4350 |
% \begin{macrocode} |
| 4351 |
\AtBeginDocument |
| 4352 |
{ |
| 4353 |
\use:e |
| 4354 |
{ |
| 4355 |
\str_if_eq:nnF { \l_@@_punct_tl } { quanjiao } |
| 4356 |
{ \exp_not:N \punctstyle { \l_@@_punct_tl } } |
| 4357 |
} |
| 4358 |
} |
| 4359 |
% \end{macrocode} |
| 4360 |
% |
| 4361 |
% 在导言区末尾更新 \tn{CJKfamilydefault},注意要在 \tn{CJK@envStart} 之前使用。 |
| 4362 |
% \begin{macrocode} |
| 4363 |
\ctex_at_end_preamble:n { \ctex_update_default_family: } |
| 4364 |
% \end{macrocode} |
| 4365 |
% |
| 4366 |
% 从 \LaTeX\ 2018-04-01 开始,传统引擎的默认编码被设置成 UTF-8, |
| 4367 |
% 汉字的首字节已经被设置成活动字符,我们无需再使用 \tn{CJK@makeActive} 设置。 |
| 4368 |
% \tn{CJK@envStart} 的定义是 |
| 4369 |
% \begin{verbatim} |
| 4370 |
% \def\CJK@envStart#1#2#3{ |
| 4371 |
% \CJK@upperReset |
| 4372 |
% \ifCJK@lowercase@ |
| 4373 |
% \CJK@lowerReset |
| 4374 |
% \fi% |
| 4375 |
% \CJK@makeActive% |
| 4376 |
% \CJK@global\let\CJK@selectFamily \CJK@selFam |
| 4377 |
% \CJK@global\let\CJK@selectEnc \CJK@selEnc% |
| 4378 |
% \def\CJK@@@enc{#2} |
| 4379 |
% \ifx\CJK@@@enc \@empty |
| 4380 |
% \PackageInfo{CJK}{ |
| 4381 |
% no encoding parameter given,\MessageBreak |
| 4382 |
% waiting for \protect\CJKenc\space commands} |
| 4383 |
% \else |
| 4384 |
% \CJKenc{#2} |
| 4385 |
% \fi |
| 4386 |
% \CJKfontenc{#2}{#1} |
| 4387 |
% \CJKfamily{#3} |
| 4388 |
% \def\CJK@series{\f@series} |
| 4389 |
% \def\CJK@shape{\f@shape}% |
| 4390 |
% \csname CJKhook\endcsname} |
| 4391 |
% \end{verbatim} |
| 4392 |
% \tn{CJK@upperReset} 可能会有一定风险,因此我们直到导言区末尾才使用 |
| 4393 |
% \tn{CJK@envStart}。这样可以避免将 \env{CJK} 环境内置入 \env{document} 环境的 |
| 4394 |
% 最里层,最后也就不需要 \tn{clearpage}。\pkg{zhmCJK} 已经提供类似功能。 |
| 4395 |
% 注意先使用 \cs{ctex_update_default_family:} 更新 \tn{CJKfamilydefault}。 |
| 4396 |
% \begin{macrocode} |
| 4397 |
\bool_if:NF \g_@@_zhmCJK_bool |
| 4398 |
{ |
| 4399 |
\str_if_eq:onTF { \g_@@_encoding_tl } { UTF8 } |
| 4400 |
{ \CJK@loadBinding { UTF8 } } |
| 4401 |
{ \CJK@loadBinding { standard } } |
| 4402 |
\exp_args:Ne \ctex_at_end_preamble:n |
| 4403 |
{ |
| 4404 |
\exp_not:N \CJK@envStart |
| 4405 |
{ } { \g_@@_encoding_tl } { \exp_not:N \CJKfamilydefault } |
| 4406 |
\exp_not:N \CJKtilde |
| 4407 |
} |
| 4408 |
} |
| 4409 |
% \end{macrocode} |
| 4410 |
% |
| 4411 |
% \begin{macro}[int]{\ctex_auto_ignorespaces:} |
| 4412 |
% 保存 \tn{CJK@@ignorespaces} 的定义,方便使用。 |
| 4413 |
% \begin{macrocode} |
| 4414 |
\cs_new_eq:NN \ctex_auto_ignorespaces: \CJK@@@@ignorespaces |
| 4415 |
% \end{macrocode} |
| 4416 |
% \end{macro} |
| 4417 |
% |
| 4418 |
% \changes{v2.5.10}{2022/07/08}{解决 \pkg{CJK} 包与 \cs{text_uppercase:n} 等转化函数的冲突。} |
| 4419 |
% |
| 4420 |
% \begin{macro}{\CJK@X,\CJK@XX,\CJK@XXX,\CJK@XXXX} |
| 4421 |
% 最新 \LaTeX\ 中的 \tn{MakeUppercase} 等大小写转化命令被定义为 \LaTeXiii\ 中对应的 |
| 4422 |
% \cs{text_uppercase:n} 等函数。 |
| 4423 |
% 它会先将参数用 \cs{text_expand:n} 逐步展开,这与 \pkg{CJK} 包的定义不兼容。 |
| 4424 |
% 可以有多种方法解决这个冲突,最简单直接的方法是将首字节的活动字符用 \tn{protected} 来定义, |
| 4425 |
% 但可能有一定的兼容性问题。保险起见,我们采用将 \tn{CJK@X} 等内部宏转化为 \tn{protected} |
| 4426 |
% 宏的方式,并将参数提前由字符转化为数字,避免在移动参数中被进一步展开。 |
| 4427 |
% \begin{macrocode} |
| 4428 |
\cs_new:Npn \@@_char:N #1 |
| 4429 |
{ \exp_args:Ne \CTEX@char@n { \int_value:w `#1 } } |
| 4430 |
\cs_new:Npn \@@_char:NN #1#2 |
| 4431 |
{ |
| 4432 |
\token_if_eq_meaning:NNTF #2 \protect |
| 4433 |
{ \@@_char_aux:NN #1 } |
| 4434 |
{ \@@_char_aux:NN #1#2 } |
| 4435 |
} |
| 4436 |
\cs_new:Npn \@@_char_aux:NN #1#2 |
| 4437 |
{ |
| 4438 |
\exp_last_unbraced:Ne \CTEX@char@nn |
| 4439 |
{ |
| 4440 |
{ \int_value:w `#1 } |
| 4441 |
{ \int_value:w `#2 } |
| 4442 |
} |
| 4443 |
} |
| 4444 |
\cs_new:Npn \@@_char:NNN #1#2#3 |
| 4445 |
{ |
| 4446 |
\token_if_eq_meaning:NNTF #2 \protect |
| 4447 |
{ \@@_char_auxi:NNNN #1#3 } |
| 4448 |
{ \@@_char_auxii:NNN #1#2#3 } |
| 4449 |
} |
| 4450 |
\cs_new:Npn \@@_char_auxi:NNN #1#2#3#4 |
| 4451 |
{ \@@_char_auxii:NNN #1#2#4 } |
| 4452 |
\cs_new:Npn \@@_char_auxii:NNN #1#2#3 |
| 4453 |
{ |
| 4454 |
\exp_last_unbraced:Ne \CTEX@char@nnn |
| 4455 |
{ |
| 4456 |
{ \int_value:w `#1 } |
| 4457 |
{ \int_value:w `#2 } |
| 4458 |
{ \int_value:w `#3 } |
| 4459 |
} |
| 4460 |
} |
| 4461 |
\cs_new:Npn \@@_char:NNNN #1#2#3#4 |
| 4462 |
{ |
| 4463 |
\token_if_eq_meaning:NNTF #2 \protect |
| 4464 |
{ \@@_char_auxi:NNNNN #1#3 } |
| 4465 |
{ \@@_char_auxii:NNNN #1#2#3#4 } |
| 4466 |
} |
| 4467 |
\cs_new:Npn \@@_char_auxi:NNNNN #1#2#3#4#5 |
| 4468 |
{ \@@_char_auxii:NNNN #1#2#3#5 } |
| 4469 |
\cs_new:Npn \@@_char_auxii:NNNN #1#2#3#4 |
| 4470 |
{ |
| 4471 |
\exp_last_unbraced:Ne \CTEX@char@nnnn |
| 4472 |
{ |
| 4473 |
{ \int_value:w `#1 } |
| 4474 |
{ \int_value:w `#2 } |
| 4475 |
{ \int_value:w `#3 } |
| 4476 |
{ \int_value:w `#4 } |
| 4477 |
} |
| 4478 |
} |
| 4479 |
\cs_gset_eq:NN \CJK@X \@@_char:N |
| 4480 |
\cs_gset_eq:NN \CJK@XX \@@_char:NN |
| 4481 |
\cs_gset_eq:NN \CJK@XXX \@@_char:NNN |
| 4482 |
\cs_gset_eq:NN \CJK@XXXX \@@_char:NNNN |
| 4483 |
% \end{macrocode} |
| 4484 |
% \pkg{CJKutf8} 包优先使用 |\u8:xxx| 的 \LaTeX\ 定义。 |
| 4485 |
% \begin{macrocode} |
| 4486 |
\str_if_eq:onF { \g_@@_encoding_tl } { GBK } |
| 4487 |
{ |
| 4488 |
\exp_args:Nne \use:n |
| 4489 |
{ \cs_gset:Npn \@@_char_aux:NN #1#2 } |
| 4490 |
{ |
| 4491 |
\exp_not:N \cs_if_exist_use:cF |
| 4492 |
{ u8: \exp_not:N \tl_to_str:n { #1#2 } } |
| 4493 |
{ \exp_not:o { \@@_char_aux:NN {#1} {#2} } } |
| 4494 |
} |
| 4495 |
\exp_args:Nne \use:n |
| 4496 |
{ \cs_gset:Npn \@@_char_auxii:NNN #1#2#3 } |
| 4497 |
{ |
| 4498 |
\exp_not:N \cs_if_exist_use:cF |
| 4499 |
{ u8: \exp_not:N \tl_to_str:n { #1#2#3 } } |
| 4500 |
{ \exp_not:o { \@@_char_auxii:NNN {#1} {#2} {#3} } } |
| 4501 |
} |
| 4502 |
} |
| 4503 |
% \end{macrocode} |
| 4504 |
% \end{macro} |
| 4505 |
% |
| 4506 |
% \begin{macro}{\mule@arg} |
| 4507 |
% 处理文档被 |extconv| 等工具预处理过的情况,只考虑最简单的情形。 |
| 4508 |
% \begin{macrocode} |
| 4509 |
\group_begin: |
| 4510 |
\char_set_catcode_active:n { "7F } |
| 4511 |
\cs_new:Npn \@@_char_preproc:w #1 ^^7f #2 ^^7f |
| 4512 |
{ \exp_args:No \CTEX@char@nn { \int_value:w `#1 } {#2} } |
| 4513 |
\cs_gset_eq:NN \mule@arg \@@_char_preproc:w |
| 4514 |
\group_end: |
| 4515 |
\exp_args:Ne \ctex_at_end:n |
| 4516 |
{ |
| 4517 |
\char_set_catcode:nn |
| 4518 |
{ \int_value:w "7F } |
| 4519 |
{ \char_value_catcode:n { "7F } } |
| 4520 |
} |
| 4521 |
% \end{macrocode} |
| 4522 |
% \end{macro} |
| 4523 |
% |
| 4524 |
% \begin{macro}{\CTEX@char@n,\CTEX@char@nn,\CTEX@char@nnn,\CTEX@char@nnnn} |
| 4525 |
% 额外加入 \cs{mode_leave_vertical:} 是为了解决某些历史遗留问题。 |
| 4526 |
% \begin{macrocode} |
| 4527 |
\cs_new_protected:Npn \CTEX@char@n #1 |
| 4528 |
{ |
| 4529 |
\mode_leave_vertical: |
| 4530 |
\use:c { CJK@ #1 } |
| 4531 |
\CJK@ignorespaces |
| 4532 |
} |
| 4533 |
\cs_new_protected:Npn \CTEX@char@nn #1#2 |
| 4534 |
{ |
| 4535 |
\mode_leave_vertical: |
| 4536 |
\use:c { CJK@ #1 } {#2} |
| 4537 |
\CJK@ignorespaces |
| 4538 |
} |
| 4539 |
\cs_new_protected:Npn \CTEX@char@nnn #1#2#3 |
| 4540 |
{ |
| 4541 |
\mode_leave_vertical: |
| 4542 |
\use:c { CJK@ #1 } {#2} {#3} |
| 4543 |
\CJK@ignorespaces |
| 4544 |
} |
| 4545 |
\cs_new_protected:Npn \CTEX@char@nnnn #1#2#3#4 |
| 4546 |
{ |
| 4547 |
\mode_leave_vertical: |
| 4548 |
\use:c { CJK@ #1 } {#2} {#3} {#4} |
| 4549 |
\CJK@ignorespaces |
| 4550 |
} |
| 4551 |
% \end{macrocode} |
| 4552 |
% \end{macro} |
| 4553 |
% |
| 4554 |
% \begin{macro}{\CTEX@char@nn@n,\CTEX@char@nnn@n,\CTEX@char@nnnn@n} |
| 4555 |
% 以下给 \tn{CTEX@char@nn} 等定义在 \cs{text_expand:n} 中的等价形式, |
| 4556 |
% 将它们的参数用只有一个参数的 \tn{CTEX@char@nn@n} 等包装起来, |
| 4557 |
% 并将 \tn{CTEX@char@nn@n} 等放入排除列表中,避免可能的大小写转化。 |
| 4558 |
% \begin{macrocode} |
| 4559 |
\cs_new_protected:Npn \CTEX@char@nn@n #1 { \CTEX@char@nn #1 } |
| 4560 |
\cs_new_protected:Npn \CTEX@char@nnn@n #1 { \CTEX@char@nnn #1 } |
| 4561 |
\cs_new_protected:Npn \CTEX@char@nnnn@n #1 { \CTEX@char@nnnn #1 } |
| 4562 |
\cs_new:Npn \@@_char_wrap:nn #1#2 |
| 4563 |
{ \CTEX@char@nn@n { {#1} {#2} } } |
| 4564 |
\cs_new:Npn \@@_char_wrap:nnn #1#2#3 |
| 4565 |
{ \CTEX@char@nnn@n { {#1} {#2} {#3} } } |
| 4566 |
\cs_new:Npn \@@_char_wrap:nnnn #1#2#3#4 |
| 4567 |
{ \CTEX@char@nnnn@n { {#1} {#2} {#3} {#4} } } |
| 4568 |
\tl_put_right:Nn \l_text_case_exclude_arg_tl |
| 4569 |
{ |
| 4570 |
\CTEX@char@n |
| 4571 |
\CTEX@char@nn@n |
| 4572 |
\CTEX@char@nnn@n |
| 4573 |
\CTEX@char@nnnn@n |
| 4574 |
} |
| 4575 |
\text_declare_expand_equivalent:Nn \CTEX@char@nn { \@@_char_wrap:nn } |
| 4576 |
\text_declare_expand_equivalent:Nn \CTEX@char@nnn { \@@_char_wrap:nnn } |
| 4577 |
\text_declare_expand_equivalent:Nn \CTEX@char@nnnn { \@@_char_wrap:nnnn } |
| 4578 |
% \end{macrocode} |
| 4579 |
% 以下给 \tn{CTEX@char@nn@n} 等定义在 \cs{text_purify:n} 中的等价形式, |
| 4580 |
% 将参数中的数字转化回字符。 |
| 4581 |
% \begin{macrocode} |
| 4582 |
\cs_new:Npn \@@_char_raw:n #1 |
| 4583 |
{ \char_generate:nn {#1} { 12 } } |
| 4584 |
\cs_new:Npn \@@_char_raw:nn #1#2 |
| 4585 |
{ |
| 4586 |
\char_generate:nn {#1} { 12 } |
| 4587 |
\char_generate:nn {#2} { 12 } |
| 4588 |
} |
| 4589 |
\cs_new:Npn \@@_char_raw:nnn #1#2#3 |
| 4590 |
{ |
| 4591 |
\char_generate:nn {#1} { 12 } |
| 4592 |
\char_generate:nn {#2} { 12 } |
| 4593 |
\char_generate:nn {#3} { 12 } |
| 4594 |
} |
| 4595 |
\cs_new:Npn \@@_char_raw:nnnn #1#2#3#4 |
| 4596 |
{ |
| 4597 |
\char_generate:nn {#1} { 12 } |
| 4598 |
\char_generate:nn {#2} { 12 } |
| 4599 |
\char_generate:nn {#3} { 12 } |
| 4600 |
\char_generate:nn {#4} { 12 } |
| 4601 |
} |
| 4602 |
\cs_new:Npn \@@_char_raw_nn:n #1 { \use:e { \@@_char_raw:nn #1 } } |
| 4603 |
\cs_new:Npn \@@_char_raw_nnn:n #1 { \use:e { \@@_char_raw:nnn #1 } } |
| 4604 |
\cs_new:Npn \@@_char_raw_nnnn:n #1 { \use:e { \@@_char_raw:nnnn #1 } } |
| 4605 |
\text_declare_purify_equivalent:Nn \CTEX@char@n { \@@_char_raw:n } |
| 4606 |
\text_declare_purify_equivalent:Nn \CTEX@char@nn@n { \@@_char_raw_nn:n } |
| 4607 |
\text_declare_purify_equivalent:Nn \CTEX@char@nnn@n { \@@_char_raw_nnn:n } |
| 4608 |
\text_declare_purify_equivalent:Nn \CTEX@char@nnnn@n { \@@_char_raw_nnnn:n } |
| 4609 |
% \end{macrocode} |
| 4610 |
% \end{macro} |
| 4611 |
% |
| 4612 |
% \begin{macro}[int]{\ctex_ignorespaces_case:N,\ctex_set_ignorespaces:} |
| 4613 |
% 设置忽略空格的的方式。根据 \opt{space} 选项的值重定义 \tn{CJK@ignorespaces}, |
| 4614 |
% 并保存起来供 \tn{CJKhook} 备用。 |
| 4615 |
% \begin{macrocode} |
| 4616 |
\cs_new_protected:Npn \ctex_ignorespaces_case:N #1 |
| 4617 |
{ |
| 4618 |
\cs_set_protected:Npn \ctex_set_ignorespaces: |
| 4619 |
{ \cs_set_eq:NN \CJK@ignorespaces #1 } |
| 4620 |
\ctex_set_ignorespaces: |
| 4621 |
} |
| 4622 |
\cs_new_protected:Npn \ctex_set_ignorespaces: |
| 4623 |
{ \cs_set_eq:NN \CJK@ignorespaces \ctex_auto_ignorespaces: } |
| 4624 |
% \end{macrocode} |
| 4625 |
% \end{macro} |
| 4626 |
% |
| 4627 |
% \begin{macro}[int]{\CJKhook} |
| 4628 |
% \changes{v2.5.5}{2020/10/06}{不再通过旧的钩子命令来定义。} |
| 4629 |
% \env{CJK} 和 \env{CJK*} 环境都会重新定义 \tn{CJK@ignorespaces}。我们在 \pkg{CJK} |
| 4630 |
% 宏包提供的 \tn{CJKhook} 里重新设置它,让这两个环境忽略空格的方式都受 \opt{space} |
| 4631 |
% 选项的控制。这对 \pkg{zhmCJK} 是必要的。 |
| 4632 |
% \begin{macrocode} |
| 4633 |
\tl_if_exist:NF \CJKhook { \tl_new:N \CJKhook } |
| 4634 |
\tl_gput_right:Nn \CJKhook { \ctex_set_ignorespaces: } |
| 4635 |
% \end{macrocode} |
| 4636 |
% \end{macro} |
| 4637 |
% |
| 4638 |
% \begin{macro}[int]{\ctex_punct_set:n} |
| 4639 |
% 设置 CJK 族对应到实际的字体。|#1| 是 \opt{fontset} 的名字。 |
| 4640 |
% \begin{macrocode} |
| 4641 |
\cs_new_protected:Npn \ctex_punct_set:n #1 |
| 4642 |
{ |
| 4643 |
\clist_map_inline:Nn \c_@@_punct_family_clist |
| 4644 |
{ |
| 4645 |
\cs_if_free:cF { c_@@_ #1 ##1 _punct_spaces_tl } |
| 4646 |
{ |
| 4647 |
\cs_set_eq:cc |
| 4648 |
{ CJKpunct@ ##1 @spaces } |
| 4649 |
{ c_@@_ #1 ##1 _punct_spaces_tl } |
| 4650 |
} |
| 4651 |
} |
| 4652 |
} |
| 4653 |
\clist_const:Nn \c_@@_punct_family_clist |
| 4654 |
{ |
| 4655 |
zhsong , zhhei , zhfs , zhkai , zhli , zhyou , |
| 4656 |
zhsongb , zhheil , zhheib , zhyoub , |
| 4657 |
zhyahei , zhyaheib , zhpf , zhpfb |
| 4658 |
} |
| 4659 |
% \end{macrocode} |
| 4660 |
% \end{macro} |
| 4661 |
% |
| 4662 |
% \begin{macro}[int]{\ctex_punct_map_family:nn} |
| 4663 |
% CJK 族 |#1| 使用族 |#2| 的边界信息。 |
| 4664 |
% \begin{macrocode} |
| 4665 |
\cs_new_protected:Npn \ctex_punct_map_family:nn #1#2 |
| 4666 |
{ |
| 4667 |
\cs_if_free:cF { CJKpunct@ #2 @spaces } |
| 4668 |
{ \cs_set_eq:cc { CJKpunct@ #1 @spaces } { CJKpunct@ #2 @spaces } } |
| 4669 |
} |
| 4670 |
% \end{macrocode} |
| 4671 |
% \end{macro} |
| 4672 |
% |
| 4673 |
% \begin{macro}[int]{\ctex_punct_map_bfseries:nn} |
| 4674 |
% CJK 族 |#1| 的 \tn{bfseries} 使用族 |#2| 的边界信息。 |
| 4675 |
% \begin{macrocode} |
| 4676 |
\cs_new_protected:Npn \ctex_punct_map_bfseries:nn #1#2 |
| 4677 |
{ |
| 4678 |
\clist_map_inline:nn {#1} |
| 4679 |
{ |
| 4680 |
\ctex_punct_map_series:nnn { ##1 } { b } {#2} |
| 4681 |
\ctex_punct_map_series:nnn { ##1 } { bx } {#2} |
| 4682 |
} |
| 4683 |
} |
| 4684 |
\cs_new_protected:Npn \ctex_punct_map_series:nnn #1#2#3 |
| 4685 |
{ |
| 4686 |
\CJKpunctmapfamily { C19 } {#1} {#2} { m } {#3} |
| 4687 |
\CJKpunctmapfamily { C19 } {#1} {#2} { it } {#3} |
| 4688 |
\CJKpunctmapfamily { C19 } {#1} {#2} { sl } {#3} |
| 4689 |
\CJKpunctmapfamily { C70 } {#1} {#2} { m } {#3} |
| 4690 |
\CJKpunctmapfamily { C70 } {#1} {#2} { it } {#3} |
| 4691 |
\CJKpunctmapfamily { C70 } {#1} {#2} { sl } {#3} |
| 4692 |
} |
| 4693 |
% \end{macrocode} |
| 4694 |
% \end{macro} |
| 4695 |
% |
| 4696 |
% \begin{macro}[int]{\ctex_punct_map_itshape:nn} |
| 4697 |
% CJK 族 |#1| 的 \tn{itshape} 使用族 |#2| 的边界信息。 |
| 4698 |
% \begin{macrocode} |
| 4699 |
\cs_new_protected:Npn \ctex_punct_map_itshape:nn #1#2 |
| 4700 |
{ |
| 4701 |
\CJKpunctmapfamily { C19 } {#1} { m } { it } {#2} |
| 4702 |
\CJKpunctmapfamily { C19 } {#1} { b } { it } {#2} |
| 4703 |
\CJKpunctmapfamily { C19 } {#1} { bx } { it } {#2} |
| 4704 |
\CJKpunctmapfamily { C70 } {#1} { m } { it } {#2} |
| 4705 |
\CJKpunctmapfamily { C70 } {#1} { b } { it } {#2} |
| 4706 |
\CJKpunctmapfamily { C70 } {#1} { bx } { it } {#2} |
| 4707 |
} |
| 4708 |
% \end{macrocode} |
| 4709 |
% \end{macro} |
| 4710 |
% |
| 4711 |
% \begin{macro}[int]{\ctex_punct_space:nn,\ctexspadef} |
| 4712 |
% 定义标点的边界信息。 |
| 4713 |
% \begin{macrocode} |
| 4714 |
\cs_new_protected:Npn \ctex_punct_space:nn #1#2 |
| 4715 |
{ \tl_const:cn { c_@@_ #1 _punct_spaces_tl } {#2} } |
| 4716 |
\cs_new_eq:NN \ctexspadef \ctex_punct_space:nn |
| 4717 |
% \end{macrocode} |
| 4718 |
% \end{macro} |
| 4719 |
% |
| 4720 |
% 载入边界信息文件。 |
| 4721 |
% \begin{macrocode} |
| 4722 |
\ctex_file_input:n { ctexspa.def } |
| 4723 |
% \end{macrocode} |
| 4724 |
% |
| 4725 |
% \begin{macrocode} |
| 4726 |
%</pdftex> |
| 4727 |
% \end{macrocode} |
| 4728 |
% |
| 4729 |
% \subsubsection{\pkg{ctex-engine-xetex.def}} |
| 4730 |
% |
| 4731 |
% \begin{macrocode} |
| 4732 |
%<*xetex> |
| 4733 |
% \end{macrocode} |
| 4734 |
% |
| 4735 |
% \changes{v2.4.4}{2016/09/12}{不再默认设置 \pkg{xeCJK} 的伪粗体。} |
| 4736 |
% \begin{macrocode} |
| 4737 |
\RequirePackage { xeCJK } |
| 4738 |
\exp_args:Ne \xeCJKsetup |
| 4739 |
{ |
| 4740 |
LoadFandol = false , |
| 4741 |
PunctStyle = \l_@@_punct_tl |
| 4742 |
} |
| 4743 |
% \end{macrocode} |
| 4744 |
% |
| 4745 |
% 最新版本的 \pkg{fontspec} 默认对 \tn{rmfamily} 和 \tn{sffamily} 设置 |
| 4746 |
% |Ligatures=TeX|,对 \tn{ttfamily} 设置 |WordSpace={1,0,0}| 和 |
| 4747 |
% |PunctuationSpace=WordSpace|。 |
| 4748 |
% \begin{macrocode} |
| 4749 |
\@ifpackagelater { fontspec } { 2014/05/25 } { } |
| 4750 |
{ \msg_error:nnn { ctex } { package-too-old } { fontspec } } |
| 4751 |
% \end{macrocode} |
| 4752 |
% |
| 4753 |
% \begin{macrocode} |
| 4754 |
%</xetex> |
| 4755 |
% \end{macrocode} |
| 4756 |
% |
| 4757 |
% \subsubsection{\pkg{ctex-engine-luatex.def}} |
| 4758 |
% |
| 4759 |
% \begin{macrocode} |
| 4760 |
%<*luatex> |
| 4761 |
% \end{macrocode} |
| 4762 |
% |
| 4763 |
% \changes{v2.0}{2014/03/08}{通过 \pkg{LuaTeX-ja} 宏包支持 \LuaLaTeX。} |
| 4764 |
% \changes{v2.3}{2015/09/25}{更新 \pkg{LuaTeX-ja} 支持(20150922.0)。} |
| 4765 |
% \changes{v2.5}{2020/04/18}{更新 \pkg{LuaTeX-ja} 支持(20200412.0)。} |
| 4766 |
% \changes{v2.5.4}{2020/08/16}{更新 \pkg{LuaTeX-ja} 支持(20200808.0)。} |
| 4767 |
% |
| 4768 |
% \pkg{LuaTeX-ja} 为了兼容 p\LaTeX 的使用习惯,对 \LaTeXe 的 \pkg{NFSS} 作了不少 |
| 4769 |
% 修改和扩充,这对于简体中文用户来说不是必要的。我们在这里禁用它。 |
| 4770 |
% \begin{macrocode} |
| 4771 |
\msg_new:nnn { ctex } { luatexja-loaded } |
| 4772 |
{ |
| 4773 |
Package~`luatexja'~can~not~be~loaded~before~`ctex'.\\ |
| 4774 |
Loading~file~`#1'~will~abort! |
| 4775 |
} |
| 4776 |
\@ifpackageloaded { luatexja } |
| 4777 |
{ \msg_critical:nnx { ctex } { luatexja-loaded } { \g_file_curr_name_str } } |
| 4778 |
{ |
| 4779 |
\ctex_at_begin_package:nn { luatexja } |
| 4780 |
{ \msg_redirect_name:nnn { ctexhook } { disable-package } { info } } |
| 4781 |
\ctex_at_end_package:nn { luatexja } |
| 4782 |
{ \msg_redirect_name:nnn { ctexhook } { disable-package } { } } |
| 4783 |
\ctex_disable_package:n { ltj-latex } |
| 4784 |
} |
| 4785 |
% \end{macrocode} |
| 4786 |
% |
| 4787 |
% \begin{macrocode} |
| 4788 |
\RequirePackage { luatexja } |
| 4789 |
\@ifpackagelater { luatexja } { 2020/04/12 } { } |
| 4790 |
{ \msg_error:nnn { ctex } { package-too-old } { luatexja } } |
| 4791 |
% \end{macrocode} |
| 4792 |
% |
| 4793 |
% \begin{macrocode} |
| 4794 |
\RequirePackage { fontspec } |
| 4795 |
\@ifpackagelater { fontspec } { 2020/02/21 } { } |
| 4796 |
{ \msg_error:nnn { ctex } { package-too-old } { fontspec } } |
| 4797 |
% \end{macrocode} |
| 4798 |
% |
| 4799 |
% 引擎文件是通过 \cs{ctex_file_input:n} 载入的,其中的 \tn{catcodetable} 机制会完整恢复 |
| 4800 |
% 文件载入之前的 \tn{catcode} 状态,在引擎文件中的 \tn{catcode} 设置都无效。 |
| 4801 |
% 因此,对 \tn{ltjlineendcomment} 的设置要放到文件之外进行。 |
| 4802 |
% \begin{macrocode} |
| 4803 |
\ctex_at_end:n { \char_set_catcode_comment:n { \ltjlineendcomment } } |
| 4804 |
% \end{macrocode} |
| 4805 |
% |
| 4806 |
% \paragraph{\pkg{LuaTeX-ja} 的默认设置} |
| 4807 |
% |
| 4808 |
% \begin{macrocode} |
| 4809 |
\ExplSyntaxOff |
| 4810 |
% \end{macrocode} |
| 4811 |
% |
| 4812 |
% 以下设置抄录自 \file{lltjdefs.sty},略有改动。 |
| 4813 |
% |
| 4814 |
% \changes{v2.4.11}{2017/08/17}{不把 Enclosed Alphanumerics 设置为 JAchar。} |
| 4815 |
% U+2460--U+24FF (Enclosed Alphanumerics) 原属于字符范围 6,是 JAchar, |
| 4816 |
% 我们把它们归入字符范围 3,改成 ALchar。 |
| 4817 |
% \begin{macrocode} |
| 4818 |
\ltjdefcharrange{1}{"80-"36F, "1E00-"1EFF} |
| 4819 |
\ltjdefcharrange{2}{"370-"4FF, "1F00-"1FFF} |
| 4820 |
\ltjdefcharrange{3}{% |
| 4821 |
"2000-"243F, "2460-"24FF, "2500-"27BF, "2900-"29FF, "2B00-"2BFF} |
| 4822 |
\ltjdefcharrange{4}{% |
| 4823 |
"500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF, |
| 4824 |
"2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A95F, "A980-"ABFF, "E000-"F8FF, |
| 4825 |
"FB00-"FE0F, "FE20-"FE2F, "FE70-"FEFF, "10000-"1AFFF, "1B170-"1F0FF, |
| 4826 |
"1F300-"1FFFF, "2000-"206F} |
| 4827 |
\ltjdefcharrange{5}{"D800-"DFFF, "E0000-"E00FF, "E01F0-"10FFFF} |
| 4828 |
\ltjdefcharrange{6}{% |
| 4829 |
"2E80-"2EFF, "3000-"30FF, "3190-"319F, "31F0-"4DBF, |
| 4830 |
"4E00-"9FFF, "F900-"FAFF, "FE10-"FE1F, "FE30-"FE6F, "FF00-"FFEF, |
| 4831 |
"1B000-"1B16F, "1F100-"1F2FF, "20000-"3FFFF, "E0100-"E01EF} |
| 4832 |
\ltjdefcharrange{7}{% |
| 4833 |
"1100-"11FF, "2F00-"2FFF, "3100-"318F, "31A0-"31EF, "A000-"A4CF, |
| 4834 |
"A960-"A97F, "AC00-"D7FF} |
| 4835 |
\ltjdefcharrange{8}{"A7, "A8, "B0, "B1, "B4, "B6, "D7, "F7} |
| 4836 |
% \end{macrocode} |
| 4837 |
% 将间隔号、引号、破折号等中西文公用的标点符号归入字符范围 9,将他们设置为 JAchar。 |
| 4838 |
% \begin{macrocode} |
| 4839 |
\ltjdefcharrange{9}{% |
| 4840 |
"00B7, "2018, "2019, "201C, "201D, "2013, "2014, "2025, "2026, "2027, "2E3A} |
| 4841 |
% \end{macrocode} |
| 4842 |
% \changes{v2.4.11}{2017/08/17}{不把希腊和西里尔字母设置为 JAchar。} |
| 4843 |
% \pkg{LuaTeX-ja} 默认把字符范围 2 和 3 设置为 JAchar,我们这里把它们都改成 ALchar。 |
| 4844 |
% \begin{macrocode} |
| 4845 |
\ltjsetparameter{jacharrange={-1, -2, -3, -4, -5, +6, +7, -8, +9}} |
| 4846 |
\directlua{for x=128,255 do luatexja.math.is_math_letters[x] = true end} |
| 4847 |
% \end{macrocode} |
| 4848 |
% |
| 4849 |
% 以下设置抄录自 2020/08/08 之前的 \file{ltj-latex.sty}。 |
| 4850 |
% 自 2020/08/08 开始,\pkg{LuaTeX-ja} 引入新的缓存机制,此段设置被整合进 \file{luatexja.lua}。 |
| 4851 |
% \begin{macrocode} |
| 4852 |
\@ifpackagelater{luatexja}{2020/08/08} |
| 4853 |
{ \ltjsetparameter { autospacing, autoxspacing, differentjfm = paverage } } |
| 4854 |
{ |
| 4855 |
\directlua{ |
| 4856 |
local s = kpse.find_file('ltj-kinsoku.lua', 'tex') |
| 4857 |
luatexja.stack.charprop_stack_table[0] = s and dofile(s) or {} |
| 4858 |
} |
| 4859 |
\ltjsetparameter{kanjiskip=\z@ plus .4pt minus .5pt, |
| 4860 |
xkanjiskip=.25\zw plus 1pt minus 1pt, |
| 4861 |
autospacing, autoxspacing, jacharrange={-1}, |
| 4862 |
yalbaselineshift=\z@, yjabaselineshift=\z@, |
| 4863 |
jcharwidowpenalty=500, differentjfm=paverage |
| 4864 |
} |
| 4865 |
} |
| 4866 |
% \end{macrocode} |
| 4867 |
% |
| 4868 |
% \begin{macrocode} |
| 4869 |
\ExplSyntaxOn |
| 4870 |
% \end{macrocode} |
| 4871 |
% |
| 4872 |
% \paragraph{\pkg{LuaTeX-ja} 的补丁} |
| 4873 |
% |
| 4874 |
% \begin{macrocode} |
| 4875 |
%<@@=ctex_ltj> |
| 4876 |
% \end{macrocode} |
| 4877 |
% |
| 4878 |
% \changes{v2.5.3}{2020/05/31}{不再依赖 \pkg{xunicode},单独补丁 \file{tuenc.def}。} |
| 4879 |
% |
| 4880 |
% \begin{macro}{\CTEX@alchar, \CTEX@beginallalchar, \CTEX@endallalchar} |
| 4881 |
% 分组中的字符都是 ALchar 类。 |
| 4882 |
% \begin{macrocode} |
| 4883 |
\cs_new_protected:Npn \CTEX@alchar #1 |
| 4884 |
{ \CTEX@beginallalchar #1 \CTEX@endallalchar } |
| 4885 |
\cs_new_protected:Npn \CTEX@beginallalchar |
| 4886 |
{ |
| 4887 |
\group_begin: |
| 4888 |
\ctex_ltj_zero_globaldefs: |
| 4889 |
\ltj@allalchar |
| 4890 |
} |
| 4891 |
\cs_new_protected:Npn \CTEX@endallalchar |
| 4892 |
{ \group_end: } |
| 4893 |
% \end{macrocode} |
| 4894 |
% \end{macro} |
| 4895 |
% |
| 4896 |
% \begin{macro}{\CTEX@chardef@text@cmd} |
| 4897 |
% 补丁 \tn{chardef@text@cmd},应用于 \tn{DeclareTextSymbol},使其定义的符号都是 ALchar。 |
| 4898 |
% \begin{macrocode} |
| 4899 |
\cs_new_protected:Npn \CTEX@chardef@text@cmd #1 |
| 4900 |
{ |
| 4901 |
\cs_set_eq:NN \@ifdefinable \@@@@ifdefinable |
| 4902 |
\tl_set:Nn \l_@@_cmd_tl {#1} |
| 4903 |
\tex_afterassignment:D \@@_chardef_text_cmd: |
| 4904 |
\tex_chardef:D #1 |
| 4905 |
} |
| 4906 |
\tl_new:N \l_@@_cmd_tl |
| 4907 |
\cs_new_protected:Npn \@@_chardef_text_cmd: |
| 4908 |
{ \exp_after:wN \@@_chardef_text_cmd_aux:N \l_@@_cmd_tl } |
| 4909 |
\cs_new_protected:Npn \@@_chardef_text_cmd_aux:N #1 |
| 4910 |
{ |
| 4911 |
\int_compare:nNnF {#1} < { "80 } |
| 4912 |
{ \cs_set_protected:Npx #1 { \CTEX@alchar { \tex_Uchar:D #1 } } } |
| 4913 |
} |
| 4914 |
% \end{macrocode} |
| 4915 |
% \end{macro} |
| 4916 |
% |
| 4917 |
% \begin{macro}{\CTEX@text@composite@x} |
| 4918 |
% \tn{@text@composite@x} 的重定义,应用于 \tn{DeclareUnicodeComposite} 等。 |
| 4919 |
% \begin{macrocode} |
| 4920 |
\cs_new_protected:Npn \CTEX@text@composite@x #1#2 |
| 4921 |
{ |
| 4922 |
\CTEX@beginallalchar |
| 4923 |
\cs_if_exist_use:NF #1 {#2} |
| 4924 |
\CTEX@endallalchar |
| 4925 |
} |
| 4926 |
% \end{macrocode} |
| 4927 |
% \end{macro} |
| 4928 |
% |
| 4929 |
% \begin{macro}{\CTEX@add@unicode@accent} |
| 4930 |
% \tn{add@unicode@accent} 的重定义,应用于 \tn{DeclareUnicodeAccent}。 |
| 4931 |
% \begin{macrocode} |
| 4932 |
\cs_new_protected:Npx \CTEX@add@unicode@accent #1#2 |
| 4933 |
{ |
| 4934 |
\CTEX@beginallalchar |
| 4935 |
\exp_not:N \tl_if_blank:nTF {#2} { \tex_Uchar:D "A0 ~ } {#2} |
| 4936 |
\exp_not:N \tex_Uchar:D \tex_numexpr:D #1 \scan_stop: |
| 4937 |
\CTEX@endallalchar |
| 4938 |
} |
| 4939 |
% \end{macrocode} |
| 4940 |
% \end{macro} |
| 4941 |
% |
| 4942 |
% \begin{macro}{\CTEX@patch@text@cmd} |
| 4943 |
% 单独补丁由 \tn{DeclareTextCommand} 定义的命令。 |
| 4944 |
% \begin{macrocode} |
| 4945 |
\cs_new_protected:Npn \CTEX@patch@text@cmd #1 |
| 4946 |
{ |
| 4947 |
\exp_args:NNc \@@_patch_text_cmd:NN #1 |
| 4948 |
{ \UnicodeEncodingName \token_to_str:N #1 } |
| 4949 |
} |
| 4950 |
\cs_new_protected:Npn \@@_patch_text_cmd:NN #1#2 |
| 4951 |
{ |
| 4952 |
\cs_set_eq:NN \CTEX@textcmd #2 |
| 4953 |
\ctex_preto_cmd:NnnTF \CTEX@textcmd |
| 4954 |
{ \ExplSyntaxOff \makeatletter } |
| 4955 |
{ \CTEX@beginallalchar } |
| 4956 |
{ |
| 4957 |
\ctex_appto_cmd:NnnTF \CTEX@textcmd |
| 4958 |
{ \ExplSyntaxOff \makeatletter } |
| 4959 |
{ \CTEX@endallalchar } |
| 4960 |
{ \cs_set_eq:NN #2 \CTEX@textcmd } |
| 4961 |
{ \ctex_patch_failure:N #1 } |
| 4962 |
} |
| 4963 |
{ \ctex_patch_failure:N #1 } |
| 4964 |
} |
| 4965 |
% \end{macrocode} |
| 4966 |
% \end{macro} |
| 4967 |
% |
| 4968 |
% \begin{macro}{\CTEX@patch@tunec} |
| 4969 |
% 重新载入 \tn{tunec.def},使补丁生效。 |
| 4970 |
% \begin{macrocode} |
| 4971 |
\cs_new_protected:Npn \CTEX@patch@tunec |
| 4972 |
{ |
| 4973 |
\cs_set_eq:NN \chardef@text@cmd \CTEX@chardef@text@cmd |
| 4974 |
\ctex_file_input:n { tuenc.def } |
| 4975 |
\cs_set_eq:NN \@text@composite@x \CTEX@text@composite@x |
| 4976 |
\cs_set_eq:NN \add@unicode@accent \CTEX@add@unicode@accent |
| 4977 |
\CTEX@patch@text@cmd \textasteriskcentered |
| 4978 |
} |
| 4979 |
\@ifpackageloaded { xunicode } |
| 4980 |
{ } |
| 4981 |
{ \CTEX@patch@tunec } |
| 4982 |
% \end{macrocode} |
| 4983 |
% \end{macro} |
| 4984 |
% |
| 4985 |
% \changes{v2.3}{2015/09/26}{更新 \pkg{unicode-math} 宏包补丁。} |
| 4986 |
% |
| 4987 |
% 在 \LaTeX{} 下,\pkg{LuaTeX-ja} 对 \pkg{fontspec}、\pkg{xunicode}、\pkg{unicode-math} |
| 4988 |
% 和 \pkg{listings} 打了补丁。其中前三个是把 \tn{char} 换成 \tn{ltjalchar},确保 |
| 4989 |
% 字符是 ALchar 类。我们这里用 \pkg{xunicode-addon} 来处理 \pkg{xunicode}。 |
| 4990 |
% \begin{macrocode} |
| 4991 |
\ctex_at_end_package:nn { xunicode } |
| 4992 |
{ |
| 4993 |
\RequirePackage { xunicode-addon } |
| 4994 |
\AtBeginUTFCommand { \CTEX@beginallalchar } |
| 4995 |
\AtEndUTFCommand { \CTEX@endallalchar } |
| 4996 |
} |
| 4997 |
% \end{macrocode} |
| 4998 |
% |
| 4999 |
% \changes{v2.4.2}{2016/05/15}{恢复 \pkg{luatexja} 对 \tn{emshape} 和 |
| 5000 |
% \tn{eminnershape} 的重定义。} |
| 5001 |
% \changes{v2.4.3}{2016/08/26}{简化 \pkg{fontspec} 补丁。} |
| 5002 |
% \changes{v2.5}{2020/04/18}{删除 \pkg{fontspec} 补丁。} |
| 5003 |
% |
| 5004 |
% 对 \pkg{listings} 的补丁是让代码环境支持 JAchar 类。 |
| 5005 |
% \begin{macrocode} |
| 5006 |
\ctex_at_end_package:nn { listings } |
| 5007 |
{ \RequirePackage { lltjp-listings } } |
| 5008 |
% \end{macrocode} |
| 5009 |
% |
| 5010 |
% \paragraph{\pkg{Lua} 函数} |
| 5011 |
% |
| 5012 |
% \changes{v2.5.8}{2021/11/29}{简化部分 \pkg{Lua} 函数。} |
| 5013 |
% |
| 5014 |
% 直接用 |token.set_lua| 定义,不是传统意义上的 \TeX \ 宏。 |
| 5015 |
% \begin{macrocode} |
| 5016 |
\group_begin: |
| 5017 |
\char_set_catcode_space:n { 32 } |
| 5018 |
\lua_now:e |
| 5019 |
{ |
| 5020 |
% \end{macrocode} |
| 5021 |
% \begin{macro}{ctex.newluacmd} |
| 5022 |
% 定义新的 \pkg{Lua} 函数。 |
| 5023 |
% \begin{macrocode} |
| 5024 |
ctex = ctex or { } |
| 5025 |
local ctex = ctex |
| 5026 |
local functions = lua.get_functions_table() |
| 5027 |
local new_luafunction = luatexbase.new_luafunction |
| 5028 |
local create, set_lua = token.create, token.set_lua |
| 5029 |
local lua_cmds = { |
| 5030 |
lua_call = true , |
| 5031 |
lua_expandable_call = true , |
| 5032 |
} |
| 5033 |
local newluacmd = function (name, func, ...) |
| 5034 |
local tok = create(name) |
| 5035 |
local id = lua_cmds[tok.cmdname] and tok.index |
| 5036 |
local id = id or new_luafunction(name) |
| 5037 |
set_lua(name, id, ...) |
| 5038 |
functions[id] = func |
| 5039 |
end |
| 5040 |
ctex.newluacmd = newluacmd |
| 5041 |
% \end{macrocode} |
| 5042 |
% \end{macro} |
| 5043 |
% \begin{macrocode} |
| 5044 |
local ltjfont = luatexja.jfont |
| 5045 |
local getattribute = tex.getattribute |
| 5046 |
local tex_set, sprint = tex.set, tex.sprint |
| 5047 |
local scan_int, scan_arg = token.scan_int, token.scan_argument |
| 5048 |
% \end{macrocode} |
| 5049 |
% \begin{macro}{\ctex_ltj_add_kyenc:n} |
| 5050 |
% 保存 jfont 的编码,用于判断。 |
| 5051 |
% \begin{macrocode} |
| 5052 |
newluacmd("ctex_ltj_add_kyenc:n", ltjfont.add_kyenc_list, "global", "protected") |
| 5053 |
% \end{macrocode} |
| 5054 |
% \end{macro} |
| 5055 |
% \begin{macro}{\ctex_ltj_is_kenc:n} |
| 5056 |
% 判断编码是否属于 jfont。 |
| 5057 |
% \begin{macrocode} |
| 5058 |
newluacmd("ctex_ltj_is_kenc:n", ltjfont.is_kenc, "global") |
| 5059 |
% \end{macrocode} |
| 5060 |
% \end{macro} |
| 5061 |
% \begin{macro}{\ctex_ltj_patch_external_font:n} |
| 5062 |
% 若对字体的定义完全相同,则它们有相同的 \texttt{font.id}。因此如果字形是由 |
| 5063 |
% \textsf{NFSS} 的替换机制定义的,它们就有相同的 \texttt{font.id}。 |
| 5064 |
% |print_aftl_address| 函数的定义是 |
| 5065 |
% \begin{verbatim} |
| 5066 |
% function luatexja.jfont.print_aftl_address() |
| 5067 |
% return ';ltjaltfont' .. tostring(aftl_base):sub(8) |
| 5068 |
% end |
| 5069 |
% \end{verbatim} |
| 5070 |
% 主要目的是,如果当前字形有替代字体,则往字形的定义中加入一些标志,确保 |
| 5071 |
% \texttt{font.id} 唯一。 |
| 5072 |
% \begin{macrocode} |
| 5073 |
newluacmd("ctex_ltj_patch_external_font:n", function () |
| 5074 |
local s = scan_arg() |
| 5075 |
local is_braced, is_quoted |
| 5076 |
if s:sub(1,1) == '{' and s:sub(-1)=='}' then |
| 5077 |
is_braced = true; s = s:sub(2,-2) |
| 5078 |
end |
| 5079 |
if s:sub(1,1) == '"' and s:sub(-1) == '"' then |
| 5080 |
is_quoted = true; s = s:sub(2,-2) |
| 5081 |
end |
| 5082 |
s = s .. ltjfont.print_aftl_address() |
| 5083 |
if is_braced then s = '{'..s..'}' |
| 5084 |
elseif is_quoted then s = '"'..s..'"' |
| 5085 |
end |
| 5086 |
sprint(-2, s) |
| 5087 |
end, "global") |
| 5088 |
% \end{macrocode} |
| 5089 |
% \end{macro} |
| 5090 |
% \begin{macro}{\ctex_ltj_set_alt_font:nnnn} |
| 5091 |
% |#1| 和 |#2| 分别是字符区间的首末,|#3| 是基础字体,|#4| 是替代字体。 |
| 5092 |
% \begin{macrocode} |
| 5093 |
newluacmd("ctex_ltj_set_alt_font:nnnn", function () |
| 5094 |
local b = tonumber(scan_arg()) |
| 5095 |
local e = tonumber(scan_arg()) |
| 5096 |
local alt = scan_arg() |
| 5097 |
local base = scan_arg() |
| 5098 |
ltjfont.set_alt_font_latex(b, e, alt, base) |
| 5099 |
end, "global", "protected") |
| 5100 |
% \end{macrocode} |
| 5101 |
% \end{macro} |
| 5102 |
% \begin{macro}{\ctex_ltj_clear_alt_font:n} |
| 5103 |
% 清除 |#1| 的替代字体。 |
| 5104 |
% \begin{macrocode} |
| 5105 |
newluacmd("ctex_ltj_clear_alt_font:n", function () |
| 5106 |
local base = scan_arg() |
| 5107 |
ltjfont.clear_alt_font_latex(base) |
| 5108 |
end, "global", "protected") |
| 5109 |
% \end{macrocode} |
| 5110 |
% \end{macro} |
| 5111 |
% \begin{macro}{\ctex_ltj_pickup_alt_font:nn} |
| 5112 |
% 定义 |#1| 的替代字体,|#2| 是字体大小。\\ |
| 5113 |
% 会在内部执行 \tn{ltj@pickup@altfont@auxy} 和 \tn{ltj@pickup@altfont@copy}。 |
| 5114 |
% \begin{macrocode} |
| 5115 |
newluacmd("ctex_ltj_pickup_alt_font:nn", function () |
| 5116 |
local base = scan_arg() |
| 5117 |
local size = scan_arg() |
| 5118 |
ltjfont.output_alt_font_cmd("y", base) |
| 5119 |
ltjfont.pickup_alt_font_a(size) |
| 5120 |
end, "global", "protected") |
| 5121 |
% \end{macrocode} |
| 5122 |
% \end{macro} |
| 5123 |
% \begin{macro}{\@@_pickup_alt_font:Nn} |
| 5124 |
% |#1| 是 \texttt{font.id},|#2| 是字体名称。 |
| 5125 |
% 在 \tn{ltj@pickup@altfont@copy} 之中使用。 |
| 5126 |
% \begin{macrocode} |
| 5127 |
newluacmd("@@_pickup_alt_font:Nn", function () |
| 5128 |
local num = scan_int() |
| 5129 |
local base = scan_arg() |
| 5130 |
ltjfont.pickup_alt_font_b(num, base) |
| 5131 |
end, "global", "protected") |
| 5132 |
% \end{macrocode} |
| 5133 |
% \end{macro} |
| 5134 |
% \begin{macro}{\@@_if_alt_set:nT} |
| 5135 |
% 判断是否存在替代字体。会设置变量 |aftl_base| 和返回 \tn{@firstofone} 或 \tn{@gobble}。 |
| 5136 |
% \begin{macrocode} |
| 5137 |
newluacmd("@@_if_alt_set:nT", ltjfont.does_alt_set, "global") |
| 5138 |
% \end{macrocode} |
| 5139 |
% \end{macro} |
| 5140 |
% \begin{macro}{\ctex_ltj_zero_globaldefs:} |
| 5141 |
% 设置 \tn{globaldefs} 为 $0$,避免全局设置,应当在分组中使用。 |
| 5142 |
% 这里通过 Lua 设置,可以不受外部 \TeX\ 环境中的 \tn{globaldefs} 的影响。 |
| 5143 |
% \begin{macrocode} |
| 5144 |
newluacmd("ctex_ltj_zero_globaldefs:", function () |
| 5145 |
tex_set("globaldefs", 0) |
| 5146 |
end, "global", "protected") |
| 5147 |
} |
| 5148 |
\group_end: |
| 5149 |
% \end{macrocode} |
| 5150 |
% \end{macro} |
| 5151 |
% |
| 5152 |
% \paragraph{字体切换方式} |
| 5153 |
% |
| 5154 |
% \begin{macro}[int]{\ctex_ltj_select_font:,\CJK@family} |
| 5155 |
% \tn{CJK@family} 保存的是当前 CJK 实际的字体族名,如果为空表示没有设置过字体。 |
| 5156 |
% \begin{macrocode} |
| 5157 |
\cs_new_protected:Npn \ctex_ltj_select_font: |
| 5158 |
{ |
| 5159 |
\group_begin: \exp_args:NNc \group_end: |
| 5160 |
\cs_if_exist_use:NF { \l_@@_current_font_tl } |
| 5161 |
{ \tl_if_empty:NF \CJK@family { \@@_select_font_aux: } } |
| 5162 |
} |
| 5163 |
\tl_new:N \CJK@family |
| 5164 |
\tl_new:N \l_@@_current_font_tl |
| 5165 |
\tl_set:Nn \l_@@_current_font_tl |
| 5166 |
{ \CJK@encoding / \CJK@family / \f@series / \f@shape / \f@size } |
| 5167 |
% \end{macrocode} |
| 5168 |
% \end{macro} |
| 5169 |
% |
| 5170 |
% \changes{v2.5.8}{2021/11/18}{兼容 \pkg{microtype}。} |
| 5171 |
% |
| 5172 |
% \begin{macro}{\@@_select_font_aux:} |
| 5173 |
% 使用 \tn{pickup@font} 取得字体名称前,总需要先设置 \tn{font@name}。在这里将 |
| 5174 |
% \tn{f@family} 换成 CJK 字体族,并确保编码正确。 |
| 5175 |
% \begin{macrocode} |
| 5176 |
\cs_new_protected:Npn \@@_select_font_aux: |
| 5177 |
{ |
| 5178 |
\group_begin: |
| 5179 |
\tl_set_eq:NN \f@encoding \CJK@encoding |
| 5180 |
\tl_set_eq:NN \f@family \CJK@family |
| 5181 |
\cs_set_eq:NN \pickup@font \ctex_ltj_pickup_font: |
| 5182 |
\@@_push_fontname:n { \curr@fontshape / \f@size } |
| 5183 |
\ctex_ltj_pickup_font: |
| 5184 |
\group_end: |
| 5185 |
\font@name |
| 5186 |
\@@_pop_fontname: |
| 5187 |
% \end{macrocode} |
| 5188 |
% 当字形未定义的时候,\textsf{NFSS} 就会启动替换机制(\tn{wrong@fontshape})。 |
| 5189 |
% 第一次启动后,\cs{l_@@_current_font_tl} 还是没有定义。为此,我们再次选择字体, |
| 5190 |
% 确保它有定义和指向正确的 \texttt{font.id}。这对 \opt{AlternateFont} 的设置 |
| 5191 |
% 特别重要。 |
| 5192 |
% \begin{macrocode} |
| 5193 |
\cs_if_exist:cF { \l_@@_current_font_tl } |
| 5194 |
{ \@@_select_font_aux: } |
| 5195 |
} |
| 5196 |
\cs_new_protected:Npn \@@_push_fontname:n #1 |
| 5197 |
{ |
| 5198 |
\seq_gpush:No \g_@@_fontname_seq { \font@name } |
| 5199 |
\tl_gset:Nx \font@name { \exp_not:c {#1} } |
| 5200 |
} |
| 5201 |
\cs_new_protected:Npn \@@_pop_fontname: |
| 5202 |
{ |
| 5203 |
\seq_gpop:NNT \g_@@_fontname_seq \l_@@_tmp_tl |
| 5204 |
{ \tl_gset_eq:NN \font@name \l_@@_tmp_tl } |
| 5205 |
} |
| 5206 |
\seq_new:N \g_@@_fontname_seq |
| 5207 |
% \end{macrocode} |
| 5208 |
% \end{macro} |
| 5209 |
% |
| 5210 |
% \begin{macro}[int]{\ctex_ltj_pickup_font:} |
| 5211 |
% 替换 \tn{define@newfont} 内部调用的 \tn{extract@font} 和 \tn{do@subst@correction}。 |
| 5212 |
% \begin{macrocode} |
| 5213 |
\cs_new_protected:Npn \ctex_ltj_pickup_font: |
| 5214 |
{ |
| 5215 |
\exp_after:wN \cs_if_exist:NF \font@name |
| 5216 |
{ |
| 5217 |
\group_begin: |
| 5218 |
\cs_set_eq:NN \extract@font \ctex_ltj_extract_font: |
| 5219 |
\cs_set_eq:NN \do@subst@correction \ctex_ltj_subst_font: |
| 5220 |
\define@newfont |
| 5221 |
\group_end: |
| 5222 |
} |
| 5223 |
} |
| 5224 |
\cs_new_eq:NN \pickup@jfont \ctex_ltj_pickup_font: |
| 5225 |
% \end{macrocode} |
| 5226 |
% \end{macro} |
| 5227 |
% |
| 5228 |
% \begin{macro}[int]{\ctex_ltj_extract_font:} |
| 5229 |
% \pkg{LuaTeX-ja} 的 \tn{globaljfont} 在 \pkg{luatexja-core} 中定义: |
| 5230 |
% \begin{verbatim} |
| 5231 |
% %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont |
| 5232 |
% \protected\def\jfont#1{% |
| 5233 |
% \afterassignment\ltj@@jfont |
| 5234 |
% \directlua{luatexja.jfont.jfontdefX |
| 5235 |
% (false, 'yoko','\luatexluaescapestring{\noexpand#1}')}} |
| 5236 |
% \protected\def\globaljfont#1{% |
| 5237 |
% \afterassignment\ltj@@jfont |
| 5238 |
% \directlua{luatexja.jfont.jfontdefX |
| 5239 |
% (true, 'yoko','\luatexluaescapestring{\noexpand#1}')}} |
| 5240 |
% \newluafunction\ltj@@jfont@inner |
| 5241 |
% \directlua{ |
| 5242 |
% local t = lua.get_functions_table() |
| 5243 |
% t[\the\ltj@@jfont@inner] = luatexja.jfont.jfontdefY |
| 5244 |
% } |
| 5245 |
% \def\ltj@@jfont{\luafunction\ltj@@jfont@inner} |
| 5246 |
% \end{verbatim} |
| 5247 |
% \texttt{jfontdefX} 函数的作用是把 \tn{CS} 定义为其后的字体,\texttt{jfontdefY} |
| 5248 |
% 的作用是更新 \texttt{JFM} 和记录相关字体信息。最后的工作是: |
| 5249 |
% \begin{verbatim} |
| 5250 |
% tex.sprint(cat_lp, global_flag, '\\protected\\expandafter\\def\\csname ', |
| 5251 |
% (cstemp==' ') and '\\space' or cstemp, '\\endcsname{\\ltj@cur'.. |
| 5252 |
% (jfm_dir == 'yoko' and 'j' or 't') .. 'fnt', fn, '\\relax}') |
| 5253 |
% \end{verbatim} |
| 5254 |
% \tn{CS} 的作用就是把 \tn{ltj@curjfnt} 设置为刚才定义的字体的 \texttt{font.id}。 |
| 5255 |
% \begin{macrocode} |
| 5256 |
\cs_new_protected_nopar:Npn \ctex_ltj_extract_font: |
| 5257 |
{ |
| 5258 |
\get@external@font |
| 5259 |
\ctex_ltj_if_alternate_shape_exist:nT { \curr@fontshape } |
| 5260 |
{ |
| 5261 |
\tl_set:Nx \external@font |
| 5262 |
{ \exp_after:wN \@@_patch_external_font:w \external@font } |
| 5263 |
} |
| 5264 |
\exp_after:wN \globaljfont \font@name \external@font \scan_stop: |
| 5265 |
% \end{macrocode} |
| 5266 |
% 这里 \tn{font@name} 不会直接改变当前字体,而 \tn{DeclareFontFamily} 和 |
| 5267 |
% \tn{DeclareFontShape} 的最后一个参数通常要使用 \tn{font} 来引用当前字体。 |
| 5268 |
% 为此,我们在分组内启用之前定义的字体,以便能得到正确的 \tn{font}。对字体参数的 |
| 5269 |
% 赋值总是全局的,不会受到分组的影响。 |
| 5270 |
% \begin{macrocode} |
| 5271 |
\font@name |
| 5272 |
\ctex_ltj_use_jfont: |
| 5273 |
\use:c { \f@encoding + \f@family } |
| 5274 |
\use:c { \curr@fontshape } |
| 5275 |
} |
| 5276 |
% \end{macrocode} |
| 5277 |
% \end{macro} |
| 5278 |
% |
| 5279 |
% \begin{macro}{\ctex_ltj_use_jfont:} |
| 5280 |
% 使用 jfont,确保当前的 \tn{font} 是 jfont。 |
| 5281 |
% \begin{macrocode} |
| 5282 |
\cs_new_protected_nopar:Npn \ctex_ltj_use_jfont: |
| 5283 |
{ \tex_setfontid:D \ltj@curjfnt } |
| 5284 |
% \end{macrocode} |
| 5285 |
% \end{macro} |
| 5286 |
% |
| 5287 |
% \begin{macro}[int]{\ctex_ltj_subst_font:} |
| 5288 |
% \tn{do@subst@correction} 在设置通过 \texttt{sub} 或者 \texttt{ssub} 函数定义的 |
| 5289 |
% 字体时会用到。如果没有设置 \opt{SlantedFont},\pkg{fontspec} 会设置 |
| 5290 |
% \tn{itdefault} 作为 \tn{sldefault} 的替代字形,因而会用到这个函数。它的本来定义是: |
| 5291 |
% \begin{verbatim} |
| 5292 |
% \def\do@subst@correction{% |
| 5293 |
% \xdef\subst@correction{% |
| 5294 |
% \font@name |
| 5295 |
% \global\expandafter\font |
| 5296 |
% \csname \curr@fontshape/\f@size\endcsname |
| 5297 |
% \noexpand\fontname\font |
| 5298 |
% \relax}% |
| 5299 |
% \aftergroup\subst@correction |
| 5300 |
% } |
| 5301 |
% \end{verbatim} |
| 5302 |
% 我们在这里不需要定义新字体,而是设置对应字体的命令。 |
| 5303 |
% \begin{macrocode} |
| 5304 |
\cs_new_protected_nopar:Npn \ctex_ltj_subst_font: |
| 5305 |
{ |
| 5306 |
\ctex_ltj_if_alternate_shape_exist:nF { \curr@fontshape } |
| 5307 |
{ |
| 5308 |
\group_begin: |
| 5309 |
\tl_set_eq:NN \CJK@family \f@family |
| 5310 |
\cs_if_exist:cF { \l_@@_current_font_tl } |
| 5311 |
{ |
| 5312 |
\cs_gset_protected_nopar:Npx \subst@correction |
| 5313 |
{ |
| 5314 |
\cs_new_eq:NN |
| 5315 |
\exp_not:c { \l_@@_current_font_tl } |
| 5316 |
\font@name |
| 5317 |
} |
| 5318 |
\group_insert_after:N \group_insert_after:N |
| 5319 |
\group_insert_after:N \subst@correction |
| 5320 |
} |
| 5321 |
\group_end: |
| 5322 |
} |
| 5323 |
} |
| 5324 |
% \end{macrocode} |
| 5325 |
% \end{macro} |
| 5326 |
% |
| 5327 |
% \begin{macro}[int,TF]{\ctex_ltj_if_alternate_shape_exist:n} |
| 5328 |
% 即 \pkg{LuaTeX-ja} 中的 \tn{ltj@@does@alt@set},判断是否存在替代字体。 |
| 5329 |
% \begin{macrocode} |
| 5330 |
\prg_new_conditional:Npnn \ctex_ltj_if_alternate_shape_exist:n #1 { T , F , TF } |
| 5331 |
{ |
| 5332 |
\@@_if_alt_set:nT {#1} { \prg_return_true: \use_none:n } |
| 5333 |
\prg_return_false: |
| 5334 |
} |
| 5335 |
% \end{macrocode} |
| 5336 |
% \end{macro} |
| 5337 |
% |
| 5338 |
% \begin{macro}{\@@_patch_external_font:w} |
| 5339 |
% \begin{macrocode} |
| 5340 |
\cs_new:Npn \@@_patch_external_font:w #1 ~ at |
| 5341 |
{ \ctex_ltj_patch_external_font:n {#1} ~ at } |
| 5342 |
% \end{macrocode} |
| 5343 |
% \end{macro} |
| 5344 |
% |
| 5345 |
% \begin{macro}[int]{\ctex_ltj_select_alternate_font:} |
| 5346 |
% 在 \tn{selectfont} 中更新替代字体。 |
| 5347 |
% \begin{macrocode} |
| 5348 |
\cs_new_protected:Npn \ctex_ltj_select_alternate_font: |
| 5349 |
{ |
| 5350 |
\ctex_ltj_if_alternate_shape_exist:nT { \l_@@_current_shape_tl } |
| 5351 |
{ |
| 5352 |
\ctex_ltj_pickup_alt_font:nn |
| 5353 |
{ \l_@@_current_shape_tl } { \f@size } |
| 5354 |
} |
| 5355 |
} |
| 5356 |
\tl_new:N \l_@@_current_shape_tl |
| 5357 |
\tl_set:Nn \l_@@_current_shape_tl |
| 5358 |
{ \CJK@encoding / \CJK@family / \f@series / \f@shape } |
| 5359 |
% \end{macrocode} |
| 5360 |
% \end{macro} |
| 5361 |
% |
| 5362 |
% \begin{macro}[int]{\ltj@pickup@altfont@auxy} |
| 5363 |
% 被用在函数 |output_alt_font_cmd| 中,作用是定义替代字体。 |
| 5364 |
% \begin{macrocode} |
| 5365 |
\cs_new_protected:Npn \ltj@pickup@altfont@auxy #1 |
| 5366 |
{ |
| 5367 |
\cs_if_exist:cF { #1/\f@size } |
| 5368 |
{ |
| 5369 |
\group_begin: |
| 5370 |
\use:e { \exp_not:N \split@name #1 / \f@size } \@nil |
| 5371 |
\@@_push_fontname:n { \curr@fontshape / \f@size } |
| 5372 |
\ctex_ltj_pickup_font: |
| 5373 |
\group_end: |
| 5374 |
\@@_pop_fontname: |
| 5375 |
} |
| 5376 |
} |
| 5377 |
% \end{macrocode} |
| 5378 |
% \end{macro} |
| 5379 |
% |
| 5380 |
% \begin{macro}[int]{\ltj@pickup@altfont@copy} |
| 5381 |
% 被用在函数 |pickup_alt_font_a| 中。\tn{ltj@@getjfontnumber} 的作用是将字体命令 |
| 5382 |
% |#1| 对应的 \texttt{font.id} 保存到 \tn{ltj@tempcntc} 中。 |
| 5383 |
% \begin{macrocode} |
| 5384 |
\cs_new_protected:Npn \ltj@pickup@altfont@copy #1#2 |
| 5385 |
{ |
| 5386 |
\ltj@@@@getjfontnumber #1 |
| 5387 |
\@@_pickup_alt_font:Nn \ltj@tempcntc {#2} |
| 5388 |
} |
| 5389 |
% \end{macrocode} |
| 5390 |
% \end{macro} |
| 5391 |
% |
| 5392 |
% \paragraph{数学字体族} |
| 5393 |
% |
| 5394 |
% 以下内容来自 \file{lltjfont.sty},目的是让汉字可以在数学环境中直接使用。 |
| 5395 |
% |
| 5396 |
% \begin{macro}[int]{\ctex_ltj_if_jfont:nTF} |
| 5397 |
% 参数 |#1| 是一个 \LaTeXe{} 编码名称或者字体命令。\LaTeXe{} 字体命令的一般形式是: |
| 5398 |
% \begin{quote}\ttfamily\small |
| 5399 |
% \textbackslash\meta{encoding}/\meta{family}/\meta{series}/\meta{shape} |
| 5400 |
% \end{quote} |
| 5401 |
% 通过截取名字中的 \meta{encoding} 来判断是否是 jfont。 |
| 5402 |
% 最后会设置 \tn{ifin@} 为对应的 \tn{iftrue} 或者 \tn{iffalse}。 |
| 5403 |
% \begin{macrocode} |
| 5404 |
\cs_new:Npn \ctex_ltj_if_jfont:nTF #1 |
| 5405 |
{ |
| 5406 |
\ctex_ltj_is_kenc:n { \@@_ltj_if_jfont:w #1 / \q_stop } |
| 5407 |
\legacy_if:nTF { in@ } |
| 5408 |
} |
| 5409 |
\cs_new:Npn \@@_ltj_if_jfont:w #1 / #2 \q_stop |
| 5410 |
{#1} |
| 5411 |
% \end{macrocode} |
| 5412 |
% \end{macro} |
| 5413 |
% |
| 5414 |
% \begin{macro}[int]{\ctex_ltj_if_jfont_math:NTF} |
| 5415 |
% |#1| 是一个形式为 |\M@|\meta{encoding} 的命令,它由 \tn{DeclareFontEncoding} 的 |
| 5416 |
% 第三个参数来定义。 |
| 5417 |
% \begin{macrocode} |
| 5418 |
\cs_new:Npn \ctex_ltj_if_jfont_math:NTF #1 |
| 5419 |
{ \exp_after:wN \@@_if_jfont_math:w \token_to_str:N #1 \q_stop } |
| 5420 |
\group_begin: |
| 5421 |
\char_set_catcode_other:N M |
| 5422 |
\cs_new:Npn \@@_if_jfont_math:w #1 M #2#3 \q_stop |
| 5423 |
{ \ctex_ltj_if_jfont:nTF {#3} } |
| 5424 |
\group_end: |
| 5425 |
% \end{macrocode} |
| 5426 |
% \end{macro} |
| 5427 |
% |
| 5428 |
% \begin{macro}[int]{\getanddefine@fonts,\ctex_ltj_get_and_define_fonts:nN} |
| 5429 |
% 在使用的场合,\tn{escapechar} 已经被设置成 $-1$,使用 \cs{token_to_str:N} 就 |
| 5430 |
% 可以得到名字,不必使用 \cs{cs_to_str:N}。 |
| 5431 |
% \begin{macrocode} |
| 5432 |
\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts:nN #1#2 |
| 5433 |
{ |
| 5434 |
\exp_args:No \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 } |
| 5435 |
{ \ctex_ltj_get_and_define_fonts_ja:nN } |
| 5436 |
{ \ctex_ltj_get_and_define_fonts_al:nN } |
| 5437 |
{#1} #2 |
| 5438 |
} |
| 5439 |
\cs_new_eq:NN \ctex_ltj_get_and_define_fonts_al:nN \getanddefine@fonts |
| 5440 |
\cs_set_eq:NN \getanddefine@fonts \ctex_ltj_get_and_define_fonts:nN |
| 5441 |
\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2 |
| 5442 |
{ |
| 5443 |
\tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \tf@size } } |
| 5444 |
\ctex_ltj_pickup_font: \tl_set_eq:NN \textfont@name \font@name |
| 5445 |
\tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \sf@size } } |
| 5446 |
\ctex_ltj_pickup_font: \tl_set_eq:NN \scriptfont@name \font@name |
| 5447 |
\tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \ssf@size } } |
| 5448 |
\ctex_ltj_pickup_font: |
| 5449 |
\tl_put_right:Nx \math@fonts |
| 5450 |
{ |
| 5451 |
\ltj@setpar@global |
| 5452 |
\ltj@@@@set@stackfont #1 , \textfont@name \c_colon_str { MJT } |
| 5453 |
\ltj@@@@set@stackfont #1 , \scriptfont@name \c_colon_str { MJS } |
| 5454 |
\ltj@@@@set@stackfont #1 , \font@name \c_colon_str { MJSS } |
| 5455 |
} |
| 5456 |
} |
| 5457 |
% \end{macrocode} |
| 5458 |
% \end{macro} |
| 5459 |
% |
| 5460 |
% \begin{macro}[int]{\use@mathgroup,\ctex_ltj_use_math_group:Nn} |
| 5461 |
% 在使用 \pkg{unicode-math} 宏包时,\cs{ctex_ltj_math_group_hook:} 将被重定义。 |
| 5462 |
% \begin{macrocode} |
| 5463 |
\cs_new_protected:Npn \ctex_ltj_use_math_group:Nn #1#2 |
| 5464 |
{ |
| 5465 |
\mode_if_math:T |
| 5466 |
{ |
| 5467 |
\math@bgroup |
| 5468 |
\cs_if_eq:cNF { M@ \f@encoding } #1 {#1} |
| 5469 |
\ctex_ltj_math_group_hook: |
| 5470 |
\ctex_ltj_if_jfont_math:NTF #1 |
| 5471 |
{ \jfam } { \mathgroup } #2 \scan_stop: |
| 5472 |
\math@egroup |
| 5473 |
} |
| 5474 |
} |
| 5475 |
\cs_new_eq:NN \ctex_ltj_math_group_hook: \prg_do_nothing: |
| 5476 |
\cs_set_eq:NN \use@mathgroup \ctex_ltj_use_math_group:Nn |
| 5477 |
% \end{macrocode} |
| 5478 |
% \end{macro} |
| 5479 |
% |
| 5480 |
% \changes{v2.4.3}{2016/08/25}{更新 \pkg{unicode-math} 补丁。} |
| 5481 |
% \changes{v2.4.9}{2017/02/27}{调整 \pkg{unicode-math} 补丁的代码顺序。} |
| 5482 |
% 对 \pkg{unicode-math} 的补丁主要是将 \file{unicode-math-table.tex} 中的数学符号设置为 |
| 5483 |
% \pkg{luatexja} 中的数学字母。 |
| 5484 |
% 本段代码应放在 \cs{ctex_ltj_math_group_hook:} 的定义之后,避免因宏包载入顺序而造成的编译错误。 |
| 5485 |
% \begin{macrocode} |
| 5486 |
\cs_new_protected:Npn \ctex_ltj_set_math_letter:NN #1#2 |
| 5487 |
{ |
| 5488 |
\group_begin: |
| 5489 |
\cs_set_protected:Npn #1 ##1##2##3 |
| 5490 |
{ \ltjsetmathletter { ##1 } } |
| 5491 |
#2 |
| 5492 |
\group_end: |
| 5493 |
} |
| 5494 |
\ctex_at_end_package:nn { unicode-math } |
| 5495 |
{ |
| 5496 |
\cs_if_exist:NTF \um_input_math_symbol_table: |
| 5497 |
{ |
| 5498 |
\ctex_ltj_set_math_letter:NN |
| 5499 |
\um_sym:nnn |
| 5500 |
\um_input_math_symbol_table: |
| 5501 |
} |
| 5502 |
{ |
| 5503 |
\cs_set_eq:NN \use@mathgroup \ctex_ltj_use_math_group:Nn |
| 5504 |
\cs_set_protected:Npn \ctex_ltj_math_group_hook: |
| 5505 |
{ \__um_switchto_literal: } |
| 5506 |
\ctex_ltj_set_math_letter:NN |
| 5507 |
\__um_sym:nnn |
| 5508 |
\__um_input_math_symbol_table: |
| 5509 |
} |
| 5510 |
} |
| 5511 |
% \end{macrocode} |
| 5512 |
% |
| 5513 |
% \paragraph{字体族的定义与使用} |
| 5514 |
% |
| 5515 |
% \changes{v2.5.9}{2022/05/26}{依赖 \pkg{chinese-jfm} 宏包。} |
| 5516 |
% |
| 5517 |
% \begin{macro}[int]{\ctex_set_jfm:n} |
| 5518 |
% \begin{variable}{\l_@@_jfm_tl, \l_@@_redirect_jfm_prop} |
| 5519 |
% 设置 \texttt{JFM},需要进行一些重定向操作。 |
| 5520 |
% \begin{macrocode} |
| 5521 |
\cs_new_protected:Npn \ctex_set_jfm:n #1 |
| 5522 |
{ |
| 5523 |
\prop_get:NnNF \l_@@_redirect_jfm_prop {#1} \l_@@_jfm_tl |
| 5524 |
{ \tl_set:Nn \l_@@_jfm_tl {#1} } |
| 5525 |
} |
| 5526 |
\cs_generate_variant:Nn \ctex_set_jfm:n { o } |
| 5527 |
\prop_new:N \l_@@_redirect_jfm_prop |
| 5528 |
\prop_set_from_keyval:Nn \l_@@_redirect_jfm_prop |
| 5529 |
{ |
| 5530 |
plain = mono , |
| 5531 |
quanjiao = zh_CN / quanjiao , |
| 5532 |
banjiao = zh_CN / banjiao , |
| 5533 |
kaiming = zh_CN / kaiming |
| 5534 |
} |
| 5535 |
\keys_define:nn { ctex_ltj / fontspec } |
| 5536 |
{ |
| 5537 |
JFM .code:n = \ctex_set_jfm:n {#1} , |
| 5538 |
JFM .value_required:n = true |
| 5539 |
} |
| 5540 |
\tl_new:N \l_@@_jfm_tl |
| 5541 |
\ctex_set_jfm:o { \l__ctex_punct_tl } |
| 5542 |
% \end{macrocode} |
| 5543 |
% \end{variable} |
| 5544 |
% \end{macro} |
| 5545 |
% |
| 5546 |
% \begin{macro}[int]{\CJK@encoding} |
| 5547 |
% 在 \LaTeX 下,\pkg{LuaTeX-ja} 依赖字体编码来实现特殊设置。例如上述的 |
| 5548 |
% \cs{ctex_ltj_if_jfont:nTF} 就是通过判断编码来实现的,它在设置数学字体时会用到。所以 |
| 5549 |
% 不应该与西文共用 \texttt{EU2}。定义字体族 song 为 \tn{CJK@encoding} 的默认替换 |
| 5550 |
% 字体。下划线 |_| 不在 \tn{nfss@catcodes} 里,可以放心使用。 |
| 5551 |
% \begin{macrocode} |
| 5552 |
\tl_const:Nn \CJK@encoding { LTJY3 } |
| 5553 |
\DeclareFontEncoding { \CJK@encoding } { } { } |
| 5554 |
\use:e |
| 5555 |
{ |
| 5556 |
\exp_not:N \DeclareFontSubstitution |
| 5557 |
{ \CJK@encoding } { song } { \mddefault } { \shapedefault } |
| 5558 |
} |
| 5559 |
\ctex_ltj_add_kyenc:n { \CJK@encoding } |
| 5560 |
\DeclareFontFamily { \CJK@encoding } { song } { } |
| 5561 |
\DeclareFontShape { \CJK@encoding } { song } { \mddefault } { \shapedefault } |
| 5562 |
{ <-> psft:SimSun:cid=Adobe-GB1-5;jfm=\l_@@_jfm_tl } { } |
| 5563 |
\DeclareFontShape { \CJK@encoding } { song } { \bfdefault } { \shapedefault } |
| 5564 |
{ <-> psft:SimHei:cid=Adobe-GB1-5;jfm=\l_@@_jfm_tl } { } |
| 5565 |
\tl_const:Nn \c_@@_math_tl { CJKmath } |
| 5566 |
\DeclareSymbolFont { \c_@@_math_tl } |
| 5567 |
{ \CJK@encoding } { song } { \mddefault } { \shapedefault } |
| 5568 |
\SetSymbolFont { \c_@@_math_tl } { bold } |
| 5569 |
{ \CJK@encoding } { song } { \bfdefault } { \shapedefault } |
| 5570 |
\int_const:Nn \c_@@_math_fam_int { \use:c { sym \c_@@_math_tl } } |
| 5571 |
\jfam \c_@@_math_fam_int |
| 5572 |
% \end{macrocode} |
| 5573 |
% \end{macro} |
| 5574 |
% |
| 5575 |
% 这是 \pkg{luatexja-fontspec} 中新增的一些字体选项。 |
| 5576 |
% \begin{macrocode} |
| 5577 |
\newfontfeature { CID } { cid = #1 } |
| 5578 |
\newfontfeature { JFM } { jfm = #1 } |
| 5579 |
\newfontfeature { JFM-var } { jfmvar = #1 } |
| 5580 |
% \end{macrocode} |
| 5581 |
% |
| 5582 |
% 在新版本的 \pkg{fontspec} 中,\cs{__fontspec_fontname_wrap:n} 变成了私有函数。 |
| 5583 |
% \begin{macrocode} |
| 5584 |
\keys_define:nn { fontspec-preparse-external } |
| 5585 |
{ |
| 5586 |
NoEmbed .code:n = |
| 5587 |
{ \cs_set_eq:NN \__fontspec_fontname_wrap:n \@@_noembed_wrap:n } |
| 5588 |
} |
| 5589 |
\cs_new:Npn \@@_noembed_wrap:n #1 { psft: #1 } |
| 5590 |
% \end{macrocode} |
| 5591 |
% |
| 5592 |
% \begin{macro}[int]{\ctex_ltj_set_family:nnn} |
| 5593 |
% 将自定义的字体族名与 \pkg{fontspec} 实际设置的名字对应起来。 |
| 5594 |
% \begin{macrocode} |
| 5595 |
\cs_new_protected:Npn \ctex_ltj_set_family:nnn #1#2#3 |
| 5596 |
{ |
| 5597 |
\group_begin: |
| 5598 |
\clist_clear:N \l_@@_char_range_clist |
| 5599 |
\prop_clear:N \l_@@_alternate_prop |
| 5600 |
\tl_set:Nn \l_@@_base_CJKfamily_tl {#1} |
| 5601 |
\keys_set_known:nnN { ctex_ltj / fontspec } {#2} \l_@@_tmp_tl |
| 5602 |
\clist_set:No \l_@@_font_options_clist { \l_@@_tmp_tl } |
| 5603 |
\ctex_ltj_set_alternate_family:nnF {#1} {#3} |
| 5604 |
{ |
| 5605 |
\prop_gput:Nnn \g_@@_family_font_name_prop {#1} {#3} |
| 5606 |
\prop_gput:Nno \g_@@_family_font_options_prop |
| 5607 |
{#1} { \l_@@_font_options_clist } |
| 5608 |
\@@_update_family_uid:N \l_@@_font_options_clist |
| 5609 |
\@@_use_global_options:N \l_@@_font_options_clist |
| 5610 |
\@@_gset_family_cs:nn {#1} {#3} |
| 5611 |
} |
| 5612 |
\group_end: |
| 5613 |
} |
| 5614 |
\tl_new:N \l_@@_base_CJKfamily_tl |
| 5615 |
\clist_new:N \l_@@_font_options_clist |
| 5616 |
% \end{macrocode} |
| 5617 |
% \end{macro} |
| 5618 |
% |
| 5619 |
% \begin{macro}{\@@_use_global_options:N} |
| 5620 |
% 应用默认字体选项,并总是设置 \opt{JFM} 和 \opt{NFSSEncoding} 。 |
| 5621 |
% \begin{macrocode} |
| 5622 |
\cs_new_protected:Npn \@@_use_global_options:N #1 |
| 5623 |
{ |
| 5624 |
\clist_concat:NNN #1 \g_@@_default_features_clist #1 |
| 5625 |
\clist_put_left:Nx #1 |
| 5626 |
{ NFSSEncoding = \CJK@encoding , JFM = \l_@@_jfm_tl } |
| 5627 |
} |
| 5628 |
% \end{macrocode} |
| 5629 |
% \end{macro} |
| 5630 |
% |
| 5631 |
% \begin{variable} |
| 5632 |
% {\g_@@_family_name_prop,\g_@@_family_font_name_prop,\g_@@_family_font_options_prop} |
| 5633 |
% 分别保存 \pkg{fontspec} 设置的字体族名、字体名称和字体选项。 |
| 5634 |
% \begin{macrocode} |
| 5635 |
\prop_new:N \g_@@_family_name_prop |
| 5636 |
\prop_new:N \g_@@_family_font_name_prop |
| 5637 |
\prop_new:N \g_@@_family_font_options_prop |
| 5638 |
% \end{macrocode} |
| 5639 |
% \end{variable} |
| 5640 |
% |
| 5641 |
% \begin{macro}{\@@_check_family:n} |
| 5642 |
% 删除重复的定义,清除替代字体的先前设置。 |
| 5643 |
% \begin{macrocode} |
| 5644 |
\cs_new_protected:Npn \@@_check_family:n #1 |
| 5645 |
{ |
| 5646 |
\prop_gpop:NnNT \g_@@_family_font_name_prop {#1} \l_@@_tmp_tl |
| 5647 |
{ |
| 5648 |
\cs_undefine:c { \@@_family_csname:n {#1} } |
| 5649 |
\cs_undefine:c { \@@_alternate_cs:n {#1} } |
| 5650 |
\prop_gpop:NnNT \g_@@_family_name_prop {#1} \l_@@_base_family_tl |
| 5651 |
{ |
| 5652 |
\use:c { \@@_alternate_cs:n { clear / #1 } } |
| 5653 |
\cs_undefine:c { \@@_alternate_cs:n { clear / #1 } } |
| 5654 |
\cs_undefine:c { \@@_alternate_cs:n { reset / #1 } } |
| 5655 |
\prop_gremove:Nn \g_@@_reset_alternate_prop {#1} |
| 5656 |
} |
| 5657 |
\msg_warning:nnxx { ctex } { redefine-family } {#1} { \l_@@_tmp_tl } |
| 5658 |
} |
| 5659 |
} |
| 5660 |
\tl_new:N \l_@@_tmp_tl |
| 5661 |
\msg_new:nnn { ctex } { redefine-family } |
| 5662 |
{ Redefining~CJKfamily~`\@@_msg_family_map:n {#1}'~(#2). } |
| 5663 |
% \end{macrocode} |
| 5664 |
% \end{macro} |
| 5665 |
% |
| 5666 |
% \begin{macro}{\@@_gset_family_cs:nn} |
| 5667 |
% 在设置字体时,实际上并不是马上就定义。而是只保存相关参数,在通过 \tn{CJKfamily} |
| 5668 |
% 第一次使用时才定义。需要注意将编码改为 \tn{CJK@encoding}。 |
| 5669 |
% \begin{macrocode} |
| 5670 |
\cs_new_protected:Npn \@@_gset_family_cs:nn #1#2 |
| 5671 |
{ |
| 5672 |
\cs_gset_protected:cpx { \@@_family_csname:n {#1} } |
| 5673 |
{ |
| 5674 |
\group_begin: |
| 5675 |
\exp_not:n { \cs_set_eq:NN \CJKfamily \use_none:n } |
| 5676 |
\exp_not:n { \fontspec_gset_family:Nnn \g_@@_fontspec_family_tl } |
| 5677 |
{ \exp_not:o { \l_@@_font_options_clist } } {#2} |
| 5678 |
\prop_gput:Nno \exp_not:N \g_@@_family_name_prop {#1} |
| 5679 |
{ \exp_not:N \g_@@_fontspec_family_tl } |
| 5680 |
\@@_set_alternate_family:n {#1} |
| 5681 |
\group_end: |
| 5682 |
} |
| 5683 |
} |
| 5684 |
\tl_new:N \l_@@_base_family_tl |
| 5685 |
\tl_new:N \g_@@_fontspec_family_tl |
| 5686 |
\cs_new:Npn \@@_family_csname:n #1 { ctex_ltj/family/#1 } |
| 5687 |
\cs_new_protected:Npn \@@_set_alternate_family:n #1 |
| 5688 |
{ |
| 5689 |
\tl_set:Nn \l_@@_base_CJKfamily_tl {#1} |
| 5690 |
\tl_set_eq:NN \l_@@_base_family_tl \g_@@_fontspec_family_tl |
| 5691 |
\cs_if_exist_use:c { \@@_alternate_cs:n { reset / #1 } } |
| 5692 |
\cs_if_exist_use:c { \@@_alternate_cs:n {#1} } |
| 5693 |
} |
| 5694 |
\cs_new:Npn \@@_alternate_cs:n #1 { ctex_ltj/alternate_family/#1 } |
| 5695 |
% \end{macrocode} |
| 5696 |
% \end{macro} |
| 5697 |
% |
| 5698 |
% \begin{macro}[int]{\CJKfamily} |
| 5699 |
% 切换字体。 |
| 5700 |
% \begin{macrocode} |
| 5701 |
\NewDocumentCommand \CJKfamily { m } |
| 5702 |
{ \ctex_ltj_switch_family:x {#1} \tex_ignorespaces:D } |
| 5703 |
\cs_new_protected:Npn \ctex_ltj_switch_family:n #1 |
| 5704 |
{ |
| 5705 |
\ctex_ltj_family_if_exist:nNTF {#1} \CJK@family |
| 5706 |
{ |
| 5707 |
\tl_set:Nn \l_ctex_ltj_family_tl {#1} |
| 5708 |
\selectfont |
| 5709 |
} |
| 5710 |
{ \@@_family_unknown_warning:n {#1} } |
| 5711 |
} |
| 5712 |
\tl_new:N \l_ctex_ltj_family_tl |
| 5713 |
\cs_generate_variant:Nn \ctex_ltj_switch_family:n { x } |
| 5714 |
% \end{macrocode} |
| 5715 |
% \end{macro} |
| 5716 |
% |
| 5717 |
% \begin{macro}[int,TF]{\ctex_ltj_family_if_exist:nN} |
| 5718 |
% 判断 CJK 字体族 |#1| 是否存在,若存在则把实际族名保存到 |#2| 中。 |
| 5719 |
% \begin{macrocode} |
| 5720 |
\prg_new_protected_conditional:Npnn \ctex_ltj_family_if_exist:nN #1#2 { T , F , TF } |
| 5721 |
{ |
| 5722 |
\prop_get:NnNTF \g_@@_family_name_prop {#1} #2 |
| 5723 |
{ \prg_return_true: } |
| 5724 |
{ |
| 5725 |
\cs_if_exist_use:cTF { \@@_family_csname:n {#1} } |
| 5726 |
{ |
| 5727 |
\tl_set_eq:NN #2 \g_@@_fontspec_family_tl |
| 5728 |
\prg_return_true: |
| 5729 |
} |
| 5730 |
{ \prg_return_false: } |
| 5731 |
} |
| 5732 |
} |
| 5733 |
\prg_generate_conditional_variant:Nnn \ctex_ltj_family_if_exist:nN { x } { T , F , TF } |
| 5734 |
% \end{macrocode} |
| 5735 |
% \end{macro} |
| 5736 |
% |
| 5737 |
% \begin{macro}{\@@_family_unknown_warning:n} |
| 5738 |
% \begin{macrocode} |
| 5739 |
\cs_new_protected:Npn \@@_family_unknown_warning:n #1 |
| 5740 |
{ |
| 5741 |
\prop_if_empty:NF \g_@@_family_font_name_prop |
| 5742 |
{ |
| 5743 |
\seq_if_in:NnF \g_@@_unknown_family_seq {#1} |
| 5744 |
{ |
| 5745 |
\seq_gput_right:Nn \g_@@_unknown_family_seq {#1} |
| 5746 |
\msg_warning:nnn { ctex } { family-unknown } {#1} |
| 5747 |
} |
| 5748 |
} |
| 5749 |
} |
| 5750 |
\seq_new:N \g_@@_unknown_family_seq |
| 5751 |
\msg_new:nnn { ctex } { family-unknown } |
| 5752 |
{ |
| 5753 |
Unknown~CJK~family~`\@@_msg_family_map:n {#1}'~is~being~ignored.\\ |
| 5754 |
Try~to~use~`\@@_msg_def_family_map:n {#1}'~to~define~it. |
| 5755 |
} |
| 5756 |
\cs_new:Npn \@@_msg_def_family_map:n #1 |
| 5757 |
{ |
| 5758 |
\str_case_e:nnF {#1} |
| 5759 |
{ |
| 5760 |
\CJKrmdefault { \token_to_str:N \setCJKmainfont } |
| 5761 |
\CJKsfdefault { \token_to_str:N \setCJKsansfont } |
| 5762 |
\CJKttdefault { \token_to_str:N \setCJKmonofont } |
| 5763 |
} |
| 5764 |
{ \token_to_str:N \setCJKfamilyfont \{ #1 \} } |
| 5765 |
[...]\{...\} |
| 5766 |
} |
| 5767 |
\cs_new:Npn \@@_msg_family_map:n #1 |
| 5768 |
{ |
| 5769 |
\str_case_e:nnF {#1} |
| 5770 |
{ |
| 5771 |
\CJKrmdefault { \token_to_str:N \CJKrmdefault } |
| 5772 |
\CJKsfdefault { \token_to_str:N \CJKsfdefault } |
| 5773 |
\CJKttdefault { \token_to_str:N \CJKttdefault } |
| 5774 |
} |
| 5775 |
{#1} |
| 5776 |
} |
| 5777 |
% \end{macrocode} |
| 5778 |
% \end{macro} |
| 5779 |
% |
| 5780 |
% \begin{macro}[int]{\ctex_ltj_fontspec:nn} |
| 5781 |
% \begin{macrocode} |
| 5782 |
\cs_new_protected:Npn \ctex_ltj_fontspec:nn #1#2 |
| 5783 |
{ |
| 5784 |
\prop_get:NnNTF \g_@@_fontspec_prop |
| 5785 |
{ CJKfontspec/#1/#2/id } \l_ctex_ltj_family_tl |
| 5786 |
{ \ctex_ltj_switch_family:x { \l_ctex_ltj_family_tl } } |
| 5787 |
{ |
| 5788 |
\int_gincr:N \g_@@_family_int |
| 5789 |
\@@_fontspec:enn |
| 5790 |
{ CJKfontspec ( \int_use:N \g_@@_family_int ) } |
| 5791 |
{#1} {#2} |
| 5792 |
} |
| 5793 |
} |
| 5794 |
\cs_new_protected:Npn \ctex_ltj_fontspec:ee #1#2 |
| 5795 |
{ \use:e { \ctex_ltj_fontspec:nn {#1} {#2} } } |
| 5796 |
\cs_new_protected:Npn \@@_fontspec:nnn #1#2#3 |
| 5797 |
{ |
| 5798 |
\bool_if:NT \l_@@_add_alternate_bool |
| 5799 |
{ |
| 5800 |
\cs_if_free:cF |
| 5801 |
{ \@@_alternate_cs:n { reset / \l_ctex_ltj_family_tl } } |
| 5802 |
{ |
| 5803 |
\cs_gset_eq:cc |
| 5804 |
{ \@@_alternate_cs:n { reset / #1 } } |
| 5805 |
{ \@@_alternate_cs:n { reset / \l_ctex_ltj_family_tl } } |
| 5806 |
\cs_gset_eq:cc |
| 5807 |
{ \@@_alternate_cs:n { clear / #1 } } |
| 5808 |
{ \@@_alternate_cs:n { clear / \l_ctex_ltj_family_tl } } |
| 5809 |
} |
| 5810 |
\bool_set_false:N \l_@@_add_alternate_bool |
| 5811 |
} |
| 5812 |
\prop_gput:Nnn \g_@@_fontspec_prop { CJKfontspec/#2/#3/id } {#1} |
| 5813 |
\ctex_ltj_set_family:nnn {#1} {#2} {#3} |
| 5814 |
\ctex_ltj_switch_family:n {#1} |
| 5815 |
} |
| 5816 |
\cs_generate_variant:Nn \@@_fontspec:nnn { e } |
| 5817 |
\prop_new:N \g_@@_fontspec_prop |
| 5818 |
% \end{macrocode} |
| 5819 |
% \end{macro} |
| 5820 |
% |
| 5821 |
% \begin{macro}[int] |
| 5822 |
% {\ctex_ltj_add_font_features:n,\ctex_ltj_add_font_features:nn} |
| 5823 |
% \begin{macrocode} |
| 5824 |
\cs_new_protected:Npn \ctex_ltj_add_font_features:n #1 |
| 5825 |
{ \ctex_ltj_add_font_features:xn { \l_ctex_ltj_family_tl } {#1} } |
| 5826 |
\cs_new_protected:Npn \ctex_ltj_add_font_features:nn #1#2 |
| 5827 |
{ |
| 5828 |
\prop_get:NnNTF \g_@@_family_font_name_prop |
| 5829 |
{#1} \l_@@_tmp_tl |
| 5830 |
{ |
| 5831 |
\prop_get:NnN \g_@@_family_font_options_prop |
| 5832 |
{#1} \l_@@_font_options_clist |
| 5833 |
\clist_put_right:Nn \l_@@_font_options_clist {#2} |
| 5834 |
\bool_set_true:N \l_@@_add_alternate_bool |
| 5835 |
\ctex_ltj_fontspec:ee |
| 5836 |
{ \exp_not:o { \l_@@_font_options_clist } } |
| 5837 |
{ \exp_not:o { \l_@@_tmp_tl } } |
| 5838 |
} |
| 5839 |
{ \msg_warning:nn { ctex } { addCJKfontfeature-ignored } } |
| 5840 |
} |
| 5841 |
\bool_new:N \l_@@_add_alternate_bool |
| 5842 |
\cs_generate_variant:Nn \ctex_ltj_add_font_features:n { x } |
| 5843 |
\cs_generate_variant:Nn \ctex_ltj_add_font_features:nn { x } |
| 5844 |
\msg_new:nnn { ctex } { addCJKfontfeature-ignored } |
| 5845 |
{ |
| 5846 |
\token_to_str:N \addCJKfontfeature (s)~ignored.\\ |
| 5847 |
It~cannot~be~used~with~a~font~that~wasn't~selected~by~ctex. |
| 5848 |
} |
| 5849 |
% \end{macrocode} |
| 5850 |
% \end{macro} |
| 5851 |
% |
| 5852 |
% \begin{macro}{\@@_pass_args:nnnn} |
| 5853 |
% 为了支持字体属性可选项在前在后两种语法,给出两个辅助工具,自带展开功能。 |
| 5854 |
% \begin{macrocode} |
| 5855 |
\cs_new_protected:Npn \@@_pass_args:nnnn #1#2#3#4 |
| 5856 |
{ |
| 5857 |
\tl_if_novalue:nTF {#2} |
| 5858 |
{ \@@_post_arg:w {#1} {#3} {#4} } |
| 5859 |
{ |
| 5860 |
\use:e { #1 {#2} {#3} } |
| 5861 |
#4 |
| 5862 |
} |
| 5863 |
} |
| 5864 |
\NewDocumentCommand \@@_post_arg:w { m m m O { } } |
| 5865 |
{ |
| 5866 |
\use:e { #1 {#4} {#2} } |
| 5867 |
#3 |
| 5868 |
} |
| 5869 |
% \end{macrocode} |
| 5870 |
% \end{macro} |
| 5871 |
% |
| 5872 |
% \changes{v2.4.6}{2016/11/20}{支持字体属性可选项在后的新语法。} |
| 5873 |
% |
| 5874 |
% \begin{macro}[int] |
| 5875 |
% {\setCJKfamilyfont,\newCJKfontfamily,\CJKfontspec,\addCJKfontfeatures} |
| 5876 |
% \begin{macrocode} |
| 5877 |
\NewDocumentCommand \setCJKfamilyfont { m o m } |
| 5878 |
{ |
| 5879 |
\@@_pass_args:nnnn |
| 5880 |
{ \ctex_ltj_set_family:nnn {#1} } {#2} {#3} |
| 5881 |
{ } |
| 5882 |
} |
| 5883 |
\NewDocumentCommand \newCJKfontfamily { o m o m } |
| 5884 |
{ |
| 5885 |
\tl_set:Nx \l_@@_tmp_tl |
| 5886 |
{ \tl_if_novalue:nTF {#1} { \cs_to_str:N #2 } {#1} } |
| 5887 |
\cs_new_protected:Npx #2 |
| 5888 |
{ \ctex_ltj_switch_family:n { \l_@@_tmp_tl } } |
| 5889 |
\@@_pass_args:nnnn |
| 5890 |
{ \ctex_ltj_set_family:nnn { \l_@@_tmp_tl } } {#3} {#4} |
| 5891 |
{ } |
| 5892 |
} |
| 5893 |
\NewDocumentCommand \CJKfontspec { o m } |
| 5894 |
{ |
| 5895 |
\@@_pass_args:nnnn |
| 5896 |
{ \ctex_ltj_fontspec:nn } {#1} {#2} |
| 5897 |
{ \tex_ignorespaces:D } |
| 5898 |
} |
| 5899 |
\NewDocumentCommand \addCJKfontfeatures { m } |
| 5900 |
{ |
| 5901 |
\ctex_ltj_add_font_features:x {#1} |
| 5902 |
\tex_ignorespaces:D |
| 5903 |
} |
| 5904 |
\cs_new_eq:NN \addCJKfontfeature \addCJKfontfeatures |
| 5905 |
% \end{macrocode} |
| 5906 |
% \end{macro} |
| 5907 |
% |
| 5908 |
% \begin{macro}[int] |
| 5909 |
% {\setCJKmainfont,\setCJKsansfont,\setCJKmonofont, |
| 5910 |
% \setCJKmathfont,\defaultCJKfontfeatures} |
| 5911 |
% \begin{macrocode} |
| 5912 |
\NewDocumentCommand \setCJKmainfont { o m } |
| 5913 |
{ |
| 5914 |
\@@_pass_args:nnnn |
| 5915 |
{ \ctex_ltj_set_family:nnn { \CJKrmdefault } } {#1} {#2} |
| 5916 |
{ \normalfont } |
| 5917 |
} |
| 5918 |
\cs_new_eq:NN \setCJKromanfont \setCJKmainfont |
| 5919 |
\NewDocumentCommand \setCJKsansfont { o m } |
| 5920 |
{ |
| 5921 |
\@@_pass_args:nnnn |
| 5922 |
{ \ctex_ltj_set_family:nnn { \CJKsfdefault } } {#1} {#2} |
| 5923 |
{ \normalfont } |
| 5924 |
} |
| 5925 |
\NewDocumentCommand \setCJKmonofont { o m } |
| 5926 |
{ |
| 5927 |
\@@_pass_args:nnnn |
| 5928 |
{ \ctex_ltj_set_family:nnn { \CJKttdefault } } {#1} {#2} |
| 5929 |
{ \normalfont } |
| 5930 |
} |
| 5931 |
\NewDocumentCommand \setCJKmathfont { o m } |
| 5932 |
{ |
| 5933 |
\@@_pass_args:nnnn |
| 5934 |
{ \ctex_ltj_set_family:nnn { \c_@@_math_tl } } {#1} {#2} |
| 5935 |
{ } |
| 5936 |
} |
| 5937 |
\NewDocumentCommand \defaultCJKfontfeatures { m } |
| 5938 |
{ \clist_gset:Nn \g_@@_default_features_clist {#1} } |
| 5939 |
\clist_new:N \g_@@_default_features_clist |
| 5940 |
\@onlypreamble \setCJKmainfont |
| 5941 |
\@onlypreamble \setCJKsansfont |
| 5942 |
\@onlypreamble \setCJKmonofont |
| 5943 |
\@onlypreamble \setCJKmathfont |
| 5944 |
\@onlypreamble \setCJKromanfont |
| 5945 |
\@onlypreamble \defaultCJKfontfeatures |
| 5946 |
% \end{macrocode} |
| 5947 |
% \end{macro} |
| 5948 |
% |
| 5949 |
% \changes{v2.4.8}{2017/02/23} |
| 5950 |
% {解决与 \pkg{fontspec} 2017/01/24 v2.5d 的字体族匹配兼容问题。} |
| 5951 |
% |
| 5952 |
% \begin{macro}[int]{\ctex_ltj_ensure_default_family:} |
| 5953 |
% 在导言区结束确认 \tn{CJKfamilydefault} 确实存在。 |
| 5954 |
% \begin{macrocode} |
| 5955 |
\cs_new_protected:Npn \ctex_ltj_ensure_default_family: |
| 5956 |
{ |
| 5957 |
\prop_if_empty:NF \g_@@_family_font_name_prop |
| 5958 |
{ |
| 5959 |
\ctex_ltj_family_if_exist:xNF { \CJKfamilydefault } \l_@@_tmp_tl |
| 5960 |
{ |
| 5961 |
\str_if_eq:eeTF { \CJKfamilydefault } { \CJKrmdefault } |
| 5962 |
{ \use:n } |
| 5963 |
{ |
| 5964 |
\ctex_ltj_family_if_exist:xNTF { \CJKrmdefault } \l_@@_tmp_tl |
| 5965 |
{ \tl_gset:Nn \CJKfamilydefault { \CJKrmdefault } \use_none:n } |
| 5966 |
{ \use:n } |
| 5967 |
} |
| 5968 |
{ |
| 5969 |
\prop_map_inline:Nn \g_@@_family_font_name_prop |
| 5970 |
{ |
| 5971 |
\prop_map_break:n |
| 5972 |
{ \tl_gset_rescan:Nnn \CJKfamilydefault { } { ##1 } } |
| 5973 |
} |
| 5974 |
} |
| 5975 |
} |
| 5976 |
\normalfont |
| 5977 |
\ctex_ltj_update_mathfont: |
| 5978 |
} |
| 5979 |
} |
| 5980 |
% \end{macrocode} |
| 5981 |
% \end{macro} |
| 5982 |
% |
| 5983 |
% \begin{macro}[int]{\ctex_ltj_update_mathfont:} |
| 5984 |
% 更新数学字体为实际的字体。 |
| 5985 |
% \begin{macrocode} |
| 5986 |
\cs_new_protected:Npn \ctex_ltj_update_mathfont: |
| 5987 |
{ |
| 5988 |
\ctex_ltj_family_if_exist:xNTF { \c_@@_math_tl } \l_@@_tmp_tl |
| 5989 |
{ \ctex_ltj_update_mathfont:n { \l_@@_tmp_tl } } |
| 5990 |
{ |
| 5991 |
\ctex_ltj_family_if_exist:xNT { \CJKfamilydefault } \l_@@_tmp_tl |
| 5992 |
{ \ctex_ltj_update_mathfont:n { \l_@@_tmp_tl } } |
| 5993 |
} |
| 5994 |
} |
| 5995 |
\cs_new_protected:Npn \ctex_ltj_update_mathfont:n #1 |
| 5996 |
{ |
| 5997 |
\tl_const:Nx \c_@@_math_family_tl {#1} |
| 5998 |
\DeclareSymbolFont { \c_@@_math_tl } { \CJK@encoding } |
| 5999 |
{ \c_@@_math_family_tl } { \mddefault } { \shapedefault } |
| 6000 |
\cs_if_free:cTF |
| 6001 |
{ \CJK@encoding/\c_@@_math_family_tl/\bfdefault/\shapedefault } |
| 6002 |
{ |
| 6003 |
\SetSymbolFont { \c_@@_math_tl } { bold } { \CJK@encoding } |
| 6004 |
{ \c_@@_math_family_tl } { \mddefault } { \shapedefault } |
| 6005 |
} |
| 6006 |
{ |
| 6007 |
\SetSymbolFont { \c_@@_math_tl } { bold } { \CJK@encoding } |
| 6008 |
{ \c_@@_math_family_tl } { \bfdefault } { \shapedefault } |
| 6009 |
} |
| 6010 |
} |
| 6011 |
% \end{macrocode} |
| 6012 |
% \end{macro} |
| 6013 |
% |
| 6014 |
% \paragraph{替代字体的设置} |
| 6015 |
% |
| 6016 |
% \changes{v2.5}{2020/04/30}{重构字体选项 \opt{AlternateFont}。} |
| 6017 |
% |
| 6018 |
% \begin{macro}{AlternateFont,CharRange} |
| 6019 |
% 设置替代字体的选项。 |
| 6020 |
% \begin{macrocode} |
| 6021 |
\keys_define:nn { ctex_ltj / fontspec } |
| 6022 |
{ |
| 6023 |
AlternateFont .code:n = \ctex_ltj_set_alternate_prop:n {#1} , |
| 6024 |
AlternateFont .value_required:n = true , |
| 6025 |
CharRange .clist_set:N = \l_@@_char_range_clist , |
| 6026 |
CharRange .value_required:n = true |
| 6027 |
} |
| 6028 |
% \end{macrocode} |
| 6029 |
% \end{macro} |
| 6030 |
% |
| 6031 |
% \begin{macro}[int]{\ctex_ltj_set_alternate_prop:n} |
| 6032 |
% 保存替代字体序列。 |
| 6033 |
% \begin{macrocode} |
| 6034 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_prop:n #1 |
| 6035 |
{ \clist_map_function:nN {#1} \@@_push_alternate_prop:n } |
| 6036 |
\cs_new_protected:Npn \@@_push_alternate_prop:n #1 |
| 6037 |
{ |
| 6038 |
\clist_set:Nx \l_@@_tmp_clist { \tl_head:n {#1} } |
| 6039 |
\tl_remove_all:Nn \l_@@_tmp_clist { ~ } |
| 6040 |
\exp_args:No \@@_push_alternate_prop:nn |
| 6041 |
{ \l_@@_tmp_clist } {#1} |
| 6042 |
} |
| 6043 |
\cs_new_protected:Npn \@@_push_alternate_prop:nn #1 |
| 6044 |
{ |
| 6045 |
\prop_remove:Nn \l_@@_alternate_prop {#1} |
| 6046 |
\prop_put:Nnn \l_@@_alternate_prop {#1} |
| 6047 |
} |
| 6048 |
\clist_new:N \l_@@_tmp_clist |
| 6049 |
\prop_new:N \l_@@_alternate_prop |
| 6050 |
% \end{macrocode} |
| 6051 |
% \end{macro} |
| 6052 |
% |
| 6053 |
% \begin{macro}[int]{\ctex_ltj_set_alternate_family:nnF} |
| 6054 |
% 如果在字体的选项中设置了 \opt{CharRange},则只设置替代字体。 |
| 6055 |
% \begin{macrocode} |
| 6056 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnF |
| 6057 |
{ |
| 6058 |
\clist_if_empty:NTF \l_@@_char_range_clist |
| 6059 |
{ \@@_set_family_aux:nnn } |
| 6060 |
{ \@@_set_alternate_family_aux:nnn } |
| 6061 |
} |
| 6062 |
\cs_new_protected:Npn \@@_set_family_aux:nnn #1#2#3 |
| 6063 |
{ |
| 6064 |
\@@_check_family:n {#1} |
| 6065 |
\prop_if_empty:NF \l_@@_alternate_prop |
| 6066 |
{ \ctex_ltj_save_alternate_seq:cn { \@@_alternate_cs:n {#1} } {#2} } |
| 6067 |
#3 |
| 6068 |
} |
| 6069 |
\cs_new_protected:Npn \@@_set_alternate_family_aux:nnn #1#2#3 |
| 6070 |
{ \ctex_ltj_set_alternate_family:nn {#1} {#2} } |
| 6071 |
% \end{macrocode} |
| 6072 |
% \end{macro} |
| 6073 |
% |
| 6074 |
% \begin{macro}[int]{\ctex_ltj_save_alternate_seq:Nn} |
| 6075 |
% 保存由 \opt{AlternateFont} 设置的替代字体序列。 |
| 6076 |
% \begin{macrocode} |
| 6077 |
\cs_new_protected:Npn \ctex_ltj_save_alternate_seq:Nn #1#2 |
| 6078 |
{ |
| 6079 |
\prop_map_inline:Nn \l_@@_alternate_prop |
| 6080 |
{ \@@_save_alternate_auxi:w ##2 { } \q_mark #1 {#2} } |
| 6081 |
} |
| 6082 |
\cs_new_protected:Npn \@@_save_alternate_auxi:w #1#2# |
| 6083 |
{ |
| 6084 |
\tl_if_blank:nTF {#2} |
| 6085 |
{ \@@_save_alternate_auxii:w {#1} } |
| 6086 |
{ \@@_save_alternate_auxii:w {#1} {#2} } |
| 6087 |
} |
| 6088 |
\cs_new_protected:Npn \@@_save_alternate_auxii:w #1#2#3 #4 \q_mark #5#6 |
| 6089 |
{ |
| 6090 |
\clist_set:Nn \l_@@_char_range_clist {#1} |
| 6091 |
\clist_set:Nn \l_@@_alternate_options_clist {#3} |
| 6092 |
\@@_use_global_options:N \l_@@_alternate_options_clist |
| 6093 |
\tl_if_blank:nTF {#2} |
| 6094 |
{ \tl_set:Nn \l_@@_tmp_tl {#6} } |
| 6095 |
{ |
| 6096 |
\tl_set:Nx \l_@@_tmp_tl { \tl_trim_spaces:n {#2} } |
| 6097 |
\tl_replace_all:Nnn \l_@@_tmp_tl { * } {#6} |
| 6098 |
} |
| 6099 |
\use:e |
| 6100 |
{ |
| 6101 |
\ctex_ltj_save_alternate_family:Nnnn \exp_not:N #5 |
| 6102 |
{ \exp_not:o { \l_@@_char_range_clist } } |
| 6103 |
{ \exp_not:o { \l_@@_alternate_options_clist } } |
| 6104 |
{ \exp_not:o { \l_@@_tmp_tl } } |
| 6105 |
} |
| 6106 |
} |
| 6107 |
\clist_new:N \l_@@_alternate_options_clist |
| 6108 |
\cs_generate_variant:Nn \ctex_ltj_save_alternate_seq:Nn { c } |
| 6109 |
% \end{macrocode} |
| 6110 |
% \end{macro} |
| 6111 |
% |
| 6112 |
% \begin{macro}[int]{\ctex_ltj_set_alternate_family:nn} |
| 6113 |
% 设置选项 \opt{CharRange} 范围内的替代字体。如果已经定义了主字体,我们也马上 |
| 6114 |
% 定义替代字体,否则只保存起来备用。 |
| 6115 |
% \begin{macrocode} |
| 6116 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nn #1#2 |
| 6117 |
{ |
| 6118 |
\@@_update_family_uid:N \l_@@_font_options_clist |
| 6119 |
\@@_use_global_options:N \l_@@_font_options_clist |
| 6120 |
\ctex_ltj_set_alternate_family:coonn |
| 6121 |
{ \@@_alternate_cs:n {#1} } |
| 6122 |
{ \l_@@_char_range_clist } |
| 6123 |
{ \l_@@_font_options_clist } {#2} {#1} |
| 6124 |
} |
| 6125 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_family:Nnnnn #1#2#3#4#5 |
| 6126 |
{ |
| 6127 |
\prop_get:NnNT \g_@@_family_name_prop {#5} \l_@@_base_family_tl |
| 6128 |
{ \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } |
| 6129 |
\ctex_ltj_save_alternate_family:Nnnn #1 {#2} {#3} {#4} |
| 6130 |
} |
| 6131 |
\cs_generate_variant:Nn \ctex_ltj_set_alternate_family:Nnnnn { coo } |
| 6132 |
% \end{macrocode} |
| 6133 |
% \end{macro} |
| 6134 |
% |
| 6135 |
% \begin{macro}[int]{\ctex_ltj_save_alternate_family:Nnnn} |
| 6136 |
% 保存替代字体序列的定义,以备定义主字体时使用。 |
| 6137 |
% \begin{macrocode} |
| 6138 |
\cs_new_protected:Npn \ctex_ltj_save_alternate_family:Nnnn #1#2#3#4 |
| 6139 |
{ |
| 6140 |
\cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } |
| 6141 |
\cs_gset_protected:Npx #1 |
| 6142 |
{ \exp_not:o { #1 \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } } |
| 6143 |
} |
| 6144 |
% \end{macrocode} |
| 6145 |
% \end{macro} |
| 6146 |
% |
| 6147 |
% \begin{macro}[int]{\ctex_ltj_set_alternate_family:nnn} |
| 6148 |
% 实际定义替代字体族。 |
| 6149 |
% \begin{macrocode} |
| 6150 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnn #1#2#3 |
| 6151 |
{ |
| 6152 |
\group_begin: |
| 6153 |
\cs_set_eq:NN \CJKfamily \use_none:n |
| 6154 |
\ctex_ltj_swap_cs:NN |
| 6155 |
\DeclareFontShape@ \ctex_ltj_declare_alternate_shape:nnnnnn |
| 6156 |
\tl_set:Nn \l_@@_char_range_clist {#1} |
| 6157 |
\fontspec_set_family:Nnn \l_@@_alternate_family_tl {#2} {#3} |
| 6158 |
\group_end: |
| 6159 |
} |
| 6160 |
\tl_new:N \l_@@_alternate_family_tl |
| 6161 |
% \end{macrocode} |
| 6162 |
% \end{macro} |
| 6163 |
% |
| 6164 |
% \begin{macro}[int]{\ctex_ltj_swap_cs:NN} |
| 6165 |
% 交换两个控制序列的意义。 |
| 6166 |
% \begin{macrocode} |
| 6167 |
\cs_new_protected:Npn \ctex_ltj_swap_cs:NN #1#2 |
| 6168 |
{ |
| 6169 |
\cs_set_eq:NN \@@_tmp:w #1 |
| 6170 |
\cs_set_eq:NN #1 #2 |
| 6171 |
\cs_set_eq:NN #2 \@@_tmp:w |
| 6172 |
\cs_undefine:N \@@_tmp:w |
| 6173 |
} |
| 6174 |
% \end{macrocode} |
| 6175 |
% \end{macro} |
| 6176 |
% |
| 6177 |
% \begin{macro}[int]{LTJFONTUID} |
| 6178 |
% \begin{macro}{\@@_update_family_uid:N} |
| 6179 |
% \pkg{fontspec} 在一个字体族的选项和字体名称相同的时候,就不定义新字体。为了 |
| 6180 |
% 避免混淆替代字体的设置,我们新定义一个虚拟的选项 \opt{LTJFONTUID},确保 |
| 6181 |
% \pkg{fontspec} 对 CJK 字体族总是定义新字体。 |
| 6182 |
% \begin{macrocode} |
| 6183 |
\keys_define:nn { fontspec } { LTJFONTUID .code:n = } |
| 6184 |
\cs_new_protected:Npn \@@_update_family_uid:N #1 |
| 6185 |
{ |
| 6186 |
\int_gincr:N \g_@@_family_int |
| 6187 |
\clist_put_right:Nx #1 { LTJFONTUID = \int_use:N \g_@@_family_int } |
| 6188 |
} |
| 6189 |
\int_new:N \g_@@_family_int |
| 6190 |
% \end{macrocode} |
| 6191 |
% \end{macro} |
| 6192 |
% \end{macro} |
| 6193 |
% |
| 6194 |
% \begin{macro}[int]{\ctex_ltj_declare_alternate_shape:nnnnnn} |
| 6195 |
% 在定义替代字体的字形时,通过字符范围与主字体的对应字形关联起来。 |
| 6196 |
% \tn{DeclareFontShape@} 一个有六个参数,我们只需要使用它的第三个参数 \meta{series} |
| 6197 |
% 和第四个参数 \meta{shape}。 |
| 6198 |
% \begin{macrocode} |
| 6199 |
\cs_new_protected:Npn \ctex_ltj_declare_alternate_shape:nnnnnn #1#2#3#4#5#6 |
| 6200 |
{ |
| 6201 |
\ctex_ltj_declare_alternate_shape:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6} |
| 6202 |
\ctex_ltj_set_alternate_shape:Nnnnnnn \l_@@_char_range_clist |
| 6203 |
{ \l_@@_base_family_tl } {#3} {#4} {#2} {#3} {#4} |
| 6204 |
} |
| 6205 |
% \end{macrocode} |
| 6206 |
% \end{macro} |
| 6207 |
% |
| 6208 |
% \begin{macro}[int]{\ctex_ltj_set_alternate_shape:Nnnnnnn} |
| 6209 |
% 与 \pkg{LuaTeX-ja} 的 \tn{DeclareAlternateKanjiFont} 的功能类似,区别是固定编码 |
| 6210 |
% 为 \tn{CJK@encoding}。这个设置总是全局的。 |
| 6211 |
% \begin{macrocode} |
| 6212 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:Nnnnnnn #1#2#3#4#5#6#7 |
| 6213 |
{ |
| 6214 |
\clist_map_inline:Nn #1 |
| 6215 |
{ |
| 6216 |
\prop_get:NnNTF \g_@@_char_range_prop { ##1 } \l_@@_char_range_tl |
| 6217 |
{ |
| 6218 |
\ctex_ltj_set_alternate_shape:nnN { #2/#3/#4 } { #5/#6/#7 } |
| 6219 |
\l_@@_char_range_tl |
| 6220 |
} |
| 6221 |
{ \ctex_ltj_set_alternate_shape:nnn { #2/#3/#4 } { #5/#6/#7 } { ##1 } } |
| 6222 |
} |
| 6223 |
\@@_save_alternate_shape:cn |
| 6224 |
{ \@@_alternate_cs:n { clear / \l_@@_base_CJKfamily_tl } } |
| 6225 |
{ \ctex_ltj_clear_alt_font:n { \CJK@encoding/#2/#3/#4 } } |
| 6226 |
} |
| 6227 |
% \end{macrocode} |
| 6228 |
% \end{macro} |
| 6229 |
% |
| 6230 |
% \begin{macro}[int]{\ctex_ltj_set_alternate_shape:nnn} |
| 6231 |
% 我们使用 \texttt{->} 而不是像 \pkg{LuaTeX-ja} 一样使用 \texttt{-} 作为区间的 |
| 6232 |
% 分隔符。\pkg{LuaTeX-ja} 支持使用负数来引用由 \texttt{JFM} 设置的字符类。如果 |
| 6233 |
% 使用 \texttt{-} 作为分隔符,那么负数单独使用时,就需要把它放在两层花括号之内 |
| 6234 |
% (例如 |{{-1}}|),或者使用类似 |{-1}-{-1}| 的形式才不会解释错误。 |
| 6235 |
% \begin{macrocode} |
| 6236 |
\NewDocumentCommand \ctex_ltj_set_alternate_shape:nnn |
| 6237 |
{ m m > { \SplitArgument { 1 } { -> } } m } |
| 6238 |
{ \ctex_ltj_set_alternate_shape:nnnn {#1} {#2} #3 } |
| 6239 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnnn #1#2#3#4 |
| 6240 |
{ |
| 6241 |
\ctex_ltj_set_alternate_shape:e |
| 6242 |
{ |
| 6243 |
\@@_range_normalization:nn {#3} {#4} |
| 6244 |
{ \CJK@encoding / \exp_not:n {#2} } |
| 6245 |
{ \CJK@encoding / \exp_not:n {#1} } |
| 6246 |
} |
| 6247 |
} |
| 6248 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:n #1 |
| 6249 |
{ |
| 6250 |
\ctex_ltj_set_alt_font:nnnn #1 |
| 6251 |
\@@_save_alternate_shape:cn |
| 6252 |
{ \@@_alternate_cs:n { reset / \l_@@_base_CJKfamily_tl } } |
| 6253 |
{ \ctex_ltj_set_alt_font:nnnn #1 } |
| 6254 |
} |
| 6255 |
\cs_generate_variant:Nn \ctex_ltj_set_alternate_shape:n { e } |
| 6256 |
% \end{macrocode} |
| 6257 |
% \end{macro} |
| 6258 |
% |
| 6259 |
% \begin{macro}[int]{\ctex_ltj_set_alternate_shape:nnN} |
| 6260 |
% 若字符范围预先由 \texttt{declarecharrange} 声明,则可以直接使用。 |
| 6261 |
% \begin{macrocode} |
| 6262 |
\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnN #1#2#3 |
| 6263 |
{ |
| 6264 |
\tl_map_inline:Nn #3 |
| 6265 |
{ |
| 6266 |
\ctex_ltj_set_alternate_shape:n |
| 6267 |
{ |
| 6268 |
##1 |
| 6269 |
{ \CJK@encoding/#2 } |
| 6270 |
{ \CJK@encoding/#1 } |
| 6271 |
} |
| 6272 |
} |
| 6273 |
} |
| 6274 |
% \end{macrocode} |
| 6275 |
% \end{macro} |
| 6276 |
% |
| 6277 |
% \begin{macro}{\@@_save_alternate_shape:Nn} |
| 6278 |
% 将实际设置的替换字形保存起来用于清除或恢复。 |
| 6279 |
% 暂时令 \cs{l_@@_base_family_tl} 为 \cs{scan_stop:} 是让它不被展开,使得替换 |
| 6280 |
% 字体的设置可以在 \tn{addCJKfontfeature} 中直接使用。 |
| 6281 |
% \begin{macrocode} |
| 6282 |
\cs_new_protected:Npn \@@_save_alternate_shape:Nn #1#2 |
| 6283 |
{ |
| 6284 |
\group_begin: |
| 6285 |
\cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } |
| 6286 |
\cs_set_eq:NN \l_@@_base_family_tl \scan_stop: |
| 6287 |
\cs_gset_protected:Npx #1 { \exp_not:o {#1} #2 } |
| 6288 |
\group_end: |
| 6289 |
} |
| 6290 |
\cs_generate_variant:Nn \@@_save_alternate_shape:Nn { c } |
| 6291 |
% \end{macrocode} |
| 6292 |
% \end{macro} |
| 6293 |
% |
| 6294 |
% \begin{macro}{clearalternatefont,resetalternatefont} |
| 6295 |
% 清除和重置操作总是全局的。 |
| 6296 |
% \begin{macrocode} |
| 6297 |
\ctex_define:n |
| 6298 |
{ |
| 6299 |
clearalternatefont .code:n = |
| 6300 |
{ \clist_map_function:eN {#1} \ctex_ltj_clear_alternate_font:n } , |
| 6301 |
resetalternatefont .code:n = |
| 6302 |
{ \clist_map_function:eN {#1} \ctex_ltj_reset_alternate_font:n } , |
| 6303 |
clearalternatefont .default:n = \l_ctex_ltj_family_tl , |
| 6304 |
resetalternatefont .default:n = \l_ctex_ltj_family_tl |
| 6305 |
} |
| 6306 |
\cs_new_protected:Npn \ctex_ltj_clear_alternate_font:n #1 |
| 6307 |
{ |
| 6308 |
\group_begin: |
| 6309 |
\ctex_ltj_family_if_exist:xNTF {#1} \l_@@_base_family_tl |
| 6310 |
{ |
| 6311 |
\cs_if_exist_use:cT |
| 6312 |
{ \@@_alternate_cs:n { clear / #1 } } |
| 6313 |
{ |
| 6314 |
\prop_gput:Nno \g_@@_reset_alternate_prop |
| 6315 |
{#1} { \l_@@_base_family_tl } |
| 6316 |
\tl_set_eq:NN \CJK@family \l_@@_base_family_tl |
| 6317 |
\selectfont |
| 6318 |
} |
| 6319 |
} |
| 6320 |
{ \@@_family_unknown_warning:n {#1} } |
| 6321 |
\group_end: |
| 6322 |
} |
| 6323 |
\cs_new_protected:Npn \ctex_ltj_reset_alternate_font:n #1 |
| 6324 |
{ |
| 6325 |
\group_begin: |
| 6326 |
\prop_gpop:NnNT \g_@@_reset_alternate_prop {#1} \CJK@family |
| 6327 |
{ |
| 6328 |
\tl_set_eq:NN \l_@@_base_family_tl \CJK@family |
| 6329 |
\use:c { \@@_alternate_cs:n { reset / #1 } } |
| 6330 |
\selectfont |
| 6331 |
} |
| 6332 |
\group_end: |
| 6333 |
} |
| 6334 |
\prop_new:N \g_@@_reset_alternate_prop |
| 6335 |
\cs_generate_variant:Nn \clist_map_function:nN { e } |
| 6336 |
% \end{macrocode} |
| 6337 |
% \end{macro} |
| 6338 |
% |
| 6339 |
% \begin{macro}{declarecharrange} |
| 6340 |
% 预先声明字符范围。 |
| 6341 |
% \begin{macrocode} |
| 6342 |
\ctex_define:n |
| 6343 |
{ |
| 6344 |
declarecharrange .code:n = \ctex_ltj_declare_char_range:e {#1} , |
| 6345 |
declarecharrange .value_required:n = true |
| 6346 |
} |
| 6347 |
\cs_new_protected:Npn \ctex_ltj_declare_char_range:n #1 |
| 6348 |
{ \clist_map_inline:nn {#1} { \@@_declare_char_range:nn ##1 } } |
| 6349 |
\cs_generate_variant:Nn \ctex_ltj_declare_char_range:n { e } |
| 6350 |
\cs_new_protected:Npn \@@_declare_char_range:nn #1 |
| 6351 |
{ \tl_trim_spaces_apply:nN {#1} \ctex_ltj_declare_char_range:nn } |
| 6352 |
% \end{macrocode} |
| 6353 |
% \end{macro} |
| 6354 |
% |
| 6355 |
% \begin{macro}[int]{\ctex_ltj_declare_char_range:nn} |
| 6356 |
% \begin{variable}{\g_@@_char_range_prop} |
| 6357 |
% |#1| 是名字,|#2| 是范围。 |
| 6358 |
% \begin{macrocode} |
| 6359 |
\cs_new_protected:Npn \ctex_ltj_declare_char_range:nn #1#2 |
| 6360 |
{ |
| 6361 |
\tl_clear:N \l_@@_char_range_tl |
| 6362 |
\clist_map_function:nN {#2} \ctex_ltj_save_char_range:n |
| 6363 |
\prop_gput:Nno \g_@@_char_range_prop {#1} { \l_@@_char_range_tl } |
| 6364 |
\ctex_ltj_def_char_range_key:n {#1} |
| 6365 |
\tl_clear:N \l_@@_char_range_tl |
| 6366 |
} |
| 6367 |
\tl_new:N \l_@@_char_range_tl |
| 6368 |
\prop_new:N \g_@@_char_range_prop |
| 6369 |
% \end{macrocode} |
| 6370 |
% \end{variable} |
| 6371 |
% \end{macro} |
| 6372 |
% |
| 6373 |
% \begin{macro}[int]{\ctex_ltj_save_char_range:n} |
| 6374 |
% 预先解释字符区间的意义。 |
| 6375 |
% \begin{macrocode} |
| 6376 |
\NewDocumentCommand \ctex_ltj_save_char_range:n |
| 6377 |
{ > { \SplitArgument { 1 } { -> } } m } |
| 6378 |
{ \ctex_ltj_save_char_range:nn #1 } |
| 6379 |
\cs_new_protected:Npn \ctex_ltj_save_char_range:nn #1#2 |
| 6380 |
{ |
| 6381 |
\tl_put_right:Nx \l_@@_char_range_tl |
| 6382 |
{ { \@@_range_normalization:nn {#1} {#2} } } |
| 6383 |
} |
| 6384 |
\cs_new:Npn \@@_range_normalization:nn #1#2 |
| 6385 |
{ |
| 6386 |
\tl_if_novalue:nTF {#2} |
| 6387 |
{ |
| 6388 |
{ \int_eval:n {#1} } |
| 6389 |
{ \int_eval:n {#1} } |
| 6390 |
} |
| 6391 |
{ |
| 6392 |
{ \int_eval:n { \tl_if_blank:nTF {#1} { \c_@@_range_min_int } {#1} } } |
| 6393 |
{ \int_eval:n { \tl_if_blank:nTF {#2} { \c_@@_range_max_int } {#2} } } |
| 6394 |
} |
| 6395 |
} |
| 6396 |
\int_const:Nn \c_@@_range_min_int { "80 } |
| 6397 |
\int_const:Nn \c_@@_range_max_int { \c_max_char_int } |
| 6398 |
% \end{macrocode} |
| 6399 |
% \end{macro} |
| 6400 |
% |
| 6401 |
% \begin{macro}[int]{\ctex_ltj_def_char_range_key:n} |
| 6402 |
% 在字体设置选项中定义字符范围键。 |
| 6403 |
% \begin{macrocode} |
| 6404 |
\cs_new_protected:Npn \ctex_ltj_def_char_range_key:n #1 |
| 6405 |
{ |
| 6406 |
\keys_if_exist:nnF { ctex_ltj / fontspec } {#1} |
| 6407 |
{ |
| 6408 |
\keys_define:nn { ctex_ltj / fontspec } |
| 6409 |
{ #1 .code:n = \ctex_ltj_char_range_key:nn {#1} { ##1 } } |
| 6410 |
} |
| 6411 |
} |
| 6412 |
% \end{macrocode} |
| 6413 |
% \end{macro} |
| 6414 |
% |
| 6415 |
% \begin{macro}[int]{\ctex_ltj_char_range_key:nn} |
| 6416 |
% 如果字符范围键没有值,则只设置的这个字符范围内的替代字体。 |
| 6417 |
% \begin{macrocode} |
| 6418 |
\cs_new_protected:Npn \ctex_ltj_char_range_key:nn #1#2 |
| 6419 |
{ |
| 6420 |
\tl_if_blank:nTF {#2} |
| 6421 |
{ \clist_set:Nn \l_@@_char_range_clist {#1} } |
| 6422 |
{ \@@_push_alternate_prop:nn {#1} { {#1} #2 } } |
| 6423 |
} |
| 6424 |
% \end{macrocode} |
| 6425 |
% \end{macro} |
| 6426 |
% |
| 6427 |
% \paragraph{其他设置} |
| 6428 |
% |
| 6429 |
% 在抄录环境中禁用 \opt{autospacing} 和 \opt{autoxspacing}。然而,\pkg{LuaTeX-ja} |
| 6430 |
% 还是会使 JAchar 自动折行。没有看到有简单的禁用折行的办法,可能需要设置所有的 |
| 6431 |
% JAchar 的 \opt{prebreakpenalty} 或 \opt{postbreakpenalty} 为 \texttt{10000}: |
| 6432 |
% \begin{verbatim} |
| 6433 |
% \directlua |
| 6434 |
% { |
| 6435 |
% luatexja.isglobal = tex.globaldefs > 0 and "global" or "" |
| 6436 |
% for i = 0x80, 0x10FFFF do |
| 6437 |
% if luatexja.charrange.jcr_table_main[i] > 0 and |
| 6438 |
% luatexja.charrange.jcr_table_main[i] < 218 and |
| 6439 |
% luatexja.charrange.is_japanese_char_curlist(i) then |
| 6440 |
% luatexja.stack.set_stack_table(luatexja.stack_table_index.PRE + i, 10000) |
| 6441 |
% end |
| 6442 |
% end |
| 6443 |
% } |
| 6444 |
% \end{verbatim} |
| 6445 |
% \begin{macrocode} |
| 6446 |
\AtBeginDocument |
| 6447 |
{ |
| 6448 |
\ctex_appto_cmd:NnnTF \verbatim@font |
| 6449 |
{ \char_set_catcode_letter:n { 64 } } |
| 6450 |
{ \CTEX@verbatim@font@hook } |
| 6451 |
{ } |
| 6452 |
{ \ctex_patch_failure:N \verbatim@font } |
| 6453 |
} |
| 6454 |
\cs_new_protected:Npn \CTEX@verbatim@font@hook |
| 6455 |
{ \ltjsetparameter { autospacing = false , autoxspacing = false } } |
| 6456 |
% \end{macrocode} |
| 6457 |
% |
| 6458 |
% \begin{macro}{\@@@@italiccorr} |
| 6459 |
% \LaTeX{} 的倾斜校正也要重新定义。 |
| 6460 |
% \begin{macrocode} |
| 6461 |
\cs_set_eq:NN \@@@@italiccorr \/ |
| 6462 |
% \end{macrocode} |
| 6463 |
% \end{macro} |
| 6464 |
% |
| 6465 |
% \changes{v2.4.12}{2018/01/27}{正确使用 \tn{ltjsetkanjiskip} 和 \tn{ltjsetxkanjiskip}。} |
| 6466 |
% |
| 6467 |
% \begin{macro}[int]{\ctex_ltj_set_kanjiskip:N,\ctex_ltj_set_xkanjiskip:N} |
| 6468 |
% \tn{ltjsetkanjiskip} 和 \tn{ltjsetxkanjiskip} 是相应的 \tn{ltjsetparameter} |
| 6469 |
% 的快捷方式,在使用他们时,要注意先使用 \tn{ltj@setpar@global}。 |
| 6470 |
% \begin{macrocode} |
| 6471 |
\cs_new_protected:Npn \ctex_ltj_set_kanjiskip:N |
| 6472 |
{ \ltj@setpar@global \ltjsetkanjiskip } |
| 6473 |
\cs_new_protected:Npn \ctex_ltj_set_xkanjiskip:N |
| 6474 |
{ \ltj@setpar@global \ltjsetxkanjiskip } |
| 6475 |
% \end{macrocode} |
| 6476 |
% \end{macro} |
| 6477 |
% |
| 6478 |
% \begin{macrocode} |
| 6479 |
%<@@=ctex> |
| 6480 |
%</luatex> |
| 6481 |
% \end{macrocode} |
| 6482 |
% |
| 6483 |
% \subsubsection{\pkg{ctex-engine-uptex.def}} |
| 6484 |
% |
| 6485 |
% \begin{macrocode} |
| 6486 |
%<*uptex|aptex> |
| 6487 |
% \end{macrocode} |
| 6488 |
% |
| 6489 |
% \changes{v2.4}{2016/02/28}{初步支持 \upLaTeX。} |
| 6490 |
% \changes{v2.4.15}{2019/04/05}{显式补丁 \upLaTeX 的 \tn{rmfamily} 等字体命令。} |
| 6491 |
% |
| 6492 |
% 按 \pkg{CJK} 的命名习惯模拟 \tn{CJKfamily}。 |
| 6493 |
% \begin{macrocode} |
| 6494 |
\NewDocumentCommand \CJKfamily { m } |
| 6495 |
{ \kanjifamily {#1} \selectfont } |
| 6496 |
% \end{macrocode} |
| 6497 |
% |
| 6498 |
% \changes{v2.4.15}{2019/04/05}{将 \upLaTeX 的默认字体由 \texttt{mc} 改为 |
| 6499 |
% \texttt{zhrm},并启用 \tn{jfam}。} |
| 6500 |
% |
| 6501 |
% 将 \upLaTeX 的默认字体由 |mc| 改为 |zhrm|,并启用 \tn{jfam}。 |
| 6502 |
% \begin{macrocode} |
| 6503 |
\DeclareErrorKanjiFont {JY2}{zhrm}{m}{n}{10} |
| 6504 |
\DeclareKanjiSubstitution {JY2}{zhrm}{m}{n} |
| 6505 |
\DeclareKanjiSubstitution {JT2}{zhrm}{m}{n} |
| 6506 |
\DeclareSymbolFont{mincho}{JY2}{zhrm}{m}{n} |
| 6507 |
\SetSymbolFont{mincho}{bold}{JY2}{zhrm}{bx}{n} |
| 6508 |
\jfam \symmincho |
| 6509 |
% \end{macrocode} |
| 6510 |
% |
| 6511 |
% \begin{macro}[int]{\em} |
| 6512 |
% \changes{v2.4.2}{2016/05/15}{兼容 \upLaTeX{} 2016/05/07u00 的定义。} |
| 6513 |
% 取消 \upLaTeX{} 对 \tn{em} 使用 |\mcfamily|、|\gtfamily| 命令的重定义,恢复 |
| 6514 |
% \LaTeXe{} 对 \tn{em} 的原始定义。如果用户已经重定义了 \tn{em},则新定义保持 |
| 6515 |
% 不变。\upLaTeX{} 2016/05/07u00 的定义有所变化,这一行为可以由用户通过 \pkg{platexrelease} |
| 6516 |
% 包改变,需要分支处理。 |
| 6517 |
% \begin{macrocode} |
| 6518 |
\ctex_patch_cmd_once:NnnnTF \em |
| 6519 |
{ \ExplSyntaxOff } |
| 6520 |
{ \eminnershape \else \gtfamily \itshape } |
| 6521 |
{ \eminnershape \else \itshape } |
| 6522 |
{ } |
| 6523 |
{ |
| 6524 |
\ctex_patch_cmd:Nnn \em |
| 6525 |
{ \mcfamily \upshape \else \gtfamily \itshape } |
| 6526 |
{ \eminnershape \else \itshape } |
| 6527 |
} |
| 6528 |
\cs_set_nopar:Npn \eminnershape { \upshape } |
| 6529 |
% \end{macrocode} |
| 6530 |
% \end{macro} |
| 6531 |
% |
| 6532 |
% \changes{v2.4}{2016/04/24}{正确设置 \upTeX{} 下字体命令。} |
| 6533 |
% \begin{macro}[int]{\ctex_set_upfamily:nnn} |
| 6534 |
% 将 NFSS 字体族 |#1| 设置为 JFM 字体名 |#2|,粗体形式字体名 |#3|。其中字体名 |
| 6535 |
% 形如 |upzhserif|,不包括表示方向的后缀 |-h| 与 |-v|。粗体字体名为空时不设置该 |
| 6536 |
% 字形。本命令不设置字体映射,需要复用已有的字体映射或另行设置。 |
| 6537 |
% \begin{macrocode} |
| 6538 |
\cs_new_protected:Npn \ctex_set_upfamily:nnn #1#2#3 |
| 6539 |
{ |
| 6540 |
\DeclareKanjiFamily{JY2}{#1}{} |
| 6541 |
\DeclareKanjiFamily{JT2}{#1}{} |
| 6542 |
\DeclareFontShape{JY2}{#1}{m}{n}{<->~ #2-h}{} |
| 6543 |
\DeclareFontShape{JT2}{#1}{m}{n}{<->~ #2-v}{} |
| 6544 |
\tl_if_empty:nF {#3} |
| 6545 |
{ |
| 6546 |
\DeclareFontShape{JY2}{#1}{b}{n}{<->~ #3-h}{} |
| 6547 |
\DeclareFontShape{JT2}{#1}{b}{n}{<->~ #3-v}{} |
| 6548 |
\DeclareFontShape{JY2}{#1}{bx}{n}{<->~ #3-h}{} |
| 6549 |
\DeclareFontShape{JT2}{#1}{bx}{n}{<->~ #3-v}{} |
| 6550 |
} |
| 6551 |
} |
| 6552 |
% \end{macrocode} |
| 6553 |
% \end{macro} |
| 6554 |
% |
| 6555 |
% \begin{macro}[int]{\ctex_set_upmap:nnn} |
| 6556 |
% 设置 \upTeX{} 字体映射。|#1| 是形如 |upserif| 的 PS TFM 字体名,不带表示粗体 |
| 6557 |
% 的后缀 |b| 与表示排版方向的后缀 |-h| 与 |-v|。|#2| 与 |#3| 是普通与粗体的实际 |
| 6558 |
% 字体名。 |
| 6559 |
% \begin{macrocode} |
| 6560 |
\cs_new_protected:Npn \ctex_set_upmap:nnn #1#2#3 |
| 6561 |
{ |
| 6562 |
\ctex_set_zhmap:n |
| 6563 |
{ |
| 6564 |
\special { pdf:mapline~#1-h~UniGB-UTF16-H~#2 } |
| 6565 |
\special { pdf:mapline~#1-v~UniGB-UTF16-V~#2 } |
| 6566 |
\tl_if_empty:nF {#3} |
| 6567 |
{ |
| 6568 |
\special { pdf:mapline~#1b-h~UniGB-UTF16-H~#3 } |
| 6569 |
\special { pdf:mapline~#1b-v~UniGB-UTF16-V~#3 } |
| 6570 |
} |
| 6571 |
} |
| 6572 |
} |
| 6573 |
% \end{macrocode} |
| 6574 |
% \end{macro} |
| 6575 |
% |
| 6576 |
% \begin{macro}[int]{\ctex_set_upmap_unicode:nnn} |
| 6577 |
% 设置 \upTeX{} 字体映射,使用 |unicode| CMap。参数同上。 |
| 6578 |
% \begin{macrocode} |
| 6579 |
\cs_new_protected:Npn \ctex_set_upmap_unicode:nnn #1#2#3 |
| 6580 |
{ |
| 6581 |
\ctex_set_zhmap:n |
| 6582 |
{ |
| 6583 |
\special { pdf:mapline~#1-h~unicode~#2 } |
| 6584 |
\special { pdf:mapline~#1-v~unicode~#2 } |
| 6585 |
\tl_if_empty:nF {#3} |
| 6586 |
{ |
| 6587 |
\special { pdf:mapline~#1b-h~unicode~#3 } |
| 6588 |
\special { pdf:mapline~#1b-v~unicode~#3 } |
| 6589 |
} |
| 6590 |
} |
| 6591 |
} |
| 6592 |
% \end{macrocode} |
| 6593 |
% \end{macro} |
| 6594 |
% |
| 6595 |
% \begin{macro}[int]{\ctex_set_upfonts:nnnnnn} |
| 6596 |
% 设置 \upTeX{} 基本字体映射,按 \pkg{zhmetrics-uptex} 的定义,依次设置衬线体 |
| 6597 |
% 正、粗、意大利,无衬线体正、粗,等宽体正——共 6 种字体,并分横排及直排。 |
| 6598 |
% \begin{macrocode} |
| 6599 |
\cs_new_protected:Npn \ctex_set_upfonts:nnnnnn #1#2#3#4#5#6 |
| 6600 |
{ |
| 6601 |
\ctex_set_upmap:nnn { upserif } {#1} {#2} |
| 6602 |
\ctex_set_upmap:nnn { upserifit } {#3} {} |
| 6603 |
\ctex_set_upmap:nnn { upsans } {#4} {#5} |
| 6604 |
\ctex_set_upmap:nnn { upmono } {#6} {} |
| 6605 |
} |
| 6606 |
% \end{macrocode} |
| 6607 |
% \end{macro} |
| 6608 |
% |
| 6609 |
% 以下命令只能在导言区使用。 |
| 6610 |
% \begin{macrocode} |
| 6611 |
\@onlypreamble \ctex_set_upfamily:nnn |
| 6612 |
\@onlypreamble \ctex_set_upmap:nnn |
| 6613 |
\@onlypreamble \ctex_set_upmap_unicode:nnn |
| 6614 |
\@onlypreamble \ctex_set_upfonts:nnnnnn |
| 6615 |
% \end{macrocode} |
| 6616 |
% |
| 6617 |
% \changes{v2.4.7}{2016/12/27}{依赖 \pkg{pxeverysel} 宏包。} |
| 6618 |
% |
| 6619 |
% \pkg{everysel} 宏包(2011/10/28)未考虑 \upLaTeX{} 对 \tn{selectfont} 的修 |
| 6620 |
% 改,需要引入 \pkg{pxeverysel} 宏包。 |
| 6621 |
% \begin{macrocode} |
| 6622 |
\bool_if:NT \c_@@_everysel_loaded_bool |
| 6623 |
{ \RequirePackage { pxeverysel } } |
| 6624 |
% \end{macrocode} |
| 6625 |
% |
| 6626 |
% \begin{macrocode} |
| 6627 |
%</uptex|aptex> |
| 6628 |
% \end{macrocode} |
| 6629 |
% |
| 6630 |
% \subsubsection{修改主要字体命令} |
| 6631 |
% |
| 6632 |
% \changes{v2.5.2}{2020/05/06}{兼容 \LaTeX\ 2020-02-02 之前的版本。} |
| 6633 |
% \changes{v2.5.4}{2020/06/07}{修正主要字体命令补丁。} |
| 6634 |
% |
| 6635 |
% 修改 \tn{rmfamily} 等主要字体命令,使得中文字体能随西文主要字体更新。 |
| 6636 |
% \LaTeX\ 2020-02-02 以后的版本可以直接使用 \tn{@rmfamilyhook} 等钩子。 |
| 6637 |
% 我们暂时需要处理旧内核的情况,以保持兼容性。 |
| 6638 |
% |
| 6639 |
% \pkg{xeCJK} 和 \pkg{zhmCJK} 已经有相同的工作,本段代码不需要对他们使用。 |
| 6640 |
% \begin{macrocode} |
| 6641 |
%<*pdftex|luatex|uptex|aptex> |
| 6642 |
%<pdftex>\reverse_if:N \if_bool:N \g_@@_zhmCJK_bool |
| 6643 |
% \end{macrocode} |
| 6644 |
% |
| 6645 |
% \changes{v2.5.5}{2020/10/17}{进一步应用 \LaTeX\ 2020/10/01 的新钩子。} |
| 6646 |
% |
| 6647 |
% \begin{macro}[int]{\ctex_provide_font_hook:NNN,\CTEX@rmfamilyhook} |
| 6648 |
% 给 \tn{rmfamily} 等字体命令加钩子,钩子名字统一为 \tn{CTEX@rmfamilyhook} 等。 |
| 6649 |
% \begin{macrocode} |
| 6650 |
\cs_new_protected:Npn \ctex_provide_font_hook:NNN #1#2 |
| 6651 |
{ |
| 6652 |
\exp_args:Nc \@@_provide_font_hook_aux:NNNN |
| 6653 |
{ CTEX \cs_to_str:N #2 } #1#2 |
| 6654 |
} |
| 6655 |
\cs_if_exist:NTF \ctex_gadd_ltxhook:nn |
| 6656 |
{ |
| 6657 |
\cs_new_protected:Npn \@@_provide_font_hook_aux:NNNN #1#2#3#4 |
| 6658 |
{ |
| 6659 |
\tl_new:N #1 |
| 6660 |
\exp_args:Nx \ctex_gadd_ltxhook:nn { \cs_to_str:N #2 } {#1} |
| 6661 |
} |
| 6662 |
} |
| 6663 |
{ |
| 6664 |
\cs_new_protected:Npn \@@_provide_font_hook_aux:NNNN #1#2#3#4 |
| 6665 |
{ |
| 6666 |
\tl_new:N #1 |
| 6667 |
\cs_if_exist:NTF #3 |
| 6668 |
{ \tl_gput_right:Nn #3 {#1} } |
| 6669 |
% \end{macrocode} |
| 6670 |
% 注意此处不能用 \cs{ctex_patch_cmd:Nnn} 来打补丁,因其会关闭 \LaTeXiii 语法, |
| 6671 |
% 但 \pkg{fontspec} 会在 \tn{rmfamily} 的命令中相应加入 |
| 6672 |
% \cs{l__fontspec_rmfamily_encoding_tl} 等,导致补丁失败。 |
| 6673 |
% \begin{macrocode} |
| 6674 |
{ \ctex_parse_name:NN \tl_replace_once:Nnn #2 {#4} { #1#4 } } |
| 6675 |
} |
| 6676 |
} |
| 6677 |
\ctex_provide_font_hook:NNN \rmfamily \@rmfamilyhook \selectfont |
| 6678 |
\ctex_provide_font_hook:NNN \sffamily \@sffamilyhook \selectfont |
| 6679 |
\ctex_provide_font_hook:NNN \ttfamily \@ttfamilyhook \selectfont |
| 6680 |
%<pdftex|luatex>\ctex_provide_font_hook:NNN \normalfont \@defaultfamilyhook \usefont |
| 6681 |
% \end{macrocode} |
| 6682 |
% \end{macro} |
| 6683 |
% |
| 6684 |
% 按 \pkg{CJK} 的命名习惯模拟部分命令,并设置默认字体。 |
| 6685 |
% \begin{macrocode} |
| 6686 |
\tl_if_exist:NF \CJKfamilydefault |
| 6687 |
{ \tl_const:Nn \CJKfamilydefault { \CJKrmdefault } } |
| 6688 |
%<*pdftex|luatex> |
| 6689 |
\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { rm } } |
| 6690 |
\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { sf } } |
| 6691 |
\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { tt } } |
| 6692 |
\tl_gput_right:Nn \CTEX@rmfamilyhook { \CJKfamily { \CJKrmdefault } } |
| 6693 |
\tl_gput_right:Nn \CTEX@sffamilyhook { \CJKfamily { \CJKsfdefault } } |
| 6694 |
\tl_gput_right:Nn \CTEX@ttfamilyhook { \CJKfamily { \CJKttdefault } } |
| 6695 |
\tl_gput_right:Nn \CTEX@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } } |
| 6696 |
%</pdftex|luatex> |
| 6697 |
% \end{macrocode} |
| 6698 |
% \upLaTeX 不需要补丁 \tn{normalfont},只需要修改 \tn{kanjifamilydefault}。 |
| 6699 |
% \begin{macrocode} |
| 6700 |
%<*uptex|aptex> |
| 6701 |
\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { zhrm } } |
| 6702 |
\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { zhsf } } |
| 6703 |
\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { zhtt } } |
| 6704 |
\tl_gput_right:Nn \CTEX@rmfamilyhook { \kanjifamily { \CJKrmdefault } } |
| 6705 |
\tl_gput_right:Nn \CTEX@sffamilyhook { \kanjifamily { \CJKsfdefault } } |
| 6706 |
\tl_gput_right:Nn \CTEX@ttfamilyhook { \kanjifamily { \CJKttdefault } } |
| 6707 |
\tl_gset:Nn \kanjifamilydefault { \CJKfamilydefault } |
| 6708 |
%</uptex|aptex> |
| 6709 |
% \end{macrocode} |
| 6710 |
% |
| 6711 |
% \pkg{zhmCJK} 判断结束。 |
| 6712 |
% \begin{macrocode} |
| 6713 |
%<pdftex>\fi: |
| 6714 |
% \end{macrocode} |
| 6715 |
% |
| 6716 |
% 使修改立刻生效,保证导言区字体族正确。 |
| 6717 |
% \begin{macrocode} |
| 6718 |
\normalfont |
| 6719 |
% \end{macrocode} |
| 6720 |
% |
| 6721 |
% 在导言区末尾更新 \tn{CJKfamilydefault},\pdfTeX 已经在之前使用过此处代码。 |
| 6722 |
% \begin{macrocode} |
| 6723 |
%<!pdftex>\ctex_at_end_preamble:n { \ctex_update_default_family: } |
| 6724 |
% \end{macrocode} |
| 6725 |
% |
| 6726 |
% \changes{v2.4}{2016/02/15}{正确更新 \pkg{CJK} 包的 \tn{CJKfamilydefault}。} |
| 6727 |
% \changes{v2.4.1}{2016/04/26}{正确更新 \upLaTeX{} 的 \tn{CJKfamilydefault}。} |
| 6728 |
% |
| 6729 |
% \begin{macro}[int]{\ctex_update_default_family:} |
| 6730 |
% 在导言区结束,如果 \tn{CJKfamilydefault} 没有被更改,则在此时根据西文字体的情况 |
| 6731 |
% 更新 \tn{CJKfamilydefault}。\pkg{xeCJK} 已经有这个功能,不需要再调整。 |
| 6732 |
% \begin{macrocode} |
| 6733 |
\cs_new_protected:Npn \ctex_update_default_family: |
| 6734 |
{ |
| 6735 |
\tl_if_eq:NNT \CJKfamilydefault \l_@@_family_default_init_tl |
| 6736 |
{ |
| 6737 |
\group_begin: |
| 6738 |
\cs_set_eq:NN \@@_family_default_wrap:n \exp_not:n |
| 6739 |
\tl_gset:Nx \CJKfamilydefault |
| 6740 |
{ |
| 6741 |
\str_case:onF { \familydefault } |
| 6742 |
{ |
| 6743 |
{ \rmdefault } { \exp_not:N \CJKrmdefault } |
| 6744 |
{ \sfdefault } { \exp_not:N \CJKsfdefault } |
| 6745 |
{ \ttdefault } { \exp_not:N \CJKttdefault } |
| 6746 |
} |
| 6747 |
{ \CJKfamilydefault } |
| 6748 |
} |
| 6749 |
\group_end: |
| 6750 |
} |
| 6751 |
% \end{macrocode} |
| 6752 |
% 使用 \LuaLaTeX{} 时,自动调整得到的 \tn{CJKfamilydefault} 可能没有定义,需要 |
| 6753 |
% 确认它的存在性。使用 \pkg{CJK} 宏包或 \upLaTeX{} |
| 6754 |
% 时,\texttt{C19rm}、\texttt{JY2rm} 等总是有定义的,不需要确认。 |
| 6755 |
% \begin{macrocode} |
| 6756 |
%<luatex> \ctex_ltj_ensure_default_family: |
| 6757 |
} |
| 6758 |
% \end{macrocode} |
| 6759 |
% \end{macro} |
| 6760 |
% |
| 6761 |
% \begin{variable}{\l_@@_family_default_init_tl} |
| 6762 |
% 往 \tn{CJKfamilydefault} 中加入标志,用于判断它是否被更改。 |
| 6763 |
% \begin{macrocode} |
| 6764 |
\tl_new:N \l_@@_family_default_init_tl |
| 6765 |
\cs_new_eq:NN \@@_family_default_wrap:n \use:n |
| 6766 |
\tl_set:Nx \l_@@_family_default_init_tl |
| 6767 |
{ |
| 6768 |
\exp_not:N \@@_family_default_wrap:n |
| 6769 |
{ \exp_not:o { \CJKfamilydefault } } |
| 6770 |
} |
| 6771 |
\tl_gset_eq:NN \CJKfamilydefault \l_@@_family_default_init_tl |
| 6772 |
% \end{macrocode} |
| 6773 |
% \end{variable} |
| 6774 |
% |
| 6775 |
% \begin{macrocode} |
| 6776 |
%</pdftex|luatex|uptex|aptex> |
| 6777 |
% \end{macrocode} |
| 6778 |
% |
| 6779 |
% \changes{v2.0}{2014/04/16}{自动检测操作系统,载入对应的字体配置。} |
| 6780 |
% \changes{v2.5}{2019/10/25}{操作系统检测移动至载入中文字库处,且不再需要 |
| 6781 |
% 依赖特定引擎。} |
| 6782 |
% |
| 6783 |
% \subsubsection{\pkg{hyperref} 兼容性处理} |
| 6784 |
% |
| 6785 |
% \changes{v2.1}{2015/06/16}{不再设置 \pkg{hyperref} 宏包的 \opt{colorlinks} 选项。} |
| 6786 |
% |
| 6787 |
% 现在处理各个引擎下的 PDF 中文书签问题。根据编译引擎与文件编码的不 |
| 6788 |
% 同,\pkg{ctex} 向 \pkg{hyperref} 传递适当的参数,完成中文书签的正确设置。用 |
| 6789 |
% 户仍需要自己载入 \pkg{hyperref} 宏包。 |
| 6790 |
% |
| 6791 |
% \begin{macro}[int]{\ctex_hypersetup:n} |
| 6792 |
% 如果已经载入 \pkg{hyperref} 宏包,则直接使用其定义设置选项;否则 |
| 6793 |
% \cs{ctex_hypersetup:n} 的效果与 \tn{PassOptionsToPackage} 一致,只传递宏包参 |
| 6794 |
% 数。如果用户不载入 \pkg{hyperref} 宏包,相关参数即被丢弃。 |
| 6795 |
% \begin{macrocode} |
| 6796 |
%<*class|ctex> |
| 6797 |
\@ifpackageloaded { hyperref } |
| 6798 |
{ |
| 6799 |
\cs_new_protected:Npn \ctex_hypersetup:n #1 |
| 6800 |
{ \hypersetup {#1} } |
| 6801 |
} |
| 6802 |
{ |
| 6803 |
\cs_new_protected:Npn \ctex_hypersetup:n #1 |
| 6804 |
{ \PassOptionsToPackage {#1} { hyperref } } |
| 6805 |
} |
| 6806 |
%</class|ctex> |
| 6807 |
% \end{macrocode} |
| 6808 |
% \end{macro} |
| 6809 |
% |
| 6810 |
% \changes{v2.5.7}{2021/06/06}{禁用 \dvipdfmx\ 驱动的 \opt{unicode} 书签设置。} |
| 6811 |
% |
| 6812 |
% 在 \pdfTeX{} 下使用 \texttt{GBK} 编码,\dvipdfmx{} 驱动可以直接用它的 |
| 6813 |
% \tn{special} 命令,其他模式用 \pkg{xCJK2uni} 宏包处理。使用 \texttt{UTF-8} 编 |
| 6814 |
% 码时,\pkg{CJKutf8} 已经处理了书签问题,但仍需要设置 \opt{pdfencoding} 为 |
| 6815 |
% \opt{unicode},目的是在书签的开头写入 BOM (|\376\377|),提示这是 |
| 6816 |
% \texttt{UTF-16BE} 字节流。 |
| 6817 |
% \pkg{hyperref} 2021-02-04 版开始默认设置 \opt{unicode} 为 \opt{true}, |
| 6818 |
% 对于 \dvipdfmx\ 驱动,我们需要禁用这个设置,为此设置 \opt{pdfencoding} 为 \opt{pdfdoc}。 |
| 6819 |
% \begin{macrocode} |
| 6820 |
%<*pdftex> |
| 6821 |
\ctex_hypersetup:n { driverfallback = dvipdfmx } |
| 6822 |
\str_if_eq:onTF { \g_@@_encoding_tl } { GBK } |
| 6823 |
{ |
| 6824 |
\ctex_hypersetup:n { CJKbookmarks = true } |
| 6825 |
\sys_if_output_pdf:TF |
| 6826 |
{ \ctex_at_end_package:nn { hyperref } { \RequirePackage { xCJK2uni } } } |
| 6827 |
{ |
| 6828 |
\ctex_hypersetup:n { pdfencoding = pdfdoc } |
| 6829 |
\ctex_at_end_package:nn { hyperref } |
| 6830 |
{ |
| 6831 |
\str_if_eq:onTF { \Hy@driver } { hdvipdfm } |
| 6832 |
{ |
| 6833 |
\ctex_at_shipout_first:n |
| 6834 |
{ \special { pdf:tounicode~GBK-EUC-UCS2 } } |
| 6835 |
} |
| 6836 |
{ \RequirePackage { xCJK2uni } } |
| 6837 |
} |
| 6838 |
} |
| 6839 |
} |
| 6840 |
{ \ctex_hypersetup:n { pdfencoding = unicode } } |
| 6841 |
%</pdftex> |
| 6842 |
% \end{macrocode} |
| 6843 |
% \XeTeX 和 \LuaTeX 统一设置 \opt{pdfencoding} 为 \opt{unicode}。 |
| 6844 |
% \begin{macrocode} |
| 6845 |
%<*xetex|luatex> |
| 6846 |
\ctex_hypersetup:n { pdfencoding = unicode } |
| 6847 |
%</xetex|luatex> |
| 6848 |
% \end{macrocode} |
| 6849 |
% |
| 6850 |
% 我们假定 \upTeX{} 使用 \dvipdfmx{} 驱动输出,于是使用与 \pdfTeX{} 类似的设 |
| 6851 |
% 置。注意 \upTeX{} 需要使用 UTF8-UTF16 的编码转换。 |
| 6852 |
% \begin{macrocode} |
| 6853 |
%<*uptex|aptex> |
| 6854 |
\ctex_hypersetup:n |
| 6855 |
{ |
| 6856 |
driverfallback = dvipdfmx , |
| 6857 |
pdfencoding = pdfdoc |
| 6858 |
} |
| 6859 |
\ctex_at_end_package:nn { hyperref } |
| 6860 |
{ |
| 6861 |
\ctex_at_shipout_first:n |
| 6862 |
{ \special { pdf:tounicode~UTF8-UTF16 } } |
| 6863 |
} |
| 6864 |
%</uptex|aptex> |
| 6865 |
% \end{macrocode} |
| 6866 |
% |
| 6867 |
% \begin{macrocode} |
| 6868 |
%<*pdftex|xetex|luatex|uptex|aptex> |
| 6869 |
% \end{macrocode} |
| 6870 |
% |
| 6871 |
% \subsubsection{\pkg{CJKfntef}、\pkg{xeCJKfntef} 相关设置} |
| 6872 |
% |
| 6873 |
% \changes{v2.0}{2015/03/25}{默认关闭 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 的彩 |
| 6874 |
% 色设置。} |
| 6875 |
% \changes{v2.0}{2015/03/25}{\tn{CTEXunderdot}、\tn{CTEXunderline}、 |
| 6876 |
% \tn{CTEXunderdblline}、\tn{CTEXunderwave}、\tn{CTEXsout}、\tn{CTEXxout} 是过 |
| 6877 |
% 时命令;\env{CTEXfilltwosides} 是过时环境。} |
| 6878 |
% \changes{v2.5}{2019/11/10}{不再自动载入 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 宏包。} |
| 6879 |
% \changes{v2.5}{2019/11/10}{移除 \tn{CTEXunderdot}、\tn{CTEXunderline}、 |
| 6880 |
% \tn{CTEXunderdblline}、\tn{CTEXunderwave}、\tn{CTEXsout}、\tn{CTEXxout}、 |
| 6881 |
% \env{CTEXfilltwosides} 等命令和环境。} |
| 6882 |
% |
| 6883 |
% 对 \pdfTeX{} 与 \XeTeX{} 引擎,分别在 \pkg{CJKfntef}、\pkg{xeCJKfntef} 宏包 |
| 6884 |
% 的末尾关闭彩色显式等多余格式。 |
| 6885 |
% |
| 6886 |
% \begin{macrocode} |
| 6887 |
%<*pdftex> |
| 6888 |
\ctex_at_end_package:nn { CJKfntef } |
| 6889 |
{ |
| 6890 |
\normalem |
| 6891 |
\cs_new_protected:Npn \@@_clear_fntef_color:n #1 |
| 6892 |
{ \tl_clear:c { CJK#1color } } |
| 6893 |
%</pdftex> |
| 6894 |
%<*xetex> |
| 6895 |
\ctex_at_end_package:nn { xeCJKfntef } |
| 6896 |
{ |
| 6897 |
\@ifpackagelater { xeCJKfntef } { 2014/11/04 } |
| 6898 |
{ |
| 6899 |
\cs_new_protected:Npn \@@_clear_fntef_color:n #1 |
| 6900 |
{ \xeCJKsetup { #1 / format = { } } } |
| 6901 |
} |
| 6902 |
{ |
| 6903 |
\cs_new_protected:Npn \@@_clear_fntef_color:n #1 |
| 6904 |
{ \tl_clear:c { CJK#1color } } |
| 6905 |
} |
| 6906 |
%</xetex> |
| 6907 |
%<*pdftex|xetex> |
| 6908 |
\clist_map_inline:nn |
| 6909 |
{ underdot , underline , underdblline , underwave , sout , xout } |
| 6910 |
{ \@@_clear_fntef_color:n {#1} } |
| 6911 |
} |
| 6912 |
%</pdftex|xetex> |
| 6913 |
% \end{macrocode} |
| 6914 |
% |
| 6915 |
% \subsubsection{\tn{ccwd} 的更新} |
| 6916 |
% |
| 6917 |
% \begin{macro}[int]{\ctex_update_ccwd:,\ccwd} |
| 6918 |
% \changes{v2.4.1}{2016/04/29}{正确设置 \upTeX{} 下的 \tn{ccwd}。} |
| 6919 |
% \begin{macrocode} |
| 6920 |
\cs_new_protected:Npn \ctex_update_ccwd: |
| 6921 |
%<*pdftex|xetex> |
| 6922 |
{ |
| 6923 |
\hbox_set:Nn \l_@@_tmp_box { \CJKglue } |
| 6924 |
\dim_set:Nn \ccwd { \box_wd:N \l_@@_tmp_box + \f@size \p@ } |
| 6925 |
} |
| 6926 |
%</pdftex|xetex> |
| 6927 |
%<*luatex> |
| 6928 |
{ \skip_set:Nn \ccwd { \ltjgetparameter { kanjiskip } + \zw } } |
| 6929 |
%</luatex> |
| 6930 |
%<*uptex|aptex> |
| 6931 |
{ \skip_set:Nn \ccwd { 1zw + \tex_kanjiskip:D } } |
| 6932 |
%</uptex|aptex> |
| 6933 |
\dim_new:N \ccwd |
| 6934 |
% \end{macrocode} |
| 6935 |
% \end{macro} |
| 6936 |
% |
| 6937 |
% \begin{macro}[int]{\ctex_update_ccglue:} |
| 6938 |
% 更新字间距。 |
| 6939 |
% \begin{macrocode} |
| 6940 |
\cs_new_protected:Npn \ctex_update_ccglue: |
| 6941 |
%<*pdftex|xetex> |
| 6942 |
{ |
| 6943 |
\cs_set_protected:Npn \CJKglue |
| 6944 |
{ \skip_horizontal:N \l_@@_ccglue_skip } |
| 6945 |
} |
| 6946 |
%</pdftex|xetex> |
| 6947 |
%<*luatex> |
| 6948 |
{ \ctex_ltj_set_kanjiskip:N \l_@@_ccglue_skip } |
| 6949 |
%</luatex> |
| 6950 |
%<*uptex|aptex> |
| 6951 |
{ \skip_set_eq:NN \tex_kanjiskip:D \l_@@_ccglue_skip } |
| 6952 |
%</uptex|aptex> |
| 6953 |
\skip_new:N \l_@@_ccglue_skip |
| 6954 |
% \end{macrocode} |
| 6955 |
% \end{macro} |
| 6956 |
% |
| 6957 |
% \begin{macro}[int,pTF]{\ctex_if_ccglue_touched:} |
| 6958 |
% 检查用户是否修改过汉字间距。 |
| 6959 |
% \begin{macrocode} |
| 6960 |
\prg_new_conditional:Npnn \ctex_if_ccglue_touched: { TF } |
| 6961 |
{ |
| 6962 |
%<*pdftex|xetex> |
| 6963 |
\if_meaning:w \CJKglue \@@_ccglue: |
| 6964 |
\prg_return_false: \else: \prg_return_true: \fi: |
| 6965 |
%</pdftex|xetex> |
| 6966 |
%<*luatex> |
| 6967 |
\skip_if_eq:nnTF { \l_@@_ccglue_skip } { \ltjgetparameter { kanjiskip } } |
| 6968 |
{ \prg_return_false: } { \prg_return_true: } |
| 6969 |
%</luatex> |
| 6970 |
%<*uptex|aptex> |
| 6971 |
\skip_if_eq:nnTF { \l_@@_ccglue_skip } { \tex_kanjiskip:D } |
| 6972 |
{ \prg_return_false: } { \prg_return_true: } |
| 6973 |
%</uptex|aptex> |
| 6974 |
} |
| 6975 |
%<pdftex|xetex>\ctex_at_end:n { \cs_new_eq:NN \@@_ccglue: \CJKglue } |
| 6976 |
% \end{macrocode} |
| 6977 |
% \end{macro} |
| 6978 |
% |
| 6979 |
% \begin{macro}[int]{\ctex_update_em_unit:} |
| 6980 |
% 将当前汉字的宽度保存到 \tn{ccwd} 中备用。不采用 \texttt{1em},因为这时的 |
| 6981 |
% \texttt{1em} 实际上来自西文字体的信息,未必等于汉字的宽度,这似乎在传统的 |
| 6982 |
% \file{.tfm} 字体上表现更明显。在 \pdfTeX{} 和 \XeTeX{} 下,直接使用 |\f@size\p@| |
| 6983 |
% 作为汉字的宽度,这应该对大多数汉字字体都成立,但不适用于诸如“方正兰亭黑长”之类 |
| 6984 |
% 的特殊字体。在 \XeTeX{} 可以用 \tn{fontcharwd} 来改进。而在 \pdfTeX{} 下,若使用 |
| 6985 |
% \pkg{zhmetrics} 技术,所有的汉字共享同一个 \file{.tfm},\tn{fontcharwd} 也就没有 |
| 6986 |
% 意义。在 \LuaTeX{} 下,\pkg{LuaTeX-ja} 总是按照 JFM 中的设置输出汉字的宽度,可以 |
| 6987 |
% 直接用 \tn{zw} 作为汉字宽度。\upTeX{} 可以直接使用原生的长度单位 |zw|。 |
| 6988 |
% \begin{macrocode} |
| 6989 |
\cs_new_protected:Npn \ctex_update_em_unit: |
| 6990 |
%<pdftex|xetex> { \dim_set:Nn \ccwd { \f@size \p@ } } |
| 6991 |
%<luatex> { \dim_set:Nn \ccwd { \zw } } |
| 6992 |
%<uptex|aptex> { \dim_set:Nn \ccwd { 1zw } } |
| 6993 |
% \end{macrocode} |
| 6994 |
% \end{macro} |
| 6995 |
% |
| 6996 |
% \subsubsection{其他} |
| 6997 |
% |
| 6998 |
% \begin{macro}[int]{\ctex_add_to_selectfont:n,\CTEX@selectfont@hook} |
| 6999 |
% \changes{v2.4.13}{2018/03/23}{修正导言区 \tn{selectfont} 钩子位置。} |
| 7000 |
% \changes{v2.5}{2020/04/19}{兼容 \pkg{KOMA-Script} 的 \tn{selectfont} 补丁。} |
| 7001 |
% \begin{macrocode} |
| 7002 |
\cs_new_protected:Npn \ctex_add_to_selectfont:n #1 |
| 7003 |
{ |
| 7004 |
\cs_set_protected:Npx \CTEX@selectfont@hook |
| 7005 |
{ \exp_not:o { \CTEX@selectfont@hook #1 } } |
| 7006 |
} |
| 7007 |
\cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: |
| 7008 |
% \end{macrocode} |
| 7009 |
% 使用 \pkg{everysel} 包的情况。 |
| 7010 |
% \tn{EverySelectfont} 直到文档开始时才有效。为了 \tn{ccwd} 和 \pkg{LuaTeX-ja} 的 |
| 7011 |
% 字体设置在导言区也可用,我们还需要在这里手工修改 \tn{selectfont}。\pkg{everysel} |
| 7012 |
% 宏包会用 \tn{CheckCommand} 来检查 \tn{selectfont} 是否为标准定义。我们修改了 |
| 7013 |
% \tn{selectfont},所以会给出一个警告。为了消除这个警告,在它检查之前,还原本来 |
| 7014 |
% 定义。\pkg{pxeverysel} 宏包取消了检查,但也需要恢复定义,避免重复使用钩子。 |
| 7015 |
% \pkg{KOMA-Script} 宏包也会进行检查,我们需要小心处理。 |
| 7016 |
% \begin{macrocode} |
| 7017 |
\bool_if:NTF \c_@@_everysel_loaded_bool |
| 7018 |
{ |
| 7019 |
\cs_if_free:NF \@EverySelectfont@Init |
| 7020 |
{ |
| 7021 |
\group_begin: |
| 7022 |
\cs_set:Npn \@@_tmp:N #1 |
| 7023 |
{ |
| 7024 |
\tl_set:Nn \l_@@_tmp_tl {#1} |
| 7025 |
\cs_new_eq:NN \CTEX@selectfont@save #1 |
| 7026 |
\cs_new_protected:Npn \@@_restore_selectfont: |
| 7027 |
{ |
| 7028 |
\cs_if_free:NF \scr@new@selectfont |
| 7029 |
{ |
| 7030 |
% \end{macrocode} |
| 7031 |
% \pkg{CJK} 直接修改 \tn{selectfont} 和 \pkg{pxeverysel} 的补丁, |
| 7032 |
% 会使 \pkg{KOMA-Script} 的 \tn{par@update} 失效。 |
| 7033 |
% \begin{macrocode} |
| 7034 |
%<*pdftex|uptex|aptex> |
| 7035 |
\cs_if_free:NF \par@update |
| 7036 |
%<*uptex|aptex> |
| 7037 |
{ |
| 7038 |
\tl_put_right:Nn \@EverySelectfont@Init |
| 7039 |
{ \tl_put_right:Nn #1 { \par@update } } |
| 7040 |
} |
| 7041 |
%</uptex|aptex> |
| 7042 |
%<*pdftex> |
| 7043 |
{ \tl_put_right:Nn #1 { \par@update } } |
| 7044 |
\cs_set_eq:NN \scr@selectfont \CTEX@selectfont@save |
| 7045 |
%</pdftex> |
| 7046 |
%</pdftex|uptex|aptex> |
| 7047 |
\cs_set_eq:NN \scr@new@selectfont #1 |
| 7048 |
%<!pdftex> \cs_set_eq:NN \CTEX@selectfont@save \scr@selectfont |
| 7049 |
} |
| 7050 |
\tl_put_left:Nn \@EverySelectfont@Init |
| 7051 |
{ \cs_set_eq:NN #1 \CTEX@selectfont@save } |
| 7052 |
\cs_undefine:N \@@_restore_selectfont: |
| 7053 |
} |
| 7054 |
} |
| 7055 |
\ctex_parse_name:NN \@@_tmp:N \selectfont |
| 7056 |
\exp_last_unbraced:NNo \group_end: |
| 7057 |
\ctex_patch_cmd_once:NnnnTF { \l_@@_tmp_tl } |
| 7058 |
{ \ExplSyntaxOff } |
| 7059 |
{ \size@update } |
| 7060 |
{ \CTEX@selectfont@hook \size@update } |
| 7061 |
{ \@@_restore_selectfont: } |
| 7062 |
{ \ctex_patch_failure:N \selectfont } |
| 7063 |
} |
| 7064 |
\cs_new_protected:Npn \ctex_gadd_selectfont_hook:n |
| 7065 |
{ \EverySelectfont } |
| 7066 |
} |
| 7067 |
% \end{macrocode} |
| 7068 |
% 使用 \LaTeX \ 2021-06-01 的新钩子,不使用 \pkg{everysel} 包的情况。 |
| 7069 |
% \begin{macrocode} |
| 7070 |
{ |
| 7071 |
\cs_new_protected:Npn \ctex_gadd_selectfont_hook:n |
| 7072 |
{ \ctex_gadd_ltxhook:nn { selectfont } } |
| 7073 |
} |
| 7074 |
% \end{macrocode} |
| 7075 |
% \end{macro} |
| 7076 |
% |
| 7077 |
% \tn{CJK@plane} 有定义,说明处于 \pkg{CJK} 宏包的 \tn{CJKsymbol} 之内,不必使用钩子。 |
| 7078 |
% \begin{macrocode} |
| 7079 |
%<*pdftex> |
| 7080 |
\ctex_gadd_selectfont_hook:n |
| 7081 |
{ \cs_if_exist:NF \CJK@plane { \CTEX@selectfont@hook } } |
| 7082 |
%</pdftex> |
| 7083 |
%<*xetex|luatex|uptex|aptex> |
| 7084 |
\ctex_gadd_selectfont_hook:n { \CTEX@selectfont@hook } |
| 7085 |
%</xetex|luatex|uptex|aptex> |
| 7086 |
% \end{macrocode} |
| 7087 |
% |
| 7088 |
% Attribute 寄存器 \tn{ltj@curjfnt} 的初始值是 $-1$,必须把它设置为一个有效的 |
| 7089 |
% \texttt{font.id},否则编译时会直接退出。 |
| 7090 |
% \begin{macrocode} |
| 7091 |
%<*luatex> |
| 7092 |
\ctex_add_to_selectfont:n |
| 7093 |
{ |
| 7094 |
\ctex_ltj_select_font: |
| 7095 |
\ctex_ltj_select_alternate_font: |
| 7096 |
} |
| 7097 |
\tl_set:Nn \CJK@family { song } \selectfont |
| 7098 |
\tl_clear:N \CJK@family |
| 7099 |
%</luatex> |
| 7100 |
% \end{macrocode} |
| 7101 |
% |
| 7102 |
% \changes{v2.4.1}{2016/05/01}{随字体更新 \upTeX{} 的 \tn{xkanjiskip}。} |
| 7103 |
% |
| 7104 |
% \begin{macro}[int]{\ctex_update_xkanjiskip:} |
| 7105 |
% \begin{variable}{\l_@@_xkanjiskip_skip} |
| 7106 |
% \upTeX{} 和 \pkg{LuaTeX-ja} 对 \tn{xkanjiskip} 都是即时赋值。单位 \opt{zw} 与字体相关,因此 |
| 7107 |
% 需要每次 \tn{selectfont} 的时候更新一次 \tn{xkanjiskip}。如果用户设置过 |
| 7108 |
% \tn{xkanjiskip},就不更新。注意,同 \TeX{} 的 \tn{baselineskip} 一样,如果在 |
| 7109 |
% 一个段落内多次设置了 \tn{kanjiskip} 或 \tn{xkanjiskip},只有最后的设置会影响 |
| 7110 |
% 全段。 |
| 7111 |
% \begin{macrocode} |
| 7112 |
%<*luatex|uptex|aptex> |
| 7113 |
\cs_new_protected:Npn \ctex_update_xkanjiskip: |
| 7114 |
{ |
| 7115 |
\skip_if_eq:nnT |
| 7116 |
%<luatex> { \ltjgetparameter { xkanjiskip } } { \l_@@_xkanjiskip_skip } |
| 7117 |
%<uptex|aptex> { \tex_xkanjiskip:D } { \l_@@_xkanjiskip_skip } |
| 7118 |
{ |
| 7119 |
\skip_set:Nn \l_@@_xkanjiskip_skip { \l_@@_xkanjiskip_tl } |
| 7120 |
%<luatex> \ctex_ltj_set_xkanjiskip:N \l_@@_xkanjiskip_skip |
| 7121 |
%<uptex|aptex> \skip_set_eq:NN \tex_xkanjiskip:D \l_@@_xkanjiskip_skip |
| 7122 |
} |
| 7123 |
} |
| 7124 |
\tl_new:N \l_@@_xkanjiskip_tl |
| 7125 |
\tl_set:Nn \l_@@_xkanjiskip_tl |
| 7126 |
%<luatex> { .25\zw plus 1pt minus 1pt } |
| 7127 |
%<uptex|aptex> { .25zw plus 1pt minus 1pt } |
| 7128 |
\skip_new:N \l_@@_xkanjiskip_skip |
| 7129 |
\skip_set:Nn \l_@@_xkanjiskip_skip |
| 7130 |
%<luatex> { \ltjgetparameter { xkanjiskip } } |
| 7131 |
%<uptex|aptex> { \tex_xkanjiskip:D } |
| 7132 |
% \end{macrocode} |
| 7133 |
% \end{variable} |
| 7134 |
% \end{macro} |
| 7135 |
% |
| 7136 |
% \begin{macrocode} |
| 7137 |
\ctex_add_to_selectfont:n { \ctex_update_xkanjiskip: } |
| 7138 |
%</luatex|uptex|aptex> |
| 7139 |
% \end{macrocode} |
| 7140 |
% |
| 7141 |
% \changes{v2.4.10}{2017/07/23}{定义 \tn{cht},\tn{cdp} 和 \tn{cwd}。} |
| 7142 |
% |
| 7143 |
% \begin{macro}[int]{\cht,\cdp,\cwd,\ctex_update_kanjisize:} |
| 7144 |
% 分别从 \file{.jfm} 中读取字符高度、深度和宽度,目前仅考虑横排的情况。 |
| 7145 |
% \begin{macrocode} |
| 7146 |
%<*luatex> |
| 7147 |
\dim_new:N \cht |
| 7148 |
\dim_new:N \cdp |
| 7149 |
\dim_new:N \cwd |
| 7150 |
\group_begin: |
| 7151 |
\char_set_catcode_space:n { 32 } |
| 7152 |
\lua_now:e |
| 7153 |
{ |
| 7154 |
local nulltable = { } |
| 7155 |
local fmt = luatexja.jfont.font_metric_table |
| 7156 |
local getattribute = tex.getattribute |
| 7157 |
local setdimen = tex.setdimen |
| 7158 |
ctex.newluacmd("ctex_update_kanjisize:", function () |
| 7159 |
local ft = fmt[getattribute("ltj@curjfnt")] or nulltable |
| 7160 |
local ft = ft and ft.char_type or nulltable |
| 7161 |
local fk = ft and ft[0] or nulltable |
| 7162 |
setdimen("cht", fk.height or 0) |
| 7163 |
setdimen("cdp", fk.depth or 0) |
| 7164 |
setdimen("cwd", fk.width or ft.zw or 0) |
| 7165 |
end, "global", "protected") |
| 7166 |
} |
| 7167 |
\group_end: |
| 7168 |
\ctex_add_to_selectfont:n { \ctex_update_kanjisize: } |
| 7169 |
%</luatex> |
| 7170 |
% \end{macrocode} |
| 7171 |
% \end{macro} |
| 7172 |
% |
| 7173 |
% \begin{macro}{space} |
| 7174 |
% 在导言区或正文中设置忽略空格方式。 |
| 7175 |
% \pdfTeX{} 和 \XeTeX{} 下初始设置为 \opt{auto},\LuaTeX{}、\upTeX{} 下是无效 |
| 7176 |
% 选项。 |
| 7177 |
% \begin{macrocode} |
| 7178 |
\ctex_define:n |
| 7179 |
{ |
| 7180 |
%<*pdftex|xetex> |
| 7181 |
space .choice: , |
| 7182 |
space / true .code:n = |
| 7183 |
%<pdftex> { \ctex_ignorespaces_case:N \prg_do_nothing: } , |
| 7184 |
%<xetex> { \xeCJKsetup { CJKspace = true } } , |
| 7185 |
space / auto .code:n = |
| 7186 |
%<pdftex> { \ctex_ignorespaces_case:N \ctex_auto_ignorespaces: } , |
| 7187 |
%<xetex> { \xeCJKsetup { CJKspace = false } } , |
| 7188 |
space / false .code:n = |
| 7189 |
%<pdftex> { \ctex_ignorespaces_case:N \tex_ignorespaces:D } , |
| 7190 |
%<xetex> { \xeCJKsetup { CJKspace = false } } , |
| 7191 |
space .default:n = { true } , |
| 7192 |
space .initial:n = { auto } |
| 7193 |
%</pdftex|xetex> |
| 7194 |
%<*luatex|uptex|aptex> |
| 7195 |
space .code:n = |
| 7196 |
{ \msg_warning:nn { ctex } { invalid-option } } |
| 7197 |
%</luatex|uptex|aptex> |
| 7198 |
} |
| 7199 |
% \end{macrocode} |
| 7200 |
% \end{macro} |
| 7201 |
% |
| 7202 |
% \begin{macro}{punct} |
| 7203 |
% 在导言区或正文中设置标点符号输出格式。\pkg{LuaTeX-ja} 设置的是字体的默认 \texttt{JFM}, |
| 7204 |
% 只会影响到之后设置的字体。\upTeX{} 暂时无效。 |
| 7205 |
% \begin{macrocode} |
| 7206 |
\ctex_define:n |
| 7207 |
{ |
| 7208 |
punct .code:n = |
| 7209 |
{ |
| 7210 |
\tl_set:Nx \l_@@_punct_tl {#1} |
| 7211 |
%<pdftex> \punctstyle { \l_@@_punct_tl } |
| 7212 |
%<xetex> \xeCJKsetup { PunctStyle = \l_@@_punct_tl } |
| 7213 |
%<luatex> \ctex_set_jfm:o { \l_@@_punct_tl } |
| 7214 |
%<uptex|aptex> \msg_warning:nn { ctex } { invalid-option } |
| 7215 |
} , |
| 7216 |
punct .default:n = { quanjiao } , |
| 7217 |
} |
| 7218 |
% \end{macrocode} |
| 7219 |
% \end{macro} |
| 7220 |
% |
| 7221 |
% \begin{macrocode} |
| 7222 |
%</pdftex|xetex|luatex|uptex|aptex> |
| 7223 |
% \end{macrocode} |
| 7224 |
% |
| 7225 |
% \subsubsection{载入引擎定义文件} |
| 7226 |
% |
| 7227 |
% 最后载入各个编译引擎的定义文件。 |
| 7228 |
% \begin{macrocode} |
| 7229 |
%<class|ctex>\ctex_file_input:n { \c_@@_engine_file_str } |
| 7230 |
% \end{macrocode} |
| 7231 |
% |
| 7232 |
% \subsection{用户设置接口} |
| 7233 |
% |
| 7234 |
% \changes{v2.0}{2014/03/18}{新增统一设置接口 \tn{ctexset}。} |
| 7235 |
% \changes{v2.4.12}{2018/01/14} |
| 7236 |
% {修正 \tn{ctexset} 在 \pkg{ctexheading} 包中无定义的错误(曾祥东)。 } |
| 7237 |
% |
| 7238 |
% \begin{macro}{\ctexset} |
| 7239 |
% \begin{macrocode} |
| 7240 |
%<*class|ctex|ctexheading> |
| 7241 |
\NewDocumentCommand \ctexset { } { \ctex_set:n } |
| 7242 |
%</class|ctex|ctexheading> |
| 7243 |
% \end{macrocode} |
| 7244 |
% \end{macro} |
| 7245 |
% |
| 7246 |
% \changes{v2.0}{2015/03/21}{\tn{CTEXsetup}, \tn{CTEXoptions} 是过时命令。} |
| 7247 |
% \begin{macro}{\CTEXsetup,\CTEXoptions} |
| 7248 |
% 过时命令。 |
| 7249 |
% \begin{macrocode} |
| 7250 |
%<*class|ctex> |
| 7251 |
\NewDocumentCommand \CTEXsetup { +O { } > { \TrimSpaces } m } |
| 7252 |
{ |
| 7253 |
\tl_if_blank:nTF {#1} |
| 7254 |
{ \ctex_deprecated_command:Nn \CTEXsetup { } } |
| 7255 |
{ |
| 7256 |
\ctex_deprecated_command:Nn \CTEXsetup |
| 7257 |
{ \ctexset {~#2~=~{~#1~}~}~is~set. } |
| 7258 |
\ctex_set:nn {#2} {#1} |
| 7259 |
} |
| 7260 |
} |
| 7261 |
\NewDocumentCommand \CTEXoptions { +O { } } |
| 7262 |
{ |
| 7263 |
\tl_if_blank:nTF {#1} |
| 7264 |
{ \ctex_deprecated_command:Nn \CTEXoptions { } } |
| 7265 |
{ |
| 7266 |
\ctex_deprecated_command:Nn \CTEXoptions |
| 7267 |
{ \ctexset {~#1~}~is~set. } |
| 7268 |
\ctex_set:n {#1} |
| 7269 |
} |
| 7270 |
} |
| 7271 |
% \end{macrocode} |
| 7272 |
% \end{macro} |
| 7273 |
% |
| 7274 |
% \subsection{字距与缩进} |
| 7275 |
% |
| 7276 |
% \begin{macro}{autoindent} |
| 7277 |
% \opt{autoindent} 也是可以用在正文中的选项,意义与宏包选项 |option/autoindent| 相同。 |
| 7278 |
% \begin{macrocode} |
| 7279 |
\ctex_define:n |
| 7280 |
{ |
| 7281 |
autoindent .choice: , |
| 7282 |
autoindent .default:n = { true } , |
| 7283 |
autoindent / true .code:n = |
| 7284 |
{ |
| 7285 |
\tl_set:Nn \l_@@_autoindent_tl { 2 \ccwd } |
| 7286 |
\ctex_select_size: |
| 7287 |
} , |
| 7288 |
autoindent / false .code:n = |
| 7289 |
{ \tl_clear:N \l_@@_autoindent_tl } , |
| 7290 |
autoindent / unknown .code:n = |
| 7291 |
{ |
| 7292 |
\ctex_set_default_ccwd:Nn \l_@@_autoindent_tl {#1} |
| 7293 |
\ctex_select_size: |
| 7294 |
} |
| 7295 |
} |
| 7296 |
% \end{macrocode} |
| 7297 |
% \end{macro} |
| 7298 |
% |
| 7299 |
% \begin{macro}{\CTEXsetfont} |
| 7300 |
% 无论字体大小是否变化都更新相关信息。 |
| 7301 |
% \begin{macrocode} |
| 7302 |
\NewDocumentCommand \CTEXsetfont { } { \ctex_select_size: } |
| 7303 |
\cs_new_protected:Npn \ctex_select_size: |
| 7304 |
{ \cs_if_free:NTF \size@update { \ctex_update_size: } { \selectfont } } |
| 7305 |
% \end{macrocode} |
| 7306 |
% \end{macro} |
| 7307 |
% |
| 7308 |
% \begin{macro}[int]{\ctex_update_size:} |
| 7309 |
% 在字号变化时更新 \tn{ccwd}、\tn{parindent} 和汉字间距。字距为零则恢复正常设置。 |
| 7310 |
% \begin{macrocode} |
| 7311 |
\cs_new_protected:Npn \ctex_update_size: |
| 7312 |
{ |
| 7313 |
\tl_if_eq:NNTF \l_@@_ziju_tl \c_@@_zero_tl |
| 7314 |
{ |
| 7315 |
\ctex_update_stretch: |
| 7316 |
\ctex_update_parindent: |
| 7317 |
} |
| 7318 |
{ \ctex_update_ziju: } |
| 7319 |
} |
| 7320 |
\tl_const:Nx \c_@@_zero_tl { \fp_use:N \c_zero_fp } |
| 7321 |
\tl_new:N \l_@@_ziju_tl |
| 7322 |
\tl_set_eq:NN \l_@@_ziju_tl \c_@@_zero_tl |
| 7323 |
% \end{macrocode} |
| 7324 |
% 在 \tn{selectfont} 中,若 \tn{size@update} 为 \tn{relax},说明字体大小没有变化, |
| 7325 |
% 我们也就不用更新相关参数。 |
| 7326 |
% \begin{macrocode} |
| 7327 |
\ctex_add_to_selectfont:n |
| 7328 |
{ \cs_if_free:NF \size@update { \ctex_update_size: } } |
| 7329 |
% \end{macrocode} |
| 7330 |
% \end{macro} |
| 7331 |
% |
| 7332 |
% \changes{v2.0}{2014/03/26}{新增 \opt{linestretch} 选项。} |
| 7333 |
% |
| 7334 |
% \begin{macro}{linestretch} |
| 7335 |
% 若行宽不是汉字宽度的整数倍,自然要求伸展它们之间的差。这里设置的是在此基础上的 |
| 7336 |
% 额外伸展量。初始化为一个汉字的宽度。若设置为 \tn{maxdimen},则禁用此功能。 |
| 7337 |
% 参数的默认单位是汉字的宽度 \tn{ccwd}。 |
| 7338 |
% \begin{macrocode} |
| 7339 |
\ctex_define:n |
| 7340 |
{ |
| 7341 |
linestretch .code:n = |
| 7342 |
{ |
| 7343 |
\ctex_set_default_ccwd:Nn \l_@@_line_stretch_tl {#1} |
| 7344 |
\ctex_select_size: |
| 7345 |
} , |
| 7346 |
linestretch .value_required:n = true |
| 7347 |
} |
| 7348 |
\tl_new:N \l_@@_line_stretch_tl |
| 7349 |
\tl_set:Nn \l_@@_line_stretch_tl { \ccwd } |
| 7350 |
% \end{macrocode} |
| 7351 |
% \end{macro} |
| 7352 |
% |
| 7353 |
% \begin{macro}[int]{\ctex_update_stretch:} |
| 7354 |
% 首先计算一行上汉字的字数,\tn{CJKglue} 相当于将 \tn{linewidth} 与汉字总宽度之差 |
| 7355 |
% 均匀地填充到汉字之间。\hologo{eTeX} 的除法是四舍五入,而我们这里应该用截断。由于 |
| 7356 |
% 没有可展性的要求,直接用原语 \cs{tex_divide:D} 要比 \cs{int_div_truncate:nn} |
| 7357 |
% 快一些。下面的算法还兼顾到了 \tn{linewidth} 不为汉字字宽的整数倍的情况。 |
| 7358 |
% 若用户禁用 \opt{linestretch} 并且修改过 \tn{CJKglue},则只更新 |
| 7359 |
% \tn{ccwd},否则设置伸展量为 $0.08$ 倍 \tn{baselineskip}。注意 \pkg{everysel} 的 |
| 7360 |
% 钩子位于 \tn{size@update} 之前,\tn{baselineskip} 还未更新,不能直接使用它。 |
| 7361 |
% \begin{macrocode} |
| 7362 |
\cs_new_protected:Npn \ctex_update_stretch: |
| 7363 |
{ |
| 7364 |
\ctex_update_em_unit: |
| 7365 |
\dim_set:Nn \l_@@_tmp_dim { \l_@@_line_stretch_tl } |
| 7366 |
\dim_compare:nNnTF \l_@@_tmp_dim = \c_max_dim |
| 7367 |
{ \@@_update_stretch_auxi: } |
| 7368 |
{ \@@_update_stretch_auxii: } |
| 7369 |
} |
| 7370 |
\cs_new_protected:Npn \@@_update_stretch_auxi: |
| 7371 |
{ |
| 7372 |
\ctex_if_ccglue_touched:TF |
| 7373 |
{ \ctex_update_ccwd: } |
| 7374 |
{ |
| 7375 |
\dim_set:Nn \l_@@_tmp_dim |
| 7376 |
{ \baselinestretch \tex_glueexpr:D \f@baselineskip \scan_stop: } |
| 7377 |
\skip_set:Nn \l_@@_ccglue_skip |
| 7378 |
{ \c_zero_dim plus .08 \l_@@_tmp_dim } |
| 7379 |
\ctex_update_ccglue: |
| 7380 |
} |
| 7381 |
} |
| 7382 |
\cs_new_protected:Npn \@@_update_stretch_auxii: |
| 7383 |
{ |
| 7384 |
\int_set:Nn \l_@@_tmp_int |
| 7385 |
{ \tex_dimexpr:D \linewidth - \ccwd - \l_@@_tmp_dim \scan_stop: } |
| 7386 |
\tex_divide:D \l_@@_tmp_int \ccwd |
| 7387 |
\int_compare:nNnTF \l_@@_tmp_int > \c_zero_int |
| 7388 |
{ |
| 7389 |
\skip_set:Nn \l_@@_ccglue_skip |
| 7390 |
{ |
| 7391 |
\c_zero_dim plus \dim_eval:n |
| 7392 |
{ |
| 7393 |
( \linewidth - \ccwd - \l_@@_tmp_int \ccwd ) / |
| 7394 |
\l_@@_tmp_int |
| 7395 |
} |
| 7396 |
} |
| 7397 |
} |
| 7398 |
{ \skip_zero:N \l_@@_ccglue_skip } |
| 7399 |
\ctex_update_ccglue: |
| 7400 |
} |
| 7401 |
% \end{macrocode} |
| 7402 |
% \end{macro} |
| 7403 |
% |
| 7404 |
% \begin{macro}[int]{\ctex_update_parindent:} |
| 7405 |
% 更新段落首行缩进。此函数在字号变化时调用。 |
| 7406 |
% \begin{macrocode} |
| 7407 |
\cs_new_protected:Npn \ctex_update_parindent: |
| 7408 |
{ |
| 7409 |
\tl_if_empty:NF \l_@@_autoindent_tl |
| 7410 |
{ |
| 7411 |
\dim_compare:nNnF \parindent = \c_zero_dim |
| 7412 |
{ \dim_set:Nn \parindent { \l_@@_autoindent_tl } } |
| 7413 |
} |
| 7414 |
} |
| 7415 |
% \end{macrocode} |
| 7416 |
% \end{macro} |
| 7417 |
% |
| 7418 |
% \begin{macro}{\ziju} |
| 7419 |
% 若参数为 $0$,则恢复正常间距。 |
| 7420 |
% \begin{macrocode} |
| 7421 |
\NewDocumentCommand \ziju { m } |
| 7422 |
{ \exp_args:Nx \ctex_ziju:n {#1} \tex_ignorespaces:D } |
| 7423 |
\cs_new_protected:Npn \ctex_ziju:n #1 |
| 7424 |
{ |
| 7425 |
\tl_set:Nx \l_@@_ziju_tl { \fp_eval:n {#1} } |
| 7426 |
\ctex_select_size: |
| 7427 |
} |
| 7428 |
% \end{macrocode} |
| 7429 |
% \end{macro} |
| 7430 |
% |
| 7431 |
% \begin{macro}[int]{\ctex_update_ziju:} |
| 7432 |
% 更新字距。若字距不大于 $-1$,即 \tn{ccwd} 为非正值,则不计算伸缩值。 |
| 7433 |
% 否则,首先假定汉字的宽度为正常宽度加上字距,看一行上能正常放下多少个汉字。 |
| 7434 |
% \begin{macrocode} |
| 7435 |
\cs_new_protected:Npn \ctex_update_ziju: |
| 7436 |
{ |
| 7437 |
\ctex_update_em_unit: |
| 7438 |
\dim_set:Nn \l_@@_ziju_dim { \l_@@_ziju_tl \ccwd } |
| 7439 |
\dim_add:Nn \ccwd { \l_@@_ziju_dim } |
| 7440 |
\dim_compare:nNnTF \ccwd > \c_zero_dim |
| 7441 |
% \end{macrocode} |
| 7442 |
% 伸展量保证行内的剩余空白能够被均匀地填充到汉字之间,收缩的最大限度是让当前行 |
| 7443 |
% 还能够再挤下一个汉字并且不会出现负间距。由 \TeX{} 决定伸展还是收缩。 |
| 7444 |
% \begin{macrocode} |
| 7445 |
{ |
| 7446 |
\dim_set:Nn \l_@@_tmp_dim |
| 7447 |
{ \linewidth - \ccwd + \l_@@_ziju_dim } |
| 7448 |
\int_set:Nn \l_@@_tmp_int { \l_@@_tmp_dim } |
| 7449 |
\tex_divide:D \l_@@_tmp_int \ccwd |
| 7450 |
\dim_sub:Nn \l_@@_tmp_dim { \l_@@_tmp_int \ccwd } |
| 7451 |
% \end{macrocode} |
| 7452 |
% 由于 \tn{parindent} 是一个固定值,并不参与伸缩,容易导致第一行出现坏盒子。 |
| 7453 |
% 我们在这里将字数减去 $2$,以此放大伸缩值。 |
| 7454 |
% \begin{macrocode} |
| 7455 |
\dim_compare:nNnF \parindent = \c_zero_dim |
| 7456 |
{ |
| 7457 |
\int_compare:nNnF \l_@@_tmp_int < 3 |
| 7458 |
{ \int_sub:Nn \l_@@_tmp_int { 2 } } |
| 7459 |
} |
| 7460 |
\skip_set:Nn \l_@@_ccglue_skip |
| 7461 |
{ |
| 7462 |
\l_@@_ziju_dim |
| 7463 |
plus \dim_eval:n { \l_@@_tmp_dim / \l_@@_tmp_int } |
| 7464 |
minus \dim_min:nn { \dim_abs:n { \l_@@_ziju_dim } } |
| 7465 |
{ ( \ccwd - \l_@@_tmp_dim ) / ( \l_@@_tmp_int + 1 ) } |
| 7466 |
} |
| 7467 |
} |
| 7468 |
{ \skip_set:Nn \l_@@_ccglue_skip { \l_@@_ziju_dim } } |
| 7469 |
\ctex_update_ccglue: |
| 7470 |
% \end{macrocode} |
| 7471 |
% 字距设置得比较大时,为了尽量保证段首缩进能够与下一行对齐,应该需要相应地加上 |
| 7472 |
% 或者减去伸缩值。但是这里并不清楚 \TeX{} 是伸展还是收缩,之前以“当前行是否还 |
| 7473 |
% 放得下一个汉字”为标准加上或减去伸缩值的做法也未必与实际结果一致,所以只好还 |
| 7474 |
% 是设置为 |2\ccwd|。 |
| 7475 |
% \begin{macrocode} |
| 7476 |
\ctex_update_parindent: |
| 7477 |
} |
| 7478 |
\dim_new:N \l_@@_ziju_dim |
| 7479 |
% \end{macrocode} |
| 7480 |
% \end{macro} |
| 7481 |
% |
| 7482 |
% \changes{v2.0}{2015/03/21}{\tn{CTEXindent}, \tn{CTEXnoindent} 是过时命令。} |
| 7483 |
% \begin{macro}{\CTEXindent,\CTEXnoindent} |
| 7484 |
% 过时命令。 |
| 7485 |
% \begin{macrocode} |
| 7486 |
\NewDocumentCommand \CTEXindent { } |
| 7487 |
{ |
| 7488 |
\ctex_deprecated_command:Nn \CTEXindent |
| 7489 |
{ \parindent is~set~to~2\ccwd. } |
| 7490 |
\ctex_update_ccwd: |
| 7491 |
\dim_set:Nn \parindent { 2 \ccwd } |
| 7492 |
} |
| 7493 |
\NewDocumentCommand \CTEXnoindent { } |
| 7494 |
{ |
| 7495 |
\ctex_deprecated_command:Nn \CTEXnoindent |
| 7496 |
{ \parindent is~set~to~0pt. } |
| 7497 |
\dim_zero:N \parindent |
| 7498 |
} |
| 7499 |
% \end{macrocode} |
| 7500 |
% \end{macro} |
| 7501 |
% |
| 7502 |
% \subsection{中文数字与日期} |
| 7503 |
% |
| 7504 |
% 需要注意的是,\pkg{ltkeys} 设置的选项列表是 |
| 7505 |
% |\@raw@opt@|\meta{\textbackslash @currname}|.|\meta{\textbackslash @currext}, |
| 7506 |
% 该列表不会将 \tn{PassOptionsToPackage} 传递的选项完全展开。 |
| 7507 |
% \begin{macrocode} |
| 7508 |
\exp_args:Ne \PassOptionsToPackage |
| 7509 |
{ encoding = \g_@@_encoding_tl } |
| 7510 |
{ zhnumber } |
| 7511 |
\RequirePackage { zhnumber } |
| 7512 |
% \end{macrocode} |
| 7513 |
% |
| 7514 |
% \begin{macro}{\chinese} |
| 7515 |
% \changes{v2.4.1}{2016/05/01}{支持 \tn{pagenumbering}。} |
| 7516 |
% \begin{macrocode} |
| 7517 |
\cs_new:Npn \chinese { \zhnum_counter:n } |
| 7518 |
\cs_new_eq:NN \@chinese \@zhnum |
| 7519 |
\cs_new_eq:NN \Chinese \chinese |
| 7520 |
\cs_new_eq:NN \CTEXcounter \use_none:n |
| 7521 |
% \end{macrocode} |
| 7522 |
% \end{macro} |
| 7523 |
% |
| 7524 |
% \changes{v2.2}{2015/06/29}{给 \pkg{enumitem} 宏包注册 \tn{chinese} 和 |
| 7525 |
% \tn{zhnum}。} |
| 7526 |
% |
| 7527 |
% 给 \pkg{enumitem} 宏包注册 \tn{chinese}、\tn{zhnum} 和 \tn{zhdig}。 |
| 7528 |
% \begin{macrocode} |
| 7529 |
\ctex_at_end_package:nn { enumitem } |
| 7530 |
{ |
| 7531 |
\cs_if_free:NF \AddEnumerateCounter |
| 7532 |
{ |
| 7533 |
\AddEnumerateCounter * { \zhnum } { \@zhnum } { 1 } |
| 7534 |
\AddEnumerateCounter * { \zhdig } { \@zhdig } { 1 } |
| 7535 |
\AddEnumerateCounter * { \chinese } { \@chinese } { 1 } |
| 7536 |
} |
| 7537 |
} |
| 7538 |
% \end{macrocode} |
| 7539 |
% |
| 7540 |
% \begin{macro}{\CTEXnumber,\CTEXdigits} |
| 7541 |
% \begin{macrocode} |
| 7542 |
\NewDocumentCommand \CTEXnumber { m m } |
| 7543 |
{ \protected@edef #1 { \zhnumber {#2} } } |
| 7544 |
\NewDocumentCommand \CTEXdigits { m m } |
| 7545 |
{ \protected@edef #1 { \zhdigits {#2} } } |
| 7546 |
% \end{macrocode} |
| 7547 |
% \end{macro} |
| 7548 |
% |
| 7549 |
% \begin{macro}{today} |
| 7550 |
% \begin{macrocode} |
| 7551 |
\cs_set_eq:NN \CTEX@todayold \today |
| 7552 |
\ctex_define:n |
| 7553 |
{ |
| 7554 |
today .choice: , |
| 7555 |
today / old .code:n = |
| 7556 |
{ \cs_set_eq:NN \today \CTEX@todayold } , |
| 7557 |
today / small .code:n = |
| 7558 |
{ |
| 7559 |
\cs_set_eq:NN \today \zhtoday |
| 7560 |
\zhnumsetup { time = Arabic } |
| 7561 |
} , |
| 7562 |
today / big .code:n = |
| 7563 |
{ |
| 7564 |
\cs_set_eq:NN \today \zhtoday |
| 7565 |
\zhnumsetup { time = Chinese } |
| 7566 |
} , |
| 7567 |
today / unknown .code:n = |
| 7568 |
{ \msg_error:nnx { ctex } { today-undef } {#1} } |
| 7569 |
} |
| 7570 |
\msg_new:nnnn { ctex } { today-undef } |
| 7571 |
{ Today~format~`#1'~is~undefined. } |
| 7572 |
{ Available~today~formats~are~`old',~`small',~and~`big'. } |
| 7573 |
% \end{macrocode} |
| 7574 |
% \end{macro} |
| 7575 |
% |
| 7576 |
% \subsection{其他中文标题定义} |
| 7577 |
% |
| 7578 |
% \changes{v2.0}{2014/03/08}{将标题汉化功能加入 \pkg{ctex.sty}。} |
| 7579 |
% \changes{v2.4.3}{2016/08/18}{确保 \tn{proofname} 非空。} |
| 7580 |
% |
| 7581 |
% \begin{macro}[int]{\proofname} |
| 7582 |
% \tn{proofname} 未在标准文档类中定义,需要确保它非空。 |
| 7583 |
% \begin{macrocode} |
| 7584 |
\tl_if_exist:NF \proofname |
| 7585 |
{ |
| 7586 |
\tl_new:N \proofname |
| 7587 |
\tl_set:Nn \proofname { Proof } |
| 7588 |
} |
| 7589 |
% \end{macrocode} |
| 7590 |
% \end{macro} |
| 7591 |
% |
| 7592 |
% \begin{macrocode} |
| 7593 |
\ctex_define:n |
| 7594 |
{ |
| 7595 |
contentsname .tl_set:N = \contentsname , |
| 7596 |
listfigurename .tl_set:N = \listfigurename , |
| 7597 |
listtablename .tl_set:N = \listtablename , |
| 7598 |
figurename .tl_set:N = \figurename , |
| 7599 |
tablename .tl_set:N = \tablename , |
| 7600 |
abstractname .tl_set:N = \abstractname , |
| 7601 |
indexname .tl_set:N = \indexname , |
| 7602 |
appendixname .tl_set:N = \appendixname , |
| 7603 |
proofname .tl_set:N = \proofname , |
| 7604 |
%<article> bibname .tl_set:N = \refname |
| 7605 |
%<book|report> bibname .tl_set:N = \bibname |
| 7606 |
%<*beamer> |
| 7607 |
algorithmname .tl_set:N = \algorithmname , |
| 7608 |
bibname .tl_set:N = \bibname , |
| 7609 |
refname .tl_set:N = \refname , |
| 7610 |
continuation .tl_set:N = \insertcontinuationtext |
| 7611 |
%</beamer> |
| 7612 |
} |
| 7613 |
% \end{macrocode} |
| 7614 |
% |
| 7615 |
% \begin{macrocode} |
| 7616 |
%<*ctex> |
| 7617 |
\msg_new:nnn { ctex } { ctexbibname } |
| 7618 |
{ |
| 7619 |
Neither~`\token_to_str:N \bibname'~nor~`\token_to_str:N \refname'~can~be~found.\\ |
| 7620 |
The~key~`bibname'~will~set~`\token_to_str:N \ctexbibname'~to~the~given~value. |
| 7621 |
} |
| 7622 |
\tl_if_exist:NTF \insertcontinuationtext |
| 7623 |
{ |
| 7624 |
\ctex_define:n |
| 7625 |
{ |
| 7626 |
algorithmname .tl_set:N = \algorithmname , |
| 7627 |
bibname .tl_set:N = \bibname , |
| 7628 |
refname .tl_set:N = \refname , |
| 7629 |
continuation .tl_set:N = \insertcontinuationtext |
| 7630 |
} |
| 7631 |
} |
| 7632 |
{ |
| 7633 |
\tl_if_exist:NTF \bibname |
| 7634 |
{ \ctex_define:n { bibname .tl_set:N = \bibname } } |
| 7635 |
{ |
| 7636 |
\tl_if_exist:NTF \refname |
| 7637 |
{ \ctex_define:n { bibname .tl_set:N = \refname } } |
| 7638 |
{ |
| 7639 |
\msg_warning:nn { ctex } { ctexbibname } |
| 7640 |
\ctex_define:n { bibname .tl_set:N = \ctexbibname } |
| 7641 |
} |
| 7642 |
} |
| 7643 |
} |
| 7644 |
%</ctex> |
| 7645 |
% \end{macrocode} |
| 7646 |
% |
| 7647 |
% \begin{macrocode} |
| 7648 |
%</class|ctex> |
| 7649 |
% \end{macrocode} |
| 7650 |
% |
| 7651 |
% \subsection{中文化的标题结构} |
| 7652 |
% |
| 7653 |
% 本节内容在 \CTeX{} 文档类或打开 \opt{heading} 选项下生效。 |
| 7654 |
% \begin{macrocode} |
| 7655 |
%<*class|heading> |
| 7656 |
% \end{macrocode} |
| 7657 |
% |
| 7658 |
% \subsubsection{定义标题格式选项} |
| 7659 |
% |
| 7660 |
% \begin{variable}{\c_@@_section_headings_seq} |
| 7661 |
% 保存 \tn{section} 级以下标题名字。 |
| 7662 |
% \begin{macrocode} |
| 7663 |
%<*article|book|report> |
| 7664 |
\seq_const_from_clist:Nn \c_@@_section_headings_seq |
| 7665 |
{ section , subsection , subsubsection , paragraph , subparagraph } |
| 7666 |
%</article|book|report> |
| 7667 |
% \end{macrocode} |
| 7668 |
% \end{variable} |
| 7669 |
% |
| 7670 |
% \begin{variable}{\c_@@_headings_seq} |
| 7671 |
% \begin{macrocode} |
| 7672 |
%<*article|book|report> |
| 7673 |
\seq_new:N \c_@@_headings_seq |
| 7674 |
\seq_gset_eq:NN \c_@@_headings_seq \c_@@_section_headings_seq |
| 7675 |
%<book|report>\seq_gput_left:Nn \c_@@_headings_seq { chapter } |
| 7676 |
\seq_gput_left:Nn \c_@@_headings_seq { part } |
| 7677 |
%</article|book|report> |
| 7678 |
%<*beamer> |
| 7679 |
\seq_const_from_clist:Nn \c_@@_headings_seq |
| 7680 |
{ part , section , subsection } |
| 7681 |
%</beamer> |
| 7682 |
% \end{macrocode} |
| 7683 |
% \end{variable} |
| 7684 |
% |
| 7685 |
% \changes{v2.1}{2015/06/19}{\opt{nameformat} 可以接受章节名字为参数。} |
| 7686 |
% \changes{v2.3}{2016/01/05}{修复 \opt{nameformat} 作用域问题。} |
| 7687 |
% |
| 7688 |
% \begin{macro}{\@@_initial_heading:n} |
| 7689 |
% \begin{macrocode} |
| 7690 |
\cs_new_protected:Npn \@@_initial_heading:n #1 |
| 7691 |
{ |
| 7692 |
\tl_new:c { CTEX@pre#1 } |
| 7693 |
\tl_new:c { CTEX@post#1 } |
| 7694 |
\tl_const:cx { CTEXthe#1 } |
| 7695 |
{ |
| 7696 |
\exp_not:c { CTEX@pre#1 } |
| 7697 |
\exp_not:c { CTEX@the#1 } |
| 7698 |
\exp_not:c { CTEX@post#1 } |
| 7699 |
} |
| 7700 |
\tl_const:cx { CTEX@#1name } |
| 7701 |
{ |
| 7702 |
\group_begin: |
| 7703 |
\exp_not:c { CTEX@#1@nameformat } |
| 7704 |
{ |
| 7705 |
\exp_not:c { CTEX@pre#1 } |
| 7706 |
\exp_not:N \tl_if_empty:NTF |
| 7707 |
\exp_not:c { CTEX@#1@numberformat } |
| 7708 |
{ \exp_not:c { CTEX@the#1 } } |
| 7709 |
{ |
| 7710 |
\group_begin: |
| 7711 |
\exp_not:c { CTEX@#1@numberformat } |
| 7712 |
\exp_not:c { CTEX@the#1 } |
| 7713 |
\group_end: |
| 7714 |
} |
| 7715 |
\exp_not:c { CTEX@post#1 } |
| 7716 |
} |
| 7717 |
\group_end: |
| 7718 |
} |
| 7719 |
} |
| 7720 |
% \end{macrocode} |
| 7721 |
% \end{macro} |
| 7722 |
% |
| 7723 |
% \changes{v2.1}{2015/05/22}{\opt{format+}, \opt{nameformat+} 等带加号的选项, |
| 7724 |
% 加号与前面的文字之间可以有可选的空格。} |
| 7725 |
% \changes{v2.1}{2015/06/19}{新的标题格式选项 \opt{aftertitle}。} |
| 7726 |
% \changes{v2.2}{2015/06/21}{新的标题格式选项 \opt{numbering}。} |
| 7727 |
% \changes{v2.2}{2015/06/27}{\opt{beforeskip} 和 \opt{afterskip} 选项的符号 |
| 7728 |
% 不再有特殊意义。} |
| 7729 |
% \changes{v2.2}{2015/06/27}{新的标题格式选项 \opt{afterindent}。} |
| 7730 |
% \changes{v2.2}{2015/06/27}{新的标题格式选项 \opt{runin}。} |
| 7731 |
% \changes{v2.4.3}{2016/06/03}{新的标题格式选项 \opt{fixskip}。} |
| 7732 |
% \changes{v2.4.4}{2016/09/19}{新的标题格式选项 \opt{break}。} |
| 7733 |
% \changes{v2.4.5}{2016/10/22}{新的标题格式选项 \opt{hang}。} |
| 7734 |
% \changes{v2.4.5}{2016/10/25}{新的标题格式选项 \opt{tocline}。} |
| 7735 |
% \changes{v2.4.11}{2017/11/21}{因上游 \pkg{l3keys} 变化,重新定义 |
| 7736 |
% \opt{format\textvisiblespace+} 等带空格加号的选项。} |
| 7737 |
% |
| 7738 |
% \begin{macro}{\@@_def_heading_keys:n} |
| 7739 |
% \begin{macrocode} |
| 7740 |
\cs_new_protected:Npn \@@_def_heading_keys:n #1 |
| 7741 |
{ |
| 7742 |
\exp_args:NNe \tl_put_right:Nn \l_@@_tmp_tl |
| 7743 |
{ |
| 7744 |
#1 .meta:nn = { ctex / #1 } { ##1 } , |
| 7745 |
#1 / name .code:n = |
| 7746 |
{ \ctex_assign_heading_name:nn {#1} { ##1 } } , |
| 7747 |
#1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , |
| 7748 |
#1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , |
| 7749 |
#1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , |
| 7750 |
#1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , |
| 7751 |
#1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , |
| 7752 |
#1 / numbering .initial:n = true , |
| 7753 |
#1 / beforeskip .initial:n = \c_zero_skip , |
| 7754 |
#1 / afterskip .initial:n = \c_zero_skip , |
| 7755 |
#1 / indent .initial:n = \c_zero_dim , |
| 7756 |
#1 / beforeskip .value_required:n = true , |
| 7757 |
#1 / afterskip .value_required:n = true , |
| 7758 |
#1 / indent .value_required:n = true , |
| 7759 |
%<*article|book|report> |
| 7760 |
#1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , |
| 7761 |
#1 / fixskip .bool_set:N = \exp_not:c { CTEX@#1@fixskip } , |
| 7762 |
#1 / hang .bool_set:N = \exp_not:c { CTEX@#1@hang } , |
| 7763 |
#1 / hang .initial:n = true , |
| 7764 |
#1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , |
| 7765 |
#1 / tocline .cs_set:Np = \exp_not:c { CTEX@#1@tocline } ##1##2 , |
| 7766 |
\@@_plus_key_aux:nn {#1} { break } , |
| 7767 |
%</article|book|report> |
| 7768 |
\@@_plus_key_aux:nn {#1} { format } , |
| 7769 |
\@@_plus_key_aux:nn {#1} { nameformat } , |
| 7770 |
\@@_plus_key_aux:nn {#1} { numberformat } , |
| 7771 |
\@@_plus_key_aux:nn {#1} { titleformat } , |
| 7772 |
\@@_plus_key_aux:nn {#1} { aftername } , |
| 7773 |
\@@_plus_key_aux:nn {#1} { aftertitle } , |
| 7774 |
} |
| 7775 |
} |
| 7776 |
\cs_new:Npn \@@_plus_key_aux:nn #1#2 |
| 7777 |
{ |
| 7778 |
#1 / #2 .tl_set:N = \exp_not:c { CTEX@#1@#2 } , |
| 7779 |
#1 / #2 + .code:n = |
| 7780 |
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ##1 } } , |
| 7781 |
#1 / #2 ~ + .code:n = |
| 7782 |
{ \tl_put_right:Nn \exp_not:c { CTEX@#1@#2 } { ##1 } } |
| 7783 |
} |
| 7784 |
% \end{macrocode} |
| 7785 |
% \end{macro} |
| 7786 |
% |
| 7787 |
% \begin{macro}[int]{\ctex_assign_heading_name:nn} |
| 7788 |
% \begin{macro}{\@@_assign_heading_name:nnn} |
| 7789 |
% \opt{name} 的值是一个至多两个元素的逗号分隔列表。由于 \LaTeXiii{} 的 |
| 7790 |
% \texttt{clist} 总是会自动忽略空元素,所以设置 |name={,章}| 后,第一个元素将会 |
| 7791 |
% 是“章”,必须用空的分组保护空元素:|name={{},章}|,这在使用中有些许不便。我们 |
| 7792 |
% 可以改用 \texttt{seq} 或者手写函数解析参数来加以改进。为实现的简单起见,这里用 |
| 7793 |
% 了 \pkg{xparse} 的 \tn{SplitArgument},它带有参数的长度检查。 |
| 7794 |
% \begin{macrocode} |
| 7795 |
\NewDocumentCommand \ctex_assign_heading_name:nn |
| 7796 |
{ m > { \SplitArgument { 1 } { , } } +m } |
| 7797 |
{ \@@_assign_heading_name:nnn {#1} #2 } |
| 7798 |
\cs_new_protected:Npn \@@_assign_heading_name:nnn #1#2#3 |
| 7799 |
{ |
| 7800 |
\tl_set:cn { CTEX@pre#1 } {#2} |
| 7801 |
\tl_if_novalue:nTF {#3} |
| 7802 |
{ \tl_clear:c { CTEX@post#1 } } |
| 7803 |
{ \tl_set:cn { CTEX@post#1 } {#3} } |
| 7804 |
} |
| 7805 |
% \end{macrocode} |
| 7806 |
% \end{macro} |
| 7807 |
% \end{macro} |
| 7808 |
% |
| 7809 |
% \changes{v2.0}{2014/03/21}{标题设置新增 \opt{pagestyle} 选项。} |
| 7810 |
% \changes{v2.4.1}{2016/05/10}{新的标题格式选项 \opt{part/fixbeforeskip} 和 |
| 7811 |
% \opt{chapter/fixbeforeskip}。} |
| 7812 |
% \changes{v2.4.3}{2016/06/03}{删除选项 \opt{part/fixbeforeskip} 和 |
| 7813 |
% \opt{chapter/fixbeforeskip}。} |
| 7814 |
% \changes{v2.4.5}{2016/10/01}{新的标题格式选项 \opt{chapter/lofskip} 和 |
| 7815 |
% \opt{chapter/lotskip}。} |
| 7816 |
% |
| 7817 |
% \begin{macro}{part/pagestyle,chapter/pagestyle,chapter/lofskip,chapter/lotskip} |
| 7818 |
% 只在 \cls{ctexbook} 和 \cls{ctexrep} 下有定义。 |
| 7819 |
% \begin{macrocode} |
| 7820 |
\group_begin: |
| 7821 |
%<*book|report> |
| 7822 |
\tl_set:Nn \l_@@_tmp_tl |
| 7823 |
{ |
| 7824 |
part / pagestyle .tl_set:N = \CTEX@part@pagestyle , |
| 7825 |
chapter / pagestyle .tl_set:N = \CTEX@chapter@pagestyle , |
| 7826 |
chapter / lofskip .tl_set:N = \CTEX@chapter@lofskip , |
| 7827 |
chapter / lotskip .tl_set:N = \CTEX@chapter@lotskip , |
| 7828 |
chapter / lofskip .initial:n = \c_zero_skip , |
| 7829 |
chapter / lotskip .initial:n = \c_zero_skip , |
| 7830 |
chapter / lofskip .value_required:n = true , |
| 7831 |
chapter / lotskip .value_required:n = true , |
| 7832 |
} |
| 7833 |
%</book|report> |
| 7834 |
%<*article|beamer> |
| 7835 |
\tl_clear:N \l_@@_tmp_tl |
| 7836 |
%</article|beamer> |
| 7837 |
% \end{macrocode} |
| 7838 |
% \end{macro} |
| 7839 |
% |
| 7840 |
% 定义标题键值选项。 |
| 7841 |
% \begin{macrocode} |
| 7842 |
\seq_map_inline:Nn \c_@@_headings_seq |
| 7843 |
{ |
| 7844 |
\@@_initial_heading:n {#1} |
| 7845 |
\@@_def_heading_keys:n {#1} |
| 7846 |
} |
| 7847 |
\exp_args:NNo \group_end: \ctex_define:n { \l_@@_tmp_tl } |
| 7848 |
% \end{macrocode} |
| 7849 |
% |
| 7850 |
% \changes{v2.5}{2020/04/23}{重构标题选项 \opt{indent} 和 \opt{hang}。} |
| 7851 |
% |
| 7852 |
% \begin{macro}[int]{\CTEX@heading@format@initial} |
| 7853 |
% 标题格式的一些初始设置,包括恢复默认字体,并禁用自动调整首行缩进,禁止在标题中分页。 |
| 7854 |
% 同时用 \tn{noindent} 抑制首行缩进并进入水平模式。 |
| 7855 |
% 统一在各级标题的 \opt{format} 选项之前使用。 |
| 7856 |
% \begin{macrocode} |
| 7857 |
\cs_new_protected:Npn \CTEX@heading@format@initial |
| 7858 |
{ |
| 7859 |
\normalfont |
| 7860 |
\tl_clear:N \l_@@_autoindent_tl |
| 7861 |
\int_set:Nn \tex_interlinepenalty:D { 10 000 } |
| 7862 |
\tex_noindent:D |
| 7863 |
} |
| 7864 |
% \end{macrocode} |
| 7865 |
% \end{macro} |
| 7866 |
% |
| 7867 |
% \begin{macro}[int]{\ctex_indent_box:n} |
| 7868 |
% 设置 \tn{parindent},并插入用于产生缩进的盒子,如果缩进为 |0|,就不插入。 |
| 7869 |
% \begin{macrocode} |
| 7870 |
\cs_new_protected:Npn \ctex_indent_box:n #1 |
| 7871 |
{ |
| 7872 |
\dim_set:Nn \tex_parindent:D {#1} |
| 7873 |
\@@_insert_indent: |
| 7874 |
} |
| 7875 |
\cs_new_protected:Npn \@@_insert_indent: |
| 7876 |
{ |
| 7877 |
\dim_compare:nNnF \tex_parindent:D = \c_zero_dim |
| 7878 |
{ \tex_indent:D } |
| 7879 |
} |
| 7880 |
\cs_new_eq:NN \CTEX@indentbox \ctex_indent_box:n |
| 7881 |
% \end{macrocode} |
| 7882 |
% \end{macro} |
| 7883 |
% |
| 7884 |
% \subsubsection{标准标题命令的修改} |
| 7885 |
% |
| 7886 |
% \begin{macrocode} |
| 7887 |
%<*article|book|report> |
| 7888 |
% \end{macrocode} |
| 7889 |
% |
| 7890 |
% \begin{macro}[int]{\CTEX@fixtopskip} |
| 7891 |
% 修正 \cls{book} 和 \cls{report} 类的 \tn{part} 和 \tn{chapter} 标题之前的多余空行。 |
| 7892 |
% \begin{macrocode} |
| 7893 |
%<*book|report> |
| 7894 |
\cs_new_protected:Npn \CTEX@fixtopskip |
| 7895 |
{ |
| 7896 |
\CTEX@fixheadingskip |
| 7897 |
\dim_compare:nNnF \tex_pagegoal:D < \c_max_dim |
| 7898 |
{ \skip_sub:Nn \l_@@_heading_skip { \tex_topskip:D } } |
| 7899 |
} |
| 7900 |
%</book|report> |
| 7901 |
% \end{macrocode} |
| 7902 |
% \end{macro} |
| 7903 |
% |
| 7904 |
% \begin{macro}[int]{\CTEX@fixheadingskip} |
| 7905 |
% 抑制行间粘连,修正标题前后的多余间距。事实上,减掉 \tn{parskip},有一定的风险。 |
| 7906 |
% 如果接下来的内容不会进入水平模式(例如在 \opt{format} 选项中使用 \tn{hrule} 或者 \tn{hbox}), |
| 7907 |
% \TeX{} 就不会加上 \tn{parskip}。这时候就需要用户把 \tn{parskip} 加到 \opt{beforeskip} |
| 7908 |
% 或者 \opt{afterskip} 作为修正。 |
| 7909 |
% \begin{macrocode} |
| 7910 |
\cs_new_protected:Npn \CTEX@fixheadingskip |
| 7911 |
{ |
| 7912 |
\par |
| 7913 |
\dim_set:Nn \tex_prevdepth:D { -1000pt } |
| 7914 |
\skip_sub:Nn \l_@@_heading_skip { \tex_parskip:D } |
| 7915 |
} |
| 7916 |
\skip_new:N \l_@@_heading_skip |
| 7917 |
\cs_new_protected:Npn \CTEX@setheadingskip |
| 7918 |
{ \skip_set:Nn \l_@@_heading_skip } |
| 7919 |
\cs_new_eq:NN \CTEX@headingskip \l_@@_heading_skip |
| 7920 |
% \end{macrocode} |
| 7921 |
% \end{macro} |
| 7922 |
% |
| 7923 |
% \changes{v2.5.10}{2022/06/23}{展开传递 \opt{pagestyle} 的值。} |
| 7924 |
% |
| 7925 |
% \begin{macro}[int]{\CTEX@setthispagestyle} |
| 7926 |
% 将 \verb"\CTEX@(part|chapter)@pagestyle" 展开后再传给 \tn{thispagestyle}。 |
| 7927 |
% \begin{macrocode} |
| 7928 |
%<*book|report> |
| 7929 |
\cs_new_protected:Npn \CTEX@setthispagestyle #1 |
| 7930 |
{ \exp_args:Ne \thispagestyle { \use:c { CTEX@#1@pagestyle } } } |
| 7931 |
%</book|report> |
| 7932 |
% \end{macrocode} |
| 7933 |
% \end{macro} |
| 7934 |
% |
| 7935 |
% \changes{v2.4.4}{2016/09/18}{提供 \tn{partmark}。} |
| 7936 |
% \begin{macro}[int]{\partmark} |
| 7937 |
% 提供 \tn{partmark}。 |
| 7938 |
% \begin{macrocode} |
| 7939 |
\ProvideDocumentCommand \partmark { m } |
| 7940 |
{ \markboth { } { } } |
| 7941 |
% \end{macrocode} |
| 7942 |
% \end{macro} |
| 7943 |
% |
| 7944 |
% \changes{v2.4.4}{2016/09/19}{提供 \tn{CTEXifname}。} |
| 7945 |
% \changes{v2.4.6}{2016/10/31}{\tn{CTEXifname} 初始为假。} |
| 7946 |
% \begin{macro}{\CTEXifname} |
| 7947 |
% \begin{macro}[int]{\CTEX@ifnametrue,\CTEX@ifnamefalse} |
| 7948 |
% 用于判断当前标题是否有编号。 |
| 7949 |
% \begin{macrocode} |
| 7950 |
\cs_new_eq:NN \CTEXifname \use_ii:nn |
| 7951 |
\cs_new_protected:Npn \CTEX@ifnametrue |
| 7952 |
{ \cs_set_eq:NN \CTEXifname \use_i:nn } |
| 7953 |
\cs_new_protected:Npn \CTEX@ifnamefalse |
| 7954 |
{ \cs_set_eq:NN \CTEXifname \use_ii:nn } |
| 7955 |
% \end{macrocode} |
| 7956 |
% \end{macro} |
| 7957 |
% \end{macro} |
| 7958 |
% |
| 7959 |
% \begin{macro}[int]{\CTEX@addloflotskip} |
| 7960 |
% 往插图和表格目录中加入额外间距。如果间距为零,则不加入。 |
| 7961 |
% \begin{macrocode} |
| 7962 |
%<*book|report> |
| 7963 |
\cs_new_protected:Npn \CTEX@addloflotskip #1 |
| 7964 |
{ |
| 7965 |
\skip_set:Nn \l_@@_heading_skip { \use:c { CTEX@#1@lofskip } } |
| 7966 |
\skip_if_eq:nnF { \l_@@_heading_skip } { \c_zero_skip } |
| 7967 |
{ |
| 7968 |
\addtocontents { lof } |
| 7969 |
{ \protect \addvspace { \skip_use:N \l_@@_heading_skip } } |
| 7970 |
} |
| 7971 |
\skip_set:Nn \l_@@_heading_skip { \use:c { CTEX@#1@lotskip } } |
| 7972 |
\skip_if_eq:nnF { \l_@@_heading_skip } { \c_zero_skip } |
| 7973 |
{ |
| 7974 |
\addtocontents { lot } |
| 7975 |
{ \protect \addvspace { \skip_use:N \l_@@_heading_skip } } |
| 7976 |
} |
| 7977 |
} |
| 7978 |
%</book|report> |
| 7979 |
% \end{macrocode} |
| 7980 |
% \end{macro} |
| 7981 |
% |
| 7982 |
% \begin{macro}[int]{\CTEX@addtocline} |
| 7983 |
% \begin{macrocode} |
| 7984 |
\cs_new_protected:Npn \CTEX@addtocline #1#2 |
| 7985 |
{ \addcontentsline { toc } {#1} { \use:c { CTEX@#1@tocline } {#1} {#2} } } |
| 7986 |
% \end{macrocode} |
| 7987 |
% \end{macro} |
| 7988 |
% |
| 7989 |
% \changes{v2.2}{2015/06/27}{\opt{beforeskip}、\opt{afterskip} 和 \opt{indent} |
| 7990 |
% 选项支持表达式。} |
| 7991 |
% \changes{v2.4.15}{2019/03/31}{修正 \opt{part/indent} 和 \opt{chapter/indent} 的实现方法。} |
| 7992 |
% \changes{v2.4.15}{2019/03/31}{定义 \opt{part/hang} 和 \opt{chapter/hang}。} |
| 7993 |
% \changes{v2.4.16}{2019/05/11}{修正 \opt{part/indent} 和 \opt{chapter/indent} |
| 7994 |
% 的实现方法,在其标题内部禁用 \opt{autoindent}。} |
| 7995 |
% |
| 7996 |
% \changes{v2.5}{2020/04/22}{标题选项 \opt{format} 也可以接受参数。} |
| 7997 |
% |
| 7998 |
% \paragraph{part 的标题} |
| 7999 |
% |
| 8000 |
% \changes{v2.2}{2015/06/27}{非 \cls{ctexart} 类的 \opt{part/beforeskip} 和 |
| 8001 |
% \opt{part/afterskip} 选项有意义。} |
| 8002 |
% |
| 8003 |
% \begin{macro}[int]{\part} |
| 8004 |
% \begin{macrocode} |
| 8005 |
%<*article> |
| 8006 |
\renewcommand\part{% |
| 8007 |
\if@noskipsec \leavevmode \fi |
| 8008 |
\par |
| 8009 |
\CTEX@part@break |
| 8010 |
% \addvspace{4ex}% |
| 8011 |
\CTEX@setheadingskip \CTEX@part@beforeskip |
| 8012 |
\ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi |
| 8013 |
\addvspace \CTEX@headingskip |
| 8014 |
\ifodd \CTEX@part@afterindent |
| 8015 |
\@afterindenttrue |
| 8016 |
\else |
| 8017 |
\@afterindentfalse |
| 8018 |
\fi |
| 8019 |
\secdef\@part\@spart} |
| 8020 |
%</article> |
| 8021 |
%<*book|report> |
| 8022 |
\renewcommand\part{% |
| 8023 |
% \if@openright |
| 8024 |
% \cleardoublepage |
| 8025 |
% \else |
| 8026 |
% \clearpage |
| 8027 |
% \fi |
| 8028 |
\CTEX@part@break |
| 8029 |
% \thispagestyle{plain}% |
| 8030 |
\CTEX@setthispagestyle{part}% |
| 8031 |
\if@twocolumn |
| 8032 |
\onecolumn |
| 8033 |
\@tempswatrue |
| 8034 |
\else |
| 8035 |
\@tempswafalse |
| 8036 |
\fi |
| 8037 |
% \null\vfil |
| 8038 |
\CTEX@setheadingskip \CTEX@part@beforeskip |
| 8039 |
\ifodd \CTEX@part@fixskip \CTEX@fixtopskip \fi |
| 8040 |
\vspace*{\CTEX@headingskip}% |
| 8041 |
\secdef\@part\@spart} |
| 8042 |
%</book|report> |
| 8043 |
% \end{macrocode} |
| 8044 |
% \end{macro} |
| 8045 |
% |
| 8046 |
% \begin{macro}[int]{\@part} |
| 8047 |
% \begin{macrocode} |
| 8048 |
%<*article> |
| 8049 |
\def\@part[#1]#2{% |
| 8050 |
\ifnum \c@secnumdepth >\m@ne |
| 8051 |
\ifodd \CTEX@part@numbering |
| 8052 |
\CTEX@ifnametrue |
| 8053 |
\refstepcounter{part}% |
| 8054 |
% \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% |
| 8055 |
\else |
| 8056 |
\CTEX@ifnamefalse |
| 8057 |
\CTEX@makeanchor{part*}% |
| 8058 |
% \addcontentsline{toc}{part}{#1}% |
| 8059 |
\fi |
| 8060 |
\else |
| 8061 |
\CTEX@ifnamefalse |
| 8062 |
\CTEX@makeanchor{part*}% |
| 8063 |
% \addcontentsline{toc}{part}{#1}% |
| 8064 |
\fi |
| 8065 |
\CTEX@gettitle{#1}% |
| 8066 |
\CTEX@addtocline{part}{#1}% |
| 8067 |
\partmark{#1}% |
| 8068 |
\begingroup |
| 8069 |
% \parindent \z@ \raggedright \interlinepenalty \@M \normalfont |
| 8070 |
\CTEX@heading@format@initial |
| 8071 |
\CTEX@part@format{% |
| 8072 |
% \ifnum \c@secnumdepth >\m@ne |
| 8073 |
% \Large\bfseries\partname\nobreakspace\thepart\par\nobreak |
| 8074 |
% \fi |
| 8075 |
\CTEX@headinghang{part}% |
| 8076 |
{\CTEXifname{\CTEX@partname\CTEX@part@aftername}{}}% |
| 8077 |
% \huge\bfseries #2% |
| 8078 |
\CTEX@part@titleformat{#2}% |
| 8079 |
% \markboth{}{}\par |
| 8080 |
\CTEX@part@aftertitle}\par |
| 8081 |
\endgroup |
| 8082 |
\nobreak |
| 8083 |
% \vskip 3ex |
| 8084 |
\CTEX@setheadingskip \CTEX@part@afterskip |
| 8085 |
\ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi |
| 8086 |
\vskip \CTEX@headingskip |
| 8087 |
\@afterheading} |
| 8088 |
%</article> |
| 8089 |
%<*book|report> |
| 8090 |
\def\@part[#1]#2{% |
| 8091 |
\ifnum \c@secnumdepth >-2\relax |
| 8092 |
\ifodd \CTEX@part@numbering |
| 8093 |
\CTEX@ifnametrue |
| 8094 |
\refstepcounter{part}% |
| 8095 |
% \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% |
| 8096 |
\else |
| 8097 |
\CTEX@ifnamefalse |
| 8098 |
\CTEX@makeanchor{part*}% |
| 8099 |
% \addcontentsline{toc}{part}{#1}% |
| 8100 |
\fi |
| 8101 |
\else |
| 8102 |
\CTEX@ifnamefalse |
| 8103 |
\CTEX@makeanchor{part*}% |
| 8104 |
% \addcontentsline{toc}{part}{#1}% |
| 8105 |
\fi |
| 8106 |
\CTEX@gettitle{#1}% |
| 8107 |
\CTEX@addtocline{part}{#1}% |
| 8108 |
% \markboth{}{}% |
| 8109 |
\partmark{#1}% |
| 8110 |
\begingroup |
| 8111 |
% \centering \interlinepenalty \@M \normalfont |
| 8112 |
\CTEX@heading@format@initial |
| 8113 |
\CTEX@part@format{% |
| 8114 |
% \ifnum \c@secnumdepth >-2\relax |
| 8115 |
% \huge\bfseries\partname\nobreakspace\thepart\par\vskip 20\p@ |
| 8116 |
% \fi |
| 8117 |
\CTEX@headinghang{part}% |
| 8118 |
{\CTEXifname{\CTEX@partname\CTEX@part@aftername}{}}% |
| 8119 |
% \Huge\bfseries #2\par |
| 8120 |
\CTEX@part@titleformat{#2}% |
| 8121 |
\CTEX@part@aftertitle}\par |
| 8122 |
\endgroup |
| 8123 |
\@endpart} |
| 8124 |
%</book|report> |
| 8125 |
% \end{macrocode} |
| 8126 |
% \end{macro} |
| 8127 |
% |
| 8128 |
% \begin{macro}[int]{\@spart} |
| 8129 |
% \begin{macrocode} |
| 8130 |
%<*article> |
| 8131 |
\def\@spart#1{% |
| 8132 |
\CTEX@ifnamefalse |
| 8133 |
\CTEX@makeanchor@spart{part*}% |
| 8134 |
\CTEX@gettitle{#1}% |
| 8135 |
\begingroup |
| 8136 |
% \parindent \z@ \raggedright \interlinepenalty \@M \normalfont |
| 8137 |
\CTEX@heading@format@initial |
| 8138 |
\CTEX@part@format{% |
| 8139 |
\CTEX@headinghang{part}{}% |
| 8140 |
% \huge \bfseries #1\par |
| 8141 |
\CTEX@part@titleformat{#1}% |
| 8142 |
\CTEX@part@aftertitle}\par |
| 8143 |
\endgroup |
| 8144 |
\nobreak |
| 8145 |
% \vskip 3ex |
| 8146 |
\CTEX@setheadingskip \CTEX@part@afterskip |
| 8147 |
\ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi |
| 8148 |
\vskip \CTEX@headingskip |
| 8149 |
\@afterheading} |
| 8150 |
%</article> |
| 8151 |
%<*book|report> |
| 8152 |
\def\@spart#1{% |
| 8153 |
\CTEX@ifnamefalse |
| 8154 |
\CTEX@makeanchor@spart{part*}% |
| 8155 |
\CTEX@gettitle{#1}% |
| 8156 |
\begingroup |
| 8157 |
% \centering \interlinepenalty \@M \normalfont |
| 8158 |
\CTEX@heading@format@initial |
| 8159 |
\CTEX@part@format{% |
| 8160 |
\CTEX@headinghang{part}{}% |
| 8161 |
% \Huge \bfseries #1\par% |
| 8162 |
\CTEX@part@titleformat{#1}% |
| 8163 |
\CTEX@part@aftertitle}\par |
| 8164 |
\endgroup |
| 8165 |
\@endpart} |
| 8166 |
%</book|report> |
| 8167 |
% \end{macrocode} |
| 8168 |
% \end{macro} |
| 8169 |
% |
| 8170 |
% \begin{macro}[int]{\@endpart} |
| 8171 |
% \begin{macrocode} |
| 8172 |
%<*book|report> |
| 8173 |
\def\@endpart{% |
| 8174 |
% \vfil |
| 8175 |
\CTEX@setheadingskip \CTEX@part@afterskip |
| 8176 |
\ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi |
| 8177 |
\vskip \CTEX@headingskip |
| 8178 |
\newpage |
| 8179 |
\if@twoside |
| 8180 |
\if@openright |
| 8181 |
\null |
| 8182 |
\thispagestyle{empty}% |
| 8183 |
\newpage |
| 8184 |
\fi |
| 8185 |
\fi |
| 8186 |
\if@tempswa |
| 8187 |
\twocolumn |
| 8188 |
\fi} |
| 8189 |
%</book|report> |
| 8190 |
% \end{macrocode} |
| 8191 |
% \end{macro} |
| 8192 |
% |
| 8193 |
% \paragraph{chapter 的标题} |
| 8194 |
% |
| 8195 |
% \begin{macrocode} |
| 8196 |
%<*book|report> |
| 8197 |
% \end{macrocode} |
| 8198 |
% |
| 8199 |
% \begin{macro}[int]{\chapter} |
| 8200 |
% \begin{macrocode} |
| 8201 |
\renewcommand\chapter{% |
| 8202 |
% \if@openright\cleardoublepage\else\clearpage\fi |
| 8203 |
% \thispagestyle{plain}% |
| 8204 |
\CTEX@chapter@break |
| 8205 |
\CTEX@setthispagestyle{chapter}% |
| 8206 |
\global\@topnum\z@ |
| 8207 |
% \@afterindentfalse |
| 8208 |
\ifodd \CTEX@chapter@afterindent |
| 8209 |
\@afterindenttrue |
| 8210 |
\else |
| 8211 |
\@afterindentfalse |
| 8212 |
\fi |
| 8213 |
\secdef\@chapter\@schapter} |
| 8214 |
% \end{macrocode} |
| 8215 |
% \end{macro} |
| 8216 |
% |
| 8217 |
% \begin{macro}[int]{\@chapter} |
| 8218 |
% \begin{macrocode} |
| 8219 |
\def\@chapter[#1]#2{% |
| 8220 |
\ifnum \c@secnumdepth >\m@ne |
| 8221 |
%<*book> |
| 8222 |
\if@mainmatter |
| 8223 |
%</book> |
| 8224 |
\ifodd \CTEX@chapter@numbering |
| 8225 |
\CTEX@ifnametrue |
| 8226 |
\refstepcounter{chapter}% |
| 8227 |
% \typeout{\@chapapp\space\thechapter.}% |
| 8228 |
\typeout{\CTEXthechapter}% |
| 8229 |
% \addcontentsline{toc}{chapter} |
| 8230 |
% {\protect\numberline{\thechapter}#1}% |
| 8231 |
\else |
| 8232 |
\CTEX@ifnamefalse |
| 8233 |
\CTEX@makeanchor{\Hy@chapapp*}% |
| 8234 |
% \addcontentsline{toc}{chapter}{#1}% |
| 8235 |
\fi |
| 8236 |
%<*book> |
| 8237 |
\else |
| 8238 |
\CTEX@ifnamefalse |
| 8239 |
\CTEX@makeanchor@chapter{\Hy@chapapp*}% |
| 8240 |
% \addcontentsline{toc}{chapter}{#1}% |
| 8241 |
\fi |
| 8242 |
%</book> |
| 8243 |
\else |
| 8244 |
\CTEX@ifnamefalse |
| 8245 |
\CTEX@makeanchor@chapter{\Hy@chapapp*}% |
| 8246 |
% \addcontentsline{toc}{chapter}{#1}% |
| 8247 |
\fi |
| 8248 |
\CTEX@gettitle{#1}% |
| 8249 |
\CTEX@addtocline{chapter}{#1}% |
| 8250 |
\chaptermark{#1}% |
| 8251 |
% \addtocontents{lof}{\protect\addvspace{10\p@}}% |
| 8252 |
% \addtocontents{lot}{\protect\addvspace{10\p@}}% |
| 8253 |
\CTEX@addloflotskip{chapter}% |
| 8254 |
\if@twocolumn |
| 8255 |
\@topnewpage[\@makechapterhead{#2}]% |
| 8256 |
\else |
| 8257 |
\@makechapterhead{#2}% |
| 8258 |
\@afterheading |
| 8259 |
\fi} |
| 8260 |
% \end{macrocode} |
| 8261 |
% \end{macro} |
| 8262 |
% |
| 8263 |
% \begin{macro}[int]{\@schapter} |
| 8264 |
% \begin{macrocode} |
| 8265 |
\def\@schapter#1{% |
| 8266 |
\CTEX@ifnamefalse |
| 8267 |
\CTEX@makeanchor@schapter{\Hy@chapapp*}% |
| 8268 |
\CTEX@gettitle{#1}% |
| 8269 |
\if@twocolumn |
| 8270 |
\@topnewpage[\@makeschapterhead{#1}]% |
| 8271 |
\else |
| 8272 |
\@makeschapterhead{#1}% |
| 8273 |
\@afterheading |
| 8274 |
\fi} |
| 8275 |
% \end{macrocode} |
| 8276 |
% \end{macro} |
| 8277 |
% |
| 8278 |
% \begin{macro}[int]{\@makechapterhead} |
| 8279 |
% \begin{macrocode} |
| 8280 |
\def\@makechapterhead#1{% |
| 8281 |
% \vspace*{50\p@}% |
| 8282 |
\CTEX@setheadingskip \CTEX@chapter@beforeskip |
| 8283 |
\ifodd \CTEX@chapter@fixskip \CTEX@fixtopskip \fi |
| 8284 |
\vspace*{\CTEX@headingskip}% |
| 8285 |
\begingroup |
| 8286 |
% \parindent \z@ \raggedright \normalfont |
| 8287 |
\CTEX@heading@format@initial |
| 8288 |
\CTEX@chapter@format{% |
| 8289 |
% \ifnum \c@secnumdepth >\m@ne |
| 8290 |
% \if@mainmatter |
| 8291 |
% \huge\bfseries\@chapapp\space\thechapter\par\nobreak\vskip 20\p@ |
| 8292 |
% \fi |
| 8293 |
% \fi |
| 8294 |
\CTEX@headinghang{chapter}% |
| 8295 |
{\CTEXifname{\CTEX@chaptername\CTEX@chapter@aftername}{}}% |
| 8296 |
% \Huge \bfseries #1\par\nobreak |
| 8297 |
\CTEX@chapter@titleformat{#1}% |
| 8298 |
\CTEX@chapter@aftertitle}\par |
| 8299 |
\endgroup |
| 8300 |
\nobreak |
| 8301 |
% \vskip 40\p@ |
| 8302 |
\CTEX@setheadingskip \CTEX@chapter@afterskip |
| 8303 |
\ifodd \CTEX@chapter@fixskip \CTEX@fixheadingskip \fi |
| 8304 |
\vskip \CTEX@headingskip} |
| 8305 |
% \end{macrocode} |
| 8306 |
% \end{macro} |
| 8307 |
% |
| 8308 |
% \begin{macro}[int]{\@makeschapterhead} |
| 8309 |
% \begin{macrocode} |
| 8310 |
\def\@makeschapterhead#1{% |
| 8311 |
% \vspace*{50\p@}% |
| 8312 |
\CTEX@setheadingskip \CTEX@chapter@beforeskip |
| 8313 |
\ifodd \CTEX@chapter@fixskip \CTEX@fixtopskip \fi |
| 8314 |
\vspace*{\CTEX@headingskip}% |
| 8315 |
\begingroup |
| 8316 |
% \parindent \z@ \raggedright \normalfont \interlinepenalty\@M |
| 8317 |
\CTEX@heading@format@initial |
| 8318 |
\CTEX@chapter@format{% |
| 8319 |
\CTEX@headinghang{chapter}{}% |
| 8320 |
% \Huge \bfseries #1\par\nobreak |
| 8321 |
\CTEX@chapter@titleformat{#1}% |
| 8322 |
\CTEX@chapter@aftertitle}\par |
| 8323 |
\endgroup |
| 8324 |
\nobreak |
| 8325 |
% \vskip 40\p@ |
| 8326 |
\CTEX@setheadingskip \CTEX@chapter@afterskip |
| 8327 |
\ifodd \CTEX@chapter@fixskip \CTEX@fixheadingskip \fi |
| 8328 |
\vskip \CTEX@headingskip} |
| 8329 |
% \end{macrocode} |
| 8330 |
% \end{macro} |
| 8331 |
% |
| 8332 |
% \begin{macrocode} |
| 8333 |
%</book|report> |
| 8334 |
% \end{macrocode} |
| 8335 |
% |
| 8336 |
% \paragraph{section 类的标题} |
| 8337 |
% |
| 8338 |
% \begin{macro}[int]{\@startsection} |
| 8339 |
% \LaTeX 的标准参数是: |
| 8340 |
% \begin{quote}\small |
| 8341 |
% \Arg{name}\Arg{level}\Arg{indent}\Arg{beforeskip}\Arg{afterskip}^^A |
| 8342 |
% \Arg{style}|*|\oarg{altheading}\Arg{heading} |
| 8343 |
% \end{quote} |
| 8344 |
% \begin{macrocode} |
| 8345 |
\def\@startsection#1#2#3#4#5#6{% |
| 8346 |
\if@noskipsec \leavevmode \fi |
| 8347 |
\par |
| 8348 |
% \@tempskipa #4\relax |
| 8349 |
% \@afterindenttrue |
| 8350 |
% \ifdim \@tempskipa <\z@ |
| 8351 |
% \@tempskipa -\@tempskipa \@afterindentfalse |
| 8352 |
% \fi |
| 8353 |
\CTEX@update@sectionformat@n{#1}% |
| 8354 |
\ifodd \CTEX@afterindent |
| 8355 |
\@afterindenttrue |
| 8356 |
\else |
| 8357 |
\@afterindentfalse |
| 8358 |
\fi |
| 8359 |
\if@nobreak |
| 8360 |
\everypar{}% |
| 8361 |
\else |
| 8362 |
% \addpenalty\@secpenalty\addvspace\@tempskipa |
| 8363 |
\csname CTEX@#1@break\endcsname |
| 8364 |
\CTEX@setheadingskip{#4}% |
| 8365 |
\ifodd \CTEX@fixskip \CTEX@fixheadingskip \fi |
| 8366 |
\addvspace \CTEX@headingskip |
| 8367 |
\fi |
| 8368 |
\@ifstar |
| 8369 |
{\CTEX@makeanchor@ssect{#1*}\@ssect{#3}{#4}{#5}{#6}}% |
| 8370 |
{\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} |
| 8371 |
% \end{macrocode} |
| 8372 |
% \end{macro} |
| 8373 |
% |
| 8374 |
% \begin{macro}[int]{\@seccntformat} |
| 8375 |
% \begin{macrocode} |
| 8376 |
\def\@seccntformat#1{% |
| 8377 |
% \csname the#1\endcsname\quad}% |
| 8378 |
\csname CTEX@#1name\endcsname |
| 8379 |
\csname CTEX@#1@aftername\endcsname} |
| 8380 |
% \end{macrocode} |
| 8381 |
% \end{macro} |
| 8382 |
% |
| 8383 |
% \begin{macro}[int]{\@sect} |
| 8384 |
% \begin{macrocode} |
| 8385 |
\def\@sect#1#2#3#4#5#6[#7]#8{% |
| 8386 |
\ifnum #2>\c@secnumdepth |
| 8387 |
\CTEX@ifnamefalse |
| 8388 |
\CTEX@makeanchor@sect{#1*}% |
| 8389 |
\let\@svsec\@empty |
| 8390 |
\else |
| 8391 |
\ifodd \csname CTEX@#1@numbering\endcsname |
| 8392 |
\CTEX@ifnametrue |
| 8393 |
\refstepcounter{#1}% |
| 8394 |
\protected@edef\@svsec{\@seccntformat{#1}\relax}% |
| 8395 |
\else |
| 8396 |
\CTEX@ifnamefalse |
| 8397 |
\CTEX@makeanchor{#1*}% |
| 8398 |
\let\@svsec\@empty |
| 8399 |
\fi |
| 8400 |
\fi |
| 8401 |
\CTEX@gettitle{#7}% |
| 8402 |
% \@tempskipa #5\relax |
| 8403 |
% \ifdim \@tempskipa>\z@ |
| 8404 |
\unless \ifodd \CTEX@runin |
| 8405 |
\begingroup |
| 8406 |
\CTEX@heading@format@initial |
| 8407 |
#6{% |
| 8408 |
% \@hangfrom{\hskip #3\relax\@svsec}% |
| 8409 |
% \interlinepenalty \@M #8\@@@@par |
| 8410 |
\CTEX@sectionhang{#3}{\@svsec}% |
| 8411 |
\csname CTEX@#1@titleformat\endcsname{#8}% |
| 8412 |
\csname CTEX@#1@aftertitle\endcsname}\par |
| 8413 |
\endgroup |
| 8414 |
\csname #1mark\endcsname{#7}% |
| 8415 |
% \addcontentsline{toc}{#1}{% |
| 8416 |
% \ifnum #2>\c@secnumdepth \else |
| 8417 |
% \protect\numberline{\csname the#1\endcsname}% |
| 8418 |
% \fi |
| 8419 |
% #7}% |
| 8420 |
\CTEX@addtocline{#1}{#7}% |
| 8421 |
\else |
| 8422 |
\def\@svsechd{% |
| 8423 |
#6{% |
| 8424 |
% \hskip #3\relax \@svsec #8 |
| 8425 |
{\CTEX@indentbox{#3}}\@svsec |
| 8426 |
\csname CTEX@#1@titleformat\endcsname{#8}% |
| 8427 |
\csname CTEX@#1@aftertitle\endcsname}% |
| 8428 |
\csname #1mark\endcsname{#7}% |
| 8429 |
% \addcontentsline{toc}{#1}{% |
| 8430 |
% \ifnum #2>\c@secnumdepth \else |
| 8431 |
% \protect\numberline{\csname the#1\endcsname}% |
| 8432 |
% \fi |
| 8433 |
% #7}% |
| 8434 |
\CTEX@addtocline{#1}{#7}}% |
| 8435 |
\fi |
| 8436 |
\@xsect{#5}} |
| 8437 |
% \end{macrocode} |
| 8438 |
% \end{macro} |
| 8439 |
% |
| 8440 |
% \begin{macro}[int]{\@ssect} |
| 8441 |
% \begin{macrocode} |
| 8442 |
\def\@ssect#1#2#3#4#5{% |
| 8443 |
\CTEX@ifnamefalse |
| 8444 |
\CTEX@gettitle{#5}% |
| 8445 |
% \@tempskipa #3\relax |
| 8446 |
% \ifdim \@tempskipa>\z@ |
| 8447 |
\unless \ifodd \CTEX@runin |
| 8448 |
\begingroup |
| 8449 |
\CTEX@heading@format@initial |
| 8450 |
#4{% |
| 8451 |
% \@hangfrom{\hskip #1}% |
| 8452 |
% \interlinepenalty \@M #5\@@par |
| 8453 |
\CTEX@sectionhang{#1}{}% |
| 8454 |
\CTEX@titleformat@n{#5}% |
| 8455 |
\CTEX@aftertitle}\par |
| 8456 |
\endgroup |
| 8457 |
\else |
| 8458 |
% \def\@svsechd{#4{\hskip #1\relax #5}}% |
| 8459 |
\def\@svsechd{#4{{\CTEX@indentbox{#1}}% |
| 8460 |
\CTEX@titleformat@n{#5}\CTEX@aftertitle}}% |
| 8461 |
\fi |
| 8462 |
\@xsect{#3}} |
| 8463 |
% \end{macrocode} |
| 8464 |
% \end{macro} |
| 8465 |
% |
| 8466 |
% \begin{macro}[int]{\@xsect} |
| 8467 |
% \begin{macrocode} |
| 8468 |
\def\@xsect#1{% |
| 8469 |
% \@tempskipa #1\relax |
| 8470 |
% \ifdim \@tempskipa>\z@ |
| 8471 |
\unless \ifodd \CTEX@runin |
| 8472 |
\par \nobreak |
| 8473 |
% \vskip \@tempskipa |
| 8474 |
\CTEX@setheadingskip{#1}% |
| 8475 |
\ifodd \CTEX@fixskip \CTEX@fixheadingskip \fi |
| 8476 |
\vskip \CTEX@headingskip |
| 8477 |
\@afterheading |
| 8478 |
\else |
| 8479 |
\@nobreakfalse |
| 8480 |
\global\@noskipsectrue |
| 8481 |
\everypar{% |
| 8482 |
\if@noskipsec |
| 8483 |
\global\@noskipsecfalse |
| 8484 |
{\setbox\z@\lastbox}% |
| 8485 |
\clubpenalty\@M |
| 8486 |
\begingroup \@svsechd \endgroup |
| 8487 |
\unskip |
| 8488 |
% \@tempskipa #1\relax |
| 8489 |
% \hskip -\@tempskipa |
| 8490 |
\CTEX@heading@glue{#1}% |
| 8491 |
\else |
| 8492 |
\clubpenalty \@clubpenalty |
| 8493 |
\everypar{}% |
| 8494 |
\fi}% |
| 8495 |
\fi |
| 8496 |
\ignorespaces} |
| 8497 |
% \end{macrocode} |
| 8498 |
% \end{macro} |
| 8499 |
% |
| 8500 |
% \begin{macro}[int]{\CTEX@headinghang,\CTEX@sectionhang} |
| 8501 |
% 分别用于用于实现 \tn{part}/\tn{chapter} 和 \tn{section} 类标题的 |
| 8502 |
% \opt{indent} 和 \opt{hang} 选项。 |
| 8503 |
% \begin{macrocode} |
| 8504 |
\cs_new_protected:Npn \CTEX@headinghang #1 |
| 8505 |
{ |
| 8506 |
\ctex_heading_hang:cnn |
| 8507 |
{ CTEX@#1@hang } |
| 8508 |
{ \use:c { CTEX@#1@indent } } |
| 8509 |
} |
| 8510 |
\cs_new_protected:Npn \CTEX@sectionhang |
| 8511 |
{ \ctex_heading_hang:Nnn \CTEX@hang } |
| 8512 |
% \end{macrocode} |
| 8513 |
% \end{macro} |
| 8514 |
% |
| 8515 |
% \begin{macro}[int]{\ctex_heading_hang:Nnn,\ctex_hang_from:n} |
| 8516 |
% \opt{hang} 选项控制是否采用悬挂缩进,同时设置 \tn{parindent}。 |
| 8517 |
% \begin{macrocode} |
| 8518 |
\cs_new_protected:Npn \ctex_heading_hang:Nnn #1#2#3 |
| 8519 |
{ |
| 8520 |
\dim_set:Nn \tex_parindent:D {#2} |
| 8521 |
\bool_if:NTF #1 |
| 8522 |
{ \ctex_hang_from:n } |
| 8523 |
{ \use:n } |
| 8524 |
{ \@@_insert_indent: #3 } |
| 8525 |
} |
| 8526 |
\cs_new_protected:Npn \ctex_hang_from:n #1 |
| 8527 |
{ |
| 8528 |
\tex_noindent:D |
| 8529 |
\hbox_set:Nn \l_@@_tmp_box {#1} |
| 8530 |
\tex_hangindent:D = \box_wd:N \l_@@_tmp_box |
| 8531 |
\box_use_drop:N \l_@@_tmp_box |
| 8532 |
} |
| 8533 |
\cs_generate_variant:Nn \ctex_heading_hang:Nnn { c } |
| 8534 |
% \end{macrocode} |
| 8535 |
% \end{macro} |
| 8536 |
% |
| 8537 |
% \begin{macro}[int]{\ctex_heading_glue:n,\CTEX@heading@glue} |
| 8538 |
% 如果缩进 |#1| 长度为零,就不插入水平间距。 |
| 8539 |
% \begin{macrocode} |
| 8540 |
\cs_new_protected:Npn \ctex_heading_glue:n #1 |
| 8541 |
{ |
| 8542 |
\group_begin: |
| 8543 |
\skip_set:Nn \l_@@_heading_skip {#1} |
| 8544 |
\dim_compare:nNnF \l_@@_heading_skip = \c_zero_dim |
| 8545 |
{ \skip_horizontal:N \l_@@_heading_skip } |
| 8546 |
\group_end: |
| 8547 |
} |
| 8548 |
\cs_new_eq:NN \CTEX@heading@glue \ctex_heading_glue:n |
| 8549 |
% \end{macrocode} |
| 8550 |
% \end{macro} |
| 8551 |
% |
| 8552 |
% \begin{macro}[int]{\CTEX@update@sectionformat@n} |
| 8553 |
% 在 \tn{@startsection} 中设置 \tn{CTEX@titleformat@n} 等为相应函数。 |
| 8554 |
% \begin{macrocode} |
| 8555 |
\cs_new_protected:Npn \CTEX@update@sectionformat@n #1 |
| 8556 |
{ |
| 8557 |
\cs_set_eq:Nc \CTEX@titleformat@n { CTEX@#1@titleformat } |
| 8558 |
\cs_set_eq:Nc \CTEX@aftertitle { CTEX@#1@aftertitle } |
| 8559 |
\cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } |
| 8560 |
\cs_set_eq:Nc \CTEX@fixskip { CTEX@#1@fixskip } |
| 8561 |
\cs_set_eq:Nc \CTEX@hang { CTEX@#1@hang } |
| 8562 |
\cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } |
| 8563 |
} |
| 8564 |
\cs_new_eq:NN \CTEX@titleformat@n \use:n |
| 8565 |
\cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: |
| 8566 |
\cs_new_eq:NN \CTEX@afterindent \c_true_bool |
| 8567 |
\cs_new_eq:NN \CTEX@fixskip \c_false_bool |
| 8568 |
\cs_new_eq:NN \CTEX@hang \c_true_bool |
| 8569 |
\cs_new_eq:NN \CTEX@runin \c_false_bool |
| 8570 |
% \end{macrocode} |
| 8571 |
% \end{macro} |
| 8572 |
% |
| 8573 |
% \begin{macro}[int]{\CTEX@part@tocline, \CTEX@chapter@tocline} |
| 8574 |
% \begin{macrocode} |
| 8575 |
\cs_new:Npn \CTEX@part@tocline #1#2 |
| 8576 |
{ |
| 8577 |
\CTEXifname |
| 8578 |
{ \CTEXthepart \hspace { 1em } } |
| 8579 |
{ } |
| 8580 |
#2 |
| 8581 |
} |
| 8582 |
%<*book|report> |
| 8583 |
\cs_new:Npn \CTEX@chapter@tocline #1#2 |
| 8584 |
{ |
| 8585 |
\CTEXifname |
| 8586 |
{ \protect \numberline { \CTEXthechapter \hspace { .3em } } } |
| 8587 |
{ } |
| 8588 |
#2 |
| 8589 |
} |
| 8590 |
%</book|report> |
| 8591 |
% \end{macrocode} |
| 8592 |
% \end{macro} |
| 8593 |
% |
| 8594 |
% \begin{macro}[int]{\CTEXnumberline} |
| 8595 |
% \begin{macrocode} |
| 8596 |
\cs_new:Npn \CTEXnumberline #1 |
| 8597 |
{ |
| 8598 |
\CTEXifname |
| 8599 |
{ \protect \numberline { \use:c { CTEXthe #1 } } } |
| 8600 |
{ } |
| 8601 |
} |
| 8602 |
% \end{macrocode} |
| 8603 |
% \end{macro} |
| 8604 |
% |
| 8605 |
% \begin{macrocode} |
| 8606 |
\int_zero:N \l_@@_tmp_int |
| 8607 |
\seq_map_inline:Nn \c_@@_section_headings_seq |
| 8608 |
{ |
| 8609 |
\int_incr:N \l_@@_tmp_int |
| 8610 |
\cs_gset_protected:cpx {#1} |
| 8611 |
{ |
| 8612 |
\exp_not:N \@startsection {#1} |
| 8613 |
{ \int_use:N \l_@@_tmp_int } |
| 8614 |
{ \exp_not:c { CTEX@#1@indent } } |
| 8615 |
{ \exp_not:c { CTEX@#1@beforeskip } } |
| 8616 |
{ \exp_not:c { CTEX@#1@afterskip } } |
| 8617 |
{ \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } |
| 8618 |
} |
| 8619 |
\cs_new:cpn { CTEX@#1@tocline } ##1##2 |
| 8620 |
{ \CTEXnumberline { ##1 } ##2 } |
| 8621 |
} |
| 8622 |
% \end{macrocode} |
| 8623 |
% |
| 8624 |
% \paragraph{附录标题} |
| 8625 |
% |
| 8626 |
% \begin{macro}[int]{appendix/name,appendix/number,appendix/numbering} |
| 8627 |
% \begin{macrocode} |
| 8628 |
\ctex_define:n |
| 8629 |
{ |
| 8630 |
appendix .meta:nn = { ctex / appendix } {#1} , |
| 8631 |
appendix / name .code:n = |
| 8632 |
{ \ctex_assign_heading_name:nn { appendix } {#1} } , |
| 8633 |
appendix / number .tl_set:N = \CTEX@appendix@number , |
| 8634 |
appendix / numbering .bool_set:N = \CTEX@appendix@numbering , |
| 8635 |
appendix / numbering .initial:n = true |
| 8636 |
} |
| 8637 |
\tl_new:N \CTEX@preappendix |
| 8638 |
\tl_new:N \CTEX@postappendix |
| 8639 |
% \end{macrocode} |
| 8640 |
% \end{macro} |
| 8641 |
% |
| 8642 |
% \begin{macro}[int]{\appendix} |
| 8643 |
% \begin{macrocode} |
| 8644 |
\cs_new_eq:NN \CTEX@save@appendix \appendix |
| 8645 |
\cs_gset_protected:Npn \appendix |
| 8646 |
{ |
| 8647 |
\CTEX@save@appendix |
| 8648 |
%<*article> |
| 8649 |
\gdef \CTEX@presection { \CTEX@preappendix } |
| 8650 |
\gdef \CTEX@thesection { \CTEX@appendix@number } |
| 8651 |
\gdef \CTEX@postsection { \CTEX@postappendix } |
| 8652 |
\gdef \CTEX@section@numbering { \CTEX@appendix@numbering } |
| 8653 |
%</article> |
| 8654 |
%<*book|report> |
| 8655 |
\gdef \CTEX@prechapter { \CTEX@preappendix } |
| 8656 |
\gdef \CTEX@thechapter { \CTEX@appendix@number } |
| 8657 |
\gdef \CTEX@postchapter { \CTEX@postappendix } |
| 8658 |
\gdef \CTEX@chapter@numbering { \CTEX@appendix@numbering } |
| 8659 |
%</book|report> |
| 8660 |
} |
| 8661 |
% \end{macrocode} |
| 8662 |
% \end{macro} |
| 8663 |
% |
| 8664 |
% \paragraph{设置 \pkg{hyperref} 宏包的标题锚点} |
| 8665 |
% |
| 8666 |
% \changes{v2.4.4}{2016/09/12}{改进 \pkg{hyperref} 宏包的标题锚点设置。} |
| 8667 |
% |
| 8668 |
% \begin{macro}[int]{\CTEX@makeanchor} |
| 8669 |
% 设置超链接跳转锚点,在 \pkg{hyperref} 载入后才有意义。 |
| 8670 |
% \begin{macrocode} |
| 8671 |
\cs_new_protected:Npn \CTEX@makeanchor #1 |
| 8672 |
{ } |
| 8673 |
% \end{macrocode} |
| 8674 |
% \end{macro} |
| 8675 |
% |
| 8676 |
% \begin{variable}{\c_@@_headings_cs_seq} |
| 8677 |
% 保存内部标题命令的 \CTeX{} 定义,用于随后比较。 |
| 8678 |
% \begin{macrocode} |
| 8679 |
\seq_const_from_clist:Nn \c_@@_headings_cs_seq |
| 8680 |
%<article> { part , spart , sect , ssect } |
| 8681 |
%<book|report> { part , spart , chapter , schapter , sect , ssect } |
| 8682 |
\seq_map_inline:Nn \c_@@_headings_cs_seq |
| 8683 |
{ |
| 8684 |
\cs_new_eq:cc { CTEX@ #1 } { @ #1 } |
| 8685 |
\cs_new_eq:cN { CTEX@makeanchor@ #1 } \CTEX@makeanchor |
| 8686 |
} |
| 8687 |
% \end{macrocode} |
| 8688 |
% \end{variable} |
| 8689 |
% |
| 8690 |
% \begin{macro}[int]{\CTEX@hyperheadinghook} |
| 8691 |
% \pkg{hyperref} 会重定义内部标题命令,目的在于为没有编号的标题设置锚点(这一功能受他的 |
| 8692 |
% \opt{implicit} 选项的控制)。我们在上面对标题命令的修改已经包含这一功能,如果这些标题命令在 |
| 8693 |
% \pkg{hyperref} 载入之前没有被修改过,则恢复 \CTeX{} 的定义。 |
| 8694 |
% \begin{macrocode} |
| 8695 |
\cs_new_protected:Npn \CTEX@hyperheadinghook |
| 8696 |
{ |
| 8697 |
\group_begin: |
| 8698 |
\legacy_if:nTF { Hy@implicit } |
| 8699 |
{ |
| 8700 |
\cs_set_eq:NN \H@old@chapter \Hy@org@chapter |
| 8701 |
\seq_map_inline:Nn \c_@@_headings_cs_seq |
| 8702 |
{ |
| 8703 |
\cs_if_eq:ccT { H@old@ ##1 } { CTEX@ ##1 } |
| 8704 |
{ |
| 8705 |
\cs_gset_eq:cc { @ ##1 } { CTEX@ ##1 } |
| 8706 |
\cs_gset_eq:cN { CTEX@makeanchor@ ##1 } \CTEX@makeanchor |
| 8707 |
} |
| 8708 |
} |
| 8709 |
} |
| 8710 |
{ |
| 8711 |
\seq_map_inline:Nn \c_@@_headings_cs_seq |
| 8712 |
{ \cs_gset_eq:cN { CTEX@makeanchor@ ##1 } \CTEX@makeanchor } |
| 8713 |
} |
| 8714 |
\group_end: |
| 8715 |
} |
| 8716 |
% \end{macrocode} |
| 8717 |
% \end{macro} |
| 8718 |
% |
| 8719 |
% \begin{macrocode} |
| 8720 |
\ctex_at_end_package:nn { hyperref } |
| 8721 |
{ |
| 8722 |
\cs_gset_protected:Npn \CTEX@makeanchor #1 |
| 8723 |
{ |
| 8724 |
\Hy@MakeCurrentHrefAuto {#1} |
| 8725 |
\Hy@raisedlink |
| 8726 |
{ |
| 8727 |
\hyper@anchorstart { \@currentHref } |
| 8728 |
\hyper@anchorend |
| 8729 |
} |
| 8730 |
} |
| 8731 |
\CTEX@hyperheadinghook |
| 8732 |
} |
| 8733 |
% \end{macrocode} |
| 8734 |
% |
| 8735 |
% \paragraph{兼容 \pkg{nameref} 宏包} |
| 8736 |
% |
| 8737 |
% \changes{v2.4.16}{2019/05/29}{更好地兼容 \pkg{nameref} 宏包。} |
| 8738 |
% |
| 8739 |
% \begin{macro}[int]{\CTEX@gettitle} |
| 8740 |
% 在 \pkg{nameref} 载入后才有意义,与上述 \pkg{hyperref} 的处理类似。 |
| 8741 |
% \begin{macrocode} |
| 8742 |
\cs_new_protected:Npn \CTEX@gettitle #1 |
| 8743 |
{ } |
| 8744 |
\ctex_at_end_package:nn { nameref } |
| 8745 |
{ |
| 8746 |
\cs_gset_protected:Npn \CTEX@gettitle { \NR@gettitle } |
| 8747 |
\seq_map_inline:Nn \c_@@_headings_cs_seq |
| 8748 |
{ |
| 8749 |
\cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 } |
| 8750 |
{ \cs_gset_eq:cc { @ #1 } { CTEX@ #1 } } |
| 8751 |
} |
| 8752 |
} |
| 8753 |
% \end{macrocode} |
| 8754 |
% \end{macro} |
| 8755 |
% |
| 8756 |
% \paragraph{兼容 \pkg{titlesec} 宏包} |
| 8757 |
% |
| 8758 |
% 我们修改了 \tn{@startsection} 的定义,它的第四个(\meta{beforeskip})和 |
| 8759 |
% 第五个(\meta{afterskip})参数的符号不再有特殊意义,改由相应的选项 |
| 8760 |
% \opt{afterindent} 和 \opt{runin} 来控制。 |
| 8761 |
% |
| 8762 |
% 引入 \pkg{titlesec} 宏包,并且未设置它的 \opt{loadonly} 选项时,\pkg{titlesec} |
| 8763 |
% 会展开 section 类标题获取它们的参数,进行初始设置。我们需要进行一些调整。 |
| 8764 |
% |
| 8765 |
% \begin{macro}[int]{\ctex_titlesec_hook:} |
| 8766 |
% \tn{titleformat} 的设置保存在名为 |\ttlf@|\meta{section} 的宏中备用,它的内容是 |
| 8767 |
% \begin{quote}\small |
| 8768 |
% |\ttlh@|\meta{shape}\Arg{format}\Arg{label}\Arg{sep}\Arg{before}\Arg{after} |
| 8769 |
% \end{quote} |
| 8770 |
% 我们这里的 \meta{shape} 为 |hang| 或者 |runin|。\tn{titlespacing} 的设置保存在 |
| 8771 |
% |\ttls@|\meta{section} 之中,它的内容是 |
| 8772 |
% \begin{quote}\small |
| 8773 |
% \Arg{left}\Arg{right}\Arg{before}\Arg{after}\Arg{afterindent} |
| 8774 |
% \end{quote} |
| 8775 |
% 其中 \meta{afterindent} 为 |1| 或 |0|,分别对应是否保留段首缩进。 |
| 8776 |
% 我们需要根据 \CTeX{} 的 \opt{runin} 和 \opt{afterindent} 选项调整 |
| 8777 |
% |\ttlh@|\meta{shape} 和 \meta{afterindent}。注意,由 \tn{ttl@extract} 得的 |
| 8778 |
% \meta{before} 和 \meta{after} 的值总是非负的,而 \CTeX{} 的 \opt{beforeskip} |
| 8779 |
% 和 \opt{afterskip} 是可以取负值的,但我们不打算调整它们了。 |
| 8780 |
% 如果使用了 \pkg{titlesec} 的 \opt{indentafter} 等选项,也不需要调整 |
| 8781 |
% |\ttls@|\meta{section}。 |
| 8782 |
% \begin{macrocode} |
| 8783 |
\cs_new_protected:Npn \ctex_titlesec_hook: |
| 8784 |
{ |
| 8785 |
\@ifpackagewith { titlesec } { explicit } |
| 8786 |
{ |
| 8787 |
\cs_set_eq:NN \@@_titlesec_format:Nn |
| 8788 |
\@@_titlesec_format_explicit:Nn |
| 8789 |
} |
| 8790 |
{ } |
| 8791 |
\clist_map_inline:nn |
| 8792 |
{ indentafter , noindentafter , indentfirst , nonindentfirst } |
| 8793 |
{ |
| 8794 |
\@ifpackagewith { titlesec } { ##1 } |
| 8795 |
{ |
| 8796 |
\clist_map_break:n |
| 8797 |
{ \cs_set_eq:NN \@@_titlesec_hook:n \@@_titlesec_format:n } |
| 8798 |
} |
| 8799 |
{ } |
| 8800 |
} |
| 8801 |
\seq_map_function:NN \c_@@_section_headings_seq \@@_titlesec_hook:n |
| 8802 |
} |
| 8803 |
\cs_new_protected:Npn \@@_titlesec_hook:n #1 |
| 8804 |
{ |
| 8805 |
\@@_titlesec_format:n {#1} |
| 8806 |
\exp_args:Nc \@@_titlesec_spacing:Nn { ttls@#1 } {#1} |
| 8807 |
} |
| 8808 |
\cs_new_protected:Npn \@@_titlesec_format:n #1 |
| 8809 |
{ |
| 8810 |
\cs_if_free:cF { ttlf@#1 } |
| 8811 |
{ \exp_args:Nc \@@_titlesec_format:Nn { ttlf@#1 } {#1} } |
| 8812 |
} |
| 8813 |
\cs_new_protected:Npn \@@_titlesec_format:Nn #1#2 |
| 8814 |
{ |
| 8815 |
\tl_set:Nx #1 |
| 8816 |
{ |
| 8817 |
\bool_if:cTF { CTEX@#2@runin } |
| 8818 |
{ \exp_not:N \ttlh@runin } |
| 8819 |
{ \exp_not:N \ttlh@hang } |
| 8820 |
\tl_tail:N #1 |
| 8821 |
} |
| 8822 |
} |
| 8823 |
\cs_new_protected:Npn \@@_titlesec_format_explicit:Nn #1#2 |
| 8824 |
{ |
| 8825 |
\cs_set_nopar:Npx #1 ##1 |
| 8826 |
{ |
| 8827 |
\bool_if:cTF { CTEX@#2@runin } |
| 8828 |
{ \exp_not:N \ttlh@runin } |
| 8829 |
{ \exp_not:N \ttlh@hang } |
| 8830 |
\exp_args:No \tl_tail:n { #1 { } } |
| 8831 |
} |
| 8832 |
} |
| 8833 |
\cs_new_protected:Npn \@@_titlesec_spacing:Nn #1#2 |
| 8834 |
{ \tl_set:Nx #1 { \exp_after:wN \@@_titlesec_spacing:nnnnnn #1 {#2} } } |
| 8835 |
\cs_new:Npn \@@_titlesec_spacing:nnnnnn #1#2#3#4#5#6 |
| 8836 |
{ |
| 8837 |
\exp_not:n { {#1} {#2} {#3} {#4} } |
| 8838 |
{ \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } |
| 8839 |
} |
| 8840 |
% \end{macrocode} |
| 8841 |
% \end{macro} |
| 8842 |
% |
| 8843 |
% \begin{macrocode} |
| 8844 |
\@ifpackageloaded { titlesec } |
| 8845 |
{ } |
| 8846 |
{ |
| 8847 |
\ctex_at_end_package:nn { titlesec } |
| 8848 |
{ |
| 8849 |
\@ifpackagewith { titlesec } { loadonly } |
| 8850 |
{ } |
| 8851 |
{ \ctex_titlesec_hook: } |
| 8852 |
} |
| 8853 |
} |
| 8854 |
% \end{macrocode} |
| 8855 |
% |
| 8856 |
% \changes{v2.4.4}{2016/09/13}{使用 \pkg{titlesec} 时,章节目录也使用 \CTeX{} 的编号。} |
| 8857 |
% 让编译时终端显示 \tn{CTEXthechapter},目录使用 |\CTEXtheXXX| 编号。 |
| 8858 |
% \begin{macrocode} |
| 8859 |
\ctex_at_end_package:nn { titlesec } |
| 8860 |
{ |
| 8861 |
%<*book|report> |
| 8862 |
\tl_set:Nn \ttl@chapterout { \typeout { \CTEXthechapter } } |
| 8863 |
%</book|report> |
| 8864 |
\cs_if_free:NF \ttl@tocpart |
| 8865 |
{ |
| 8866 |
\cs_set_protected:Npn \ttl@tocpart |
| 8867 |
{ \tl_set:Nn \ttl@a { \CTEXthepart \hspace { 1em } } } |
| 8868 |
} |
| 8869 |
\seq_map_inline:Nn \c_@@_headings_seq |
| 8870 |
{ |
| 8871 |
\cs_if_exist:cF { ttl@toc #1 } |
| 8872 |
{ |
| 8873 |
\cs_new_protected:cpx { ttl@toc #1 } |
| 8874 |
{ |
| 8875 |
\tl_set:Nn \exp_not:N \ttl@a |
| 8876 |
{ |
| 8877 |
\exp_not:N \protect |
| 8878 |
\exp_not:N \numberline { \exp_not:c { CTEXthe #1 } } |
| 8879 |
} |
| 8880 |
} |
| 8881 |
} |
| 8882 |
} |
| 8883 |
} |
| 8884 |
% \end{macrocode} |
| 8885 |
% |
| 8886 |
% \changes{v2.5.8}{2021/12/04}{兼容 \pkg{titlesec} 包和 \tn{CTEXifname}。} |
| 8887 |
% 在 \pkg{titlesec} 包定义的标题中更新 \tn{CTEXifname}。 |
| 8888 |
% \begin{macrocode} |
| 8889 |
\ctex_at_end_package:nn { titlesec } |
| 8890 |
{ |
| 8891 |
\ctex_patch_cmd:Nnn \ttl@labelling |
| 8892 |
{ \let \ifttl@toclabel \ifttl@label } |
| 8893 |
{ |
| 8894 |
\let \ifttl@toclabel \ifttl@label |
| 8895 |
\CTEX@updatettlifname |
| 8896 |
} |
| 8897 |
\cs_new_protected:Npn \CTEX@updatettlifname |
| 8898 |
{ \legacy_if:nTF { ttl@label } { \CTEX@ifnametrue } { \CTEX@ifnamefalse } } |
| 8899 |
} |
| 8900 |
% \end{macrocode} |
| 8901 |
% |
| 8902 |
% \paragraph{兼容 \pkg{titleps} 宏包} |
| 8903 |
% |
| 8904 |
% \changes{v2.3}{2015/12/25}{兼容 \pkg{titleps} 宏包。} |
| 8905 |
% |
| 8906 |
% 按照 \pkg{titleps} 宏包的实现机制,|\CTEXtheXXX| 等宏直到页眉排版时才会被展开, |
| 8907 |
% 这可能会造成问题\footnote{\url{https://github.com/CTeX-org/ctex-kit/issues/217}}。 |
| 8908 |
% |
| 8909 |
% \begin{macro}[int]{\ctex_titleps_hook:} |
| 8910 |
% 我们修改 \pkg{titleps} 包的内部命令 \tn{ttl@settopmark} 和 \tn{ttl@setsubmark}, |
| 8911 |
% 将 |\CTEXtheXXX| 等加入更新队列中。 |
| 8912 |
% \begin{macrocode} |
| 8913 |
\group_begin: |
| 8914 |
\char_set_catcode_other:N \# |
| 8915 |
\cs_new_protected:Npn \ctex_titleps_hook: |
| 8916 |
{ |
| 8917 |
\ctex_patch_cmd:Nnn \ttl@settopmark |
| 8918 |
{ \protect \@namedef { the#1 } { \@nameuse { the#1 } } } |
| 8919 |
{ |
| 8920 |
\protect \@namedef { the#1 } { \@nameuse { the#1 } } |
| 8921 |
\CTEX@titlepslabel@set {#1} |
| 8922 |
} |
| 8923 |
\ctex_patch_cmd:Nnn \ttl@setsubmark |
| 8924 |
{ \protect \@namedef { the#1 } { } } |
| 8925 |
{ |
| 8926 |
\protect \@namedef { the#1 } { } |
| 8927 |
\CTEX@titlepslabel@clear {#1} |
| 8928 |
} |
| 8929 |
\ctex_patch_cmd:Nnn \ttl@setsubmark |
| 8930 |
{ \protect \@namedef { the#2 } { \@nameuse { the#2 } } } |
| 8931 |
{ |
| 8932 |
\protect \@namedef { the#2 } { \@nameuse { the#2 } } |
| 8933 |
\CTEX@titlepslabel@set {#2} |
| 8934 |
} |
| 8935 |
} |
| 8936 |
\group_end: |
| 8937 |
% \end{macrocode} |
| 8938 |
% \end{macro} |
| 8939 |
% |
| 8940 |
% \begin{macro}[int]{\CTEX@titlepslabel@set,\CTEX@titlepslabel@clear} |
| 8941 |
% 这两个函数要在随后被 \tn{xdef} 展开来获得 |\CTEXtheXXX| 的内容,不应该用 |
| 8942 |
% \tn{protected} 来定义。 |
| 8943 |
% \begin{macrocode} |
| 8944 |
\cs_new:Npn \CTEX@titlepslabel@set #1 |
| 8945 |
{ |
| 8946 |
\cs_if_free:cF { CTEXthe#1 } |
| 8947 |
{ \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } } |
| 8948 |
} |
| 8949 |
\cs_new:Npn \CTEX@titlepslabel@clear #1 |
| 8950 |
{ |
| 8951 |
\cs_if_free:cF { CTEXthe#1 } |
| 8952 |
{ \protect \@namedef { CTEXthe#1 } { } } |
| 8953 |
} |
| 8954 |
% \end{macrocode} |
| 8955 |
% \end{macro} |
| 8956 |
% |
| 8957 |
% \pkg{titleps} 宏包的功能可以由 \pkg{titlesec} 的选项 \opt{pagestyles} 引入。 |
| 8958 |
% \begin{macrocode} |
| 8959 |
\ctex_at_end_package:nn { titlesec } |
| 8960 |
{ \cs_if_free:NF \ttl@settopmark { \ctex_titleps_hook: } } |
| 8961 |
\ctex_at_end_package:nn { titleps } { \ctex_titleps_hook: } |
| 8962 |
% \end{macrocode} |
| 8963 |
% |
| 8964 |
% 除此之外,也可以使用 \pkg{titleps} 提供的命令 \tn{newtitlemark} 来完成: |
| 8965 |
% \begin{verbatim} |
| 8966 |
% \newtitlemark { \CTEXthechapter } |
| 8967 |
% \newtitlemark { \CTEXthesection } |
| 8968 |
% \end{verbatim} |
| 8969 |
% 但 \tn{newtitlemark} 不包含章节间的层次信息,功能上不及修改内部命令完整。 |
| 8970 |
% |
| 8971 |
% \changes{v2.4.6}{2016/10/31}{重新初始化 \tn{ifthechapter} 等。} |
| 8972 |
% \begin{macro}[int]{\ttl@setifthe} |
| 8973 |
% 使 |\iftheXXX| 等命令在页眉设置中可用。 |
| 8974 |
% \begin{macrocode} |
| 8975 |
\ctex_at_end_package:nn { titleps } |
| 8976 |
{ |
| 8977 |
\cs_set_protected:Npn \ttl@setifthe #1 |
| 8978 |
{ |
| 8979 |
\exp_args:Nco \cs_set:Npn { ifthe #1 } |
| 8980 |
{ |
| 8981 |
\CTEXifname |
| 8982 |
{ \protect \@firstoftwo } |
| 8983 |
{ \protect \@secondoftwo } |
| 8984 |
} |
| 8985 |
} |
| 8986 |
\seq_map_function:NN \c_@@_headings_seq \ttl@setifthe |
| 8987 |
} |
| 8988 |
% \end{macrocode} |
| 8989 |
% \end{macro} |
| 8990 |
% |
| 8991 |
% |
| 8992 |
% \subsubsection{目录标签的宽度} |
| 8993 |
% |
| 8994 |
% \begin{macro}{\CTEX@toc@width@n} |
| 8995 |
% \begin{macrocode} |
| 8996 |
\cs_new_protected:Npn \CTEX@toc@width@n #1 |
| 8997 |
{ |
| 8998 |
\hbox_set:Nn \l_@@_tmp_box {#1} |
| 8999 |
\dim_set:Nn \@tempdima |
| 9000 |
{ |
| 9001 |
\dim_max:nn { \@tempdima } |
| 9002 |
{ \box_wd:N \l_@@_tmp_box + \f@size \p@ / 2 } |
| 9003 |
} |
| 9004 |
} |
| 9005 |
% \end{macrocode} |
| 9006 |
% \end{macro} |
| 9007 |
% |
| 9008 |
% \changes{v2.5}{2020/01/11}{兼容 \pkg{titletoc} 宏包。} |
| 9009 |
% |
| 9010 |
% \begin{macro}{\numberline,\@@_patch_toc_width:n} |
| 9011 |
% 为 \tn{numberline} 命令打补丁,并兼容 \pkg{tocloft} 和 \pkg{titletoc} 宏包。 |
| 9012 |
% |
| 9013 |
% 这里需要替换 |#| 本身,因此需要先切换为 other 类。表示参数的 |#| 用 |
| 9014 |
% \cs{c_parameter_token} 代替。 |
| 9015 |
% \begin{macrocode} |
| 9016 |
\group_begin: |
| 9017 |
\char_set_catcode_other:N \# |
| 9018 |
\use:n |
| 9019 |
{ |
| 9020 |
\group_end: |
| 9021 |
\ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } |
| 9022 |
{ \CTEX@toc@width@n {#1} } |
| 9023 |
{ } |
| 9024 |
{ \ctex_patch_failure:N \numberline } |
| 9025 |
\cs_new_protected:Npn \@@_patch_toc_width:n \c_parameter_token 1 |
| 9026 |
{ |
| 9027 |
\@ifpackageloaded { \c_parameter_token 1 } |
| 9028 |
{ } |
| 9029 |
{ |
| 9030 |
\ctex_at_end_package:nn { \c_parameter_token 1 } |
| 9031 |
{ |
| 9032 |
\ctex_preto_cmd:NnnTF \numberline |
| 9033 |
{ \char_set_catcode_letter:n { 64 } } |
| 9034 |
{ \CTEX@toc@width@n {#1} } |
| 9035 |
{ } |
| 9036 |
{ \ctex_patch_failure:N \numberline } |
| 9037 |
} |
| 9038 |
} |
| 9039 |
} |
| 9040 |
} |
| 9041 |
\@@_patch_toc_width:n { tocloft } |
| 9042 |
\@@_patch_toc_width:n { titletoc } |
| 9043 |
% \end{macrocode} |
| 9044 |
% \end{macro} |
| 9045 |
% |
| 9046 |
% \subsubsection{页眉信息的修改} |
| 9047 |
% |
| 9048 |
% \begin{macro}[int]{\ps@headings} |
| 9049 |
% \changes{v2.4.5}{2016/10/01}{修复补丁失败。} |
| 9050 |
% \changes{v2.4.7}{2016/12/23}{修复 \cls{ctexrep} 类的 \tn{chaptermark} 汉化错误。} |
| 9051 |
% \changes{v2.4.11}{2017/09/13}{补充页眉空格。} |
| 9052 |
% \begin{macrocode} |
| 9053 |
%<*article> |
| 9054 |
\legacy_if:nTF { @twoside } |
| 9055 |
{ |
| 9056 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9057 |
{ \ifnum \c@secnumdepth > \z@ \thesection \quad \fi } |
| 9058 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 9059 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9060 |
{ \ifnum \c@secnumdepth > \@ne \thesubsection \quad \fi } |
| 9061 |
{ \CTEXifname { \CTEXthesubsection \quad } { } } |
| 9062 |
} |
| 9063 |
% \end{macrocode} |
| 9064 |
% 不知为何,标准文档类此处对 \texttt{secnumdepth} 的判断为 $0$,与 \tn{section} 的层次 $1$ 不符。 |
| 9065 |
% \begin{macrocode} |
| 9066 |
{ |
| 9067 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9068 |
{ \ifnum \c@secnumdepth > \m@ne \thesection \quad \fi } |
| 9069 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 9070 |
} |
| 9071 |
%</article> |
| 9072 |
%<*book|report> |
| 9073 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9074 |
{ |
| 9075 |
%<book> \ifnum \c@secnumdepth > \m@ne \if@mainmatter |
| 9076 |
%<report> \ifnum \c@secnumdepth > \m@ne |
| 9077 |
\@chapapp \ \thechapter . ~ \ % |
| 9078 |
%<report> \fi |
| 9079 |
%<book> \fi \fi |
| 9080 |
} |
| 9081 |
{ \CTEXifname { \CTEXthechapter \quad } { } } |
| 9082 |
\legacy_if:nT { @twoside } |
| 9083 |
{ |
| 9084 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9085 |
{ \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi } |
| 9086 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 9087 |
} |
| 9088 |
%</book|report> |
| 9089 |
% \end{macrocode} |
| 9090 |
% \end{macro} |
| 9091 |
% |
| 9092 |
% |
| 9093 |
% \begin{macro}[int]{\f@nch@initialise} |
| 9094 |
% 这里对 \pkg{fancyhdr} 宏包打补丁。原来 \pkg{fancyhdr} 宏包中使用 |
| 9095 |
% \tn{thesection} 等宏表示页眉中的章节编号,这里改用 \pkg{ctex} 包所用的 |
| 9096 |
% \tn{CTEXthesection} 系列宏。 |
| 9097 |
% \changes{v2.5.6}{2021/01/11}{更新 \pkg{fancyhdr} 宏包的补丁。} |
| 9098 |
% \begin{macrocode} |
| 9099 |
\ctex_at_end_package:nn { fancyhdr } |
| 9100 |
{ |
| 9101 |
\ctex_patch_cmd:Nnn \f@nch@initialise |
| 9102 |
{ \ifnum \c@secnumdepth > \z@ \thesection \hskip 1em \relax \fi } |
| 9103 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 9104 |
\ctex_patch_cmd:Nnn \f@nch@initialise |
| 9105 |
{ \ifnum \c@secnumdepth > \@ne \thesubsection \hskip 1em \relax \fi } |
| 9106 |
{ \CTEXifname { \CTEXthesubsection \quad } { } } |
| 9107 |
\ctex_patch_cmd:Nnn \f@nch@initialise |
| 9108 |
{ \ifnum \c@secnumdepth > \m@ne \@chapapp\ \thechapter . ~ \ \fi } |
| 9109 |
{ \CTEXifname { \CTEXthechapter \quad } { } } |
| 9110 |
\ctex_patch_cmd:Nnn \f@nch@initialise |
| 9111 |
{ \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi } |
| 9112 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 9113 |
\f@nch@initialise |
| 9114 |
% \end{macrocode} |
| 9115 |
% \pkg{fancyhdr} 的 \opt{headings} 选项会重定义 \cs{ps@headings}, |
| 9116 |
% 这里也要打补丁。 |
| 9117 |
% \begin{macrocode} |
| 9118 |
\@ifpackagewith { fancyhdr } { headings } |
| 9119 |
{ |
| 9120 |
%<*article> |
| 9121 |
\legacy_if:nTF { @twoside } |
| 9122 |
{ |
| 9123 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9124 |
{ \ifnum \c@secnumdepth > \z@ \thesection \quad \fi } |
| 9125 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 9126 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9127 |
{ \ifnum \c@secnumdepth > \@ne \thesubsection \quad \fi } |
| 9128 |
{ \CTEXifname { \CTEXthesubsection \quad } { } } |
| 9129 |
} |
| 9130 |
{ |
| 9131 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9132 |
{ \ifnum \c@secnumdepth > \z@ \thesection \quad \fi } |
| 9133 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 9134 |
} |
| 9135 |
%</article> |
| 9136 |
%<*book|report> |
| 9137 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9138 |
{ |
| 9139 |
%<book> \ifnum \c@secnumdepth > \m@ne \if@mainmatter |
| 9140 |
%<report> \ifnum \c@secnumdepth > \m@ne |
| 9141 |
\@chapapp \ \thechapter . ~ \ % |
| 9142 |
%<report> \fi |
| 9143 |
%<book> \fi \fi |
| 9144 |
} |
| 9145 |
{ \CTEXifname { \CTEXthechapter \quad } { } } |
| 9146 |
\legacy_if:nT { @twoside } |
| 9147 |
{ |
| 9148 |
\ctex_patch_cmd:Nnn \ps@headings |
| 9149 |
{ \ifnum \c@secnumdepth > \z@ \thesection . ~ \ \fi } |
| 9150 |
{ \CTEXifname { \CTEXthesection \quad } { } } |
| 9151 |
} |
| 9152 |
%</book|report> |
| 9153 |
} |
| 9154 |
{ } |
| 9155 |
} |
| 9156 |
% \end{macrocode} |
| 9157 |
% \end{macro} |
| 9158 |
% |
| 9159 |
% \begin{macrocode} |
| 9160 |
%</article|book|report> |
| 9161 |
% \end{macrocode} |
| 9162 |
% |
| 9163 |
% \subsubsection{\cls{beamer} 标题页模板的修改} |
| 9164 |
% |
| 9165 |
% \begin{macrocode} |
| 9166 |
%<*beamer> |
| 9167 |
% \end{macrocode} |
| 9168 |
% |
| 9169 |
% \begin{macrocode} |
| 9170 |
\ExplSyntaxOff |
| 9171 |
% \end{macrocode} |
| 9172 |
% |
| 9173 |
% \changes{v2.4.15}{2019/01/29}{局部指定 \opt{autoindent} 为 \opt{false},并交换 |
| 9174 |
% \tn{CTEX@XXX@indent} 与 \tn{CTEX@XXX@format} 的顺序。} |
| 9175 |
% |
| 9176 |
% 对应 \tn{partpage}。 |
| 9177 |
% \begin{macrocode} |
| 9178 |
\defbeamertemplate*{part page}{CTEX}[1][]{% |
| 9179 |
\begingroup |
| 9180 |
% \centering |
| 9181 |
% {\usebeamerfont{part name}% |
| 9182 |
% \usebeamercolor[fg]{part name}\partname~\insertromanpartnumber} |
| 9183 |
% \vskip1em\par |
| 9184 |
\par \addvspace{\glueexpr\CTEX@part@beforeskip\relax}% |
| 9185 |
\CTEX@heading@format@initial |
| 9186 |
\CTEX@part@format{% |
| 9187 |
\CTEX@indentbox{\CTEX@part@indent}% |
| 9188 |
\ifodd \CTEX@part@numbering |
| 9189 |
\CTEX@partname \CTEX@part@aftername |
| 9190 |
\fi |
| 9191 |
\begin{beamercolorbox}[sep=16pt,center,#1]{part title} |
| 9192 |
% \usebeamerfont{part title}\insertpart\par |
| 9193 |
\CTEX@part@titleformat \insertpart \CTEX@part@aftertitle |
| 9194 |
\end{beamercolorbox}}% |
| 9195 |
\par \addvspace{\glueexpr\CTEX@part@afterskip\relax}% |
| 9196 |
\endgroup} |
| 9197 |
% \end{macrocode} |
| 9198 |
% |
| 9199 |
% 对应 \tn{sectionpage}。 |
| 9200 |
% \begin{macrocode} |
| 9201 |
\defbeamertemplate*{section page}{CTEX}[1][]{% |
| 9202 |
\begingroup |
| 9203 |
% \centering |
| 9204 |
% {\usebeamerfont{section name}% |
| 9205 |
% \usebeamercolor[fg]{section name}\sectionname~\insertsectionnumber} |
| 9206 |
% \vskip1em\par |
| 9207 |
\par \addvspace{\glueexpr\CTEX@section@beforeskip\relax}% |
| 9208 |
\CTEX@heading@format@initial |
| 9209 |
\CTEX@section@format{% |
| 9210 |
\CTEX@indentbox{\CTEX@section@indent}% |
| 9211 |
\ifodd \CTEX@section@numbering |
| 9212 |
\CTEX@sectionname \CTEX@section@aftername |
| 9213 |
\fi |
| 9214 |
\begin{beamercolorbox}[sep=12pt,center,#1]{part title} |
| 9215 |
% \usebeamerfont{section title}\insertsection\par |
| 9216 |
\CTEX@section@titleformat \insertsection \CTEX@section@aftertitle |
| 9217 |
\end{beamercolorbox}}% |
| 9218 |
\par \addvspace{\glueexpr\CTEX@section@afterskip\relax}% |
| 9219 |
\endgroup} |
| 9220 |
% \end{macrocode} |
| 9221 |
% |
| 9222 |
% 对应 \tn{subsectionpage}。 |
| 9223 |
% \begin{macrocode} |
| 9224 |
\defbeamertemplate*{subsection page}{CTEX}[1][]{% |
| 9225 |
\begingroup |
| 9226 |
% \centering |
| 9227 |
% {\usebeamerfont{subsection name}% |
| 9228 |
% \usebeamercolor[fg]{subsection name}\subsectionname~\insertsubsectionnumber} |
| 9229 |
% \vskip1em\par |
| 9230 |
\par \addvspace{\glueexpr\CTEX@subsection@beforeskip\relax}% |
| 9231 |
\CTEX@heading@format@initial |
| 9232 |
\CTEX@subsection@format{% |
| 9233 |
\CTEX@indentbox{\CTEX@subsection@indent}% |
| 9234 |
\ifodd \CTEX@subsection@numbering |
| 9235 |
\CTEX@subsectionname \CTEX@subsection@aftername |
| 9236 |
\fi |
| 9237 |
\begin{beamercolorbox}[sep=8pt,center,#1]{part title} |
| 9238 |
% \usebeamerfont{subsection title}\insertsubsection\par |
| 9239 |
\CTEX@subsection@titleformat \insertsubsection \CTEX@subsection@aftertitle |
| 9240 |
\end{beamercolorbox}}% |
| 9241 |
\par \addvspace{\glueexpr\CTEX@subsection@afterskip\relax}% |
| 9242 |
\endgroup} |
| 9243 |
% \end{macrocode} |
| 9244 |
% |
| 9245 |
% 将 \cls{beamer} 的默认模板重定向为 \texttt{CTEX} 模板。 |
| 9246 |
% \begin{macrocode} |
| 9247 |
\defbeamertemplatealias{part page}{default}{CTEX} |
| 9248 |
\defbeamertemplatealias{section page}{default}{CTEX} |
| 9249 |
\defbeamertemplatealias{subsection page}{default}{CTEX} |
| 9250 |
% \end{macrocode} |
| 9251 |
% |
| 9252 |
% \begin{macrocode} |
| 9253 |
\ExplSyntaxOn |
| 9254 |
% \end{macrocode} |
| 9255 |
% |
| 9256 |
% \begin{macrocode} |
| 9257 |
%</beamer> |
| 9258 |
% \end{macrocode} |
| 9259 |
% |
| 9260 |
% \subsubsection{标题编号和目录的层次设置} |
| 9261 |
% |
| 9262 |
% \changes{v2.5.2}{2020/05/06}{新增标题选项 \opt{secnumdepth} 和 \opt{tocdepth}。} |
| 9263 |
% |
| 9264 |
% \begin{macro}{secnumdepth, tocdepth} |
| 9265 |
% \opt{secnumdepth} 在 \cls{beamer} 下无意义。 |
| 9266 |
% \begin{macrocode} |
| 9267 |
\ctex_define:n |
| 9268 |
{ |
| 9269 |
%<*!beamer> |
| 9270 |
secnumdepth .code:n = \ctex_heading_depth:ne { secnumdepth } {#1} , |
| 9271 |
secnumdepth .value_required:n = true , |
| 9272 |
%</!beamer> |
| 9273 |
tocdepth .code:n = \ctex_heading_depth:ne { tocdepth } {#1} , |
| 9274 |
tocdepth .value_required:n = true |
| 9275 |
} |
| 9276 |
% \end{macrocode} |
| 9277 |
% \end{macro} |
| 9278 |
% |
| 9279 |
% \begin{macro}[int]{\ctex_heading_depth:nn} |
| 9280 |
% 注意此处 \tn{setcounter} 的赋值是全局的。 |
| 9281 |
% \begin{macrocode} |
| 9282 |
\cs_new_protected:Npn \ctex_heading_depth:nn #1#2 |
| 9283 |
{ |
| 9284 |
\prop_get:NnNTF \c_@@_heading_level_prop {#2} \l_@@_tmp_tl |
| 9285 |
{ \setcounter {#1} { \l_@@_tmp_tl } } |
| 9286 |
{ \setcounter {#1} { \int_eval:n {#2} } } |
| 9287 |
} |
| 9288 |
\cs_generate_variant:Nn \ctex_heading_depth:nn { ne } |
| 9289 |
% \end{macrocode} |
| 9290 |
% \end{macro} |
| 9291 |
% |
| 9292 |
% \begin{variable}[int]{\c_@@_heading_level_prop} |
| 9293 |
% 章节层次与名称的对应表。 |
| 9294 |
% \begin{macrocode} |
| 9295 |
\prop_const_from_keyval:Nn \c_@@_heading_level_prop |
| 9296 |
{ |
| 9297 |
%<*article|beamer> |
| 9298 |
part = 0 , |
| 9299 |
%</article|beamer> |
| 9300 |
%<*book|report> |
| 9301 |
part = -1 , |
| 9302 |
chapter = 0 , |
| 9303 |
%</book|report> |
| 9304 |
section = 1 , |
| 9305 |
subsection = 2 , |
| 9306 |
subsubsection = 3 , |
| 9307 |
paragraph = 4 , |
| 9308 |
subparagraph = 5 |
| 9309 |
} |
| 9310 |
% \end{macrocode} |
| 9311 |
% \end{variable} |
| 9312 |
% |
| 9313 |
% \subsubsection{标签引用数字的汉化} |
| 9314 |
% |
| 9315 |
% \begin{macro}[int]{\refstepcounter} |
| 9316 |
% 对标题进行引用时,设置标签为通过 \opt{number} 选项设置的形式。 |
| 9317 |
% \begin{macrocode} |
| 9318 |
\cs_new_protected:Npn \CTEX@setcurrentlabel@n #1 |
| 9319 |
{ |
| 9320 |
\protected@edef \@currentlabel |
| 9321 |
{ |
| 9322 |
\cs_if_exist:cTF { CTEX@the#1 } |
| 9323 |
{ \exp_args:cc { p@#1 } { CTEX@the#1 } } |
| 9324 |
{ \exp_not:o { \@currentlabel } } |
| 9325 |
} |
| 9326 |
} |
| 9327 |
% \end{macrocode} |
| 9328 |
% \end{macro} |
| 9329 |
% |
| 9330 |
% \begin{macro}[int]{\ctex_varioref_hook:} |
| 9331 |
% 关于标签引用的宏包可能会修改 \tn{refstepcounter}。其中 \pkg{cleveref} 和 |
| 9332 |
% \pkg{hyperref} 宏包都会保存之前的定义,并且它们都要求尽可能晚的被载入,所以 |
| 9333 |
% 对我们上述的修改影响不大。需要注意的是 \pkg{varioref} 宏包,如果它在 |
| 9334 |
% \CTeX{} 之后被载入,我们之前的修改将会被覆盖。 |
| 9335 |
% 较新版 \LaTeX \ 内核已经包含 \tn{labelformat},可以直接使用。 |
| 9336 |
% \begin{macrocode} |
| 9337 |
\cs_new_protected:Npn \ctex_varioref_hook: |
| 9338 |
{ |
| 9339 |
\seq_map_inline:Nn \c_@@_headings_seq |
| 9340 |
{ \ctex_fix_varioref_label:n { ##1 } } |
| 9341 |
\ctex_at_end_package:nn { cleveref } { \ctex_cleveref_hook: } |
| 9342 |
} |
| 9343 |
% \end{macrocode} |
| 9344 |
% \end{macro} |
| 9345 |
% |
| 9346 |
% \begin{macro}{\ctex_fix_varioref_label:n} |
| 9347 |
% \pkg{varioref} 宏包的 \tn{labelformat} 实际上是定义一个以 |\the<#1>| 为参数的宏 |
| 9348 |
% |\p@<#1>|。\LaTeX{} 在定义计数器 |<#1>| 时,都会将 |\p@<#1>| 初始化为 \tn{@empty}。 |
| 9349 |
% 如果这个宏非空,说明用户自定义了标签格式,我们就不再修改。这里不能使用 |
| 9350 |
% \cs{exp_args:Nnc},因为 \texttt{c} 这种展开格式不会将参数放在花括号内。而 |
| 9351 |
% \tn{labelformat} 的定义是 |
| 9352 |
% \begin{verbatim} |
| 9353 |
% \def\labelformat#1{\expandafter\def\csname p@#1\endcsname##1} |
| 9354 |
% \end{verbatim} |
| 9355 |
% 它的第二个参数必须放在花括号内,否则将会被作为宏的定界符号。 |
| 9356 |
% \begin{macrocode} |
| 9357 |
\cs_new_protected:Npn \ctex_fix_varioref_label:n #1 |
| 9358 |
{ |
| 9359 |
\tl_if_empty:cT { p@#1 } |
| 9360 |
{ \exp_args:Nnx \labelformat {#1} { \exp_not:c { CTEX@the#1 } } } |
| 9361 |
} |
| 9362 |
% \end{macrocode} |
| 9363 |
% \end{macro} |
| 9364 |
% |
| 9365 |
% \changes{v2.5.3}{2020/06/04}{兼容 \pkg{cleveref}。} |
| 9366 |
% \changes{v2.5.4}{2020/06/17}{同时兼容 \pkg{cleveref} 和 \pkg{hyperref}。} |
| 9367 |
% \changes{v2.5.7}{2021/06/04}{同时兼容 \pkg{cleveref} 和 \cls{beamer}。} |
| 9368 |
% \begin{macro}{\ctex_cleveref_hook:,\@@_cleveref_hook_aux:N} |
| 9369 |
% 需要将\pkg{cleveref} 包对应命令中 |\p@|\meta{counter} 的参数及时展开,以兼容 \tn{labelformat}。 |
| 9370 |
% \begin{macrocode} |
| 9371 |
\cs_new_protected:Npn \ctex_cleveref_hook: |
| 9372 |
{ |
| 9373 |
\@ifpackageloaded { hyperref } |
| 9374 |
{ |
| 9375 |
\@ifpackagewith { hyperref } { implicit = false } |
| 9376 |
{ } |
| 9377 |
{ \@@_cleveref_hook_aux:N \H@refstepcounter } |
| 9378 |
} |
| 9379 |
{ |
| 9380 |
\@@_cleveref_hook_aux:N \refstepcounter@noarg |
| 9381 |
\@@_cleveref_hook_aux:N \refstepcounter@optarg |
| 9382 |
} |
| 9383 |
\@@_cleveref_hook_aux:N \appendix |
| 9384 |
} |
| 9385 |
\cs_new_protected:Npn \@@_cleveref_hook_aux:N #1 |
| 9386 |
{ |
| 9387 |
\ctex_patch_cmd_all:NnnnTF #1 |
| 9388 |
{ |
| 9389 |
\ExplSyntaxOff |
| 9390 |
\char_set_catcode_letter:n { 64 } |
| 9391 |
} |
| 9392 |
{ \endcsname \csname the } |
| 9393 |
{ \expandafter \endcsname \csname the } |
| 9394 |
{ } |
| 9395 |
{ \ctex_patch_failure:N #1 } |
| 9396 |
} |
| 9397 |
% \end{macrocode} |
| 9398 |
% \end{macro} |
| 9399 |
% |
| 9400 |
% \changes{v2.5}{2020/04/19}{应用新内核中的 \tn{labelformat}。} |
| 9401 |
% |
| 9402 |
% 如果 \pkg{varioref} 已经被载入,则使用它来设置。 |
| 9403 |
% \begin{macrocode} |
| 9404 |
\cs_if_exist:NTF \labelformat |
| 9405 |
{ \ctex_varioref_hook: } |
| 9406 |
{ |
| 9407 |
\cs_new_eq:NN \CTEX@save@refstepcounter \refstepcounter |
| 9408 |
\RenewDocumentCommand \refstepcounter { m } |
| 9409 |
{ |
| 9410 |
\CTEX@save@refstepcounter {#1} |
| 9411 |
\CTEX@setcurrentlabel@n {#1} |
| 9412 |
} |
| 9413 |
\ctex_at_end_package:nn { varioref } { \ctex_varioref_hook: } |
| 9414 |
} |
| 9415 |
% \end{macrocode} |
| 9416 |
% |
| 9417 |
% \subsubsection{载入 \meta{scheme} 文件} |
| 9418 |
% |
| 9419 |
% \begin{macrocode} |
| 9420 |
\ctex_scheme_input:o { \l_@@_scheme_tl } |
| 9421 |
% \end{macrocode} |
| 9422 |
% |
| 9423 |
% \begin{macrocode} |
| 9424 |
%</class|heading> |
| 9425 |
% \end{macrocode} |
| 9426 |
% |
| 9427 |
% \subsubsection{标题格式的 \opt{scheme} 定义} |
| 9428 |
% |
| 9429 |
% 下面使用 \CTeX 文档类的设置方式,\opt{plain} 模拟标准文档类直接定义或以 |
| 9430 |
% \tn{@startsection} 设定的章节标题格式,\opt{chinese} 汉化的标题格式。 |
| 9431 |
% |
| 9432 |
% \begin{macrocode} |
| 9433 |
%<*scheme&(article|book|report|beamer)> |
| 9434 |
% \end{macrocode} |
| 9435 |
% |
| 9436 |
% \changes{v2.1}{2015/05/30}{修复 \cls{ctexbook} 和 \cls{ctexrep} 类的中文 |
| 9437 |
% \opt{part/number} 选项初值为空的错误。} |
| 9438 |
% \changes{v2.2}{2015/06/30}{将中文版式下的 \texttt{part} 和 \texttt{chapter} |
| 9439 |
% 标题的 \opt{nameformat} 和 \opt{titleformat} 选项的初值合并到 \opt{format} 中。} |
| 9440 |
% |
| 9441 |
% \begin{macrocode} |
| 9442 |
\ctex_set:nn { part } |
| 9443 |
{ |
| 9444 |
aftertitle = \par , |
| 9445 |
%<*article|book|report> |
| 9446 |
hang = false , |
| 9447 |
%</article|book|report> |
| 9448 |
%<*plain> |
| 9449 |
name = \partname \space , |
| 9450 |
%<*article|book|report> |
| 9451 |
number = \thepart , |
| 9452 |
%</article|book|report> |
| 9453 |
%<*beamer> |
| 9454 |
number = \insertromanpartnumber , |
| 9455 |
%</beamer> |
| 9456 |
%</plain> |
| 9457 |
%<*chinese> |
| 9458 |
number = \chinese { part } , |
| 9459 |
%</chinese> |
| 9460 |
%<*article> |
| 9461 |
beforeskip = 4ex , |
| 9462 |
afterskip = 3ex , |
| 9463 |
%<*plain> |
| 9464 |
format = \raggedright , |
| 9465 |
nameformat = \Large \bfseries , |
| 9466 |
aftername = \par \nobreak , |
| 9467 |
titleformat = \huge \bfseries , |
| 9468 |
afterindent = false |
| 9469 |
%</plain> |
| 9470 |
%<*chinese> |
| 9471 |
format = \Large \bfseries \centering , |
| 9472 |
aftername = \quad , |
| 9473 |
afterindent = true |
| 9474 |
%</chinese> |
| 9475 |
%</article> |
| 9476 |
%<*book|report> |
| 9477 |
aftername = \par \vskip 20 \p@ , |
| 9478 |
beforeskip = 0pt \@plus 1fil , |
| 9479 |
afterskip = 0pt \@plus 1fil , |
| 9480 |
pagestyle = plain , |
| 9481 |
break = \if@openright \cleardoublepage \else \clearpage \fi , |
| 9482 |
%<*plain> |
| 9483 |
format = \centering , |
| 9484 |
nameformat = \huge \bfseries , |
| 9485 |
titleformat = \Huge \bfseries |
| 9486 |
%</plain> |
| 9487 |
%<*chinese> |
| 9488 |
format = \huge \bfseries \centering |
| 9489 |
%</chinese> |
| 9490 |
%</book|report> |
| 9491 |
%<*beamer> |
| 9492 |
format = \centering , |
| 9493 |
nameformat = \usebeamerfont { part ~ name } |
| 9494 |
\usebeamercolor [fg] { part ~ name } , |
| 9495 |
aftername = \vskip 1em \par , |
| 9496 |
titleformat = \usebeamerfont { part ~ title } |
| 9497 |
%</beamer> |
| 9498 |
} |
| 9499 |
% \end{macrocode} |
| 9500 |
% |
| 9501 |
% \begin{macrocode} |
| 9502 |
%<*book|report> |
| 9503 |
\ctex_set:nn { chapter } |
| 9504 |
{ |
| 9505 |
pagestyle = plain , |
| 9506 |
aftertitle = \par , |
| 9507 |
hang = false , |
| 9508 |
beforeskip = 50 \p@ , |
| 9509 |
afterskip = 40 \p@ , |
| 9510 |
lofskip = 10 \p@ , |
| 9511 |
lotskip = 10 \p@ , |
| 9512 |
break = \if@openright \cleardoublepage \else \clearpage \fi , |
| 9513 |
%<*plain> |
| 9514 |
name = \chaptername \space , |
| 9515 |
number = \thechapter , |
| 9516 |
format = \raggedright , |
| 9517 |
nameformat = \huge \bfseries , |
| 9518 |
aftername = \par \nobreak \vskip 20 \p@ , |
| 9519 |
titleformat = \Huge \bfseries , |
| 9520 |
afterindent = false , |
| 9521 |
tocline = \CTEXnumberline {#1} #2 |
| 9522 |
%</plain> |
| 9523 |
%<*chinese> |
| 9524 |
number = \chinese { chapter } , |
| 9525 |
format = \huge \bfseries \centering , |
| 9526 |
aftername = \quad , |
| 9527 |
afterindent = true |
| 9528 |
%</chinese> |
| 9529 |
} |
| 9530 |
%</book|report> |
| 9531 |
% \end{macrocode} |
| 9532 |
% |
| 9533 |
% \begin{macrocode} |
| 9534 |
\ctex_set:nn { section } |
| 9535 |
{ |
| 9536 |
%<*article|book|report> |
| 9537 |
number = \thesection , |
| 9538 |
aftername = \quad , |
| 9539 |
aftertitle = \@@@@par , |
| 9540 |
beforeskip = 3.5ex \@plus 1ex \@minus .2ex , |
| 9541 |
afterskip = 2.3ex \@plus .2ex , |
| 9542 |
runin = false , |
| 9543 |
break = \addpenalty \@secpenalty , |
| 9544 |
%<*plain> |
| 9545 |
format = \Large \bfseries , |
| 9546 |
afterindent = false |
| 9547 |
%</plain> |
| 9548 |
%<*chinese> |
| 9549 |
format = \Large \bfseries \centering , |
| 9550 |
afterindent = true |
| 9551 |
%</chinese> |
| 9552 |
%</article|book|report> |
| 9553 |
%<*beamer> |
| 9554 |
%<*plain> |
| 9555 |
name = \sectionname \space , |
| 9556 |
%</plain> |
| 9557 |
format = \centering , |
| 9558 |
number = \insertsectionnumber , |
| 9559 |
nameformat = \usebeamerfont { section ~ name } |
| 9560 |
\usebeamercolor [fg] { section ~ name } , |
| 9561 |
aftername = \vskip 1em \par , |
| 9562 |
titleformat = \usebeamerfont { section ~ title } , |
| 9563 |
aftertitle = \par |
| 9564 |
%</beamer> |
| 9565 |
} |
| 9566 |
% \end{macrocode} |
| 9567 |
% |
| 9568 |
% \begin{macrocode} |
| 9569 |
\ctex_set:nn { subsection } |
| 9570 |
{ |
| 9571 |
%<*article|book|report> |
| 9572 |
number = \thesubsection , |
| 9573 |
format = \large \bfseries , |
| 9574 |
aftername = \quad , |
| 9575 |
aftertitle = \@@@@par , |
| 9576 |
beforeskip = 3.25ex \@plus 1ex \@minus .2ex , |
| 9577 |
afterskip = 1.5ex \@plus .2ex , |
| 9578 |
runin = false , |
| 9579 |
break = \addpenalty \@secpenalty , |
| 9580 |
%<*plain> |
| 9581 |
afterindent = false |
| 9582 |
%</plain> |
| 9583 |
%<*chinese> |
| 9584 |
afterindent = true |
| 9585 |
%</chinese> |
| 9586 |
%</article|book|report> |
| 9587 |
%<*beamer> |
| 9588 |
%<*plain> |
| 9589 |
name = \subsectionname \space , |
| 9590 |
number = \insertsubsectionnumber , |
| 9591 |
%</plain> |
| 9592 |
%<*chinese> |
| 9593 |
number = \arabic { section } . \arabic { subsection } , |
| 9594 |
%</chinese> |
| 9595 |
format = \centering , |
| 9596 |
nameformat = \usebeamerfont { subsection ~ name } |
| 9597 |
\usebeamercolor [fg] { subsection ~ name } , |
| 9598 |
aftername = \vskip 1em \par , |
| 9599 |
titleformat = \usebeamerfont { subsection ~ title } , |
| 9600 |
aftertitle = \par |
| 9601 |
%</beamer> |
| 9602 |
} |
| 9603 |
% \end{macrocode} |
| 9604 |
% |
| 9605 |
% \begin{macrocode} |
| 9606 |
%<*article|book|report> |
| 9607 |
% \end{macrocode} |
| 9608 |
% |
| 9609 |
% \begin{macrocode} |
| 9610 |
\ctex_set:nn { subsubsection } |
| 9611 |
{ |
| 9612 |
number = \thesubsubsection , |
| 9613 |
format = \normalsize \bfseries , |
| 9614 |
aftername = \quad , |
| 9615 |
aftertitle = \@@@@par , |
| 9616 |
beforeskip = 3.25ex \@plus 1ex \@minus .2ex , |
| 9617 |
afterskip = 1.5ex \@plus .2ex , |
| 9618 |
runin = false , |
| 9619 |
break = \addpenalty \@secpenalty , |
| 9620 |
%<*plain> |
| 9621 |
afterindent = false |
| 9622 |
%</plain> |
| 9623 |
%<*chinese> |
| 9624 |
afterindent = true |
| 9625 |
%</chinese> |
| 9626 |
} |
| 9627 |
% \end{macrocode} |
| 9628 |
% |
| 9629 |
% \begin{macrocode} |
| 9630 |
\ctex_set:nn { paragraph } |
| 9631 |
{ |
| 9632 |
number = \theparagraph , |
| 9633 |
format = \normalsize \bfseries , |
| 9634 |
aftername = \quad , |
| 9635 |
beforeskip = 3.25ex \@plus 1ex \@minus .2ex , |
| 9636 |
break = \addpenalty \@secpenalty , |
| 9637 |
%<*plain> |
| 9638 |
afterindent = false |
| 9639 |
%</plain> |
| 9640 |
%<*chinese> |
| 9641 |
afterindent = true |
| 9642 |
%</chinese> |
| 9643 |
} |
| 9644 |
% \end{macrocode} |
| 9645 |
% |
| 9646 |
% \begin{macrocode} |
| 9647 |
\ctex_set:nn { subparagraph } |
| 9648 |
{ |
| 9649 |
number = \thesubparagraph , |
| 9650 |
format = \normalsize \bfseries , |
| 9651 |
aftername = \quad , |
| 9652 |
beforeskip = 3.25ex \@plus 1ex \@minus .2ex , |
| 9653 |
break = \addpenalty \@secpenalty , |
| 9654 |
%<*plain> |
| 9655 |
afterindent = false |
| 9656 |
%</plain> |
| 9657 |
%<*chinese> |
| 9658 |
afterindent = true |
| 9659 |
%</chinese> |
| 9660 |
} |
| 9661 |
% \end{macrocode} |
| 9662 |
% |
| 9663 |
% 处理 \opt{sub3section} 与 \opt{sub4section} 的格式。 |
| 9664 |
% \begin{macrocode} |
| 9665 |
\int_compare:nNnTF \g_@@_section_depth_int > 2 |
| 9666 |
{ |
| 9667 |
\ctex_set:nn { paragraph } |
| 9668 |
{ |
| 9669 |
aftertitle = \@@@@par , |
| 9670 |
afterskip = 1ex \@plus .2ex , |
| 9671 |
runin = false |
| 9672 |
} |
| 9673 |
} |
| 9674 |
{ |
| 9675 |
\ctex_set:nn { paragraph } |
| 9676 |
{ |
| 9677 |
afterskip = 1em , |
| 9678 |
runin = true |
| 9679 |
} |
| 9680 |
} |
| 9681 |
\int_compare:nNnTF \g_@@_section_depth_int > 3 |
| 9682 |
{ |
| 9683 |
\ctex_set:nn { subparagraph } |
| 9684 |
{ |
| 9685 |
aftertitle = \@@@@par , |
| 9686 |
afterskip = 1ex \@plus .2ex , |
| 9687 |
runin = false |
| 9688 |
} |
| 9689 |
} |
| 9690 |
{ |
| 9691 |
\ctex_set:nn { subparagraph } |
| 9692 |
{ |
| 9693 |
afterskip = 1em , |
| 9694 |
runin = true |
| 9695 |
} |
| 9696 |
} |
| 9697 |
\int_compare:nNnTF \g_@@_section_depth_int > 2 |
| 9698 |
{ \ctex_set:nn { subparagraph } { indent = \c_zero_dim } } |
| 9699 |
{ \ctex_set:nn { subparagraph } { indent = \parindent } } |
| 9700 |
% \end{macrocode} |
| 9701 |
% |
| 9702 |
% 处理附录的格式。 |
| 9703 |
% \begin{macrocode} |
| 9704 |
\ctex_set:nn { appendix } |
| 9705 |
%<*article> |
| 9706 |
{ number = \@Alph \c@section } |
| 9707 |
%</article> |
| 9708 |
%<*book|report> |
| 9709 |
{ |
| 9710 |
name = \appendixname \space , |
| 9711 |
number = \@Alph \c@chapter |
| 9712 |
} |
| 9713 |
%</book|report> |
| 9714 |
% \end{macrocode} |
| 9715 |
% |
| 9716 |
% \begin{macrocode} |
| 9717 |
%</article|book|report> |
| 9718 |
% \end{macrocode} |
| 9719 |
% |
| 9720 |
% \begin{macrocode} |
| 9721 |
%</scheme&(article|book|report|beamer)> |
| 9722 |
% \end{macrocode} |
| 9723 |
% |
| 9724 |
% \subsubsection{\pkg{ctex.sty} 的 \opt{heading} 选项} |
| 9725 |
% |
| 9726 |
% \begin{macrocode} |
| 9727 |
%<*ctex|ctexheading> |
| 9728 |
% \end{macrocode} |
| 9729 |
% |
| 9730 |
% \begin{variable}{\c_@@_std_class_tl} |
| 9731 |
% 用于记录被引入的标准文档类。 |
| 9732 |
% \begin{macrocode} |
| 9733 |
\clist_map_inline:nn { article , book , report , beamer } |
| 9734 |
{ |
| 9735 |
\@ifclassloaded {#1} |
| 9736 |
{ \clist_map_break:n { \tl_const:Nn \c_@@_std_class_tl {#1} } } |
| 9737 |
{ } |
| 9738 |
} |
| 9739 |
% \end{macrocode} |
| 9740 |
% \end{variable} |
| 9741 |
% |
| 9742 |
% 若标准文档类被引入,则载入对应的标题定义文件。否则视 \tn{chapter} 是否有定义来 |
| 9743 |
% 引入 \cls{book} 或者 \cls{article}。 |
| 9744 |
% \begin{macrocode} |
| 9745 |
\msg_new:nnn { ctex } { not-standard-class } |
| 9746 |
{ |
| 9747 |
None~of~the~standard~document~classes~was~loaded.\\ |
| 9748 |
Heading~`#1'~is~selected.\\ |
| 9749 |
ctex~may~not~work~as~expected. |
| 9750 |
} |
| 9751 |
%<ctex>\bool_if:NTF \l_@@_heading_bool |
| 9752 |
%<ctexheading>\use:n |
| 9753 |
{ |
| 9754 |
\tl_if_exist:NTF \c_@@_std_class_tl |
| 9755 |
{ \cs_new_eq:NN \c_@@_class_tl \c_@@_std_class_tl } |
| 9756 |
{ |
| 9757 |
\cs_if_exist:NTF \chapter |
| 9758 |
{ |
| 9759 |
\cs_if_exist:NF \if@mainmatter |
| 9760 |
{ \cs_new_eq:NN \if@mainmatter \tex_iftrue:D } |
| 9761 |
\tl_const:Nn \c_@@_class_tl { book } |
| 9762 |
} |
| 9763 |
{ \tl_const:Nn \c_@@_class_tl { article } } |
| 9764 |
\msg_warning:nnx { ctex } { not-standard-class } { \c_@@_class_tl } |
| 9765 |
} |
| 9766 |
\ctex_file_input:n { ctex-heading- \c_@@_class_tl .def } |
| 9767 |
} |
| 9768 |
%<ctex> { \ctex_scheme_input:o { \l_@@_scheme_tl } } |
| 9769 |
% \end{macrocode} |
| 9770 |
% |
| 9771 |
% \begin{macrocode} |
| 9772 |
%</ctex|ctexheading> |
| 9773 |
% \end{macrocode} |
| 9774 |
% |
| 9775 |
% \subsubsection{标题配置文件} |
| 9776 |
% |
| 9777 |
% \begin{macrocode} |
| 9778 |
%<*name> |
| 9779 |
% \end{macrocode} |
| 9780 |
% |
| 9781 |
% \begin{macrocode} |
| 9782 |
\keys_set_known:nn { ctex } |
| 9783 |
{ |
| 9784 |
contentsname = 目录 , |
| 9785 |
listfigurename = 插图 , |
| 9786 |
listtablename = 表格 , |
| 9787 |
figurename = 图 , |
| 9788 |
tablename = 表 , |
| 9789 |
abstractname = 摘要 , |
| 9790 |
indexname = 索引 , |
| 9791 |
bibname = 参考文献 , |
| 9792 |
appendixname = 附录 , |
| 9793 |
proofname = 证明 , |
| 9794 |
algorithmname = 算法 , |
| 9795 |
refname = 参考文献 , |
| 9796 |
continuation = (续) , |
| 9797 |
part / name = { 第 , 部分 } , |
| 9798 |
chapter / name = { 第 , 章 } |
| 9799 |
} |
| 9800 |
% \end{macrocode} |
| 9801 |
% |
| 9802 |
% \begin{macrocode} |
| 9803 |
%</name> |
| 9804 |
% \end{macrocode} |
| 9805 |
% |
| 9806 |
% \subsection{\opt{chinese} 方案的其他设置} |
| 9807 |
% |
| 9808 |
% \begin{macrocode} |
| 9809 |
%<*scheme&chinese> |
| 9810 |
% \end{macrocode} |
| 9811 |
% |
| 9812 |
% \opt{chinese} 在标准文档类下的页面格式总采用 \texttt{headings}。 |
| 9813 |
% \begin{macrocode} |
| 9814 |
%<article|book|report>\pagestyle { headings } |
| 9815 |
% \end{macrocode} |
| 9816 |
% |
| 9817 |
% 日期格式。 |
| 9818 |
% \begin{macrocode} |
| 9819 |
\ctex_set:n { today = small } |
| 9820 |
% \end{macrocode} |
| 9821 |
% |
| 9822 |
% 若用户未设置宏包选项 \opt{autoindent},则自动调整首行缩进。 |
| 9823 |
% \begin{macrocode} |
| 9824 |
\ctex_if_autoindent_touched:F |
| 9825 |
{ \ctex_set:n { autoindent = true } } |
| 9826 |
% \end{macrocode} |
| 9827 |
% |
| 9828 |
% 使用标题定义时的设置。首先是命题名字汉化。\cls{beamer} 需要汉化定理名称。 |
| 9829 |
% \begin{macrocode} |
| 9830 |
%<*!generic> |
| 9831 |
\str_if_eq:onTF { \g_@@_encoding_tl } { GBK } |
| 9832 |
%<*beamer> |
| 9833 |
{ |
| 9834 |
\uselanguage { ChineseGBK } |
| 9835 |
\languagealias { chinese } { ChineseGBK } |
| 9836 |
\ctex_file_input:n { ctex-name-gbk.cfg } |
| 9837 |
} |
| 9838 |
{ |
| 9839 |
\uselanguage { ChineseUTF8 } |
| 9840 |
\languagealias { chinese } { ChineseUTF8 } |
| 9841 |
\ctex_file_input:n { ctex-name-utf8.cfg } |
| 9842 |
} |
| 9843 |
% \end{macrocode} |
| 9844 |
% 让 \pkg{translator} 包优先查找中文翻译。 |
| 9845 |
% \begin{macrocode} |
| 9846 |
\clist_put_left:Nn \trans@languagepath { chinese } |
| 9847 |
%</beamer> |
| 9848 |
%<*!beamer> |
| 9849 |
{ \ctex_file_input:n { ctex-name-gbk.cfg } } |
| 9850 |
{ \ctex_file_input:n { ctex-name-utf8.cfg } } |
| 9851 |
% \end{macrocode} |
| 9852 |
% |
| 9853 |
% \changes{v2.4.1}{2016/05/09}{\cls{beamer} 不调整默认字体大小。} |
| 9854 |
% 对 \cls{beamer} 以外的文档类,若用户未设置宏包选项 \opt{zihao},则设置 \tn{normalsize} |
| 9855 |
% 为五号字。\cls{beamer} 不调整默认字体大小。 |
| 9856 |
% \begin{macrocode} |
| 9857 |
\int_compare:nNnF \g_@@_font_size_int > { -1 } |
| 9858 |
{ \int_gset:Nn \g_@@_font_size_int { 0 } } |
| 9859 |
% \end{macrocode} |
| 9860 |
% |
| 9861 |
% \changes{v2.4.1}{2016/05/09}{\cls{beamer} 不调整默认行距。} |
| 9862 |
% 对 \cls{beamer} 以外的文档类,若用户未设置宏包选项 \opt{linespread},则设置行 |
| 9863 |
% 距初始值为 $1.3\times 1.2=1.56$ 倍字体大小。\cls{beamer} 不调整行距。 |
| 9864 |
% \begin{macrocode} |
| 9865 |
\fp_if_nan:nT { \l_@@_line_spread_fp } |
| 9866 |
{ \fp_set:Nn \l_@@_line_spread_fp { 1.3 } } |
| 9867 |
%</!beamer> |
| 9868 |
%</!generic> |
| 9869 |
% \end{macrocode} |
| 9870 |
% |
| 9871 |
% 不使用标题定义时的通用设置,注意此处 \cs{c_@@_std_class_tl} 可能没有定义。 |
| 9872 |
% \begin{macrocode} |
| 9873 |
%<*generic> |
| 9874 |
\tl_if_eq:NnTF \c_@@_std_class_tl { beamer } |
| 9875 |
{ |
| 9876 |
\str_if_eq:onTF { \g_@@_encoding_tl } { GBK } |
| 9877 |
{ |
| 9878 |
\uselanguage { ChineseGBK } |
| 9879 |
\languagealias { chinese } { ChineseGBK } |
| 9880 |
\ctex_file_input:n { ctex-name-gbk.cfg } |
| 9881 |
} |
| 9882 |
{ |
| 9883 |
\uselanguage { ChineseUTF8 } |
| 9884 |
\languagealias { chinese } { ChineseUTF8 } |
| 9885 |
\ctex_file_input:n { ctex-name-utf8.cfg } |
| 9886 |
} |
| 9887 |
\clist_put_left:Nn \trans@languagepath { chinese } |
| 9888 |
} |
| 9889 |
{ |
| 9890 |
\str_if_eq:onTF { \g_@@_encoding_tl } { GBK } |
| 9891 |
{ \ctex_file_input:n { ctex-name-gbk.cfg } } |
| 9892 |
{ \ctex_file_input:n { ctex-name-utf8.cfg } } |
| 9893 |
\int_compare:nNnF \g_@@_font_size_int > { -1 } |
| 9894 |
{ \int_gset:Nn \g_@@_font_size_int { 0 } } |
| 9895 |
\fp_if_nan:nT { \l_@@_line_spread_fp } |
| 9896 |
{ \fp_set:Nn \l_@@_line_spread_fp { 1.3 } } |
| 9897 |
% \end{macrocode} |
| 9898 |
% \changes{v2.0.2}{2015/05/16}{修复加载 \pkg{ctex} 宏包后章节标题后第一段 |
| 9899 |
% 无段首缩进的问题。} |
| 9900 |
% 若 \pkg{ctex} 宏包与标准文档类及其衍生文档类联用,则将载入 \pkg{indentfirst} 宏包, |
| 9901 |
% 实现章节标题后首个段落的段首缩进。 |
| 9902 |
% \begin{macrocode} |
| 9903 |
\tl_if_exist:NT \c_@@_std_class_tl |
| 9904 |
{ \RequirePackage { indentfirst } } |
| 9905 |
} |
| 9906 |
%</generic> |
| 9907 |
% \end{macrocode} |
| 9908 |
% |
| 9909 |
% \begin{macrocode} |
| 9910 |
%</scheme&chinese> |
| 9911 |
% \end{macrocode} |
| 9912 |
% |
| 9913 |
% \subsection{中文字号} |
| 9914 |
% |
| 9915 |
% \begin{macrocode} |
| 9916 |
%<*class|ctex|ctexsize> |
| 9917 |
% \end{macrocode} |
| 9918 |
% |
| 9919 |
% \changes{v2.0}{2014/03/08}{将中文字号功能提取到可以独立使用的 \pkg{ctexsize}。} |
| 9920 |
% |
| 9921 |
% \begin{macro}{\zihao} |
| 9922 |
% \begin{macrocode} |
| 9923 |
\NewDocumentCommand \zihao { m } |
| 9924 |
{ \exp_args:Nx \ctex_zihao:n {#1} \tex_ignorespaces:D } |
| 9925 |
% \end{macrocode} |
| 9926 |
% \end{macro} |
| 9927 |
% |
| 9928 |
% \begin{macro}[int]{\ctex_zihao:n} |
| 9929 |
% \begin{macrocode} |
| 9930 |
\cs_new_protected:Npn \ctex_zihao:n #1 |
| 9931 |
{ |
| 9932 |
\prop_get:NnNTF \c_@@_font_size_prop {#1} \l_@@_font_size_tl |
| 9933 |
{ \exp_after:wN \fontsize \l_@@_font_size_tl \selectfont } |
| 9934 |
{ \msg_error:nnn { ctex } { fontsize } {#1} } |
| 9935 |
} |
| 9936 |
\msg_new:nnnn { ctex } { fontsize } |
| 9937 |
{ Undefined~Chinese~font~size~`#1'~in~command~\token_to_str:N \zihao.} |
| 9938 |
{ |
| 9939 |
The~old~font~size~is~used~if~you~continue.\\ |
| 9940 |
The~available~font~sizes~are~listed~as~follow.\\ |
| 9941 |
\seq_use:Nnnn \c_@@_font_size_seq { ~and~ } { ,~ } { ,~and~ }. |
| 9942 |
} |
| 9943 |
% \end{macrocode} |
| 9944 |
% \end{macro} |
| 9945 |
% |
| 9946 |
% \subsubsection{定义中文字号} |
| 9947 |
% |
| 9948 |
% \changes{v2.0}{2014/03/08}{中文字号不再采用近似值。} |
| 9949 |
% |
| 9950 |
% \begin{variable}{\c_@@_font_size_prop} |
| 9951 |
% \begin{macro}{\@@_save_font_size:nn} |
| 9952 |
% 基础行距是字号的 $1.2$ 倍,采用 \hologo{eTeX} 的 scaling 运算得到的结果 |
| 9953 |
% 要比简单的 |1.2\dimexpr| 精确^^A |
| 9954 |
% \footnote{\url{http://thread.gmane.org/gmane.comp.tex.latex.latex3/3190}}。 |
| 9955 |
% \begin{macrocode} |
| 9956 |
\prop_new:N \c_@@_font_size_prop |
| 9957 |
\seq_new:N \c_@@_font_size_seq |
| 9958 |
\cs_new_protected:Npn \@@_save_font_size:nn #1#2 |
| 9959 |
{ |
| 9960 |
\use:e |
| 9961 |
{ |
| 9962 |
\prop_gput:Nnn \exp_not:N \c_@@_font_size_prop {#1} |
| 9963 |
{ |
| 9964 |
{ \dim_to_decimal:n {#2} } |
| 9965 |
{ \dim_to_decimal:n { (#2) * 6 / 5 } } |
| 9966 |
} |
| 9967 |
} |
| 9968 |
\seq_gput_right:Nn \c_@@_font_size_seq {#1} |
| 9969 |
} |
| 9970 |
\clist_map_inline:nn |
| 9971 |
{ |
| 9972 |
{ 8 } { 5 bp } , |
| 9973 |
{ 7 } { 5.5 bp } , |
| 9974 |
{ -6 } { 6.5 bp } , |
| 9975 |
{ 6 } { 7.5 bp } , |
| 9976 |
{ -5 } { 9 bp } , |
| 9977 |
{ 5 } { 10.5 bp } , |
| 9978 |
{ -4 } { 12 bp } , |
| 9979 |
{ 4 } { 14 bp } , |
| 9980 |
{ -3 } { 15 bp } , |
| 9981 |
{ 3 } { 16 bp } , |
| 9982 |
{ -2 } { 18 bp } , |
| 9983 |
{ 2 } { 22 bp } , |
| 9984 |
{ -1 } { 24 bp } , |
| 9985 |
{ 1 } { 26 bp } , |
| 9986 |
{ -0 } { 36 bp } , |
| 9987 |
{ 0 } { 42 bp } |
| 9988 |
} |
| 9989 |
{ \@@_save_font_size:nn #1 } |
| 9990 |
% \end{macrocode} |
| 9991 |
% \end{macro} |
| 9992 |
% \end{variable} |
| 9993 |
% |
| 9994 |
% \begin{macro}[int]{\ctex_declare_math_sizes:nnnn} |
| 9995 |
% \begin{macrocode} |
| 9996 |
\cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4 |
| 9997 |
{ |
| 9998 |
\@@_get_font_sizes:Nn \l_@@_font_size_tl { {#1} {#2} {#3} {#4} } |
| 9999 |
\exp_after:wN \DeclareMathSizes \l_@@_font_size_tl |
| 10000 |
} |
| 10001 |
% \end{macrocode} |
| 10002 |
% \end{macro} |
| 10003 |
% |
| 10004 |
% \begin{macro}{\@@_get_font_sizes:Nn} |
| 10005 |
% \begin{macrocode} |
| 10006 |
\cs_new_protected:Npn \@@_get_font_sizes:Nn #1#2 |
| 10007 |
{ |
| 10008 |
\tl_clear:N #1 |
| 10009 |
\tl_map_inline:nn {#2} |
| 10010 |
{ |
| 10011 |
\prop_get:NnNTF \c_@@_font_size_prop {##1} \l_@@_tmp_tl |
| 10012 |
{ \tl_put_right:Nx #1 { { \tl_head:N \l_@@_tmp_tl } } } |
| 10013 |
{ \tl_put_right:Nx #1 { { \dim_to_decimal:n { ##1 } } } } |
| 10014 |
} |
| 10015 |
} |
| 10016 |
% \end{macrocode} |
| 10017 |
% \end{macro} |
| 10018 |
% |
| 10019 |
% \begin{macrocode} |
| 10020 |
\clist_map_inline:nn |
| 10021 |
{ |
| 10022 |
{ 8 }{ 8 }{ 5pt }{ 5pt } , |
| 10023 |
{ 7 }{ 7 }{ 5pt }{ 5pt } , |
| 10024 |
{ -6 }{ -6 }{ 5pt }{ 5pt } , |
| 10025 |
{ 6 }{ 6 }{ 5pt }{ 5pt } , |
| 10026 |
{ -5 }{ -5 }{ 6pt }{ 5pt } , |
| 10027 |
{ 5 }{ 5 }{ 7pt }{ 5pt } , |
| 10028 |
{ -4 }{ -4 }{ 8pt }{ 6pt } , |
| 10029 |
{ 4 }{ 4 }{ 5 }{ 6 } , |
| 10030 |
{ -3 }{ -3 }{ -4 }{ -5 } , |
| 10031 |
{ 3 }{ 3 }{ 4 }{ 5 } , |
| 10032 |
{ -2 }{ -2 }{ -3 }{ -4 } , |
| 10033 |
{ 2 }{ 2 }{ 3 }{ 4 } , |
| 10034 |
{ -1 }{ -1 }{ -2 }{ -3 } , |
| 10035 |
{ 1 }{ 1 }{ 2 }{ 3 } , |
| 10036 |
{ -0 }{ -0 }{ -1 }{ -2 } , |
| 10037 |
{ 0 }{ 0 }{ 1 }{ 2 } |
| 10038 |
} |
| 10039 |
{ \ctex_declare_math_sizes:nnnn #1 } |
| 10040 |
% \end{macrocode} |
| 10041 |
% |
| 10042 |
% \subsubsection{修改默认字号大小} |
| 10043 |
% |
| 10044 |
% \begin{macro}[int]{\ctex_set_font_size:Nnn} |
| 10045 |
% \begin{macrocode} |
| 10046 |
\cs_new_protected:Npn \ctex_set_font_size:Nnn #1#2#3 |
| 10047 |
{ |
| 10048 |
\prop_get:NnNTF \c_@@_font_size_prop {#2} \l_@@_font_size_tl |
| 10049 |
{ \exp_after:wN \@@_set_font_size:nnNn \l_@@_font_size_tl #1 {#3} } |
| 10050 |
{ \msg_error:nnn { ctex } { fontsize } {#2} } |
| 10051 |
} |
| 10052 |
\cs_new_protected:Npn \@@_set_font_size:nnNn #1#2#3#4 |
| 10053 |
{ \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } } |
| 10054 |
% \end{macrocode} |
| 10055 |
% \end{macro} |
| 10056 |
% |
| 10057 |
% \begin{macrocode} |
| 10058 |
\int_case:nn { \g_@@_font_size_int } |
| 10059 |
{ |
| 10060 |
{ 0 } { \file_input:n { ctex-c5size.clo } } |
| 10061 |
{ 1 } { \file_input:n { ctex-cs4size.clo } } |
| 10062 |
} |
| 10063 |
% \end{macrocode} |
| 10064 |
% |
| 10065 |
% \begin{macrocode} |
| 10066 |
%</class|ctex|ctexsize> |
| 10067 |
% \end{macrocode} |
| 10068 |
% |
| 10069 |
% \begin{macrocode} |
| 10070 |
%<*c5size> |
| 10071 |
\ctex_set_font_size:Nnn \normalsize { 5 } |
| 10072 |
{ |
| 10073 |
\abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ |
| 10074 |
\abovedisplayshortskip \z@ \@plus3\p@ |
| 10075 |
\belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ |
| 10076 |
\belowdisplayskip \abovedisplayskip |
| 10077 |
\let\@listi\@listI |
| 10078 |
} |
| 10079 |
\ctex_set_font_size:Nnn \small { -5 } |
| 10080 |
{ |
| 10081 |
\abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@ |
| 10082 |
\abovedisplayshortskip \z@ \@plus2\p@ |
| 10083 |
\belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@ |
| 10084 |
\def\@listi{\leftmargin\leftmargini |
| 10085 |
\topsep 4\p@ \@plus2\p@ \@minus2\p@ |
| 10086 |
\parsep 2\p@ \@plus\p@ \@minus\p@ |
| 10087 |
\itemsep \parsep} |
| 10088 |
\belowdisplayskip \abovedisplayskip |
| 10089 |
} |
| 10090 |
\ctex_set_font_size:Nnn \footnotesize { 6 } |
| 10091 |
{ |
| 10092 |
\abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@ |
| 10093 |
\abovedisplayshortskip \z@ \@plus\p@ |
| 10094 |
\belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@ |
| 10095 |
\def\@listi{\leftmargin\leftmargini |
| 10096 |
\topsep 3\p@ \@plus\p@ \@minus\p@ |
| 10097 |
\parsep 2\p@ \@plus\p@ \@minus\p@ |
| 10098 |
\itemsep \parsep} |
| 10099 |
\belowdisplayskip \abovedisplayskip |
| 10100 |
} |
| 10101 |
\ctex_set_font_size:Nnn \scriptsize { -6 } { } |
| 10102 |
\ctex_set_font_size:Nnn \tiny { 7 } { } |
| 10103 |
\ctex_set_font_size:Nnn \large { -4 } { } |
| 10104 |
\ctex_set_font_size:Nnn \Large { -3 } { } |
| 10105 |
\ctex_set_font_size:Nnn \LARGE { -2 } { } |
| 10106 |
\ctex_set_font_size:Nnn \huge { 2 } { } |
| 10107 |
\ctex_set_font_size:Nnn \Huge { 1 } { } |
| 10108 |
%</c5size> |
| 10109 |
%<*cs4size> |
| 10110 |
\ctex_set_font_size:Nnn \normalsize { -4 } |
| 10111 |
{ |
| 10112 |
\abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@ |
| 10113 |
\abovedisplayshortskip \z@ \@plus3\p@ |
| 10114 |
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@ |
| 10115 |
\belowdisplayskip \abovedisplayskip |
| 10116 |
\let\@listi\@listI |
| 10117 |
} |
| 10118 |
\ctex_set_font_size:Nnn \small { 5 } |
| 10119 |
{ |
| 10120 |
\abovedisplayskip 11\p@ \@plus3\p@ \@minus6\p@ |
| 10121 |
\abovedisplayshortskip \z@ \@plus3\p@ |
| 10122 |
\belowdisplayshortskip 6.5\p@ \@plus3.5\p@ \@minus3\p@ |
| 10123 |
\def\@listi{\leftmargin\leftmargini |
| 10124 |
\topsep 9\p@ \@plus3\p@ \@minus5\p@ |
| 10125 |
\parsep 4.5\p@ \@plus2\p@ \@minus\p@ |
| 10126 |
\itemsep \parsep} |
| 10127 |
\belowdisplayskip \abovedisplayskip |
| 10128 |
} |
| 10129 |
\ctex_set_font_size:Nnn \footnotesize { -5 } |
| 10130 |
{ |
| 10131 |
\abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ |
| 10132 |
\abovedisplayshortskip \z@ \@plus3\p@ |
| 10133 |
\belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ |
| 10134 |
\def\@listi{\leftmargin\leftmargini |
| 10135 |
\topsep 6\p@ \@plus2\p@ \@minus2\p@ |
| 10136 |
\parsep 3\p@ \@plus2\p@ \@minus\p@ |
| 10137 |
\itemsep \parsep} |
| 10138 |
\belowdisplayskip \abovedisplayskip |
| 10139 |
} |
| 10140 |
\ctex_set_font_size:Nnn \scriptsize { 6 } { } |
| 10141 |
\ctex_set_font_size:Nnn \tiny { -6 } { } |
| 10142 |
\ctex_set_font_size:Nnn \large { -3 } { } |
| 10143 |
\ctex_set_font_size:Nnn \Large { -2 } { } |
| 10144 |
\ctex_set_font_size:Nnn \LARGE { 2 } { } |
| 10145 |
\ctex_set_font_size:Nnn \huge { -1 } { } |
| 10146 |
\ctex_set_font_size:Nnn \Huge { 1 } { } |
| 10147 |
%</cs4size> |
| 10148 |
% \end{macrocode} |
| 10149 |
% |
| 10150 |
% \begin{macrocode} |
| 10151 |
%<ctexsize>\normalsize |
| 10152 |
% \end{macrocode} |
| 10153 |
% |
| 10154 |
% \begin{macrocode} |
| 10155 |
%<*class|ctex> |
| 10156 |
% \end{macrocode} |
| 10157 |
% |
| 10158 |
% \subsection{更新行距} |
| 10159 |
% |
| 10160 |
% \cs{l_@@_line_spread_fp} 被设置了才有必要更新行距和 \tn{footnotesep}。 |
| 10161 |
% \begin{macrocode} |
| 10162 |
\fp_if_nan:nF { \l_@@_line_spread_fp } |
| 10163 |
{ |
| 10164 |
\exp_args:Nx \linespread { \fp_use:N \l_@@_line_spread_fp } |
| 10165 |
% \end{macrocode} |
| 10166 |
% |
| 10167 |
% \changes{v2.0}{2014/04/23}{调整 \tn{footnotesep} 的大小,以适合行距的变化。} |
| 10168 |
% |
| 10169 |
% \begin{variable}[int]{\footnotesep} |
| 10170 |
% 我们调整了行距,可能导致脚注的间距与行距不协调,需要调整 \tn{footnotesep}。标准 |
| 10171 |
% 文档类对 \tn{footnotesep} 的设置是,字体大小为 \tn{footnotesize} 时 \tn{strutbox} |
| 10172 |
% 的高度(默认值是 |.7\baselineskip|)。我们沿用这个设置方法,只需要更新具体的大小。 |
| 10173 |
% \begin{macrocode} |
| 10174 |
\group_begin: \footnotesize \exp_args:NNNo \group_end: |
| 10175 |
\dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } |
| 10176 |
} |
| 10177 |
% \end{macrocode} |
| 10178 |
% \end{variable} |
| 10179 |
% |
| 10180 |
% 激活默认字体大小,更新行距、\tn{parindent} 和 \tn{CJKglue}。 |
| 10181 |
% \begin{macrocode} |
| 10182 |
\normalsize |
| 10183 |
% \end{macrocode} |
| 10184 |
% |
| 10185 |
% \subsection{其他功能} |
| 10186 |
% |
| 10187 |
% \begin{macro}{\CTeX} |
| 10188 |
% \changes{v2.4.12}{2017/12/05}{不依赖 \tn{ifincsname}。} |
| 10189 |
% \file{ctex-faq.sty} 中的定义是 |
| 10190 |
% \begin{verbatim} |
| 10191 |
% \DeclareRobustCommand\CTeX{$\mathbb{C}$\kern-.05em\TeX} |
| 10192 |
% \end{verbatim} |
| 10193 |
% 然而 \tn{mathbb} 未必有定义,这里就不采用它了,只定义最简单的形式。 |
| 10194 |
% \CTeX{} 可以直接用在 PDF 书签中。 |
| 10195 |
% \begin{macrocode} |
| 10196 |
\NewDocumentCommand \CTeX { } |
| 10197 |
{ C \TeX } |
| 10198 |
\ctex_at_end_package:nn { hyperref } |
| 10199 |
{ \pdfstringdefDisableCommands { \tl_set:Nn \CTeX { CTeX } } } |
| 10200 |
% \end{macrocode} |
| 10201 |
% \end{macro} |
| 10202 |
% |
| 10203 |
% \changes{v2.0}{2014/03/28}{\opt{captiondelimiter} 是过时选项。} |
| 10204 |
% \begin{macro}{captiondelimiter} |
| 10205 |
% 过时选项。 |
| 10206 |
% \begin{macrocode} |
| 10207 |
\ctex_define:n |
| 10208 |
{ |
| 10209 |
captiondelimiter .code:n = |
| 10210 |
{ |
| 10211 |
\ctex_deprecated_option:n |
| 10212 |
{ You~can~load~the~package~`caption'~to~get~its~functionality. } |
| 10213 |
} |
| 10214 |
} |
| 10215 |
% \end{macrocode} |
| 10216 |
% \end{macro} |
| 10217 |
% |
| 10218 |
% \begin{macrocode} |
| 10219 |
%</class|ctex> |
| 10220 |
% \end{macrocode} |
| 10221 |
% |
| 10222 |
% \subsubsection{列表环境的缩进} |
| 10223 |
% |
| 10224 |
% \begin{macro}[int]{\verse,\quotation} |
| 10225 |
% 只在使用文档类的时候修改诗歌和引用环境的缩进。 |
| 10226 |
% \begin{macrocode} |
| 10227 |
%<*scheme&chinese&(article|book|report)> |
| 10228 |
\ctex_patch_cmd:Nnn \verse { -1.5em } { -2 \ccwd } |
| 10229 |
\ctex_patch_cmd:Nnn \verse { 1.5em } { 2 \ccwd } |
| 10230 |
\ctex_patch_cmd:Nnn \quotation { 1.5em } { 2 \ccwd } |
| 10231 |
%</scheme&chinese&(article|book|report)> |
| 10232 |
% \end{macrocode} |
| 10233 |
% \end{macro} |
| 10234 |
% |
| 10235 |
% \begin{macrocode} |
| 10236 |
%<*class|ctex> |
| 10237 |
% \end{macrocode} |
| 10238 |
% |
| 10239 |
% \changes{v2.0}{2014/03/09} |
| 10240 |
% {解决 \pkg{etoolbox} 与 \pkg{breqn} 关于 \tn{end} 的冲突。} |
| 10241 |
% \changes{v2.2}{2015/06/23}{删去 \pkg{etoolbox} 与 \pkg{breqn} 的兼容补丁。} |
| 10242 |
% |
| 10243 |
% \subsection{载入中文字库} |
| 10244 |
% |
| 10245 |
% \begin{macro}[int]{\ctex_fontset_error:n} |
| 10246 |
% 字库不可用时给出紧急错误信息,停止读取定义文件。 |
| 10247 |
% \begin{macrocode} |
| 10248 |
\cs_new_protected:Npn \ctex_fontset_error:n #1 |
| 10249 |
{ \msg_critical:nnn { ctex } { fontset-unavailable } {#1} } |
| 10250 |
\msg_new:nnn { ctex } { fontset-unavailable } |
| 10251 |
{ CTeX~fontset~`#1'~is~unavailable~in~current~mode. } |
| 10252 |
% \end{macrocode} |
| 10253 |
% \end{macro} |
| 10254 |
% |
| 10255 |
% \begin{macro}[int]{\ctex_fontset_case:nnn} |
| 10256 |
% $3$ 个参数依次为 \pdfTeX、\upTeX\ 和 \XeTeX/\LuaTeX。 |
| 10257 |
% \begin{macrocode} |
| 10258 |
\cs_new:Npx \ctex_fontset_case:nnn #1#2#3 |
| 10259 |
{ |
| 10260 |
\sys_if_engine_pdftex:TF |
| 10261 |
{#1} |
| 10262 |
{ \sys_if_engine_uptex:TF {#2} {#3} } |
| 10263 |
} |
| 10264 |
% \end{macrocode} |
| 10265 |
% \end{macro} |
| 10266 |
% |
| 10267 |
% \begin{macro}[int]{\ctex_fontset_case:nnnn} |
| 10268 |
% $4$ 个参数依次为 \pdfTeX(生成 PDF)、\pdfTeX(生成 DVI)、\upTeX 和 |
| 10269 |
% \XeTeX/\LuaTeX。 |
| 10270 |
% \begin{macrocode} |
| 10271 |
\cs_new:Npx \ctex_fontset_case:nnnn #1#2#3#4 |
| 10272 |
{ |
| 10273 |
\sys_if_engine_pdftex:TF |
| 10274 |
{ \sys_if_output_pdf:TF {#1} {#2} } |
| 10275 |
{ \sys_if_engine_uptex:TF {#3} {#4} } |
| 10276 |
} |
| 10277 |
% \end{macrocode} |
| 10278 |
% \end{macro} |
| 10279 |
% |
| 10280 |
% \begin{macro}[int]{\ctex_detect_platform:} |
| 10281 |
% 根据操作系统判断默认字体配置。 |
| 10282 |
% \begin{macrocode} |
| 10283 |
\cs_new_protected:Npn \ctex_detect_platform: |
| 10284 |
{ |
| 10285 |
\sys_if_platform_windows:TF |
| 10286 |
{ \tl_gset:Nn \g_@@_fontset_tl { windows } } |
| 10287 |
{ |
| 10288 |
\ctex_if_platform_macos:TF |
| 10289 |
{ \tl_gset:Nn \g_@@_fontset_tl { mac } } |
| 10290 |
{ \tl_gset:Nn \g_@@_fontset_tl { fandol } } |
| 10291 |
} |
| 10292 |
} |
| 10293 |
% \end{macrocode} |
| 10294 |
% \end{macro} |
| 10295 |
% |
| 10296 |
% \begin{macro}[int]{\ctex_if_platform_macos:TF} |
| 10297 |
% \changes{v2.1}{2015/06/17}{改用 \file{/Library/Fonts/Songti.ttc} 为特征文件。} |
| 10298 |
% \changes{v2.5}{2019/10/25}{改用 \file{/System/Library/Fonts/Menlo.ttc} |
| 10299 |
% 为特征文件。} |
| 10300 |
% 以特定字体判断 macOS 系统。 |
| 10301 |
% \begin{macrocode} |
| 10302 |
\cs_new_protected:Npn \ctex_if_platform_macos:TF |
| 10303 |
{ \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } } |
| 10304 |
% \end{macrocode} |
| 10305 |
% \end{macro} |
| 10306 |
% |
| 10307 |
% \begin{macro}[int]{\ctex_load_fontset:} |
| 10308 |
% 如果用户没有指定字体,则探测操作系统,载入相应的字体配置。 |
| 10309 |
% \begin{macrocode} |
| 10310 |
\cs_new_protected:Npn \ctex_load_fontset: |
| 10311 |
{ |
| 10312 |
\tl_if_empty:NTF \g_@@_fontset_tl |
| 10313 |
{ \ctex_detect_platform: } |
| 10314 |
{ |
| 10315 |
\bool_lazy_or:nnTF |
| 10316 |
{ \str_if_eq_p:on { \g_@@_fontset_tl } { windowsnew } } |
| 10317 |
{ \str_if_eq_p:on { \g_@@_fontset_tl } { windowsold } } |
| 10318 |
{ |
| 10319 |
\msg_warning:nnxx { ctex } { deprecated-fontset } |
| 10320 |
{ \g_@@_fontset_tl } { windows } |
| 10321 |
\tl_gset:Nn \g_@@_fontset_tl { windows } |
| 10322 |
} |
| 10323 |
{ |
| 10324 |
\file_if_exist:nF { ctex-fontset- \g_@@_fontset_tl .def } |
| 10325 |
{ |
| 10326 |
\use:e |
| 10327 |
{ |
| 10328 |
\ctex_detect_platform: |
| 10329 |
\msg_error:nnxx { ctex } { fontset-not-found } |
| 10330 |
{ \g_@@_fontset_tl } { \exp_not:N \g_@@_fontset_tl } |
| 10331 |
} |
| 10332 |
} |
| 10333 |
} |
| 10334 |
} |
| 10335 |
\ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def } |
| 10336 |
} |
| 10337 |
\msg_new:nnn { ctex } { deprecated-fontset } |
| 10338 |
{ CTeX~fontset~`#1'~is~deprecated.\\ Fontset~`#2'~will~be~used~instead. } |
| 10339 |
\msg_new:nnnn { ctex } { fontset-not-found } |
| 10340 |
{ CTeX~fontset~`#1'~could~not~be~found.\\ Fontset~`#2'~will~be~used~instead. } |
| 10341 |
{ You~may~run~`mktexlsr'~firstly. } |
| 10342 |
\@onlypreamble \ctex_load_fontset: |
| 10343 |
% \end{macrocode} |
| 10344 |
% \end{macro} |
| 10345 |
% |
| 10346 |
% \begin{macro}{fontset} |
| 10347 |
% 在导言区通过 \tn{ctexset} 载入中文字库的选项。 |
| 10348 |
% \begin{macrocode} |
| 10349 |
\ctex_define:n |
| 10350 |
{ |
| 10351 |
fontset .code:n = |
| 10352 |
{ |
| 10353 |
\ctex_if_preamble:TF |
| 10354 |
{ |
| 10355 |
\str_if_eq:eeTF {#1} { none } |
| 10356 |
{ \msg_warning:nnn { ctex } { invalid-value } {#1} } |
| 10357 |
{ |
| 10358 |
\str_if_eq:onTF { \g_@@_fontset_tl } { none } |
| 10359 |
{ |
| 10360 |
\tl_gset:Nx \g_@@_fontset_tl {#1} |
| 10361 |
\ctex_load_fontset: |
| 10362 |
} |
| 10363 |
{ |
| 10364 |
\msg_error:nnxx { ctex } { fontset-loaded } |
| 10365 |
{ \g_@@_fontset_tl } {#1} |
| 10366 |
} |
| 10367 |
} |
| 10368 |
} |
| 10369 |
{ \msg_error:nn { ctex } { fontset-only-preamble } } |
| 10370 |
} |
| 10371 |
} |
| 10372 |
\msg_new:nnnn { ctex } { fontset-loaded } |
| 10373 |
{ |
| 10374 |
CTeX~fontset~`#1'~has~been~loaded. |
| 10375 |
\str_if_eq:nnF {#1} {#2} { \\ Fontset~`#2'~will~be~ignored. } |
| 10376 |
} |
| 10377 |
{ Only~one~fontset~can~be~loaded~in~the~preamble. } |
| 10378 |
\msg_new:nnn { ctex } { fontset-only-preamble } |
| 10379 |
{ The~`fontset'~option~can~be~used~only~in~preamble. } |
| 10380 |
% \end{macrocode} |
| 10381 |
% \end{macro} |
| 10382 |
% |
| 10383 |
% 载入中文字库。 |
| 10384 |
% \begin{macrocode} |
| 10385 |
\str_if_eq:onF { \g_@@_fontset_tl } { none } |
| 10386 |
{ \ctex_load_fontset: } |
| 10387 |
% \end{macrocode} |
| 10388 |
% |
| 10389 |
% \subsection{宏包配置文件} |
| 10390 |
% |
| 10391 |
% \subsubsection{\pkg{ctex.cfg}} |
| 10392 |
% |
| 10393 |
% \begin{macrocode} |
| 10394 |
\ctex_at_end:n { \ctex_file_input:n { ctex.cfg } } |
| 10395 |
% \end{macrocode} |
| 10396 |
% |
| 10397 |
% \begin{macrocode} |
| 10398 |
%</class|ctex> |
| 10399 |
% \end{macrocode} |
| 10400 |
% |
| 10401 |
% \begin{macrocode} |
| 10402 |
%<*config> |
| 10403 |
%% |
| 10404 |
%</config> |
| 10405 |
% \end{macrocode} |
| 10406 |
% |
| 10407 |
% \subsubsection{\pkg{ctexopts.cfg}} |
| 10408 |
% |
| 10409 |
% 这里仅为配置文件示例:使用 Windows 下的字体设置。 |
| 10410 |
% \begin{macrocode} |
| 10411 |
%<*ctexopts> |
| 10412 |
%% |
| 10413 |
%% \ctex_set:nn { option } { fontset = windows } |
| 10414 |
%</ctexopts> |
| 10415 |
% \end{macrocode} |
| 10416 |
% |
| 10417 |
% \subsection{字体定义文件} |
| 10418 |
% |
| 10419 |
% \subsubsection{传统定义方式} |
| 10420 |
% |
| 10421 |
% \changes{v2.4.15}{2019/04/05}{将 \texttt{JY2} 和 \texttt{JT2} 编码的字体定义提取到单独的文件中。} |
| 10422 |
% |
| 10423 |
% \begin{macrocode} |
| 10424 |
%<*c19|c70> |
| 10425 |
%% |
| 10426 |
%% Chinese characters |
| 10427 |
%% |
| 10428 |
%<c19>%% character set: GBK (extension of GB 2312) |
| 10429 |
%<c70>%% character set: Unicode |
| 10430 |
%% font encoding: Unicode |
| 10431 |
%% |
| 10432 |
%</c19|c70> |
| 10433 |
% \end{macrocode} |
| 10434 |
% |
| 10435 |
% \pkg{CJK} 宏包使用的字体族。 |
| 10436 |
% \begin{macrocode} |
| 10437 |
%<rm&c19>\DeclareFontFamily{C19}{rm}{\hyphenchar\font\m@ne} |
| 10438 |
%<rm&c70>\DeclareFontFamily{C70}{rm}{\hyphenchar\font\m@ne} |
| 10439 |
%<sf&c19>\DeclareFontFamily{C19}{sf}{\hyphenchar\font\m@ne} |
| 10440 |
%<sf&c70>\DeclareFontFamily{C70}{sf}{\hyphenchar\font\m@ne} |
| 10441 |
%<tt&c19>\DeclareFontFamily{C19}{tt}{\hyphenchar\font\m@ne} |
| 10442 |
%<tt&c70>\DeclareFontFamily{C70}{tt}{\hyphenchar\font\m@ne} |
| 10443 |
% \end{macrocode} |
| 10444 |
% |
| 10445 |
% \changes{v2.4}{2016/04/25}{提供 \upLaTeX{} 的 NFSS 字体定义。} |
| 10446 |
% \upLaTeX{} 使用的字体族。\upLaTeX 在 NFSS 下使用字体编码 |JY2| 和 |JT2| 来分别 |
| 10447 |
% 表示横排与直排的日文。 |
| 10448 |
% \begin{macrocode} |
| 10449 |
%<rm&jy2>\DeclareKanjiFamily{JY2}{zhrm}{} |
| 10450 |
%<rm&jt2>\DeclareKanjiFamily{JT2}{zhrm}{} |
| 10451 |
%<sf&jy2>\DeclareKanjiFamily{JY2}{zhsf}{} |
| 10452 |
%<sf&jt2>\DeclareKanjiFamily{JT2}{zhsf}{} |
| 10453 |
%<tt&jy2>\DeclareKanjiFamily{JY2}{zhtt}{} |
| 10454 |
%<tt&jt2>\DeclareKanjiFamily{JT2}{zhtt}{} |
| 10455 |
% \end{macrocode} |
| 10456 |
% |
| 10457 |
% |
| 10458 |
% \begin{macrocode} |
| 10459 |
%<*rm> |
| 10460 |
%<*c19> |
| 10461 |
\DeclareFontShape{C19}{rm}{m}{n}{<-> CJK * gbksong}{\CJKnormal} |
| 10462 |
\DeclareFontShape{C19}{rm}{b}{n}{<-> CJK * gbkhei}{\CJKnormal} |
| 10463 |
\DeclareFontShape{C19}{rm}{bx}{n}{<-> CJK * gbkhei}{\CJKnormal} |
| 10464 |
\DeclareFontShape{C19}{rm}{m}{sl}{<-> CJK * gbksongsl}{\CJKnormal} |
| 10465 |
\DeclareFontShape{C19}{rm}{b}{sl}{<-> CJK * gbkheisl}{\CJKnormal} |
| 10466 |
\DeclareFontShape{C19}{rm}{bx}{sl}{<-> CJK * gbkheisl}{\CJKnormal} |
| 10467 |
\DeclareFontShape{C19}{rm}{m}{it}{<-> CJK * gbkkai}{\CJKnormal} |
| 10468 |
\DeclareFontShape{C19}{rm}{b}{it}{<-> CJKb * gbkkai}{\CJKbold} |
| 10469 |
\DeclareFontShape{C19}{rm}{bx}{it}{<-> CJKb * gbkkai}{\CJKbold} |
| 10470 |
%</c19> |
| 10471 |
%<*c70> |
| 10472 |
\DeclareFontShape{C70}{rm}{m}{n}{<-> CJK * unisong}{\CJKnormal} |
| 10473 |
\DeclareFontShape{C70}{rm}{b}{n}{<-> CJK * unihei}{\CJKnormal} |
| 10474 |
\DeclareFontShape{C70}{rm}{bx}{n}{<-> CJK * unihei}{\CJKnormal} |
| 10475 |
\DeclareFontShape{C70}{rm}{m}{sl}{<-> CJK * unisongsl}{\CJKnormal} |
| 10476 |
\DeclareFontShape{C70}{rm}{b}{sl}{<-> CJK * uniheisl}{\CJKnormal} |
| 10477 |
\DeclareFontShape{C70}{rm}{bx}{sl}{<-> CJK * uniheisl}{\CJKnormal} |
| 10478 |
\DeclareFontShape{C70}{rm}{m}{it}{<-> CJK * unikai}{\CJKnormal} |
| 10479 |
\DeclareFontShape{C70}{rm}{b}{it}{<-> CJKb * unikai}{\CJKbold} |
| 10480 |
\DeclareFontShape{C70}{rm}{bx}{it}{<-> CJKb * unikai}{\CJKbold} |
| 10481 |
%</c70> |
| 10482 |
%<*jy2> |
| 10483 |
\DeclareFontShape{JY2}{zhrm}{m}{n}{<-> upzhserif-h}{} |
| 10484 |
\DeclareFontShape{JY2}{zhrm}{m}{it}{<-> upzhserifit-h}{} |
| 10485 |
\DeclareFontShape{JY2}{zhrm}{b}{n}{<-> upzhserifb-h}{} |
| 10486 |
\DeclareFontShape{JY2}{zhrm}{bx}{n}{<-> upzhserifb-h}{} |
| 10487 |
%</jy2> |
| 10488 |
%<*jt2> |
| 10489 |
\DeclareFontShape{JT2}{zhrm}{m}{n}{<-> upzhserif-v}{} |
| 10490 |
\DeclareFontShape{JT2}{zhrm}{m}{it}{<-> upzhserifit-v}{} |
| 10491 |
\DeclareFontShape{JT2}{zhrm}{b}{n}{<-> upzhserifb-v}{} |
| 10492 |
\DeclareFontShape{JT2}{zhrm}{bx}{n}{<-> upzhserifb-v}{} |
| 10493 |
%</jt2> |
| 10494 |
%</rm> |
| 10495 |
% \end{macrocode} |
| 10496 |
% |
| 10497 |
% \begin{macrocode} |
| 10498 |
%<*sf> |
| 10499 |
%<*c19> |
| 10500 |
\DeclareFontShape{C19}{sf}{m}{n}{<-> CJK * gbkyou}{\CJKnormal} |
| 10501 |
\DeclareFontShape{C19}{sf}{b}{n}{<-> CJKb * gbkyou}{\CJKbold} |
| 10502 |
\DeclareFontShape{C19}{sf}{bx}{n}{<-> CJKb * gbkyou}{\CJKbold} |
| 10503 |
\DeclareFontShape{C19}{sf}{m}{sl}{<-> CJK * gbkyousl}{\CJKnormal} |
| 10504 |
\DeclareFontShape{C19}{sf}{b}{sl}{<-> CJKb * gbkyousl}{\CJKbold} |
| 10505 |
\DeclareFontShape{C19}{sf}{bx}{sl}{<-> CJKb * gbkyousl}{\CJKbold} |
| 10506 |
\DeclareFontShape{C19}{sf}{m}{it}{<-> CJK * gbkyou}{\CJKnormal} |
| 10507 |
\DeclareFontShape{C19}{sf}{b}{it}{<-> CJKb * gbkyou}{\CJKbold} |
| 10508 |
\DeclareFontShape{C19}{sf}{bx}{it}{<-> CJKb * gbkyou}{\CJKbold} |
| 10509 |
%</c19> |
| 10510 |
%<*c70> |
| 10511 |
\DeclareFontShape{C70}{sf}{m}{n}{<-> CJK * uniyou}{\CJKnormal} |
| 10512 |
\DeclareFontShape{C70}{sf}{b}{n}{<-> CJKb * uniyou}{\CJKbold} |
| 10513 |
\DeclareFontShape{C70}{sf}{bx}{n}{<-> CJKb * uniyou}{\CJKbold} |
| 10514 |
\DeclareFontShape{C70}{sf}{m}{sl}{<-> CJK * uniyousl}{\CJKnormal} |
| 10515 |
\DeclareFontShape{C70}{sf}{b}{sl}{<-> CJKb * uniyousl}{\CJKbold} |
| 10516 |
\DeclareFontShape{C70}{sf}{bx}{sl}{<-> CJKb * uniyousl}{\CJKbold} |
| 10517 |
\DeclareFontShape{C70}{sf}{m}{it}{<-> CJK * uniyou}{\CJKnormal} |
| 10518 |
\DeclareFontShape{C70}{sf}{b}{it}{<-> CJKb * uniyou}{\CJKbold} |
| 10519 |
\DeclareFontShape{C70}{sf}{bx}{it}{<-> CJKb * uniyou}{\CJKbold} |
| 10520 |
%</c70> |
| 10521 |
%<*jy2> |
| 10522 |
\DeclareFontShape{JY2}{zhsf}{m}{n}{<-> upzhsans-h}{} |
| 10523 |
\DeclareFontShape{JY2}{zhsf}{b}{n}{<-> upzhsansb-h}{} |
| 10524 |
\DeclareFontShape{JY2}{zhsf}{bx}{n}{<-> upzhsansb-h}{} |
| 10525 |
%</jy2> |
| 10526 |
%<*jt2> |
| 10527 |
\DeclareFontShape{JT2}{zhsf}{m}{n}{<-> upzhsans-v}{} |
| 10528 |
\DeclareFontShape{JT2}{zhsf}{b}{n}{<-> upzhsansb-v}{} |
| 10529 |
\DeclareFontShape{JT2}{zhsf}{bx}{n}{<-> upzhsansb-v}{} |
| 10530 |
%</jt2> |
| 10531 |
%</sf> |
| 10532 |
% \end{macrocode} |
| 10533 |
% |
| 10534 |
% \begin{macrocode} |
| 10535 |
%<*tt> |
| 10536 |
%<*c19> |
| 10537 |
\DeclareFontShape{C19}{tt}{m}{n}{<-> CJK * gbkfs}{\CJKnormal} |
| 10538 |
\DeclareFontShape{C19}{tt}{b}{n}{<-> CJKb * gbkfs}{\CJKbold} |
| 10539 |
\DeclareFontShape{C19}{tt}{bx}{n}{<-> CJKb * gbkfs}{\CJKbold} |
| 10540 |
\DeclareFontShape{C19}{tt}{m}{sl}{<-> CJK * gbkfssl}{\CJKnormal} |
| 10541 |
\DeclareFontShape{C19}{tt}{b}{sl}{<-> CJKb * gbkfssl}{\CJKbold} |
| 10542 |
\DeclareFontShape{C19}{tt}{bx}{sl}{<-> CJKb * gbkfssl}{\CJKbold} |
| 10543 |
\DeclareFontShape{C19}{tt}{m}{it}{<-> CJK * gbkfs}{\CJKnormal} |
| 10544 |
\DeclareFontShape{C19}{tt}{b}{it}{<-> CJKb * gbkfs}{\CJKbold} |
| 10545 |
\DeclareFontShape{C19}{tt}{bx}{it}{<-> CJKb * gbkfs}{\CJKbold} |
| 10546 |
%</c19> |
| 10547 |
%<*c70> |
| 10548 |
\DeclareFontShape{C70}{tt}{m}{n}{<-> CJK * unifs}{\CJKnormal} |
| 10549 |
\DeclareFontShape{C70}{tt}{b}{n}{<-> CJKb * unifs}{\CJKbold} |
| 10550 |
\DeclareFontShape{C70}{tt}{bx}{n}{<-> CJKb * unifs}{\CJKbold} |
| 10551 |
\DeclareFontShape{C70}{tt}{m}{sl}{<-> CJK * unifssl}{\CJKnormal} |
| 10552 |
\DeclareFontShape{C70}{tt}{b}{sl}{<-> CJKb * unifssl}{\CJKbold} |
| 10553 |
\DeclareFontShape{C70}{tt}{bx}{sl}{<-> CJKb * unifssl}{\CJKbold} |
| 10554 |
\DeclareFontShape{C70}{tt}{m}{it}{<-> CJK * unifs}{\CJKnormal} |
| 10555 |
\DeclareFontShape{C70}{tt}{b}{it}{<-> CJKb * unifs}{\CJKbold} |
| 10556 |
\DeclareFontShape{C70}{tt}{bx}{it}{<-> CJKb * unifs}{\CJKbold} |
| 10557 |
%</c70> |
| 10558 |
%<*jy2> |
| 10559 |
\DeclareFontShape{JY2}{zhtt}{m}{n}{<-> upzhmono-h}{} |
| 10560 |
%</jy2> |
| 10561 |
%<*jt2> |
| 10562 |
\DeclareFontShape{JT2}{zhtt}{m}{n}{<-> upzhmono-v}{} |
| 10563 |
%</jt2> |
| 10564 |
%</tt> |
| 10565 |
% \end{macrocode} |
| 10566 |
% |
| 10567 |
% \subsubsection{预定义字库} |
| 10568 |
% |
| 10569 |
% \begin{macrocode} |
| 10570 |
%<*fontset> |
| 10571 |
% \end{macrocode} |
| 10572 |
% |
| 10573 |
% \paragraph{\opt{adobe}} |
| 10574 |
% |
| 10575 |
% \tn{pdfmapline} 不支持 OpenType 字体,因而 \opt{adobe} 字体集在 pdf 模式下 |
| 10576 |
% 就没有定义。\opt{fandol} 的情况类似。 |
| 10577 |
% \begin{macrocode} |
| 10578 |
%<*adobe> |
| 10579 |
\ctex_fontset_case:nnnn |
| 10580 |
{ \ctex_fontset_error:n { adobe } } |
| 10581 |
{ |
| 10582 |
\ctex_zhmap_case:nnn |
| 10583 |
{ |
| 10584 |
\setCJKmainfont { AdobeSongStd-Light.otf } |
| 10585 |
[ |
| 10586 |
cmap = UniGB-UTF16-H, |
| 10587 |
BoldFont = AdobeHeitiStd-Regular.otf, |
| 10588 |
ItalicFont = AdobeKaitiStd-Regular.otf |
| 10589 |
] |
| 10590 |
\setCJKsansfont { AdobeHeitiStd-Regular.otf } |
| 10591 |
[ cmap = UniGB-UTF16-H ] |
| 10592 |
\setCJKmonofont { AdobeFangsongStd-Regular.otf } |
| 10593 |
[ cmap = UniGB-UTF16-H ] |
| 10594 |
\setCJKfamilyfont { zhsong } { AdobeSongStd-Light.otf } |
| 10595 |
[ cmap = UniGB-UTF16-H ] |
| 10596 |
\setCJKfamilyfont { zhhei } { AdobeHeitiStd-Regular.otf } |
| 10597 |
[ cmap = UniGB-UTF16-H ] |
| 10598 |
\setCJKfamilyfont { zhkai } { AdobeKaitiStd-Regular.otf } |
| 10599 |
[ cmap = UniGB-UTF16-H ] |
| 10600 |
\setCJKfamilyfont { zhfs } { AdobeFangsongStd-Regular.otf } |
| 10601 |
[ cmap = UniGB-UTF16-H ] |
| 10602 |
\ctex_punct_set:n { adobe } |
| 10603 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10604 |
\ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } |
| 10605 |
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs } |
| 10606 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } |
| 10607 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10608 |
} |
| 10609 |
{ |
| 10610 |
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { adobe } |
| 10611 |
\ctex_punct_set:n { adobe } |
| 10612 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10613 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } |
| 10614 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10615 |
} |
| 10616 |
{ \ctex_fontset_error:n { adobe } } |
| 10617 |
} |
| 10618 |
{ |
| 10619 |
\ctex_set_upfonts:nnnnnn |
| 10620 |
{ AdobeSongStd-Light.otf } |
| 10621 |
{ AdobeHeitiStd-Regular.otf } |
| 10622 |
{ AdobeKaitiStd-Regular.otf } |
| 10623 |
{ AdobeHeitiStd-Regular.otf } |
| 10624 |
{ AdobeHeitiStd-Regular.otf } |
| 10625 |
{ AdobeFangsongStd-Regular.otf } |
| 10626 |
\ctex_set_upfamily:nnn { zhsong } { upzhserif } {} |
| 10627 |
\ctex_set_upfamily:nnn { zhhei } { upzhsans } {} |
| 10628 |
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {} |
| 10629 |
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} |
| 10630 |
} |
| 10631 |
{ |
| 10632 |
\setCJKmainfont { AdobeSongStd-Light } |
| 10633 |
[ BoldFont = AdobeHeitiStd-Regular, ItalicFont = AdobeKaitiStd-Regular ] |
| 10634 |
\setCJKsansfont { AdobeHeitiStd-Regular } |
| 10635 |
\setCJKmonofont { AdobeFangsongStd-Regular } |
| 10636 |
\setCJKfamilyfont { zhsong } { AdobeSongStd-Light } |
| 10637 |
\setCJKfamilyfont { zhhei } { AdobeHeitiStd-Regular } |
| 10638 |
\setCJKfamilyfont { zhfs } { AdobeFangsongStd-Regular } |
| 10639 |
\setCJKfamilyfont { zhkai } { AdobeKaitiStd-Regular } |
| 10640 |
} |
| 10641 |
%</adobe> |
| 10642 |
% \end{macrocode} |
| 10643 |
% |
| 10644 |
% \paragraph{\opt{fandol}} |
| 10645 |
% |
| 10646 |
% \begin{macrocode} |
| 10647 |
%<*fandol> |
| 10648 |
\ctex_fontset_case:nnnn |
| 10649 |
{ \ctex_fontset_error:n { fandol } } |
| 10650 |
{ |
| 10651 |
\ctex_zhmap_case:nnn |
| 10652 |
{ |
| 10653 |
\setCJKmainfont { FandolSong-Regular.otf } |
| 10654 |
[ |
| 10655 |
cmap = UniGB-UTF16-H, |
| 10656 |
BoldFont = FandolSong-Bold.otf, |
| 10657 |
ItalicFont = FandolKai-Regular.otf |
| 10658 |
] |
| 10659 |
\setCJKsansfont { FandolHei-Regular.otf } |
| 10660 |
[ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf ] |
| 10661 |
\setCJKmonofont { FandolFang-Regular.otf } |
| 10662 |
[ cmap = UniGB-UTF16-H ] |
| 10663 |
\setCJKfamilyfont { zhsong } { FandolSong-Regular.otf } |
| 10664 |
[ cmap = UniGB-UTF16-H, BoldFont = FandolSong-Bold.otf ] |
| 10665 |
\setCJKfamilyfont { zhhei } { FandolHei-Regular.otf } |
| 10666 |
[ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf ] |
| 10667 |
\setCJKfamilyfont { zhfs } { FandolFang-Regular.otf } |
| 10668 |
[ cmap = UniGB-UTF16-H ] |
| 10669 |
\setCJKfamilyfont { zhkai } { FandolKai-Regular.otf } |
| 10670 |
[ cmap = UniGB-UTF16-H ] |
| 10671 |
\ctex_punct_set:n { fandol } |
| 10672 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10673 |
\ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } |
| 10674 |
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs } |
| 10675 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb } |
| 10676 |
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhheib } |
| 10677 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10678 |
} |
| 10679 |
{ |
| 10680 |
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { fandol } |
| 10681 |
\ctex_punct_set:n { fandol } |
| 10682 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10683 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } |
| 10684 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10685 |
} |
| 10686 |
{ \ctex_fontset_error:n { fandol } } |
| 10687 |
} |
| 10688 |
{ |
| 10689 |
\ctex_set_upfonts:nnnnnn |
| 10690 |
{ FandolSong-Regular.otf } |
| 10691 |
{ FandolSong-Bold.otf } |
| 10692 |
{ FandolKai-Regular.otf } |
| 10693 |
{ FandolHei-Regular.otf } |
| 10694 |
{ FandolHei-Bold.otf } |
| 10695 |
{ FandolFang-Regular.otf } |
| 10696 |
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } |
| 10697 |
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } |
| 10698 |
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {} |
| 10699 |
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} |
| 10700 |
} |
| 10701 |
{ |
| 10702 |
\setCJKmainfont { FandolSong-Regular } |
| 10703 |
[ |
| 10704 |
Extension = .otf, |
| 10705 |
BoldFont = FandolSong-Bold, |
| 10706 |
ItalicFont = FandolKai-Regular |
| 10707 |
] |
| 10708 |
\setCJKsansfont { FandolHei-Regular } |
| 10709 |
[ Extension = .otf, BoldFont = FandolHei-Bold ] |
| 10710 |
\setCJKmonofont { FandolFang-Regular } |
| 10711 |
[ Extension = .otf ] |
| 10712 |
\setCJKfamilyfont { zhsong } { FandolSong-Regular } |
| 10713 |
[ Extension = .otf, BoldFont = FandolSong-Bold ] |
| 10714 |
\setCJKfamilyfont { zhhei } { FandolHei-Regular } |
| 10715 |
[ Extension = .otf, BoldFont = FandolHei-Bold ] |
| 10716 |
\setCJKfamilyfont { zhfs } { FandolFang-Regular } |
| 10717 |
[ Extension = .otf ] |
| 10718 |
\setCJKfamilyfont { zhkai } { FandolKai-Regular } |
| 10719 |
[ Extension = .otf ] |
| 10720 |
} |
| 10721 |
%</fandol> |
| 10722 |
% \end{macrocode} |
| 10723 |
% |
| 10724 |
% \paragraph{\opt{founder}} |
| 10725 |
% |
| 10726 |
% \changes{v2.4.15}{2019/03/28}{统一“方正细黑一\_GBK”的名称为 \texttt{FZXiHeiI-Z08}。} |
| 10727 |
% |
| 10728 |
% \begin{macrocode} |
| 10729 |
%<*founder> |
| 10730 |
\ctex_fontset_case:nnn |
| 10731 |
{ |
| 10732 |
\ctex_zhmap_case:nnn |
| 10733 |
{ |
| 10734 |
\setCJKmainfont { FZSSK.TTF } |
| 10735 |
[ BoldFont = FZXBSK.TTF, ItalicFont = FZKTK.TTF ] |
| 10736 |
\setCJKsansfont { FZXH1K.TTF } [ BoldFont = FZHTK.TTF ] |
| 10737 |
\setCJKmonofont { FZFSK.TTF } |
| 10738 |
\setCJKfamilyfont { zhsong } { FZSSK.TTF } [ BoldFont = FZXBSK.TTF ] |
| 10739 |
\setCJKfamilyfont { zhhei } { FZHTK.TTF } |
| 10740 |
\setCJKfamilyfont { zhkai } { FZKTK.TTF } |
| 10741 |
\setCJKfamilyfont { zhfs } { FZFSK.TTF } |
| 10742 |
\setCJKfamilyfont { zhli } { FZLSK.TTF } |
| 10743 |
\setCJKfamilyfont { zhyou } { FZY1K.TTF } [ BoldFont = FZY3K.TTF ] |
| 10744 |
\ctex_punct_set:n { founder } |
| 10745 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10746 |
\ctex_punct_map_family:nn { \CJKsfdefault } { zhheil } |
| 10747 |
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs } |
| 10748 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10749 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb } |
| 10750 |
\ctex_punct_map_bfseries:nn { \CJKsfdefault } { zhhei } |
| 10751 |
\ctex_punct_map_bfseries:nn { zhyou } { zhyoub } |
| 10752 |
} |
| 10753 |
{ |
| 10754 |
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { founder } |
| 10755 |
\ctex_punct_set:n { founder } |
| 10756 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10757 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } |
| 10758 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10759 |
} |
| 10760 |
{ \ctex_fontset_error:n { founder } } |
| 10761 |
} |
| 10762 |
{ |
| 10763 |
\ctex_set_upfonts:nnnnnn |
| 10764 |
{ FZSSK.TTF } |
| 10765 |
{ FZXBSK.TTF } |
| 10766 |
{ FZKTK.TTF } |
| 10767 |
{ FZXH1K.TTF } |
| 10768 |
{ FZHTK.TTF } |
| 10769 |
{ FZFSK.TTF } |
| 10770 |
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } |
| 10771 |
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } |
| 10772 |
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {} |
| 10773 |
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} |
| 10774 |
\ctex_set_upfamily:nnn { zhli } { upschrm } {} |
| 10775 |
\ctex_set_upfamily:nnn { zhyou } { upschgt } {} |
| 10776 |
\ctex_set_upmap:nnn { upstsl } { FZLSK.TTF } {} |
| 10777 |
\ctex_set_upmap:nnn { upstht } { FZY1K.TTF } {} |
| 10778 |
} |
| 10779 |
{ |
| 10780 |
\setCJKmainfont { FZShuSong-Z01 } |
| 10781 |
[ BoldFont = FZXiaoBiaoSong-B05, ItalicFont = FZKai-Z03 ] |
| 10782 |
\setCJKsansfont { FZXiHeiI-Z08 } [ BoldFont = FZHei-B01 ] |
| 10783 |
\setCJKmonofont { FZFangSong-Z02 } |
| 10784 |
\setCJKfamilyfont { zhsong } { FZShuSong-Z01 } |
| 10785 |
[ BoldFont = FZXiaoBiaoSong-B05 ] |
| 10786 |
\setCJKfamilyfont { zhhei } { FZHei-B01 } |
| 10787 |
\setCJKfamilyfont { zhkai } { FZKai-Z03 } |
| 10788 |
\setCJKfamilyfont { zhfs } { FZFangSong-Z02 } |
| 10789 |
\setCJKfamilyfont { zhli } { FZLiShu-S01 } |
| 10790 |
\setCJKfamilyfont { zhyou } { FZXiYuan-M01 } |
| 10791 |
[ BoldFont = FZZhunYuan-M02 ] |
| 10792 |
} |
| 10793 |
%</founder> |
| 10794 |
% \end{macrocode} |
| 10795 |
% |
| 10796 |
% \changes{v2.5.2}{2020/05/06} |
| 10797 |
% {修正 \opt{macnew} 和 \opt{ubuntu} 字库的 \pkg{CJKpunct} 标点信息。} |
| 10798 |
% |
| 10799 |
% \paragraph{\opt{mac} 相关} |
| 10800 |
% |
| 10801 |
% \changes{v2.4.14}{2018/05/01}{区分 \opt{macold} 及 \opt{macnew}。} |
| 10802 |
% |
| 10803 |
% 按 \href{https://github.com/CTeX-org/ctex-kit/issues/351}{Issue 351} |
| 10804 |
% 的讨论,以 El Capitan 为分界,分别设置 |macold|(El Capitan 之前) |
| 10805 |
% 和 |macnew|(El Capitan 及之后)。检测方式则以 El Capitan 及之后 |
| 10806 |
% 的苹方字体为准。 |
| 10807 |
% |
| 10808 |
% \begin{macrocode} |
| 10809 |
%<*mac> |
| 10810 |
\file_if_exist:nTF { /System/Library/Fonts/PingFang.ttc } |
| 10811 |
{ \ctex_file_input:n { ctex-fontset-macnew.def } } |
| 10812 |
{ \ctex_file_input:n { ctex-fontset-macold.def } } |
| 10813 |
%</mac> |
| 10814 |
% \end{macrocode} |
| 10815 |
% |
| 10816 |
% \changes{v2.4.14}{2018/05/01}{配置 \opt{macnew} 的默认字体设置。} |
| 10817 |
% \changes{v2.5}{2019/11/05}{为 \opt{macnew} 增加粗楷体、隶书和圆体的定义。} |
| 10818 |
% \changes{v2.5}{2019/11/07}{允许 \opt{macnew} 在 \LaTeX{} 和 \upLaTeX{} 下使用。} |
| 10819 |
% |
| 10820 |
% |macold| 的设置参考了 |
| 10821 |
% \href{https://github.com/CTeX-org/ctex-kit/wiki/OS-X-Mavericks-(10.9)-预装的主要简体中文字体}^^A |
| 10822 |
% {OS X Mavericks (10.9) 预装的主要简体中文字体列表}。 |
| 10823 |
% |
| 10824 |
% |macnew| 在默认字体设置方面,引入了多字重的宋体作为罗马字族, |
| 10825 |
% 以及引入了苹方黑体作为无衬线字族。 |
| 10826 |
% 由于 Songti SC Light 的字重与 STSong 及 Windows 上的 SimSun 更接近,故默认字重 |
| 10827 |
% 使用 Songti SC Light,而不带后缀的正常字重事实上没有使用。黑体、圆体等设置 |
| 10828 |
% 也有类似的情况。 |
| 10829 |
% |
| 10830 |
% \begin{macrocode} |
| 10831 |
%<*macold|macnew> |
| 10832 |
\ctex_fontset_case:nnnn |
| 10833 |
{ \ctex_fontset_error:n { mac } } |
| 10834 |
%<*macold> |
| 10835 |
{ \ctex_fontset_error:n { macold } } |
| 10836 |
{ \ctex_fontset_error:n { macold } } |
| 10837 |
%</macold> |
| 10838 |
%<*macnew> |
| 10839 |
{ |
| 10840 |
\ctex_zhmap_case:nnn |
| 10841 |
{ |
| 10842 |
\setCJKmainfont { :3:Songti.ttc } |
| 10843 |
[ |
| 10844 |
BoldFont = :1:Songti.ttc, |
| 10845 |
ItalicFont = :0:Kaiti.ttc, |
| 10846 |
BoldItalicFont = :3:Kaiti.ttc, |
| 10847 |
] |
| 10848 |
\setCJKsansfont { :2:PingFang.ttc } [ BoldFont = :8:PingFang.ttc ] |
| 10849 |
\setCJKmonofont { STFANGSO.ttf } |
| 10850 |
\setCJKfamilyfont { zhsong } { :3:Songti.ttc } [ BoldFont = :1:Songti.ttc ] |
| 10851 |
\setCJKfamilyfont { zhhei } { :2:PingFang.ttc } [ BoldFont = :8:PingFang.ttc ] |
| 10852 |
\setCJKfamilyfont { zhkai } { :0:Kaiti.ttc } [ BoldFont = :3:Kaiti.ttc ] |
| 10853 |
\setCJKfamilyfont { zhfs } { STFANGSO.ttf } |
| 10854 |
\setCJKfamilyfont { zhli } { :0:Baoli.ttc } |
| 10855 |
\setCJKfamilyfont { zhyou } { :4:Yuanti.ttc } [ BoldFont = :0:Yuanti.ttc ] |
| 10856 |
\ctex_punct_set:n { mac } |
| 10857 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10858 |
\ctex_punct_map_family:nn { \CJKsfdefault } { zhpf } |
| 10859 |
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs } |
| 10860 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10861 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb } |
| 10862 |
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhpfb } |
| 10863 |
\ctex_punct_map_bfseries:nn { zhyou } { zhyoub } |
| 10864 |
} |
| 10865 |
{ |
| 10866 |
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { mac } |
| 10867 |
\ctex_punct_set:n { mac } |
| 10868 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10869 |
\ctex_punct_map_family:nn { \CJKsfdefault } { zhpf } |
| 10870 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhpf } |
| 10871 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10872 |
} |
| 10873 |
{ \ctex_fontset_error:n { macnew } } |
| 10874 |
} |
| 10875 |
{ |
| 10876 |
\ctex_set_upmap:nnn { upserif } { :3:Songti.ttc } { :1:Songti.ttc } |
| 10877 |
\ctex_set_upmap:nnn { upserifit } { :0:Kaiti.ttc } { } |
| 10878 |
\ctex_set_upmap:nnn { upstsl } { :0:Baoli.ttc } { } |
| 10879 |
\ctex_set_upmap:nnn { upstht } { :4:Yuanti.ttc } { } |
| 10880 |
\ctex_set_upmap_unicode:nnn { upsans } { :2:PingFang.ttc } { :8:PingFang.ttc } |
| 10881 |
\ctex_set_upmap_unicode:nnn { upmono } { STFANGSO.ttf } { } |
| 10882 |
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } |
| 10883 |
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } |
| 10884 |
\ctex_set_upfamily:nnn { zhfs } { upzhmono } { } |
| 10885 |
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } { } |
| 10886 |
\ctex_set_upfamily:nnn { zhli } { upschrm } { } |
| 10887 |
\ctex_set_upfamily:nnn { zhyou } { upschgt } { } |
| 10888 |
} |
| 10889 |
%</macnew> |
| 10890 |
{ |
| 10891 |
%<*macold> |
| 10892 |
\setCJKmainfont { STSong } |
| 10893 |
[ BoldFont = STHeiti, ItalicFont = STKaiti ] |
| 10894 |
\setCJKsansfont { STXihei } [ BoldFont = STHeiti ] |
| 10895 |
\setCJKmonofont { STFangsong } |
| 10896 |
\setCJKfamilyfont { zhsong } { STSong } |
| 10897 |
\setCJKfamilyfont { zhhei } { STHeiti } |
| 10898 |
\setCJKfamilyfont { zhfs } { STFangsong } |
| 10899 |
\setCJKfamilyfont { zhkai } { STKaiti } |
| 10900 |
%</macold> |
| 10901 |
%<*macnew> |
| 10902 |
\setCJKmainfont { Songti~SC~Light } |
| 10903 |
[ |
| 10904 |
BoldFont = Songti~SC~Bold, |
| 10905 |
ItalicFont = Kaiti~SC, |
| 10906 |
BoldItalicFont = Kaiti~SC~Bold |
| 10907 |
] |
| 10908 |
\setCJKsansfont { PingFang~SC } |
| 10909 |
\setCJKmonofont { STFangsong } |
| 10910 |
\setCJKfamilyfont { zhsong } { Songti~SC~Light } [ BoldFont = Songti~SC~Bold ] |
| 10911 |
\setCJKfamilyfont { zhhei } { Heiti~SC~Light } [ BoldFont = Heiti~SC~Medium ] |
| 10912 |
\setCJKfamilyfont { zhpf } { PingFang~SC } |
| 10913 |
\setCJKfamilyfont { zhfs } { STFangsong } |
| 10914 |
\setCJKfamilyfont { zhkai } { Kaiti~SC } [ BoldFont = Kaiti~SC~Bold ] |
| 10915 |
\setCJKfamilyfont { zhli } { Baoli~SC } |
| 10916 |
\setCJKfamilyfont { zhyou } { Yuanti~SC~Light } [ BoldFont = Yuanti~SC~Regular ] |
| 10917 |
%</macnew> |
| 10918 |
} |
| 10919 |
%</macold|macnew> |
| 10920 |
% \end{macrocode} |
| 10921 |
% |
| 10922 |
% \paragraph{\opt{ubuntu}} |
| 10923 |
% |
| 10924 |
% \changes{v2.5}{2019/11/07}{\opt{ubuntu} 改用思源(Noto CJK)和文鼎字库,不再 |
| 10925 |
% 支持使用 \pdfLaTeX{} 编译。} |
| 10926 |
% |
| 10927 |
% \begin{macrocode} |
| 10928 |
%<*ubuntu> |
| 10929 |
\ctex_fontset_case:nnnn |
| 10930 |
{ \ctex_fontset_error:n { ubuntu } } |
| 10931 |
{ |
| 10932 |
\ctex_zhmap_case:nnn |
| 10933 |
{ |
| 10934 |
\setCJKmainfont { :2:NotoSerifCJK-Regular.ttc } |
| 10935 |
[ BoldFont = :2:NotoSerifCJK-Bold.ttc, ItalicFont = gkai00mp.ttf ] |
| 10936 |
\setCJKsansfont { :2:NotoSansCJK-Regular.ttc } |
| 10937 |
[ BoldFont = :2:NotoSansCJK-Bold.ttc ] |
| 10938 |
\setCJKmonofont { :2:NotoSerifCJK-Regular.ttc } |
| 10939 |
[ BoldFont = :2:NotoSerifCJK-Bold.ttc ] |
| 10940 |
\setCJKfamilyfont { zhsong } { :2:NotoSerifCJK-Regular.ttc } |
| 10941 |
[ BoldFont = :2:NotoSerifCJK-Bold.ttc ] |
| 10942 |
\setCJKfamilyfont { zhhei } { :2:NotoSansCJK-Regular.ttc } |
| 10943 |
[ BoldFont = :2:NotoSansCJK-Bold.ttc ] |
| 10944 |
\setCJKfamilyfont { zhkai } { gkai00mp.ttf } |
| 10945 |
\ctex_punct_set:n { ubuntu } |
| 10946 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10947 |
\ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } |
| 10948 |
\ctex_punct_map_family:nn { \CJKttdefault } { zhsong } |
| 10949 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10950 |
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhheib } |
| 10951 |
\ctex_punct_map_bfseries:nn |
| 10952 |
{ \CJKrmdefault, \CJKttdefault, zhsong } |
| 10953 |
{ zhsongb } |
| 10954 |
} |
| 10955 |
{ |
| 10956 |
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhsong } { ubuntu } |
| 10957 |
\ctex_punct_set:n { ubuntu } |
| 10958 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 10959 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } |
| 10960 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 10961 |
} |
| 10962 |
{ \ctex_fontset_error:n { ubuntu } } |
| 10963 |
} |
| 10964 |
{ |
| 10965 |
\ctex_set_upmap_unicode:nnn { upserif } |
| 10966 |
{ :2:NotoSerifCJK-Regular.ttc } { :2:NotoSerifCJK-Bold.ttc } |
| 10967 |
\ctex_set_upmap_unicode:nnn { upsans } |
| 10968 |
{ :2:NotoSansCJK-Regular.ttc } { :2:NotoSansCJK-Bold.ttc } |
| 10969 |
\ctex_set_upmap_unicode:nnn { upmono } |
| 10970 |
{ :2:NotoSerifCJK-Regular.ttc } { } |
| 10971 |
\ctex_set_upmap:nnn { upserifit } { gkai00mp.ttf } { } |
| 10972 |
\ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } |
| 10973 |
\ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } |
| 10974 |
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } { } |
| 10975 |
} |
| 10976 |
{ |
| 10977 |
\setCJKmainfont { Noto~Serif~CJK~SC } [ ItalicFont = AR~PL~KaitiM~GB ] |
| 10978 |
\setCJKsansfont { Noto~Sans~CJK~SC } |
| 10979 |
\setCJKmonofont { Noto~Serif~CJK~SC } |
| 10980 |
\setCJKfamilyfont { zhsong } { Noto~Serif~CJK~SC } |
| 10981 |
\setCJKfamilyfont { zhhei } { Noto~Sans~CJK~SC } |
| 10982 |
\setCJKfamilyfont { zhkai } { AR~PL~KaitiM~GB } |
| 10983 |
} |
| 10984 |
%</ubuntu> |
| 10985 |
% \end{macrocode} |
| 10986 |
% |
| 10987 |
% \paragraph{\opt{windows}} |
| 10988 |
% |
| 10989 |
% \changes{v2.4.1}{2016/05/14}{使用 \file{bootfont.bin} 判断 Windows XP 以避免 |
| 10990 |
% 权限问题。} |
| 10991 |
% \changes{v2.5}{2019/11/04}{使用环境变量代替绝对路径查找字体。} |
| 10992 |
% \changes{v2.5}{2019/11/05}{不再支持 Windows XP 系统,\opt{windowsold} 和 |
| 10993 |
% \opt{windowsnew} 成为过时字库选项。} |
| 10994 |
% |
| 10995 |
% \begin{variable}{ \c_@@_msyh_suffix_tl} |
| 10996 |
% Windows 8 以后,微软雅黑由原来的 \file{.ttf} 后缀改为 \file{.ttc} 后缀,需要 |
| 10997 |
% 加以区分。 |
| 10998 |
% \begin{macrocode} |
| 10999 |
%<*windows> |
| 11000 |
\file_if_exist:nTF { \c_dollar_str WINDIR/Fonts/msyh.ttc } |
| 11001 |
{ \tl_const:Nn \c_@@_msyh_suffix_tl { ttc } } |
| 11002 |
{ |
| 11003 |
\file_if_exist:nTF { msyh.ttc } |
| 11004 |
{ \tl_const:Nn \c_@@_msyh_suffix_tl { ttc } } |
| 11005 |
{ \tl_const:Nn \c_@@_msyh_suffix_tl { ttf } } |
| 11006 |
} |
| 11007 |
% \end{macrocode} |
| 11008 |
% \end{variable} |
| 11009 |
% |
| 11010 |
% \begin{macrocode} |
| 11011 |
\ctex_fontset_case:nnn |
| 11012 |
{ |
| 11013 |
\ctex_zhmap_case:nnn |
| 11014 |
{ |
| 11015 |
\ctex_punct_set:n { windows } |
| 11016 |
\setCJKmainfont { simsun.ttc } |
| 11017 |
[ BoldFont = simhei.ttf, ItalicFont = simkai.ttf ] |
| 11018 |
\setCJKsansfont { msyh.\c_@@_msyh_suffix_tl } |
| 11019 |
[ BoldFont = msyhbd.\c_@@_msyh_suffix_tl ] |
| 11020 |
\setCJKmonofont { simfang.ttf } |
| 11021 |
\setCJKfamilyfont { zhsong } { simsun.ttc } |
| 11022 |
\setCJKfamilyfont { zhhei } { simhei.ttf } |
| 11023 |
\setCJKfamilyfont { zhfs } { simfang.ttf } |
| 11024 |
\setCJKfamilyfont { zhkai } { simkai.ttf } |
| 11025 |
\setCJKfamilyfont { zhyahei } { msyh.\c_@@_msyh_suffix_tl } |
| 11026 |
[ BoldFont = msyhbd.\c_@@_msyh_suffix_tl ] |
| 11027 |
\setCJKfamilyfont { zhli } { simli.ttf } |
| 11028 |
\setCJKfamilyfont { zhyou } { simyou.ttf } |
| 11029 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 11030 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } |
| 11031 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 11032 |
\ctex_punct_map_family:nn { \CJKsfdefault } { zhyahei } |
| 11033 |
\ctex_punct_map_bfseries:nn { \CJKsfdefault, zhyahei } { zhyaheib } |
| 11034 |
\ctex_punct_map_family:nn { \CJKttdefault } { zhfs } |
| 11035 |
} |
| 11036 |
{ |
| 11037 |
\ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { windows } |
| 11038 |
\ctex_punct_set:n { windows } |
| 11039 |
\ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } |
| 11040 |
\ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } |
| 11041 |
\ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } |
| 11042 |
} |
| 11043 |
{ } |
| 11044 |
} |
| 11045 |
{ |
| 11046 |
\ctex_set_upfonts:nnnnnn |
| 11047 |
{ simsun.ttc } |
| 11048 |
{ simhei.ttf } |
| 11049 |
{ simkai.ttf } |
| 11050 |
{ msyh.\c_@@_msyh_suffix_tl } |
| 11051 |
{ msyhbd.\c_@@_msyh_suffix_tl } |
| 11052 |
{ simfang.ttf } |
| 11053 |
\ctex_set_upfamily:nnn { zhsong } { upzhserif } {} |
| 11054 |
\ctex_set_upfamily:nnn { zhhei } { upzhserifb } {} |
| 11055 |
\ctex_set_upfamily:nnn { zhfs } { upzhmono } {} |
| 11056 |
\ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} |
| 11057 |
\ctex_set_upfamily:nnn { zhyahei } { upzhsans } { upzhsansb } |
| 11058 |
\ctex_set_upfamily:nnn { zhli } { upschrm } {} |
| 11059 |
\ctex_set_upfamily:nnn { zhyou } { upschgt } {} |
| 11060 |
\ctex_set_upmap:nnn { upstsl } { simli.ttf } {} |
| 11061 |
\ctex_set_upmap:nnn { upstht } { simyou.ttf } {} |
| 11062 |
} |
| 11063 |
{ |
| 11064 |
\setCJKmainfont { SimSun } [ BoldFont = SimHei , ItalicFont = KaiTi ] |
| 11065 |
\setCJKsansfont { Microsoft~YaHei } [ BoldFont = *~Bold ] |
| 11066 |
\setCJKmonofont { FangSong } |
| 11067 |
\setCJKfamilyfont { zhsong } { SimSun } |
| 11068 |
\setCJKfamilyfont { zhhei } { SimHei } |
| 11069 |
\setCJKfamilyfont { zhfs } { FangSong } |
| 11070 |
\setCJKfamilyfont { zhkai } { KaiTi } |
| 11071 |
\setCJKfamilyfont { zhyahei } { Microsoft~YaHei } [ BoldFont = *~Bold ] |
| 11072 |
\setCJKfamilyfont { zhli } { LiSu } |
| 11073 |
\setCJKfamilyfont { zhyou } { YouYuan } |
| 11074 |
} |
| 11075 |
%</windows> |
| 11076 |
% \end{macrocode} |
| 11077 |
% |
| 11078 |
% \subsubsection{中文字体命令} |
| 11079 |
% \changes{v2.4.14}{2018/05/01}{为 \opt{macnew} 配置字体命令。} |
| 11080 |
% |
| 11081 |
% \begin{macro}{\songti,\heiti,\fangsong,\kaishu,\lishu,\youyuan,\yahei,\pingfang} |
| 11082 |
% 使用 \upLaTeX{} 编译时,\opt{macnew} 字库中由于传统黑体(黑体-简)无法使用, |
| 11083 |
% 我们用苹方来代替。同时 \tn{yahei}、\tn{pingfang} 命令被设置为与 \tn{heiti} 相同。 |
| 11084 |
% \begin{macrocode} |
| 11085 |
%<*!mac> |
| 11086 |
\NewDocumentCommand \songti { } { \CJKfamily { zhsong } } |
| 11087 |
\NewDocumentCommand \heiti { } { \CJKfamily { zhhei } } |
| 11088 |
%<!ubuntu>\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } } |
| 11089 |
\NewDocumentCommand \kaishu { } { \CJKfamily { zhkai } } |
| 11090 |
%<*windows|founder|macnew> |
| 11091 |
\NewDocumentCommand \lishu { } { \CJKfamily { zhli } } |
| 11092 |
\NewDocumentCommand \youyuan { } { \CJKfamily { zhyou } } |
| 11093 |
%</windows|founder|macnew> |
| 11094 |
%<windows>\NewDocumentCommand \yahei { } { \CJKfamily { zhyahei } } |
| 11095 |
%<*macnew> |
| 11096 |
\bool_lazy_or:nnTF |
| 11097 |
{ \sys_if_engine_pdftex_p: } |
| 11098 |
{ \sys_if_engine_uptex_p: } |
| 11099 |
{ |
| 11100 |
\cs_new_eq:NN \yahei \heiti |
| 11101 |
\cs_new_eq:NN \pingfang \heiti |
| 11102 |
} |
| 11103 |
{ |
| 11104 |
\NewDocumentCommand \yahei { } { \CJKfamily { zhpf } } |
| 11105 |
\NewDocumentCommand \pingfang { } { \CJKfamily { zhpf } } |
| 11106 |
} |
| 11107 |
%</macnew> |
| 11108 |
%</!mac> |
| 11109 |
% \end{macrocode} |
| 11110 |
% \end{macro} |
| 11111 |
% |
| 11112 |
% \begin{macrocode} |
| 11113 |
%</fontset> |
| 11114 |
% \end{macrocode} |
| 11115 |
% |
| 11116 |
% \subsubsection{\pkg{zhmetrics} 的字体映射} |
| 11117 |
% |
| 11118 |
% \changes{v2.5.2}{2020/05/05}{\file{zhadobefonts.tex} 等字体映射文件更名为 |
| 11119 |
% \file{ctex-zhmap-*.tex}。} |
| 11120 |
% |
| 11121 |
% 确认 \tn{catcode},没有重复载入检查。 |
| 11122 |
% \begin{macrocode} |
| 11123 |
%<*zhmap> |
| 11124 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 11125 |
\catcode 35=6 % # |
| 11126 |
\catcode 45=12 % - |
| 11127 |
\catcode123=1 % { |
| 11128 |
\catcode125=2 % } |
| 11129 |
\toks0{\endlinechar=\the\endlinechar\relax}% |
| 11130 |
\toks2{\endlinechar=-1 }% |
| 11131 |
\def\x#1 #2 {% |
| 11132 |
\toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}% |
| 11133 |
\toks2\expandafter{\the\toks2 \catcode#1=#2 }}% |
| 11134 |
\x 13 5 % carriage return |
| 11135 |
\x 32 10 % space |
| 11136 |
\x 35 6 % # |
| 11137 |
\x 40 12 % ( |
| 11138 |
\x 41 12 % ) |
| 11139 |
\x 45 12 % - |
| 11140 |
\x 46 12 % . |
| 11141 |
\x 47 12 % / |
| 11142 |
\x 58 12 % : |
| 11143 |
\x 60 12 % < |
| 11144 |
\x 61 12 % = |
| 11145 |
\x 64 11 % @ |
| 11146 |
\x 91 12 % [ |
| 11147 |
\x 93 12 % ] |
| 11148 |
\x 123 1 % { |
| 11149 |
\x 125 2 % } |
| 11150 |
\edef\x#1{\endgroup% |
| 11151 |
\edef\noexpand#1{% |
| 11152 |
\the\toks0 % |
| 11153 |
\let\noexpand\noexpand\noexpand#1% |
| 11154 |
\noexpand\noexpand\noexpand\undefined% |
| 11155 |
\noexpand\noexpand\noexpand\endinput}% |
| 11156 |
\the\toks2}% |
| 11157 |
\expandafter\x\csname ctex@zhmap@endinput\endcsname |
| 11158 |
% \end{macrocode} |
| 11159 |
% |
| 11160 |
% \begin{macro}[int]{\ifzhmappdf} |
| 11161 |
% \begin{macrocode} |
| 11162 |
\begingroup\expandafter\endgroup |
| 11163 |
\expandafter\let\csname ifzhmappdf\expandafter\endcsname\csname |
| 11164 |
\expandafter\ifx\csname ifctexpdf\endcsname\relax |
| 11165 |
\expandafter\ifx\csname pdfoutput\endcsname\relax |
| 11166 |
iffalse\else\ifnum\pdfoutput < 1 iffalse\else iftrue\fi\fi |
| 11167 |
\else ifctexpdf\fi |
| 11168 |
\endcsname |
| 11169 |
% \end{macrocode} |
| 11170 |
% \end{macro} |
| 11171 |
% |
| 11172 |
% \begin{macro}[int]{\ProvidesFile} |
| 11173 |
% 提供非 \LaTeX{} 格式下的 \tn{ProvidesFile}。 |
| 11174 |
% \begin{macrocode} |
| 11175 |
\begingroup |
| 11176 |
\expandafter\ifx\csname ProvidesFile\endcsname\relax |
| 11177 |
\long\def\x#1\ProvidesFile#2[#3]{% |
| 11178 |
#1% |
| 11179 |
\immediate\write-1{File: #2 #3}% |
| 11180 |
\expandafter\xdef\csname ver@#2\endcsname{#3}} |
| 11181 |
\expandafter\x% |
| 11182 |
\fi |
| 11183 |
\endgroup |
| 11184 |
% \end{macrocode} |
| 11185 |
% \end{macro} |
| 11186 |
% |
| 11187 |
% 文件标识信息。 |
| 11188 |
% \begin{macrocode} |
| 11189 |
%<adobe>\ProvidesFile{ctex-zhmap-adobe.tex}% |
| 11190 |
%<adobe> [2022/07/14 v2.5.10 Adobe font map loader for DVIPDFMx (CTEX)] |
| 11191 |
%<fandol>\ProvidesFile{ctex-zhmap-fandol.tex}% |
| 11192 |
%<fandol> [2022/07/14 v2.5.10 Fandol font map loader for DVIPDFMx (CTEX)] |
| 11193 |
%<founder>\ProvidesFile{ctex-zhmap-founder.tex}% |
| 11194 |
%<founder> [2022/07/14 v2.5.10 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)] |
| 11195 |
%<mac>\ProvidesFile{ctex-zhmap-mac.tex}% |
| 11196 |
%<mac> [2022/07/14 v2.5.10 Mac font map loader for DVIPDFMx (CTEX)] |
| 11197 |
%<ubuntu>\ProvidesFile{ctex-zhmap-ubuntu.tex}% |
| 11198 |
%<ubuntu> [2022/07/14 v2.5.10 Ubuntu font map loader for DVIPDFMx (CTEX)] |
| 11199 |
%<windows>\ProvidesFile{ctex-zhmap-windows.tex}% |
| 11200 |
%<windows> [2022/07/14 v2.5.10 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)] |
| 11201 |
% \end{macrocode} |
| 11202 |
% |
| 11203 |
% \paragraph{\pkg{ctex-zhmap-adobe.tex}} |
| 11204 |
% |
| 11205 |
% \begin{macrocode} |
| 11206 |
%<*adobe> |
| 11207 |
\ifzhmappdf |
| 11208 |
%% pdfTeX does not support OTF fonts |
| 11209 |
\else |
| 11210 |
\special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf} |
| 11211 |
\special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf} |
| 11212 |
\special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf} |
| 11213 |
\special{pdf:mapline gbkhei@UGBK@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf} |
| 11214 |
\special{pdf:mapline gbkfs@UGBK@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf} |
| 11215 |
\special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf} |
| 11216 |
\special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf} |
| 11217 |
\special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf} |
| 11218 |
\special{pdf:mapline unihei@Unicode@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf} |
| 11219 |
\special{pdf:mapline unifs@Unicode@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf} |
| 11220 |
\special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167} |
| 11221 |
\special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167} |
| 11222 |
\special{pdf:mapline gbkheisl@UGBK@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167} |
| 11223 |
\special{pdf:mapline gbkfssl@UGBK@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167} |
| 11224 |
\special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167} |
| 11225 |
\special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167} |
| 11226 |
\special{pdf:mapline uniheisl@Unicode@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167} |
| 11227 |
\special{pdf:mapline unifssl@Unicode@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167} |
| 11228 |
\fi |
| 11229 |
%</adobe> |
| 11230 |
% \end{macrocode} |
| 11231 |
% |
| 11232 |
% \paragraph{\pkg{ctex-zhmap-fandol.tex}} |
| 11233 |
% |
| 11234 |
% \begin{macrocode} |
| 11235 |
%<*fandol> |
| 11236 |
\ifzhmappdf |
| 11237 |
%% pdfTeX does not support OTF fonts |
| 11238 |
\else |
| 11239 |
\special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf} |
| 11240 |
\special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf} |
| 11241 |
\special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H FandolKai-Regular.otf} |
| 11242 |
\special{pdf:mapline gbkhei@UGBK@ UniGB-UTF16-H FandolHei-Regular.otf} |
| 11243 |
\special{pdf:mapline gbkfs@UGBK@ UniGB-UTF16-H FandolFang-Regular.otf} |
| 11244 |
\special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf} |
| 11245 |
\special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf} |
| 11246 |
\special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H FandolKai-Regular.otf} |
| 11247 |
\special{pdf:mapline unihei@Unicode@ UniGB-UTF16-H FandolHei-Regular.otf} |
| 11248 |
\special{pdf:mapline unifs@Unicode@ UniGB-UTF16-H FandolFang-Regular.otf} |
| 11249 |
\special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf -s .167} |
| 11250 |
\special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H FandolKai-Regular.otf -s .167} |
| 11251 |
\special{pdf:mapline gbkheisl@UGBK@ UniGB-UTF16-H FandolHei-Regular.otf -s .167} |
| 11252 |
\special{pdf:mapline gbkfssl@UGBK@ UniGB-UTF16-H FandolFang-Regular.otf -s .167} |
| 11253 |
\special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf -s .167} |
| 11254 |
\special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H FandolKai-Regular.otf -s .167} |
| 11255 |
\special{pdf:mapline uniheisl@Unicode@ UniGB-UTF16-H FandolHei-Regular.otf -s .167} |
| 11256 |
\special{pdf:mapline unifssl@Unicode@ UniGB-UTF16-H FandolFang-Regular.otf -s .167} |
| 11257 |
\fi |
| 11258 |
%</fandol> |
| 11259 |
% \end{macrocode} |
| 11260 |
% |
| 11261 |
% \paragraph{\pkg{ctex-zhmap-founder.tex}} |
| 11262 |
% |
| 11263 |
% \begin{macrocode} |
| 11264 |
%<*founder> |
| 11265 |
\ifzhmappdf |
| 11266 |
\pdfmapline{=gbk@UGBK@ <FZSSK.TTF} |
| 11267 |
\pdfmapline{=gbksong@UGBK@ <FZSSK.TTF} |
| 11268 |
\pdfmapline{=gbkkai@UGBK@ <FZKTK.TTF} |
| 11269 |
\pdfmapline{=gbkhei@UGBK@ <FZHTK.TTF} |
| 11270 |
\pdfmapline{=gbkfs@UGBK@ <FZFSK.TTF} |
| 11271 |
\pdfmapline{=gbkli@UGBK@ <FZLSK.TTF} |
| 11272 |
\pdfmapline{=gbkyou@UGBK@ <FZY1K.TTF} |
| 11273 |
\pdfmapline{=cyberb@Unicode@ <FZSSK.TTF} |
| 11274 |
\pdfmapline{=unisong@Unicode@ <FZSSK.TTF} |
| 11275 |
\pdfmapline{=unikai@Unicode@ <FZKTK.TTF} |
| 11276 |
\pdfmapline{=unihei@Unicode@ <FZHTK.TTF} |
| 11277 |
\pdfmapline{=unifs@Unicode@ <FZFSK.TTF} |
| 11278 |
\pdfmapline{=unili@Unicode@ <FZLSK.TTF} |
| 11279 |
\pdfmapline{=uniyou@Unicode@ <FZY1K.TTF} |
| 11280 |
\pdfmapline{=gbksongsl@UGBK@ <FZSSK.TTF} |
| 11281 |
\pdfmapline{=gbkkaisl@UGBK@ <FZKTK.TTF} |
| 11282 |
\pdfmapline{=gbkheisl@UGBK@ <FZHTK.TTF} |
| 11283 |
\pdfmapline{=gbkfssl@UGBK@ <FZFSK.TTF} |
| 11284 |
\pdfmapline{=gbklisl@UGBK@ <FZLSK.TTF} |
| 11285 |
\pdfmapline{=gbkyousl@UGBK@ <FZY1K.TTF} |
| 11286 |
\pdfmapline{=unisongsl@Unicode@ <FZSSK.TTF} |
| 11287 |
\pdfmapline{=unikaisl@Unicode@ <FZKTK.TTF} |
| 11288 |
\pdfmapline{=uniheisl@Unicode@ <FZHTK.TTF} |
| 11289 |
\pdfmapline{=unifssl@Unicode@ <FZFSK.TTF} |
| 11290 |
\pdfmapline{=unilisl@Unicode@ <FZLSK.TTF} |
| 11291 |
\pdfmapline{=uniyousl@Unicode@ <FZY1K.TTF} |
| 11292 |
\else |
| 11293 |
\special{pdf:mapline gbk@UGBK@ unicode FZSSK.TTF} |
| 11294 |
\special{pdf:mapline gbksong@UGBK@ unicode FZSSK.TTF} |
| 11295 |
\special{pdf:mapline gbkkai@UGBK@ unicode FZKTK.TTF} |
| 11296 |
\special{pdf:mapline gbkhei@UGBK@ unicode FZHTK.TTF} |
| 11297 |
\special{pdf:mapline gbkfs@UGBK@ unicode FZFSK.TTF} |
| 11298 |
\special{pdf:mapline gbkli@UGBK@ unicode FZLSK.TTF} |
| 11299 |
\special{pdf:mapline gbkyou@UGBK@ unicode FZY1K.TTF} |
| 11300 |
\special{pdf:mapline cyberb@Unicode@ unicode FZSSK.TTF} |
| 11301 |
\special{pdf:mapline unisong@Unicode@ unicode FZSSK.TTF} |
| 11302 |
\special{pdf:mapline unikai@Unicode@ unicode FZKTK.TTF} |
| 11303 |
\special{pdf:mapline unihei@Unicode@ unicode FZHTK.TTF} |
| 11304 |
\special{pdf:mapline unifs@Unicode@ unicode FZFSK.TTF} |
| 11305 |
\special{pdf:mapline unili@Unicode@ unicode FZLSK.TTF} |
| 11306 |
\special{pdf:mapline uniyou@Unicode@ unicode FZY1K.TTF} |
| 11307 |
\special{pdf:mapline gbksongsl@UGBK@ unicode FZSSK.TTF -s .167} |
| 11308 |
\special{pdf:mapline gbkkaisl@UGBK@ unicode FZKTK.TTF -s .167} |
| 11309 |
\special{pdf:mapline gbkheisl@UGBK@ unicode FZHTK.TTF -s .167} |
| 11310 |
\special{pdf:mapline gbkfssl@UGBK@ unicode FZFSK.TTF -s .167} |
| 11311 |
\special{pdf:mapline gbklisl@UGBK@ unicode FZLSK.TTF -s .167} |
| 11312 |
\special{pdf:mapline gbkyousl@UGBK@ unicode FZY1K.TTF -s .167} |
| 11313 |
\special{pdf:mapline unisongsl@Unicode@ unicode FZSSK.TTF -s .167} |
| 11314 |
\special{pdf:mapline unikaisl@Unicode@ unicode FZKTK.TTF -s .167} |
| 11315 |
\special{pdf:mapline uniheisl@Unicode@ unicode FZHTK.TTF -s .167} |
| 11316 |
\special{pdf:mapline unifssl@Unicode@ unicode FZFSK.TTF -s .167} |
| 11317 |
\special{pdf:mapline unilisl@Unicode@ unicode FZLSK.TTF -s .167} |
| 11318 |
\special{pdf:mapline uniyousl@Unicode@ unicode FZY1K.TTF -s .167} |
| 11319 |
\fi |
| 11320 |
%</founder> |
| 11321 |
% \end{macrocode} |
| 11322 |
% |
| 11323 |
% \paragraph{\pkg{ctex-zhmap-mac.tex}} |
| 11324 |
% |
| 11325 |
% \changes{v2.5}{2020/01/15}{增加字体映射文件 \file{zhmacfonts.tex}。} |
| 11326 |
% |
| 11327 |
% \begin{macrocode} |
| 11328 |
%<*mac> |
| 11329 |
\ifzhmappdf |
| 11330 |
%% pdfTeX does not support OTF fonts |
| 11331 |
\else |
| 11332 |
\special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H :3:Songti.ttc} |
| 11333 |
\special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H :3:Songti.ttc} |
| 11334 |
\special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H :0:Kaiti.ttc} |
| 11335 |
\special{pdf:mapline gbkhei@UGBK@ unicode :2:PingFang.ttc} |
| 11336 |
\special{pdf:mapline gbkfs@UGBK@ unicode STFANGSO.ttf} |
| 11337 |
\special{pdf:mapline gbkli@UGBK@ UniGB-UTF16-H :0:Baoli.ttc} |
| 11338 |
\special{pdf:mapline gbkyou@UGBK@ UniGB-UTF16-H :4:Yuanti.ttc} |
| 11339 |
\special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H :3:Songti.ttc} |
| 11340 |
\special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H :3:Songti.ttc} |
| 11341 |
\special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H :0:Kaiti.ttc} |
| 11342 |
\special{pdf:mapline unihei@Unicode@ unicode :2:PingFang.ttc} |
| 11343 |
\special{pdf:mapline unifs@Unicode@ unicode STFANGSO.ttf} |
| 11344 |
\special{pdf:mapline unili@Unicode@ UniGB-UTF16-H :0:Baoli.ttc} |
| 11345 |
\special{pdf:mapline uniyou@Unicode@ UniGB-UTF16-H :4:Yuanti.ttc} |
| 11346 |
\special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H :3:Songti.ttc -s .167} |
| 11347 |
\special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H :0:Kaiti.ttc -s .167} |
| 11348 |
\special{pdf:mapline gbkheisl@UGBK@ unicode :2:PingFang.ttc -s .167} |
| 11349 |
\special{pdf:mapline gbkfssl@UGBK@ unicode STFANGSO.ttf -s .167} |
| 11350 |
\special{pdf:mapline gbklisl@UGBK@ UniGB-UTF16-H :0:Baoli.ttc -s .167} |
| 11351 |
\special{pdf:mapline gbkyousl@UGBK@ UniGB-UTF16-H :4:Yuanti.ttc -s .167} |
| 11352 |
\special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H :3:Songti.ttc -s .167} |
| 11353 |
\special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H :0:Kaiti.ttc -s .167} |
| 11354 |
\special{pdf:mapline uniheisl@Unicode@ unicode :2:PingFang.ttc -s .167} |
| 11355 |
\special{pdf:mapline unifssl@Unicode@ unicode STFANGSO.ttf -s .167} |
| 11356 |
\special{pdf:mapline unilisl@Unicode@ UniGB-UTF16-H :0:Baoli.ttc -s .167} |
| 11357 |
\special{pdf:mapline uniyousl@Unicode@ UniGB-UTF16-H :4:Yuanti.ttc -s .167} |
| 11358 |
\fi |
| 11359 |
%</mac> |
| 11360 |
% \end{macrocode} |
| 11361 |
% |
| 11362 |
% \paragraph{\pkg{ctex-zhmap-ubuntu.tex}} |
| 11363 |
% |
| 11364 |
% \begin{macrocode} |
| 11365 |
%<*ubuntu> |
| 11366 |
\ifzhmappdf |
| 11367 |
%% pdfTeX does not support OTF fonts |
| 11368 |
\else |
| 11369 |
\special{pdf:mapline gbk@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc} |
| 11370 |
\special{pdf:mapline gbksong@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc} |
| 11371 |
\special{pdf:mapline gbkkai@UGBK@ unicode gkai00mp.ttf} |
| 11372 |
\special{pdf:mapline gbkhei@UGBK@ unicode :2:NotoSansCJK-Regular.ttc} |
| 11373 |
\special{pdf:mapline gbkfs@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc} |
| 11374 |
\special{pdf:mapline cyberb@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc} |
| 11375 |
\special{pdf:mapline unisong@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc} |
| 11376 |
\special{pdf:mapline unikai@Unicode@ unicode gkai00mp.ttf} |
| 11377 |
\special{pdf:mapline unihei@Unicode@ unicode :2:NotoSansCJK-Regular.ttc} |
| 11378 |
\special{pdf:mapline unifs@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc} |
| 11379 |
\special{pdf:mapline gbksongsl@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc -s .167} |
| 11380 |
\special{pdf:mapline gbkkaisl@UGBK@ unicode gkai00mp.ttf -s .167} |
| 11381 |
\special{pdf:mapline gbkheisl@UGBK@ unicode :2:NotoSansCJK-Regular.ttc -s .167} |
| 11382 |
\special{pdf:mapline gbkfssl@UGBK@ unicode :2:NotoSerifCJK-Regular.ttc -s .167} |
| 11383 |
\special{pdf:mapline unisongsl@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc -s .167} |
| 11384 |
\special{pdf:mapline unikaisl@Unicode@ unicode gkai00mp.ttf -s .167} |
| 11385 |
\special{pdf:mapline uniheisl@Unicode@ unicode :2:NotoSansCJK-Regular.ttc -s .167} |
| 11386 |
\special{pdf:mapline unifssl@Unicode@ unicode :2:NotoSerifCJK-Regular.ttc -s .167} |
| 11387 |
\fi |
| 11388 |
%</ubuntu> |
| 11389 |
% \end{macrocode} |
| 11390 |
% |
| 11391 |
% \paragraph{\pkg{ctex-zhmap-windows.tex}} |
| 11392 |
% |
| 11393 |
% \begin{macrocode} |
| 11394 |
%<*windows> |
| 11395 |
\ifzhmappdf |
| 11396 |
\pdfmapline{=gbk@UGBK@ <simsun.ttc} |
| 11397 |
\pdfmapline{=gbksong@UGBK@ <simsun.ttc} |
| 11398 |
\pdfmapline{=gbkkai@UGBK@ <simkai.ttf} |
| 11399 |
\pdfmapline{=gbkhei@UGBK@ <simhei.ttf} |
| 11400 |
\pdfmapline{=gbkfs@UGBK@ <simfang.ttf} |
| 11401 |
\pdfmapline{=gbkli@UGBK@ <simli.ttf} |
| 11402 |
\pdfmapline{=gbkyou@UGBK@ <simyou.ttf} |
| 11403 |
\pdfmapline{=cyberb@Unicode@ <simsun.ttc} |
| 11404 |
\pdfmapline{=unisong@Unicode@ <simsun.ttc} |
| 11405 |
\pdfmapline{=unikai@Unicode@ <simkai.ttf} |
| 11406 |
\pdfmapline{=unihei@Unicode@ <simhei.ttf} |
| 11407 |
\pdfmapline{=unifs@Unicode@ <simfang.ttf} |
| 11408 |
\pdfmapline{=unili@Unicode@ <simli.ttf} |
| 11409 |
\pdfmapline{=uniyou@Unicode@ <simyou.ttf} |
| 11410 |
\pdfmapline{=gbksongsl@UGBK@ <simsun.ttc} |
| 11411 |
\pdfmapline{=gbkkaisl@UGBK@ <simkai.ttf} |
| 11412 |
\pdfmapline{=gbkheisl@UGBK@ <simhei.ttf} |
| 11413 |
\pdfmapline{=gbkfssl@UGBK@ <simfang.ttf} |
| 11414 |
\pdfmapline{=gbklisl@UGBK@ <simli.ttf} |
| 11415 |
\pdfmapline{=gbkyousl@UGBK@ <simyou.ttf} |
| 11416 |
\pdfmapline{=unisongsl@Unicode@ <simsun.ttc} |
| 11417 |
\pdfmapline{=unikaisl@Unicode@ <simkai.ttf} |
| 11418 |
\pdfmapline{=uniheisl@Unicode@ <simhei.ttf} |
| 11419 |
\pdfmapline{=unifssl@Unicode@ <simfang.ttf} |
| 11420 |
\pdfmapline{=unilisl@Unicode@ <simli.ttf} |
| 11421 |
\pdfmapline{=uniyousl@Unicode@ <simyou.ttf} |
| 11422 |
\else |
| 11423 |
\special{pdf:mapline gbk@UGBK@ unicode :0:simsun.ttc -v 50} |
| 11424 |
\special{pdf:mapline gbksong@UGBK@ unicode :0:simsun.ttc -v 50} |
| 11425 |
\special{pdf:mapline gbkkai@UGBK@ unicode simkai.ttf -v 70} |
| 11426 |
\special{pdf:mapline gbkhei@UGBK@ unicode simhei.ttf -v 150} |
| 11427 |
\special{pdf:mapline gbkfs@UGBK@ unicode simfang.ttf -v 50} |
| 11428 |
\special{pdf:mapline gbkli@UGBK@ unicode simli.ttf -v 150} |
| 11429 |
\special{pdf:mapline gbkyou@UGBK@ unicode simyou.ttf -v 60} |
| 11430 |
\special{pdf:mapline cyberb@Unicode@ unicode :0:simsun.ttc -v 50} |
| 11431 |
\special{pdf:mapline unisong@Unicode@ unicode :0:simsun.ttc -v 50} |
| 11432 |
\special{pdf:mapline unikai@Unicode@ unicode simkai.ttf -v 70} |
| 11433 |
\special{pdf:mapline unihei@Unicode@ unicode simhei.ttf -v 150} |
| 11434 |
\special{pdf:mapline unifs@Unicode@ unicode simfang.ttf -v 50} |
| 11435 |
\special{pdf:mapline unili@Unicode@ unicode simli.ttf -v 150} |
| 11436 |
\special{pdf:mapline uniyou@Unicode@ unicode simyou.ttf -v 60} |
| 11437 |
\special{pdf:mapline gbksongsl@UGBK@ unicode :0:simsun.ttc -v 50 -s .167} |
| 11438 |
\special{pdf:mapline gbkkaisl@UGBK@ unicode simkai.ttf -v 70 -s .167} |
| 11439 |
\special{pdf:mapline gbkheisl@UGBK@ unicode simhei.ttf -v 150 -s .167} |
| 11440 |
\special{pdf:mapline gbkfssl@UGBK@ unicode simfang.ttf -v 50 -s .167} |
| 11441 |
\special{pdf:mapline gbklisl@UGBK@ unicode simli.ttf -v 150 -s .167} |
| 11442 |
\special{pdf:mapline gbkyousl@UGBK@ unicode simyou.ttf -v 60 -s .167} |
| 11443 |
\special{pdf:mapline unisongsl@Unicode@ unicode :0:simsun.ttc -v 50 -s .167} |
| 11444 |
\special{pdf:mapline unikaisl@Unicode@ unicode simkai.ttf -v 70 -s .167} |
| 11445 |
\special{pdf:mapline uniheisl@Unicode@ unicode simhei.ttf -v 150 -s .167} |
| 11446 |
\special{pdf:mapline unifssl@Unicode@ unicode simfang.ttf -v 50 -s .167} |
| 11447 |
\special{pdf:mapline unilisl@Unicode@ unicode simli.ttf -v 150 -s .167} |
| 11448 |
\special{pdf:mapline uniyousl@Unicode@ unicode simyou.ttf -v 60 -s .167} |
| 11449 |
\fi |
| 11450 |
%</windows> |
| 11451 |
% \end{macrocode} |
| 11452 |
% |
| 11453 |
% \begin{macrocode} |
| 11454 |
\ctex@zhmap@endinput |
| 11455 |
%</zhmap> |
| 11456 |
% \end{macrocode} |
| 11457 |
% |
| 11458 |
% \subsubsection{制作 \texttt{spa} 文件} |
| 11459 |
% |
| 11460 |
% \changes{v2.5.2}{2020/05/05}{\file{ctexmakespa.tex} 更名为 \file{ctex-spa-make.tex}。} |
| 11461 |
% \changes{v2.5.2}{2020/05/05}{\file{ctexspamacro.tex} 更名为 \file{ctex-spa-macro.tex}。} |
| 11462 |
% |
| 11463 |
% 我们通过 \XeTeX{} 的 \tn{XeTeXglyphbounds} 取得字体中标点符号的边界信息,为 |
| 11464 |
% \pkg{CJKpunct} 宏包制作 \file{spa}。 |
| 11465 |
% |
| 11466 |
% \begin{macrocode} |
| 11467 |
%<*spa> |
| 11468 |
%<*macro> |
| 11469 |
\input expl3-generic % |
| 11470 |
\ExplSyntaxOn |
| 11471 |
\sys_if_engine_xetex:F |
| 11472 |
{ |
| 11473 |
\msg_new:nnn { ctex } { xetex } |
| 11474 |
{ XeTeX~is~required~to~compile~this~document! } |
| 11475 |
\msg_fatal:nn { ctex } { xetex } |
| 11476 |
} |
| 11477 |
% \end{macrocode} |
| 11478 |
% |
| 11479 |
% \pkg{CJKpunct} 定义的标点符号是: |
| 11480 |
% \begin{verbatim} |
| 11481 |
% ‘“「『〔([{〈《〖【 |
| 11482 |
% —…、。,.:;!?%〕)]}〉》〗】’”」』 |
| 11483 |
% \end{verbatim} |
| 11484 |
% 注意顺序不能改变。 |
| 11485 |
% \begin{macrocode} |
| 11486 |
\seq_const_from_clist:Nn \c_@@_punct_seq |
| 11487 |
{ |
| 11488 |
"2018 , "201C , "300C , "300E , "3014 , "FF08 , "FF3B , "FF5B , |
| 11489 |
"3008 , "300A , "3016 , "3010 , |
| 11490 |
"2014 , "2026 , "3001 , "3002 , "FF0C , "FF0E , "FF1A , "FF1B , |
| 11491 |
"FF01 , "FF1F , "FF05 , "3015 , "FF09 , "FF3D , "FF5D , "3009 , |
| 11492 |
"300B , "3017 , "3011 , "2019 , "201D , "300D , "300F |
| 11493 |
} |
| 11494 |
% \end{macrocode} |
| 11495 |
% |
| 11496 |
% \begin{macro}[int]{\ctex_make_spa:nn} |
| 11497 |
% |#1| 是 \file{spa} 文件名,|#2| 是由 CJK 族名与字体构成的逗号列表。 |
| 11498 |
% \begin{macrocode} |
| 11499 |
\cs_new_protected:Npn \ctex_make_spa:nn #1#2 |
| 11500 |
{ |
| 11501 |
\iow_open:Nn \g_@@_spa_iow {#1} |
| 11502 |
\clist_map_inline:nn {#2} |
| 11503 |
{ \@@_write_family:nn ##1 } |
| 11504 |
\iow_close:N \g_@@_spa_iow |
| 11505 |
} |
| 11506 |
\iow_new:N \g_@@_spa_iow |
| 11507 |
\cs_new_eq:NN \MAKESPA \ctex_make_spa:nn |
| 11508 |
% \end{macrocode} |
| 11509 |
% \end{macro} |
| 11510 |
% |
| 11511 |
% \begin{macrocode} |
| 11512 |
\cs_new_protected:Npn \@@_write_family:nn #1#2 |
| 11513 |
{ |
| 11514 |
\group_begin: |
| 11515 |
\tex_font:D \l_@@_punct_font = "#2" ~ at ~ 100 pt \scan_stop: |
| 11516 |
\l_@@_punct_font |
| 11517 |
\clist_clear:N \l_@@_punct_bounds_clist |
| 11518 |
\seq_map_inline:Nn \c_@@_punct_seq |
| 11519 |
{ \exp_args:No \@@_save_bounds:n { \int_use:N \tex_XeTeXcharglyph:D ##1 } } |
| 11520 |
\iow_now:Nx \g_@@_spa_iow |
| 11521 |
{ |
| 11522 |
\token_to_str:N \ctexspadef {#1} |
| 11523 |
% \end{macrocode} |
| 11524 |
% 最后这三个逗号对 \pkg{CJKpunct} 来说是必要的。 |
| 11525 |
% \begin{macrocode} |
| 11526 |
{ \l_@@_punct_bounds_clist , , , } |
| 11527 |
} |
| 11528 |
\group_end: |
| 11529 |
} |
| 11530 |
\cs_new_protected:Npn \@@_save_bounds:n #1 |
| 11531 |
{ |
| 11532 |
\clist_put_right:Nx \l_@@_punct_bounds_clist |
| 11533 |
{ |
| 11534 |
\@@_calc_bounds:nn { 1 } {#1} , |
| 11535 |
\@@_calc_bounds:nn { 3 } {#1} |
| 11536 |
} |
| 11537 |
} |
| 11538 |
\clist_new:N \l_@@_punct_bounds_clist |
| 11539 |
% \end{macrocode} |
| 11540 |
% |
| 11541 |
% \pkg{CJKpunct} 要求的格式是边界空白宽度与 1\,em 的比值的一百倍。 |
| 11542 |
% \begin{macrocode} |
| 11543 |
\cs_new:Npn \@@_calc_bounds:nn #1#2 |
| 11544 |
{ |
| 11545 |
\fp_eval:n |
| 11546 |
{ |
| 11547 |
round |
| 11548 |
( |
| 11549 |
\dim_to_decimal_in_unit:nn |
| 11550 |
{ 100 \tex_XeTeXglyphbounds:D #1 ~ #2 } |
| 11551 |
{ 1 em } |
| 11552 |
) |
| 11553 |
} |
| 11554 |
} |
| 11555 |
\ExplSyntaxOff |
| 11556 |
%</macro> |
| 11557 |
% \end{macrocode} |
| 11558 |
% |
| 11559 |
% 下面是 \CTeX{} 定义的一些字体。 |
| 11560 |
% \begin{macrocode} |
| 11561 |
%<*make> |
| 11562 |
\input ctex-spa-macro % |
| 11563 |
\MAKESPA {ctexpunct.spa} |
| 11564 |
{ |
| 11565 |
{adobezhsong} {AdobeSongStd-Light} , |
| 11566 |
{adobezhhei} {AdobeHeitiStd-Regular} , |
| 11567 |
{adobezhkai} {AdobeKaitiStd-Regular} , |
| 11568 |
{adobezhfs} {AdobeFangsongStd-Regular} , |
| 11569 |
% |
| 11570 |
{fandolzhsong} {FandolSong} , |
| 11571 |
{fandolzhsongb} {FandolSong-Bold} , |
| 11572 |
{fandolzhhei} {FandolHei} , |
| 11573 |
{fandolzhheib} {FandolHei-Bold} , |
| 11574 |
{fandolzhkai} {FandolKai} , |
| 11575 |
{fandolzhfs} {FandolFang} , |
| 11576 |
% |
| 11577 |
{founderzhsong} {FZShuSong-Z01} , |
| 11578 |
{founderzhsongb} {FZXiaoBiaoSong-B05} , |
| 11579 |
{founderzhhei} {FZHei-B01} , |
| 11580 |
{founderzhheil} {FZXiHeiI-Z08} , |
| 11581 |
{founderzhkai} {FZKai-Z03} , |
| 11582 |
{founderzhfs} {FZFangSong-Z02} , |
| 11583 |
{founderzhli} {FZLiShu-S01} , |
| 11584 |
{founderzhyou} {FZXiYuan-M01} , |
| 11585 |
{founderzhyoub} {FZZhunYuan-M02} , |
| 11586 |
% |
| 11587 |
{maczhsong} {Songti SC Light} , |
| 11588 |
{maczhsongb} {Songti SC Bold} , |
| 11589 |
{maczhhei} {Heiti SC Medium} , |
| 11590 |
{maczhheil} {Heiti SC Light} , |
| 11591 |
{maczhkai} {Kaiti SC} , |
| 11592 |
{maczhkaib} {Kaiti SC Bold} , |
| 11593 |
{maczhfs} {STFangsong} , |
| 11594 |
{maczhli} {Baoli SC} , |
| 11595 |
{maczhyou} {Yuanti SC Light} , |
| 11596 |
{maczhyoub} {Yuanti SC Regular} , |
| 11597 |
{maczhpf} {PingFang SC} , |
| 11598 |
{maczhpfb} {PingFang SC Semibold} , |
| 11599 |
% |
| 11600 |
{ubuntuzhsong} {Noto Serif CJK SC} , |
| 11601 |
{ubuntuzhsongb} {Noto Serif CJK SC Bold} , |
| 11602 |
{ubuntuzhhei} {Noto Sans CJK SC} , |
| 11603 |
{ubuntuzhheib} {Noto Sans CJK SC Bold} , |
| 11604 |
{ubuntuzhkai} {AR PL KaitiM GB} , |
| 11605 |
% |
| 11606 |
{windowszhsong} {SimSun} , |
| 11607 |
{windowszhhei} {SimHei} , |
| 11608 |
{windowszhkai} {KaiTi} , |
| 11609 |
{windowszhfs} {FangSong} , |
| 11610 |
{windowszhli} {LiSu} , |
| 11611 |
{windowszhyou} {YouYuan} , |
| 11612 |
{windowszhyahei} {Microsoft YaHei} , |
| 11613 |
{windowszhyaheib} {Microsoft YaHei Bold} |
| 11614 |
} |
| 11615 |
\primitive\end |
| 11616 |
%</make> |
| 11617 |
%</spa> |
| 11618 |
% \end{macrocode} |
| 11619 |
% |
| 11620 |
% \subsection{\pkg{translator} 宏包的中文字典} |
| 11621 |
% |
| 11622 |
% \begin{macrocode} |
| 11623 |
%<*dict> |
| 11624 |
% \end{macrocode} |
| 11625 |
% |
| 11626 |
% \changes{v2.4}{2016/02/19}{提供 \pkg{translator} 宏包的中文定理名称翻译。} |
| 11627 |
% |
| 11628 |
% 包括 \pkg{ChineseGBK} 和 \pkg{ChineseUTF8} 两种形式,目前只翻译 \pkg{beamer} |
| 11629 |
% 宏包需要的定理环境名称。 |
| 11630 |
% |
| 11631 |
% \begin{macrocode} |
| 11632 |
%<*theorem> |
| 11633 |
\providetranslation{Comments}{评论} |
| 11634 |
\providetranslation{comments}{评论} |
| 11635 |
\providetranslation{Comment}{评论} |
| 11636 |
\providetranslation{comment}{评论} |
| 11637 |
\providetranslation{Corollaries}{推论} |
| 11638 |
\providetranslation{corollaries}{推论} |
| 11639 |
\providetranslation{Corollary}{推论} |
| 11640 |
\providetranslation{corollary}{推论} |
| 11641 |
\providetranslation{Definitions}{定义} |
| 11642 |
\providetranslation{definitions}{定义} |
| 11643 |
\providetranslation{Definition}{定义} |
| 11644 |
\providetranslation{definition}{定义} |
| 11645 |
\providetranslation{Examples}{例} |
| 11646 |
\providetranslation{examples}{例} |
| 11647 |
\providetranslation{Example}{例} |
| 11648 |
\providetranslation{example}{例} |
| 11649 |
\providetranslation{Exercises}{练习} |
| 11650 |
\providetranslation{exercises}{练习} |
| 11651 |
\providetranslation{Exercise}{练习} |
| 11652 |
\providetranslation{exercise}{练习} |
| 11653 |
\providetranslation{Facts}{事实} |
| 11654 |
\providetranslation{facts}{事实} |
| 11655 |
\providetranslation{Fact}{事实} |
| 11656 |
\providetranslation{fact}{事实} |
| 11657 |
\providetranslation{Key Lemmas}{关键引理} |
| 11658 |
\providetranslation{key lemmas}{关键引理} |
| 11659 |
\providetranslation{Key Lemma}{关键引理} |
| 11660 |
\providetranslation{key lemma}{关键引理} |
| 11661 |
\providetranslation{Key Observations}{关键观察} |
| 11662 |
\providetranslation{key observations}{关键观察} |
| 11663 |
\providetranslation{Key Observation}{关键观察} |
| 11664 |
\providetranslation{key observation}{关键观察} |
| 11665 |
\providetranslation{Lemmas}{引理} |
| 11666 |
\providetranslation{lemmas}{引理} |
| 11667 |
\providetranslation{Lemma}{引理} |
| 11668 |
\providetranslation{lemma}{引理} |
| 11669 |
\providetranslation{Main Theorems}{主要定理} |
| 11670 |
\providetranslation{main theorems}{主要定理} |
| 11671 |
\providetranslation{Main Theorem}{主要定理} |
| 11672 |
\providetranslation{main theorem}{主要定理} |
| 11673 |
\providetranslation{Observations}{观察} |
| 11674 |
\providetranslation{observations}{观察} |
| 11675 |
\providetranslation{Observation}{观察} |
| 11676 |
\providetranslation{observation}{观察} |
| 11677 |
\providetranslation{Problems}{问题} |
| 11678 |
\providetranslation{problems}{问题} |
| 11679 |
\providetranslation{Problem}{问题} |
| 11680 |
\providetranslation{problem}{问题} |
| 11681 |
\providetranslation{Proofs}{证明} |
| 11682 |
\providetranslation{proofs}{证明} |
| 11683 |
\providetranslation{Proof}{证明} |
| 11684 |
\providetranslation{proof}{证明} |
| 11685 |
\providetranslation{Proof Sketch}{证明提要} |
| 11686 |
\providetranslation{Proof sketch}{证明提要} |
| 11687 |
\providetranslation{proof sketch}{证明提要} |
| 11688 |
\providetranslation{Proof Sketches}{证明提要} |
| 11689 |
\providetranslation{Proof sketches}{证明提要} |
| 11690 |
\providetranslation{proof sketches}{证明提要} |
| 11691 |
\providetranslation{Sketch of Proof}{证明提要} |
| 11692 |
\providetranslation{Sketch of Proofs}{证明提要} |
| 11693 |
\providetranslation{Sketch of proof}{证明提要} |
| 11694 |
\providetranslation{Sketch of proofs}{证明提要} |
| 11695 |
\providetranslation{sketch of proof}{证明提要} |
| 11696 |
\providetranslation{sketch of proofs}{证明提要} |
| 11697 |
\providetranslation{Propositions}{命题} |
| 11698 |
\providetranslation{propositions}{命题} |
| 11699 |
\providetranslation{Proposition}{命题} |
| 11700 |
\providetranslation{proposition}{命题} |
| 11701 |
\providetranslation{Remarks}{注} |
| 11702 |
\providetranslation{remarks}{注} |
| 11703 |
\providetranslation{Remark}{注} |
| 11704 |
\providetranslation{remark}{注} |
| 11705 |
\providetranslation{Solutions}{解} |
| 11706 |
\providetranslation{solutions}{解} |
| 11707 |
\providetranslation{Solution}{解} |
| 11708 |
\providetranslation{solution}{解} |
| 11709 |
\providetranslation{Theorems}{定理} |
| 11710 |
\providetranslation{theorems}{定理} |
| 11711 |
\providetranslation{Theorem}{定理} |
| 11712 |
\providetranslation{theorem}{定理} |
| 11713 |
%</theorem> |
| 11714 |
% \end{macrocode} |
| 11715 |
% |
| 11716 |
% \begin{macrocode} |
| 11717 |
%</dict> |
| 11718 |
% \end{macrocode} |
| 11719 |
% |
| 11720 |
% \subsection{\pkg{ctexcap} 宏包} |
| 11721 |
% |
| 11722 |
% \begin{macrocode} |
| 11723 |
%<*ctexcap> |
| 11724 |
% \end{macrocode} |
| 11725 |
% |
| 11726 |
% \pkg{ctexcap} 是过时宏包。 |
| 11727 |
% \begin{macrocode} |
| 11728 |
\clist_new:N \l_@@_ctexcap_options_clist |
| 11729 |
\clist_set:Nx \l_@@_ctexcap_options_clist |
| 11730 |
{ \exp_not:v { opt@ \@currname . \@currext } , heading } |
| 11731 |
\msg_new:nnn { ctexcap } { deprecated } |
| 11732 |
{ |
| 11733 |
Package~`ctexcap'~is~deprecated.\\ |
| 11734 |
Please~use~package~`ctex'~with~option~`#1'~instead: \\\\ |
| 11735 |
\iow_indent:n { \token_to_str:N \usepackage [#1] \{ ctex \} } \\ |
| 11736 |
} |
| 11737 |
\msg_warning:nnx { ctexcap } { deprecated } |
| 11738 |
{ \clist_use:Nn \l_@@_ctexcap_options_clist { , ~ } } |
| 11739 |
% \end{macrocode} |
| 11740 |
% |
| 11741 |
% \pkg{ctexcap} 是默认打开 \opt{heading} 选项的 \pkg{ctex}。 |
| 11742 |
% \begin{macrocode} |
| 11743 |
\PassOptionsToPackage { heading = true } { ctexcap } |
| 11744 |
\RequirePackageWithOptions { ctex } |
| 11745 |
% \end{macrocode} |
| 11746 |
% |
| 11747 |
% \begin{macrocode} |
| 11748 |
%</ctexcap> |
| 11749 |
% \end{macrocode} |
| 11750 |
% |
| 11751 |
% |
| 11752 |
% \subsection{\pkg{ctexhook} 宏包} |
| 11753 |
% |
| 11754 |
% \changes{v2.2}{2015/06/26}{将文档开头和宏包末尾钩子提取到 \pkg{ctexhook} 宏包中。} |
| 11755 |
% \changes{v2.5}{2020/04/21}{增加宏包开头钩子。} |
| 11756 |
% \changes{v2.5.4}{2020/08/02}{兼容 \LaTeX \ 2020/10/01 的钩子机制。} |
| 11757 |
% |
| 11758 |
% \begin{macrocode} |
| 11759 |
%<*ctexhook> |
| 11760 |
% \end{macrocode} |
| 11761 |
% |
| 11762 |
% \begin{macro}[int]{\ctex_if_format_at_least:nTF} |
| 11763 |
% 与 \tn{IfFormatAtLeastTF} 同义。 |
| 11764 |
% \begin{macrocode} |
| 11765 |
\cs_new:Npn \ctex_if_format_at_least:nTF |
| 11766 |
{ \@ifl@t@r \fmtversion } |
| 11767 |
% \end{macrocode} |
| 11768 |
% \end{macro} |
| 11769 |
% |
| 11770 |
% \changes{v2.5.7}{2021/06/12}{重新应用 \pkg{l3cctab}。} |
| 11771 |
% |
| 11772 |
% \begin{macro}[int]{\ctex_file_input:n,\ctex_push_file:,\ctex_pop_file:} |
| 11773 |
% 输入文件,关闭 \LaTeXiii 语法环境,并设置 |@| 为字母类,利用 \pkg{l3cctab} 实现。 |
| 11774 |
% 我们使用 \cs{file_input:n} 而不是 \LaTeXe \ 的 \tn{input} 或者 \tn{InputIfFileExists} |
| 11775 |
% 载入文件,因此 \LaTeXe \ 的文件钩子都\emph{无效}。 |
| 11776 |
% \begin{macrocode} |
| 11777 |
\cs_new_protected:Npn \ctex_file_input:n #1 |
| 11778 |
{ |
| 11779 |
\ctex_push_file: |
| 11780 |
\file_input:n {#1} |
| 11781 |
\ctex_pop_file: |
| 11782 |
} |
| 11783 |
\bool_if_exist:NTF \l__kernel_expl_bool |
| 11784 |
{ |
| 11785 |
\cs_new_protected:Npn \ctex_push_file: |
| 11786 |
{ |
| 11787 |
\seq_gpush:Nx \g_@@_expl_status_seq |
| 11788 |
{ \bool_if:NTF \l__kernel_expl_bool { 1 } { 0 } } |
| 11789 |
\bool_set_false:N \l__kernel_expl_bool |
| 11790 |
\cctab_begin:N \c_@@_package_cctab |
| 11791 |
} |
| 11792 |
\cs_new_protected:Npn \ctex_pop_file: |
| 11793 |
{ |
| 11794 |
\cctab_end: |
| 11795 |
\seq_gpop:NN \g_@@_expl_status_seq \l_@@_expl_status_tl |
| 11796 |
\int_if_odd:nTF { \l_@@_expl_status_tl } |
| 11797 |
{ \bool_set_true:N \l__kernel_expl_bool } |
| 11798 |
{ \bool_set_false:N \l__kernel_expl_bool } |
| 11799 |
} |
| 11800 |
\tl_new:N \l_@@_expl_status_tl |
| 11801 |
\seq_new:N \g_@@_expl_status_seq |
| 11802 |
} |
| 11803 |
{ |
| 11804 |
\cs_new_protected:Npn \ctex_push_file: |
| 11805 |
{ \cctab_begin:N \c_@@_package_cctab } |
| 11806 |
\cs_new_protected:Npn \ctex_pop_file: |
| 11807 |
{ \cctab_end: } |
| 11808 |
} |
| 11809 |
\cctab_const:Nn \c_@@_package_cctab |
| 11810 |
{ |
| 11811 |
\cctab_select:N \c_document_cctab |
| 11812 |
\char_set_catcode_letter:n { 64 } |
| 11813 |
} |
| 11814 |
% \end{macrocode} |
| 11815 |
% \end{macro} |
| 11816 |
% |
| 11817 |
% \changes{v2.5.7}{2021/06/09}{使用 \tn{disable@package@load} 禁止宏包载入。} |
| 11818 |
% |
| 11819 |
% \begin{macro}[int]{\ctex_disable_package:n} |
| 11820 |
% 禁止宏包载入。采用 \LaTeX \ 2020-10-01 提供的 \tn{disable@package@load} 实现, |
| 11821 |
% 否则采用传统方式:预定义 |\ver@|\meta{package}|.sty| 标识符。 |
| 11822 |
% \begin{macrocode} |
| 11823 |
\cs_new_protected:Npn \ctex_disable_package:n #1 |
| 11824 |
{ |
| 11825 |
\@ifpackageloaded {#1} |
| 11826 |
{ \msg_error:nnxx } |
| 11827 |
{ \@@_disable_package_aux:nnnn } |
| 11828 |
{ ctexhook } { disable-package } {#1} { \@currname } |
| 11829 |
} |
| 11830 |
\cs_new_protected:Npx \@@_disable_package_aux:nnnn #1#2#3#4 |
| 11831 |
{ |
| 11832 |
\cs_if_exist:NTF \disable@package@load |
| 11833 |
{ |
| 11834 |
\exp_args:Nnx \exp_not:N \disable@package@load {#3} |
| 11835 |
{ \msg_warning:nnnn {#1} {#2} {#3} {#4} } |
| 11836 |
} |
| 11837 |
{ \tl_const:cn { ver@ #3 . \exp_not:N \@pkgextension } { 9999/99/99 } } |
| 11838 |
} |
| 11839 |
\msg_new:nnn { ctexhook } { disable-package } |
| 11840 |
{ Package~`#1'~can~not~be~loaded~with~`#2'. } |
| 11841 |
% \end{macrocode} |
| 11842 |
% \end{macro} |
| 11843 |
% |
| 11844 |
% \begin{macro}[int]{\ctex_replace_package:nn} |
| 11845 |
% 替换宏包。采用 \LaTeX \ 2020-10-01 提供的 \tn{declare@file@substitution} 实现, |
| 11846 |
% 否则给出无效警告。 |
| 11847 |
% \begin{macrocode} |
| 11848 |
\ctex_if_format_at_least:nTF { 2020/10/01 } |
| 11849 |
{ |
| 11850 |
\cs_new_protected:Npn \ctex_replace_package:nn #1#2 |
| 11851 |
{ |
| 11852 |
\declare@file@substitution |
| 11853 |
{ #1 . \@pkgextension } |
| 11854 |
{ #2 . \@pkgextension } |
| 11855 |
} |
| 11856 |
} |
| 11857 |
{ |
| 11858 |
\cs_new_protected:Npn \ctex_replace_package:nn |
| 11859 |
{ \msg_warning:nnnn { ctexhook } { replace-package-invalid } } |
| 11860 |
\msg_new:nnn { ctexhook } { replace-package-invalid } |
| 11861 |
{ |
| 11862 |
\token_to_str:N \ctex_replace_package:nn \{#1\}\{#2\}~is~invalid~ |
| 11863 |
before~LaTeX~2020-10-01. |
| 11864 |
} |
| 11865 |
} |
| 11866 |
% \end{macrocode} |
| 11867 |
% \end{macro} |
| 11868 |
% |
| 11869 |
% \begin{macro}[int]{\ctex_at_begin_package:nn} |
| 11870 |
% 如果宏包已经被载入,则钩子无效,给出警告。 |
| 11871 |
% \begin{macrocode} |
| 11872 |
\cs_new_protected:Npn \ctex_at_begin_package:nn #1 |
| 11873 |
{ |
| 11874 |
\@ifpackageloaded {#1} |
| 11875 |
{ \@@_package_loaded_warning:nn {#1} } |
| 11876 |
{ \ctex_gadd_package_hook:nnn { before } {#1} } |
| 11877 |
} |
| 11878 |
\cs_new_protected:Npn \@@_package_loaded_warning:nn #1#2 |
| 11879 |
{ \msg_warning:nnx { ctexhook } { invalid-hook } {#1} } |
| 11880 |
\msg_new:nnn { ctexhook } { invalid-hook } |
| 11881 |
{ |
| 11882 |
Package~`#1'~is~loaded. \\ |
| 11883 |
\token_to_str:N \ctex_at_begin_package:nn \{#1\}\{...\}~is~invalid. |
| 11884 |
} |
| 11885 |
% \end{macrocode} |
| 11886 |
% \end{macro} |
| 11887 |
% |
| 11888 |
% \begin{macro}[int]{\ctex_at_end_package:nn} |
| 11889 |
% 与 \pkg{filehook} 的 \tn{AtEndOfPackageFile*} 类似,如果原来没有在载入宏包则 |
| 11890 |
% 在宏包末尾执行语句,否则立即执行。 |
| 11891 |
% \begin{macrocode} |
| 11892 |
\cs_new_protected:Npn \ctex_at_end_package:nn #1 |
| 11893 |
{ |
| 11894 |
\@ifpackageloaded {#1} |
| 11895 |
{ \use:n } |
| 11896 |
{ \ctex_gadd_package_hook:nnn { after } {#1} } |
| 11897 |
} |
| 11898 |
% \end{macrocode} |
| 11899 |
% \end{macro} |
| 11900 |
% |
| 11901 |
% \changes{v2.5.6}{2021/02/16}{使用正确的导言区末尾钩子。} |
| 11902 |
% \changes{v2.5.8}{2021/11/18}{兼容 \LaTeX \ 2021/11/15。} |
| 11903 |
% |
| 11904 |
% \LaTeX \ 2020/10/01 开始提供常用钩子管理机制。在新机制下,我们只需要做简单的包装。 |
| 11905 |
% \begin{macrocode} |
| 11906 |
\ctex_if_format_at_least:nTF { 2020/10/01 } |
| 11907 |
{ |
| 11908 |
\cs_new_protected:Npx \ctex_gadd_ltxhook:nn #1 |
| 11909 |
{ \hook_gput_code:nnn {#1} { \c_novalue_tl } } |
| 11910 |
\cs_new_protected:Npn \ctex_at_end_preamble:n |
| 11911 |
{ \ctex_gadd_ltxhook:nn { begindocument/before } } |
| 11912 |
\cs_new_protected:Npn \ctex_after_end_preamble:n |
| 11913 |
{ \ctex_gadd_ltxhook:nn { begindocument/end } } |
| 11914 |
\cs_new_protected:Npx \ctex_gadd_package_hook:nnn #1#2 |
| 11915 |
{ |
| 11916 |
\ctex_if_format_at_least:nTF { 2021/11/15 } |
| 11917 |
{ \ctex_gadd_ltxhook:nn { package/#2/#1 } } |
| 11918 |
{ \ctex_gadd_ltxhook:nn { package/#1/#2 } } |
| 11919 |
} |
| 11920 |
\file_input_stop: |
| 11921 |
} |
| 11922 |
{ } |
| 11923 |
% \end{macrocode} |
| 11924 |
% |
| 11925 |
% 对于 \LaTeX \ 2020/10/01 之前的版本,需要自行补丁。 |
| 11926 |
% |
| 11927 |
% \begin{macro}[int]{\ctex_at_end_preamble:n,\ctex_after_end_preamble:n} |
| 11928 |
% 实现 \pkg{etoolbox} 宏包的 \tn{AtEndPreamble} 和 \tn{AfterEndPreamble}。 |
| 11929 |
% \begin{macrocode} |
| 11930 |
\cs_new_protected:Npn \ctex_at_end_preamble:n |
| 11931 |
{ \tl_gput_right:Nn \g_@@_end_preamble_hook_tl } |
| 11932 |
\cs_new_protected:Npn \ctex_after_end_preamble:n |
| 11933 |
{ \tl_gput_right:Nn \g_@@_after_end_preamble_hook_tl } |
| 11934 |
\cs_new_protected:Npn \CTEX@document@left@hook |
| 11935 |
{ \group_end: \g_@@_end_preamble_hook_tl \group_begin: } |
| 11936 |
\cs_new_protected:Npn \CTEX@document@right@hook |
| 11937 |
{ \scan_stop: \g_@@_after_end_preamble_hook_tl \tex_ignorespaces:D } |
| 11938 |
\cs_set_nopar:Npx \document |
| 11939 |
{ |
| 11940 |
\CTEX@document@left@hook |
| 11941 |
\exp_not:o { \document } |
| 11942 |
\CTEX@document@right@hook |
| 11943 |
} |
| 11944 |
\tl_new:N \g_@@_end_preamble_hook_tl |
| 11945 |
\tl_new:N \g_@@_after_end_preamble_hook_tl |
| 11946 |
% \end{macrocode} |
| 11947 |
% \end{macro} |
| 11948 |
% |
| 11949 |
% \begin{macro}[int]{\ctex_gadd_package_hook:nnn, |
| 11950 |
% \ctex_gadd_hook:Nn, \ctex_gadd_hook:cn} |
| 11951 |
% 给钩子附加内容。 |
| 11952 |
% \begin{macrocode} |
| 11953 |
\cs_new_protected:Npn \ctex_gadd_package_hook:nnn #1#2 |
| 11954 |
{ \ctex_gadd_hook:cn { g_@@_at_ #1 _ #2 _hook_tl } } |
| 11955 |
\cs_new_protected:Npn \ctex_gadd_hook:Nn #1 |
| 11956 |
{ |
| 11957 |
\tl_if_exist:NF #1 { \tl_new:N #1 } |
| 11958 |
\tl_gput_right:Nn #1 |
| 11959 |
} |
| 11960 |
\cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } |
| 11961 |
% \end{macrocode} |
| 11962 |
% \end{macro} |
| 11963 |
% |
| 11964 |
% \begin{macro}[int]{\ctex_use_package_hook:nn} |
| 11965 |
% 宏包钩子,只执行一次,用后清除。 |
| 11966 |
% \begin{macrocode} |
| 11967 |
\cs_new_protected:Npn \ctex_use_package_hook:nn #1#2 |
| 11968 |
{ |
| 11969 |
\group_begin: \exp_args:NNc \group_end: |
| 11970 |
\@@_use_package_hook_aux:N { g_@@_at_ #1 _ #2 _hook_tl } |
| 11971 |
} |
| 11972 |
\cs_new_protected:Npn \@@_use_package_hook_aux:N #1 |
| 11973 |
{ \cs_if_exist_use:NT #1 { \cs_undefine:N #1 } } |
| 11974 |
% \end{macrocode} |
| 11975 |
% \end{macro} |
| 11976 |
% |
| 11977 |
% \begin{macro}[int]{\@reset@ptions,\CTEX@reset@ptions@hook} |
| 11978 |
% \tn{@pushfilename} 内部的 \tn{@currname} 和 \tn{@currext} 保存的是 |
| 11979 |
% 前一个宏包的状态,不能使用。需要对其后的 \tn{@reset@ptions} 做补丁来实现 |
| 11980 |
% \cs{ctex_at_begin_package:nn} 的功能。 |
| 11981 |
% \begin{macrocode} |
| 11982 |
\tl_put_right:Nn \@reset@ptions { \CTEX@reset@ptions@hook } |
| 11983 |
\cs_new_protected:Npn \CTEX@reset@ptions@hook |
| 11984 |
{ |
| 11985 |
\cs_if_eq:NNT \@currext \@pkgextension |
| 11986 |
{ \ctex_use_package_hook:nn { before } { \@currname } } |
| 11987 |
} |
| 11988 |
% \end{macrocode} |
| 11989 |
% \end{macro} |
| 11990 |
% |
| 11991 |
% \begin{macro}[int]{\@popfilename,\CTEX@popfilename@hook} |
| 11992 |
% 对 \tn{@popfilename} 做补丁来实现 \cs{ctex_at_end_package:nn} 的功能。 |
| 11993 |
% \begin{macrocode} |
| 11994 |
\tl_put_left:Nn \@popfilename { \CTEX@popfilename@hook } |
| 11995 |
\cs_new_protected:Npn \CTEX@popfilename@hook |
| 11996 |
{ |
| 11997 |
\cs_if_eq:NNT \@currext \@pkgextension |
| 11998 |
{ \ctex_use_package_hook:nn { after } { \@currname } } |
| 11999 |
} |
| 12000 |
% \end{macrocode} |
| 12001 |
% \end{macro} |
| 12002 |
% |
| 12003 |
% \begin{macrocode} |
| 12004 |
%</ctexhook> |
| 12005 |
% \end{macrocode} |
| 12006 |
% |
| 12007 |
% |
| 12008 |
% \subsection{\pkg{ctexpatch} 宏包} |
| 12009 |
% |
| 12010 |
% \changes{v2.2}{2015/06/23}{新增子宏包 \pkg{ctexpatch} 实现给宏打补丁功能。} |
| 12011 |
% |
| 12012 |
% \begin{macrocode} |
| 12013 |
%<*ctexpatch> |
| 12014 |
% \end{macrocode} |
| 12015 |
% |
| 12016 |
% \begin{macro}[int]{\ctex_patch_cmd_once:NnnnTF} |
| 12017 |
% 只进行第一次匹配进行替换。参数 |#2| 是宏重建时的 \tn{catcode} 设置。 |
| 12018 |
% \begin{macrocode} |
| 12019 |
\cs_new_protected:Npn \ctex_patch_cmd_once:NnnnTF #1#2 |
| 12020 |
{ |
| 12021 |
\ctex_patch_boot:NNnnTF \@@_patch_cmd:Nnnnnw #1 |
| 12022 |
{ once } {#2} { \use_i:nn } { \use_ii:nn } |
| 12023 |
} |
| 12024 |
% \end{macrocode} |
| 12025 |
% \end{macro} |
| 12026 |
% |
| 12027 |
% \begin{macro}[int]{\ctex_patch_cmd_all:NnnnTF} |
| 12028 |
% 替换所有匹配到的文本。 |
| 12029 |
% \begin{macrocode} |
| 12030 |
\cs_new_protected:Npn \ctex_patch_cmd_all:NnnnTF #1#2 |
| 12031 |
{ |
| 12032 |
\ctex_patch_boot:NNnnTF \@@_patch_cmd:Nnnnnw #1 |
| 12033 |
{ all } {#2} { \use_i:nn } { \use_ii:nn } |
| 12034 |
} |
| 12035 |
% \end{macrocode} |
| 12036 |
% \end{macro} |
| 12037 |
% |
| 12038 |
% \begin{macro}[int]{\ctex_patch_cmd:Nnn} |
| 12039 |
% 快捷方式,在补丁的时候关闭 \LaTeXiii{} 语法和设置 |@| 为字母类,补丁失败时给出警告。 |
| 12040 |
% \begin{macrocode} |
| 12041 |
\cs_new_protected:Npn \ctex_patch_cmd:Nnn #1 |
| 12042 |
{ |
| 12043 |
\ctex_patch_boot:NNnnTF \@@_patch_cmd:Nnnnnw #1 |
| 12044 |
{ once } |
| 12045 |
{ |
| 12046 |
\ExplSyntaxOff |
| 12047 |
\char_set_catcode_letter:n { 64 } |
| 12048 |
} |
| 12049 |
{ } |
| 12050 |
{ \ctex_patch_failure:N #1 } |
| 12051 |
} |
| 12052 |
\cs_new_protected:Npn \ctex_patch_failure:N #1 |
| 12053 |
{ \msg_warning:nnx { ctexpatch } { patch-failure } { \token_to_str:N #1 } } |
| 12054 |
\msg_new:nnn { ctexpatch } { patch-failure } |
| 12055 |
{ Oops!~Command~`#1'~is~NOT~patchable.\\ } |
| 12056 |
% \end{macrocode} |
| 12057 |
% \end{macro} |
| 12058 |
% |
| 12059 |
% \begin{macro}[int]{\ctex_preto_cmd:NnnTF} |
| 12060 |
% 在宏的原本定义前面增加钩子。 |
| 12061 |
% \begin{macrocode} |
| 12062 |
\cs_new_protected:Npn \ctex_preto_cmd:NnnTF #1#2 |
| 12063 |
{ |
| 12064 |
\ctex_patch_boot:NNnnTF \@@_hookto_cmd:Nnnnw #1 |
| 12065 |
{ left } {#2} { \use_i:nn } { \use_ii:nn } |
| 12066 |
} |
| 12067 |
% \end{macrocode} |
| 12068 |
% \end{macro} |
| 12069 |
% |
| 12070 |
% \begin{macro}[int]{\ctex_appto_cmd:NnnTF} |
| 12071 |
% 在宏的原本定义后面追加钩子。 |
| 12072 |
% \begin{macrocode} |
| 12073 |
\cs_new_protected:Npn \ctex_appto_cmd:NnnTF #1#2 |
| 12074 |
{ |
| 12075 |
\ctex_patch_boot:NNnnTF \@@_hookto_cmd:Nnnnw #1 |
| 12076 |
{ right } {#2} { \use_i:nn } { \use_ii:nn } |
| 12077 |
} |
| 12078 |
% \end{macrocode} |
| 12079 |
% \end{macro} |
| 12080 |
% |
| 12081 |
% \begin{macro}[int]{\ctex_patch_boot:NNnnTF} |
| 12082 |
% 参数记号 |#| 作为宏的参数被读入时,总是会双写,会影响随后的字符串替换。需要先 |
| 12083 |
% 将它转换为普通符号。 |
| 12084 |
% \begin{macrocode} |
| 12085 |
\cs_new_protected:Npn \ctex_patch_boot:NNnnTF #1#2#3#4#5#6 |
| 12086 |
{ |
| 12087 |
\cs_set_protected:Npx \@@_patch_true:w { \exp_not:n {#5} } |
| 12088 |
\cs_set_protected:Npx \@@_patch_false:w { \exp_not:n {#6} } |
| 12089 |
\group_begin: |
| 12090 |
\char_set_catcode_other:n { 35 } |
| 12091 |
\ctex_parse_name:NN #1 #2 {#3} {#4} |
| 12092 |
} |
| 12093 |
\cs_new_eq:NN \@@_patch_true:w \use_i:nn |
| 12094 |
\cs_new_eq:NN \@@_patch_false:w \use_ii:nn |
| 12095 |
% \end{macrocode} |
| 12096 |
% \end{macro} |
| 12097 |
% |
| 12098 |
% \begin{macro}[int]{\ctex_parse_name:NN} |
| 12099 |
% \changes{v2.4}{2016/04/11}{修复宏名解析错误。} |
| 12100 |
% 用 \tn{DeclareRobustCommand} 定义的宏或者由 \tn{newcommand} 或 \tn{newrobustcmd} |
| 12101 |
% 定义的带一个可选参数的宏第一次展开的结果都不是其实际定义,实际定义被保存在另外的 |
| 12102 |
% 宏中。由这些命令定义的宏的第一次展开结果可以有下面的形式(细节可查阅 \pkg{xpatch} |
| 12103 |
% 的文档): |
| 12104 |
% \begin{verbatim}[numbers=left,gobble=4] |
| 12105 |
% \protect␣\xaa␣␣ % \DeclareRobustCommand\xaa[1]{...} |
| 12106 |
% \protect␣\xab␣␣ % \DeclareRobustCommand\xab[1][]{...} |
| 12107 |
% \@protected@testopt␣\xac␣\\xac␣{} % \newcommand\xac[1][]{...} |
| 12108 |
% \@testopt␣\\xad␣{} % \newrobustcmd\xad[1][]{...} |
| 12109 |
% \x@protect␣\1\protect␣\1␣␣ % \DeclareRobustCommand\1[1]{...} |
| 12110 |
% \x@protect␣\2\protect␣\2␣␣ % \DeclareRobustCommand\2[1][]{...} |
| 12111 |
% \@protected@testopt␣\3\\3␣{} % \newcommand\3[1][]{...} |
| 12112 |
% \@testopt␣\\4␣{} % \newrobustcmd\4[1][]{...} |
| 12113 |
% \end{verbatim} |
| 12114 |
% \pkg{ctexpatch} 的主要原理是先对宏的 \tn{meaning} 作字符串替换,然后再用 |
| 12115 |
% \tn{scantokens} 来重建它。我们希望对宏的实际定义打补丁,为此需要先得到 |
| 12116 |
% 对应的名字。\pkg{letltxmacro}、\pkg{show2e} 和 \pkg{xpatch} 宏包中都有 |
| 12117 |
% 类似的工作。 |
| 12118 |
% \begin{macrocode} |
| 12119 |
\cs_new_protected:Npn \ctex_parse_name:NN #1#2 |
| 12120 |
{ \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } |
| 12121 |
\group_begin: |
| 12122 |
\cs_set_protected:Npn \@@_tmp:w #1#2#3 |
| 12123 |
{ |
| 12124 |
\cs_new_protected:Npn \ctex_parse_name:NNn ##1##2##3 |
| 12125 |
{ |
| 12126 |
\bool_lazy_or:nnTF |
| 12127 |
{ \cs_if_exist_p:c { ##3 ~ } } |
| 12128 |
{ \cs_if_exist_p:c { #1##3 } } |
| 12129 |
{ |
| 12130 |
\group_begin: |
| 12131 |
\use:e |
| 12132 |
{ |
| 12133 |
\group_end: |
| 12134 |
\@@_parse_name:nNNNnN |
| 12135 |
{ \cs_replacement_spec:N ##2 } |
| 12136 |
\exp_not:N ##2 |
| 12137 |
\exp_not:c { ##3 ~ } |
| 12138 |
\exp_not:c { #1##3 } |
| 12139 |
} { ##3 } ##1 |
| 12140 |
} |
| 12141 |
{ ##1##2 } |
| 12142 |
} |
| 12143 |
\cs_new_protected:Npn \@@_parse_name:nNNNnN ##1##2##3##4##5##6 |
| 12144 |
{ |
| 12145 |
\exp_args:Nc ##6 |
| 12146 |
{ |
| 12147 |
\str_case:nnTF {##1} |
| 12148 |
{ |
| 12149 |
{ \protect ##3 } { } |
| 12150 |
{ \x@protect ##2 \protect ##3 } { } |
| 12151 |
} |
| 12152 |
{ |
| 12153 |
\str_if_eq:eeTF |
| 12154 |
{ \exp_not:n { #1@protected@ ##3 #1##3 } } |
| 12155 |
{ |
| 12156 |
\exp_last_unbraced:Ne \@@_parse_name:w |
| 12157 |
{ \cs_replacement_spec:N ##3 } #3 ~ #2 \q_stop |
| 12158 |
} |
| 12159 |
{ #1##5 ~ } { ##5 ~ } |
| 12160 |
} |
| 12161 |
{ |
| 12162 |
\str_case:onTF { \@@_parse_name:w ##1 #3 ~ #2 \q_stop } |
| 12163 |
{ |
| 12164 |
{ #1@protected@ ##2 ##4 } { } |
| 12165 |
{ #1@ ##4 } { } |
| 12166 |
} |
| 12167 |
{ #1##5 } {##5} |
| 12168 |
} |
| 12169 |
} |
| 12170 |
} |
| 12171 |
\cs_new:Npn \@@_parse_name:w ##1 #3 ~ ##2 #2 ##3 \q_stop { ##1##2 } |
| 12172 |
} |
| 12173 |
\use:e |
| 12174 |
{ |
| 12175 |
\@@_tmp:w |
| 12176 |
{ \c_backslash_str } |
| 12177 |
{ \c_left_brace_str } |
| 12178 |
{ \tl_to_str:n { testopt } } |
| 12179 |
} |
| 12180 |
\group_end: |
| 12181 |
\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } |
| 12182 |
% \end{macrocode} |
| 12183 |
% \end{macro} |
| 12184 |
% |
| 12185 |
% \begin{variable}{\l_@@_prefix_str,\l_@@_parameter_str,\l_@@_replacement_str} |
| 12186 |
% 分别保存宏的 \tn{meaning} 中的前缀、参数文本和替换文本。 |
| 12187 |
% \begin{macrocode} |
| 12188 |
\str_new:N \l_@@_prefix_str |
| 12189 |
\str_new:N \l_@@_parameter_str |
| 12190 |
\str_new:N \l_@@_replacement_str |
| 12191 |
% \end{macrocode} |
| 12192 |
% \end{variable} |
| 12193 |
% |
| 12194 |
% \begin{macro}[int]{\ctex_get_macro_meaning:NTF} |
| 12195 |
% \begin{macro}{\@@_get_macro_meaning:w} |
| 12196 |
% 解构待补丁宏的 \tn{meaning}。若命令不是宏,则走向 |false| 分支。 |
| 12197 |
% \begin{macrocode} |
| 12198 |
\group_begin: |
| 12199 |
\cs_set_protected:Npn \@@_tmp:w #1 |
| 12200 |
{ |
| 12201 |
\prg_new_protected_conditional:Npnn |
| 12202 |
\ctex_get_macro_meaning:N ##1 { TF } |
| 12203 |
{ |
| 12204 |
\exp_after:wN \@@_get_macro_meaning:w |
| 12205 |
\token_to_meaning:N ##1 \q_mark #1 -> \q_mark \q_stop |
| 12206 |
} |
| 12207 |
\cs_new_protected:Npn \@@_get_macro_meaning:w |
| 12208 |
##1 #1 ##2 -> ##3 \q_mark ##4 \q_stop |
| 12209 |
{ |
| 12210 |
\tl_if_empty:nTF { ##4 } |
| 12211 |
{ \prg_return_false: } |
| 12212 |
{ |
| 12213 |
\str_set:Nn \l_@@_prefix_str { ##1 } |
| 12214 |
\str_set:Nn \l_@@_parameter_str { ##2 } |
| 12215 |
\str_set:Nn \l_@@_replacement_str { ##3 } |
| 12216 |
\prg_return_true: |
| 12217 |
} |
| 12218 |
} |
| 12219 |
} |
| 12220 |
\exp_args:No \@@_tmp:w { \tl_to_str:n { macro: } } |
| 12221 |
\group_end: |
| 12222 |
% \end{macrocode} |
| 12223 |
% \end{macro} |
| 12224 |
% \end{macro} |
| 12225 |
% |
| 12226 |
% \begin{macro}[int]{\ctex_if_rescanable:NnTF} |
| 12227 |
% 检查宏是否可以重建。 |
| 12228 |
% \begin{macrocode} |
| 12229 |
\cs_new_protected:Npn \ctex_if_rescanable:NnTF #1#2#3#4 |
| 12230 |
{ |
| 12231 |
\ctex_get_macro_meaning:NTF #1 |
| 12232 |
{ |
| 12233 |
\@@_patch_rebuild:Nn \@@_rebuild_cmd:w {#2} |
| 12234 |
\cs_if_eq:NNTF #1 \@@_rebuild_cmd:w {#3} {#4} |
| 12235 |
} |
| 12236 |
{#4} |
| 12237 |
} |
| 12238 |
\cs_new_eq:NN \@@_rebuild_cmd:w \prg_do_nothing: |
| 12239 |
% \end{macrocode} |
| 12240 |
% \end{macro} |
| 12241 |
% |
| 12242 |
% \begin{macro}{\@@_patch_rebuild:Nn} |
| 12243 |
% 使用 \cs{tl_rescan:nn} 来重新记号化 \tn{meaning} 字符串。 |
| 12244 |
% \begin{macrocode} |
| 12245 |
\cs_new_protected:Npn \@@_patch_rebuild:Nn #1#2 |
| 12246 |
{ |
| 12247 |
\@@_patch_rescan:NNn \l_@@_prefix_tl \l_@@_prefix_str {#2} |
| 12248 |
\@@_patch_rescan:NNn \l_@@_parameter_tl \l_@@_parameter_str {#2} |
| 12249 |
\@@_patch_rescan:NNn \l_@@_replacement_tl \l_@@_replacement_str {#2} |
| 12250 |
\use:e |
| 12251 |
{ |
| 12252 |
\exp_not:o { \l_@@_prefix_tl } \tex_def:D \exp_not:N #1 |
| 12253 |
\exp_not:o { \l_@@_parameter_tl } |
| 12254 |
{ \exp_not:o { \l_@@_replacement_tl } } |
| 12255 |
} |
| 12256 |
} |
| 12257 |
\cs_new_protected:Npn \@@_patch_rescan:NNn #1#2#3 |
| 12258 |
{ |
| 12259 |
\str_if_empty:NTF #2 |
| 12260 |
{ \tl_clear:N #1 } |
| 12261 |
{ \tl_set_rescan:Nno #1 {#3} {#2} } |
| 12262 |
} |
| 12263 |
\tl_new:N \l_@@_prefix_tl |
| 12264 |
\tl_new:N \l_@@_parameter_tl |
| 12265 |
\tl_new:N \l_@@_replacement_tl |
| 12266 |
% \end{macrocode} |
| 12267 |
% \end{macro} |
| 12268 |
% |
| 12269 |
% \begin{macro}{\@@_patch_cmd:Nnnnnw} |
| 12270 |
% 对宏的替换文本进行字符串替换,然后重建。 |
| 12271 |
% \begin{macrocode} |
| 12272 |
\cs_new_protected:Npn \@@_patch_cmd:Nnnnnw #1#2#3#4#5 |
| 12273 |
{ |
| 12274 |
\group_end: |
| 12275 |
\ctex_if_rescanable:NnTF #1 {#3} |
| 12276 |
{ |
| 12277 |
\use:e |
| 12278 |
{ |
| 12279 |
\@@_patch_replace:nnnTF {#2} |
| 12280 |
{ \tl_to_str:n {#4} } |
| 12281 |
{ \tl_to_str:n {#5} } |
| 12282 |
} |
| 12283 |
{ |
| 12284 |
\@@_patch_rebuild:Nn #1 {#3} |
| 12285 |
\@@_patch_true:w |
| 12286 |
} |
| 12287 |
{ \@@_patch_false:w } |
| 12288 |
} |
| 12289 |
{ \@@_patch_false:w } |
| 12290 |
} |
| 12291 |
% \end{macrocode} |
| 12292 |
% \end{macro} |
| 12293 |
% |
| 12294 |
% \begin{macro}{\@@_patch_replace:nnnTF} |
| 12295 |
% 替换前先检查原文本是否存在。 |
| 12296 |
% \begin{macrocode} |
| 12297 |
\cs_new_protected:Npn \@@_patch_replace:nnnTF #1#2#3#4 |
| 12298 |
{ |
| 12299 |
\tl_if_in:NnTF \l_@@_replacement_str {#2} |
| 12300 |
{ \use:c { tl_replace_ #1 :Nnn } \l_@@_replacement_str {#2} {#3} #4 } |
| 12301 |
} |
| 12302 |
% \end{macrocode} |
| 12303 |
% \end{macro} |
| 12304 |
% |
| 12305 |
% \begin{macro}{\@@_hookto_cmd:Nnnnw} |
| 12306 |
% 在宏的前/后附加钩子。 |
| 12307 |
% \begin{macrocode} |
| 12308 |
\cs_new_protected:Npn \@@_hookto_cmd:Nnnnw #1#2#3#4 |
| 12309 |
{ |
| 12310 |
\group_end: |
| 12311 |
\ctex_get_macro_meaning:NTF #1 |
| 12312 |
{ |
| 12313 |
\str_if_empty:NTF \l_@@_parameter_str |
| 12314 |
{ \@@_hookto_cmd_parameterless:Nnnnw } |
| 12315 |
{ \@@_hookto_cmd_parameter:Nnnnw } |
| 12316 |
#1 {#2} {#3} {#4} |
| 12317 |
} |
| 12318 |
{ \@@_patch_false:w } |
| 12319 |
} |
| 12320 |
% \end{macrocode} |
| 12321 |
% \end{macro} |
| 12322 |
% |
| 12323 |
% \begin{macro}{\@@_hookto_cmd_parameterless:Nnnnw} |
| 12324 |
% 如果宏没有参数,可以直接进行附加操作。注意保持宏的前缀。 |
| 12325 |
% \begin{macrocode} |
| 12326 |
\cs_new_protected:Npn \@@_hookto_cmd_parameterless:Nnnnw #1#2#3#4 |
| 12327 |
{ |
| 12328 |
\str_if_empty:NF \l_@@_prefix_str |
| 12329 |
{ \tl_rescan:no {#3} { \l_@@_prefix_str } } |
| 12330 |
\tex_edef:D #1 |
| 12331 |
{ |
| 12332 |
\use:c { @@_ #2 _hook_aux:nn } |
| 12333 |
{ \exp_not:o {#1} } |
| 12334 |
{ \exp_not:n {#4} } |
| 12335 |
} |
| 12336 |
\@@_patch_true:w |
| 12337 |
} |
| 12338 |
\cs_generate_variant:Nn \tl_rescan:nn { no } |
| 12339 |
\cs_new:Npn \@@_left_hook_aux:nn #1#2 { #2#1 } |
| 12340 |
\cs_new_eq:NN \@@_right_hook_aux:nn \use:nn |
| 12341 |
% \end{macrocode} |
| 12342 |
% \end{macro} |
| 12343 |
% |
| 12344 |
% \begin{macro}{\@@_hookto_cmd_parameter:Nnnnw} |
| 12345 |
% 如果宏有参数,需要在字符串中进行附加,然后再重建。 |
| 12346 |
% \begin{macrocode} |
| 12347 |
\cs_new_protected:Npn \@@_hookto_cmd_parameter:Nnnnw #1#2#3#4 |
| 12348 |
{ |
| 12349 |
\@@_patch_rebuild:Nn \@@_rebuild_cmd:w {#3} |
| 12350 |
\cs_if_eq:NNTF #1 \@@_rebuild_cmd:w |
| 12351 |
{ |
| 12352 |
\use:c { str_put_ #2 :Nn } \l_@@_replacement_str {#4} |
| 12353 |
\@@_patch_rebuild:Nn #1 {#3} |
| 12354 |
\@@_patch_true:w |
| 12355 |
} |
| 12356 |
{ \@@_patch_false:w } |
| 12357 |
} |
| 12358 |
% \end{macrocode} |
| 12359 |
% \end{macro} |
| 12360 |
% |
| 12361 |
% \begin{macrocode} |
| 12362 |
%</ctexpatch> |
| 12363 |
% \end{macrocode} |
| 12364 |
% |
| 12365 |
% \end{implementation} |
| 12366 |
% |
| 12367 |
% \Finale |
| 12368 |
% |
| 12369 |
\endinput |