From 8626a9c3cb5dc8d02d779d5b5b1e3933d5626f43 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 2 May 2020 03:03:34 +0000 Subject: CTAN sync 202005020303 --- language/chinese/ctex/README.md | 35 +- language/chinese/ctex/ctex.dtx | 6695 ++++++++++++------------- language/chinese/ctex/ctex.pdf | Bin 1061924 -> 1097730 bytes language/chinese/ctex/ctexpunct.spa | 20 +- language/chinese/ctex/ctxdoc.cls | 867 ++++ language/chinese/ctex/ctxdocstrip.tex | 110 + language/chinese/ctex/zhconv-make.lua | 114 + language/chinese/ctex/zhconv.lua | 205 + language/japanese/jlreq/Makefile | 2 +- language/japanese/jlreq/README-ja.md | 9 +- language/japanese/jlreq/README.md | 3 + language/japanese/jlreq/jlreq-helpers.sty | 16 +- language/japanese/jlreq/jlreq-ja.pdf | Bin 359176 -> 359458 bytes language/japanese/jlreq/jlreq-trimmarks-ja.md | 5 +- language/japanese/jlreq/jlreq-trimmarks.md | 7 +- language/japanese/jlreq/jlreq-trimmarks.sty | 140 +- language/japanese/jlreq/jlreq.cls | 71 +- language/japanese/jlreq/jlreq.pdf | Bin 116207 -> 116315 bytes 18 files changed, 4565 insertions(+), 3734 deletions(-) create mode 100644 language/chinese/ctex/ctxdoc.cls create mode 100644 language/chinese/ctex/ctxdocstrip.tex create mode 100644 language/chinese/ctex/zhconv-make.lua create mode 100644 language/chinese/ctex/zhconv.lua (limited to 'language') diff --git a/language/chinese/ctex/README.md b/language/chinese/ctex/README.md index 0fb3ee02f4..ae64dbcadd 100644 --- a/language/chinese/ctex/README.md +++ b/language/chinese/ctex/README.md @@ -15,6 +15,10 @@ Authors and Contributors * Chen Zhichu * Li Qing * Liam Huang +* Zeng Xiangdong +* Li Zeping +* Zhou Yukai +* Zhang Ruixi Contributing ------------ @@ -26,7 +30,7 @@ Issues and pull requests are welcome. Copyright and Licence --------------------- - Copyright (C) 2003--2019 + Copyright (C) 2003--2020 CTEX.ORG and any individual authors listed elsewhere in this file. ---------------------------------------------------------------------- @@ -40,11 +44,13 @@ Copyright and Licence and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. - This work has the LPPL maintenance status `maintained'. + This work has the LPPL maintenance status "maintained". - The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang. - - This package consists of the file ctex.dtx, + This package consists of the files ctex.dtx, + ctxdoc.cls, + ctxdocstrip.tex, + zhconv.lua, + zhconv-make.lua, and the derived files ctex.pdf, ctex.ins, ctex.sty, @@ -54,16 +60,15 @@ Copyright and Licence ctexbook.cls, ctexrep.cls, ctexbeamer.cls, - ctxdoc.cls, ctexcap.sty, ctexhook.sty, ctexpatch.sty, ctex-c5size.clo, ctex-cs4size.clo, - ctex-article.def, - ctex-book.def, - ctex-report.def, - ctex-beamer.def, + ctex-heading-article.def, + ctex-heading-book.def, + ctex-heading-report.def, + ctex-heading-beamer.def, ctex-scheme-plain.def, ctex-scheme-plain-article.def, ctex-scheme-plain-book.def, @@ -78,6 +83,7 @@ Copyright and Licence ctex-name-utf8.cfg, ctex.cfg, ctexopts.cfg, + ctexbackend.cfg, ctex-engine-pdftex.def, ctex-engine-xetex.def, ctex-engine-luatex.def, @@ -95,26 +101,25 @@ Copyright and Licence jt2zhrm.fd, jt2zhsf.fd, jt2zhtt.fd, - ctex-fontset-windows.def, - ctex-fontset-windowsnew.def, - ctex-fontset-windowsold.def, ctex-fontset-adobe.def, ctex-fontset-fandol.def, + ctex-fontset-founder.def, ctex-fontset-mac.def, ctex-fontset-macnew.def, ctex-fontset-macold.def, - ctex-fontset-founder.def, ctex-fontset-ubuntu.def, + ctex-fontset-windows.def, ctexspa.def, ctexpunct.spa, ctexmakespa.tex, ctexspamacro.tex, - ctxdocstrip.tex, zhadobefonts.tex, zhfandolfonts.tex, zhfounderfonts.tex, + zhmacfonts.tex, zhubuntufonts.tex, zhwindowsfonts.tex, + zhconv-index.lua, translator-theorem-dictionary-ChineseGBK.dict, translator-theorem-dictionary-ChineseUTF8.dict, and README.md (this file). diff --git a/language/chinese/ctex/ctex.dtx b/language/chinese/ctex/ctex.dtx index d4a80e4344..bd92c7e0a0 100644 --- a/language/chinese/ctex/ctex.dtx +++ b/language/chinese/ctex/ctex.dtx @@ -2,7 +2,7 @@ % !TeX program = XeLaTeX % !TeX encoding = UTF-8 % -% Copyright (C) 2003--2019 +% Copyright (C) 2003--2020 % CTEX.ORG and any individual authors listed elsewhere in this file. % -------------------------------------------------------------------------- % @@ -16,9 +16,7 @@ % and version 1.3 or later is part of all distributions of % LaTeX version 2005/12/01 or later. % -% This work has the LPPL maintenance status `maintained'. -% -% The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang. +% This work has the LPPL maintenance status "maintained". % % -------------------------------------------------------------------------- % @@ -43,6 +41,10 @@ Authors and Contributors * Chen Zhichu * Li Qing * Liam Huang +* Zeng Xiangdong +* Li Zeping +* Zhou Yukai +* Zhang Ruixi Contributing ------------ @@ -54,7 +56,7 @@ Issues and pull requests are welcome. Copyright and Licence --------------------- - Copyright (C) 2003--2019 + Copyright (C) 2003--2020 CTEX.ORG and any individual authors listed elsewhere in this file. ---------------------------------------------------------------------- @@ -68,11 +70,13 @@ Copyright and Licence and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. - This work has the LPPL maintenance status `maintained'. - - The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang. + This work has the LPPL maintenance status "maintained". - This package consists of the file ctex.dtx, + This package consists of the files ctex.dtx, + ctxdoc.cls, + ctxdocstrip.tex, + zhconv.lua, + zhconv-make.lua, and the derived files ctex.pdf, ctex.ins, ctex.sty, @@ -82,16 +86,15 @@ Copyright and Licence ctexbook.cls, ctexrep.cls, ctexbeamer.cls, - ctxdoc.cls, ctexcap.sty, ctexhook.sty, ctexpatch.sty, ctex-c5size.clo, ctex-cs4size.clo, - ctex-article.def, - ctex-book.def, - ctex-report.def, - ctex-beamer.def, + ctex-heading-article.def, + ctex-heading-book.def, + ctex-heading-report.def, + ctex-heading-beamer.def, ctex-scheme-plain.def, ctex-scheme-plain-article.def, ctex-scheme-plain-book.def, @@ -106,6 +109,7 @@ Copyright and Licence ctex-name-utf8.cfg, ctex.cfg, ctexopts.cfg, + ctexbackend.cfg, ctex-engine-pdftex.def, ctex-engine-xetex.def, ctex-engine-luatex.def, @@ -123,26 +127,25 @@ Copyright and Licence jt2zhrm.fd, jt2zhsf.fd, jt2zhtt.fd, - ctex-fontset-windows.def, - ctex-fontset-windowsnew.def, - ctex-fontset-windowsold.def, ctex-fontset-adobe.def, ctex-fontset-fandol.def, + ctex-fontset-founder.def, ctex-fontset-mac.def, ctex-fontset-macnew.def, ctex-fontset-macold.def, - ctex-fontset-founder.def, ctex-fontset-ubuntu.def, + ctex-fontset-windows.def, ctexspa.def, ctexpunct.spa, ctexmakespa.tex, ctexspamacro.tex, - ctxdocstrip.tex, zhadobefonts.tex, zhfandolfonts.tex, zhfounderfonts.tex, + zhmacfonts.tex, zhubuntufonts.tex, zhwindowsfonts.tex, + zhconv-index.lua, translator-theorem-dictionary-ChineseGBK.dict, translator-theorem-dictionary-ChineseUTF8.dict, and README.md (this file). @@ -160,9 +163,9 @@ Copyright and Licence \preamble - Copyright (C) 2003--2019 + Copyright (C) 2003--2020 CTEX.ORG and any individual authors listed in the documentation. ------------------------------------------------------------------------------- +--------------------------------------------------------------------- This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either @@ -174,16 +177,18 @@ Copyright and Licence and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. - This work has the LPPL maintenance status `maintained'. + This work has the LPPL maintenance status "maintained". - The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang. - ------------------------------------------------------------------------------- +--------------------------------------------------------------------- \endpreamble \postamble - This package consists of the file ctex.dtx, + This package consists of the files ctex.dtx, + ctxdoc.cls, + ctxdocstrip.tex, + zhconv.lua, + zhconv-make.lua, and the derived files ctex.pdf, ctex.ins, ctex.sty, @@ -193,16 +198,15 @@ Copyright and Licence ctexbook.cls, ctexrep.cls, ctexbeamer.cls, - ctxdoc.cls, ctexcap.sty, ctexhook.sty, ctexpatch.sty, ctex-c5size.clo, ctex-cs4size.clo, - ctex-article.def, - ctex-book.def, - ctex-report.def, - ctex-beamer.def, + ctex-heading-article.def, + ctex-heading-book.def, + ctex-heading-report.def, + ctex-heading-beamer.def, ctex-scheme-plain.def, ctex-scheme-plain-article.def, ctex-scheme-plain-book.def, @@ -217,6 +221,7 @@ Copyright and Licence ctex-name-utf8.cfg, ctex.cfg, ctexopts.cfg, + ctexbackend.cfg, ctex-engine-pdftex.def, ctex-engine-xetex.def, ctex-engine-luatex.def, @@ -234,26 +239,25 @@ Copyright and Licence jt2zhrm.fd, jt2zhsf.fd, jt2zhtt.fd, - ctex-fontset-windows.def, - ctex-fontset-windowsnew.def, - ctex-fontset-windowsold.def, ctex-fontset-adobe.def, ctex-fontset-fandol.def, + ctex-fontset-founder.def, ctex-fontset-mac.def, ctex-fontset-macnew.def, ctex-fontset-macold.def, - ctex-fontset-founder.def, ctex-fontset-ubuntu.def, + ctex-fontset-windows.def, ctexspa.def, ctexpunct.spa, ctexmakespa.tex, ctexspamacro.tex, - ctxdocstrip.tex, zhadobefonts.tex, zhfandolfonts.tex, zhfounderfonts.tex, + zhmacfonts.tex, zhubuntufonts.tex, zhwindowsfonts.tex, + zhconv-index.lua, translator-theorem-dictionary-ChineseGBK.dict, translator-theorem-dictionary-ChineseUTF8.dict, and README.md. @@ -270,16 +274,15 @@ Copyright and Licence \file{ctexrep.cls} {\from{\jobname.dtx}{class,report}} \file{ctexbeamer.cls} {\from{\jobname.dtx}{class,beamer}} \usepostamble\emptypostamble - \file{ctxdoc.cls} {\from{\jobname.dtx}{ctxdoc}} \file{ctexcap.sty} {\from{\jobname.dtx}{ctexcap}} \file{ctexhook.sty} {\from{\jobname.dtx}{ctexhook}} \file{ctexpatch.sty} {\from{\jobname.dtx}{ctexpatch}} \file{ctex-c5size.clo} {\from{\jobname.dtx}{c5size}} \file{ctex-cs4size.clo} {\from{\jobname.dtx}{cs4size}} - \file{ctex-article.def} {\from{\jobname.dtx}{heading,article}} - \file{ctex-book.def} {\from{\jobname.dtx}{heading,book}} - \file{ctex-report.def} {\from{\jobname.dtx}{heading,report}} - \file{ctex-beamer.def} {\from{\jobname.dtx}{heading,beamer}} + \file{ctex-heading-article.def} {\from{\jobname.dtx}{heading,article}} + \file{ctex-heading-book.def} {\from{\jobname.dtx}{heading,book}} + \file{ctex-heading-report.def} {\from{\jobname.dtx}{heading,report}} + \file{ctex-heading-beamer.def} {\from{\jobname.dtx}{heading,beamer}} \file{ctex-scheme-plain.def} {\from{\jobname.dtx}{scheme,generic,plain}} \file{ctex-scheme-plain-article.def} {\from{\jobname.dtx}{scheme,article,plain}} \file{ctex-scheme-plain-book.def} {\from{\jobname.dtx}{scheme,book,plain}} @@ -290,10 +293,11 @@ Copyright and Licence \file{ctex-scheme-chinese-book.def} {\from{\jobname.dtx}{scheme,book,chinese}} \file{ctex-scheme-chinese-report.def} {\from{\jobname.dtx}{scheme,report,chinese}} \file{ctex-scheme-chinese-beamer.def} {\from{\jobname.dtx}{scheme,beamer,chinese}} - \file{ctex-name-gbk.cfg} {\from{\jobname.dtx}{name,GBK}} + \ctxfile{GBK}{ctex-name-gbk.cfg} {\from{\jobname.dtx}{name,GBK}} \file{ctex-name-utf8.cfg} {\from{\jobname.dtx}{name,UTF8}} \file{ctex.cfg} {\from{\jobname.dtx}{config}} \file{ctexopts.cfg} {\from{\jobname.dtx}{ctexopts}} + \file{ctexbackend.cfg} {\from{\jobname.dtx}{backend}} \file{ctex-engine-pdftex.def} {\from{\jobname.dtx}{pdftex}} \file{ctex-engine-xetex.def} {\from{\jobname.dtx}{xetex}} \file{ctex-engine-luatex.def} {\from{\jobname.dtx}{luatex}} @@ -311,34 +315,29 @@ Copyright and Licence \file{jt2zhrm.fd} {\from{\jobname.dtx}{fd,rm,jt2}} \file{jt2zhsf.fd} {\from{\jobname.dtx}{fd,sf,jt2}} \file{jt2zhtt.fd} {\from{\jobname.dtx}{fd,tt,jt2}} - \file{ctex-fontset-windows.def} {\from{\jobname.dtx}{fontset,windows}} - \file{ctex-fontset-windowsnew.def} {\from{\jobname.dtx}{fontset,windowsnew}} - \file{ctex-fontset-windowsold.def} {\from{\jobname.dtx}{fontset,windowsold}} \file{ctex-fontset-adobe.def} {\from{\jobname.dtx}{fontset,adobe}} \file{ctex-fontset-fandol.def} {\from{\jobname.dtx}{fontset,fandol}} + \file{ctex-fontset-founder.def} {\from{\jobname.dtx}{fontset,founder}} \file{ctex-fontset-mac.def} {\from{\jobname.dtx}{fontset,mac}} - \file{ctex-fontset-macold.def} {\from{\jobname.dtx}{fontset,macold}} \file{ctex-fontset-macnew.def} {\from{\jobname.dtx}{fontset,macnew}} - \file{ctex-fontset-founder.def} {\from{\jobname.dtx}{fontset,founder}} + \file{ctex-fontset-macold.def} {\from{\jobname.dtx}{fontset,macold}} \file{ctex-fontset-ubuntu.def} {\from{\jobname.dtx}{fontset,ubuntu}} - \file{translator-theorem-dictionary-ChineseGBK.dict} + \file{ctex-fontset-windows.def} {\from{\jobname.dtx}{fontset,windows}} + \ctxfile{GBK}{translator-theorem-dictionary-ChineseGBK.dict} {\from{\jobname.dtx}{dict,theorem,GBK}} \file{translator-theorem-dictionary-ChineseUTF8.dict} {\from{\jobname.dtx}{dict,theorem,UTF8}} - \file{ctexspa.def} - { - \from{\jobname.dtx} {ctexspa} - \from{ctexpunct.spa} {} - } + \file{ctexspa.def} {\from{\jobname.dtx}{ctexspa} + \from{ctexpunct.spa}{}} \usedir{tex/generic/ctex} \file{ctexmakespa.tex} {\from{\jobname.dtx}{spa,make}} \file{ctexspamacro.tex} {\from{\jobname.dtx}{spa,macro}} \file{zhadobefonts.tex} {\from{\jobname.dtx}{zhmap,adobe}} \file{zhfandolfonts.tex} {\from{\jobname.dtx}{zhmap,fandol}} \file{zhfounderfonts.tex} {\from{\jobname.dtx}{zhmap,founder}} + \file{zhmacfonts.tex} {\from{\jobname.dtx}{zhmap,mac}} \file{zhubuntufonts.tex} {\from{\jobname.dtx}{zhmap,ubuntu}} \file{zhwindowsfonts.tex} {\from{\jobname.dtx}{zhmap,windows}} - \file{ctxdocstrip.tex} {\from{\jobname.dtx}{docstrip}} % %<*internal> \usedir{source/latex/ctex} @@ -366,16 +365,15 @@ Copyright and Licence \Msg{* ctexbook.cls *} \Msg{* ctexrep.cls *} \Msg{* ctexbeamer.cls *} -\Msg{* ctxdoc.cls *} \Msg{* ctexcap.sty *} \Msg{* ctexhook.sty *} \Msg{* ctexpatch.sty *} \Msg{* ctex-c5size.clo *} \Msg{* ctex-cs4size.clo *} -\Msg{* ctex-article.def *} -\Msg{* ctex-book.def *} -\Msg{* ctex-report.def *} -\Msg{* ctex-beamer.def *} +\Msg{* ctex-heading-article.def *} +\Msg{* ctex-heading-book.def *} +\Msg{* ctex-heading-report.def *} +\Msg{* ctex-heading-beamer.def *} \Msg{* ctex-scheme-plain.def *} \Msg{* ctex-scheme-plain-article.def *} \Msg{* ctex-scheme-plain-book.def *} @@ -390,6 +388,7 @@ Copyright and Licence \Msg{* ctex-name-utf8.cfg *} \Msg{* ctex.cfg *} \Msg{* ctexopts.cfg *} +\Msg{* ctexbackend.cfg *} \Msg{* ctex-engine-pdftex.def *} \Msg{* ctex-engine-xetex.def *} \Msg{* ctex-engine-luatex.def *} @@ -407,23 +406,21 @@ Copyright and Licence \Msg{* jt2zhrm.fd *} \Msg{* jt2zhsf.fd *} \Msg{* jt2zhtt.fd *} -\Msg{* ctex-fontset-windows.def *} -\Msg{* ctex-fontset-windowsnew.def *} -\Msg{* ctex-fontset-windowsold.def *} \Msg{* ctex-fontset-adobe.def *} \Msg{* ctex-fontset-fandol.def *} +\Msg{* ctex-fontset-founder.def *} \Msg{* ctex-fontset-mac.def *} -\Msg{* ctex-fontset-macold.def *} \Msg{* ctex-fontset-macnew.def *} -\Msg{* ctex-fontset-founder.def *} +\Msg{* ctex-fontset-macold.def *} \Msg{* ctex-fontset-ubuntu.def *} +\Msg{* ctex-fontset-windows.def *} \Msg{* ctexspa.def *} \Msg{* ctexmakespa.tex *} \Msg{* ctexspamacro.tex *} -\Msg{* ctxdocstrip.tex *} \Msg{* zhadobefonts.tex *} \Msg{* zhfandolfonts.tex *} \Msg{* zhfounderfonts.tex *} +\Msg{* zhmacfonts.tex *} \Msg{* zhubuntufonts.tex *} \Msg{* zhwindowsfonts.tex *} \Msg{* translator-theorem-dictionary-ChineseGBK.dict *} @@ -442,12 +439,11 @@ Copyright and Licence \fi % %<*!(driver|readme|install|zhmap|spa|docstrip)> -%<*!(fd|ctexspa|dict)> -%\NeedsTeXFormat{LaTeX2e} -%\RequirePackage{expl3} -%<+!driver>\GetIdInfo$Id: ctex.dtx 735dfe2 2019-05-29 21:42:29 +0800 Qing Lee $ -% {ctex documentation (CTEX)} -%\ProvidesExplClass{ctxdoc} +%<*!(fd|ctexspa|dict|backend)> +%\NeedsTeXFormat{LaTeX2e} +%\input{ctexbackend.cfg} +%\RequirePackage{expl3} +%<+!driver>\GetIdInfo$Id: ctex.dtx d2534e9 2020-05-01 21:11:07 +0800 Qing Lee $ % {Chinese adapter in LaTeX (CTEX)} %\ProvidesExplPackage{\ExplFileName} % {Chinese font size definition (CTEX)} @@ -502,7 +498,7 @@ Copyright and Licence %\ProvidesExplFile{ctex-scheme-chinese-beamer.def} % {Caption with encoding GBK (CTEX)} %\ProvidesExplFile{ctex-name-gbk.cfg} -% {Caption with encoding UTF8 (CTEX)} +% {Caption with encoding UTF-8 (CTEX)} %\ProvidesExplFile{ctex-name-utf8.cfg} % {Configuration file (CTEX)} %\ProvidesExplFile{\ExplFileName.cfg} @@ -520,26 +516,22 @@ Copyright and Licence %\ProvidesExplFile{ctex-engine-uptex.def} % {Windows fonts definition (CTEX)} %\ProvidesExplFile{ctex-fontset-windows.def} -% {Windows fonts definition for Vista or later version (CTEX)} -%\ProvidesExplFile{ctex-fontset-windowsnew.def} -% {Windows fonts definition for XP or earlier version (CTEX)} -%\ProvidesExplFile{ctex-fontset-windowsold.def} % {Adobe fonts definition (CTEX)} %\ProvidesExplFile{ctex-fontset-adobe.def} % {Fandol fonts definition (CTEX)} %\ProvidesExplFile{ctex-fontset-fandol.def} -% {Mac OS X fonts definition (CTEX)} +% {macOS fonts definition (CTEX)} %\ProvidesExplFile{ctex-fontset-mac.def} -% {Mac OS X fonts definition for El Capitan or later version (CTEX)} +% {macOS fonts definition for El Capitan or later version (CTEX)} %\ProvidesExplFile{ctex-fontset-macnew.def} -% {Mac OS X fonts definition for Yosemite or earlier version (CTEX)} +% {macOS fonts definition for Yosemite or earlier version (CTEX)} %\ProvidesExplFile{ctex-fontset-macold.def} % {Founder fonts definition (CTEX)} %\ProvidesExplFile{ctex-fontset-founder.def} % {Ubuntu fonts definition (CTEX)} %\ProvidesExplFile{ctex-fontset-ubuntu.def} -% {\ExplFileDate}{2.4.16}{\ExplFileDescription} -% +% {\ExplFileDate}{2.5}{\ExplFileDescription} +% %\ProvidesFile{c19rm.fd}% %\ProvidesFile{c19sf.fd}% %\ProvidesFile{c19tt.fd}% @@ -553,11 +545,13 @@ Copyright and Licence %\ProvidesFile{jt2zhsf.fd}% %\ProvidesFile{jt2zhtt.fd}% %\ProvidesFile{ctexspa.def}% +%\ProvidesFile{ctexbackend.cfg}% %\ProvidesDictionary{translator-theorem-dictionary}{ChineseGBK}% %\ProvidesDictionary{translator-theorem-dictionary}{ChineseUTF8}% -% [2019/05/29 v2.4.16 Chinese font definition (CTEX)] -% [2019/05/29 v2.4.16 Space info for CJKpunct (CTEX)] -% [2019/05/29 v2.4.16 Chinese translation for theorem name (CTEX)] +% [2020/05/01 v2.5 Chinese font definition (CTEX)] +% [2020/05/01 v2.5 Space info for CJKpunct (CTEX)] +% [2020/05/01 v2.5 Backend configuration file (CTEX)] +% [2020/05/01 v2.5 Chinese translation for theorem name (CTEX)] % %<*driver> \documentclass{ctxdoc} @@ -580,8 +574,7 @@ Copyright and Licence % \changes{v2.4.12}{2018/01/13}{同步 \LaTeXiii{} 2017/12/16。} % \changes{v2.4.15}{2019/03/23}{同步 \LaTeXiii{} 2019/03/05。} % -% -% \CheckSum{5934} +% \CheckSum{6105} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -599,7 +592,7 @@ Copyright and Licence % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % -% \GetFileId{ctex.sty}% +% \GetFileId{ctex.sty} % % \title{\bfseries \CTeX{} 宏集手册} % \author{\href{http://www.ctex.org}{CTEX.ORG}} @@ -612,13 +605,13 @@ Copyright and Licence % 日期转换等支持功能,可适应论文、报告、书籍、幻灯片等不同类型的中文文档。 % % \CTeX{} 宏集支持 \LaTeX、\pdfLaTeX、\XeLaTeX、\LuaLaTeX、\upLaTeX{} 等多种不同 -% 的编译方式,并为它们提供了统一的界面。主要功能由宏包 \pkg{ctex} 和中文文档类 +% 的编译方式,并为它们提供了统一的界面。主要功能由宏包 \pkg{ctex} 以及中文文档类 % \cls{ctexart}、\cls{ctexrep}、\cls{ctexbook} 和 \cls{ctexbeamer} 实现。 % \end{abstract} % % \tableofcontents % -% \clearpage +% \bigskip % \setlength{\parskip}{0.8ex} % % \begin{documentation} @@ -629,14 +622,14 @@ Copyright and Licence % % \CTeX{} 宏集的源头有两个:一是王磊编写的 \cls{cjkbook} 文档类,二是吴凌云编写的 % \file{GB.cap}。 -% 这些工作没有经过认真、系统的设计,也没有用户文档,不利于维护和改进。 +% 这些工作没有经过认真系统的设计,也没有用户文档,不利于维护和改进。 % % 2003 年,吴凌云使用 \pkg{doc} 和 \pkg{DocStrip} 重构了整个工程,并增加了许多新的功能, % 称为 \pkg{ctex} 宏包。2007 年,oseen 和王越在 \pkg{ctex} 宏包的基础上, % 增加了对 UTF-8 编码的支持,开发出了 \pkg{ctexutf8} 宏包。 % % 2009 年 5 月,我们在 Google Code 建立了 ctex-kit 项目^^A -% \footnote{\nolinkurl{http://code.google.com/p/ctex-kit/}}, +% \footnote{\nolinkurl{http://code.google.com/p/ctex-kit/},该链接现已失效。}, % 对 \pkg{ctex} 宏包及相关脚本进行了整合,并加入了对 \XeTeX{} 引擎的支持。 % 在开发新版本时,考虑到合作开发和调试的方便,我们放弃了 \pkg{doc} 和 \pkg{DocStrip}, % 采取了直接编写宏包代码的方式。 @@ -649,11 +642,11 @@ Copyright and Licence % \href{https://github.com/CTeX-org/ctex-kit}{GitHub}^^A % \footnote{\url{https://github.com/CTeX-org/ctex-kit}}。 % -% 最初,Knuth 在设计开发 \TeX{} 的时候没有考虑到多国语言支持,特别是对多字节的中日韩 -% 语言的支持。这使得 \TeX{} 以至后来的 \LaTeX{} 对中文的支持一直不是很好。即使在 +% 最初,Knuth 在设计开发 \TeX{} 的时候没有考虑到多国文字支持,特别是对多字节的中日韩 +% 表意文字的支持。这使得 \TeX{} 以至后来的 \LaTeX{} 对中文的支持一直不是很好。即使在 % \pkg{CJK} 宏包解决了中文字符处理的问题以后,中文用户使用 \LaTeX{} 仍然要面对许 % 多困难。 -% 这些困难里,以章节标题的中文化为最。由于中文和西文语言习惯的差异,用户很难使用标准 +% 这些困难里,以章节标题的中文化为最。由于中文和西文书写习惯的差异,用户很难使用标准 % 文档类中的代码结构来表达中文标题。于是,用户不得不对标准文档类做较大的修改。 % 除此之外,日期格式、首行缩进、中文字号和字距等细节问题,也需要精细的调校。 % 我们设计 \CTeX{} 宏集的目的之一就是解决这些 \LaTeX{} 文档的汉化难题。 @@ -661,23 +654,24 @@ Copyright and Licence % 另一方面,随着 \TeX{} 引擎和 \LaTeX{} 宏包的不断发展,\LaTeX{} 的中文支持方式从早期的 % 专用系统(如 \pkg{CCT})发展为适用于不同引擎的多种方式^^A % \footnote{比如:\pdfTeX{} 引擎下的 \pkg{CJK}、\pkg{zhmCJK}宏包, -% \XeTeX{} 引擎下的 \pkg{xeCJK} 宏包和 \LuaTeX{} 引擎下的 \pkg{LuaTeX-ja} 宏 -% 包}。这些方式的适用情况和使用方式有不少细节上的差异,同时操作系统的不同、语言环境的不同等 +% \XeTeX{} 引擎下的 \pkg{xeCJK} 宏包和 \LuaTeX{} 引擎下的 \pkg{LuaTeX-ja} 宏包。}。 +% 这些方式的适用情况和使用方式有不少细节上的差异,同时操作系统的不同、语言环境的不同等 % 客观情况又进一步带来了更多的细节差异。我们设计 \CTeX{} 宏集的另一个主要目的就是 % 尽可能消除这些差异带来的影响,使用户能够以一个统一的接口来使用不同的中文支持方式, % 使得同一份文档能够在不同环境下交换使用。 % -% \CTeX{} 宏集的许多实现细节离不开热心朋友们在 \url{bbs.ctex.org} 论坛上的讨论, -% 在此对参与讨论的朋友们表示感谢。 +% \CTeX{} 宏集的许多实现细节离不开热心朋友们在 \nolinkurl{bbs.ctex.org} 论坛^^A +% \footnote{2018 年,\CTeX{} 论坛因故无限期关闭,此链接现已失效。}^^A +% 上的讨论,在此对参与讨论的朋友们表示感谢。 % % \subsection*{关于宏集名字的说明} % % \CTeX{} 之名是英文单词 China(中国)或 Chinese(中文)的首字母“C”与 “\TeX{}” % 结合而成的。在纯文本环境下,该名字应写作“CTeX”。 % -% \CTeX{} 宏集是由 \href{http://bbs.ctex.org}{\CTeX{} 社区} 发起并维护的 +% \CTeX{} 宏集是由 \href{https://github.com/CTeX-org}{\CTeX{} 社区}发起并维护的 % \LaTeX{} \emph{宏包和文档类的集合}。 -% 社区另有发布名为 \href{http://www.ctex.org/CTeX}{\CTeX{} 套装} +% 社区另有发布名为 \href{http://www.ctex.org/CTeX}{\CTeX{} 套装}^^A % 的 \TeX{} 发行版,与本文档所述的 \CTeX{} 宏集并非是同一事物。 % % \pkg{ctex} 则是本宏集中的 \pkg{ctex.sty} 的名字。这一完全小写的名称,在过去 @@ -688,7 +682,7 @@ Copyright and Licence % % \subsection{\CTeX{} 宏集的组成} % -% 为了适应用户不同的需求,我们将 \CTeX{} 宏集的主要功能分散在四个中文文档类和 +% 为了适应用户不同的需求,我们将 \CTeX{} 宏集的主要功能设计安排在四个中文文档类和 % 三个宏包当中,具体的组成见表~\ref{tab:ctex}。 % % \begin{table}[htbp] @@ -698,21 +692,21 @@ Copyright and Licence % \toprule % 类别 & 文件 & 说明 \\ % \midrule -% 文档类 & \file{ctexart.cls} & 标准文档类 \cls{article} 的汉化版本,一般适用于 -% 短篇幅的文章 \\ -% & \file{ctexrep.cls} & 标准文档类 \cls{report} 的汉化版本,一般适用于 -% 中篇幅的报告 \\ -% & \file{ctexbook.cls} & 标准文档类 \cls{book} 的汉化版本,一般适用于 -% 长篇幅的书籍 \\ -% & \file{ctexbeamer.cls} & 文档类 \cls{beamer} 的汉化版本,适用于 -% 幻灯片演示 \\ +% 文档类 & \file{ctexart.cls} & 标准文档类 \cls{article} 的汉化版本, +% 一般适用于短篇幅的文章 \\ +% & \file{ctexrep.cls} & 标准文档类 \cls{report} 的汉化版本, +% 一般适用于中篇幅的报告 \\ +% & \file{ctexbook.cls} & 标准文档类 \cls{book} 的汉化版本, +% 一般适用于长篇幅的书籍 \\ +% & \file{ctexbeamer.cls} & 文档类 \cls{beamer} 的汉化版本, +% 适用于幻灯片演示 \\ % \midrule -% 宏包 & \file{ctex.sty} & 提供全部功能,但\emph{默认不开启章节标题设置功能}, -% 需要使用 \opt{heading} 选项来开启 \\ -% & \file{ctexsize.sty} & 定义和调整中文字号,在 \pkg{ctex} 宏包 -% 或 \CTeX{} 中文文档类之外单独调用 \\ +% 宏包 & \file{ctex.sty} & 提供全部功能,但\emph{默认不开启章节标题设置功能}, +% 需要使用 \opt{heading} 选项来开启 \\ +% & \file{ctexsize.sty} & 定义和调整中文字号,可以在 \pkg{ctex} 宏包 +% 或 \CTeX{} 中文文档类之外单独调用 \\ % & \file{ctexheading.sty} & 提供章节标题设置功能(见 \ref{sec:secstyle} -% 节),在 \pkg{ctex} 宏包或 \CTeX{} 中文 +% 节),可以在 \pkg{ctex} 宏包或 \CTeX{} 中文 % 文档类之外单独调用 \\ % \bottomrule % \end{tabularx} @@ -720,37 +714,42 @@ Copyright and Licence % % \subsection{\CTeX{} 宏集的安装和更新} % \label{subsec:easy-ins} -% -% \CTeX{} 宏集依赖的宏包和宏集已被最常见的 \TeX{} 发行版 \TeXLive{} 和 \MiKTeX{} -% 所收录。如果本地安装 \TeXLive{} 或 \MiKTeX{} 不是完全版本,就可能需要通过这 -% 两个发行版提供的\emph{宏包管理器}来安装宏包。 -% -% \TeXLive{} 的宏包管理器是 tlmgr。用户可以在系统命令行中^^A -% \footnote{Windows 系统的命令行是 CMD 命令提示符,你可以使用 Win + R 组合键^^A -% 打开“运行”对话框,然后输入 cmd 确认打开命令提示符窗口。}^^A -% 执行 +% 最常见的 \TeX{} 发行版(\TeXLive{} 和 \MiKTeX{})已收录 \CTeX{} 宏集及其依赖的宏包和宏集。 +% \footnote{\pkg{zhmCJK} 宏包是个例外。当用户显式指定选项 \opt{zhmap = zhmCJK} 时,^^A +% \CTeX{} 宏集依赖它。由于,它没有被 \TeXLive{} 和 \MiKTeX{} 收录,用户可能需要遵照其说明文档 +% 自行安装。}如果本地安装 \TeXLive{} 或 \MiKTeX{} 不是完整版本,则可能需要通过这 +% 两个发行版提供的\emph{包管理器}来安装宏包。 +% +% \TeXLive{} 的包管理器是 tlmgr(\TeXLive{} Manager)。用户可以在系统命令行中^^A +% \footnote{Windows 系统的命令行是 CMD 命令提示符,你可以使用 Win + R 组合键 +% 打开“运行”对话框,然后输入 cmd 确认打开命令提示符窗口。}执行 % \begin{frameverb} % tlmgr gui % \end{frameverb} -% 启动管理器的图形界面(Windows 用户也可以通过开始菜单的 -% TeX Live 2015 \ding{212} TeX Live Manager 打开)。 -% 连接上远程仓库之后,搜索 ctex 安装即可。 -% tlmgr 的图形界面使用 Perl 编写,容易造成系统假死。遇到这种问题的用户, +% 启动管理器的图形界面(Windows 用户也可以通过开始菜单的 TeX Live 20XX(年份) +% \ding{212} TeX Live Manager 打开)。连接上远程仓库之后,搜索 |ctex| 即可安装。 +% tlmgr 的图形界面使用 Perl 编写,在实践中发现容易造成系统假死。遇到这种问题的用户, % 也可以直接在系统命令行执行 % \begin{frameverb} % tlmgr install ctex % \end{frameverb} -% 来安装 \CTeX{} 宏集\footnote{*nix 用户可能需要超级用户权限才能正确安装宏集。}。 +% 来安装 \CTeX{} 宏集^^A +% \footnote{*nix 用户可能需要超级用户权限(sudo)才能正确安装宏集。}。 % -% \MiKTeX{} 的宏包管理器是 mpm (\MiKTeX{} Package Manager)。用户可以在开始菜单 -% 找到 MiKTeX \ding{212} Maintenance (Admin) \ding{212} Package Manager (Admin), -% 打开管理器,连接上远程仓库之后,搜索 ctex 安装即可。 +% \MiKTeX{} 通常会在缺失宏包时自动完成安装。如需手动安装,可以使用其管理维护 +% 工具 \MiKTeX{} Console。用户可以打开管理器,连接上远程仓库之后,在“Package” +% 选项卡中搜索“ctex”并安装即可。 +% 也可以使用 mpm(\MiKTeX{} Package Manager),在命令行执行 +% \begin{frameverb} +% mpm --admin --install=ctex +% \end{frameverb} +% 来安装 \CTeX{} 宏集。 % -% 若希望了解 \CTeX{} 宏集具体的依赖情况和手工安装宏集的方法, +% 若希望了解 \CTeX{} 宏集具体的依赖情况或手工安装宏集的方法, % 请参阅第 \ref{sec:dep-ins}~节。 % -% 当宏包发布新版本,并被发行版在远程仓库安装之后,在本地就可以通过宏包管理器来 -% 取得新版本。 +% 当我们将宏集的新版本发布于 CTAN,且为发行版的远程仓库更新后,用户就可以在本地 +% 通过包管理器获取新版本。 % % 对于 \TeXLive{},可以在 tlmgr 的图形界面点击“更新全部已安装的”按钮或者在 % 命令行执行 @@ -759,14 +758,17 @@ Copyright and Licence % \end{frameverb} % 来完整更新已安装的宏包。 % -% 对于 \MiKTeX{},在开始菜单找到 -% MiKTeX \ding{212} Maintenance (Admin) \ding{212} Update (Admin), -% 按照界面说明更新即可。 +% 对于 \MiKTeX{},在 \MiKTeX{} Console 中找到“Updates”选项卡,检查更新后即可 +% 选择升级宏包。也可以使用 mpm,在命令行执行 +% \begin{frameverb} +% mpm --admin --update +% \end{frameverb} +% 来进行更新。 % % \subsection{使用 \CTeX{} 文档类} % -% \emph{如果用户需要在标准文档类的基础上添加中文支持和中文版式支持,我们建议用户使用 \CTeX{} -% 宏集提供的四个中文文档类。} +% \emph{如果用户需要在三个标准文档类或 \cls{beamer} 的基础上添加中文及版式的支持, +% 我们建议用户使用 \CTeX{} 宏集提供的四个中文文档类。} % % \CTeX{} 宏集提供了四个中文文档类:\cls{ctexart}、\cls{ctexrep}、\cls{ctexbook} 和 % \cls{ctexbeamer},分别对应 \LaTeX{} 的标准文档类 \cls{article}、\cls{report}、 @@ -775,18 +777,18 @@ Copyright and Licence % \ref{subs:encoding}~节)}。 % % \begin{ctexexam} -% \documentclass[UTF8]{ctexart} +% \documentclass{ctexart} % \begin{document} % 中文文档类测试。你需要将所有源文件保存为 UTF-8 编码。 % % 你可以使用 XeLaTeX、LuaLaTeX 或 upLaTeX 编译,也可以使用 (pdf)LaTeX 编译。 -% 推荐使用 XeLaTeX 或 LuaLaTeX 编译。 +% 推荐使用 XeLaTeX 或 LuaLaTeX 编译。对高级用户,我们也推荐使用 upLaTeX 编译。 % \end{document} % \end{ctexexam} % % 以下是使用 \cls{ctexbeamer} 文档类编写中文演示文稿的一个示例。 % \begin{ctexexam} -% \documentclass[UTF8]{ctexbeamer} +% \documentclass{ctexbeamer} % \begin{document} % \begin{frame}{中文演示文档} % \begin{itemize} @@ -794,6 +796,7 @@ Copyright and Licence % \item 你可以使用 XeLaTeX、LuaLaTeX 或 upLaTeX 编译 % \item 也可以使用 (pdf)LaTeX 编译 % \item 推荐使用 XeLaTeX 或 LuaLaTeX 编译 +% \item 对高级用户,我们也推荐使用 upLaTeX 编译 % \end{itemize} % \end{frame} % \end{document} @@ -801,14 +804,14 @@ Copyright and Licence % % \subsection{使用 \pkg{ctex} 宏包} % -% \emph{用户在使用非标准文档类时,如果需要添加中文支持或中文版式支持,则可以使用 \pkg{ctex} -% 宏包。} +% \emph{用户在使用非标准文档类及 \cls{beamer} 时,如果需要添加中文及版式的支持, +% 则可以使用 \pkg{ctex} 宏包。} % -% 有些文档类是建立在 \LaTeX{} 标准文档类之上开发的。这时,给 \pkg{ctex} 宏包 +% 对于建立在 \LaTeX{} 标准文档类之上开发的文档类,在使用 \pkg{ctex} 宏包时 % 加上 \opt{heading} 选项,可以将章节标题设置为中文风格。 % \begin{ctexexam} % \documentclass{ltxdoc} -% \usepackage[UTF8, heading = true]{ctex} +% \usepackage[heading = true]{ctex} % \begin{document} % \section{简介} % 章节标题中文化的 \LaTeX{} 手册。 @@ -820,16 +823,13 @@ Copyright and Licence % % \CTeX{} 宏集已经尽可能就中文的行文和版式习惯做了调整和配置,通常而言,这些配置 % 已经够用。因此,除非必要,我们不建议普通用户修改这些默认配置。如果你认为 \CTeX{} 宏集 -% 的默认配置还可以完善,可以在项目主页上% +% 的默认配置还可以完善,可以在项目主页上^^A % \href{https://github.com/CTeX-org/ctex-kit/issues}{提交 issue}, % 向我们反映,我们会酌情在后续版本中予以改进。 % % 不过,\CTeX{} 宏集也提供了一系列选项。用户可以使用这些选项来控制 \CTeX{} 宏集的行为。 -% 具体来说,这些选项里,有的以传统的方式提供, -% 也有的以 \meta{key}|=|\meta{value} 的形式提供。对于以键值对形式提供的选项, -% 在下面的说明中使用\textbf{粗体}来表示 \CTeX{} 的默认设置。 -% -% 另一方面,这些选项可以分为以下三类: +% 按形式分类,这些选项有的以传统的方式提供,有的以 \meta{key}|=|\meta{value} 的形式提供。 +% 按指定位置分类,这些选项又可以分为以下三类: % \begin{itemize} % \item 名字后带有 \rexptarget\rexpstar{} 号的选项,只能作为宏包/文档类选项,需要 % 在引入宏包/文档类的时候指定; @@ -891,28 +891,24 @@ Copyright and Licence % \end{table} % % 不同的编译方式和中文支持方式会在一定程度上影响 \CTeX{} 宏集的行为,比如宏包对 -% 编码的处理。 -% 在用户使用 \XeLaTeX、\LuaLaTeX{} 及 \upLaTeX{} 编译时,\CTeX{} 宏集使用(且仅 -% 能使用)UTF-8 编码;而因为历史原因,在用户使用 \LaTeX{} 及 \pdfLaTeX{} 编译 -% 时,宏包默认使用 GBK 编码。用户需要\emph{保证编译方式、 -% 源文件编码、宏包编码选项三者一致}。 -% 关于宏包编码选项,可以参考 \ref{subs:encoding}~节。 -% -% 除去文档编码之外,选择不同的编译方式还可能影响 \CTeX{} 宏集对字体选择、空格处理、 -% 标点处理的处理。具体的影响将在本文档后续内容中进行阐述。 +% 文档编码、字体选择、空格、标点等的处理。具体细节将在本文档后续内容中进行阐述。 % % \subsection{中文编码} % \label{subs:encoding} % -% \begin{function}[rEXP]{GBK, UTF8} -% 指明编写文档时使用的编码格式。\CTeX{} 宏集无法检测用户编写文档时使用的编码格式,因此 -% 需要用户自行指定编码。\emph{我们建议用户总是使用 UTF-8 编码,并显式指定 \opt{UTF8} -% 选项,并使用 \XeLaTeX、\LuaLaTeX{} 或 \upLaTeX{} 编译。} +% \begin{function}[rEXP,updated=2019-11-10]{GBK, UTF8} +% 指明编写文档时使用的编码。\CTeX{} 宏集无法检测文档源文件的实际编码格式,因此需要 +% 用户通过选项声明。如果没有显式指定,则默认采用 UTF-8 编码。 % -% 使用 \XeLaTeX、\LuaLaTeX{} 或 \upLaTeX{} 编译时,\CTeX{} 宏集强制使用 UTF-8 -% 编码,此时 \opt{GBK} 选项无效。 -% 使用 (pdf)\LaTeX{} 编译时,\CTeX{} 宏集默认启用 \opt{GBK} 选项;不过,用户也可以 -% 显式声明 \opt{UTF8} 选项,使 \CTeX{} 宏集工作在 UTF-8 编码下。 +% 使用 \XeLaTeX{}、\LuaLaTeX{} 或 \upLaTeX{} 编译时,\CTeX{} 宏集强制使用 +% UTF-8 编码,此时 \opt{GBK} 选项无效;使用 (pdf)\LaTeX{} 编译时, +% \CTeX{} 宏集默认使用 UTF-8 编码,但用户也可以显式声明 \opt{GBK} 选项, +% 使 \CTeX{} 宏集按 GBK 编码处理文档。 +% +% 用户需要\emph{保证编译方式、源文件编码、宏包编码选项三者一致}。 +% +% \emph{我们建议编写新文档时始终使用 UTF-8 编码,而仅把 GBK 编码留给 +% 历史遗留文档。} % \end{function} % % \subsection{中文字库} @@ -920,9 +916,9 @@ Copyright and Licence % % 以往,为 \LaTeX{} 文档配置中文支持是一件相当繁琐的事情。默认情况下, % \CTeX{} 宏集能自动检测用户使用的编译方式(参见 \ref{subs:compile}~节)和 -% 操作系统\footnote{\CTeX{} 宏集现在能够识别 Mac~OS~X 系统以及 Windows 系统。}, -% 选择合适的底层支持和字库,从而简化配置过程。自动配置的情况参见 -% 表~\ref{tab:default-font-select}。 +% 操作系统\footnote{\CTeX{} 宏集现在能够识别 macOS 及 Windows 系统, +% 并将其他系统统一归为 Linux。},选择合适的底层支持和字库,从而简化配置过程。 +% 自动配置的情况参见表~\ref{tab:default-font-select}。 % % \begin{table}[htbp] % \centering @@ -931,42 +927,50 @@ Copyright and Licence % \label{tab:default-font-select} % \begin{tabular}{*{5}{c}} % \toprule -% & Mac OS X & Windows New\tnote{1} & Windows Old\tnote{2} & -% 其他 \\ +% & macOS Old\tnote{1} +% & macOS New\tnote{2} +% & Windows\tnote{3} +% & 其他 \\ % \midrule -% \XeLaTeX{} & \makecell{\pkg{xeCJK}\\华文字库} & -% \makecell{\pkg{xeCJK}\\中易字库 + 微软雅黑} & \makecell{\pkg{xeCJK}\\中易字库} & -% \makecell{\pkg{xeCJK}\\Fandol 字库\tnote{3}} \\ +% \XeLaTeX & \makecell{\pkg{xeCJK}\\华文字库} +% & \makecell{\pkg{xeCJK}\\华文字库 + 苹方} +% & \makecell{\pkg{xeCJK}\\中易字库 + 微软雅黑} +% & \makecell{\pkg{xeCJK}\\Fandol 字库\tnote{4}} \\ % \cmidrule(lr){1-5} -% \LuaLaTeX{}\tnote{4} & \makecell{\pkg{LuaTeX-ja}\\华文字库} & -% \makecell{\pkg{LuaTeX-ja}\\中易字库 + 微软雅黑} & -% \makecell{\pkg{LuaTeX-ja}\\中易字库} & -% \makecell{\pkg{LuaTeX-ja}\\Fandol 字库} \\ +% \LuaLaTeX\tnote{5} +% & \makecell{\pkg{LuaTeX-ja}\\华文字库} +% & \makecell{\pkg{LuaTeX-ja}\\华文字库 + 苹方} +% & \makecell{\pkg{LuaTeX-ja}\\中易字库 + 微软雅黑} +% & \makecell{\pkg{LuaTeX-ja}\\Fandol 字库} \\ % \cmidrule(lr){1-5} -% \pdfLaTeX{} & 不可用\tnote{5} & -% \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑} & -% \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库} & 不可用\tnote{5} \\ +% \pdfLaTeX +% & 不可用 +% & 不可用 +% & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑\tnote{6}} +% & 不可用 \\ % \cmidrule(lr){1-5} -% \makecell{\LaTeX{} + \\\dvipdfmx{}} & 不可用\tnote{6} & -% \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑} & -% \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库} & -% \makecell{\pkg{CJK} + \pkg{zhmetrics}\\Fandol 字库} \\ +% \makecell{\LaTeX{} + \\\dvipdfmx} +% & 不可用 +% & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\华文字库 + 苹方} +% & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\中易字库 + 微软雅黑\tnote{6}} +% & \makecell{\pkg{CJK} + \pkg{zhmetrics}\\Fandol 字库} \\ % \cmidrule(lr){1-5} -% \makecell{\upLaTeX{} + \\\dvipdfmx{}} & 不可用\tnote{6} & -% \makecell{\pkg{zhmetrics-uptex}\\中易字库 + 微软雅黑} & -% \makecell{\pkg{zhmetrics-uptex}\\中易字库} & -% \makecell{\pkg{zhmetrics-uptex}\\Fandol 字库} \\ +% \makecell{\upLaTeX{} + \\\dvipdfmx} +% & 不可用 +% & \makecell{\pkg{zhmetrics-uptex}\\华文字库 + 苹方} +% & \makecell{\pkg{zhmetrics-uptex}\\中易字库 + 微软雅黑} +% & \makecell{\pkg{zhmetrics-uptex}\\Fandol 字库} \\ % \bottomrule % \end{tabular} % \begin{tablenotes} -% \item [1] Windows Vista 及以后的 Windows 操作系统。 -% \item [2] Windows XP 及以前的 Windows 操作系统。 -% \item [3] 由马起园、苏杰、黄晨成等人开发的开源中文字体, -% 参见:\url{https://github.com/clerkma/fandol-fonts}。 -% \item [4] \LuaLaTeX{} 编译时使用 \pkg{LuaTeX-ja} 宏包。对此, +% \item [1] Yosemite (10.10) 及以前的 macOS 系统。 +% \item [2] El Capitan (10.11) 及以后的 macOS 系统。 +% \item [3] 仅支持 Windows Vista 及以后的 Windows 操作系统。 +% \item [4] 由马起园、苏杰、黄晨成等人开发的开源中文字体, +% 参见:\url{https://www.ctan.org/pkg/fandol}。 +% \item [5] \LuaLaTeX{} 编译时使用 \pkg{LuaTeX-ja} 宏包。对此, % 第 \ref{sec:lualatex-chinese}~节有特别说明。 -% \item [5] 受 \pdfTeX{} 的限制,无法嵌入 OpenType 字体。 -% \item [6] 目前受 \dvipdfmx{} 的限制,Mac OS X 系统上的黑体和仿宋无法读取。 +% \item [6] 微软雅黑字体并不总是有效,这和选项 \opt{zhmap} 的取值有关。 % \end{tablenotes} % \end{threeparttable} % \end{table} @@ -980,14 +984,20 @@ Copyright and Licence % \begin{syntax} % zhmap = <\TTF|zhmCJK> % \end{syntax} -% 指定字体映射机制。本选项只在使用 \pdfLaTeX/\LaTeX{} 编译时有意义。 +% 指定字体映射机制。本选项只在使用 (pdf)\LaTeX{} 编译时有意义。 % \end{function} % \begin{optdesc} -% \item[true] 使用 \pkg{zhmetrics} 宏包,将 CJK 字库通过 \tn{special} +% \item[true] 这是该选项的默认值。^^A +% \footnote{对于以键值对形式提供的选项,文档以\textbf{粗体}来表示其默认值。^^A +% 下同,不再额外解释。}使用 \pkg{zhmetrics} 宏包,将 CJK 字库通过 \tn{special} % 命令映射到 \file{.ttf} 文件。 % % \item[false] 使用传统的 CJK 字库(Type 1)^^A -% \footnote{如果需要使用自定义的字体映射文件,或者希望使用 Type1 字库,请禁用本选项。}。 +% \footnote{使用 (pdf)\LaTeX{} 编译时,如果需要使用自定义的字体映射文件(比如需要 +% 使用 \LaTeX{} + Dvips 编译),或者希望使用 Type1 字库,请禁用本选项。为此,你 +% 可能需要安装 CJK 字体。参考 \pkg{zhmetrics} 宏包提供的脚本 +% \href{https://github.com/CTeX-org/ctex-kit/blob/master/zhmetrics/CTeXFonts.lua} +% {\file{CTeXFonts.lua}}。}。 % % \item[zhmCJK] 载入 \pkg{zhmCJK} 宏包^^A % \footnote{\pkg{zhmCJK} 宏包基于 \pkg{zhmetrics} 和 \pkg{CJK} 宏包,提供与 @@ -997,8 +1007,7 @@ Copyright and Licence % % \begin{function}[added=2014-03-08]{fontset} % \begin{syntax} -% fontset =^^A -% +% fontset = % \end{syntax} % 指定 \CTeX{} 宏集加载的字库。 % @@ -1012,24 +1021,18 @@ Copyright and Licence % \item[adobe] 使用 Adobe 公司的四款中文字体,\emph{不支持 \pdfLaTeX}。 % \item[fandol] 使用 Fandol 中文字体,\emph{不支持 \pdfLaTeX}。 % \item[founder] 使用方正公司的中文字体。 -% \item[mac] 使用 Mac OS X 系统下的字体,\emph{不支持 (pdf)\LaTeX}。 -% \item[macnew] 使用 El Capitan 或之后的多字重宋体、苹方黑体。 -% \item[macold] 使用 Yosemite 或之前的华文字库。 -% \item[ubuntu] 使用 Ubuntu 系统下的文泉驿和文鼎字体。 -% \item[windows] 使用简体中文 Windows 系统下的中文字体,自动判断 Windows 系 -% 统版本,采用 |windowsnew| 或 |windowsold| 的设置。 -% \item[windowsnew] 使用简体中文 Windows Vista 或之后系统下的中易字体和微软 -% 雅黑字体。 -% \item[windowsold] 使用简体中文 Windows XP 或之前系统下的中易字体。 +% \item[mac] 使用 macOS 系统下的字体,\emph{不支持 \pdfLaTeX},根据版本分为 +% |macnew| 和 |macold| 两种。 +% \item[macnew] 使用 El Capitan 或之后的多字重华文字体和苹方字体。 +% \item[macold] 使用 Yosemite 或之前的华文字体。 +% \item[ubuntu] 使用 Ubuntu 系统下的思源宋体、思源黑体和 \TeX{} 发行版自带的 +% 文鼎楷体,\emph{不支持 \pdfLaTeX}。 +% \item[windows] 使用 Windows 系统下的中易字体和微软雅黑字体。 +% 当使用 (pdf)\LaTeX{} 编译时,微软雅黑仅在以下两种情形有效: +% 安装有 \pkg{zhmCJK} 宏包且选项 \opt{zhmap=zhmCJK} 时,或者 +% 安装有微软雅黑的 Type1 字体且选项 \opt{zhmap=false} 时。 % \end{optdesc} % -% 注意:使用 (pdf)\LaTeX{} 编译的时候,若设置 \opt{zhmap = false}(比如需要 -% 使用 \LaTeX{} + Dvips 编译),则需要按照传统方式^^A -% \footnote{可以使用 \pkg{zhmetrics} 宏包提供的脚本 -% \href{https://github.com/CTeX-org/ctex-kit/blob/master/zhmetrics/CTeXFonts.lua} -% {\file{CTeXFonts.lua}}。}^^A -% 在本地安装好 CJK 字体。 -% % 如果不想使用 \CTeX{} 预定义的中文字库,可以设置 \opt{fontset} 为下述值之一。 % % \begin{optdesc} @@ -1043,7 +1046,7 @@ Copyright and Licence % \end{optdesc} % % 注意:\emph{如果希望使用 \tn{ctexset} 在导言区指定字库,则需要先在宏包/文档类选项中指定 -% \opt{fontset = none}}。例如: +% \opt{fontset = none}}(这会禁用 \CTeX{} 宏集的操作系统检测功能和自动设定字库功能)。例如: % \begin{ctexexam} % \documentclass[fontset = none]{ctexart} % \ctexset{fontset = founder} @@ -1054,27 +1057,25 @@ Copyright and Licence % \end{ctexexam} % % \CTeX{} 宏集预定义的中文字库还定义了一些字体命令。除了在 \opt{ubuntu} 字库中没有 -% \tn{fangsong} 的定义外,所有字库都有以下四个字体命令。 -% +% \tn{fangsong} 的定义外,所有字库都有以下四个字体命令: % \begin{optdesc} % \item[\tn{songti}] 宋体,CJK 等价命令 |\CJKfamily{zhsong}|。 % \item[\tn{heiti}] 黑体,CJK 等价命令 |\CJKfamily{zhhei}|。 % \item[\tn{fangsong}] 仿宋,CJK 等价命令 |\CJKfamily{zhfs}|。 % \item[\tn{kaishu}] 楷书,CJK 等价命令 |\CJKfamily{zhkai}|。 % \end{optdesc} -% -% 在 \opt{windows} 和 \opt{founder} 字库中,额外定义了 \tn{lishu} 和 \tn{youyuan}。 +% 在 \opt{windows}、\opt{founder} 和 \opt{macnew} 字库中,额外定义了 \tn{lishu} +% 和 \tn{youyuan}: % \begin{optdesc} % \item[\tn{lishu}] 隶书,CJK 等价命令 |\CJKfamily{zhli}|。 % \item[\tn{youyuan}] 圆体,CJK 等价命令 |\CJKfamily{zhyou}|。 % \end{optdesc} -% 在 \opt{windowsnew} 和 \opt{macnew} 字库中,还有 \tn{yahei}。 -% 其中在 \opt{macnew} 字库中,\tn{yahei} 实际调用苹方黑体。此举乃是为了更好的兼容性而设。 +% 在 \opt{windows} 字库中还定义了 \tn{yahei}。出于兼容性的考虑,\tn{yahei} 命令 +% 在 \opt{macnew} 字库中也有定义,但实际调用苹方黑体: % \begin{optdesc} % \item[\tn{yahei}] 微软雅黑,CJK 等价命令 |\CJKfamily{zhyahei}|。 % \end{optdesc} -% -% 在 \opt{macnew} 字库中,还定义了 \tn{pingfang}。 +% 在 \opt{macnew} 字库中,还定义了 \tn{pingfang}: % \begin{optdesc} % \item[\tn{pingfang}] 苹方黑体,CJK 等价命令 |\CJKfamily{zhpf}|。 % \end{optdesc} @@ -1093,9 +1094,10 @@ Copyright and Licence % 本选项可以用于四个 \CTeX{} 文档类和 \pkg{ctex} 宏包, % 也可以用于 \pkg{ctexsize} 宏包。 % -% \opt{scheme = chinese} 时,对标准文档类默认值为 |5|,即设置 -% \tn{normalsize} 为五号字;对 \cls{beamer} 则为 |false|,使用文档类原有的设 -% 置。 +% 该选项的默认值与 \opt{scheme} 的取值有关。 +% 当 \opt{scheme = chinese} 时,对标准文档类默认值为 |5|,即设置 +% \tn{normalsize} 为五号字;对 \cls{beamer} 则为 |false|,使用文档类原有的设置。 +% 当 \opt{scheme = plain} 时,该选项不设默认值,沿用标准文档类或 \cls{beamer} 的原有设置。 % \end{function} % % \begin{table}[htbp] @@ -1150,8 +1152,7 @@ Copyright and Licence % 本选项只能在调用 \pkg{ctex.sty} 时作为宏包选项使用。 % % \CTeX{} 宏集提供了一套用于修改文档章节标题格式的接口。该选项用于选择是否 -% 启用该功能。详细的设置方法请参见 -% \ref{sec:secstyle}~节和 \ref{subs:pagestyle}~节。 +% 启用该功能。详细的设置方法请参见第 \ref{subs:pagestyle}~节和第 \ref{sec:secstyle}~节。 % \end{function} % % \CTeX{} 宏集提供的四个文档类总是启用该功能。如果在 \pkg{ctex.sty} 下启用该选项, @@ -1169,7 +1170,7 @@ Copyright and Licence % 的格式。启用 \opt{sub4section} 会将 \tn{paragraph} 和 \tn{subparagraph} 的格式 % 都修改为类似 \tn{section} 的格式。 % -% 启用该选项通常需要将计数器 |secnumdepth| 的值为设置为 4 或 5。 +% 启用该选项通常还需要将计数器 |secnumdepth| 的值为设置为 4 或 5。 % % 具体格式可参考 \ref{sec:secstyle}~节中的 \opt{runin} 和 \opt{afterskip} 选项。 % @@ -1185,7 +1186,7 @@ Copyright and Licence % \begin{syntax} % scheme = <(chinese)|plain> % \end{syntax} -% 选择文章的排版方案,预设有 \opt{chinese} 和 \opt{plain} 两种方案。% +% 选择文章的排版方案,预设有 \opt{chinese} 和 \opt{plain} 两种方案。 % \end{function} % \begin{optdesc}[itemsep=\medskipamount] % \item[chinese] 对 \cls{beamer} 以外的文档类,调整默认字号为五号字,并调 @@ -1224,14 +1225,14 @@ Copyright and Licence % \begin{syntax} % space = <\TF|(auto)> % \end{syntax} -% 是否在生成的 PDF 中保留汉字后面的空格。 +% 是否在生成的 PDF 中保留汉字后面的空格。该选项仅在使用 \XeLaTeX{}/(pdf)\LaTeX{} 编译时有效。 % \end{function} % % \begin{optdesc} % \item[true] 总是保留汉字后的空格。此时,用户需要自行在行尾加上~|%|~处理换行产生 % 的空格\footnote{\LaTeX{} 将单个换行视作一个空格。}。 -% \item[false] 总是忽略掉汉字后面的空格,不论汉字后是什么(使用 (pdf)\LaTeX{} -% 编译时);等同于 \opt{auto} 的效果(使用 \XeLaTeX{} 编译时)。不建议使用该选项。 +% \item[false] 使用 (pdf)\LaTeX{} 编译时:总是忽略掉汉字后面的空格,不论汉字后是什么; +% 使用 \XeLaTeX{} 编译时,等同于 \opt{auto} 的效果。不建议使用该选项。 % \item[auto] 根据空格后面的情况决定是否保留:如果空格后面是汉字,则忽略该 % 空格,否则保留。 % \end{optdesc} @@ -1278,8 +1279,10 @@ Copyright and Licence % \begin{optdesc} % \item[\meta{数值或带单位的数值}] 用于设置段首缩进的长度。如果不带单位,则默认 % 单位是单个汉字字宽 \tn{ccwd};如果带单位,则使用该单位。 +% 若要显式使用 \tn{ccwd} 为单位,则必须在导言区进行设置。 % -% \item[true] 等价于设置 \opt{autoindent = 2}。 +% \item[true] 等价于设置 \opt{autoindent = 2} 或 +% 在导言区设置 \opt{autoindent = 2\tn{ccwd}}。 % % \item[false] 禁用自动调整功能,可以设置固定长度的段首缩进。如设置每段缩进 40 点: % \begin{ctexexam} @@ -1315,7 +1318,7 @@ Copyright and Licence % \subsection{日期汉化} % % \CTeX 宏包对显示当前日期的 \tn{today} 命令进行了汉化,使之以中文的方式显示今 -% 天的日期。如编译本文档的日期就是“\today”。 +% 天的日期。如本文档编译时的日期是“\today”。 % % \begin{function}[EXP]{today} % \begin{syntax} @@ -1329,6 +1332,7 @@ Copyright and Licence % 效果为“\today”。使用全汉字的日期格式。 % \item[old] \ctexset{today=old} % 效果为“\today”。使用文档原来的(英文)日期格式。 +% \ctexset{today=small} ^^A NOTE(Liam): 复原设定是好习惯。 % \end{optdesc} % \end{function} % @@ -1343,7 +1347,7 @@ Copyright and Licence % \subsection{文档标题汉化} % \label{subs:capname} % -% 这里主要介绍由宏包 \opt{scheme} 选项(\ref{subs:options-type-style}~节)控制 +% 这里主要介绍由 \opt{scheme} 选项(\ref{subs:options-type-style}~节)控制 % 的文档标题汉化功能。 % % 设置文档标题名的示例可见例~\ref{exam:capname}。下面的选项(如 @@ -1413,8 +1417,16 @@ Copyright and Licence % \begin{syntax} % bibname = <名字> % \end{syntax} -% 设置参考文献标题名 \tn{refname}(对 \cls{article})或 \tn{bibname}(对 -% \cls{report}、\cls{book} 和 \cls{beamer})。中文默认为“\refname”。 +% 设置参考文献标题名。中文默认为“\refname”。 +% +% 在标准文档类中 \cls{article} 的参考文献名使用宏 \tn{refname},而 +% \cls{book} 和 \cls{report} 使用宏 \tn{bibname}。本选项会根据标准文档类的不同,自动 +% 设定 \tn{refname} 或是 \tn{bibname}。因此,对于标准文档类及对应的 \CTeX{} 文档类 +% 可以统一地使用 \opt{bibname} 选项来控制参考文献标题名。 +% +% 对于 \cls{beamer} 及对应的 \cls{ctexbeamer} 来说,它们同时具有宏 \tn{bibname} 和 +% 宏 \tn{refname}。本选项仅控制其中的 \tn{bibname}; +% \tn{refname} 则交由 \opt{refname} 选项控制。 % \end{function} % % \begin{function}[EXP]{proofname} @@ -1433,6 +1445,10 @@ Copyright and Licence % refname = <名字> % \end{syntax} % 设置参考文献标题名 \tn{refname}。中文默认为“\refname”。 +% +% 注意,三个标准文档类(及相应的 \CTeX{} 文档类)的参考文献标题名由 \opt{bibname} 选项 +% 统一设置,本选项仅适用于 \cls{beamer} 及其对应的 \cls{ctexbeamer}。 +% 在三个标准文档类(及相应的 \CTeX{} 文档类)中使用 \opt{refname} 选项会报错。 % \end{function} % % \begin{function}[EXP]{algorithmname} @@ -1455,8 +1471,10 @@ Copyright and Licence % \subsection{页面格式设置与汉化} % \label{subs:pagestyle} % -% 当使用了 \CTeX 的文档类或是用 \pkg{ctex} 宏包加载了 \opt{heading} 选项时,会 -% 设置整个文档的页面格式(page style)为 |headings|,即相当于设置了 +% 页面格式设置与汉化的功能(及章节标题样式设置功能,见第 \ref{sec:secstyle} 节)^^A +% 由 \pkg{ctexheading} 宏包完成。加载该宏包时,或者使用 \CTeX{} 文档类时,^^A +% 或者是使用 \pkg{ctex} 宏包并设定选项 \opt{heading = true} 时,相关功能被激活。 +% 此时,整个文档的页面格式(page style)被设定为 |headings|,即相当于设置了 % \begin{frameverb} % \pagestyle{headings} % \end{frameverb} @@ -1481,7 +1499,7 @@ Copyright and Licence % \tn{chaptermark}、\tn{sectionmark} 中调用 \tn{markright} 或 \tn{markboth} 生 % 成的。 % \end{itemize} -% 有关 \LaTeX 页面标记的涵义与使用细节,已经超出了本文档讨论的范围。可以参考 +% 有关 \LaTeX 页面标记的含义与使用细节,已经超出了本文档讨论的范围。可以参考 % \cite[Chapter~23]{knuthtex1986}、\cite[\S4.3, \S4.4]{mittelbach2004} 等书籍。 % % 这里举一个例子,说明通过重定义 \tn{sectionmark},在 \cls{ctexart} 文档类中的 @@ -1548,41 +1566,50 @@ Copyright and Licence % \smallskip\hrule % \end{trivlist} % -% \section{章节标题格式设置} +% \section{章节标题样式设置} % \label{sec:secstyle} % -% \CTeX 宏包对 \LaTeX 的标准文档类(\cls{article}、\cls{report} 和 -% \cls{book})和 \cls{beamer} 进行了扩充。当以 \opt{heading} 选项调用 \CTeX -% 宏包时(\ref{subs:options-heading}~节),则会启用章 -% 节标题的格式设置功能。本节就来介绍有关章节标题的格式选项,所有选项使用 -% \tn{ctexset} 命令设置。 +% \CTeX{} 宏集对 \LaTeX{} 的标准文档类(\cls{article}、\cls{report}、 +% \cls{book})和 \cls{beamer} 进行了章节标题样式设置功能的扩充。 +% 章节标题样式设置功能(及页面格式设置与汉化功能,见第 \ref{subs:pagestyle} 节)^^A +% 由 \pkg{ctexheading} 宏包完成。加载该宏包时,或者使用 \CTeX{} 文档类时,^^A +% 或者是使用 \pkg{ctex} 宏包并设定选项 \opt{heading = true} 时,相关功能被激活。 +% 其中,独立使用 \pkg{ctexheading} 宏包时,本节介绍各选项的默认值与指定 +% \opt{scheme = plain} 时相同。 % -% 第 \ref{subs:pagestyle} 节和本节介绍的功能已经被提取到 \pkg{ctexheading} -% 宏包之中,可以在 \pkg{ctex} 宏包和 \cls{ctexart} 等文档类之外独立使用。 -% 各选项的默认值与 \opt{scheme = plain} 时的情形相同。 +% 本节涉及的所有选项均需使用 \tn{ctexset} 命令设置。 % % \changes{v2.0}{2015/03/21}{\tn{CTEXsetup}, \tn{CTEXoptions} 是过时命令。} -% 章节标题的格式选项是分层设置的。顶层的选项是章节标题名称,次一级的选项是章节 -% 标题的格式。章节标题名包括 |part|, |chapter|, |section|, |subsection|, -% |subsubsection|, |paragraph|, |subparagraph|;而可用的格式包括 \opt{numbering}, -% \opt{name}, \opt{number}, \opt{format}, \opt{nameformat}, \opt{numberformat}, -% \opt{aftername}, \opt{titleformat}, \opt{aftertitle}, \opt{runin}, -% \opt{afterindent}, \opt{beforeskip}, \opt{afterskip}, \opt{fixskip}, -% \opt{lotskip}, \opt{lofskip}, \opt{indent}, \opt{hang}, -% \opt{pagestyle}, \opt{break}, \opt{tocline} 等。 +% +% 章节标题的样式选项是分层设置的。顶层的选项是章节标题名称(例如 |section|), +% 次一层的选项是章节标题的样式(例如 \opt{nameformat})。章节标题名称包括 +% |part|, |chapter|, |section|, |subsection|, |subsubsection|, |paragraph|, +% |subparagraph|。可用的样式选项包括: +% \begin{itemize} +% \item 编号相关(\ref{subsec:sec-number}~小节): +% \opt{numbering}, \opt{name}, \opt{number} +% \item 格式相关(\ref{subsec:sec-format}~小节): +% \opt{format}, \opt{nameformat}, \opt{numberformat}, \opt{titleformat}, +% \opt{aftername}, \opt{aftertitle}, \opt{pagestyle} +% \item 间距、缩进相关(\ref{subsec:sec-spacing}~小节): +% \opt{runin}, \opt{hang}, \opt{indent}, \opt{beforeskip}, \opt{afterskip}, +% \opt{fixskip}, \opt{break}, \opt{afterindent} +% \item 目录、附录相关(\ref{subsec:sec-toc-appendix}~小节): +% \opt{tocline}, \opt{lofskip}, \opt{lotskip}, \opt{appendix/numbering}, +% \opt{appendix/name}, \opt{appendix/number} +% \end{itemize} % % 注意,对 \cls{article} 及其衍生的 \cls{ctexart} 等文档类,没有 |chapter| -% 级别的标题。而对于 \cls{beamer} 文档类,这些选项控制的是由 \tn{partpage}, -% \tn{sectionpage} 和 \tn{subsectionpage} 产生的标题格式,此时只有 |part|, +% 级别的标题;而对于 \cls{beamer} 文档类,这些选项控制的是由 \tn{partpage}, +% \tn{sectionpage} 和 \tn{subsectionpage} 产生的标题样式,此时只有 |part|, % |section| 和 |subsection| 这三层级别,并且 \opt{runin}, \opt{afterindent}, -% \opt{fixskip}, \opt{hang}, \opt{break} 和 \opt{tocline} 这六个格式无效。 +% \opt{fixskip}, \opt{hang}, \opt{break} 和 \opt{tocline} 这六个选项无效。 % -% 多级选项之间用斜线分开,例如,\opt{part/name} 选项设置 \tn{part} 标题的在数 +% 多层选项之间用斜线分开,例如,\opt{part/name} 选项设置 \tn{part} 标题的在数 % 字前后的名称,而 \opt{section/number} 选项设置 \tn{section} 标题的数字类型。 -% 注意,斜线 |/| 前后不能有空格或者换行。 -% -% 使用 \tn{ctexset} 设置多级选项时,可以在同一个上级选项下设置多个下级选项。 +% 注意,斜线 |/| 的前后不能有空格或者换行。 % +% 使用 \tn{ctexset} 设置多级选项时,还可以在同一个上级选项下设置多个下级选项。 % 例如,同时设置 |part| 一级标题的 \opt{pagestyle} 选项,|chapter| 一级标题的 % \opt{format} 与 \opt{pagestyle} 选项和 |section| 一级标题的 \opt{name} 与 % \opt{number} 选项: @@ -1600,32 +1627,55 @@ Copyright and Licence % } % \end{ctexexam} % +% \subsection{编号相关} +% \label{subsec:sec-number} +% % \begin{function}[EXP,added=2015-06-21]{part/numbering, chapter/numbering, % section/numbering, subsection/numbering, subsubsection/numbering, % paragraph/numbering, subparagraph/numbering} % \begin{syntax} % numbering = \TTF % \end{syntax} -% 控制是否对章节标题编号。对各级标题的默认值均为 \opt{true}。 +% 控制是否对\emph{不带星号}的章节标题进行编号。 +% 各级标题的默认值均为 \opt{true}。 +% +% \LaTeX{} 标准的章节标题命令(如 \tn{section})大体上完成四项工作: +% 输出标题内容、对标题编号(计数器增加 1)、将标题列入目录(若调用了 +% \pkg{hyperref} 宏包还会添加 PDF 书签)、更新页眉页脚标记。带星号的 +% 章节标题命令(如 \tn{section*})只简单地输出章节标题内容,但不对标题编号, +% 不将标题列入目录或 PDF 书签,也不写入页眉页脚标记。与之不同的是, +% 本选项仅仅是否对\emph{不带星号}的章节标题进行编号。因此,当设置本选项为 +% \opt{false} 时,除了不对标题编号以外,其余功能与正常标题一致:可以 +% 编入目录,并生成正确的 \pkg{hyperref} 目录超链接位置和页眉页脚标记。例如: +% \begin{ctexexam} +% \documentclass{ctexbook} +% \begin{document} +% \tableofcontents +% \chapter{A} +% \chapter*{B} +% \ctexset{chapter/numbering=false} +% \chapter{C} +% \end{document} +% \end{ctexexam} +% 三章的标题分别为“第一章\quad A”、“B”和“C”,但在目录中则只出现 +% “第一章\quad A”和“C”。 % -% 我们知道,\LaTeX{} 带星号的章节标题命令(如 \tn{section*})不会对标题编号, -% 但也不会将该没编号的标题编入目录中。本选项控制的是不带星号的标题命令是否编号。 -% 设置本选项为 \opt{false},除了不对标题编号以外,功能与正常标题一致, -% 比如可以编目录,正确的 \pkg{hyperref} 目录超链接位置和页眉标记。 +% 注意,章节标题是否编号还要受到 \LaTeX{} 计数器 |secnumdepth| 的控制。 +% 例如,对于 |section| 而言,其深度为 1。因此,|section| 会被编号,当且仅当 +% |secnumdepth| 不小于 1,并且 \opt{section/numbering} 为 \opt{true}, +% 并且使用不带星号的章节标题命令(即 \tn{section})。 % -% 注意,章节标题的编号深度受 \LaTeX{} 计数器 |secnumdepth| 的控制。 -% \opt{numbering} 选项在 |secnumdepth| 的控制下起作用。 +% 如果没有特别说明,以下将用 “|...|” 代表各级章节标题名。 % \end{function} % -% 如果没有特别说明,以下将用 “|...|” 代表各级章节标题名。 -% % \begin{function}[EXP,updated=2014-03-08]{.../name} % \begin{syntax} % name = \{<前名字>,<后名字>\} % name = \Arg{前名字} % \end{syntax} -% 设置章节的名字。名字可以分为前后两部分,即章节编号前后的词语,两个词之间用 -% 一个半角逗号分开;也可以只有一部分,表示只有章节编号之前的名字。例如: +% 设置章节的名字。所谓“章节的名字”,可以分为前后两部分,即章节编号前后的 +% 词语,两个词之间用一个半角逗号分开;也可以只有一部分,表示只有章节编号之前 +% 的名字。例如: % \begin{ctexexam} % \ctexset{ % chapter/name = {第,章}, @@ -1633,30 +1683,32 @@ Copyright and Licence % } % \end{ctexexam} % 会使得 \tn{chapter} 标题使用形如“第一章”的名字,而 \tn{section} 标题则使 -% 用形如“\S1”的名字。 +% 用形如“\S1”的名字。该选项的默认设置见表~\ref{tab:name-default}。 % \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{name} 选项的默认设置} -% \begin{tabular}{llll} -% \toprule -% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} & 注 \\ -% \midrule -% part & |{第,部分}| & |{\partname\space}| & 原 \tn{partname} 为 Part \\ -% chapter & |{第,章}| & |{\chaptername\space}| -% & 原 \tn{chaptername} 为 Chapter \\ -% section (beamer) & |{}| & |{\sectionname\space}| -% & \BSTACK 原 \tn{sectionname} 为\\ |\translate{Section}| \ESTACK \\ -% section & 同右 & |{}| & \\ -% subsection (beamer) & |{}| & |{\subsectionname\space}| -% & \BSTACK 原 \tn{subsectionname} 为\\ |\translate{Subsection}| \ESTACK \\ -% subsection & 同右 & |{}| & \\ -% subsubsection & 同右 & |{}| & \\ -% paragraph & 同右 & |{}| & \\ -% subparagraph & 同右 & |{}| & \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} +% \caption{\opt{name} 选项的默认设置} +% \label{tab:name-default} +% \begin{tabular}{llll} +% \toprule +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} & 注 \\ +% \midrule +% part & |{第,部分}| & |{\partname\space}| & 原 \tn{partname} 为 Part \\ +% chapter & |{第,章}| & |{\chaptername\space}| +% & 原 \tn{chaptername} 为 Chapter \\ +% section (beamer) & |{}| & |{\sectionname\space}| +% & \BSTACK 原 \tn{sectionname} 为\\ |\translate{Section}| \ESTACK \\ +% section & 同右 & |{}| & \\ +% subsection (beamer) & |{}| & |{\subsectionname\space}| +% & \BSTACK 原 \tn{subsectionname} 为\\ |\translate{Subsection}| \ESTACK \\ +% subsection & 同右 & |{}| & \\ +% subsubsection & 同右 & |{}| & \\ +% paragraph & 同右 & |{}| & \\ +% subparagraph & 同右 & |{}| & \\ +% \bottomrule +% \end{tabular} % \end{table} % % \begin{function}[EXP]{.../number} @@ -1664,118 +1716,132 @@ Copyright and Licence % number = \Arg{数字输出命令} % \end{syntax} % 设置章节编号的数字输出格式。\meta{数字输出命令} 通常是对应章节编号计数器的 -% 输出命令,如 \tn{thesection} 或 |\chinese{chapter}| 之类。 +% 输出命令,如 \tn{thesection} 或 |\chinese{chapter}| 之类。例如: % \begin{ctexexam} % \ctexset{ % section/number = \Roman{section} % } % \end{ctexexam} -% \end{function} +% 将会使 \tn{section} 的编号变为大写罗马数字(如 I、II 等)。 % -% \opt{number} 选项的定义同时将控制对章节计数器的交叉引用。在引用计数器时, +% \opt{number} 选项定义的同时将控制对章节计数器的交叉引用。在引用计数器时, % 记录在 \LaTeX{} 辅助文件中的是 \opt{number} 选项的定义。 % % 但是,\opt{number} 选项不会影响计数器本身的输出。即设置 |section/number| -% 不会影响 \tn{thesection} 的定义。(但该选项会影响 \tn{CTEXthesection} 的定 -% 义,见后。) +% 不会影响 \tn{thesection} 的定义(但该选项会影响 \tn{CTEXthesection} 的定 +% 义,见后)。该选项的默认设置见表~\ref{tab:number-default}。 +% \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{number} 选项的默认设置} -% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} -% \begin{tabular}{llll} -% \toprule -% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} -% & 原 |\the|\meta{标题} 等价定义 \\ -% \midrule -% part (beamer) & |\chinese{part}| & |\insertromanpartnumber| & 意义为 |\Roman{part}| \\ -% part & |\chinese{part}| & |\thepart| & |\Roman{part}| \\ -% chapter & |\chinese{chapter}| & |\thechapter| & |\arabic{chapter}| \\ -% section (beamer) & 同右 & |\insertsectionnumber| & 意义为 |\arabic{section}| \\ -% section & 同右 & |\thesection| & |\arabic{section}| \\ -% subsection (beamer) -% & \BSTACK |\arabic{section}.|\\ |\arabic{subsection}| \ESTACK -% & |\insertsubsectionnumber| & 意义为 |\arabic{subsection}| \\ -% subsection & 同右 & |\thesubsection| & |\thesection.\arabic{subsection}| \\ -% subsubsection & 同右 & |\thesubsubsection| -% & |\thesubsection.\arabic{subsubsection}| \\ -% paragraph & 同右 & |\theparagraph| -% & |\thesubsubsection.\arabic{paragraph}| \\ -% subparagraph & 同右 & |\thesubparagraph| -% & |\theparagraph.\arabic{subparagraph}| \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \caption{\opt{number} 选项的默认设置} +% \label{tab:number-default} +% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} +% \begin{tabular}{llll} +% \toprule +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} +% & 原 |\the|\meta{标题} 等价定义 \\ +% \midrule +% part (beamer) & |\chinese{part}| & |\insertromanpartnumber| & 意义为 |\Roman{part}| \\ +% part & |\chinese{part}| & |\thepart| & |\Roman{part}| \\ +% chapter & |\chinese{chapter}| & |\thechapter| & |\arabic{chapter}| \\ +% section (beamer) & 同右 & |\insertsectionnumber| & 意义为 |\arabic{section}| \\ +% section & 同右 & |\thesection| & |\arabic{section}| \\ +% subsection (beamer) +% & \BSTACK |\arabic{section}.|\\ |\arabic{subsection}| \ESTACK +% & |\insertsubsectionnumber| & 意义为 |\arabic{subsection}| \\ +% subsection & 同右 & |\thesubsection| & |\thesection.\arabic{subsection}| \\ +% subsubsection & 同右 & |\thesubsubsection| +% & |\thesubsection.\arabic{subsubsection}| \\ +% paragraph & 同右 & |\theparagraph| +% & |\thesubsubsection.\arabic{paragraph}| \\ +% subparagraph & 同右 & |\thesubparagraph| +% & |\theparagraph.\arabic{subparagraph}| \\ +% \bottomrule +% \end{tabular} % \end{table} % -% \begin{function}{\CTEXthepart, \CTEXthechapter, \CTEXthesection, -% \CTEXthesubsection, \CTEXthesubsubsection, \CTEXtheparagraph, -% \CTEXthesubparagraph} -% 以 |\CTEXthe| 开头的这组宏给出结合了 \opt{name} 与 \opt{number} 选项的章节 -% 编号输出格式。例如在 \opt{scheme = chinese} 时,默认章编号输出格式就是 -% \tn{CTEXthechapter},形如“第一章”。 -% -% 这组宏在 \CTeX 文档类中将代替 \tn{thechapter} 等宏的作用,在章节中引用本章 -% 节的完整编号。例如用于帮助定义自定义的目录格式、页眉格式等。 -% \end{function} -% -% \begin{function}[added=2016-09-18]{\CTEXifname} -% \begin{syntax} -% \tn{CTEXifname} \Arg{有名字时的格式命令} \Arg{无名字时的格式命令} -% \end{syntax} -% \tn{CTEXifname} 用于根据当前章节的名字的有无设置不同的格式。 -% -% 它可用于 \opt{format}, \opt{titleformat}, \opt{aftertitle}, \opt{afterskip}, -% \opt{indent} 这五个选项和 \tn{chapter} 标题 \opt{beforeskip} 选项的格式设置之中。 -% 也可用于帮助定义自定义的目录格式、页眉格式等。 -% -% 例如,设置章的标题有名字时左对齐,无名字时居中对齐,并且在标题后画一条横线。 -% \begin{ctexexam} -% \ctexset{ -% chapter/format = \CTEXifname{\raggedright}{\centering}, -% chapter/aftertitle = \par\CTEXifname{}{\hrule}, -% } -% \end{ctexexam} -% \end{function} -% -% \begin{function}[EXP,updated=2015-06-30]{.../format, .../format+} +% \subsection{格式相关} +% \label{subsec:sec-format} +% +% \CTeX{} 宏集提供了 \opt{numberformat}, \opt{nameformat}, \opt{titleformat}, +% \opt{format} 这几个选项用来控制章节标题的格式。 +% 它们的作用范围如图~\ref{fig:heading-format} 所示。具体用法见下文。 +% +% \begin{figure}[htbp] +% \centering +% \[ +% \underbrace{ +% \overbrace{ +% \text{\huge\bfseries 第} +% \mspace{-25mu} +% \underbrace{\text{\huge\bfseries 1}}_{\text{\small\opt{numberformat}}} +% \mspace{-25mu} +% \text{\huge\bfseries 章} +% }^{\text{\small\opt{nameformat}}} \quad +% \overbrace{\text{\huge\bfseries 熟悉 \LaTeX}}^{\text{\small\opt{titleformat}}} +% }_{\text{\small\opt{format}}} +% \] +% \caption{\opt{numberformat}, \opt{nameformat}, \opt{titleformat}, +% \opt{format} 几个选项的作用范围示意} +% \label{fig:heading-format} +% \end{figure} +% +% \begin{function}[EXP,updated=2020-04-22]{.../format, .../format+} % \begin{syntax} % format = \Arg{格式命令} % format+= \Arg{格式命令} % \end{syntax} % \opt{format} 选项用于控制章节标题的全局格式,作用域为章节名字和随后的标题 % 内容。可以用于控制章节标题的对齐方式、整体字体字号等格式。 +% 带加号的 \opt{format+} 选项用于在已有的格式命令后附加内容。 % -% 带加号的 \opt{format+} 选项则用于在已有格式之后追加新的格式命令。 +% \opt{format} 选项的最后一个格式命令可以带有一个参数。 +% 这一参数用于接受章节名字、编号和标题内容(以及由 \opt{nameformat}, \opt{numberformat}, +% \opt{aftername},\opt{titleformat}, \opt{aftertitle}, \opt{indent} +% 及 \opt{hang} 选项设定的,应用于这些内容之上的格式),以实现特殊效果。 % -% 例如,设置章格式为无衬线字体左对齐,为节格式增加无衬线字体设置: +% 例如,设置章标题为无衬线字体左对齐、为节标题增加无衬线字体设置、 +% 为小节标题加框(\tn{fbox} 命令本身需带一个参数): % \begin{ctexexam} % \ctexset{ -% chapter/format = \sffamily\raggedright, -% section/format += \sffamily +% chapter/format = \sffamily\raggedright, +% section/format += \sffamily, +% subsection/format += \fbox, % } % \end{ctexexam} +% +% \opt{format} 选项的默认设置见表~\ref{tab:format-default}。 % \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{format} 选项的默认设置} -% \begin{tabular}{lll} -% \toprule -% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ -% \midrule -% part (article) & |\Large\bfseries\centering| & |\raggedright| \\ -% part (beamer) & 同右 & |\centering| \\ -% part & |\huge\bfseries\centering| & |\centering| \\ -% chapter & |\huge\bfseries\centering| & |\raggedright| \\ -% section (beamer) & 同右 & |\centering| \\ -% section & |\Large\bfseries\centering| & |\Large\bfseries| \\ -% subsection (beamer) & 同右 & |\centering| \\ -% subsection & 同右 & |\large\bfseries| \\ -% subsubsection & 同右 & |\normalsize\bfseries| \\ -% paragraph & 同右 & |\normalsize\bfseries| \\ -% subparagraph & 同右 & |\normalsize\bfseries| \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \begin{threeparttable} +% \caption{\opt{format} 选项的默认设置} +% \label{tab:format-default} +% \begin{tabular}{lll} +% \toprule +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ +% \midrule +% part (article) & |\Large\bfseries\centering| & |\raggedright|\tnote{*} \\ +% part (beamer) & 同右 & |\centering| \\ +% part & |\huge\bfseries\centering| & |\centering| \\ +% chapter & |\huge\bfseries\centering| & |\raggedright| \\ +% section (beamer) & 同右 & |\centering| \\ +% section & |\Large\bfseries\centering| & |\Large\bfseries| \\ +% subsection (beamer) & 同右 & |\centering| \\ +% subsection & 同右 & |\large\bfseries| \\ +% subsubsection & 同右 & |\normalsize\bfseries| \\ +% paragraph & 同右 & |\normalsize\bfseries| \\ +% subparagraph & 同右 & |\normalsize\bfseries| \\ +% \bottomrule +% \end{tabular} +% \begin{tablenotes} +% \item[*] 为了与 \LaTeXe{} 的默认效果保持一致,在 \opt{scheme = plain} +% 时,part 和 chapter 的 \opt{nameformat} 和 \opt{titleformat} +% 并不一样,因此没有使用 \opt{format} 选项统一设置名字和标题的格式。 +% \end{tablenotes} +% \end{threeparttable} % \end{table} % % \begin{function}[EXP,updated=2015-06-30]{.../nameformat, .../nameformat+} @@ -1785,42 +1851,42 @@ Copyright and Licence % \end{syntax} % \opt{nameformat} 用于控制章节名字的格式,作用域为章节名字,包括编号。它一 % 般用于章节名(包括编号)与章节标题的字体、字号等设置不一致的情形。参见 -% \opt{titleformat} 选项。 +% 下面的 \opt{titleformat} 选项。\opt{nameformat+} 用于在已有的章节名字 +% 格式命令后附加内容。 % -% \opt{nameformat+} 用于在已有的章节名字格式后附加内容。 +% \opt{nameformat} 选项的最后一个格式命令可以带有一个参数。 +% 这一参数用于接受章节名字和编号,以实现特殊效果(见例~\ref{exam:miscopt})。 % -% \opt{nameformat} 选项的最后一个格式命令可以是一个有一个参数的命令。 -% 这个命令的参数用于接受章节名字和编号,实现特殊效果(见例~\ref{exam:miscopt})。 -% -% \opt{nameformat} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 +% \opt{nameformat} 选项的默认设置见表~\ref{tab:nameformat-default}。 % \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{nameformat} 选项的默认设置} -% \begin{tabular}{lll} -% \toprule -% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ -% \midrule -% part (article) & |{}| & |\Large\bfseries| \\ -% part (beamer) & 同右 -% & \BSTACK |\usebeamerfont{part name}| \\ -% |\usebeamercolor[fg]{part name}| \ESTACK \\ -% part & |{}| & |\huge\bfseries| \\ -% chapter & |{}| & |\huge\bfseries| \\ -% section (beamer) & 同右 -% & \BSTACK |\usebeamerfont{section name}| \\ -% |\usebeamercolor[fg]{section name}| \ESTACK \\ -% section & 同右 & |{}| \\ -% subsection (beamer) & 同右 -% & \BSTACK |\usebeamerfont{subsection name}| \\ -% |\usebeamercolor[fg]{subsection name}| \ESTACK \\ -% subsection & 同右 & |{}| \\ -% subsubsection & 同右 & |{}| \\ -% paragraph & 同右 & |{}| \\ -% subparagraph & 同右 & |{}| \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \caption{\opt{nameformat} 选项的默认设置} +% \label{tab:nameformat-default} +% \begin{tabular}{lll} +% \toprule +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ +% \midrule +% part (article) & |{}| & |\Large\bfseries| \\ +% part (beamer) & 同右 +% & \BSTACK |\usebeamerfont{part name}| \\ +% |\usebeamercolor[fg]{part name}| \ESTACK \\ +% part & |{}| & |\huge\bfseries| \\ +% chapter & |{}| & |\huge\bfseries| \\ +% section (beamer) & 同右 +% & \BSTACK |\usebeamerfont{section name}| \\ +% |\usebeamercolor[fg]{section name}| \ESTACK \\ +% section & 同右 & |{}| \\ +% subsection (beamer) & 同右 +% & \BSTACK |\usebeamerfont{subsection name}| \\ +% |\usebeamercolor[fg]{subsection name}| \ESTACK \\ +% subsection & 同右 & |{}| \\ +% subsubsection & 同右 & |{}| \\ +% paragraph & 同右 & |{}| \\ +% subparagraph & 同右 & |{}| \\ +% \bottomrule +% \end{tabular} % \end{table} % % \begin{function}[EXP,updated=2015-06-19]{.../numberformat, .../numberformat+} @@ -1829,74 +1895,37 @@ Copyright and Licence % numberformat+= \Arg{格式命令} % \end{syntax} % \opt{numberformat} 选项用于控制章节编号的格式,作用域仅为编号数字本身。对 -% 各级标题默认均为空,当你需要编号的格式和前后的章节名字不一样时可以使用。 +% 各级标题默认均为空,当需要编号的格式和前后的章节名字不一样时可以使用。 +% \opt{numberformat+} 用于在已有的编号格式命令后附加内容。 % -% \opt{numberformat+} 选项用于在原有编号格式后面附加格式命令。 -% -% \opt{numberformat} 选项的最后一个格式命令可以是一个有一个参数的命令。 -% 这个命令的参数用于接受编号数字。 -% \end{function} -% -% 例如,我们可以使用 \opt{numberformat} 特别强调章标题中的数字: +% \opt{numberformat} 选项的最后一个格式命令可以带有一个参数。这一参数用于接受 +% 编号数字。例如,我们可以使用 \opt{numberformat} 特别强调章标题中的数字: % \begin{ctexexam} % \ctexset{ % chapter/number = \arabic{chapter}, -% chapter/numberformat = \color{blue}\zihao{0}\itshape, +% chapter/numberformat = \color{blue}\zihao{0}\emph, % } % \end{ctexexam} % 上面的代码在 \opt{scheme = chinese} 时可以做出类似这样的章标题效果: % \begin{center} -% \huge\bfseries 第 \textit{\color{blue}\zihao{0}4} 章 +% \huge\bfseries 第 \emph{\color{blue}\zihao{0}4} 章 % \end{center} % -% \begin{function}[EXP,updated=2014-03-08]{.../aftername, .../aftername+} -% \begin{syntax} -% aftername = \Arg{代码} -% aftername+= \Arg{代码} -% \end{syntax} -% \opt{aftername} 选项的参数 \meta{代码} 将被插入到章节编号与其后的标题内容之 -% 间,用于控制格式变换。常用于控制章节编号与标题内容之间的距离,或者控制标题 -% 是否另起一行。 -% -% \opt{aftername+} 选项用于在原有代码后面附加代码。 +% \opt{numberformat} 选项默认均设置为空,故章节编号默认与章节名字使用 +% 相同的格式。 % \end{function} % -% \begin{table}[htbp] -% \small\centering -% \caption{\opt{aftername} 选项的默认设置} -% \begin{tabular}{lll} -% \toprule -% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ -% \midrule -% part (article) & |\quad| & |\par\nobreak| \\ -% part (beamer) & 同右 & |\vskip 1em \par| \\ -% part & 同右 & |\par\vskip 20pt| \\ -% chapter & |\quad| & |\par\nobreak\vskip 20pt| \\ -% section (beamer) & 同右 & |\vskip 1em \par| \\ -% section & 同右 & |\quad| \\ -% subsection (beamer) & 同右 & |\vskip 1em \par| \\ -% subsection & 同右 & |\quad| \\ -% subsubsection & 同右 & |\quad| \\ -% paragraph & 同右 & |\quad| \\ -% subparagraph & 同右 & |\quad| \\ -% \bottomrule -% \end{tabular} -% \end{table} -% % \begin{function}[EXP,updated=2015-06-30]{.../titleformat, .../titleformat+} % \begin{syntax} % titleformat = \Arg{格式命令} % titleformat+= \Arg{格式命令} % \end{syntax} % \opt{titleformat} 选项用于控制标题内容的格式,作用域为章节标题内容。 +% \opt{titleformat+} 选项用于在已有的标题格式命令后附加内容。 % -% \opt{titleformat+} 选项用于在原有标题格式后面附加格式命令。 -% -% 需要注意的是,\opt{titleformat} 选项的最后一个格式命令可以是一个有一个 -% 参数的命令。这个命令的参数接受标题内容,用于实现特殊效果。 -% 例如,实现多行标题的居中悬挂对齐: -% \end{function} -% \begin{ctexexam} +% \opt{titleformat} 选项的最后一个格式命令可以带有一个参数。这一参数用于接受 +% 标题内容。例如,实现多行标题的居中悬挂对齐: +% \begin{ctexexam} % \usepackage{varwidth} %% 提供 varwidth 环境 % \ctexset{ % chapter/name = {第,回}, @@ -1906,142 +1935,265 @@ Copyright and Licence % \begin{varwidth}[t]{.7\linewidth}#1\end{varwidth}} % ...... % \chapter{情中情因情感妹妹\\错里错以错劝哥哥} -% \end{ctexexam} -% 上面的代码可以做出类似这样的章标题效果: -% \begin{center}\Large\bfseries -% 第三十四回\quad -% \begin{tabular}[t]{l} -% 情中情因情感妹妹\\ -% 错里错以错劝哥哥 -% \end{tabular} -% \end{center} +% \end{ctexexam} +% 上面的代码可以做出类似这样的章标题效果: +% \begin{center}\Large\bfseries +% 第三十四回\quad +% \begin{tabular}[t]{l} +% 情中情因情感妹妹\\ +% 错里错以错劝哥哥 +% \end{tabular} +% \end{center} +% +% \opt{titleformat} 选项的默认设置见表~\ref{tab:titleformat-default}。 +% \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{titleformat} 选项的默认设置} -% \begin{tabular}{lll} -% \toprule -% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ -% \midrule -% part (article) & |{}| & |\huge\bfseries| \\ -% part (beamer) & 同右 & |\usebeamerfont{part title}| \\ -% part & |{}| & |\Huge\bfseries| \\ -% chapter & |{}| & |\Huge\bfseries| \\ -% section (beamer) & 同右 & |\usebeamerfont{section title}| \\ -% section & 同右 & |{}| \\ -% subsection (beamer) & 同右 & |\usebeamerfont{subsection title}| \\ -% subsection & 同右 & |{}| \\ -% subsubsection & 同右 & |{}| \\ -% paragraph & 同右 & |{}| \\ -% subparagraph & 同右 & |{}| \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \caption{\opt{titleformat} 选项的默认设置} +% \label{tab:titleformat-default} +% \begin{tabular}{lll} +% \toprule +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ +% \midrule +% part (article) & |{}| & |\huge\bfseries| \\ +% part (beamer) & 同右 & |\usebeamerfont{part title}| \\ +% part & |{}| & |\Huge\bfseries| \\ +% chapter & |{}| & |\Huge\bfseries| \\ +% section (beamer) & 同右 & |\usebeamerfont{section title}| \\ +% section & 同右 & |{}| \\ +% subsection (beamer) & 同右 & |\usebeamerfont{subsection title}| \\ +% subsection & 同右 & |{}| \\ +% subsubsection & 同右 & |{}| \\ +% paragraph & 同右 & |{}| \\ +% subparagraph & 同右 & |{}| \\ +% \bottomrule +% \end{tabular} % \end{table} % +% \begin{function}[EXP,updated=2014-03-08]{.../aftername, .../aftername+} +% \begin{syntax} +% aftername = \Arg{代码} +% aftername+= \Arg{代码} +% \end{syntax} +% \opt{aftername} 选项的参数 \meta{代码} 将被插入到章节编号与其后的标题内容之 +% 间,用于控制格式变换。常用于控制章节编号与标题内容之间的距离,或者控制标题 +% 是否另起一行。\opt{aftername+} 用于在已有的代码后附加内容。该选项的默认设置 +% 见表~\ref{tab:aftername-default}。 +% \end{function} +% % \begin{function}[EXP,added=2015-06-19]{.../aftertitle, .../aftertitle+} % \begin{syntax} % aftertitle = \Arg{代码} % aftertitle+= \Arg{代码} % \end{syntax} % \opt{aftertitle} 选项的参数 \meta{代码} 将被插入到章节标题内容之后。 +% \opt{aftertitle+} 用于在已有的代码后附加内容。该选项的默认设置 +% 见表~\ref{tab:aftertitle-default}。需注意,\opt{sub3section} 或 +% \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)会影响 +% \opt{aftertitle} 选项的默认值。 +% \end{function} % -% \opt{aftertitle+} 选项用于在原有代码后面附加代码。 -% -% \opt{aftertitle} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 +% \begin{table}[htbp] +% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} +% \begin{minipage}[t]{.75\linewidth} +% \small\centering +% \caption{\opt{aftername} 选项的默认设置} +% \label{tab:aftername-default} +% \begin{tabular}{lll} +% \toprule +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ +% \midrule +% part (article) & |\quad| & |\par\nobreak| \\ +% part (beamer) & 同右 & |\vskip 1em \par| \\ +% part & 同右 & |\par\vskip 20pt| \\ +% chapter & |\quad| & |\par\nobreak\vskip 20pt| \\ +% section (beamer) & 同右 & |\vskip 1em \par| \\ +% section & 同右 & |\quad| \\ +% subsection (beamer) & 同右 & |\vskip 1em \par| \\ +% subsection & 同右 & |\quad| \\ +% subsubsection & 同右 & |\quad| \\ +% paragraph & 同右 & |\quad| \\ +% subparagraph & 同右 & |\quad| \\ +% \bottomrule +% \end{tabular} +% \end{minipage}\nobreak\quad +% \begin{minipage}[t]{.42\linewidth} +% \small\centering +% \caption{\opt{aftertitle} 选项的默认设置} +% \label{tab:aftertitle-default} +% \begin{tabular}{p{\dimexpr .58\linewidth - 2\tabcolsep\relax}p{\dimexpr .4\linewidth - 2\tabcolsep\relax}} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part & |\par| \\ +% chapter & |\par| \\ +% section & |\@@par| \\ +% subsection & |\@@par| \\ +% subsubsection & |\@@par| \\ +% paragraph & |{}| \\ +% \qquad(sub3section) & |\@@par| \\ +% \qquad(sub4section) & 同上 \\ +% subparagraph & |{}| \\ +% \qquad(sub4section) & |\@@par| \\ +% \bottomrule +% \end{tabular} +% \end{minipage} +% \end{table} % -% \opt{sub3section} 或 \opt{sub4section} 宏包选项(见 -% \ref{subs:options-heading}~节)会影响 \opt{aftertitle} 选项的默认值。 +% \begin{function}[EXP,added=2014-03-21]{part/pagestyle, chapter/pagestyle} +% \begin{syntax} +% pagestyle = \Arg{页面格式} +% \end{syntax} +% 设置 \cls{book}/\cls{ctexbook} 或 \cls{report}/\cls{ctexrep} 文档类 +% 中,\tn{part} 与 \tn{chapter} 标题所在页的页面格式(page style)。 +% 该选项的默认设置见表~\ref{tab:pagestyle-default}。 % \end{function} % % \begin{table}[htbp] -% \begin{minipage}[t]{.5\linewidth} -% \small\centering -% \caption{\opt{aftertitle} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part & |\par| \\ -% chapter & |\par| \\ -% section & |\@@par| \\ -% subsection & |\@@par| \\ -% subsubsection & |\@@par| \\ -% paragraph & |{}| \\ -% \qquad(sub3section) & |\@@par| \\ -% \qquad(sub4section) & 同上 \\ -% subparagraph & |{}| \\ -% \qquad(sub4section) & |\@@par| \\ -% \bottomrule -% \end{tabular} -% \end{minipage}% -% \begin{minipage}[t]{.5\linewidth} -% \small\centering -% \caption{\opt{runin} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part & 无效 \\ -% chapter & 无效 \\ -% section & |false| \\ -% subsection & |false| \\ -% subsubsection & |false| \\ -% paragraph & |true| \\ -% \qquad(sub3section) & |false| \\ -% \qquad(sub4section) & 同上 \\ -% subparagraph & |true| \\ -% \qquad(sub4section) & |false| \\ -% \bottomrule -% \end{tabular} -% \end{minipage} +% \small\centering +% \caption{\opt{pagestyle} 选项的默认设置} +% \label{tab:pagestyle-default} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part (article) & 无效 \\ +% part & |plain| \\ +% chapter & |plain| \\ +% \bottomrule +% \end{tabular} % \end{table} % +% \subsection{间距、缩进相关} +% \label{subsec:sec-spacing} +% % \begin{function}[EXP,added=2015-06-27]{section/runin, subsection/runin, % subsubsection/runin, paragraph/runin, subparagraph/runin} % \begin{syntax} % runin = \TF % \end{syntax} -% \opt{runin} 选项只对 \tn{section} 级以下标题有意义。 -% 用于确定标题与随后的正文是否排在同一段之上。 -% -% \opt{runin} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 +% \opt{runin} 选项只对 \tn{section} 级以下标题有意义,用于确定标题与随后的 +% 正文是否排在同一段之上。该选项的默认设置见表~\ref{tab:runin-default}。 % % 默认情况下,\tn{paragraph}、\tn{subparagraph} 两级标题是与后面正文排在同一 % 段的,\opt{runin} 选项为 \opt{true};但使用 \opt{sub3section} 或 -% \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)后, -% 将对这两级标题设 \opt{runin} 选项为 \opt{false},这两级标题会改为排在不同段。 +% \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)后,将对 +% 这两级标题设 \opt{runin} 选项为 \opt{false},这两级标题会改为排在不同段。 % \end{function} % -% \begin{function}[EXP,added=2015-06-27]{.../afterindent} +% \begin{table}[htbp] +% \small\centering +% \caption{\opt{runin} 选项的默认设置} +% \label{tab:runin-default} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part & 无效 \\ +% chapter & 无效 \\ +% section & |false| \\ +% subsection & |false| \\ +% subsubsection & |false| \\ +% paragraph & |true| \\ +% \qquad(sub3section) & |false| \\ +% \qquad(sub4section) & 同上 \\ +% subparagraph & |true| \\ +% \qquad(sub4section) & |false| \\ +% \bottomrule +% \end{tabular} +% \end{table} +% +% \begin{function}[EXP,updated=2020-04-23]{.../hang} % \begin{syntax} -% afterindent = \TF +% hang = \TF % \end{syntax} -% \opt{afterindent} 选项用于设置章节标题后首段的缩进。 +% \opt{hang} 选项用于设置是否对章节标题实施悬挂缩进(缩进的宽度为名字宽度 +% 和 \opt{indent} 选项设置的宽度之和)。 % -% \cls{book} 和 \cls{report} 类的 \tn{part} 标题被单独排在一页之上, -% \opt{afterindent} 选项没有意义。 +% 注意,当 \opt{hang = true} 时,不恰当地设置选项 \opt{aftername} 的值,可能会引发 +% 错误。这是因为当 \opt{hang = true} 时,\LaTeX{} 内部会构造一个 \tn{hbox} 而 +% 进入受限水平模式(restricted horizontal mode)。若在 \opt{aftername} 中加入 +% 包含 \tn{vskip} 等会导致从受限水平模式切出的垂直命令(vertical command)时,就会报错。 +% 特别地,\opt{aftername} 的默认值也可能导致这种情形(见表~\ref{tab:aftername-default})。 +% 因此,当设置 \opt{hang = true} 时,用户必须恰当地设置选项 \opt{aftername} 的值。 % +% 本选项对 \cls{beamer}/\cls{ctexbeamer} 文档类无效。 % 对于 \tn{section} 级以下标题,若设置了 \opt{runin} 选项为 \opt{true}, -% 即标题与随后正文排在同一段,\opt{afterindent} 选项也就没有了意义。 +% 即标题与随后正文排在同一段,\opt{hang} 选项没有意义。 +% 该选项的默认设置见表~\ref{tab:hang-default}。 +% \end{function} +% +% \begin{function}[EXP,updated=2020-04-23]{.../indent} +% \begin{syntax} +% indent = \Arg{缩进间距} +% \end{syntax} +% \opt{indent} 选项用于设置章节标题本身的首行缩进。 +% 该选项的默认设置见表~\ref{tab:indent-default}。 +% +% 如果 \opt{indent} 的值是以 \texttt{em}、\texttt{ex} 或 \cs{ccwd} 为单位, +% 那么缩进间距的大小是相对于 \opt{format} 中指定的字号大小。 +% 例如,设置 \tn{part} 标题缩进三个字、\tn{section} 标题缩进 \SI{20}{pt}: +% \begin{ctexexam} +% \ctexset{ +% part = { +% format += \raggedright, +% indent = 3\ccwd, +% }, +% section = { +% format = \Large\bfseries, +% indent = 20pt, +% } +% } +% \part{首行缩进的标题} +% \noindent 无缩进的正文。 +% \section{首行缩进的标题} +% \noindent 无缩进的正文。 +% \end{ctexexam} % \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{afterindent} 选项的默认设置} -% \begin{tabular}{lll} -% \toprule -% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ -% \midrule -% part (article) & |true| & |false| \\ -% part & 无效 & 无效 \\ -% chapter & |true| & |false| \\ -% section & |true| & |false| \\ -% subsection & |true| & |false| \\ -% subsubsection & |true| & |false| \\ -% paragraph & |true| & |false| \\ -% subparagraph & |true| & |false| \\ -% \bottomrule -% \end{tabular} +% \begin{minipage}[t]{.5\linewidth} +% \small\centering +% \caption{\opt{hang} 选项的默认设置} +% \label{tab:hang-default} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part & |false| \\ +% chapter & |false| \\ +% section & |true| \\ +% subsection & |true| \\ +% subsubsection & |true| \\ +% paragraph & 无意义 \\ +% \qquad(sub3section) & |true| \\ +% \qquad(sub4section) & |true| \\ +% subparagraph & 无意义 \\ +% \qquad(sub4section) & |true| \\ +% \bottomrule +% \end{tabular} +% \end{minipage} +% \begin{minipage}[t]{.5\linewidth} +% \small\centering +% \caption{\opt{indent} 选项的默认设置} +% \label{tab:indent-default} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part & |0pt| \\ +% chapter & |0pt| \\ +% section & |0pt| \\ +% subsection & |0pt| \\ +% subsubsection & |0pt| \\ +% paragraph & |0pt| \\ +% subparagraph & |\parindent| \\ +% \qquad(sub3section) & |0pt| \\ +% \qquad(sub4section) & 同上 \\ +% \bottomrule +% \end{tabular} +% \end{minipage} % \end{table} % % \begin{function}[EXP,updated=2016-05-10]{.../beforeskip} @@ -2049,59 +2201,9 @@ Copyright and Licence % beforeskip = \Arg{弹性间距} % \end{syntax} % \opt{beforeskip} 选项用于设置章节标题前的垂直间距。 -% -% \opt{beforeskip} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 +% 该选项的默认设置见表~\ref{tab:beforeskip-default}。 % \end{function} % -% \begin{table}[htbp] -% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} -% \begin{minipage}[t]{.6\linewidth} -% \small\centering -% \caption{\opt{beforeskip} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part (article) & |4ex| \\ -% part (beamer) & |0pt| \\ -% part & |0pt plus 1fil| \\ -% chapter & |50pt| \\ -% section (beamer) & |0pt| \\ -% section & |3.5ex plus 1ex minus .2ex| \\ -% subsection (beamer) & |0pt| \\ -% subsection & |3.25ex plus 1ex minus .2ex| \\ -% subsubsection & |3.25ex plus 1ex minus .2ex| \\ -% paragraph & |3.25ex plus 1ex minus .2ex| \\ -% subparagraph & |3.25ex plus 1ex minus .2ex| \\ -% \bottomrule -% \end{tabular} -% \end{minipage}% -% \begin{minipage}[t]{.5\linewidth} -% \small\centering -% \caption{\opt{afterskip} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part (article) & |3ex| \\ -% part (beamer) & |0pt| \\ -% part & |0pt plus 1fil| \\ -% chapter & |40pt| \\ -% section (beamer) & |0pt| \\ -% section & |2.3ex plus .2ex| \\ -% subsection (beamer) & |0pt| \\ -% subsection & |1.5ex plus .2ex| \\ -% subsubsection & |1.5ex plus .2ex| \\ -% paragraph & |1em| \\ -% \qquad(sub3section) & |1ex plus .2ex| \\ -% \qquad(sub4section) & 同上 \\ -% subparagraph & |1em| \\ -% \qquad(sub4section) & |1ex plus .2ex| \\ -% \bottomrule -% \end{tabular} -% \end{minipage} -% \end{table} -% % \begin{function}[EXP,updated=2015-06-27]{.../afterskip} % \begin{syntax} % afterskip = \Arg{弹性间距} @@ -2112,222 +2214,207 @@ Copyright and Licence % 若 \opt{runin} 为 \opt{true},标题与随后正文排在同一段,\meta{弹性间距} 给出水平间距。 % 否则,正文另起一段,\meta{弹性间距} 给出的是垂直间距。 % -% \opt{afterskip} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 -% -% \opt{sub3section} 或 \opt{sub4section} 宏包选项(见 +% 该选项的默认设置见表~\ref{tab:afterskip-default}。 +% 注意 \opt{sub3section} 或 \opt{sub4section} 宏包选项(见 % \ref{subs:options-heading}~节)会影响 \opt{aftertitle} 选项的默认值。 % \end{function} % +% \begin{table}[htbp] +% \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} +% \begin{minipage}[t]{.6\linewidth} +% \small\centering +% \caption{\opt{beforeskip} 选项的默认设置} +% \label{tab:beforeskip-default} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part (article) & |4ex| \\ +% part (beamer) & |0pt| \\ +% part & |0pt plus 1fil| \\ +% chapter & |50pt| \\ +% section (beamer) & |0pt| \\ +% section & |3.5ex plus 1ex minus .2ex| \\ +% subsection (beamer) & |0pt| \\ +% subsection & |3.25ex plus 1ex minus .2ex| \\ +% subsubsection & |3.25ex plus 1ex minus .2ex| \\ +% paragraph & |3.25ex plus 1ex minus .2ex| \\ +% subparagraph & |3.25ex plus 1ex minus .2ex| \\ +% \bottomrule +% \end{tabular} +% \end{minipage}\nobreak\quad +% \begin{minipage}[t]{.5\linewidth} +% \small\centering +% \caption{\opt{afterskip} 选项的默认设置} +% \label{tab:afterskip-default} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part (article) & |3ex| \\ +% part (beamer) & |0pt| \\ +% part & |0pt plus 1fil| \\ +% chapter & |40pt| \\ +% section (beamer) & |0pt| \\ +% section & |2.3ex plus .2ex| \\ +% subsection (beamer) & |0pt| \\ +% subsection & |1.5ex plus .2ex| \\ +% subsubsection & |1.5ex plus .2ex| \\ +% paragraph & |1em| \\ +% \qquad(sub3section) & |1ex plus .2ex| \\ +% \qquad(sub4section) & 同上 \\ +% subparagraph & |1em| \\ +% \qquad(sub4section) & |1ex plus .2ex| \\ +% \bottomrule +% \end{tabular} +% \end{minipage} +% \end{table} +% % \begin{function}[EXP,added=2016-06-03]{.../fixskip} % \begin{syntax} % fixskip = \TFF % \end{syntax} -% 默认情况下,\cls{article}、\cls{book} 和 \cls{report} 类的标题与正文的距离除了由 -% \opt{beforeskip} 和 \opt{afterskip} 选项设置的垂直间距外,还会有一些多余的间距。 -% \opt{fixskip} 选项用于抑制这些多余间距。 +% 默认情况下,\cls{article}、\cls{book} 和 \cls{report} 类的标题与正文的距离 +% 除了由 \opt{beforeskip} 和 \opt{afterskip} 选项设置的垂直间距外,还会有 +% 一些多余的间距。\opt{fixskip} 选项用于抑制这些多余间距。该选项默认不开启。 % \end{function} % -% \begin{function}[EXP,added=2016-10-01]{chapter/lofskip, chapter/lotskip} +% \begin{function}[EXP,added=2016-09-19]{.../break, .../break+} % \begin{syntax} -% lofskip = \Arg{弹性间距} -% lotskip = \Arg{弹性间距} +% break = \Arg{格式命令} +% break+= \Arg{格式命令} % \end{syntax} -% \opt{lofskip} 选项控制插图目录(\file{.lof})中,章之间的插图标题的距离。 +% \opt{break} 选项用于控制章节标题与\emph{之前}正文的分隔关系。 +% 一般用于设置是否在标题之前分页或者设置行间罚点。 +% \opt{break+} 用于在已有的格式命令后附加内容。 % -% 同样,\opt{lotskip} 选项控制表格目录(\file{.lot})中,章之间的表格标题的距离。 +% 例如,若当前页剩余高度小于正文高度的一半时,则另起一页输出 +% \tn{section} 标题: +% \begin{ctexexam} +% \usepackage{needspace} +% \ctexset{section/break = \Needspace{.5\textheight}} +% \end{ctexexam} % -% 目前,这两个选项只在 \opt{chapter} 标题下有定义。 -% 他们的默认值,在 \opt{scheme} 选项的不同取值下都为 \SI{10}{pt}。 +% 该选项的默认设置见表~\ref{tab:break-default}。 % \end{function} % -% \begin{function}[EXP,updated=2015-06-27]{.../indent} -% \begin{syntax} -% indent = \Arg{缩进间距} -% \end{syntax} -% \opt{indent} 选项用于设置章节标题本身的首行缩进。 -% -% \opt{indent} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 -% -% 如果 \opt{indent} 的值是以 \texttt{em}、\texttt{ex} 或 \cs{ccwd} 为单位, -% 那么缩进间距的大小是相对于 \opt{format} 中指定的字号大小。 -% -% 例如,设置 \tn{part} 标题缩进三个字、\tn{section} 标题缩进 \SI{20}{pt}: -% \end{function} -% \begin{ctexexam} -% \ctexset{ -% part={ -% format+=\raggedright, -% indent=3\ccwd, -% }, -% section={ -% format=\Large\bfseries, -% indent=20pt, -% } -% } -% \part{首行缩进的标题} -% \noindent 无缩进的正文。 -% \section{首行缩进的标题} -% \noindent 无缩进的正文。 -% \end{ctexexam} -% % \begin{table}[htbp] -% \begin{minipage}[t]{.5\linewidth} -% \small\centering -% \caption{\opt{indent} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part & |0pt| \\ -% chapter & |0pt| \\ -% section & |0pt| \\ -% subsection & |0pt| \\ -% subsubsection & |0pt| \\ -% paragraph & |0pt| \\ -% subparagraph & |\parindent| \\ -% \qquad(sub3section) & |0pt| \\ -% \qquad(sub4section) & 同上 \\ -% \bottomrule -% \end{tabular} -% \end{minipage}% -% \begin{minipage}[t]{.5\linewidth} -% \small\centering -% \caption{\opt{hang} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part & |false| \\ -% chapter & |false| \\ -% section & |true| \\ -% subsection & |true| \\ -% subsubsection & |true| \\ -% paragraph & 无意义 \\ -% \qquad(sub3section) & |true| \\ -% \qquad(sub4section) & |true| \\ -% subparagraph & 无意义 \\ -% \qquad(sub4section) & |true| \\ -% \bottomrule -% \end{tabular} -% \end{minipage}% +% \small\centering +% \caption{\opt{break} 选项的默认设置} +% \label{tab:break-default} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part (article) & |{}| \\ +% part & |\if@openright\cleardoublepage\else\clearpage\fi| \\ +% chapter & 同上 \\ +% section & |\addpenalty{\@secpenalty}| \\ +% subsection & 同上 \\ +% subsubsection & 同上 \\ +% paragraph & 同上 \\ +% subparagraph & 同上 \\ +% \bottomrule +% \end{tabular} % \end{table} % -% \begin{function}[EXP,updated=2019-03-31]{part/hang, chapter/hang, section/hang, -% subsection/hang, subsubsection/hang, paragraph/hang, subparagraph/hang} +% \begin{function}[EXP,added=2015-06-27]{.../afterindent} % \begin{syntax} -% hang = \TF +% afterindent = \TF % \end{syntax} -% \opt{hang} 选项用于设置是否对章节标题实施悬挂缩进(缩进的宽度为名字宽度和 \opt{indent} 选项 -% 设置的宽度之和)。 +% \opt{afterindent} 选项用于设置章节标题后首段的缩进。 % -% 本选项对 \cls{beamer}/\cls{ctexbeamer} 文档类无效。 +% \cls{book} 和 \cls{report} 类的 \tn{part} 标题被单独排在一页之上, +% \opt{afterindent} 选项没有意义。 % 对于 \tn{section} 级以下标题,若设置了 \opt{runin} 选项为 \opt{true}, -% 即标题与随后正文排在同一段,\opt{hang} 选项没有意义。 -% \end{function} +% 即标题与随后正文排在同一段,\opt{afterindent} 选项也就没有了意义。 % -% \begin{function}[EXP,added=2014-03-21]{part/pagestyle, chapter/pagestyle} -% \begin{syntax} -% pagestyle = \Arg{页面格式} -% \end{syntax} -% 设置 \cls{book}/\cls{ctexbook} 或 \cls{report}/\cls{ctexrep} 文档类 -% 中,\tn{part} 与 \tn{chapter} 标题所在页的页面格式(page style)。 +% 该选项的默认设置见表~\ref{tab:afterindent-default}。 % \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{pagestyle} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part (article) & 无效 \\ -% part & |plain| \\ -% chapter & |plain| \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \caption{\opt{afterindent} 选项的默认设置} +% \label{tab:afterindent-default} +% \begin{tabular}{lll} +% \toprule +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ +% \midrule +% part (article) & |true| & |false| \\ +% part & 无效 & 无效 \\ +% chapter & |true| & |false| \\ +% section & |true| & |false| \\ +% subsection & |true| & |false| \\ +% subsubsection & |true| & |false| \\ +% paragraph & |true| & |false| \\ +% subparagraph & |true| & |false| \\ +% \bottomrule +% \end{tabular} % \end{table} % -% \begin{function}[EXP,added=2016-09-19]{.../break, .../break+} +% \subsection{目录、附录相关} +% \label{subsec:sec-toc-appendix} +% +% \begin{function}[EXP,added=2016-10-25]{.../tocline} % \begin{syntax} -% break = \Arg{格式命令} -% break+= \Arg{格式命令} +% tocline = \Arg{格式定义} % \end{syntax} -% \opt{break} 选项用于控制章节标题与之前正文的分隔关系。一般用于设置是否在标题之前分页或者设置行间罚点。 -% -% 带加号的 \opt{break+} 选项则用于在已有格式之后追加新的格式命令。 -% -% \opt{break} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 -% -% 例如,若当前页剩余高度小于正文高度的一半时,则另起一页输出 \tn{section} 标题: -% \begin{ctexexam} -% \usepackage{needspace} -% \ctexset{section/break = \Needspace{.5\textheight}} -% \end{ctexexam} +% \opt{tocline} 选项用于定义章节标题在目录文件(\file{.toc})中的格式。 +% \meta{格式定义}有两个参数:参数 |#1| 是 |part|、|chapter| 等名字, +% 参数 |#2| 是标题内容。该选项的默认设置见表~\ref{tab:tocline-default}。 % \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{break} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part (article) & |{}| \\ -% part & |\if@openright\cleardoublepage\else\clearpage\fi| \\ -% chapter & 同上 \\ -% section & |\addpenalty{\@secpenalty}| \\ -% subsection & 同上 \\ -% subsubsection & 同上 \\ -% paragraph & 同上 \\ -% subparagraph & 同上 \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \caption{\opt{tocline} 选项的默认设置} +% \label{tab:tocline-default} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part & |\CTEXifname{\CTEXthepart\hspace{1em}}{}#2| \\ +% chapter (\opt{chinese}) +% & |\CTEXifname{\protect\numberline{\CTEXthechapter\hspace{.3em}}}{}#2| \\ +% chapter (\opt{plain}) +% & |\CTEXnumberline{#1}#2| \\ +% section & |\CTEXnumberline{#1}#2| \\ +% subsection & 同上 \\ +% subsubsection & 同上 \\ +% paragraph & 同上 \\ +% subparagraph & 同上 \\ +% \bottomrule +% \end{tabular} +% +% \medskip +% \raggedright +% 这里 \tn{CTEXnumberline} 的意义是,若标题 |#1| 没有名字,则不输出 +% |\numberline{\CTEXthe#1}| 等编号: +% \begin{verbatim} +% \CTEXifname{\protect\numberline{\csname CTEXthe#1\endcsname}}{} +% \end{verbatim} +% 其中,\tn{CTEXifname} 的定义见 \ref{subsec:sec-commands}~小节。 % \end{table} % -% \begin{function}[EXP,added=2016-10-25]{.../tocline} +% \begin{function}[EXP,added=2016-10-01]{chapter/lofskip, chapter/lotskip} % \begin{syntax} -% tocline = \Arg{格式定义} +% lofskip = \Arg{弹性间距} +% lotskip = \Arg{弹性间距} % \end{syntax} -% \opt{tocline} 选项用于定义章节标题在目录文件(\file{.toc})中的格式。\meta{格式定义}有两个参数: -% 参数 |#1| 是 |part|、|chapter| 等名字,参数 |#2| 是标题内容。 -% \end{function} -% -% \begin{table}[htbp] -% \small\centering -% \caption{\opt{tocline} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part & |\CTEXifname{\CTEXthepart\hspace{1em}}{}#2| \\ -% chapter (\opt{chinese}) -% & |\CTEXifname{\protect\numberline{\CTEXthechapter\hspace{.3em}}}{}#2| \\ -% chapter (\opt{plain}) -% & |\CTEXnumberline{#1}#2| \\ -% section & |\CTEXnumberline{#1}#2| \\ -% subsection & 同上 \\ -% subsubsection & 同上 \\ -% paragraph & 同上 \\ -% subparagraph & 同上 \\ -% \bottomrule -% \end{tabular} +% \opt{lofskip} 选项控制插图目录(\file{.lof})中,章之间的插图标题的距离。 +% 同样,\opt{lotskip} 选项控制表格目录(\file{.lot})中,章之间的表格标题 +% 的距离。 % -% \medskip -% 其中 \tn{CTEXnumberline} 的意义是若标题 |#1| 没有名字,则不输出 |\numberline{\CTEXthe#1}| -% 等编号: -% \begin{verbatim} -% \CTEXifname{\protect\numberline{\csname CTEXthe#1\endcsname}}{} -% \end{verbatim} -% \end{table} +% 目前,这两个选项只在 \opt{chapter} 标题下有定义。 +% 它们的默认值,在 \opt{scheme} 选项的不同取值下都为 \SI{10}{pt}。 +% \end{function} % % \begin{function}[EXP,added=2015-06-21]{appendix/numbering} % \begin{syntax} % numbering = \TTF % \end{syntax} -% 控制是否对附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article}) -% 进行编号。 -% -% 用法与普通章节 \opt{numbering} 选项类似。 +% 控制是否对附录章(对应 \cls{book} 与 \cls{report})或附录节 +% (对应 \cls{article})进行编号,用法与普通章节对应的 \opt{numbering} +% 选项相同。该选项默认值为 \opt{true}。 % \end{function} % % \begin{function}[EXP,updated=2014-03-08]{appendix/name} @@ -2335,60 +2422,103 @@ Copyright and Licence % name = \{<前名字>,<后名字>\} % name = \Arg{前名字} % \end{syntax} -% 设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article})的 -% 名字。 -% -% 用法与普通章节 \opt{name} 选项类似。 +% 设置附录章(对应 \cls{book} 与 \cls{report})或附录节(对应 \cls{article}) +% 的名字,用法与普通章节对应的 \opt{name} 选项相同。 % % 注意该选项与 \opt{appendixname} 选项(\ref{subs:capname}~节)在意义上有 -% 些重叠,但意义不同。\opt{appendixname} 选项只用来重定义 -% \tn{appendixname},而不管 \tn{appendixname} 如何使用;该选项则决定在章节标 -% 题中输出的名字,可以调用 \tn{appendixname} 设置。 +% 些重叠,但不完全相同。\opt{appendixname} 选项只用来重定义 +% \tn{appendixname},而不管 \tn{appendixname} 如何使用;该选项则决定在章节 +% 标题中输出的名字,可以调用 \tn{appendixname} 设置。 +% +% 该选项的默认设置见表~\ref{tab:appendix-name-default}。 % \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{appendix/name} 选项的默认设置} -% \begin{tabular}{llllll} -% \toprule -% 文档类 & 影响命令 & \opt{scheme = chinese} & 实际定义 -% & \opt{scheme = plain} & 实际定义 \\ -% \midrule -% article & \tn{section} & |{}| & & |{}| & \\ -% book, report & \tn{chapter} & |\appendixname\space| & \verb*|附录 | -% & |\appendixname\space| & \verb*|Appendix | \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \caption{\opt{appendix/name} 选项的默认设置} +% \label{tab:appendix-name-default} +% \begin{tabular}{llllll} +% \toprule +% 文档类 & 影响命令 & \opt{scheme = chinese} & 实际定义 +% & \opt{scheme = plain} & 实际定义 \\ +% \midrule +% article & \tn{section} & |{}| & & |{}| & \\ +% book, report & \tn{chapter} & |\appendixname\space| & \verb*|附录 | +% & |\appendixname\space| & \verb*|Appendix | \\ +% \bottomrule +% \end{tabular} % \end{table} % % \begin{function}[EXP]{appendix/number} % \begin{syntax} % number = \Arg{数字输出命令} % \end{syntax} -% 设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article})编 -% 号的数字输出格式。 -% -% 用法与普通章节的 \opt{number} 选项类似。 -% -% 该选项也同时控制附录章节计数器的交叉引用。 +% 设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article}) +% 编号的数字输出格式,用法与普通章节对应的 \opt{number} 选项相同。 % +% \opt{appendix/number} 选项同时也会控制附录章节计数器的交叉引用。 % 与普通章节的 \opt{number} 选项类似,同样需要注意,该选项不会影响计数器本身 % 的输出,即不影响 \tn{thesection} 或 \tn{thechapter} 的定义。 +% +% 该选项的默认设置见表~\ref{tab:appendix-number-default}。 % \end{function} % % \begin{table}[htbp] -% \small\centering -% \caption{\opt{appendix/number} 选项的默认设置} -% \begin{tabular}{llllll} -% \toprule -% 文档类 & 影响命令 & 默认值 \\ -% \midrule -% article & \tn{section} & |\Alph{section}| \\ -% book, report & \tn{chapter} & |\Alph{chapter}| \\ -% \bottomrule -% \end{tabular} +% \small\centering +% \caption{\opt{appendix/number} 选项的默认设置} +% \label{tab:appendix-number-default} +% \begin{tabular}{llllll} +% \toprule +% 文档类 & 影响命令 & 默认值 \\ +% \midrule +% article & \tn{section} & |\Alph{section}| \\ +% book, report & \tn{chapter} & |\Alph{chapter}| \\ +% \bottomrule +% \end{tabular} % \end{table} % +% \subsection{有关命令} +% \label{subsec:sec-commands} +% +% \CTeX{} 宏集还提供了一些命令(宏),用于存储章节标题格式,或进行一些条件判断。 +% +% \begin{function}{\CTEXthepart, \CTEXthechapter, \CTEXthesection, +% \CTEXthesubsection, \CTEXthesubsubsection, \CTEXtheparagraph, +% \CTEXthesubparagraph} +% 以 |\CTEXthe| 开头的这组宏给出结合了 \opt{name} 与 \opt{number} 选项的章节 +% 编号输出格式。例如在 \opt{scheme = chinese} 时,默认章编号输出格式就是 +% \tn{CTEXthechapter},形如“第一章”。 +% +% 这组宏在 \CTeX 文档类中将代替 \tn{thechapter} 等宏的作用,在章节中引用本章 +% 节的完整编号。例如用于帮助定义自定义的目录格式、页眉格式等。 +% \end{function} +% +% \begin{function}[added=2016-09-18]{\CTEXifname} +% \begin{syntax} +% \tn{CTEXifname} \Arg{有名字时的内容} \Arg{无名字时的内容} +% \end{syntax} +% \tn{CTEXifname} 会根据当前章节有无名字展开得到不同内容(通常是格式命令)。 +% 由于章节名字总是与编号一起出现,章节有无名字通常也表达为“章节是否编号”。 +% 在 \LaTeX{} 中,后者取决于以下几个方面:章节深度是否不大于计数器 +% |secnumdepth| 的值,章节标题是否使用不带星号的命令。在 \CTeX{} 宏集中, +% 后者还取决于 \opt{.../numbering} 是否为 \opt{true}。 +% +% \tn{CTEXifname} 可用于 \opt{format}, \opt{titleformat}, \opt{aftertitle}, +% \opt{afterskip}, \opt{indent} 这五个选项和 \tn{chapter} 标题 +% \opt{beforeskip} 选项的格式设置之中。也可用于帮助定义自定义的目录格式、 +% 页眉格式等。 +% +% 例如,设置章的标题有名字时左对齐,无名字时居中对齐,并且在标题后画一条横线。 +% \begin{ctexexam} +% \ctexset{ +% chapter/format = \CTEXifname{\raggedright}{\centering}, +% chapter/aftertitle = \par\CTEXifname{}{\hrule}, +% } +% \end{ctexexam} +% \end{function} +% +% \subsection{示例} +% % 我们最后举一个稍微复杂的例子,来看看上述选项的综合应用。 % % \begin{ctexexam}[labelref=exam:miscopt] @@ -2548,18 +2678,18 @@ Copyright and Licence % % \subsection{\LuaLaTeX{} 下替代字体的设置} % -% \begin{function}[added=2014-04-14]{AlternateFont} +% \begin{function}[updated=2020-04-30]{AlternateFont} % \begin{syntax} -% \tn{setCJKfamilyfont} \Arg{family} +% \tn{setCJKfamilyfont} \Arg{family} \Arg{base font name} % \ [ +% \ , % \ AlternateFont = % \ \{ -% \ \Arg{character range_1} \oarg{alternate font features_1} \Arg{alternate font name_1} || -% \ \Arg{character range_2} \oarg{alternate font features_2} \Arg{alternate font name_2} || +% \ \Arg{character range_1} \Arg{alternate font name_1} , +% \ \Arg{character range_2} \Arg{alternate font name_2} \Arg{alternate font features_2} , % \ ...... -% \ \} , -% \ -% \ ] \Arg{base font name} +% \ \} +% \ ] % \end{syntax} % 在设置字体族 \meta{family} 的时候,同时设置该字体族在字符范围 % \meta{character range_n} 内,对应字形的替代字体。 @@ -2567,11 +2697,11 @@ Copyright and Licence % % \begin{function}[added=2014-04-14]{CharRange} % \begin{syntax} -% \tn{setCJKfamilyfont} \Arg{family} +% \tn{setCJKfamilyfont} \Arg{family} \Arg{alternate font name} % \ [ % \ CharRange = \Arg{character range} , % \ -% \ ] \Arg{alternate font name} +% \ ] % \end{syntax} % 只设置字体族 \meta{family} 在字符范围 \meta{character range} 内,对应字形的 % 替代字体。 @@ -2586,7 +2716,7 @@ Copyright and Licence % \setCJKmainfont[CharRange={"6800->"9FFF}, ...]{...} % \end{ctexexam} % -% \begin{function}[EXP,added=2014-04-14]{declarecharrange} +% \begin{function}[EXP,added=2020-04-30]{declarecharrange} % \begin{syntax} % \tn{ctexset} % \ \{ @@ -2605,9 +2735,10 @@ Copyright and Licence % % 在声明字符范围 \meta{name} 的同时,还为 \tn{setCJKmainfont} 等字体设置命令定义 % 了选项 \meta{name},用于设置对应字符的替代字体: -% \begin{quote}\linespread{1}\small\ttfamily -% \meta{name} = \oarg{alternate font features} \Arg{alternate font name} -% \end{quote} +% \begin{syntax} +% \meta{name} = \Arg{alternate font name} +% \meta{name} = \Arg{alternate font name} \Arg{alternate font features} +% \end{syntax} % \meta{name} 选项可以与 \opt{AlternateFont} 共同使用,但不能与 \opt{CharRange} % 一起使用。如果没有给 \meta{name} 设置值,则等价于设置 \opt{CharRange=\meta{name}}, % 即只设置 \meta{name} 对应的字符范围的替代字体。 @@ -2652,7 +2783,7 @@ Copyright and Licence % 例如对于 \TeX{} Live,系统自带的配置文件就在 \TeX{} Live 安装目录下的 % \path{texmf-dist/tex/latex/ctex/config/} 子目录下,可以修改它的副本,保存在 % 本地 TDS 树的 \path{texmf-local/tex/latex/ctex/} 目录下,或者用户 TDS 树的 -% \path{~/.texlive2015/texmf-var/tex/latex/ctex/} 目录下,作为本地/用户专有的 +% \path{~/texmf/tex/latex/ctex/} 目录下,作为本地/用户专有的 % 配置文件。复制配置文件后需要运行 |texhash| 命令使本地配置文件生效。 % % \MiKTeX{} 的配置文件也保存在类似的目录结构中,\MiKTeX{} 管理的 @@ -2668,13 +2799,12 @@ Copyright and Licence % 注释就可以生效。 % % \begin{ctexexam} -% % 系统自带 ctexopts.cfg 注释中的示例语句,固定默认字体集为 windowsnew。 +% % 系统自带 ctexopts.cfg 注释中的示例语句,固定默认字体集为 windows。 % % 该设置可以用在安装了 Windows 字体的非 Windows 系统中。 -% \keys_set:nn { ctex / option } { fontset = windowsnew } +% \ctex_set:nn { option } { fontset = windows } % \end{ctexexam} -% 如上例所示,宏包选项通常使用 \LaTeXiii{} 的 \cs{keys_set:nn} 命令完成键值设置, -% 第一个参数是固定的子模块 |ctex/option|,第二个参数中是用户定义的新的默认宏包 -% 选项。 +% 如上例所示,宏包选项通常使用 \LaTeXiii{} 的 \cs{ctex_set:nn} 命令完成键值设置, +% 第一个参数是固定的子模块 |option|,第二个参数中是用户定义的新的默认宏包选项。 % % \file{ctexopts.cfg} 中的设置将在 \CTeX{} 宏集的开始处,定义过宏包选项之后, % \tn{ProcessKeysOptions} 命令之前生效。最好只使用此配置文件修改宏包默认选项。 @@ -2820,20 +2950,22 @@ Copyright and Licence % % \begin{function}{fntef} % 旧版本的 \opt{fntef} 选项用于统一 \pkg{CCTfntef} 与 \pkg{CJKfntef} 的界面, -% 新版本 \CTeX{} 宏集不再支持 \pkg{CCT},而是直接载入 \pkg{CJKfntef} 或 -% \pkg{xeCJKfntef} 宏包并禁用其彩色设置。该选项是过时选项。 +% 新版本 \CTeX{} 宏集不再支持 \pkg{CCT},也不再自动载入 \pkg{CJKfntef} 或 +% \pkg{xeCJKfntef} 宏包,而仅在其末尾做适当格式调整。 +% +% \opt{fntef} 选项过时,因兼容性保留,功能是根据引擎载入 \pkg{CJKfntef} +% (\pdfTeX{}) 或 \pkg{xeCJKfntef} (\XeTeX{}) 宏包。 % \end{function} % % \begin{function}{\CTEXunderdot, \CTEXunderline, \CTEXunderdblline, -% \CTEXunderwave, \CTEXsout, \CTEXxout, \CTEXfilltwosides} +% \CTEXunderwave, \CTEXsout, \CTEXxout, CTEXfilltwosides} % 在调用 \opt{fntef} 宏包选项的同时,旧版本 \CTeX{} 宏包由于需要支持 \pkg{CCT} % 系统,会将以 |\CJK| 开头的 \tn{CJKunderline} 等宏换名为以 |\CTEX| 开头的 -% \tn{CTEXunderline} 等宏。此功能在新版本的 \CTeX{} 宏集中已失去意义。 -% -% 此外,在 \pdfTeX{} 引擎下,用于设置格式的 \tn{CJKunderdotbasesep} 等宏也被换 -% 名为 \tn{CTEXunderdotbasesep} 等宏。 +% \tn{CTEXunderline} 等宏。此功能在新版本的 \CTeX{} 宏集中已失去意义。此外, +% 在 \pdfTeX{} 引擎下,用于设置格式的 \tn{CJKunderdotbasesep} 等宏也被更名为 +% \tn{CTEXunderdotbasesep} 等宏。 % -% 在新版本中,上述由 \opt{fntef} 衍生的相关宏都成为过时命令。 +% 在新版本中,上述由 \opt{fntef} 衍生的相关命令和环境均被移除。 % \end{function} % % \begin{function}{\CTEXsetfont} @@ -2927,11 +3059,53 @@ Copyright and Licence % 这两个选项已经被删除,相应功能由新的选项 \opt{fixskip} 提供。 % \end{function} % +% \subsection{\CTeX\ 2.5 之前的版本} +% +% \CTeX\ 2.5 有一些比较大的变动。 +% +% \begin{function}[label =]{UTF8, GBK} +% (pdf)\LaTeX{} 格式下,文档编码初始值统一设置成 UTF-8。因此,仍旧使用 GBK +% 编码的文档,需要在文档类或宏包选项中显式指定 \opt{GBK}。 +% \end{function} +% +% \begin{function}[label =]{\CTEXunderdot, \CTEXunderline, \CTEXunderdblline, +% \CTEXunderwave, \CTEXsout, \CTEXxout, CTEXfilltwosides} +% 不再默认载入 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 宏包,同步移除有关命令 +% 和环境。若需使用相关宏包,建议用户使用 \tn{usepackage} 命令主动载入。 +% \end{function} +% +% \begin{function}[label =]{fntef} +% 作为兼容性保留,会视编译引擎载入相应宏包。 +% \end{function} +% +% \begin{function}{windows} +% 不再支持 Windows XP 系统,默认要求 Windows 系统有微软雅黑字体。 +% 建议 Windows XP 系统的用户及时更新操作系统。若一定要在 Windows XP 中使用, +% 请使用 2.5 以前的版本。 +% \end{function} +% +% \begin{function}{windowsold, windowsnew} +% 过时字库选项,作为兼容性保留,功能是载入 \opt{windows} 字库。 +% \end{function} +% +% \begin{function}{ubuntu} +% 改用思源(Noto CJK)和文鼎字库。该字库不再支持 \pdfLaTeX 编译。 +% \end{function} +% +% \begin{function}[label =]{AlternateFont} +% 不再支持将替代字体的可选项放在字体名之前的方括号中, +% 新的语法是将可选项放在字体名之后的花括号之内。 +% \end{function} +% +% 除了以上列出的选项以外,当用户使用 \CTeX{} 系列文档类,且使用 \LaTeX 或 +% \upLaTeX 编译时,若用户没有在文档类选项中显式指定 |dvips|/|dvipdfmx|/|dvisvgm| +% 等驱动选项,则文档类指定默认驱动为 \dvipdfmx。 +% % \section{宏集依赖情况与手工安装方法} % \label{sec:dep-ins} % % 本节介绍 \CTeX{} 宏集的依赖情况,并介绍手工编译安装的具体方法。 -% 通常用户只需参照第 \ref{subsec:easy-ins}~节介绍的方法,使用发行版自带的宏包管理器安装 +% 通常用户只需参照第 \ref{subsec:easy-ins}~节介绍的方法,使用发行版自带的包管理器安装 % 本宏集。 % % \CTeX{} 宏集有两个源文件:\file{ctex.dtx}、\file{ctexpunct.spa}。 @@ -2943,14 +3117,20 @@ Copyright and Licence % 和 \pkg{l3packages} 宏集。 % \item \pkg{indentfirst} 宏包,属于 \pkg{tools} 宏集。 % \item \pkg{everysel} 宏包,属于 \pkg{ms} 宏集。 -% \item \pkg{ulem} 宏包。 % \item \pkg{zhnumber} 宏包。 % \item[\ding{229}] 以上是各种编译方式都必需的依赖项。 % \item \pkg{CJK} 宏集。 % \item \pkg{CJKpunct} 宏包。 % \item \pkg{xCJK2uni} 宏包。 % \item \pkg{zhmetrics} 宏包。 -% \item \pkg{zhmCJK} 宏包,它还依赖 \pkg{oberdiek} 宏集。 +% \item \pkg{zhmCJK} 宏包,它还依赖 +% \begin{itemize} +% \item \pkg{iftex} 宏包。 +% \item \pkg{ltxcmds} 宏包。 +% \item \pkg{kvoptions} 宏包。 +% \item \pkg{kvsetkeys} 宏包。 +% \item \pkg{keyval} 宏包,\pkg{graphics} 宏集。 +% \end{itemize} % \item[\ding{229}] 以上是使用 \pdfLaTeX{} 或 \LaTeX{} + \dvipdfmx{} 的编译方式所需要 % 的依赖项,其中 \pkg{zhmCJK} 是可选的。 % \item \pkg{xeCJK} 宏集,它还依赖 @@ -2958,17 +3138,19 @@ Copyright and Licence % \item \pkg{xtemplate} 宏包,它属于 \pkg{l3packages} 宏集。 % \item \pkg{fontspec} 宏包。 % \end{itemize} -% \item \pkg{environ} 宏包,它还依赖 \pkg{trimspaces} 宏包。 % \item[\ding{229}] 以上是使用 \XeLaTeX{} 编译时的依赖项。 % \item \pkg{luatexja} 宏包,它还依赖 % \begin{itemize} % \item \pkg{adobemapping} 宏包。 -% \item \pkg{lualibs} 宏包。 -% \item \pkg{luaotfload} 宏包。 +% \item \pkg{luaotfload} 宏包,它还依赖 \pkg{lualibs} 宏包。 % \item \pkg{luatexbase} 宏包,它还依赖 \pkg{ctablestack} 宏包。 -% \item \pkg{oberdiek} 宏集。 -% \item \pkg{xkeyval} 宏包。 +% \item \pkg{atbegshi} 宏包。 % \item \pkg{etoolbox} 宏包。 +% \item \pkg{iftex} 宏包。 +% \item \pkg{infwarerr} 宏包。 +% \item \pkg{ltxcmds} 宏包。 +% \item \pkg{pdftexcmds} 宏包。 +% \item \pkg{xkeyval} 宏包。 % \end{itemize} % \item \pkg{fontspec} 宏包。 % \item \pkg{xunicode-addon} 宏包,属于 \pkg{xeCJK} 宏集,它还依赖 @@ -2978,6 +3160,7 @@ Copyright and Licence % \item \pkg{graphics} 宏集。 % \item \pkg{graphics-cfg} 宏包。 % \item \pkg{graphics-def} 宏包。 +% \item \pkg{tipa} 宏包。 % \end{itemize} % \end{itemize} % \item[\ding{229}] 以上是使用 \LuaLaTeX{} 编译时的依赖项。 @@ -3001,7 +3184,7 @@ Copyright and Licence % 中第 3 节的指导。 % % \emph{\CTeX{} 宏集已被 \TeXLive{} 和 \MiKTeX{} 收录,若无特别理由, -% 我们强烈建议用户使用宏包管理器安装本宏集。} +% 我们强烈建议用户使用包管理器安装本宏集。} % % 若要手工安装,请遵循如下步骤: % \begin{enumerate} @@ -3023,9 +3206,12 @@ Copyright and Licence % \item 陈之初 (\email{zhichu.chen@gmail.com}) % \item 李清 (\email{sobenlee@gmail.com}) % \item 黄晨成 (\email{liamhuang0205@gmail.com}) +% \item 曾祥东 (\email{xdzeng96@gmail.com}) +% \item 李泽平 (\email{zepinglee@gmail.com}) +% \item 周宇恺 (\email{muzimuzhi@gmail.com}) +% \item 张瑞熹 (\email{ruixizhang42@gmail.com}) % \end{itemize} % -% 目前比较活跃的开发维护人员是刘海洋、李清和黄晨成。 % % % \begin{thebibliography}{9} @@ -3105,11 +3291,11 @@ Copyright and Licence \msg_new:nnnn { ctex } { l3-too-old } { Support~package~`#1'~too~old. } { - Please~update~an~up~to~date~version~of~the~bundles\\\\ + Please~update~an~up-to-date~version~of~the~bundles\\\\ `l3kernel'~and~`l3packages'\\\\ using~your~TeX~package~manager~or~from~CTAN. } -\@ifpackagelater { expl3 } { 2019/03/05 } { } +\@ifpackagelater { expl3 } { 2020/04/06 } { } { \msg_error:nnn { ctex } { l3-too-old } { expl3 } } %<*class> \@ifpackagelater { l3keys2e } { 2015/12/20 } { } @@ -3138,13 +3324,20 @@ Copyright and Licence % % \end{macrocode} % +% \changes{v2.5}{2020/04/19} +% {处理 \cs{ctex_file_input:n} 在 \pkg{ctexsize} 中未定义的错误。} +% \changes{v2.5}{2020/04/21}{在 \pkg{ctexsize} 也载入 \pkg{fix-cm}。} +% % \begin{macrocode} -%<*class|ctex|ctexheading> +%<*class|ctex|ctexheading|ctexsize> % \end{macrocode} % +% \pkg{ctexsize} 也要载入 \pkg{fix-cm} 包解决传统 cm 字体字号缺失的问题。 % \begin{macrocode} -\RequirePackage { ctexhook , ctexpatch } -%\RequirePackage { fix-cm , everysel } +%\RequirePackage { ctexhook , ctexpatch } +%\RequirePackage { fix-cm } +%<*!ctexsize> +%\RequirePackage { everysel } % \end{macrocode} % % \subsection{内部函数与变量} @@ -3159,10 +3352,28 @@ Copyright and Licence % \end{macrocode} % \end{variable} % +% \begin{macro}[int]{\ctex_define_option:n, +% \ctex_define:n,\ctex_set:n,\ctex_set:nn} +% 在宏包内部使用的键值选项定义、设置命令。 +% \begin{macrocode} +% +\cs_new_protected:Npn \ctex_define_option:n + { \keys_define:nn { ctex / option } } +%<*!ctexsize> +\cs_new_protected:Npn \ctex_define:n + { \keys_define:nn { ctex } } +\cs_new_protected:Npn \ctex_set:n + { \keys_set:nn { ctex } } +\cs_new_protected:Npn \ctex_set:nn #1 + { \keys_set:nn { ctex / #1 } } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[int]{\ctex_file_wrapper:nnn} % 设置文件操作的 \tn{catcode} 环境,参数 |#1| 是设置,|#2| 是文件操作,|#3| 是恢复。 % 默认关闭 \LaTeXiii{} 语法环境,并设置 |@| 的 \tn{catcode} 为 $11$。 % \begin{macrocode} +% \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { \use:x @@ -3184,15 +3395,16 @@ Copyright and Licence % \begin{macro}[int]{\ctex_file_input:n} % 输入文件。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_file_input:n #1 +\cs_new_protected:Npn \ctex_file_input:n #1 { \ctex_file_wrapper:nnn { } { \file_input:n {#1} } { } } +%<*!ctexsize> % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\ctex_scheme_input:n} % 输入 \opt{scheme} 文件。先查找当前文档类下的 \meta{scheme},找不到再查找一般的文件。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_scheme_input:n #1 +\cs_new_protected:Npn \ctex_scheme_input:n #1 { \ctex_file_wrapper:nnn { } @@ -3222,7 +3434,8 @@ Copyright and Licence % \end{variable} % % \begin{macrocode} -% +% +% %<*class|ctex> % \end{macrocode} % @@ -3231,7 +3444,7 @@ Copyright and Licence \msg_new:nnnn { ctex } { package-too-old } { Support~package~`#1'~too~old. } { - Please~update~an~up~to~date~version~of~the~package~`#1'\\ + Please~update~an~up-to-date~version~of~the~package~`#1'\\ using~your~TeX~package~manager~or~from~CTAN. } % \end{macrocode} @@ -3278,12 +3491,10 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \begin{variable}{\l_@@_encoding_tl} -% (pdf)\LaTeX{} 初始化编码为 GBK,其它则是 UTF8。 +% \begin{variable}{\g_@@_encoding_tl} +% 所有引擎下默认编码均设为 UTF-8,初始值为空,\tn{ProcessKeysOptions} 再判断。 % \begin{macrocode} -\tl_new:N \l_@@_encoding_tl -\tl_set:Nx \l_@@_encoding_tl - { \sys_if_engine_pdftex:TF { GBK } { UTF8 } } +\tl_new:N \g_@@_encoding_tl % \end{macrocode} % \end{variable} % @@ -3318,8 +3529,8 @@ Copyright and Licence % \begin{macro}[int]{\ctex_at_end:n} % 区分 \tn{AtEndOfClass} 和 \tn{AtEndOfPackage},虽然它们的意思都是一样的。 % \begin{macrocode} -%\cs_new_protected_nopar:Npn \ctex_at_end:n { \AtEndOfClass } -%\cs_new_protected_nopar:Npn \ctex_at_end:n { \AtEndOfPackage } +%\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfClass } +%\cs_new_protected:Npn \ctex_at_end:n { \AtEndOfPackage } % \end{macrocode} % \end{macro} % @@ -3340,15 +3551,28 @@ Copyright and Licence { Value~`#1'~is~invalid~for~the~key~`\l_keys_key_tl'. } % \end{macrocode} % +% \begin{macro}[int]{\ctex_deprecated_option:nn, +% \ctex_set_deprecated_option:n,\ctex_deprecated_command:Nn} % 对过时选项或命令给出警告。 % \begin{macrocode} +\cs_new_protected:Npn \ctex_deprecated_option:n + { \msg_warning:nnn { ctex } { deprecated-option } } +\cs_new_protected:Npn \ctex_set_deprecated_option:n #1 + { + \ctex_deprecated_option:n { Option~`#1'~is~set. } + \ctex_set:nn { option } {#1} + } +\cs_new_protected:Npn \ctex_deprecated_command:Nn #1#2 + { + \msg_warning:nnxx { ctex } { deprecated-command } + { \token_to_str:N #1 } { \exp_not:n {#2} } + } \msg_new:nnn { ctex } { deprecated-option } - { Option~ `\l_keys_key_tl'~ is~ deprecated.\\ #1 } + { Option~`\l_keys_key_tl'~is~deprecated.\\ #1 } \msg_new:nnn { ctex } { deprecated-command } - { Command~ #1 is~ deprecated.\\ #2 } -\msg_new:nnn { ctex } { deprecated-environment } - { Environment~ `#1'~ is~ deprecated.\\ #2 } + { Command~`#1'~is~deprecated.\\ #2 } % \end{macrocode} +% \end{macro} % % \begin{macrocode} % @@ -3360,7 +3584,7 @@ Copyright and Licence % \begin{macrocode} %<*class|ctex|ctexsize> \int_new:N \g_@@_font_size_int -\int_set:Nn \g_@@_font_size_int { -1 } +\int_gset:Nn \g_@@_font_size_int { -1 } % % \end{macrocode} % \end{variable} @@ -3372,7 +3596,7 @@ Copyright and Licence % % \begin{macrocode} %<*class|style> -\keys_define:nn { ctex / option } +\ctex_define_option:n { % % \end{macrocode} @@ -3392,18 +3616,8 @@ Copyright and Licence % } % %<*class|ctex> - c5size .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { Option~ `zihao=5'~ is~ set. } - \keys_set:nn { ctex / option } { zihao = 5 } - } , - cs4size .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { Option~ `zihao=-4'~ is~ set. } - \keys_set:nn { ctex / option } { zihao = -4 } - } , + c5size .code:n = { \ctex_set_deprecated_option:n { zihao = 5 } } , + cs4size .code:n = { \ctex_set_deprecated_option:n { zihao = -4 } } , c5size .value_forbidden:n = true , cs4size .value_forbidden:n = true , % \end{macrocode} @@ -3451,31 +3665,40 @@ Copyright and Licence % \begin{macrocode} indent .code:n = { - \msg_warning:nnn { ctex } { deprecated-option } + \ctex_deprecated_option:n { - The~ functionality~ has~ been~ removed.\\ - It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ - options.~ + The~functionality~has~been~removed.\\ + It's~better~to~set~the~heading~styles~via~`afterindent'~option. } } , indent .value_forbidden:n = true , noindent .code:n = { - \msg_warning:nnn { ctex } { deprecated-option } + \ctex_deprecated_option:n { - The~ functionality~ has~ been~ removed.\\ - It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ - options. + The~functionality~has~been~removed.\\ + It's~better~to~set~the~heading~styles~via~`afterindent'~option. } } , noindent .value_forbidden:n = true , % \end{macrocode} % \end{macro} % +% \changes{v2.5}{2019/11/10}{所有引擎下默认编码均设为 UTF-8。} +% % \begin{macro}{GBK,UTF8} +% 文档编码,默认为 UTF-8。 % \begin{macrocode} - GBK .code:n = { \tl_set:Nn \l_@@_encoding_tl { GBK } } , - UTF8 .code:n = { \tl_set:Nn \l_@@_encoding_tl { UTF8 } } , + GBK .code:n = + { + \sys_if_engine_pdftex:TF + { \tl_gset:Nn \g_@@_encoding_tl { GBK } } + { + \msg_warning:nn { ctex } { invalid-option } + \tl_gset:Nn \g_@@_encoding_tl { UTF8 } + } + } , + UTF8 .code:n = { \tl_gset:Nn \g_@@_encoding_tl { UTF8 } } , GBK .value_forbidden:n = true , UTF8 .value_forbidden:n = true , % \end{macrocode} @@ -3487,36 +3710,12 @@ Copyright and Licence % % \begin{macro}{fontset} % 初始值为空。若用户未指定,则根据操作系统载入对应字体配置,可以区分 Windows、 -% Mac~OS~X 和其它。 +% macOS 和其他。 % \begin{macrocode} fontset .tl_gset:N = \g_@@_fontset_tl , - nofonts .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { - Option~ `fontset=none'~ is~ set.~ It~ is~ better~ to~ use~ - fontset~ option. - } - \keys_set:nn { ctex / option } { fontset = none } - } , - adobefonts .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { - Option~ `fontset=adobe'~ is~ set.~ It~ is~ better~ to~ use~ - fontset~ option. - } - \keys_set:nn { ctex / option } { fontset = adobe } - } , - winfonts .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { - Option~ `fontset=windows'~ is~ set.~ It~ is~ better~ to~ use~ - fontset~ option. - } - \keys_set:nn { ctex / option } { fontset = windows } - } , + nofonts .code:n = { \ctex_set_deprecated_option:n { fontset = none } } , + adobefonts .code:n = { \ctex_set_deprecated_option:n { fontset = adobe } } , + winfonts .code:n = { \ctex_set_deprecated_option:n { fontset = windows } } , nofonts .value_forbidden:n = true , winfonts .value_forbidden:n = true , adobefonts .value_forbidden:n = true , @@ -3546,11 +3745,7 @@ Copyright and Licence \cs_gset_eq:NN \ctex_zhmap_case:nnn \use_iii:nnn } , nozhmap .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { Option~ `zhmap=false'~ is~ set. } - \keys_set:nn { ctex / option } { zhmap = false } - } , + { \ctex_set_deprecated_option:n { zhmap = false } } , nozhmap .value_forbidden:n = true , % \end{macrocode} % \end{macro} @@ -3564,12 +3759,7 @@ Copyright and Licence punct .tl_set:N = \l_@@_punct_tl , punct .default:n = { quanjiao } , punct .initial:n = { quanjiao } , - nopunct .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { Option~ `punct=plain'~ is~ set. } - \keys_set:nn { ctex / option } { punct = plain } - } , + nopunct .code:n = \ctex_set_deprecated_option:n { punct = plain } , nopunct .value_forbidden:n = true , % \end{macrocode} % \end{macro} @@ -3581,15 +3771,10 @@ Copyright and Licence { true , auto , false } { \exp_args:Nx \ctex_at_end:n - { \keys_set:nn { ctex } { space = \l_keys_choice_tl } } + { \ctex_set:n { space = \l_keys_choice_tl } } } , space .default:n = { true } , - nospace .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { Option~ `space=false'~ is~ set. } - \keys_set:nn { ctex / option } { space = false } - } , + nospace .code:n = { \ctex_deprecated_option:nn { space = false } } , nospace .value_forbidden:n = true , % \end{macrocode} % \end{macro} @@ -3622,6 +3807,7 @@ Copyright and Licence % % \changes{v2.0}{2015/04/15}{新增 \opt{scheme} 选项,并将 \opt{cap} 和 \opt{nocap} % 列为过时选项。} +% % \begin{macro}{scheme} % \begin{macrocode} scheme .tl_set:N = \l_@@_scheme_tl , @@ -3635,25 +3821,18 @@ Copyright and Licence scheme .initial:n = { chinese } , % % \end{macrocode} +% \end{macro} % % \begin{macrocode} % %<*class|ctex> % \end{macrocode} % +% \begin{macro}{cap,nocap} +% \opt{cap} 和 \opt{nocap} 是过时选项。 % \begin{macrocode} - cap .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { Option~ `scheme = chinese' ~ is~ set. } - \keys_set:nn { ctex / option } { scheme = chinese } - } , - nocap .code:n = - { - \msg_warning:nnn { ctex } { deprecated-option } - { Option~ `scheme = plain' ~ is~ set. } - \keys_set:nn { ctex / option } { scheme = plain } - } , + cap .code:n = { \ctex_set_deprecated_option:n { scheme = chinese } } , + nocap .code:n = { \ctex_set_deprecated_option:n { scheme = plain } } , cap .value_forbidden:n = true , nocap .value_forbidden:n = true , % \end{macrocode} @@ -3662,25 +3841,51 @@ Copyright and Licence % \changes{v2.0}{2015/04/20}{\opt{hyperref} 成为过时选项,原选项功能总是打开。} % \changes{v2.0}{2015/04/20}{\opt{fancyhdr} 成为过时选项,原选项功能总是打开。} % \changes{v2.0}{2015/04/20}{\opt{fntef} 成为过时选项,原选项功能总是打开。} -% \begin{macro}{fntef,fancyhdr,hyperref} -% \changes{v2.1}{2015/06/03}{补充定义 \tn{hypersetup}。} -% 这些都是过时的宏包兼容选项,原选项功能总是打开的。 +% +% 以下三项都是过时的兼容选项,它们会载入有关宏包。 +% +% \begin{macro}{fntef} +% \changes{v2.5}{2019/11/10}{仅在该选项启用时会载入 \pkg{CJKfntef} 或 +% \pkg{xeCJKfntef} 宏包。} % \begin{macrocode} - fntef .code:n = + fntef .code:n = { - \msg_warning:nnn { ctex } { deprecated-option } - { `(xe)CJKfntef'~ package~ is~ always~ loaded. } + \sys_if_engine_xetex:TF + { + \ctex_deprecated_option:n { `xeCJKfntef'~package~is~loaded. } + \ctex_at_end:n { \RequirePackage { xeCJKfntef } } + } + { + \sys_if_engine_pdftex:TF + { + \ctex_deprecated_option:n { `CJKfntef'~package~is~loaded. } + \ctex_at_end:n { \RequirePackage { CJKfntef } } + } + { + \ctex_deprecated_option:n + { Furthermore,~option~`fntef'~is~invalid~in~current~mode. } + } + } } , +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{fancyhdr} +% \begin{macrocode} fancyhdr .code:n = { - \msg_warning:nnn { ctex } { deprecated-option } - { `fancyhdr'~ package~ is~ loaded. } - \RequirePackage { fancyhdr } + \ctex_deprecated_option:n { `fancyhdr'~package~is~loaded. } + \ctex_at_end:n { \RequirePackage { fancyhdr } } } , +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{hyperref} +% \changes{v2.1}{2015/06/03}{补充定义 \tn{hypersetup}。} +% \begin{macrocode} hyperref .code:n = { - \msg_warning:nnn { ctex } { deprecated-option } - { `hyperref'~ package~ will~ be~ loaded. } + \ctex_deprecated_option:n { `hyperref'~package~will~be~loaded. } \ctex_at_end:n { \cs_if_exist:NF \hypersetup @@ -3726,7 +3931,7 @@ Copyright and Licence #1 .value_forbidden:n = true , } } -\use:x { \keys_define:nn { ctex / option } { \exp_not:o { \l_@@_tmp_tl } } } +\exp_args:No \ctex_define_option:n { \l_@@_tmp_tl } \tl_clear:N \l_@@_tmp_tl % \end{macrocode} % \end{macro} @@ -3734,7 +3939,7 @@ Copyright and Licence % 将未知选项传给标准文档类。 % \begin{macrocode} %<*class> -\keys_define:nn { ctex / option } +\ctex_define_option:n { unknown .code:n = { \clist_gput_right:No \g_@@_std_options_clist { \CurrentOption } } @@ -3742,28 +3947,44 @@ Copyright and Licence % % \end{macrocode} % +% 载入选项配置文件。 % \begin{macrocode} %\ctex_file_input:n { ctexopts.cfg } % % \end{macrocode} % +% 处理宏包选项。 % \begin{macrocode} %<*class|style> \ProcessKeysOptions { ctex / option } % % \end{macrocode} % +% \pdfLaTeX{} 下,如果没有显式指定编码为 |UTF8|,则给出警告信息。 +% \begin{macrocode} +%<*class|ctex> +\msg_new:nnn { ctex } { pdftex-utf8 } + { UTF8~will~be~used~as~the~default~encoding. } +\tl_if_empty:NT \g_@@_encoding_tl + { + \sys_if_engine_pdftex:T + { \msg_warning:nn { ctex } { pdftex-utf8 } } + \tl_gset:Nn \g_@@_encoding_tl { UTF8 } + } +% +% \end{macrocode} +% % \begin{macrocode} %<*class> % \end{macrocode} % % 五号字使用标准文档类的 |10pt| 字体大小设置,小四号字则使用 |12pt|。 % \begin{macrocode} -\if_case:w \g_@@_font_size_int - \clist_gput_right:Nn \g_@@_std_options_clist { 10pt } -\or: - \clist_gput_right:Nn \g_@@_std_options_clist { 12pt } -\fi: +\int_case:nn { \g_@@_font_size_int } + { + { 0 } { \clist_gput_right:Nn \g_@@_std_options_clist { 10pt } } + { 1 } { \clist_gput_right:Nn \g_@@_std_options_clist { 12pt } } + } % \end{macrocode} % % 使用 \tn{PassOptionsToClass} 是为了预防可能存在的选项冲突。 @@ -3796,19 +4017,71 @@ Copyright and Licence % % \subsection{特定引擎支持与设置} % +% \changes{v2.5}{2020/04/22}{给 \LaTeX 和 \upLaTeX 下的文档类指定驱动为 \dvipdfmx。} +% +% \subsubsection{\pkg{ctexbackend.cfg}} +% +% 对于 \XeLaTeX{}/\pdfLaTeX{}/\LuaLaTeX{} 等默认直接输出 PDF 的编译方式,用户 +% 无需为涉及驱动的宏包指定驱动选项。对于 \LaTeX 和 \upLaTeX{} 等默认不直接输出 PDF 的编译方式, +% 用户则需要指定驱动选项。 +% +% 由于历史遗留问题,在使用 \LaTeX{} 或 \upLaTeX{} 等编译时, +% 大多数涉及驱动的宏包选定的默认输出驱动都是 Dvips。 +% 考虑当前实际使用频率,以及考虑到 \CTeX{} 宏集对中文支持的默认方式, +% 我们在用户使用 \CTeX{} 系列文档类时,将默认的输出驱动改为 \dvipdfmx。 +% +% 具体来说,如果 |dvips|,|dvipdfmx|,|dvisvgm| 等驱动没有在文档类的全局选项中被明确指定, +% 我们就在 \tn{@classoptionslist} 开头加入 |dvipdfmx|。 +% +% 本段代码只在 \cls{ctexart} 等文档类开头载入,不在 \pkg{ctex} 中使用。 +% 并且需要放在 \pkg{expl3} 之前载入,保证它载入正确的 backend 文件。 +% \begin{macrocode} +%<*backend> +\begingroup +\expandafter\ifx\csname Umathchardef\endcsname\relax +\else\expandafter\endgroup\expandafter\endinput\fi + \ifodd + \expandafter\ifx\csname pdfoutput\endcsname\relax + \expandafter\ifx\csname enablecjktoken\endcsname\relax 0\else 1\fi + \else\ifnum\pdfoutput>0 0\else 1\fi\fi\space + \def\x#1{% + \if\relax\detokenize{#1}\relax + \gdef\@classoptionslist{dvipdfmx}% + \else + \let\CTEX@add\@ne + \@tfor\x:={dvips}{dvipdfmx}{dvisvgm}\do{% + \expandafter\in@\expandafter{\expandafter,\x,}{,#1,}% + \ifin@ \let\CTEX@add\tw@ \@break@tfor \fi}% + \ifodd\CTEX@add \gdef\@classoptionslist{dvipdfmx,#1}\fi + \fi} + \expandafter\x\expandafter{\@classoptionslist} + \fi +\endgroup +% +% \end{macrocode} +% % \subsubsection{\pkg{ctex-engine-pdftex.def}} % % \begin{macro}[int]{\ctex_set_zhmap:n} % 设置 \upTeX{} 字体映射,同时作用于 \tn{AtBeginDvi} 与 % \tn{AtBeginShipoutFirst}。该宏对 \pdfTeX{} 和 \upTeX{} 均有用。 +% \tn{AtBeginDvi} 直接将 \tn{special} 保存到盒子中, +% \tn{AtBeginShipoutFirst} 是保存到到宏中,并且不展开参数。 % \begin{macrocode} %<*pdftex|uptex|aptex> -\cs_new_protected_nopar:Npn \ctex_set_zhmap:n #1 - { - \AtBeginDvi {#1} - \ctex_at_end_package:nn { atbegshi } - { \AtBeginShipoutFirst {#1} } - } +\cs_new_protected:Npn \ctex_set_zhmap:n + { \tl_gput_right:Nx \g_@@_zhmap_tl } +\cs_new_protected:Npn \ctex_use_zhmap: + { \tl_use:N \g_@@_zhmap_tl } +\cs_new_protected:Npn \ctex_add_dvi_zhmap: + { \AtBeginDvi { \ctex_use_zhmap: } } +\ctex_after_end_preamble:n { \ctex_add_dvi_zhmap: } +\ctex_at_end_package:nn { atbegshi } + { + \AtBeginShipoutFirst { \ctex_use_zhmap: } + \cs_gset_eq:NN \ctex_add_dvi_zhmap: \prg_do_nothing: + } +\tl_new:N \g_@@_zhmap_tl \@onlypreamble \ctex_set_zhmap:n % % \end{macrocode} @@ -3818,7 +4091,7 @@ Copyright and Licence %<*pdftex> % \end{macrocode} % -% \changes{v2.1}{2015/05/18}{给 \pdfLaTeX{} 下的非 UTF8 编码 CJK 字体族加上 CMap。} +% \changes{v2.1}{2015/05/18}{给 \pdfLaTeX{} 下的非 UTF-8 编码 CJK 字体族加上 CMap。} % % \begin{variable}{\c_@@_cmap_encoding_seq} % 需要加上 CMap 的 CJK 字体编码。 @@ -3831,7 +4104,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_family_cmap:nn} % 在 \tn{DeclareFontFamily} 的 \meta{loading-settings} 中给 CJK 字体族加上 CMap。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_family_cmap:nn #1#2 +\cs_new_protected:Npn \ctex_family_cmap:nn #1#2 { \cs_if_free:cF { #1 + #2 } { @@ -3847,22 +4120,22 @@ Copyright and Licence % \begin{macro}[int]{\ctex_add_cmap:n} % 给 |#1| 编码的 CJK 字体加上 CMap。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_add_cmap:n #1 +\cs_new_protected:Npn \ctex_add_cmap:n #1 { \cs_if_free:NF \CJK@plane { \ctex_add_cmap:cn { @@_add_cmap_ #1 \CJK@plane : } {#1} } } -\cs_new_protected_nopar:Npn \ctex_add_cmap:Nn #1#2 +\cs_new_protected:Npn \ctex_add_cmap:Nn #1#2 { \cs_if_exist:NF #1 { \@@_save_cmap:Nn #1 {#2} } #1 } \cs_generate_variant:Nn \ctex_add_cmap:Nn { c } -\cs_new_protected_nopar:Npn \@@_save_cmap:Nn #1#2 +\cs_new_protected:Npn \@@_save_cmap:Nn #1#2 { - \tl_set:Nx \l_@@_tmp_tl { \str_lower_case:n {#2} \CJK@plane } + \tl_set:Nx \l_@@_tmp_tl { \str_lowercase:n {#2} \CJK@plane } \tex_immediate:D \tex_pdfobj:D stream ~ file { \l_@@_tmp_tl .cmap } - \cs_new_protected_nopar:Npx #1 + \cs_new_protected:Npx #1 { \exp_not:N \tex_pdffontattr:D \exp_not:N \tex_font:D { /ToUnicode ~ \int_use:N \tex_pdflastobj:D \c_space_tl 0 ~ R } @@ -3894,13 +4167,13 @@ Copyright and Licence % 首先检查选项,决定是否载入 \pkg{zhmCJK} 宏包。 % \begin{macrocode} \if_bool:N \g_@@_zhmCJK_bool - \PassOptionsToPackage { encoding = \l_@@_encoding_tl } { zhmCJK } + \PassOptionsToPackage { encoding = \g_@@_encoding_tl } { zhmCJK } \RequirePackage { zhmCJK } % \end{macrocode} % 不载入 \pkg{zhmCJK} 宏包时直接调用 \pkg{CJK} 及相关宏包。 % \begin{macrocode} \else: - \str_if_eq:onTF { \l_@@_encoding_tl } { GBK } + \str_if_eq:onTF { \g_@@_encoding_tl } { GBK } { \RequirePackage { CJK } } { \RequirePackage { CJKutf8 } } \RequirePackage { CJKpunct , CJKspace } @@ -3909,7 +4182,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_load_zhmap:nnnn} % 载入 \pkg{zhmetrics} 的字体映射文件,同时设置 \tn{CJKrmdefault} 等。 % \begin{macrocode} - \cs_new_protected_nopar:Npn \ctex_load_zhmap:nnnn #1#2#3#4 + \cs_new_protected:Npn \ctex_load_zhmap:nnnn #1#2#3#4 { \tl_set:Nn \CJKrmdefault {#1} \tl_set:Nn \CJKsfdefault {#2} @@ -3924,7 +4197,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_zhmap_input:n} % 载入字体映射文件时,确认 |%| 和 |\| 的 \tn{catcode}。 % \begin{macrocode} - \cs_new_protected_nopar:Npn \ctex_zhmap_input:n #1 + \cs_new_protected:Npn \ctex_zhmap_input:n #1 { \ctex_file_wrapper:nnn { @@ -3946,22 +4219,10 @@ Copyright and Licence \tl_if_exist:NF \CJKrmdefault { \tl_new:N \CJKrmdefault } \tl_if_exist:NF \CJKsfdefault { \tl_new:N \CJKsfdefault } \tl_if_exist:NF \CJKttdefault { \tl_new:N \CJKttdefault } - \ctex_preto_cmd:NnnTF \rmfamily { \ExplSyntaxOff } - { \CJKfamily { \CJKrmdefault } } - { } - { \ctex_patch_failure:N \rmfamily } - \ctex_preto_cmd:NnnTF \sffamily { \ExplSyntaxOff } - { \CJKfamily { \CJKsfdefault } } - { } - { \ctex_patch_failure:N \sffamily } - \ctex_preto_cmd:NnnTF \ttfamily { \ExplSyntaxOff } - { \CJKfamily { \CJKttdefault } } - { } - { \ctex_patch_failure:N \ttfamily } - \ctex_preto_cmd:NnnTF \normalfont { \ExplSyntaxOff } - { \CJKfamily { \CJKfamilydefault } } - { \cs_set_eq:NN \reset@font \normalfont } - { \ctex_patch_failure:N \normalfont } + \g@addto@macro \@rmfamilyhook { \CJKfamily { \CJKrmdefault } } + \g@addto@macro \@sffamilyhook { \CJKfamily { \CJKsfdefault } } + \g@addto@macro \@ttfamilyhook { \CJKfamily { \CJKttdefault } } + \g@addto@macro \@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } } % \end{macrocode} % % \pkg{zhmCJK} 判断结束。 @@ -3975,7 +4236,7 @@ Copyright and Licence % \tn{CJK@loadEncoding})。因此需要确保载入 \file{.enc} 和 \file{.bdg} 文件时, % |^| 的 \tn{catcode} 为 $7$。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_CJK_input:n #1 +\cs_new_protected:Npn \ctex_CJK_input:n #1 { \ctex_file_wrapper:nnn { @@ -4002,7 +4263,7 @@ Copyright and Licence % 我们在这里给出 \tn{CJK@surr} 的一个不依赖 \tn{uppercase} 的实现。 % \begin{macrocode} \if_cs_exist:N \CJK@surr - \cs_new_protected_nopar:Npn \ctex_plane_to_utfxvibe:Nn #1#2 + \cs_new_protected:Npn \ctex_plane_to_utfxvibe:Nn #1#2 { \tl_set:Nx \l_@@_tmp_tl {#2} \int_set:Nn \l_@@_tmp_int @@ -4039,14 +4300,14 @@ Copyright and Licence \ctex_at_end_preamble:n { \ctex_update_default_family: } % \end{macrocode} % -% 启用中文字符功能。\texttt{GBK} 编码时,将汉字的首字节设置为活动字符,并对这些 -% 字符初始化;\texttt{UTF8} 编码时,上游宏包已经处理好。 +% 启用中文字符功能。\opt{GBK} 编码时,将汉字的首字节设置为活动字符,并对这些 +% 字符初始化;\opt{UTF8} 编码时,上游宏包已经处理好。 % \tn{CJK@makeActive} 应该先于 \file{ctex-name-gbk.cfg} 等文件的载入。 % 注意 \tn{CJK@loadBinding} 需要调用补丁后的 \tn{CJK@input}。使用 % \pkg{zhmCJK} 时,此功能已经被启用。 % \begin{macrocode} \reverse_if:N \if_bool:N \g_@@_zhmCJK_bool - \str_if_eq:onF { \l_@@_encoding_tl } { UTF8 } + \str_if_eq:onF { \g_@@_encoding_tl } { UTF8 } { \CJK@makeActive \CJK@loadBinding { standard } @@ -4087,7 +4348,7 @@ Copyright and Licence \exp_args:Nx \ctex_at_end_preamble:n { \exp_not:N \CJK@envStart - { } { \l_@@_encoding_tl } { \exp_not:N \CJKfamilydefault } + { } { \g_@@_encoding_tl } { \exp_not:N \CJKfamilydefault } \exp_not:N \CJKtilde } % \end{macrocode} @@ -4098,14 +4359,9 @@ Copyright and Licence % \end{macrocode} % % \begin{macro}[int]{\ctex_auto_ignorespaces:} -% 关闭名字空间,保存 \tn{CJK@@ignorespaces} 的定义,方便使用。 -% \begin{macrocode} -%<@@=> -\cs_new_eq:NN \ctex_auto_ignorespaces: \CJK@@ignorespaces -% \end{macrocode} -% 恢复名字空间,要把它放在一个 \env{macrocode} 环境中,\cls{l3doc} 才能正确工作。 +% 保存 \tn{CJK@@ignorespaces} 的定义,方便使用。 % \begin{macrocode} -%<@@=ctex> +\cs_new_eq:NN \ctex_auto_ignorespaces: \CJK@@@@ignorespaces % \end{macrocode} % \end{macro} % @@ -4113,13 +4369,13 @@ Copyright and Licence % 设置忽略空格的的方式。根据 \opt{space} 选项的值重定义 \tn{CJK@ignorespaces}, % 并保存起来供 \tn{CJKhook} 备用。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ignorespaces_case:N #1 +\cs_new_protected:Npn \ctex_ignorespaces_case:N #1 { - \cs_set_protected_nopar:Npn \ctex_set_ignorespaces: + \cs_set_protected:Npn \ctex_set_ignorespaces: { \cs_set_eq:NN \CJK@ignorespaces #1 } \ctex_set_ignorespaces: } -\cs_new_protected_nopar:Npn \ctex_set_ignorespaces: +\cs_new_protected:Npn \ctex_set_ignorespaces: { \cs_set_eq:NN \CJK@ignorespaces \ctex_auto_ignorespaces: } % \end{macrocode} % \end{macro} @@ -4136,7 +4392,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_punct_set:n} % 设置 CJK 族对应到实际的字体。|#1| 是 \opt{fontset} 的名字。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_punct_set:n #1 +\cs_new_protected:Npn \ctex_punct_set:n #1 { \clist_map_inline:Nn \c_@@_punct_family_clist { @@ -4159,7 +4415,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_punct_map_family:nn} % CJK 族 |#1| 使用族 |#2| 的边界信息。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_punct_map_family:nn #1#2 +\cs_new_protected:Npn \ctex_punct_map_family:nn #1#2 { \cs_if_free:cF { CJKpunct@ #2 @spaces } { \cs_set_eq:cc { CJKpunct@ #1 @spaces } { CJKpunct@ #2 @spaces } } @@ -4170,7 +4426,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_punct_map_bfseries:nn} % CJK 族 |#1| 的 \tn{bfseries} 使用族 |#2| 的边界信息。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_punct_map_bfseries:nn #1#2 +\cs_new_protected:Npn \ctex_punct_map_bfseries:nn #1#2 { \clist_map_inline:nn {#1} { @@ -4178,7 +4434,7 @@ Copyright and Licence \ctex_punct_map_series:nnn { ##1 } { bx } {#2} } } -\cs_new_protected_nopar:Npn \ctex_punct_map_series:nnn #1#2#3 +\cs_new_protected:Npn \ctex_punct_map_series:nnn #1#2#3 { \CJKpunctmapfamily { C19 } {#1} {#2} { m } {#3} \CJKpunctmapfamily { C19 } {#1} {#2} { it } {#3} @@ -4193,7 +4449,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_punct_map_itshape:nn} % CJK 族 |#1| 的 \tn{itshape} 使用族 |#2| 的边界信息。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_punct_map_itshape:nn #1#2 +\cs_new_protected:Npn \ctex_punct_map_itshape:nn #1#2 { \CJKpunctmapfamily { C19 } {#1} { m } { it } {#2} \CJKpunctmapfamily { C19 } {#1} { b } { it } {#2} @@ -4208,7 +4464,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_punct_space:nn,\ctexspadef} % 定义标点的边界信息。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_punct_space:nn #1#2 +\cs_new_protected:Npn \ctex_punct_space:nn #1#2 { \tl_const:cn { c_@@_ #1 _punct_spaces_tl } {#2} } \cs_new_eq:NN \ctexspadef \ctex_punct_space:nn % \end{macrocode} @@ -4259,6 +4515,7 @@ Copyright and Licence % % \changes{v2.0}{2014/03/08}{通过 \pkg{LuaTeX-ja} 宏包支持 \LuaLaTeX。} % \changes{v2.3}{2015/09/25}{更新 \pkg{LuaTeX-ja} 支持(20150922.0)。} +% \changes{v2.5}{2020/04/18}{更新 \pkg{LuaTeX-ja} 支持(20200412.0)。} % % \pkg{LuaTeX-ja} 为了兼容 p\LaTeX 的使用习惯,对 \LaTeXe 的 \pkg{NFSS} 作了不少 % 修改和扩充,这对于简体中文用户来说不是必要的。我们在这里禁用它。 @@ -4275,13 +4532,13 @@ Copyright and Licence % % \begin{macrocode} \RequirePackage { luatexja } -\@ifpackagelater { luatexja } { 2015/09/21 } { } +\@ifpackagelater { luatexja } { 2020/04/12 } { } { \msg_error:nnn { ctex } { package-too-old } { luatexja } } % \end{macrocode} % % \begin{macrocode} \RequirePackage { fontspec } -\@ifpackagelater { fontspec } { 2014/05/25 } { } +\@ifpackagelater { fontspec } { 2020/02/21 } { } { \msg_error:nnn { ctex } { package-too-old } { fontspec } } % \end{macrocode} % @@ -4300,19 +4557,20 @@ Copyright and Licence \ltjdefcharrange{1}{"80-"36F, "1E00-"1EFF} \ltjdefcharrange{2}{"370-"4FF, "1F00-"1FFF} \ltjdefcharrange{3}{% - "2000-"206F, "2070-"243F, "2460-"24FF, "2500-"27BF, "2900-"29FF, - "2B00-"2BFF} + "2000-"243F, "2460-"24FF, "2500-"27BF, "2900-"29FF, "2B00-"2BFF} \ltjdefcharrange{4}{% "500-"10FF, "1200-"1DFF, "2440-"245F, "27C0-"28FF, "2A00-"2AFF, - "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A82F, "A840-"ABFF, "FB00-"FE0F, - "FE20-"FE2F, "FE70-"FEFF, "10000-"1FFFF, "E000-"F8FF} % non-Japanese + "2C00-"2E7F, "4DC0-"4DFF, "A4D0-"A95F, "A980-"ABFF, "E000-"F8FF, + "FB00-"FE0F, "FE20-"FE2F, "FE70-"FEFF, "10000-"1AFFF, "1B170-"1F0FF, + "1F300-"1FFFF, "2000-"206F} \ltjdefcharrange{5}{"D800-"DFFF, "E0000-"E00FF, "E01F0-"10FFFF} \ltjdefcharrange{6}{% "2E80-"2EFF, "3000-"30FF, "3190-"319F, "31F0-"4DBF, - "4E00-"9FFF, "F900-"FAFF, "FE10-"FE6F, "20000-"2FFFF, "E0100-"E01EF} + "4E00-"9FFF, "F900-"FAFF, "FE10-"FE1F, "FE30-"FE6F, "FF00-"FFEF, + "1B000-"1B16F, "1F100-"1F2FF, "20000-"3FFFF, "E0100-"E01EF} \ltjdefcharrange{7}{% - "1100-"11FF, "2F00-"2FFF, "3100-"31EF, "A000-"A4CF, - "A830-"A83F, "AC00-"D7FF} + "1100-"11FF, "2F00-"2FFF, "3100-"318F, "31A0-"31EF, "A000-"A4CF, + "A960-"A97F, "AC00-"D7FF} \ltjdefcharrange{8}{"A7, "A8, "B0, "B1, "B4, "B6, "D7, "F7} % \end{macrocode} % 将引号、破折号等中西文公用的标点符号归入字符范围 9,将他们设置为 JAchar。 @@ -4358,56 +4616,202 @@ Copyright and Licence % 字符是 ALchar 类。我们这里用 \pkg{xunicode-addon} 来处理 \pkg{xunicode}。 % \begin{macrocode} \RequirePackage { xunicode-addon } -\AtBeginUTFCommand +\AtBeginUTFCommand { \CTEX@beginallalchar } +\AtEndUTFCommand { \CTEX@endallalchar } +\cs_new_protected:Npn \CTEX@beginallalchar { \group_begin: - \lua_now:e { tex.globaldefs = 0 } - \ltj@allalchar + \ctex_ltj_zero_globaldefs: + \ltj@allalchar } -\AtEndUTFCommand { \group_end: } +\cs_new_protected:Npn \CTEX@endallalchar + { \group_end: } % \end{macrocode} % % \changes{v2.4.2}{2016/05/15}{恢复 \pkg{luatexja} 对 \tn{emshape} 和 % \tn{eminnershape} 的重定义。} % \changes{v2.4.3}{2016/08/26}{简化 \pkg{fontspec} 补丁。} -% \begin{macro}[int]{\fontspec_visible_space:} -% 我们不使用 \pkg{luatexja} 对 \pkg{fontspec} 的补丁,直接处理。 +% \changes{v2.5}{2020/04/18}{删除 \pkg{fontspec} 补丁。} +% +% 对 \pkg{listings} 的补丁是让代码环境支持 JAchar 类。 % \begin{macrocode} -\cs_set_protected:Npn \fontspec_visible_space: - { - \tex_iffontchar:D \tex_font:D "2423 \exp_stop_f: - \ltjalchar "2423 \exp_stop_f: - \else: - \fontspec_visible_space_fallback: - \fi: - } +\ctex_at_end_package:nn { listings } + { \RequirePackage { lltjp-listings } } % \end{macrocode} -% \end{macro} % -% 对 \pkg{listings} 的补丁是让代码环境支持 JAchar 类。\pkg{LuaTeX-ja} 的补丁会将 -% 代码目录标题改为日文,我们不需要。 +% \paragraph{\pkg{Lua} 函数} +% +% 直接用 |token.set_lua| 定义,不是传统意义上的 \TeX \ 宏。 % \begin{macrocode} -\ctex_at_end_package:nn { listings } +\group_begin: +\char_set_catcode_space:n { 32 } +\lua_now:e { - \use:x - { - \exp_not:N \RequirePackage { lltjp-listings } - \tl_set:Nn \exp_not:N \lstlistingname - { \exp_not:o { \lstlistingname } } - \tl_set:Nn \exp_not:N \lstlistlistingname - { \exp_not:o { \lstlistlistingname } } - } + local func = lua.get_functions_table() + local ltjfont = luatexja.jfont + local getattribute = tex.getattribute + local set_lua = token.set_lua + local scan_int, scan_arg = token.scan_int, token.scan_argument + local new_luafunction = luatexbase.new_luafunction +% \end{macrocode} +% \begin{macro}{\ctex_ltj_add_kyenc:n} +% 保存 jfont 的编码,用于判断。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = ltjfont.add_kyenc_list + set_lua("ctex_ltj_add_kyenc:n", id, "global", "protected") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ctex_ltj_is_kenc:n} +% 判断编码是否属于 jfont。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = ltjfont.is_kenc + set_lua("ctex_ltj_is_kenc:n", id, "global") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ctex_ltj_patch_external_font:n} +% 若对字体的定义完全相同,则它们有相同的 \texttt{font.id}。因此如果字形是由 +% \textsf{NFSS} 的替换机制定义的,它们就有相同的 \texttt{font.id}。 +% |print_aftl_address| 函数的定义是 +% \begin{verbatim} +% function luatexja.jfont.print_aftl_address() +% return ';ltjaltfont' .. tostring(aftl_base):sub(8) +% end +% \end{verbatim} +% 主要目的是,如果当前字形有替代字体,则往字形的定义中加入一些标志,确保 +% \texttt{font.id} 唯一。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = function () + local s = scan_arg() + local is_braced, is_quoted + if s:sub(1,1) == '{' and s:sub(-1)=='}' then + is_braced = true; s = s:sub(2,-2) + end + if s:sub(1,1) == '"' and s:sub(-1) == '"' then + is_quoted = true; s = s:sub(2,-2) + end + s = s .. ltjfont.print_aftl_address() + if is_braced then s = '{'..s..'}' + elseif is_quoted then s = '"'..s..'"' + end + tex.sprint(-2, s) + end + set_lua("ctex_ltj_patch_external_font:n", id, "global") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ctex_ltj_use_jfont:} +% 使用 jfont,确保当前的 \tn{font} 是 jfont。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = function () + font.current(getattribute("ltj@curjfnt")) + end + set_lua("ctex_ltj_use_jfont:", id, "global", "protected") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ctex_ltj_set_alt_font:nnnn} +% |#1| 和 |#2| 分别是字符区间的首末,|#3| 是基础字体,|#4| 是替代字体。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = function () + local b = tonumber(scan_arg()) + local e = tonumber(scan_arg()) + local alt = scan_arg() + local base = scan_arg() + ltjfont.set_alt_font_latex(b, e, alt, base) + end + set_lua("ctex_ltj_set_alt_font:nnnn", id, "global", "protected") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ctex_ltj_clear_alt_font:n} +% 清除 |#1| 的替代字体。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = function () + local base = scan_arg() + ltjfont.clear_alt_font_latex(base) + end + set_lua("ctex_ltj_clear_alt_font:n", id, "global", "protected") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ctex_ltj_pickup_alt_font:nn} +% 定义 |#1| 的替代字体,|#2| 是字体大小。\\ +% 会在内部执行 \tn{ltj@pickup@altfont@auxy} 和 \tn{ltj@pickup@altfont@copy}。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = function () + local base = scan_arg() + local size = scan_arg() + ltjfont.output_alt_font_cmd("y", base) + ltjfont.pickup_alt_font_a(size) + end + set_lua("ctex_ltj_pickup_alt_font:nn", id, "global", "protected") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@@_pickup_alt_font:Nn} +% |#1| 是 \texttt{font.id},|#2| 是字体名称。 +% 在 \tn{ltj@pickup@altfont@copy} 之中使用。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = function () + local num = scan_int() + local base = scan_arg() + ltjfont.pickup_alt_font_b(num, base) + end + set_lua("@@_pickup_alt_font:Nn", id, "global", "protected") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\@@_if_alt_set:nT} +% 判断是否存在替代字体。会设置变量 |aftl_base| 和返回 \tn{@firstofone} 或 \tn{@gobble}。 +% \begin{verbatim} +% function luatexja.jfont.does_alt_set(bbase) +% aftl_base = alt_font_table_latex[bbase] +% tex.sprint(cat_lp, aftl_base and '\\@firstofone' or '\\@gobble') +% end +% \end{verbatim} +% \pkg{luatexja} 20200412.0 以后的定义为: +% \begin{verbatim} +% function luatexja.jfont.does_alt_set() +% aftl_base = alt_font_table_latex[scan_arg()] +% tex.sprint(cat_lp, aftl_base and '\\@firstofone' or '\\@gobble') +% end +% \end{verbatim} +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = \LuaTeXjaversion > 20200412.0 + and ltjfont.does_alt_set + or function () + local base = scan_arg() + ltjfont.does_alt_set(base) + end + set_lua("@@_if_alt_set:nT", id, "global") +% \end{macrocode} +% \end{macro} +% \begin{macro}{\ctex_ltj_zero_globaldefs:} +% 设置 \tn{globaldefs} 为 $0$,避免全局设置,应当在分组中使用。 +% 这里通过 Lua 设置,可以不受外部 \TeX\ 环境中的 \tn{globaldefs} 的影响。 +% \begin{macrocode} + local id = new_luafunction("ctex") + func[id] = function () + tex.set("globaldefs", 0) + end + set_lua("ctex_ltj_zero_globaldefs:", id, "global", "protected") } +\group_end: % \end{macrocode} +% \end{macro} % % \paragraph{字体切换方式} % % \begin{macro}[int]{\ctex_ltj_select_font:,\CJK@family} % \tn{CJK@family} 保存的是当前 CJK 实际的字体族名,如果为空表示没有设置过字体。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_select_font: +\cs_new_protected:Npn \ctex_ltj_select_font: { - \cs_if_exist_use:cF { \l_@@_current_font_tl } + \group_begin: \exp_args:NNc \group_end: + \cs_if_exist_use:NF { \l_@@_current_font_tl } { \tl_if_empty:NF \CJK@family { \@@_select_font_aux: } } } \tl_new:N \CJK@family @@ -4421,7 +4825,7 @@ Copyright and Licence % 使用 \tn{pickup@font} 取得字体名称前,总需要先设置 \tn{font@name}。在这里将 % \tn{f@family} 换成 CJK 字体族,并确保编码正确。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_select_font_aux: +\cs_new_protected:Npn \@@_select_font_aux: { \group_begin: \tl_set_eq:NN \f@encoding \CJK@encoding @@ -4440,20 +4844,24 @@ Copyright and Licence \cs_if_exist:cF { \l_@@_current_font_tl } { \@@_select_font_aux: } } -\cs_new_protected_nopar:Npn \@@_push_fontname:n #1 +\cs_new_protected:Npn \@@_push_fontname:n #1 { - \cs_gset_eq:NN \@@_save_fontname:w \font@name + \seq_gpush:No \g_@@_fontname_seq { \font@name } \cs_gset_nopar:Npx \font@name {#1} } -\cs_new_protected_nopar:Npn \@@_pop_fontname: - { \cs_gset_eq:NN \font@name \@@_save_fontname:w } +\cs_new_protected:Npn \@@_pop_fontname: + { + \seq_gpop:NNT \g_@@_fontname_seq \l_@@_tmp_tl + { \cs_gset_eq:NN \font@name \l_@@_tmp_tl } + } +\seq_new:N \g_@@_fontname_seq % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\ctex_ltj_pickup_font:} % 替换 \tn{define@newfont} 内部调用的 \tn{extract@font} 和 \tn{do@subst@correction}。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_pickup_font: +\cs_new_protected:Npn \ctex_ltj_pickup_font: { \exp_after:wN \cs_if_exist:NF \font@name { @@ -4474,11 +4882,18 @@ Copyright and Licence % %%%%%%%% \jfont\CS={...:...;jfm=metric;...}, \globaljfont % \protected\def\jfont#1{% % \afterassignment\ltj@@jfont -% \directlua{luatexja.jfont.jfontdefX(false, 'yoko','\luatexluaescapestring{\noexpand#1}')}} +% \directlua{luatexja.jfont.jfontdefX +% (false, 'yoko','\luatexluaescapestring{\noexpand#1}')}} % \protected\def\globaljfont#1{% % \afterassignment\ltj@@jfont -% \directlua{luatexja.jfont.jfontdefX(true, 'yoko','\luatexluaescapestring{\noexpand#1}')}} -% \def\ltj@@jfont{\directlua{luatexja.jfont.jfontdefY()}} +% \directlua{luatexja.jfont.jfontdefX +% (true, 'yoko','\luatexluaescapestring{\noexpand#1}')}} +% \newluafunction\ltj@@jfont@inner +% \directlua{ +% local t = lua.get_functions_table() +% t[\the\ltj@@jfont@inner] = luatexja.jfont.jfontdefY +% } +% \def\ltj@@jfont{\luafunction\ltj@@jfont@inner} % \end{verbatim} % \texttt{jfontdefX} 函数的作用是把 \tn{CS} 定义为其后的字体,\texttt{jfontdefY} % 的作用是更新 \texttt{JFM} 和记录相关字体信息。最后的工作是: @@ -4505,7 +4920,7 @@ Copyright and Licence % 赋值总是全局的,不会受到分组的影响。 % \begin{macrocode} \font@name - \lua_now:e { font.current(tex.getattribute('ltj@curjfnt')) } + \ctex_ltj_use_jfont: \use:c { \f@encoding + \f@family } \use:c { \curr@fontshape } } @@ -4557,42 +4972,28 @@ Copyright and Licence % \begin{macrocode} \prg_new_conditional:Npnn \ctex_ltj_if_alternate_shape_exist:n #1 { T , F , TF } { - \lua_now:e { luatexja.jfont.does_alt_set ('\lua_escape:e {#1}') } - \prg_return_true: \else: \prg_return_false: \fi: + \@@_if_alt_set:nT {#1} { \prg_return_true: \use_none:n } + \prg_return_false: } % \end{macrocode} % \end{macro} % % \begin{macro}{\@@_patch_external_font:w} -% 若对字体的定义完全相同,则它们有相同的 \texttt{font.id}。因此如果字形是由 -% \textsf{NFSS} 的替换机制定义的,它们就有相同的 \texttt{font.id}。 -% |print_aftl_address| 函数的定义是 -% \begin{verbatim} -% function print_aftl_address() -% tex.sprint(cat_lp, ';ltjaltfont' .. tostring(aftl_base):sub(8)) -% end -% \end{verbatim} -% 主要目的是,如果当前字形有替代字体,则往字形的定义中加入一些标志,确保 -% \texttt{font.id} 唯一。 % \begin{macrocode} -\cs_new_nopar:Npn \@@_patch_external_font:w #1 ~ at - { #1 \lua_now:e { luatexja.jfont.print_aftl_address() } ~ at } +\cs_new:Npn \@@_patch_external_font:w #1 ~ at + { \ctex_ltj_patch_external_font:n {#1} ~ at } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\ctex_ltj_select_alternate_font:} % 在 \tn{selectfont} 中更新替代字体。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_select_alternate_font: +\cs_new_protected:Npn \ctex_ltj_select_alternate_font: { \ctex_ltj_if_alternate_shape_exist:nT { \l_@@_current_shape_tl } { - \lua_now:e - { - luatexja.jfont.output_alt_font_cmd - ('y', '\lua_escape:e { \l_@@_current_shape_tl }') - } - \lua_now:e { luatexja.jfont.pickup_alt_font_a ('\f@size') } + \ctex_ltj_pickup_alt_font:nn + { \l_@@_current_shape_tl } { \f@size } } } \tl_new:N \l_@@_current_shape_tl @@ -4604,12 +5005,12 @@ Copyright and Licence % \begin{macro}[int]{\ltj@pickup@altfont@auxy} % 被用在函数 |output_alt_font_cmd| 中,作用是定义替代字体。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ltj@pickup@altfont@auxy #1 +\cs_new_protected:Npn \ltj@pickup@altfont@auxy #1 { \cs_if_exist:cF { #1/\f@size } { \group_begin: - \use:x { \exp_not:N \split@name #1 / \f@size } \@nil + \use:e { \exp_not:N \split@name #1 / \f@size } \@nil \@@_push_fontname:n { \use:c { \curr@fontshape / \f@size } } \ctex_ltj_pickup_font: \group_end: @@ -4619,32 +5020,20 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \begin{macrocode} -%<@@=> -% \end{macrocode} -% % \begin{macro}[int]{\ltj@pickup@altfont@copy} % 被用在函数 |pickup_alt_font_a| 中。\tn{ltj@@getjfontnumber} 的作用是将字体命令 % |#1| 对应的 \texttt{font.id} 保存到 \tn{ltj@tempcntc} 中。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ltj@pickup@altfont@copy #1#2 +\cs_new_protected:Npn \ltj@pickup@altfont@copy #1#2 { - \ltj@@getjfontnumber #1 - \lua_now:e - { - luatexja.jfont.pickup_alt_font_b - ( \int_use:N \ltj@tempcntc, '\lua_escape:e {#2}' ) - } + \ltj@@@@getjfontnumber #1 + \@@_pickup_alt_font:Nn \ltj@tempcntc {#2} } % \end{macrocode} % \end{macro} % % \paragraph{数学字体族} % -% \begin{macrocode} -%<@@=ctex_ltj> -% \end{macrocode} -% % 以下内容来自 \file{lltjfont.sty},目的是让汉字可以在数学环境中直接使用。 % % \begin{macro}[int]{\ctex_ltj_if_jfont:nTF} @@ -4657,10 +5046,11 @@ Copyright and Licence % \begin{macrocode} \cs_new:Npn \ctex_ltj_if_jfont:nTF #1 { - \lua_now:e - { luatexja.jfont.is_kenc( string.match('\lua_escape:e {#1}', '[^/]+') ) } + \ctex_ltj_is_kenc:n { \@@_ltj_if_jfont:w #1 / \q_stop } \ifin@ \exp_after:wN \use_i:nn \else: \exp_after:wN \use_ii:nn \fi: } +\cs_new:Npn \@@_ltj_if_jfont:w #1 / #2 \q_stop + {#1} % \end{macrocode} % \end{macro} % @@ -4678,24 +5068,20 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \begin{macrocode} -%<@@=> -% \end{macrocode} -% % \begin{macro}[int]{\getanddefine@fonts,\ctex_ltj_get_and_define_fonts:nN} % 在使用的场合,\tn{escapechar} 已经被设置成 $-1$,使用 \cs{token_to_str:N} 就 % 可以得到名字,不必使用 \cs{cs_to_str:N}。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_get_and_define_fonts:nN #1#2 +\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts:nN #1#2 { - \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 } + \exp_args:No \ctex_ltj_if_jfont:nTF { \token_to_str:N #2 } { \ctex_ltj_get_and_define_fonts_ja:nN } { \ctex_ltj_get_and_define_fonts_al:nN } {#1} #2 } \cs_new_eq:NN \ctex_ltj_get_and_define_fonts_al:nN \getanddefine@fonts \cs_set_eq:NN \getanddefine@fonts \ctex_ltj_get_and_define_fonts:nN -\cs_new_protected_nopar:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2 +\cs_new_protected:Npn \ctex_ltj_get_and_define_fonts_ja:nN #1#2 { \tl_gset:Nx \font@name { \use:c { \token_to_str:N #2 / \tf@size } } \ctex_ltj_pickup_font: \tl_set_eq:NN \textfont@name \font@name @@ -4706,22 +5092,18 @@ Copyright and Licence \tl_put_right:Nx \math@fonts { \ltj@setpar@global - \ltj@@set@stackfont #1 , \textfont@name \c_colon_str { MJT } - \ltj@@set@stackfont #1 , \scriptfont@name \c_colon_str { MJS } - \ltj@@set@stackfont #1 , \font@name \c_colon_str { MJSS } + \ltj@@@@set@stackfont #1 , \textfont@name \c_colon_str { MJT } + \ltj@@@@set@stackfont #1 , \scriptfont@name \c_colon_str { MJS } + \ltj@@@@set@stackfont #1 , \font@name \c_colon_str { MJSS } } } % \end{macrocode} % \end{macro} % -% \begin{macrocode} -%<@@=ctex_ltj> -% \end{macrocode} -% % \begin{macro}[int]{\use@mathgroup,\ctex_ltj_use_math_group:Nn} % 在使用 \pkg{unicode-math} 宏包时,\cs{ctex_ltj_math_group_hook:} 将被重定义。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_use_math_group:Nn #1#2 +\cs_new_protected:Npn \ctex_ltj_use_math_group:Nn #1#2 { \mode_if_math:T { @@ -4762,7 +5144,7 @@ Copyright and Licence } { \cs_set_eq:NN \use@mathgroup \ctex_ltj_use_math_group:Nn - \cs_set_protected_nopar:Npn \ctex_ltj_math_group_hook: + \cs_set_protected:Npn \ctex_ltj_math_group_hook: { \__um_switchto_literal: } \ctex_ltj_set_math_letter:NN \__um_sym:nnn @@ -4777,7 +5159,7 @@ Copyright and Licence % \begin{variable}{\l_@@_jfm_tl} % \pkg{LuaTeX-ja} 中与标点格式 \opt{plain} 对应的 \texttt{JFM} 是 \opt{mono}。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_mono_jfm:n #1 +\cs_new_protected:Npn \ctex_mono_jfm:n #1 { \str_if_eq:nnTF {#1} { plain } { \tl_set:Nn \l_@@_jfm_tl { mono } } @@ -4791,7 +5173,6 @@ Copyright and Licence % \end{macro} % % \begin{macro}[int]{\CJK@encoding} -% \begin{macro}{\@@_change_encoding:} % 在 \LaTeX 下,\pkg{LuaTeX-ja} 依赖字体编码来实现特殊设置。例如上述的 % \cs{ctex_ltj_if_jfont:nTF} 就是通过判断编码来实现的,它在设置数学字体时会用到。所以 % 不应该与西文共用 \texttt{EU2}。定义字体族 song 为 \tn{CJK@encoding} 的默认替换 @@ -4799,29 +5180,26 @@ Copyright and Licence % \begin{macrocode} \tl_const:Nn \CJK@encoding { LTJY3 } \DeclareFontEncoding { \CJK@encoding } { } { } -\use:x +\use:e { \exp_not:N \DeclareFontSubstitution - { \CJK@encoding } { song } { \mddefault } { \updefault } + { \CJK@encoding } { song } { \mddefault } { \shapedefault } } -\lua_now:e { luatexja.jfont.add_kyenc_list('\CJK@encoding') } -\cs_new_protected_nopar:Npn \@@_change_encoding: - { \tl_set_eq:NN \g_fontspec_encoding_tl \CJK@encoding } +\ctex_ltj_add_kyenc:n { \CJK@encoding } \DeclareFontFamily { \CJK@encoding } { song } { } -\DeclareFontShape { \CJK@encoding } { song } { \mddefault } { \updefault } +\DeclareFontShape { \CJK@encoding } { song } { \mddefault } { \shapedefault } { <-> psft:SimSun:cid=Adobe-GB1-5;jfm=\l_@@_jfm_tl } { } -\DeclareFontShape { \CJK@encoding } { song } { \bfdefault } { \updefault } +\DeclareFontShape { \CJK@encoding } { song } { \bfdefault } { \shapedefault } { <-> psft:SimHei:cid=Adobe-GB1-5;jfm=\l_@@_jfm_tl } { } \tl_const:Nn \c_@@_math_tl { CJKmath } \DeclareSymbolFont { \c_@@_math_tl } - { \CJK@encoding } { song } { \mddefault } { \updefault } + { \CJK@encoding } { song } { \mddefault } { \shapedefault } \SetSymbolFont { \c_@@_math_tl } { bold } - { \CJK@encoding } { song } { \bfdefault } { \updefault } + { \CJK@encoding } { song } { \bfdefault } { \shapedefault } \int_const:Nn \c_@@_math_fam_int { \use:c { sym \c_@@_math_tl } } \jfam \c_@@_math_fam_int % \end{macrocode} % \end{macro} -% \end{macro} % % 这是 \pkg{luatexja-fontspec} 中新增的一些字体选项。 % \begin{macrocode} @@ -4847,7 +5225,7 @@ Copyright and Licence { \group_begin: \clist_clear:N \l_@@_char_range_clist - \seq_clear:N \l_@@_alternate_seq + \prop_clear:N \l_@@_alternate_prop \tl_set:Nn \l_@@_base_CJKfamily_tl {#1} \keys_set_known:nnN { ctex_ltj / fontspec } {#2} \l_@@_tmp_tl \clist_set:No \l_@@_font_options_clist { \l_@@_tmp_tl } @@ -4864,10 +5242,17 @@ Copyright and Licence } \tl_new:N \l_@@_base_CJKfamily_tl \clist_new:N \l_@@_font_options_clist -\cs_new_protected_nopar:Npn \@@_use_global_options:N #1 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_use_global_options:N} +% 应用默认字体选项,并总是设置 \opt{JFM} 和 \opt{NFSSEncoding} 。 +% \begin{macrocode} +\cs_new_protected:Npn \@@_use_global_options:N #1 { \clist_concat:NNN #1 \g_@@_default_features_clist #1 - \clist_put_left:Nx #1 { JFM = \l_@@_jfm_tl } + \clist_put_left:Nx #1 + { NFSSEncoding = \CJK@encoding , JFM = \l_@@_jfm_tl } } % \end{macrocode} % \end{macro} @@ -4885,7 +5270,7 @@ Copyright and Licence % \begin{macro}{\@@_check_family:n} % 删除重复的定义,清除替代字体的先前设置。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_check_family:n #1 +\cs_new_protected:Npn \@@_check_family:n #1 { \prop_gpop:NnNT \g_@@_family_font_name_prop {#1} \l_@@_tmp_tl { @@ -4911,28 +5296,24 @@ Copyright and Licence % 在设置字体时,实际上并不是马上就定义。而是只保存相关参数,在通过 \tn{CJKfamily} % 第一次使用时才定义。需要注意将编码改为 \tn{CJK@encoding}。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_gset_family_cs:nn #1#2 +\cs_new_protected:Npn \@@_gset_family_cs:nn #1#2 { - \cs_gset_protected_nopar:cpx { \@@_family_csname:n {#1} } + \cs_gset_protected:cpx { \@@_family_csname:n {#1} } { \group_begin: - \@@_change_encoding: \exp_not:n { \cs_set_eq:NN \CJKfamily \use_none:n } - \exp_not:n { \cs_set_eq:NN \CTEX@fontfamily \use_none:n } - \exp_not:n { \fontspec_set_family:Nnn \g_@@_fontspec_family_tl } + \exp_not:n { \fontspec_gset_family:Nnn \g_@@_fontspec_family_tl } { \exp_not:o { \l_@@_font_options_clist } } {#2} \prop_gput:Nno \exp_not:N \g_@@_family_name_prop {#1} { \exp_not:N \g_@@_fontspec_family_tl } - \tl_gset_eq:NN \exp_not:N \g_@@_fontspec_family_tl - \exp_not:N \g_@@_fontspec_family_tl \@@_set_alternate_family:n {#1} \group_end: } } \tl_new:N \l_@@_base_family_tl \tl_new:N \g_@@_fontspec_family_tl -\cs_new_nopar:Npn \@@_family_csname:n #1 { ctex_ltj/family/#1 } -\cs_new_protected_nopar:Npn \@@_set_alternate_family:n #1 +\cs_new:Npn \@@_family_csname:n #1 { ctex_ltj/family/#1 } +\cs_new_protected:Npn \@@_set_alternate_family:n #1 { \tl_set:Nn \l_@@_base_CJKfamily_tl {#1} \tl_set_eq:NN \l_@@_base_family_tl \g_@@_fontspec_family_tl @@ -4948,7 +5329,7 @@ Copyright and Licence % \begin{macrocode} \NewDocumentCommand \CJKfamily { m } { \ctex_ltj_switch_family:x {#1} \tex_ignorespaces:D } -\cs_new_protected_nopar:Npn \ctex_ltj_switch_family:n #1 +\cs_new_protected:Npn \ctex_ltj_switch_family:n #1 { \ctex_ltj_family_if_exist:nNTF {#1} \CJK@family { @@ -4984,7 +5365,7 @@ Copyright and Licence % % \begin{macro}{\@@_family_unknown_warning:n} % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_family_unknown_warning:n #1 +\cs_new_protected:Npn \@@_family_unknown_warning:n #1 { \prop_if_empty:NF \g_@@_family_font_name_prop { @@ -5001,7 +5382,7 @@ Copyright and Licence Unknown~CJK~family~`\@@_msg_family_map:n {#1}'~is~being~ignored.\\ Try~to~use~`\@@_msg_def_family_map:n {#1}'~to~define~it. } -\cs_new_nopar:Npn \@@_msg_def_family_map:n #1 +\cs_new:Npn \@@_msg_def_family_map:n #1 { \str_case_e:nnF {#1} { @@ -5012,7 +5393,7 @@ Copyright and Licence { \token_to_str:N \setCJKfamilyfont \{ #1 \} } [...]\{...\} } -\cs_new_nopar:Npn \@@_msg_family_map:n #1 +\cs_new:Npn \@@_msg_family_map:n #1 { \str_case_e:nnF {#1} { @@ -5027,21 +5408,21 @@ Copyright and Licence % % \begin{macro}[int]{\ctex_ltj_fontspec:nn} % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_fontspec:nn #1#2 +\cs_new_protected:Npn \ctex_ltj_fontspec:nn #1#2 { \prop_get:NnNTF \g_@@_fontspec_prop { CJKfontspec/#1/#2/id } \l_ctex_ltj_family_tl { \ctex_ltj_switch_family:x { \l_ctex_ltj_family_tl } } { \int_gincr:N \g_@@_family_int - \@@_fontspec:xnn + \@@_fontspec:enn { CJKfontspec ( \int_use:N \g_@@_family_int ) } {#1} {#2} } } -\cs_new_protected_nopar:Npn \ctex_ltj_fontspec:xx #1#2 - { \use:x { \ctex_ltj_fontspec:nn {#1} {#2} } } -\cs_new_protected_nopar:Npn \@@_fontspec:nnn #1#2#3 +\cs_new_protected:Npn \ctex_ltj_fontspec:ee #1#2 + { \use:e { \ctex_ltj_fontspec:nn {#1} {#2} } } +\cs_new_protected:Npn \@@_fontspec:nnn #1#2#3 { \bool_if:NT \l_@@_add_alternate_bool { @@ -5061,7 +5442,7 @@ Copyright and Licence \ctex_ltj_set_family:nnn {#1} {#2} {#3} \ctex_ltj_switch_family:n {#1} } -\cs_generate_variant:Nn \@@_fontspec:nnn { x } +\cs_generate_variant:Nn \@@_fontspec:nnn { e } \prop_new:N \g_@@_fontspec_prop % \end{macrocode} % \end{macro} @@ -5069,9 +5450,9 @@ Copyright and Licence % \begin{macro}[int] % {\ctex_ltj_add_font_features:n,\ctex_ltj_add_font_features:nn} % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_add_font_features:n #1 +\cs_new_protected:Npn \ctex_ltj_add_font_features:n #1 { \ctex_ltj_add_font_features:xn { \l_ctex_ltj_family_tl } {#1} } -\cs_new_protected_nopar:Npn \ctex_ltj_add_font_features:nn #1#2 +\cs_new_protected:Npn \ctex_ltj_add_font_features:nn #1#2 { \prop_get:NnNTF \g_@@_family_font_name_prop {#1} \l_@@_tmp_tl @@ -5080,7 +5461,7 @@ Copyright and Licence {#1} \l_@@_font_options_clist \clist_put_right:Nn \l_@@_font_options_clist {#2} \bool_set_true:N \l_@@_add_alternate_bool - \ctex_ltj_fontspec:xx + \ctex_ltj_fontspec:ee { \exp_not:o { \l_@@_font_options_clist } } { \exp_not:o { \l_@@_tmp_tl } } } @@ -5102,16 +5483,16 @@ Copyright and Licence % \begin{macrocode} \cs_new_protected:Npn \@@_pass_args:nnnn #1#2#3#4 { - \IfNoValueTF {#2} + \tl_if_novalue:nTF {#2} { \@@_post_arg:w {#1} {#3} {#4} } { - \use:x { #1 {#2} {#3} } + \use:e { #1 {#2} {#3} } #4 } } \NewDocumentCommand \@@_post_arg:w { m m m O { } } { - \use:x { #1 {#4} {#2} } + \use:e { #1 {#4} {#2} } #3 } % \end{macrocode} @@ -5131,8 +5512,8 @@ Copyright and Licence \NewDocumentCommand \newCJKfontfamily { o m o m } { \tl_set:Nx \l_@@_tmp_tl - { \IfNoValueTF {#1} { \cs_to_str:N #2 } {#1} } - \cs_new_protected_nopar:Npx #2 + { \tl_if_novalue:nTF {#1} { \cs_to_str:N #2 } {#1} } + \cs_new_protected:Npx #2 { \ctex_ltj_switch_family:n { \l_@@_tmp_tl } } \@@_pass_args:nnnn { \ctex_ltj_set_family:nnn { \l_@@_tmp_tl } } {#3} {#4} @@ -5202,36 +5583,15 @@ Copyright and Licence \tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { tt } } % \end{macrocode} % -% \begin{macro}[int]{\fontfamily} -% \begin{macro}[int]{\CTEX@fontfamily} % \changes{v2.4.8}{2017/02/23} % {解决与 \pkg{fontspec} 2017/01/24 v2.5d 的字体族匹配兼容问题。} -% 修改 \tn{fontfamily},使主要 |CJK| 字体族能随西文主要字体更新。 +% 使用 \LaTeXe \ 提供的钩子,使主要 |CJK| 字体族能随西文主要字体更新。 % \begin{macrocode} -\RenewDocumentCommand \fontfamily { m } - { - \tl_set:Nx \f@family {#1} - \CTEX@fontfamily {#1} - } -\cs_new_protected_nopar:Npn \CTEX@fontfamily #1 - { - \str_if_eq:nnTF {#1} { \familydefault } - { \CJKfamily { \CJKfamilydefault } } - { \@@_update_family_aux: } - } -\cs_new_protected_nopar:Npn \@@_update_family_aux: - { - \str_case_e:nn { \f@family } - { - { \rmdefault } { \CJKfamily { \CJKrmdefault } } - { \sfdefault } { \CJKfamily { \CJKsfdefault } } - { \ttdefault } { \CJKfamily { \CJKttdefault } } - { \familydefault } { \CJKfamily { \CJKfamilydefault } } - } - } +\g@addto@macro \@rmfamilyhook { \CJKfamily { \CJKrmdefault } } +\g@addto@macro \@sffamilyhook { \CJKfamily { \CJKsfdefault } } +\g@addto@macro \@ttfamilyhook { \CJKfamily { \CJKttdefault } } +\g@addto@macro \@defaultfamilyhook { \CJKfamily { \CJKfamilydefault } } % \end{macrocode} -% \end{macro} -% \end{macro} % % 在导言区末尾更新 \tn{CJKfamilydefault}。 % \begin{macrocode} @@ -5241,7 +5601,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_ltj_ensure_default_family:} % 在导言区结束确认 \tn{CJKfamilydefault} 确实存在。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_ensure_default_family: +\cs_new_protected:Npn \ctex_ltj_ensure_default_family: { \prop_if_empty:NF \g_@@_family_font_name_prop { @@ -5272,7 +5632,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_ltj_update_mathfont:} % 更新数学字体为实际的字体。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_update_mathfont: +\cs_new_protected:Npn \ctex_ltj_update_mathfont: { \ctex_ltj_family_if_exist:xNTF { \c_@@_math_tl } \l_@@_tmp_tl { \ctex_ltj_update_mathfont:n { \l_@@_tmp_tl } } @@ -5281,20 +5641,20 @@ Copyright and Licence { \ctex_ltj_update_mathfont:n { \l_@@_tmp_tl } } } } -\cs_new_protected_nopar:Npn \ctex_ltj_update_mathfont:n #1 +\cs_new_protected:Npn \ctex_ltj_update_mathfont:n #1 { \tl_const:Nx \c_@@_math_family_tl {#1} \DeclareSymbolFont { \c_@@_math_tl } { \CJK@encoding } - { \c_@@_math_family_tl } { \mddefault } { \updefault } + { \c_@@_math_family_tl } { \mddefault } { \shapedefault } \cs_if_free:cTF - { \CJK@encoding/\c_@@_math_family_tl/\bfdefault/\updefault } + { \CJK@encoding/\c_@@_math_family_tl/\bfdefault/\shapedefault } { \SetSymbolFont { \c_@@_math_tl } { bold } { \CJK@encoding } - { \c_@@_math_family_tl } { \mddefault } { \updefault } + { \c_@@_math_family_tl } { \mddefault } { \shapedefault } } { \SetSymbolFont { \c_@@_math_tl } { bold } { \CJK@encoding } - { \c_@@_math_family_tl } { \bfdefault } { \updefault } + { \c_@@_math_family_tl } { \bfdefault } { \shapedefault } } } % \end{macrocode} @@ -5302,12 +5662,14 @@ Copyright and Licence % % \paragraph{替代字体的设置} % +% \changes{v2.5}{2020/04/30}{重构字体选项 \opt{AlternateFont}。} +% % \begin{macro}{AlternateFont,CharRange} % 设置替代字体的选项。 % \begin{macrocode} \keys_define:nn { ctex_ltj / fontspec } { - AlternateFont .code:n = \ctex_ltj_set_alternate_seq:n {#1} , + AlternateFont .code:n = \ctex_ltj_set_alternate_prop:n {#1} , AlternateFont .value_required:n = true , CharRange .clist_set:N = \l_@@_char_range_clist , CharRange .value_required:n = true @@ -5315,84 +5677,84 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\ctex_ltj_set_alternate_seq:n} -% 我们使用 \verb=||= 作为替代字体序列的分隔标志。它可能被设置为活动字符,为此 -% 需要先“消毒”,同时过滤掉空元素。 +% \begin{macro}[int]{\ctex_ltj_set_alternate_prop:n} +% 保存替代字体序列。 % \begin{macrocode} -\group_begin: - \char_set_catcode_other:N \| - \cs_set:Npn \@@_tmp:w #1 - { - \cs_new_protected:Npn \ctex_ltj_set_alternate_seq:n ##1 - { - \clist_if_empty:NT \l_@@_char_range_clist - { - \tl_set:Nn \l_@@_tmp_tl { ##1 } - \tl_replace_all:Nnn \l_@@_tmp_tl {#1} { || } - \seq_set_split:NnV \l_@@_tmp_seq { || } \l_@@_tmp_tl - \seq_set_filter:NNn \l_@@_tmp_seq \l_@@_tmp_seq - { ! \tl_if_blank_p:n { ####1 } } - \seq_concat:NNN \l_@@_alternate_seq - \l_@@_alternate_seq \l_@@_tmp_seq - } - } - } - \char_set_catcode_active:N \| - \@@_tmp:w { || } -\group_end: -\seq_new:N \l_@@_tmp_seq -\seq_new:N \l_@@_alternate_seq +\cs_new_protected:Npn \ctex_ltj_set_alternate_prop:n #1 + { \clist_map_function:nN {#1} \@@_push_alternate_prop:n } +\cs_new_protected:Npn \@@_push_alternate_prop:n #1 + { + \clist_set:Nx \l_@@_tmp_clist { \tl_head:n {#1} } + \tl_remove_all:Nn \l_@@_tmp_clist { ~ } + \exp_args:No \@@_push_alternate_prop:nn + { \l_@@_tmp_clist } {#1} + } +\cs_new_protected:Npn \@@_push_alternate_prop:nn #1 + { + \prop_remove:Nn \l_@@_alternate_prop {#1} + \prop_put:Nnn \l_@@_alternate_prop {#1} + } +\clist_new:N \l_@@_tmp_clist +\prop_new:N \l_@@_alternate_prop % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\ctex_ltj_set_alternate_family:nnF} % 如果在字体的选项中设置了 \opt{CharRange},则只设置替代字体。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nnF #1#2#3 +\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnF { \clist_if_empty:NTF \l_@@_char_range_clist - { - \@@_check_family:n {#1} - \seq_if_empty:NF \l_@@_alternate_seq - { \ctex_ltj_save_alternate_seq:cn { \@@_alternate_cs:n {#1} } {#2} } - #3 - } - { \ctex_ltj_set_alternate_family:nn {#1} {#2} } + { \@@_set_family_aux:nnn } + { \@@_set_alternate_family_aux:nnn } + } +\cs_new_protected:Npn \@@_set_family_aux:nnn #1#2#3 + { + \@@_check_family:n {#1} + \prop_if_empty:NF \l_@@_alternate_prop + { \ctex_ltj_save_alternate_seq:cn { \@@_alternate_cs:n {#1} } {#2} } + #3 } +\cs_new_protected:Npn \@@_set_alternate_family_aux:nnn #1#2#3 + { \ctex_ltj_set_alternate_family:nn {#1} {#2} } % \end{macrocode} % \end{macro} % -% \begin{macro}[int] -% {\ctex_ltj_save_alternate_seq:Nn,\ctex_ltj_save_alternate_seq:Nnnwn} +% \begin{macro}[int]{\ctex_ltj_save_alternate_seq:Nn} % 保存由 \opt{AlternateFont} 设置的替代字体序列。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_save_alternate_seq:Nn #1#2 +\cs_new_protected:Npn \ctex_ltj_save_alternate_seq:Nn #1#2 { - \seq_map_inline:Nn \l_@@_alternate_seq - { \ctex_ltj_save_alternate_seq:Nnnwnw #1 {#2} ##1 { } \q_stop } + \prop_map_inline:Nn \l_@@_alternate_prop + { \@@_save_alternate_auxi:w ##2 { } \q_mark #1 {#2} } } -\cs_generate_variant:Nn \ctex_ltj_save_alternate_seq:Nn { c } -\NewDocumentCommand \ctex_ltj_save_alternate_seq:Nnnwnw - { m m m +O{ } m u{ \q_stop } } +\cs_new_protected:Npn \@@_save_alternate_auxi:w #1#2# + { + \tl_if_blank:nTF {#2} + { \@@_save_alternate_auxii:w {#1} } + { \@@_save_alternate_auxii:w {#1} {#2} } + } +\cs_new_protected:Npn \@@_save_alternate_auxii:w #1#2#3 #4 \q_mark #5#6 { - \clist_set:Nn \l_@@_char_range_clist {#3} - \clist_set:Nn \l_@@_alternate_options_clist {#4} + \clist_set:Nn \l_@@_char_range_clist {#1} + \clist_set:Nn \l_@@_alternate_options_clist {#3} \@@_use_global_options:N \l_@@_alternate_options_clist - \tl_if_blank:nTF {#5} - { \tl_set:Nn \l_@@_tmp_tl {#2} } + \tl_if_blank:nTF {#2} + { \tl_set:Nn \l_@@_tmp_tl {#6} } { - \tl_set:Nn \l_@@_tmp_tl {#5} - \tl_replace_all:Nnn \l_@@_tmp_tl { * } {#2} + \tl_set:Nx \l_@@_tmp_tl { \tl_trim_spaces:n {#2} } + \tl_replace_all:Nnn \l_@@_tmp_tl { * } {#6} } - \use:x + \use:e { - \ctex_ltj_save_alternate_family:Nnnn \exp_not:N #1 + \ctex_ltj_save_alternate_family:Nnnn \exp_not:N #5 { \exp_not:o { \l_@@_char_range_clist } } { \exp_not:o { \l_@@_alternate_options_clist } } { \exp_not:o { \l_@@_tmp_tl } } } } \clist_new:N \l_@@_alternate_options_clist +\cs_generate_variant:Nn \ctex_ltj_save_alternate_seq:Nn { c } % \end{macrocode} % \end{macro} % @@ -5400,7 +5762,7 @@ Copyright and Licence % 设置选项 \opt{CharRange} 范围内的替代字体。如果已经定义了主字体,我们也马上 % 定义替代字体,否则只保存起来备用。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nn #1#2 +\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nn #1#2 { \@@_update_family_uid:N \l_@@_font_options_clist \@@_use_global_options:N \l_@@_font_options_clist @@ -5409,7 +5771,7 @@ Copyright and Licence { \l_@@_char_range_clist } { \l_@@_font_options_clist } {#2} {#1} } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:Nnnnn #1#2#3#4#5 +\cs_new_protected:Npn \ctex_ltj_set_alternate_family:Nnnnn #1#2#3#4#5 { \prop_get:NnNT \g_@@_family_name_prop {#5} \l_@@_base_family_tl { \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } @@ -5422,10 +5784,10 @@ Copyright and Licence % \begin{macro}[int]{\ctex_ltj_save_alternate_family:Nnnn} % 保存替代字体序列的定义,以备定义主字体时使用。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_save_alternate_family:Nnnn #1#2#3#4 +\cs_new_protected:Npn \ctex_ltj_save_alternate_family:Nnnn #1#2#3#4 { \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } - \cs_gset_protected_nopar:Npx #1 + \cs_gset_protected:Npx #1 { \exp_not:o { #1 \ctex_ltj_set_alternate_family:nnn {#2} {#3} {#4} } } } % \end{macrocode} @@ -5434,10 +5796,9 @@ Copyright and Licence % \begin{macro}[int]{\ctex_ltj_set_alternate_family:nnn} % 实际定义替代字体族。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_family:nnn #1#2#3 +\cs_new_protected:Npn \ctex_ltj_set_alternate_family:nnn #1#2#3 { \group_begin: - \@@_change_encoding: \cs_set_eq:NN \CJKfamily \use_none:n \ctex_ltj_swap_cs:NN \DeclareFontShape@ \ctex_ltj_declare_alternate_shape:nnnnnn @@ -5469,7 +5830,7 @@ Copyright and Licence % \pkg{fontspec} 对 CJK 字体族总是定义新字体。 % \begin{macrocode} \keys_define:nn { fontspec } { LTJFONTUID .code:n = } -\cs_new_protected_nopar:Npn \@@_update_family_uid:N #1 +\cs_new_protected:Npn \@@_update_family_uid:N #1 { \int_gincr:N \g_@@_family_int \clist_put_right:Nx #1 { LTJFONTUID = \int_use:N \g_@@_family_int } @@ -5488,8 +5849,7 @@ Copyright and Licence { \ctex_ltj_declare_alternate_shape:nnnnnn {#1} {#2} {#3} {#4} {#5} {#6} \ctex_ltj_set_alternate_shape:Nnnnnnn \l_@@_char_range_clist - { \l_@@_base_family_tl } {#3} {#4} - { \l_fontspec_family_tl } {#3} {#4} + { \l_@@_base_family_tl } {#3} {#4} {#2} {#3} {#4} } % \end{macrocode} % \end{macro} @@ -5498,7 +5858,7 @@ Copyright and Licence % 与 \pkg{LuaTeX-ja} 的 \tn{DeclareAlternateKanjiFont} 的功能类似,区别是固定编码 % 为 \tn{CJK@encoding}。这个设置总是全局的。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:Nnnnnnn #1#2#3#4#5#6#7 +\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:Nnnnnnn #1#2#3#4#5#6#7 { \clist_map_inline:Nn #1 { @@ -5509,10 +5869,9 @@ Copyright and Licence } { \ctex_ltj_set_alternate_shape:nnn { #2/#3/#4 } { #5/#6/#7 } { ##1 } } } - \@@_save_alternate_shape:cnn + \@@_save_alternate_shape:cn { \@@_alternate_cs:n { clear / \l_@@_base_CJKfamily_tl } } - { luatexja.jfont.clear_alt_font_latex } - { '\lua_escape:e { \CJK@encoding/#2/#3/#4 }' } + { \ctex_ltj_clear_alt_font:n { \CJK@encoding/#2/#3/#4 } } } % \end{macrocode} % \end{macro} @@ -5526,85 +5885,80 @@ Copyright and Licence \NewDocumentCommand \ctex_ltj_set_alternate_shape:nnn { m m > { \SplitArgument { 1 } { -> } } m } { \ctex_ltj_set_alternate_shape:nnnn {#1} {#2} #3 } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:nnnn #1#2#3#4 +\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnnn #1#2#3#4 { - \ctex_ltj_set_alternate_shape:n + \ctex_ltj_set_alternate_shape:e { - \IfNoValueTF {#4} - { \int_eval:n {#3} , \int_eval:n {#3} , } - { - \int_eval:n { \tl_if_blank:nTF {#3} { "80 } {#3} } , - \int_eval:n { \tl_if_blank:nTF {#4} { "10FFFF } {#4} } , - } - '\lua_escape:e { \CJK@encoding/#2 }' , - '\lua_escape:e { \CJK@encoding/#1 }' + \@@_range_normalization:nn {#3} {#4} + { \CJK@encoding / \exp_not:n {#2} } + { \CJK@encoding / \exp_not:n {#1} } } } -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:n #1 +\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:n #1 { - \lua_now:e { luatexja.jfont.set_alt_font_latex ( #1 ) } - \@@_save_alternate_shape:cnn + \ctex_ltj_set_alt_font:nnnn #1 + \@@_save_alternate_shape:cn { \@@_alternate_cs:n { reset / \l_@@_base_CJKfamily_tl } } - { luatexja.jfont.set_alt_font_latex } {#1} + { \ctex_ltj_set_alt_font:nnnn #1 } } +\cs_generate_variant:Nn \ctex_ltj_set_alternate_shape:n { e } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\ctex_ltj_set_alternate_shape:nnN} % 若字符范围预先由 \texttt{declarecharrange} 声明,则可以直接使用。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_set_alternate_shape:nnN #1#2#3 +\cs_new_protected:Npn \ctex_ltj_set_alternate_shape:nnN #1#2#3 { \tl_map_inline:Nn #3 { \ctex_ltj_set_alternate_shape:n { - ##1 , - '\lua_escape:e { \CJK@encoding/#2 }' , - '\lua_escape:e { \CJK@encoding/#1 }' + ##1 + { \CJK@encoding/#2 } + { \CJK@encoding/#1 } } } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_save_alternate_shape:Nnn} +% \begin{macro}{\@@_save_alternate_shape:Nn} % 将实际设置的替换字形保存起来用于清除或恢复。 % 暂时令 \cs{l_@@_base_family_tl} 为 \cs{scan_stop:} 是让它不被展开,使得替换 % 字体的设置可以在 \tn{addCJKfontfeature} 中直接使用。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_save_alternate_shape:Nnn #1#2#3 +\cs_new_protected:Npn \@@_save_alternate_shape:Nn #1#2 { \group_begin: - \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } - \cs_set_eq:NN \l_@@_base_family_tl \scan_stop: - \cs_set_eq:NN \lua_escape:e \scan_stop: - \cs_gset_protected_nopar:Npx #1 - { \exp_not:o {#1} \exp_not:N \lua_now:e { #2 ( #3 ) } } + \cs_if_exist:NF #1 { \cs_set_eq:NN #1 \prg_do_nothing: } + \cs_set_eq:NN \l_@@_base_family_tl \scan_stop: + \cs_gset_protected:Npx #1 { \exp_not:o {#1} #2 } \group_end: } -\cs_generate_variant:Nn \@@_save_alternate_shape:Nnn { c } +\cs_generate_variant:Nn \@@_save_alternate_shape:Nn { c } % \end{macrocode} % \end{macro} % % \begin{macro}{clearalternatefont,resetalternatefont} % 清除和重置操作总是全局的。 % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { clearalternatefont .code:n = - { \clist_map_function:xN {#1} \ctex_ltj_clear_alternate_font:n } , + { \clist_map_function:eN {#1} \ctex_ltj_clear_alternate_font:n } , resetalternatefont .code:n = - { \clist_map_function:xN {#1} \ctex_ltj_reset_alternate_font:n } , + { \clist_map_function:eN {#1} \ctex_ltj_reset_alternate_font:n } , clearalternatefont .default:n = \l_ctex_ltj_family_tl , resetalternatefont .default:n = \l_ctex_ltj_family_tl } -\cs_new_protected_nopar:Npn \ctex_ltj_clear_alternate_font:n #1 +\cs_new_protected:Npn \ctex_ltj_clear_alternate_font:n #1 { \group_begin: \ctex_ltj_family_if_exist:xNTF {#1} \l_@@_base_family_tl { - \cs_if_exist_use:cT { \@@_alternate_cs:n { clear / #1 } } + \cs_if_exist_use:cT + { \@@_alternate_cs:n { clear / #1 } } { \prop_gput:Nno \g_@@_reset_alternate_prop {#1} { \l_@@_base_family_tl } @@ -5615,7 +5969,7 @@ Copyright and Licence { \@@_family_unknown_warning:n {#1} } \group_end: } -\cs_new_protected_nopar:Npn \ctex_ltj_reset_alternate_font:n #1 +\cs_new_protected:Npn \ctex_ltj_reset_alternate_font:n #1 { \group_begin: \prop_gpop:NnNT \g_@@_reset_alternate_prop {#1} \CJK@family @@ -5627,23 +5981,23 @@ Copyright and Licence \group_end: } \prop_new:N \g_@@_reset_alternate_prop -\cs_generate_variant:Nn \clist_map_function:nN { x } +\cs_generate_variant:Nn \clist_map_function:nN { e } % \end{macrocode} % \end{macro} % % \begin{macro}{declarecharrange} % 预先声明字符范围。 % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { - declarecharrange .code:n = \ctex_ltj_declare_char_range:x {#1} , + declarecharrange .code:n = \ctex_ltj_declare_char_range:e {#1} , declarecharrange .value_required:n = true } -\cs_new_protected_nopar:Npn \ctex_ltj_declare_char_range:n #1 +\cs_new_protected:Npn \ctex_ltj_declare_char_range:n #1 { \clist_map_inline:nn {#1} { \@@_declare_char_range:nn ##1 } } -\cs_generate_variant:Nn \ctex_ltj_declare_char_range:n { x } -\cs_new_protected_nopar:Npn \@@_declare_char_range:nn #1#2 - { \use:x { \ctex_ltj_declare_char_range:nn { \tl_trim_spaces:n {#1} } } {#2} } +\cs_generate_variant:Nn \ctex_ltj_declare_char_range:n { e } +\cs_new_protected:Npn \@@_declare_char_range:nn #1 + { \exp_args:Ne \ctex_ltj_declare_char_range:nn { \tl_trim_spaces:n {#1} } } % \end{macrocode} % \end{macro} % @@ -5651,7 +6005,7 @@ Copyright and Licence % \begin{variable}{\g_@@_char_range_prop} % |#1| 是名字,|#2| 是范围。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_declare_char_range:nn #1#2 +\cs_new_protected:Npn \ctex_ltj_declare_char_range:nn #1#2 { \tl_clear:N \l_@@_char_range_tl \clist_map_function:nN {#2} \ctex_ltj_save_char_range:n @@ -5671,25 +6025,32 @@ Copyright and Licence \NewDocumentCommand \ctex_ltj_save_char_range:n { > { \SplitArgument { 1 } { -> } } m } { \ctex_ltj_save_char_range:nn #1 } -\cs_new_protected_nopar:Npn \ctex_ltj_save_char_range:nn #1#2 +\cs_new_protected:Npn \ctex_ltj_save_char_range:nn #1#2 { \tl_put_right:Nx \l_@@_char_range_tl - { { - \IfNoValueTF {#2} - { \int_eval:n {#1} , \int_eval:n {#1} } - { - \int_eval:n { \tl_if_blank:nTF {#1} { "80 } {#1} } , - \int_eval:n { \tl_if_blank:nTF {#2} { "10FFFF } {#2} } - } - } } + { { \@@_range_normalization:nn {#1} {#2} } } + } +\cs_new:Npn \@@_range_normalization:nn #1#2 + { + \tl_if_novalue:nTF {#2} + { + { \int_eval:n {#1} } + { \int_eval:n {#1} } + } + { + { \int_eval:n { \tl_if_blank:nTF {#1} { \c_@@_range_min_int } {#1} } } + { \int_eval:n { \tl_if_blank:nTF {#2} { \c_@@_range_max_int } {#2} } } + } } +\int_const:Nn \c_@@_range_min_int { "80 } +\int_const:Nn \c_@@_range_max_int { \c_max_char_int } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\ctex_ltj_def_char_range_key:n} % 在字体设置选项中定义字符范围键。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_def_char_range_key:n #1 +\cs_new_protected:Npn \ctex_ltj_def_char_range_key:n #1 { \keys_if_exist:nnF { ctex_ltj / fontspec } {#1} { @@ -5706,42 +6067,13 @@ Copyright and Licence \cs_new_protected:Npn \ctex_ltj_char_range_key:nn #1#2 { \tl_if_blank:nTF {#2} - { \tl_set:Nn \l_@@_char_range_clist {#1} } - { - \clist_if_empty:NT \l_@@_char_range_clist - { - \tl_set:Nn \l_@@_tmp_tl { {#1} } - \@@_char_range_parse_feature:w #2 \q_stop - } - } + { \clist_set:Nn \l_@@_char_range_clist {#1} } + { \@@_push_alternate_prop:nn {#1} { {#1} #2 } } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_char_range_parse_feature:w} -% 可以使用加方括号的方式,通过文件名来调用字体。这容易与字体选项混淆。例如,需要 -% 将 |[simsun.ttc]| 设置为 \opt{range} 的主字体,就需要使用 -% |range={{[simsun.ttc]}}| 或者 |[]{[simsun.ttc]}|。下面的目的是,支持直接使用 -% |[simsun.ttc]| 和 |[...][simsun.ttc]|。 -% \begin{macrocode} -\NewDocumentCommand \@@_char_range_parse_feature:w - { +o o u { \q_stop } } - { - \exp_args:NNf \tl_put_right:Nn \l_@@_tmp_tl - { - \IfNoValueTF {#1} { {#3} } - { - \IfNoValueTF {#2} - { \tl_if_blank:nTF {#3} { { [#1] } } { [ {#1} ] {#3} } } - { [ {#1} ] { [#2] } } - } - } - \seq_put_right:No \l_@@_alternate_seq { \l_@@_tmp_tl } - } -% \end{macrocode} -% \end{macro} -% -% \paragraph{其它设置} +% \paragraph{其他设置} % % 在抄录环境中禁用 \opt{autospacing} 和 \opt{autoxspacing}。然而,\pkg{LuaTeX-ja} % 还是会使 JAchar 自动折行。没有看到有简单的禁用折行的办法,可能需要设置所有的 @@ -5768,16 +6100,14 @@ Copyright and Licence { } { \ctex_patch_failure:N \verbatim@font } } -\cs_new_protected_nopar:Npn \CTEX@verbatim@font@hook +\cs_new_protected:Npn \CTEX@verbatim@font@hook { \ltjsetparameter { autospacing = false , autoxspacing = false } } % \end{macrocode} % -% \begin{macro}{\@@italiccorr} +% \begin{macro}{\@@@@italiccorr} % \LaTeX{} 的倾斜校正也要重新定义。 % \begin{macrocode} -%<@@=> -\cs_set_eq:NN \@@italiccorr \/ -%<@@=ctex> +\cs_set_eq:NN \@@@@italiccorr \/ % \end{macrocode} % \end{macro} % @@ -5787,14 +6117,15 @@ Copyright and Licence % \tn{ltjsetkanjiskip} 和 \tn{ltjsetxkanjiskip} 是相应的 \tn{ltjsetparameter} % 的快捷方式,在使用他们时,要注意先使用 \tn{ltj@setpar@global}。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_ltj_set_kanjiskip:N +\cs_new_protected:Npn \ctex_ltj_set_kanjiskip:N { \ltj@setpar@global \ltjsetkanjiskip } -\cs_new_protected_nopar:Npn \ctex_ltj_set_xkanjiskip:N +\cs_new_protected:Npn \ctex_ltj_set_xkanjiskip:N { \ltj@setpar@global \ltjsetxkanjiskip } % \end{macrocode} % \end{macro} % % \begin{macrocode} +%<@@=ctex> % % \end{macrocode} % @@ -5809,37 +6140,17 @@ Copyright and Licence % % 按 \pkg{CJK} 的命名习惯模拟部分命令,并设置默认字体。 % \begin{macrocode} -\tl_set:Nn \CJKrmdefault { zhrm } -\tl_set:Nn \CJKsfdefault { zhsf } -\tl_set:Nn \CJKttdefault { zhtt } -\tl_set:Nn \CJKfamilydefault { \CJKrmdefault } +\tl_if_exist:NF \CJKfamilydefault + { \tl_const:Nn \CJKfamilydefault { \CJKrmdefault } } +\tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { zhrm } } +\tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { zhsf } } +\tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { zhtt } } \tl_set:Nn \kanjifamilydefault { \CJKfamilydefault } -\RenewDocumentCommand \rmfamily { } - { - \not@math@alphabet \rmfamily \mathrm - \romanfamily \rmdefault - \kanjifamily \CJKrmdefault - \selectfont - } -\RenewDocumentCommand \sffamily { } - { - \not@math@alphabet \sffamily \mathsf - \romanfamily \sfdefault - \kanjifamily \CJKsfdefault - \selectfont - } -\RenewDocumentCommand \ttfamily { } - { - \not@math@alphabet \ttfamily \mathtt - \romanfamily \ttdefault - \kanjifamily \CJKttdefault - \selectfont - } +\g@addto@macro \@rmfamilyhook { \kanjifamily { \CJKrmdefault } } +\g@addto@macro \@sffamilyhook { \kanjifamily { \CJKsfdefault } } +\g@addto@macro \@ttfamilyhook { \kanjifamily { \CJKttdefault } } \NewDocumentCommand \CJKfamily { m } - { - \kanjifamily {#1} - \selectfont - } + { \kanjifamily {#1} \selectfont } % \end{macrocode} % % \changes{v2.4.15}{2019/04/05}{将 \upLaTeX 的默认字体由 \texttt{mc} 改为 @@ -5847,9 +6158,9 @@ Copyright and Licence % % 将 \upLaTeX 的默认字体由 |mc| 改为 |zhrm|,并启用 \tn{jfam}。 % \begin{macrocode} -\DeclareErrorKanjiFont{JY2}{zhrm}{m}{n}{10} -\DeclareKanjiSubstitution{JY2}{zhrm}{m}{n} -\DeclareKanjiSubstitution{JT2}{zhrm}{m}{n} +\DeclareErrorKanjiFont {JY2}{zhrm}{m}{n}{10} +\DeclareKanjiSubstitution {JY2}{zhrm}{m}{n} +\DeclareKanjiSubstitution {JT2}{zhrm}{m}{n} \DeclareSymbolFont{mincho}{JY2}{zhrm}{m}{n} \SetSymbolFont{mincho}{bold}{JY2}{zhrm}{bx}{n} \jfam \symmincho @@ -5892,19 +6203,20 @@ Copyright and Licence % 形如 |upzhserif|,不包括表示方向的后缀 |-h| 与 |-v|。粗体字体名为空时不设置该 % 字形。本命令不设置字体映射,需要复用已有的字体映射或另行设置。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_set_upfamily:nnn #1 #2 #3 +\cs_new_protected:Npn \ctex_set_upfamily:nnn #1#2#3 { \DeclareKanjiFamily{JY2}{#1}{} \DeclareKanjiFamily{JT2}{#1}{} \DeclareFontShape{JY2}{#1}{m}{n}{<->~ #2-h}{} \DeclareFontShape{JT2}{#1}{m}{n}{<->~ #2-v}{} - \tl_if_empty:nF { #3 } + \tl_if_empty:nF {#3} { + \DeclareFontShape{JY2}{#1}{b}{n}{<->~ #3-h}{} + \DeclareFontShape{JT2}{#1}{b}{n}{<->~ #3-v}{} \DeclareFontShape{JY2}{#1}{bx}{n}{<->~ #3-h}{} \DeclareFontShape{JT2}{#1}{bx}{n}{<->~ #3-v}{} } } -\@onlypreamble \ctex_set_upfamily:nnn % \end{macrocode} % \end{macro} % @@ -5913,20 +6225,38 @@ Copyright and Licence % 的后缀 |b| 与表示排版方向的后缀 |-h| 与 |-v|。|#2| 与 |#3| 是普通与粗体的实际 % 字体名。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_set_upmap:nnn #1 #2 #3 +\cs_new_protected:Npn \ctex_set_upmap:nnn #1#2#3 { \ctex_set_zhmap:n { - \special{ pdf:mapline~ #1-h~ UniGB-UTF16-H~ #2 } - \special{ pdf:mapline~ #1-v~ UniGB-UTF16-V~ #2 } - \tl_if_empty:nF { #3 } + \special { pdf:mapline~#1-h~UniGB-UTF16-H~#2 } + \special { pdf:mapline~#1-v~UniGB-UTF16-V~#2 } + \tl_if_empty:nF {#3} { - \special{ pdf:mapline~ #1b-h~ UniGB-UTF16-H~ #3 } - \special{ pdf:mapline~ #1b-v~ UniGB-UTF16-V~ #3 } + \special { pdf:mapline~#1b-h~UniGB-UTF16-H~#3 } + \special { pdf:mapline~#1b-v~UniGB-UTF16-V~#3 } + } + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_set_upmap_unicode:nnn} +% 设置 \upTeX{} 字体映射,使用 |unicode| CMap。参数同上。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_set_upmap_unicode:nnn #1#2#3 + { + \ctex_set_zhmap:n + { + \special { pdf:mapline~#1-h~unicode~#2 } + \special { pdf:mapline~#1-v~unicode~#2 } + \tl_if_empty:nF {#3} + { + \special { pdf:mapline~#1b-h~unicode~#3 } + \special { pdf:mapline~#1b-v~unicode~#3 } } } } -\@onlypreamble \ctex_set_upmap:nnn % \end{macrocode} % \end{macro} % @@ -5934,17 +6264,24 @@ Copyright and Licence % 设置 \upTeX{} 基本字体映射,按 \pkg{zhmetrics-uptex} 的定义,依次设置衬线体 % 正、粗、意大利,无衬线体正、粗,等宽体正——共 6 种字体,并分横排及直排。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_set_upfonts:nnnnnn #1 #2 #3 #4 #5 #6 +\cs_new_protected:Npn \ctex_set_upfonts:nnnnnn #1#2#3#4#5#6 { - \ctex_set_upmap:nnn { upserif } { #1 } { #2 } - \ctex_set_upmap:nnn { upserifit } { #3 } {} - \ctex_set_upmap:nnn { upsans } { #4 } { #5 } - \ctex_set_upmap:nnn { upmono } { #6 } {} + \ctex_set_upmap:nnn { upserif } {#1} {#2} + \ctex_set_upmap:nnn { upserifit } {#3} {} + \ctex_set_upmap:nnn { upsans } {#4} {#5} + \ctex_set_upmap:nnn { upmono } {#6} {} } -\@onlypreamble \ctex_set_upfonts:nnnnnn % \end{macrocode} % \end{macro} % +% 以下命令只能在导言区使用。 +% \begin{macrocode} +\@onlypreamble \ctex_set_upfamily:nnn +\@onlypreamble \ctex_set_upmap:nnn +\@onlypreamble \ctex_set_upmap_unicode:nnn +\@onlypreamble \ctex_set_upfonts:nnnnnn +% \end{macrocode} +% % \changes{v2.4.7}{2016/12/27}{依赖 \pkg{pxeverysel} 宏包。} % % \pkg{everysel} 宏包(2011/10/28)未考虑 \upLaTeX{} 对 \tn{selectfont} 的修 @@ -5967,7 +6304,7 @@ Copyright and Licence % 更新 \tn{CJKfamilydefault}。\pkg{xeCJK} 已经有这个功能,不需要再调整。 % \begin{macrocode} %<*pdftex|luatex|uptex|aptex> -\cs_new_protected_nopar:Npn \ctex_update_default_family: +\cs_new_protected:Npn \ctex_update_default_family: { \tl_if_eq:NNT \CJKfamilydefault \l_@@_family_default_init_tl { @@ -6012,90 +6349,9 @@ Copyright and Licence % \end{macrocode} % \end{variable} % -% \subsubsection{操作系统的判断} -% % \changes{v2.0}{2014/04/16}{自动检测操作系统,载入对应的字体配置。} -% -% \begin{macro}[int]{\ctex_detected_platform:} -% 在 \LuaTeX{} 下直接用调用 |os.name| 来判断。 -% \begin{macrocode} -%<*luatex> -\cs_new_protected_nopar:Npn \ctex_detected_platform: - { - \tl_gset:Nx \g_@@_fontset_tl - { - \lua_now:e - { - if ~ os.name == 'windows' then ~ - tex.sprint ( 'windows' ) - elseif ~ os.name == 'macosx' then ~ - tex.sprint ( 'mac' ) - else ~ - tex.sprint ( 'fandol' ) - end - } - } - } -% -% \end{macrocode} -% -% \ApTeX{} 可以使用 \tn{ngostype} 来判断。 -% \begin{macrocode} -%<*aptex> -\cs_new_protected_nopar:Npn \ctex_detected_platform: - { - \tl_gset:Nx \g_@@_fontset_tl - { - \str_case:onF { \ngostype } - { - { Win32 } { windows } - { Win64 } { windows } - { Darwin } { mac } - } - { fandol } - } - } -% -% \end{macrocode} -% -% \pdfTeX{} 和 \XeTeX{} 下则依据 \file{/dev/null} 和 \file{nul:} 的存在性以及 -% 文件系统的大小写敏感性来判断。Mac~OS~X 的大小写敏感性在安装时是可选的。为了 -% 保险起见,这里的判断很繁琐,最多要进行 4 次文件操作! -% \begin{macrocode} -%<*xetex|pdftex|uptex> -\cs_new_protected_nopar:Npn \ctex_detected_platform: - { - \file_if_exist:nTF { /dev/null } - { - \file_if_exist:nTF { nul: } - { - \file_if_exist:nTF { \c_@@_upper_case_file_str } - { \ctex_if_macosx:TF { mac } { windows } } - { \ctex_if_macosx:TF { mac } { fandol } } - } - { \ctex_if_macosx:TF { mac } { fandol } } - } - { \tl_gset:Nn \g_@@_fontset_tl { windows } } - } -\str_const:Nx \c_@@_upper_case_file_str - { \exp_args:No \str_upper_case:n { \g_file_curr_name_str } } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[int]{\ctex_if_macosx:TF} -% \changes{v2.1}{2015/06/17}{改用 \file{/Library/Fonts/Songti.ttc} 为特征文件。} -% 以 \file{/Library/Fonts/Songti.ttc} 为特征文件判断 Mac~OS~X。 -% \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_if_macosx:TF #1#2 - { - \file_if_exist:nTF { \c_@@_macosx_file_str } - { \tl_gset:Nn \g_@@_fontset_tl {#1} } - { \tl_gset:Nn \g_@@_fontset_tl {#2} } - } -\str_const:Nn \c_@@_macosx_file_str { /Library/Fonts/Songti.ttc } -% -% \end{macrocode} -% \end{macro} +% \changes{v2.5}{2019/10/25}{操作系统检测移动至载入中文字库处,且不再需要 +% 依赖特定引擎。} % % \subsubsection{\pkg{hyperref} 兼容性处理} % @@ -6113,11 +6369,11 @@ Copyright and Licence %<*class|ctex> \@ifpackageloaded { hyperref } { - \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1 + \cs_new_protected:Npn \ctex_hypersetup:n #1 { \hypersetup {#1} } } { - \cs_new_protected_nopar:Npn \ctex_hypersetup:n #1 + \cs_new_protected:Npn \ctex_hypersetup:n #1 { \PassOptionsToPackage {#1} { hyperref } } } % @@ -6125,14 +6381,14 @@ Copyright and Licence % \end{macro} % % 在 \pdfTeX{} 下使用 \texttt{GBK} 编码,\dvipdfmx{} 驱动可以直接用它的 -% \tn{special} 命令,其它模式用 \pkg{xCJK2uni} 宏包处理。使用 \texttt{UTF-8} 编 +% \tn{special} 命令,其他模式用 \pkg{xCJK2uni} 宏包处理。使用 \texttt{UTF-8} 编 % 码时,\pkg{CJKutf8} 已经处理了书签问题,但仍需要设置 \opt{pdfencoding} 为 % \opt{unicode},目的是在书签的开头写入 BOM (|\376\377|),提示这是 % \texttt{UTF-16BE} 字节流。 % \begin{macrocode} %<*pdftex> \ctex_hypersetup:n { driverfallback = dvipdfmx } -\str_if_eq:onTF { \l_@@_encoding_tl } { GBK } +\str_if_eq:onTF { \g_@@_encoding_tl } { GBK } { \ctex_hypersetup:n { CJKbookmarks = true } \sys_if_output_pdf:TF @@ -6205,7 +6461,7 @@ Copyright and Licence %<*uptex|aptex> \ctex_hypersetup:n { driverfallback = dvipdfmx } \ctex_at_end_package:nn { hyperref } - { \AtBeginShipoutFirst { \special { pdf:tounicode~ UTF8-UTF16 } } } + { \AtBeginShipoutFirst { \special { pdf:tounicode~UTF8-UTF16 } } } % % \end{macrocode} % @@ -6215,83 +6471,46 @@ Copyright and Licence % % \subsubsection{\pkg{CJKfntef}、\pkg{xeCJKfntef} 相关设置} % -% \CTeX{} 宏集对 \pdfTeX{} 与 \XeTeX{} 引擎,分别载入 \pkg{CJKfntef} 或 -% \pkg{xeCJKfntef} 宏包,并关闭宏包默认的彩色等多余格式。 -% % \changes{v2.0}{2015/03/25}{默认关闭 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 的彩 % 色设置。} -% \changes{v2.0}{2015/03/25}{\tn{CTEXunderdot}, \tn{CTEXunderline}, -% \tn{CTEXunderdblline}, \tn{CTEXunderwave}, \tn{CTEXsout}, \tn{CTEXxout} 是过 +% \changes{v2.0}{2015/03/25}{\tn{CTEXunderdot}、\tn{CTEXunderline}、 +% \tn{CTEXunderdblline}、\tn{CTEXunderwave}、\tn{CTEXsout}、\tn{CTEXxout} 是过 % 时命令;\env{CTEXfilltwosides} 是过时环境。} +% \changes{v2.5}{2019/11/10}{不再自动载入 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 宏包。} +% \changes{v2.5}{2019/11/10}{移除 \tn{CTEXunderdot}、\tn{CTEXunderline}、 +% \tn{CTEXunderdblline}、\tn{CTEXunderwave}、\tn{CTEXsout}、\tn{CTEXxout}、 +% \env{CTEXfilltwosides} 等命令和环境。} % -% 载入 \pkg{CJKfntef} 或 \pkg{xeCJKfntef} 并做适当格式设置。有关 |\CTEX| 开头 -% 的宏定义是过时命令,仅做兼容性保留。 +% 对 \pdfTeX{} 与 \XeTeX{} 引擎,分别在 \pkg{CJKfntef}、\pkg{xeCJKfntef} 宏包 +% 的末尾关闭彩色显式等多余格式。 % % \begin{macrocode} %<*pdftex> -\RequirePackage { CJKfntef } -\normalem -\cs_new_protected_nopar:Npn \@@_clear_fntef_color:n #1 - { \tl_clear:c { CJK#1color } } -% -%<*xetex> -\RequirePackage { xeCJKfntef } -\@ifpackagelater { xeCJKfntef } { 2014/11/04 } +\ctex_at_end_package:nn { CJKfntef } { - \cs_new_protected_nopar:Npn \@@_clear_fntef_color:n #1 - { \xeCJKsetup { #1 / format = { } } } - } - { - \cs_new_protected_nopar:Npn \@@_clear_fntef_color:n #1 + \normalem + \cs_new_protected:Npn \@@_clear_fntef_color:n #1 { \tl_clear:c { CJK#1color } } - } -% -%<*luatex|uptex|aptex> -\msg_new:nnn { ctex } { fntef-not-available } -% { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ LuaLaTeX. } -% { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ upLaTeX. } -% { Functions~ of~ `CJKfntef'~ is~ not~ available~ in~ ApLaTeX. } -\msg_warning:nn { ctex } { fntef-not-available } -% -\clist_map_inline:nn - { underdot , underline , underdblline , underwave , sout , xout } -%<*pdftex|xetex> +% +%<*xetex> +\ctex_at_end_package:nn { xeCJKfntef } { - \@@_clear_fntef_color:n {#1} - \cs_new_protected_nopar:cpx { CTEX#1 } + \@ifpackagelater { xeCJKfntef } { 2014/11/04 } { - \msg_warning:nnnn { ctex } { deprecated-command } { \exp_not:c { CTEX#1 } } - { You~ can~ use~ the~ command~ with~ prefix~ \exp_not:N \CJK~ instead. } - \exp_not:c { CJK#1 } + \cs_new_protected:Npn \@@_clear_fntef_color:n #1 + { \xeCJKsetup { #1 / format = { } } } } + { + \cs_new_protected:Npn \@@_clear_fntef_color:n #1 + { \tl_clear:c { CJK#1color } } + } +% +%<*pdftex|xetex> + \clist_map_inline:nn + { underdot , underline , underdblline , underwave , sout , xout } + { \@@_clear_fntef_color:n {#1} } } -\cs_new_protected_nopar:Npn { \CTEXfilltwosides } - { - \msg_warning:nnnn { ctex } { deprecated-environment } { CTEXfilltwosides } - { You~ can~ use~ `CJKfilltwosides'~ environment~ instead. } - \CJKfilltwosides - } -\cs_new_protected_nopar:Npn { \endCTEXfilltwosides } { \endCJKfilltwosides } % -%<*luatex|uptex|aptex> - { \cs_new_eq:cN { CTEX#1 } \use:n } -\cs_new_eq:NN \CTEXfilltwosides \use_none:n -\cs_new_eq:NN \endCTEXfilltwosides \prg_do_nothing: -% -%<*pdftex> -\clist_map_inline:nn - { - underdotbasesep , underdotsep , underlinebasesep , - underlinesep , underdbllinesep , underdbllinebasesep , - underwavebasesep , underwavesep , southeight , - underdotcolor , underwavecolor , underlinecolor , - underdbllinecolor , soutcolor , xoutcolor - } - { - \cs_new_eq:cc { CTEX#1 } { CJK#1 } - \cs_set_nopar:cpx { CJK#1 } { \exp_not:c { CTEX#1 } } - } -% % \end{macrocode} % % \subsubsection{\tn{ccwd} 的更新} @@ -6299,7 +6518,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_update_ccwd:,\ccwd} % \changes{v2.4.1}{2016/04/29}{正确设置 \upTeX{} 下的 \tn{ccwd}。} % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_update_ccwd: +\cs_new_protected:Npn \ctex_update_ccwd: %<*pdftex|xetex> { \hbox_set:Nn \l_@@_tmp_box { \CJKglue } @@ -6319,10 +6538,10 @@ Copyright and Licence % \begin{macro}[int]{\ctex_update_ccglue:} % 更新字间距。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_update_ccglue: +\cs_new_protected:Npn \ctex_update_ccglue: %<*pdftex|xetex> { - \cs_set_protected_nopar:Npn \CJKglue + \cs_set_protected:Npn \CJKglue { \skip_horizontal:N \l_@@_ccglue_skip } } % @@ -6354,13 +6573,7 @@ Copyright and Licence { \prg_return_false: } { \prg_return_true: } % } -% \end{macrocode} -% 注意下面的标记不能用 \verb"%",它会导致旧版本的 \pkg{l3docstrip} -% 不能替换 \texttt{@@}。 -% \begin{macrocode} -%<*pdftex|xetex> -\ctex_at_end:n { \cs_new_eq:NN \@@_ccglue: \CJKglue } -% +%\ctex_at_end:n { \cs_new_eq:NN \@@_ccglue: \CJKglue } % \end{macrocode} % \end{macro} % @@ -6374,27 +6587,29 @@ Copyright and Licence % 意义。在 \LuaTeX{} 下,\pkg{LuaTeX-ja} 总是按照 JFM 中的设置输出汉字的宽度,可以 % 直接用 \tn{zw} 作为汉字宽度。\upTeX{} 可以直接使用原生的长度单位 |zw|。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_update_em_unit: +\cs_new_protected:Npn \ctex_update_em_unit: % { \dim_set:Nn \ccwd { \f@size \p@ } } % { \dim_set:Nn \ccwd { \zw } } % { \dim_set:Nn \ccwd { 1zw } } % \end{macrocode} % \end{macro} % -% \subsubsection{其它} +% \subsubsection{其他} % +% \begin{macro}[int]{\ctex_add_to_selectfont:n,\CTEX@selectfont@hook} % \changes{v2.4.13}{2018/03/23}{修正导言区 \tn{selectfont} 钩子位置。} +% \changes{v2.5}{2020/04/19}{兼容 \pkg{KOMA-Script} 的 \tn{selectfont} 补丁。} % -% \begin{macro}[int]{\ctex_add_to_selectfont:n,\CTEX@selectfont@hook} % \tn{EverySelectfont} 直到文档开始时才有效。为了 \tn{ccwd} 和 \pkg{LuaTeX-ja} 的 % 字体设置在导言区也可用,我们还需要在这里手工修改 \tn{selectfont}。\pkg{everysel} % 宏包会用 \tn{CheckCommand} 来检查 \tn{selectfont} 是否为标准定义。我们修改了 % \tn{selectfont},所以会给出一个警告。为了消除这个警告,在它检查之前,还原本来 % 定义。\pkg{pxeverysel} 宏包取消了检查,但也需要恢复定义,避免重复使用钩子。 +% \pkg{KOMA-Script} 宏包也会进行检查,我们需要小心处理。 % \begin{macrocode} \cs_new_protected:Npn \ctex_add_to_selectfont:n #1 { - \cs_set_protected_nopar:Npx \CTEX@selectfont@hook + \cs_set_protected:Npx \CTEX@selectfont@hook { \exp_not:o { \CTEX@selectfont@hook #1 } } } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: @@ -6404,10 +6619,32 @@ Copyright and Licence { \tl_set:Nn \l_@@_tmp_tl {#1} \cs_new_eq:NN \CTEX@selectfont@save #1 - \cs_new_protected_nopar:Npn \@@_restore_selectfont: + \cs_new_protected:Npn \@@_restore_selectfont: { + \cs_if_free:NF \scr@new@selectfont + { +% \end{macrocode} +% \pkg{CJK} 直接修改 \tn{selectfont} 和 \pkg{pxeverysel} 的补丁, +% 会使 \pkg{KOMA-Script} 的 \tn{par@update} 失效。 +% \begin{macrocode} +%<*pdftex|uptex|aptex> + \cs_if_free:NF \par@update +%<*uptex|aptex> + { + \tl_put_right:Nn \@EverySelectfont@Init + { \tl_put_right:Nn #1 { \par@update } } + } +% +%<*pdftex> + { \tl_put_right:Nn #1 { \par@update } } + \cs_set_eq:NN \scr@selectfont \CTEX@selectfont@save +% +% + \cs_set_eq:NN \scr@new@selectfont #1 +% \cs_set_eq:NN \CTEX@selectfont@save \scr@selectfont + } \tl_put_left:Nn \@EverySelectfont@Init - { \let #1 \CTEX@selectfont@save } + { \cs_set_eq:NN #1 \CTEX@selectfont@save } \cs_undefine:N \@@_restore_selectfont: } } @@ -6458,7 +6695,7 @@ Copyright and Licence % 全段。 % \begin{macrocode} %<*luatex|uptex|aptex> -\cs_new_protected_nopar:Npn \ctex_update_xkanjiskip: +\cs_new_protected:Npn \ctex_update_xkanjiskip: { \skip_if_eq:nnT % { \ltjgetparameter { xkanjiskip } } { \l_@@_xkanjiskip_skip } @@ -6488,35 +6725,34 @@ Copyright and Licence % % \changes{v2.4.10}{2017/07/23}{定义 \tn{cht},\tn{cdp} 和 \tn{cwd}。} % -% \begin{macro}[int]{\cht,\cdp,\cwd} +% \begin{macro}[int]{\cht,\cdp,\cwd,\ctex_update_kanjisize:} % 分别从 \file{.jfm} 中读取字符高度、深度和宽度,目前仅考虑横排的情况。 % \begin{macrocode} %<*luatex> \dim_new:N \cht \dim_new:N \cdp \dim_new:N \cwd -\newluafunction \g_@@_kanjisize_func \group_begin: \char_set_catcode_space:n { 32 } \lua_now:e { local nulltable = { } - local t = lua.get_functions_table() local fmt = luatexja.jfont.font_metric_table local getattribute = tex.getattribute local setdimen = tex.setdimen - t[\int_use:N \g_@@_kanjisize_func] = function () - local ft = fmt[getattribute('ltj@curjfnt')] or nulltable + local func = lua.get_functions_table() + local id = luatexbase.new_luafunction("ctex") + func[id] = function () + local ft = fmt[getattribute("ltj@curjfnt")] or nulltable local ft = ft and ft.char_type or nulltable local fk = ft and ft[0] or nulltable - setdimen('cht', fk.height or 0) - setdimen('cdp', fk.depth or 0) - setdimen('cwd', fk.width or ft.zw or 0) + setdimen("cht", fk.height or 0) + setdimen("cdp", fk.depth or 0) + setdimen("cwd", fk.width or ft.zw or 0) end + token.set_lua("ctex_update_kanjisize:", id, "global", "protected") } \group_end: -\cs_new_protected_nopar:Npn \ctex_update_kanjisize: - { \tex_luafunction:D \g_@@_kanjisize_func } \ctex_add_to_selectfont:n { \ctex_update_kanjisize: } % % \end{macrocode} @@ -6527,7 +6763,7 @@ Copyright and Licence % \pdfTeX{} 和 \XeTeX{} 下初始设置为 \opt{auto},\LuaTeX{}、\upTeX{} 下是无效 % 选项。 % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { %<*pdftex|xetex> space .choice: , @@ -6555,11 +6791,11 @@ Copyright and Licence % 在导言区或正文中设置标点符号输出格式。\pkg{LuaTeX-ja} 设置的是字体的默认 \texttt{JFM}, % 只会影响到之后设置的字体。\upTeX{} 暂时无效。 % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { punct .code:n = { - \tl_set:Nx \l_@@_punct_tl { #1 } + \tl_set:Nx \l_@@_punct_tl {#1} % \punctstyle { \l_@@_punct_tl } % \xeCJKsetup { PunctStyle = \l_@@_punct_tl } % \ctex_mono_jfm:o { \l_@@_punct_tl } @@ -6570,13 +6806,6 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \XeLaTeX{}、\LuaLaTeX{} 和 \upLaTeX{} 总是使用 \texttt{UTF8} 编码。 -% \begin{macrocode} -%<*xetex|luatex|uptex|aptex> -\tl_set:Nn \l_@@_encoding_tl { UTF8 } -% -% \end{macrocode} -% % \begin{macrocode} % % \end{macrocode} @@ -6597,27 +6826,35 @@ Copyright and Licence % \begin{macro}{\ctexset} % \begin{macrocode} %<*class|ctex|ctexheading> -\NewDocumentCommand \ctexset { } { \keys_set:nn { ctex } } +\NewDocumentCommand \ctexset { } { \ctex_set:n } % % \end{macrocode} % \end{macro} % % \changes{v2.0}{2015/03/21}{\tn{CTEXsetup}, \tn{CTEXoptions} 是过时命令。} % \begin{macro}{\CTEXsetup,\CTEXoptions} -% 过时命令。出于历史原因,\tn{CTEXoptions} 需要在 \pkg{pxeverysel} 宏包之后定义。 +% 过时命令。 % \begin{macrocode} %<*class|ctex> -\NewDocumentCommand \CTEXsetup { +o > { \TrimSpaces } m } +\NewDocumentCommand \CTEXsetup { +O { } > { \TrimSpaces } m } { - \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXsetup } - { \ctexset~ {~ #2~ =~ {~ #1~ }~ }~ is~ set. } - \IfNoValueF {#1} { \keys_set:nn { ctex / #2 } {#1} } + \tl_if_blank:nTF {#1} + { \ctex_deprecated_command:Nn \CTEXsetup { } } + { + \ctex_deprecated_command:Nn \CTEXsetup + { \ctexset {~#2~=~{~#1~}~}~is~set. } + \ctex_set:nn {#2} {#1} + } } -\NewDocumentCommand \CTEXoptions { +o } +\NewDocumentCommand \CTEXoptions { +O { } } { - \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXoptions } - { \ctexset~ {~ #1~ }~ is~ set. } - \IfNoValueF {#1} { \keys_set:nn { ctex } {#1} } + \tl_if_blank:nTF {#1} + { \ctex_deprecated_command:Nn \CTEXoptions { } } + { + \ctex_deprecated_command:Nn \CTEXoptions + { \ctexset {~#1~}~is~set. } + \ctex_set:n {#1} + } } % \end{macrocode} % \end{macro} @@ -6627,7 +6864,7 @@ Copyright and Licence % \begin{macro}{autoindent} % \opt{autoindent} 也是可以用在正文中的选项,意义与宏包选项 |option/autoindent| 相同。 % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { autoindent .choice: , autoindent .default:n = { true } , @@ -6651,7 +6888,7 @@ Copyright and Licence % 无论字体大小是否变化都更新相关信息。 % \begin{macrocode} \NewDocumentCommand \CTEXsetfont { } { \ctex_select_size: } -\cs_new_protected_nopar:Npn \ctex_select_size: +\cs_new_protected:Npn \ctex_select_size: { \cs_if_free:NTF \size@update { \ctex_update_size: } { \selectfont } } % \end{macrocode} % \end{macro} @@ -6659,7 +6896,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_update_size:} % 在字号变化时更新 \tn{ccwd}、\tn{parindent} 和汉字间距。字距为零则恢复正常设置。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_update_size: +\cs_new_protected:Npn \ctex_update_size: { \tl_if_eq:NNTF \l_@@_ziju_tl \c_@@_zero_tl { @@ -6687,7 +6924,7 @@ Copyright and Licence % 额外伸展量。初始化为一个汉字的宽度。若设置为 \tn{maxdimen},则禁用此功能。 % 参数的默认单位是汉字的宽度 \tn{ccwd}。 % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { linestretch .code:n = { @@ -6710,7 +6947,7 @@ Copyright and Licence % \tn{ccwd},否则设置伸展量为 $0.08$ 倍 \tn{baselineskip}。注意 \pkg{everysel} 的 % 钩子位于 \tn{size@update} 之前,\tn{baselineskip} 还未更新,不能直接使用它。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_update_stretch: +\cs_new_protected:Npn \ctex_update_stretch: { \ctex_update_em_unit: \dim_set:Nn \l_@@_tmp_dim { \l_@@_line_stretch_tl } @@ -6751,7 +6988,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_update_parindent:} % 更新段落首行缩进。此函数在字号变化时调用。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_update_parindent: +\cs_new_protected:Npn \ctex_update_parindent: { \tl_if_empty:NF \l_@@_autoindent_tl { @@ -6767,7 +7004,7 @@ Copyright and Licence % \begin{macrocode} \NewDocumentCommand \ziju { m } { \exp_args:Nx \ctex_ziju:n {#1} \tex_ignorespaces:D } -\cs_new_protected_nopar:Npn \ctex_ziju:n #1 +\cs_new_protected:Npn \ctex_ziju:n #1 { \tl_set:Nx \l_@@_ziju_tl { \fp_eval:n {#1} } \ctex_select_size: @@ -6779,7 +7016,7 @@ Copyright and Licence % 更新字距。若字距不大于 $-1$,即 \tn{ccwd} 为非正值,则不计算伸缩值。 % 否则,首先假定汉字的宽度为正常宽度加上字距,看一行上能正常放下多少个汉字。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_update_ziju: +\cs_new_protected:Npn \ctex_update_ziju: { \ctex_update_em_unit: \dim_set:Nn \l_@@_ziju_dim { \l_@@_ziju_tl \ccwd } @@ -6832,14 +7069,15 @@ Copyright and Licence % \begin{macrocode} \NewDocumentCommand \CTEXindent { } { - \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXindent } - { \parindent is~ set~ to~ 2\ccwd. } - \ctex_update_ccwd: \dim_set:Nn \parindent { 2 \ccwd } + \ctex_deprecated_command:Nn \CTEXindent + { \parindent is~set~to~2\ccwd. } + \ctex_update_ccwd: + \dim_set:Nn \parindent { 2 \ccwd } } \NewDocumentCommand \CTEXnoindent { } { - \msg_warning:nnnn { ctex } { deprecated-command } { \CTEXnoindent } - { \parindent is~ set~ to~ 0pt. } + \ctex_deprecated_command:Nn \CTEXnoindent + { \parindent is~set~to~0pt. } \dim_zero:N \parindent } % \end{macrocode} @@ -6848,14 +7086,14 @@ Copyright and Licence % \subsection{中文数字与日期} % % \begin{macrocode} -\PassOptionsToPackage { encoding = \l_@@_encoding_tl } { zhnumber } +\PassOptionsToPackage { encoding = \g_@@_encoding_tl } { zhnumber } \RequirePackage { zhnumber } % \end{macrocode} % % \begin{macro}{\chinese} % \changes{v2.4.1}{2016/05/01}{支持 \tn{pagenumbering}。} % \begin{macrocode} -\cs_new_nopar:Npn \chinese { \zhnum_counter:n } +\cs_new:Npn \chinese { \zhnum_counter:n } \cs_new_eq:NN \@chinese \@zhnum \cs_new_eq:NN \Chinese \chinese \cs_new_eq:NN \CTEXcounter \use_none:n @@ -6890,7 +7128,7 @@ Copyright and Licence % \begin{macro}{today} % \begin{macrocode} \cs_set_eq:NN \CTEX@todayold \today -\keys_define:nn { ctex } +\ctex_define:n { today .choice: , today / old .code:n = @@ -6914,7 +7152,7 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \subsection{其它中文标题定义} +% \subsection{其他中文标题定义} % % \changes{v2.0}{2014/03/08}{将标题汉化功能加入 \pkg{ctex.sty}。} % \changes{v2.4.3}{2016/08/18}{确保 \tn{proofname} 非空。} @@ -6931,7 +7169,7 @@ Copyright and Licence % \end{macro} % % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { contentsname .tl_set:N = \contentsname , listfigurename .tl_set:N = \listfigurename , @@ -6962,7 +7200,7 @@ Copyright and Licence } \tl_if_exist:NTF \insertcontinuationtext { - \keys_define:nn { ctex } + \ctex_define:n { algorithmname .tl_set:N = \algorithmname , bibname .tl_set:N = \bibname , @@ -6972,13 +7210,13 @@ Copyright and Licence } { \tl_if_exist:NTF \bibname - { \keys_define:nn { ctex } { bibname .tl_set:N = \bibname } } + { \ctex_define:n { bibname .tl_set:N = \bibname } } { \tl_if_exist:NTF \refname - { \keys_define:nn { ctex } { bibname .tl_set:N = \refname } } + { \ctex_define:n { bibname .tl_set:N = \refname } } { \msg_warning:nn { ctex } { ctexbibname } - \keys_define:nn { ctex } { bibname .tl_set:N = \ctexbibname } + \ctex_define:n { bibname .tl_set:N = \ctexbibname } } } } @@ -7028,7 +7266,7 @@ Copyright and Licence % % \begin{macro}{\@@_initial_heading:n} % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_initial_heading:n #1 +\cs_new_protected:Npn \@@_initial_heading:n #1 { \tl_new:c { CTEX@pre#1 } \tl_new:c { CTEX@post#1 } @@ -7078,7 +7316,7 @@ Copyright and Licence % % \begin{macro}{\@@_def_heading_keys:n} % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_def_heading_keys:n #1 +\cs_new_protected:Npn \@@_def_heading_keys:n #1 { \tl_put_right:Nx \l_@@_tmp_tl { @@ -7103,11 +7341,8 @@ Copyright and Licence #1 / hang .bool_set:N = \exp_not:c { CTEX@#1@hang } , #1 / hang .initial:n = true , #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , - #1 / tocline .code:n = - { - \cs_set:Npn \exp_not:c { CTEX@#1@tocline} - \exp_not:n { ####1####2 } { ####1 } - } , + #1 / tocline .cs_set:Np = \exp_not:c { CTEX@#1@tocline} + \exp_not:n { ##1##2 } , \@@_plus_key_aux:nn {#1} { break } , % \@@_plus_key_aux:nn {#1} { format } , @@ -7118,7 +7353,7 @@ Copyright and Licence \@@_plus_key_aux:nn {#1} { aftertitle } , } } -\cs_new_nopar:Npn \@@_plus_key_aux:nn #1#2 +\cs_new:Npn \@@_plus_key_aux:nn #1#2 { #1 / #2 .tl_set:N = \exp_not:c { CTEX@#1@#2 } , #1 / #2 + .code:n = @@ -7143,7 +7378,7 @@ Copyright and Licence \cs_new_protected:Npn \@@_assign_heading_name:nnn #1#2#3 { \tl_set:cn { CTEX@pre#1 } {#2} - \IfNoValueTF {#3} + \tl_if_novalue:nTF {#3} { \tl_clear:c { CTEX@post#1 } } { \tl_set:cn { CTEX@post#1 } {#3} } } @@ -7189,24 +7424,54 @@ Copyright and Licence \@@_initial_heading:n {#1} \@@_def_heading_keys:n {#1} } -\use:x +\exp_args:NNo \group_end: \ctex_define:n { \l_@@_tmp_tl } +% \end{macrocode} +% +% \changes{v2.5}{2020/04/23}{重构标题选项 \opt{indent} 和 \opt{hang}。} +% +% \begin{macro}[int]{\CTEX@heading@format@initial} +% 标题格式的一些初始设置,包括恢复默认字体,并禁用自动调整首行缩进,禁止在标题中分页。 +% 同时用 \tn{noindent} 抑制首行缩进并进入水平模式。 +% 统一在各级标题的 \opt{format} 选项之前使用。 +% \begin{macrocode} +\cs_new_protected:Npn \CTEX@heading@format@initial { - \group_end: - \keys_define:nn { ctex } { \exp_not:o { \l_@@_tmp_tl } } + \normalfont + \tl_clear:N \l_@@_autoindent_tl + \int_set:Nn \tex_interlinepenalty:D { 10 000 } + \tex_noindent:D } % \end{macrocode} +% \end{macro} % +% \begin{macro}[int]{\ctex_indent_box:n} +% 设置 \tn{parindent},并插入用于产生缩进的盒子,如果缩进为 |0|,就不插入。 % \begin{macrocode} -%<*article|book|report> +\cs_new_protected:Npn \ctex_indent_box:n #1 + { + \dim_set:Nn \tex_parindent:D {#1} + \@@_insert_indent: + } +\cs_new_protected:Npn \@@_insert_indent: + { + \dim_compare:nNnF \tex_parindent:D = \c_zero_dim + { \tex_indent:D } + } +\cs_new_eq:NN \CTEX@indentbox \ctex_indent_box:n % \end{macrocode} +% \end{macro} % % \subsubsection{标准标题命令的修改} % +% \begin{macrocode} +%<*article|book|report> +% \end{macrocode} +% % \begin{macro}[int]{\CTEX@fixtopskip} % 修正 \cls{book} 和 \cls{report} 类的 \tn{part} 和 \tn{chapter} 标题之前的多余空行。 % \begin{macrocode} %<*book|report> -\cs_new_protected_nopar:Npn \CTEX@fixtopskip +\cs_new_protected:Npn \CTEX@fixtopskip { \CTEX@fixheadingskip \dim_compare:nNnF \tex_pagegoal:D < \c_max_dim @@ -7222,14 +7487,14 @@ Copyright and Licence % \TeX{} 就不会加上 \tn{parskip}。这时候就需要用户把 \tn{parskip} 加到 \opt{beforeskip} % 或者 \opt{afterskip} 作为修正。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \CTEX@fixheadingskip +\cs_new_protected:Npn \CTEX@fixheadingskip { \par \dim_set:Nn \tex_prevdepth:D { -1000pt } \skip_sub:Nn \l_@@_heading_skip { \tex_parskip:D } } \skip_new:N \l_@@_heading_skip -\cs_new_protected_nopar:Npn \CTEX@setheadingskip +\cs_new_protected:Npn \CTEX@setheadingskip { \skip_set:Nn \l_@@_heading_skip } \cs_new_eq:NN \CTEX@headingskip \l_@@_heading_skip % \end{macrocode} @@ -7251,9 +7516,9 @@ Copyright and Licence % 用于判断当前标题是否有编号。 % \begin{macrocode} \cs_new_eq:NN \CTEXifname \use_ii:nn -\cs_new_protected_nopar:Npn \CTEX@ifnametrue +\cs_new_protected:Npn \CTEX@ifnametrue { \cs_set_eq:NN \CTEXifname \use_i:nn } -\cs_new_protected_nopar:Npn \CTEX@ifnamefalse +\cs_new_protected:Npn \CTEX@ifnamefalse { \cs_set_eq:NN \CTEXifname \use_ii:nn } % \end{macrocode} % \end{macro} @@ -7263,7 +7528,7 @@ Copyright and Licence % 往插图和表格目录中加入额外间距。如果间距为零,则不加入。 % \begin{macrocode} %<*book|report> -\cs_new_protected_nopar:Npn \CTEX@addloflotskip #1 +\cs_new_protected:Npn \CTEX@addloflotskip #1 { \skip_set:Nn \l_@@_heading_skip { \use:c { CTEX@#1@lofskip } } \skip_if_eq:nnF { \l_@@_heading_skip } { \c_zero_skip } @@ -7289,14 +7554,6 @@ Copyright and Licence % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\CTEX@disableautoindent} -% 禁用自动调整首行缩进。 -% \begin{macrocode} -\cs_new_protected_nopar:Npn \CTEX@disableautoindent - { \tl_clear:N \l_@@_autoindent_tl } -% \end{macrocode} -% \end{macro} -% % \changes{v2.2}{2015/06/27}{\opt{beforeskip}、\opt{afterskip} 和 \opt{indent} % 选项支持表达式。} % \changes{v2.4.15}{2019/03/31}{修正 \opt{part/indent} 和 \opt{chapter/indent} 的实现方法。} @@ -7304,11 +7561,9 @@ Copyright and Licence % \changes{v2.4.16}{2019/05/11}{修正 \opt{part/indent} 和 \opt{chapter/indent} % 的实现方法,在其标题内部禁用 \opt{autoindent}。} % -% \paragraph{part 的标题} +% \changes{v2.5}{2020/04/22}{标题选项 \opt{format} 也可以接受参数。} % -% \begin{macrocode} -%<@@=> -% \end{macrocode} +% \paragraph{part 的标题} % % \changes{v2.2}{2015/06/27}{非 \cls{ctexart} 类的 \opt{part/beforeskip} 和 % \opt{part/afterskip} 选项有意义。} @@ -7317,19 +7572,19 @@ Copyright and Licence % \begin{macrocode} %<*article> \renewcommand\part{% - \if@noskipsec \leavevmode \fi - \par - \CTEX@part@break -% \addvspace{4ex}% - \CTEX@setheadingskip \CTEX@part@beforeskip - \ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi - \addvspace \CTEX@headingskip - \ifodd \CTEX@part@afterindent - \@afterindenttrue - \else - \@afterindentfalse - \fi - \secdef\@part\@spart} + \if@noskipsec \leavevmode \fi + \par + \CTEX@part@break +% \addvspace{4ex}% + \CTEX@setheadingskip \CTEX@part@beforeskip + \ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi + \addvspace \CTEX@headingskip + \ifodd \CTEX@part@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \secdef\@part\@spart} % %<*book|report> \renewcommand\part{% @@ -7377,20 +7632,21 @@ Copyright and Licence \fi \CTEX@gettitle{#1}% \CTEX@addtocline{part}{#1}% - {\interlinepenalty \@M -% \normalfont \parindent \z@ \raggedright - \CTEX@disableautoindent - \normalfont \CTEX@part@format -% \ifnum \c@secnumdepth >\m@ne -% \Large\bfseries\partname\nobreakspace\thepart\par\nobreak -% \fi - \CTEX@hangindent{part}% - {\CTEXifname{\CTEX@partname\CTEX@part@aftername}{}}% -% \huge\bfseries #2% - \CTEX@part@titleformat{#2}% -% \markboth{}{}% - \partmark{#1}% - \CTEX@part@aftertitle}% + \partmark{#1}% + \begingroup +% \parindent \z@ \raggedright \interlinepenalty \@M \normalfont + \CTEX@heading@format@initial + \CTEX@part@format{% +% \ifnum \c@secnumdepth >\m@ne +% \Large\bfseries\partname\nobreakspace\thepart\par\nobreak +% \fi + \CTEX@headinghang{part}% + {\CTEXifname{\CTEX@partname\CTEX@part@aftername}{}}% +% \huge\bfseries #2% + \CTEX@part@titleformat{#2}% +% \markboth{}{}\par + \CTEX@part@aftertitle}\par + \endgroup \nobreak % \vskip 3ex \CTEX@setheadingskip \CTEX@part@afterskip @@ -7418,19 +7674,20 @@ Copyright and Licence \CTEX@gettitle{#1}% \CTEX@addtocline{part}{#1}% % \markboth{}{}% - \partmark{#1}% - {\interlinepenalty \@M -% \normalfont \centering - \CTEX@disableautoindent - \normalfont \CTEX@part@format -% \ifnum \c@secnumdepth >-2\relax -% \huge\bfseries\partname\nobreakspace\thepart\par\vskip 20\p@ -% \fi - \CTEX@hangindent{part}% - {\CTEXifname{\CTEX@partname\CTEX@part@aftername}{}}% -% \Huge\bfseries #2\par}% - \CTEX@part@titleformat{#2}% - \CTEX@part@aftertitle}% + \partmark{#1}% + \begingroup +% \centering \interlinepenalty \@M \normalfont + \CTEX@heading@format@initial + \CTEX@part@format{% +% \ifnum \c@secnumdepth >-2\relax +% \huge\bfseries\partname\nobreakspace\thepart\par\vskip 20\p@ +% \fi + \CTEX@headinghang{part}% + {\CTEXifname{\CTEX@partname\CTEX@part@aftername}{}}% +% \Huge\bfseries #2\par + \CTEX@part@titleformat{#2}% + \CTEX@part@aftertitle}\par + \endgroup \@endpart} % % \end{macrocode} @@ -7440,38 +7697,40 @@ Copyright and Licence % \begin{macrocode} %<*article> \def\@spart#1{% - \CTEX@ifnamefalse - \CTEX@makeanchor@spart{part*}% - \CTEX@gettitle{#1}% - {\interlinepenalty \@M -% \normalfont \parindent \z@ \raggedright - \CTEX@disableautoindent - \normalfont \CTEX@part@format - \CTEX@hangindent{part}{}% -% \huge \bfseries #1\par}% - \CTEX@part@titleformat{#1}% - \CTEX@part@aftertitle}% - \nobreak -% \vskip 3ex - \CTEX@setheadingskip \CTEX@part@afterskip - \ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi - \vskip \CTEX@headingskip - \@afterheading} + \CTEX@ifnamefalse + \CTEX@makeanchor@spart{part*}% + \CTEX@gettitle{#1}% + \begingroup +% \parindent \z@ \raggedright \interlinepenalty \@M \normalfont + \CTEX@heading@format@initial + \CTEX@part@format{% + \CTEX@headinghang{part}{}% +% \huge \bfseries #1\par + \CTEX@part@titleformat{#1}% + \CTEX@part@aftertitle}\par + \endgroup + \nobreak +% \vskip 3ex + \CTEX@setheadingskip \CTEX@part@afterskip + \ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi + \vskip \CTEX@headingskip + \@afterheading} % %<*book|report> \def\@spart#1{% - \CTEX@ifnamefalse - \CTEX@makeanchor@spart{part*}% - \CTEX@gettitle{#1}% - {\interlinepenalty \@M -% \normalfont \centering - \CTEX@disableautoindent - \normalfont \CTEX@part@format - \CTEX@hangindent{part}{}% -% \Huge \bfseries #1\par}% - \CTEX@part@titleformat{#1}% - \CTEX@part@aftertitle}% - \@endpart} + \CTEX@ifnamefalse + \CTEX@makeanchor@spart{part*}% + \CTEX@gettitle{#1}% + \begingroup +% \centering \interlinepenalty \@M \normalfont + \CTEX@heading@format@initial + \CTEX@part@format{% + \CTEX@headinghang{part}{}% +% \Huge \bfseries #1\par% + \CTEX@part@titleformat{#1}% + \CTEX@part@aftertitle}\par + \endgroup + \@endpart} % % \end{macrocode} % \end{macro} @@ -7480,21 +7739,21 @@ Copyright and Licence % \begin{macrocode} %<*book|report> \def\@endpart{% -% \vfil - \CTEX@setheadingskip \CTEX@part@afterskip - \ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi - \vskip \CTEX@headingskip - \newpage - \if@twoside - \if@openright - \null - \thispagestyle{empty}% - \newpage - \fi - \fi - \if@tempswa - \twocolumn - \fi} +% \vfil + \CTEX@setheadingskip \CTEX@part@afterskip + \ifodd \CTEX@part@fixskip \CTEX@fixheadingskip \fi + \vskip \CTEX@headingskip + \newpage + \if@twoside + \if@openright + \null + \thispagestyle{empty}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi} % % \end{macrocode} % \end{macro} @@ -7508,18 +7767,18 @@ Copyright and Licence % \begin{macro}[int]{\chapter} % \begin{macrocode} \renewcommand\chapter{% -% \if@openright\cleardoublepage\else\clearpage\fi -% \thispagestyle{plain}% - \CTEX@chapter@break - \thispagestyle{\CTEX@chapter@pagestyle}% - \global\@topnum\z@ -% \@afterindentfalse - \ifodd \CTEX@chapter@afterindent - \@afterindenttrue - \else - \@afterindentfalse - \fi - \secdef\@chapter\@schapter} +% \if@openright\cleardoublepage\else\clearpage\fi +% \thispagestyle{plain}% + \CTEX@chapter@break + \thispagestyle{\CTEX@chapter@pagestyle}% + \global\@topnum\z@ +% \@afterindentfalse + \ifodd \CTEX@chapter@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \secdef\@chapter\@schapter} % \end{macrocode} % \end{macro} % @@ -7591,26 +7850,26 @@ Copyright and Licence \CTEX@setheadingskip \CTEX@chapter@beforeskip \ifodd \CTEX@chapter@fixskip \CTEX@fixtopskip \fi \vspace*{\CTEX@headingskip}% -% {\normalfont \parindent \z@ \raggedright - {\CTEX@disableautoindent - \normalfont \CTEX@chapter@format - \interlinepenalty\@M -% \ifnum \c@secnumdepth >\m@ne -% \if@mainmatter -% \huge\bfseries\@chapapp\space\thechapter\par\nobreak\vskip 20\p@ -% \fi -% \fi - \CTEX@hangindent{chapter}% - {\CTEXifname{\CTEX@chaptername\CTEX@chapter@aftername}{}}% -% \Huge \bfseries #1\par\nobreak - \CTEX@chapter@titleformat{#1}% - \CTEX@chapter@aftertitle - \nobreak + \begingroup +% \parindent \z@ \raggedright \normalfont + \CTEX@heading@format@initial + \CTEX@chapter@format{% +% \ifnum \c@secnumdepth >\m@ne +% \if@mainmatter +% \huge\bfseries\@chapapp\space\thechapter\par\nobreak\vskip 20\p@ +% \fi +% \fi + \CTEX@headinghang{chapter}% + {\CTEXifname{\CTEX@chaptername\CTEX@chapter@aftername}{}}% +% \Huge \bfseries #1\par\nobreak + \CTEX@chapter@titleformat{#1}% + \CTEX@chapter@aftertitle}\par + \endgroup + \nobreak % \vskip 40\p@ - \CTEX@setheadingskip \CTEX@chapter@afterskip - \ifodd \CTEX@chapter@fixskip \CTEX@fixheadingskip \fi - \vskip \CTEX@headingskip - }} + \CTEX@setheadingskip \CTEX@chapter@afterskip + \ifodd \CTEX@chapter@fixskip \CTEX@fixheadingskip \fi + \vskip \CTEX@headingskip} % \end{macrocode} % \end{macro} % @@ -7621,20 +7880,20 @@ Copyright and Licence \CTEX@setheadingskip \CTEX@chapter@beforeskip \ifodd \CTEX@chapter@fixskip \CTEX@fixtopskip \fi \vspace*{\CTEX@headingskip}% -% {\normalfont \parindent \z@ \raggedright - {\CTEX@disableautoindent - \normalfont \CTEX@chapter@format - \interlinepenalty\@M - \CTEX@hangindent{chapter}{}% -% \Huge \bfseries #1\par\nobreak - \CTEX@chapter@titleformat{#1}% - \CTEX@chapter@aftertitle - \nobreak -% \vskip 40\p@ - \CTEX@setheadingskip \CTEX@chapter@afterskip - \ifodd \CTEX@chapter@fixskip \CTEX@fixheadingskip \fi - \vskip \CTEX@headingskip - }} + \begingroup +% \parindent \z@ \raggedright \normalfont \interlinepenalty\@M + \CTEX@heading@format@initial + \CTEX@chapter@format{% + \CTEX@headinghang{chapter}{}% +% \Huge \bfseries #1\par\nobreak + \CTEX@chapter@titleformat{#1}% + \CTEX@chapter@aftertitle}\par + \endgroup + \nobreak +% \vskip 40\p@ + \CTEX@setheadingskip \CTEX@chapter@afterskip + \ifodd \CTEX@chapter@fixskip \CTEX@fixheadingskip \fi + \vskip \CTEX@headingskip} % \end{macrocode} % \end{macro} % @@ -7645,6 +7904,11 @@ Copyright and Licence % \paragraph{section 类的标题} % % \begin{macro}[int]{\@startsection} +% \LaTeX 的标准参数是: +% \begin{quote}\small +% \Arg{name}\Arg{level}\Arg{indent}\Arg{beforeskip}\Arg{afterskip}^^A +% \Arg{style}|*|\oarg{altheading}\Arg{heading} +% \end{quote} % \begin{macrocode} \def\@startsection#1#2#3#4#5#6{% \if@noskipsec \leavevmode \fi @@ -7707,12 +7971,13 @@ Copyright and Licence % \ifdim \@tempskipa>\z@ \unless \ifodd \CTEX@runin \begingroup + \CTEX@heading@format@initial #6{% - \CTEX@hangfrom{\hskip\glueexpr #3\relax\@svsec}% -% \interlinepenalty \@M #8\@@par}% - \interlinepenalty \@M +% \@hangfrom{\hskip #3\relax\@svsec}% +% \interlinepenalty \@M #8\@@@@par + \CTEX@sectionhang{#3}{\@svsec}% \csname CTEX@#1@titleformat\endcsname{#8}% - \csname CTEX@#1@aftertitle\endcsname}% + \csname CTEX@#1@aftertitle\endcsname}\par \endgroup \csname #1mark\endcsname{#7}% % \addcontentsline{toc}{#1}{% @@ -7723,18 +7988,18 @@ Copyright and Licence \CTEX@addtocline{#1}{#7}% \else \def\@svsechd{% - #6{\hskip\glueexpr #3\relax -% \@svsec #8}% - \@svsec - \csname CTEX@#1@titleformat\endcsname{#8}% - \csname CTEX@#1@aftertitle\endcsname}% - \csname #1mark\endcsname{#7}% -% \addcontentsline{toc}{#1}{% -% \ifnum #2>\c@secnumdepth \else -% \protect\numberline{\csname the#1\endcsname}% -% \fi -% #7}% - \CTEX@addtocline{#1}{#7}}% + #6{% +% \hskip #3\relax \@svsec #8 + {\CTEX@indentbox{#3}}\@svsec + \csname CTEX@#1@titleformat\endcsname{#8}% + \csname CTEX@#1@aftertitle\endcsname}% + \csname #1mark\endcsname{#7}% +% \addcontentsline{toc}{#1}{% +% \ifnum #2>\c@secnumdepth \else +% \protect\numberline{\csname the#1\endcsname}% +% \fi +% #7}% + \CTEX@addtocline{#1}{#7}}% \fi \@xsect{#5}} % \end{macrocode} @@ -7749,17 +8014,18 @@ Copyright and Licence % \ifdim \@tempskipa>\z@ \unless \ifodd \CTEX@runin \begingroup + \CTEX@heading@format@initial #4{% - \CTEX@hangfrom{\hskip\glueexpr #1\relax}% -% \interlinepenalty \@M #5\@@par}% - \interlinepenalty \@M +% \@hangfrom{\hskip #1}% +% \interlinepenalty \@M #5\@@par + \CTEX@sectionhang{#1}{}% \CTEX@titleformat@n{#5}% - \CTEX@aftertitle}% + \CTEX@aftertitle}\par \endgroup \else -% \def\@svsechd{#4{\hskip\glueexpr #1\relax #5}}% - \def\@svsechd{#4{\hskip\glueexpr #1\relax - \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% +% \def\@svsechd{#4{\hskip #1\relax #5}}% + \def\@svsechd{#4{{\CTEX@indentbox{#1}}% + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} % \end{macrocode} @@ -7789,7 +8055,7 @@ Copyright and Licence \unskip % \@tempskipa #1\relax % \hskip -\@tempskipa - \hskip\glueexpr #1\relax + \CTEX@heading@glue{#1}% \else \clubpenalty \@clubpenalty \everypar{}% @@ -7799,44 +8065,62 @@ Copyright and Licence % \end{macrocode} % \end{macro} % +% \begin{macro}[int]{\CTEX@headinghang,\CTEX@sectionhang} +% 分别用于用于实现 \tn{part}/\tn{chapter} 和 \tn{section} 类标题的 +% \opt{indent} 和 \opt{hang} 选项。 % \begin{macrocode} -%<@@=ctex> +\cs_new_protected:Npn \CTEX@headinghang #1 + { + \ctex_heading_hang:cnn + { CTEX@#1@hang } + { \use:c { CTEX@#1@indent } } + } +\cs_new_protected:Npn \CTEX@sectionhang + { \ctex_heading_hang:Nnn \CTEX@hang } % \end{macrocode} +% \end{macro} % -% \begin{macro}[int]{\CTEX@hangindent} -% 用于实现 \tn{part} 和 \tn{chapter} 标题的 \opt{indent} 和 \opt{hang} 选项。 +% \begin{macro}[int]{\ctex_heading_hang:Nnn,\ctex_hang_from:n} +% \opt{hang} 选项控制是否采用悬挂缩进,同时设置 \tn{parindent}。 % \begin{macrocode} -\cs_new_protected:Npn \CTEX@hangindent #1#2 +\cs_new_protected:Npn \ctex_heading_hang:Nnn #1#2#3 { - \dim_set:Nn \parindent { \use:c { CTEX@#1@indent } } - \bool_if:cTF { CTEX@#1@hang } - { \@hangfrom { \@@_indent_aux: #2 } } - {#2} + \dim_set:Nn \tex_parindent:D {#2} + \bool_if:NTF #1 + { \ctex_hang_from:n } + { \use:n } + { \@@_insert_indent: #3 } } -\cs_new_protected_nopar:Npn \@@_indent_aux: +\cs_new_protected:Npn \ctex_hang_from:n #1 { - \dim_compare:nNnF \parindent = \c_zero_dim - { \skip_horizontal:n { \parindent } } + \tex_noindent:D + \hbox_set:Nn \l_@@_tmp_box {#1} + \tex_hangindent:D = \box_wd:N \l_@@_tmp_box + \box_use_drop:N \l_@@_tmp_box } +\cs_generate_variant:Nn \ctex_heading_hang:Nnn { c } % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\CTEX@hangfrom} -% \opt{hang} 选项控制是否采用悬挂缩进。 +% \begin{macro}[int]{\ctex_heading_glue:n,\CTEX@heading@glue} +% 如果缩进 |#1| 长度为零,就不插入水平间距。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \CTEX@hangfrom +\cs_new_protected:Npn \ctex_heading_glue:n #1 { - \bool_if:NTF \CTEX@hang - { \@hangfrom } - { \noindent \use:n } + \group_begin: + \skip_set:Nn \l_@@_heading_skip {#1} + \dim_compare:nNnF \l_@@_heading_skip = \c_zero_dim + { \skip_horizontal:N \l_@@_heading_skip } + \group_end: } +\cs_new_eq:NN \CTEX@heading@glue \ctex_heading_glue:n % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\CTEX@update@sectionformat@n} % 在 \tn{@startsection} 中设置 \tn{CTEX@titleformat@n} 等为相应函数。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \CTEX@update@sectionformat@n #1 +\cs_new_protected:Npn \CTEX@update@sectionformat@n #1 { \cs_set_eq:Nc \CTEX@titleformat@n { CTEX@#1@titleformat } \cs_set_eq:Nc \CTEX@aftertitle { CTEX@#1@aftertitle } @@ -7877,7 +8161,7 @@ Copyright and Licence % % \begin{macro}[int]{\CTEXnumberline} % \begin{macrocode} -\cs_new_nopar:Npn \CTEXnumberline #1 +\cs_new:Npn \CTEXnumberline #1 { \CTEXifname { \protect \numberline { \use:c { CTEXthe #1 } } } @@ -7891,7 +8175,7 @@ Copyright and Licence \seq_map_inline:Nn \c_@@_section_headings_seq { \int_incr:N \l_@@_tmp_int - \cs_gset_protected_nopar:cpx {#1} + \cs_gset_protected:cpx {#1} { \exp_not:N \@startsection {#1} { \int_use:N \l_@@_tmp_int } @@ -7909,7 +8193,7 @@ Copyright and Licence % % \begin{macro}[int]{appendix/name,appendix/number,appendix/numbering} % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { appendix .meta:nn = { ctex / appendix } {#1} , appendix / name .code:n = @@ -7926,7 +8210,7 @@ Copyright and Licence % \begin{macro}[int]{\appendix} % \begin{macrocode} \cs_new_eq:NN \CTEX@save@appendix \appendix -\cs_gset_protected_nopar:Npn \appendix +\cs_gset_protected:Npn \appendix { \CTEX@save@appendix %<*article> @@ -7952,7 +8236,7 @@ Copyright and Licence % \begin{macro}[int]{\CTEX@makeanchor} % 设置超链接跳转锚点,在 \pkg{hyperref} 载入后才有意义。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \CTEX@makeanchor #1 +\cs_new_protected:Npn \CTEX@makeanchor #1 { } % \end{macrocode} % \end{macro} @@ -7976,7 +8260,7 @@ Copyright and Licence % \opt{implicit} 选项的控制)。我们在上面对标题命令的修改已经包含这一功能,如果这些标题命令在 % \pkg{hyperref} 载入之前没有被修改过,则恢复 \CTeX{} 的定义。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \CTEX@hyperheadinghook +\cs_new_protected:Npn \CTEX@hyperheadinghook { \group_begin: \ifHy@implicit @@ -8001,7 +8285,7 @@ Copyright and Licence % \begin{macrocode} \ctex_at_end_package:nn { hyperref } { - \cs_gset_protected_nopar:Npn \CTEX@makeanchor #1 + \cs_gset_protected:Npn \CTEX@makeanchor #1 { \Hy@MakeCurrentHrefAuto {#1} \Hy@raisedlink @@ -8025,7 +8309,7 @@ Copyright and Licence { } \ctex_at_end_package:nn { nameref } { - \cs_gset_protected_nopar:Npn \CTEX@gettitle { \NR@gettitle } + \cs_gset_protected:Npn \CTEX@gettitle { \NR@gettitle } \seq_map_inline:Nn \c_@@_headings_cs_seq { \cs_if_eq:ccT { NR@ #1 } { CTEX@ #1 } @@ -8062,7 +8346,7 @@ Copyright and Licence % 如果使用了 \pkg{titlesec} 的 \opt{indentafter} 等选项,也不需要调整 % |\ttls@|\meta{section}。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_titlesec_hook: +\cs_new_protected:Npn \ctex_titlesec_hook: { \@ifpackagewith { titlesec } { explicit } { @@ -8082,17 +8366,17 @@ Copyright and Licence } \seq_map_function:NN \c_@@_section_headings_seq \@@_titlesec_hook:n } -\cs_new_protected_nopar:Npn \@@_titlesec_hook:n #1 +\cs_new_protected:Npn \@@_titlesec_hook:n #1 { \@@_titlesec_format:n {#1} \exp_args:Nc \@@_titlesec_spacing:Nn { ttls@#1 } {#1} } -\cs_new_protected_nopar:Npn \@@_titlesec_format:n #1 +\cs_new_protected:Npn \@@_titlesec_format:n #1 { \cs_if_free:cF { ttlf@#1 } { \exp_args:Nc \@@_titlesec_format:Nn { ttlf@#1 } {#1} } } -\cs_new_protected_nopar:Npn \@@_titlesec_format:Nn #1#2 +\cs_new_protected:Npn \@@_titlesec_format:Nn #1#2 { \tl_set:Nx #1 { @@ -8102,7 +8386,7 @@ Copyright and Licence \tl_tail:N #1 } } -\cs_new_protected_nopar:Npn \@@_titlesec_format_explicit:Nn #1#2 +\cs_new_protected:Npn \@@_titlesec_format_explicit:Nn #1#2 { \cs_set_nopar:Npx #1 ##1 { @@ -8112,7 +8396,7 @@ Copyright and Licence \exp_args:No \tl_tail:n { #1 { } } } } -\cs_new_protected_nopar:Npn \@@_titlesec_spacing:Nn #1#2 +\cs_new_protected:Npn \@@_titlesec_spacing:Nn #1#2 { \tl_set:Nx #1 { \exp_after:wN \@@_titlesec_spacing:nnnnnn #1 {#2} } } \cs_new:Npn \@@_titlesec_spacing:nnnnnn #1#2#3#4#5#6 { @@ -8145,14 +8429,14 @@ Copyright and Licence % \cs_if_free:NF \ttl@tocpart { - \cs_set_protected_nopar:Npn \ttl@tocpart + \cs_set_protected:Npn \ttl@tocpart { \tl_set:Nn \ttl@a { \CTEXthepart \hspace { 1em } } } } \seq_map_inline:Nn \c_@@_headings_seq { \cs_if_exist:cF { ttl@toc #1 } { - \cs_new_protected_nopar:cpx { ttl@toc #1 } + \cs_new_protected:cpx { ttl@toc #1 } { \tl_set:Nn \exp_not:N \ttl@a { @@ -8178,7 +8462,7 @@ Copyright and Licence % \begin{macrocode} \group_begin: \char_set_catcode_other:N \# -\cs_new_protected_nopar:Npn \ctex_titleps_hook: +\cs_new_protected:Npn \ctex_titleps_hook: { \ctex_patch_cmd:Nnn \ttl@settopmark { \protect \@namedef { the#1 } { \@nameuse { the#1 } } } @@ -8207,12 +8491,12 @@ Copyright and Licence % 这两个函数要在随后被 \tn{xdef} 展开来获得 |\CTEXtheXXX| 的内容,不应该用 % \tn{protected} 来定义。 % \begin{macrocode} -\cs_new_nopar:Npn \CTEX@titlepslabel@set #1 +\cs_new:Npn \CTEX@titlepslabel@set #1 { \cs_if_free:cF { CTEXthe#1 } { \protect \@namedef { CTEXthe#1 } { \@nameuse { CTEXthe#1 } } } } -\cs_new_nopar:Npn \CTEX@titlepslabel@clear #1 +\cs_new:Npn \CTEX@titlepslabel@clear #1 { \cs_if_free:cF { CTEXthe#1 } { \protect \@namedef { CTEXthe#1 } { } } @@ -8240,9 +8524,9 @@ Copyright and Licence % \begin{macrocode} \ctex_at_end_package:nn { titleps } { - \cs_set_protected_nopar:Npn \ttl@setifthe #1 + \cs_set_protected:Npn \ttl@setifthe #1 { - \exp_args:Nco \cs_set_nopar:Npn { ifthe #1 } + \exp_args:Nco \cs_set:Npn { ifthe #1 } { \CTEXifname { \protect \@firstoftwo } @@ -8257,7 +8541,7 @@ Copyright and Licence % % \subsubsection{目录标签的宽度} % -% \begin{macro}[int]{\numberline} +% \begin{macro}{\CTEX@toc@width@n} % \begin{macrocode} \cs_new_protected:Npn \CTEX@toc@width@n #1 { @@ -8268,6 +8552,17 @@ Copyright and Licence { \box_wd:N \l_@@_tmp_box + \f@size \p@ / 2 } } } +% \end{macrocode} +% \end{macro} +% +% \changes{v2.5}{2020/01/11}{兼容 \pkg{titletoc} 宏包。} +% +% \begin{macro}{\numberline,\@@_patch_toc_width:n} +% 为 \tn{numberline} 命令打补丁,并兼容 \pkg{tocloft} 和 \pkg{titletoc} 宏包。 +% +% 这里需要替换 |#| 本身,因此需要先切换为 other 类。表示参数的 |#| 用 +% \cs{c_parameter_token} 代替。 +% \begin{macrocode} \group_begin: \char_set_catcode_other:N \# \use:n @@ -8277,19 +8572,24 @@ Copyright and Licence { \CTEX@toc@width@n {#1} } { } { \ctex_patch_failure:N \numberline } - \@ifpackageloaded { tocloft } - { } + \cs_new_protected:Npn \@@_patch_toc_width:n \c_parameter_token 1 { - \ctex_at_end_package:nn { tocloft } + \@ifpackageloaded { \c_parameter_token 1 } + { } { - \ctex_preto_cmd:NnnTF \numberline - { \char_set_catcode_letter:n { 64 } } - { \CTEX@toc@width@n {#1} } - { } - { \ctex_patch_failure:N \numberline } + \ctex_at_end_package:nn { \c_parameter_token 1 } + { + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } + { \ctex_patch_failure:N \numberline } + } } } } +\@@_patch_toc_width:n { tocloft } +\@@_patch_toc_width:n { titletoc } % \end{macrocode} % \end{macro} % @@ -8385,72 +8685,69 @@ Copyright and Licence % \begin{macrocode} \defbeamertemplate*{part page}{CTEX}[1][]{% \begingroup - \CTEX@disableautoindent % \centering % {\usebeamerfont{part name}% % \usebeamercolor[fg]{part name}\partname~\insertromanpartnumber} % \vskip1em\par \par \addvspace{\glueexpr\CTEX@part@beforeskip\relax}% - \CTEX@part@format - \parindent \dimexpr \CTEX@part@indent \relax - \ifodd \CTEX@part@numbering - \CTEX@partname \CTEX@part@aftername - \fi - \begin{beamercolorbox}[sep=16pt,center,#1]{part title} -% \usebeamerfont{part title}\insertpart\par - \CTEX@part@titleformat \insertpart \CTEX@part@aftertitle - \end{beamercolorbox}% + \CTEX@heading@format@initial + \CTEX@part@format{% + \CTEX@indentbox{\CTEX@part@indent}% + \ifodd \CTEX@part@numbering + \CTEX@partname \CTEX@part@aftername + \fi + \begin{beamercolorbox}[sep=16pt,center,#1]{part title} +% \usebeamerfont{part title}\insertpart\par + \CTEX@part@titleformat \insertpart \CTEX@part@aftertitle + \end{beamercolorbox}}% \par \addvspace{\glueexpr\CTEX@part@afterskip\relax}% - \endgroup -} + \endgroup} % \end{macrocode} % % 对应 \tn{sectionpage}。 % \begin{macrocode} \defbeamertemplate*{section page}{CTEX}[1][]{% \begingroup - \CTEX@disableautoindent % \centering % {\usebeamerfont{section name}% % \usebeamercolor[fg]{section name}\sectionname~\insertsectionnumber} % \vskip1em\par \par \addvspace{\glueexpr\CTEX@section@beforeskip\relax}% - \CTEX@section@format - \parindent \dimexpr \CTEX@section@indent \relax - \ifodd \CTEX@section@numbering - \CTEX@sectionname \CTEX@section@aftername - \fi - \begin{beamercolorbox}[sep=12pt,center,#1]{part title} -% \usebeamerfont{section title}\insertsection\par - \CTEX@section@titleformat \insertsection \CTEX@section@aftertitle - \end{beamercolorbox}% + \CTEX@heading@format@initial + \CTEX@section@format{% + \CTEX@indentbox{\CTEX@section@indent}% + \ifodd \CTEX@section@numbering + \CTEX@sectionname \CTEX@section@aftername + \fi + \begin{beamercolorbox}[sep=12pt,center,#1]{part title} +% \usebeamerfont{section title}\insertsection\par + \CTEX@section@titleformat \insertsection \CTEX@section@aftertitle + \end{beamercolorbox}}% \par \addvspace{\glueexpr\CTEX@section@afterskip\relax}% - \endgroup -} + \endgroup} % \end{macrocode} % % 对应 \tn{subsectionpage}。 % \begin{macrocode} \defbeamertemplate*{subsection page}{CTEX}[1][]{% \begingroup - \CTEX@disableautoindent % \centering % {\usebeamerfont{subsection name}% % \usebeamercolor[fg]{subsection name}\subsectionname~\insertsubsectionnumber} % \vskip1em\par \par \addvspace{\glueexpr\CTEX@subsection@beforeskip\relax}% - \CTEX@subsection@format - \parindent \dimexpr \CTEX@subsection@indent \relax - \ifodd \CTEX@subsection@numbering - \CTEX@subsectionname \CTEX@subsection@aftername - \fi - \begin{beamercolorbox}[sep=8pt,center,#1]{part title} -% \usebeamerfont{subsection title}\insertsubsection\par - \CTEX@subsection@titleformat \insertsubsection \CTEX@subsection@aftertitle - \end{beamercolorbox}% + \CTEX@heading@format@initial + \CTEX@subsection@format{% + \CTEX@indentbox{\CTEX@subsection@indent}% + \ifodd \CTEX@subsection@numbering + \CTEX@subsectionname \CTEX@subsection@aftername + \fi + \begin{beamercolorbox}[sep=8pt,center,#1]{part title} +% \usebeamerfont{subsection title}\insertsubsection\par + \CTEX@subsection@titleformat \insertsubsection \CTEX@subsection@aftertitle + \end{beamercolorbox}}% \par \addvspace{\glueexpr\CTEX@subsection@afterskip\relax}% - \endgroup -} + \endgroup} % \end{macrocode} % % 将 \cls{beamer} 的默认模板重定向为 \texttt{CTEX} 模板。 @@ -8473,7 +8770,7 @@ Copyright and Licence % \begin{macro}[int]{\refstepcounter} % 对标题进行引用时,设置标签为通过 \opt{number} 选项设置的形式。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 +\cs_new_protected:Npn \CTEX@setcurrentlabel@n #1 { \protected@edef \@currentlabel { @@ -8490,8 +8787,9 @@ Copyright and Licence % \pkg{hyperref} 宏包都会保存之前的定义,并且它们都要求尽可能晚的被载入,所以 % 对我们上述的修改影响不大。需要注意的是 \pkg{varioref} 宏包,如果它在 % \CTeX{} 之后被载入,我们之前的修改将会被覆盖。 +% 较新版 \LaTeX \ 内核已经包含 \tn{labelformat},可以直接使用。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_varioref_hook: +\cs_new_protected:Npn \ctex_varioref_hook: { \seq_map_inline:Nn \c_@@_headings_seq { \ctex_fix_varioref_label:n { ##1 } } @@ -8510,17 +8808,19 @@ Copyright and Licence % \end{verbatim} % 它的第二个参数必须放在花括号内,否则将会被作为宏的定界符号。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_fix_varioref_label:n #1 +\cs_new_protected:Npn \ctex_fix_varioref_label:n #1 { \tl_if_empty:cT { p@#1 } - { \exp_args:Nno \labelformat {#1} { \cs:w CTEX@the#1 \cs_end: } } + { \exp_args:Nnx \labelformat {#1} { \exp_not:c { CTEX@the#1 } } } } % \end{macrocode} % \end{macro} % +% \changes{v2.5}{2020/04/19}{应用新内核中的 \tn{labelformat}。} +% % 如果 \pkg{varioref} 已经被载入,则使用它来设置。 % \begin{macrocode} -\@ifpackageloaded { varioref } +\cs_if_exist:NTF \labelformat { \ctex_varioref_hook: } { \cs_new_eq:NN \CTEX@save@refstepcounter \refstepcounter @@ -8558,7 +8858,7 @@ Copyright and Licence % 标题的 \opt{nameformat} 和 \opt{titleformat} 选项的初值合并到 \opt{format} 中。} % % \begin{macrocode} -\keys_set:nn { ctex / part } +\ctex_set:nn { part } { aftertitle = \par , %<*article|book|report> @@ -8619,7 +8919,7 @@ Copyright and Licence % % \begin{macrocode} %<*book|report> -\keys_set:nn { ctex / chapter } +\ctex_set:nn { chapter } { pagestyle = plain , aftertitle = \par , @@ -8650,16 +8950,12 @@ Copyright and Licence % \end{macrocode} % % \begin{macrocode} -%<@@=> -% \end{macrocode} -% -% \begin{macrocode} -\keys_set:nn { ctex / section } +\ctex_set:nn { section } { %<*article|book|report> number = \thesection , aftername = \quad , - aftertitle = \@@par , + aftertitle = \@@@@par , beforeskip = 3.5ex \@plus 1ex \@minus .2ex , afterskip = 2.3ex \@plus .2ex , runin = false , @@ -8689,13 +8985,13 @@ Copyright and Licence % \end{macrocode} % % \begin{macrocode} -\keys_set:nn { ctex / subsection } +\ctex_set:nn { subsection } { %<*article|book|report> number = \thesubsection , format = \large \bfseries , aftername = \quad , - aftertitle = \@@par , + aftertitle = \@@@@par , beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , runin = false , @@ -8730,12 +9026,12 @@ Copyright and Licence % \end{macrocode} % % \begin{macrocode} -\keys_set:nn { ctex / subsubsection } +\ctex_set:nn { subsubsection } { number = \thesubsubsection , format = \normalsize \bfseries , aftername = \quad , - aftertitle = \@@par , + aftertitle = \@@@@par , beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , runin = false , @@ -8750,7 +9046,7 @@ Copyright and Licence % \end{macrocode} % % \begin{macrocode} -\keys_set:nn { ctex / paragraph } +\ctex_set:nn { paragraph } { number = \theparagraph , format = \normalsize \bfseries , @@ -8767,7 +9063,7 @@ Copyright and Licence % \end{macrocode} % % \begin{macrocode} -\keys_set:nn { ctex / subparagraph } +\ctex_set:nn { subparagraph } { number = \thesubparagraph , format = \normalsize \bfseries , @@ -8787,15 +9083,15 @@ Copyright and Licence % \begin{macrocode} \int_compare:nNnTF \g__ctex_section_depth_int > 2 { - \keys_set:nn { ctex / paragraph } + \ctex_set:nn { paragraph } { - aftertitle = \@@par , + aftertitle = \@@@@par , afterskip = 1ex \@plus .2ex , runin = false } } { - \keys_set:nn { ctex / paragraph } + \ctex_set:nn { paragraph } { afterskip = 1em , runin = true @@ -8803,32 +9099,28 @@ Copyright and Licence } \int_compare:nNnTF \g__ctex_section_depth_int > 3 { - \keys_set:nn { ctex / subparagraph } + \ctex_set:nn { subparagraph } { - aftertitle = \@@par , + aftertitle = \@@@@par , afterskip = 1ex \@plus .2ex , runin = false } } { - \keys_set:nn { ctex / subparagraph } + \ctex_set:nn { subparagraph } { afterskip = 1em , runin = true } } \int_compare:nNnTF \g__ctex_section_depth_int > 2 - { \keys_set:nn { ctex / subparagraph } { indent = \c_zero_dim } } - { \keys_set:nn { ctex / subparagraph } { indent = \parindent } } -% \end{macrocode} -% -% \begin{macrocode} -%<@@=ctex> + { \ctex_set:nn { subparagraph } { indent = \c_zero_dim } } + { \ctex_set:nn { subparagraph } { indent = \parindent } } % \end{macrocode} % % 处理附录的格式。 % \begin{macrocode} -\keys_set:nn { ctex / appendix } +\ctex_set:nn { appendix } %<*article> { number = \@Alph \c@section } % @@ -8890,7 +9182,7 @@ Copyright and Licence { \tl_const:Nn \c_@@_class_tl { article } } \msg_warning:nnx { ctex } { not-standard-class } { \c_@@_class_tl } } - \ctex_file_input:n { ctex- \c_@@_class_tl .def } + \ctex_file_input:n { ctex-heading- \c_@@_class_tl .def } } % { \ctex_scheme_input:o { \l_@@_scheme_tl } } % \end{macrocode} @@ -8943,19 +9235,19 @@ Copyright and Licence % % 日期格式。 % \begin{macrocode} -\keys_set:nn { ctex } { today = small } +\ctex_set:n { today = small } % \end{macrocode} % % 若用户未设置宏包选项 \opt{autoindent},则自动调整首行缩进。 % \begin{macrocode} \ctex_if_autoindent_touched:F - { \keys_set:nn { ctex } { autoindent = true } } + { \ctex_set:n { autoindent = true } } % \end{macrocode} % % 使用标题定义时的设置。首先是命题名字汉化。\cls{beamer} 需要汉化定理名称。 % \begin{macrocode} %<*!generic> -\str_if_eq:onTF { \l_@@_encoding_tl } { GBK } +\str_if_eq:onTF { \g_@@_encoding_tl } { GBK } %<*beamer> { \uselanguage { ChineseGBK } @@ -8989,19 +9281,19 @@ Copyright and Licence % 对 \cls{beamer} 以外的文档类,若用户未设置宏包选项 \opt{linespread},则设置行 % 距初始值为 $1.3\times 1.2=1.56$ 倍字体大小。\cls{beamer} 不调整行距。 % \begin{macrocode} -\fp_compare:nNnT { \l_@@_line_spread_fp } ? { \c_zero_fp } +\fp_if_nan:nT { \l_@@_line_spread_fp } { \fp_set:Nn \l_@@_line_spread_fp { 1.3 } } % % % \end{macrocode} % -% 不使用标题定义时的通用设置。 +% 不使用标题定义时的通用设置,注意此处 \cs{c_@@_std_class_tl} 可能没有定义。 % \begin{macrocode} %<*generic> \tl_set:Nn \l_@@_tmp_tl { beamer } \tl_if_eq:NNTF \c_@@_std_class_tl \l_@@_tmp_tl { - \str_if_eq:onTF { \l_@@_encoding_tl } { GBK } + \str_if_eq:onTF { \g_@@_encoding_tl } { GBK } { \uselanguage { ChineseGBK } \languagealias { chinese } { ChineseGBK } @@ -9015,12 +9307,12 @@ Copyright and Licence \clist_put_left:Nn \trans@languagepath { chinese } } { - \str_if_eq:onTF { \l_@@_encoding_tl } { GBK } + \str_if_eq:onTF { \g_@@_encoding_tl } { GBK } { \ctex_file_input:n { ctex-name-gbk.cfg } } { \ctex_file_input:n { ctex-name-utf8.cfg } } \int_compare:nNnF \g_@@_font_size_int > { -1 } { \int_gset:Nn \g_@@_font_size_int { 0 } } - \fp_compare:nNnT { \l_@@_line_spread_fp } ? { \c_zero_fp } + \fp_if_nan:nT { \l_@@_line_spread_fp } { \fp_set:Nn \l_@@_line_spread_fp { 1.3 } } % \end{macrocode} % \changes{v2.0.2}{2015/05/16}{修复加载 \pkg{ctex} 宏包后章节标题后第一段 @@ -9055,7 +9347,7 @@ Copyright and Licence % % \begin{macro}[int]{\ctex_zihao:n} % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_zihao:n #1 +\cs_new_protected:Npn \ctex_zihao:n #1 { \prop_get:NnNTF \c_@@_font_size_prop {#1} \l_@@_font_size_tl { \exp_after:wN \fontsize \l_@@_font_size_tl \selectfont } @@ -9083,7 +9375,7 @@ Copyright and Licence % \begin{macrocode} \prop_new:N \c_@@_font_size_prop \seq_new:N \c_@@_font_size_seq -\cs_new_protected_nopar:Npn \@@_save_font_size:nn #1#2 +\cs_new_protected:Npn \@@_save_font_size:nn #1#2 { \use:x { @@ -9121,7 +9413,7 @@ Copyright and Licence % % \begin{macro}[int]{\ctex_declare_math_sizes:nnnn} % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4 +\cs_new_protected:Npn \ctex_declare_math_sizes:nnnn #1#2#3#4 { \@@_get_font_sizes:Nn \l_@@_font_size_tl { {#1} {#2} {#3} {#4} } \exp_after:wN \DeclareMathSizes \l_@@_font_size_tl @@ -9131,7 +9423,7 @@ Copyright and Licence % % \begin{macro}{\@@_get_font_sizes:Nn} % \begin{macrocode} -\cs_new_protected_nopar:Npn \@@_get_font_sizes:Nn #1#2 +\cs_new_protected:Npn \@@_get_font_sizes:Nn #1#2 { \tl_clear:N #1 \tl_map_inline:nn {#2} @@ -9178,16 +9470,16 @@ Copyright and Licence { \msg_error:nnn { ctex } { fontsize } {#2} } } \cs_new_protected:Npn \@@_set_font_size:nnNn #1#2#3#4 - { \cs_set_protected_nopar:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } } + { \cs_set_protected:Npn #3 { \@setfontsize #3 {#1} {#2} #4 } } % \end{macrocode} % \end{macro} % % \begin{macrocode} -\if_case:w \g_@@_font_size_int - \ctex_file_input:n { ctex-c5size.clo } -\or: - \ctex_file_input:n { ctex-cs4size.clo } -\fi: +\int_case:nn { \g_@@_font_size_int } + { + { 0 } { \ctex_file_input:n { ctex-c5size.clo } } + { 1 } { \ctex_file_input:n { ctex-cs4size.clo } } + } % \end{macrocode} % % \begin{macrocode} @@ -9287,7 +9579,7 @@ Copyright and Licence % % \cs{l_@@_line_spread_fp} 被设置了才有必要更新行距和 \tn{footnotesep}。 % \begin{macrocode} -\fp_compare:nNnF { \l_@@_line_spread_fp } ? { \c_zero_fp } +\fp_if_nan:nF { \l_@@_line_spread_fp } { \exp_args:Nx \linespread { \fp_use:N \l_@@_line_spread_fp } % \end{macrocode} @@ -9310,7 +9602,7 @@ Copyright and Licence \normalsize % \end{macrocode} % -% \subsection{其它功能} +% \subsection{其他功能} % % \begin{macro}{\CTeX} % \changes{v2.4.12}{2017/12/05}{不依赖 \tn{ifincsname}。} @@ -9332,11 +9624,11 @@ Copyright and Licence % \begin{macro}{captiondelimiter} % 过时选项。 % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { captiondelimiter .code:n = { - \msg_warning:nnn { ctex } { deprecated-option } + \ctex_deprecated_option:n { You~can~load~the~package~`caption'~to~get~its~functionality. } } } @@ -9368,56 +9660,113 @@ Copyright and Licence % {解决 \pkg{etoolbox} 与 \pkg{breqn} 关于 \tn{end} 的冲突。} % \changes{v2.2}{2015/06/23}{删去 \pkg{etoolbox} 与 \pkg{breqn} 的兼容补丁。} % -% \subsection{载入中文字体} +% \subsection{载入中文字库} % % \begin{macro}[int]{\ctex_fontset_error:n} % 字库不可用时给出紧急错误信息,停止读取定义文件。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_fontset_error:n #1 +\cs_new_protected:Npn \ctex_fontset_error:n #1 { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} } \msg_new:nnn { ctex } { fontset-unavailable } { CTeX~fontset~`#1'~is~unavailable~in~current~mode. } % \end{macrocode} % \end{macro} % +% \begin{macro}{\ctex_fontset_case:nnn} +% $3$ 个参数依次为 \pdfTeX、\upTeX\ 和 \XeTeX/\LuaTeX。 +% \begin{macrocode} +\cs_new:Npx \ctex_fontset_case:nnn #1#2#3 + { + \sys_if_engine_pdftex:TF + {#1} + { \sys_if_engine_uptex:TF {#2} {#3} } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ctex_fontset_case:nnnn} +% $4$ 个参数依次为 \pdfTeX(生成 PDF)、\pdfTeX(生成 DVI)、\upTeX 和 +% \XeTeX/\LuaTeX。 +% \begin{macrocode} +\cs_new:Npx \ctex_fontset_case:nnnn #1#2#3#4 + { + \sys_if_engine_pdftex:TF + { \sys_if_output_pdf:TF {#1} {#2} } + { \sys_if_engine_uptex:TF {#3} {#4} } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_detect_platform:} +% 根据操作系统判断默认字体配置。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_detect_platform: + { + \sys_if_platform_windows:TF + { \tl_gset:Nn \g_@@_fontset_tl { windows } } + { + \ctex_if_platform_macos:TF + { \tl_gset:Nn \g_@@_fontset_tl { mac } } + { \tl_gset:Nn \g_@@_fontset_tl { fandol } } + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_if_platform_macos:TF} +% \changes{v2.1}{2015/06/17}{改用 \file{/Library/Fonts/Songti.ttc} 为特征文件。} +% \changes{v2.5}{2019/10/25}{改用 \file{/System/Library/Fonts/Menlo.ttc} +% 为特征文件。} +% 以特定字体判断 macOS 系统。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_if_platform_macos:TF + { \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[int]{\ctex_load_fontset:} % 如果用户没有指定字体,则探测操作系统,载入相应的字体配置。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_load_fontset: +\cs_new_protected:Npn \ctex_load_fontset: { \tl_if_empty:NTF \g_@@_fontset_tl + { \ctex_detect_platform: } { - \ctex_detected_platform: - \ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def } - } - { - \file_if_exist:nTF { ctex-fontset- \g_@@_fontset_tl .def } - { \ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def } } + \bool_lazy_or:nnTF + { \str_if_eq_p:on { \g_@@_fontset_tl } { windowsnew } } + { \str_if_eq_p:on { \g_@@_fontset_tl } { windowsold } } { - \use:x + \msg_warning:nnxx { ctex } { deprecated-fontset } + { \g_@@_fontset_tl } { windows } + \tl_gset:Nn \g_@@_fontset_tl { windows } + } + { + \file_if_exist:nF { ctex-fontset- \g_@@_fontset_tl .def } { - \ctex_detected_platform: - \msg_error:nnxx { ctex } { fontset-not-found } - { \g_@@_fontset_tl } { \exp_not:N \g_@@_fontset_tl } + \use:x + { + \ctex_detect_platform: + \msg_error:nnxx { ctex } { fontset-not-found } + { \g_@@_fontset_tl } { \exp_not:N \g_@@_fontset_tl } + } } - \ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def } } } + \ctex_file_input:n { ctex-fontset- \g_@@_fontset_tl .def } } -\@onlypreamble \ctex_load_fontset: +\msg_new:nnn { ctex } { deprecated-fontset } + { CTeX~fontset~`#1'~is~deprecated.\\ Fontset~`#2'~will~be~used~instead. } \msg_new:nnnn { ctex } { fontset-not-found } - { - CTeX~fontset~`#1'~could~not~be~found.\\ - Fontset~`#2'~will~be~used~instead. - } + { CTeX~fontset~`#1'~could~not~be~found.\\ Fontset~`#2'~will~be~used~instead. } { You~may~run~`mktexlsr'~firstly. } +\@onlypreamble \ctex_load_fontset: % \end{macrocode} % \end{macro} % % \begin{macro}{fontset} % 在导言区通过 \tn{ctexset} 载入中文字库的选项。 % \begin{macrocode} -\keys_define:nn { ctex } +\ctex_define:n { fontset .code:n = { @@ -9447,9 +9796,7 @@ Copyright and Licence } { Only~one~fontset~can~be~loaded~in~the~preamble. } \msg_new:nnn { ctex } { fontset-only-preamble } - { - The~ `fontset'~ option~ can~ be~ used~ only~ in~ preamble. - } + { The~`fontset'~option~can~be~used~only~in~preamble. } % \end{macrocode} % \end{macro} % @@ -9479,11 +9826,11 @@ Copyright and Licence % % \subsubsection{\pkg{ctexopts.cfg}} % -% 这里仅为配置文件示例:使用 Windows Vista 或以后版本的字体设置。 +% 这里仅为配置文件示例:使用 Windows 下的字体设置。 % \begin{macrocode} %<*ctexopts> %% -%% \keys_set:nn { ctex / option } { fontset = windowsnew } +%% \ctex_set:nn { option } { fontset = windows } % % \end{macrocode} % @@ -9555,11 +9902,13 @@ Copyright and Licence %<*jy2> \DeclareFontShape{JY2}{zhrm}{m}{n}{<-> upzhserif-h}{} \DeclareFontShape{JY2}{zhrm}{m}{it}{<-> upzhserifit-h}{} +\DeclareFontShape{JY2}{zhrm}{b}{n}{<-> upzhserifb-h}{} \DeclareFontShape{JY2}{zhrm}{bx}{n}{<-> upzhserifb-h}{} % %<*jt2> \DeclareFontShape{JT2}{zhrm}{m}{n}{<-> upzhserif-v}{} \DeclareFontShape{JT2}{zhrm}{m}{it}{<-> upzhserifit-v}{} +\DeclareFontShape{JT2}{zhrm}{b}{n}{<-> upzhserifb-v}{} \DeclareFontShape{JT2}{zhrm}{bx}{n}{<-> upzhserifb-v}{} % % @@ -9591,10 +9940,12 @@ Copyright and Licence % %<*jy2> \DeclareFontShape{JY2}{zhsf}{m}{n}{<-> upzhsans-h}{} +\DeclareFontShape{JY2}{zhsf}{b}{n}{<-> upzhsansb-h}{} \DeclareFontShape{JY2}{zhsf}{bx}{n}{<-> upzhsansb-h}{} % %<*jt2> \DeclareFontShape{JT2}{zhsf}{m}{n}{<-> upzhsans-v}{} +\DeclareFontShape{JT2}{zhsf}{b}{n}{<-> upzhsansb-v}{} \DeclareFontShape{JT2}{zhsf}{bx}{n}{<-> upzhsansb-v}{} % % @@ -9633,307 +9984,238 @@ Copyright and Licence % % \end{macrocode} % +% \subsubsection{预定义字库} +% % \begin{macrocode} %<*fontset> % \end{macrocode} % -% \subsubsection{\pkg{ctex-fontset-windows.def} 等} +% \paragraph{\opt{adobe}} % -% \changes{v2.4.1}{2016/05/14}{使用 \file{bootfont.bin} 判断 Windows XP 以避免 -% 权限问题。} -% \pkg{ctex} 包利用 |C:\bootfont.bin| 文件的存在性来判断是否使用 Windows XP 版 -% 本,分别载入新旧字体设置。(注:\pkg{ctex} 包不支持 Windows 2000 以前使用 -% \file{simsun.ttf} 的旧宋体文件名。) -% \begin{macrocode} -%<*windows> -\file_if_exist:nTF { C:/bootfont.bin } - { \ctex_file_input:n { ctex-fontset-windowsold.def } } - { \ctex_file_input:n { ctex-fontset-windowsnew.def } } -% -% \end{macrocode} -% -% 旧的 Windows 字体设置使用黑体作为无衬线体,楷体和仿宋是 GB2312 编码;新的 -% Windows 字体设置使用微软雅黑作为无衬线体,楷体和仿宋是大字库。 -% Windows 8 以后,微软雅黑由原来的 \file{.ttf} 后缀改为 \file{.ttc} 后缀,需要 -% 加以区分。 +% \tn{pdfmapline} 不支持 OpenType 字体,因而 \opt{adobe} 字体集在 pdf 模式下 +% 就没有定义。\opt{fandol} 的情况类似。 % \begin{macrocode} -%<*windowsnew> -\tl_new:N \l_@@_msyh_suffix_tl -\tl_set:Nn \l_@@_msyh_suffix_tl { .ttc } -\file_if_exist:nF { C:/Windows/Fonts/msyh.ttc } - { - \file_if_exist:nF { msyh.ttc } - { \tl_set:Nn \l_@@_msyh_suffix_tl { .ttf } } - } -% -%<*windowsnew|windowsold> -\sys_if_engine_pdftex:TF +%<*adobe> +\ctex_fontset_case:nnnn + { \ctex_fontset_error:n { adobe } } { \ctex_zhmap_case:nnn { - \ctex_punct_set:n { windows } - \setCJKmainfont - [ BoldFont = simhei.ttf , ItalicFont = simkai.ttf ] { simsun.ttc } -%<*windowsold> - \setCJKsansfont { simhei.ttf } - \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } -% -%<*windowsnew> - \setCJKsansfont - [ BoldFont = msyhbd\l_@@_msyh_suffix_tl ] { msyh\l_@@_msyh_suffix_tl } - \setCJKfamilyfont { zhyahei } - [ BoldFont = msyhbd\l_@@_msyh_suffix_tl ] { msyh\l_@@_msyh_suffix_tl } - \ctex_punct_map_family:nn { \CJKsfdefault } { zhyahei } - \ctex_punct_map_bfseries:nn { \CJKsfdefault , zhyahei } { zhyaheib } -% - \setCJKmonofont { simfang.ttf } - \setCJKfamilyfont { zhkai } { simkai.ttf } - \setCJKfamilyfont { zhfs } { simfang.ttf } - \setCJKfamilyfont { zhsong } { simsun.ttc } - \setCJKfamilyfont { zhhei } { simhei.ttf } - \setCJKfamilyfont { zhli } { simli.ttf } - \setCJKfamilyfont { zhyou } { simyou.ttf } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } - \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } - } - { - \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhwindowsfonts } - \ctex_punct_set:n { windows } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } - } - { - \tl_set:Nn \CJKrmdefault { rm } - \tl_set:Nn \CJKsfdefault { sf } - \tl_set:Nn \CJKttdefault { tt } + \setCJKmainfont { AdobeSongStd-Light.otf } + [ + cmap = UniGB-UTF16-H, + BoldFont = AdobeHeitiStd-Regular.otf, + ItalicFont = AdobeKaitiStd-Regular.otf + ] + \setCJKsansfont { AdobeHeitiStd-Regular.otf } + [ cmap = UniGB-UTF16-H ] + \setCJKmonofont { AdobeFangsongStd-Regular.otf } + [ cmap = UniGB-UTF16-H ] + \setCJKfamilyfont { zhsong } { AdobeSongStd-Light.otf } + [ cmap = UniGB-UTF16-H ] + \setCJKfamilyfont { zhhei } { AdobeHeitiStd-Regular.otf } + [ cmap = UniGB-UTF16-H ] + \setCJKfamilyfont { zhkai } { AdobeKaitiStd-Regular.otf } + [ cmap = UniGB-UTF16-H ] + \setCJKfamilyfont { zhfs } { AdobeFangsongStd-Regular.otf } + [ cmap = UniGB-UTF16-H ] + \ctex_punct_set:n { adobe } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } + \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } + \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } + } + { + \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhadobefonts } + \ctex_punct_set:n { adobe } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } } + { \ctex_fontset_error:n { adobe } } } { - \sys_if_engine_uptex:TF - { - \ctex_set_upfonts:nnnnnn - {simsun.ttc} {simhei.ttf} {simkai.ttf} -% {msyh\l_@@_msyh_suffix_tl} {msyhbd\l_@@_msyh_suffix_tl} -% {simhei.ttf} {simhei.ttf} - {simfang.ttf} - \ctex_set_upfamily:nnn { zhsong } { upzhserif } {} - \ctex_set_upfamily:nnn { zhhei } { upzhserifb } {} - \ctex_set_upfamily:nnn { zhfs } { upzhmono} {} - \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} -% \ctex_set_upfamily:nnn { zhyahei } { upzhsans } { upzhsansb } - \ctex_set_upfamily:nnn { zhli } { upschrm } {} - \ctex_set_upmap:nnn { upstsl } { simli.ttf } {} - \ctex_set_upfamily:nnn { zhyou } { upschgt } {} - \ctex_set_upmap:nnn { upstht } { simyou.ttf } {} - } - { -%<*windowsold> - \setCJKmainfont - [ BoldFont = SimHei , ItalicFont = KaiTi_GB2312 ] { SimSun } - \setCJKsansfont { SimHei } - \setCJKmonofont { FangSong_GB2312 } - \setCJKfamilyfont { zhkai } { KaiTi_GB2312 } - \setCJKfamilyfont { zhfs } { FangSong_GB2312 } -% -%<*windowsnew> - \setCJKmainfont - [ BoldFont = SimHei , ItalicFont = KaiTi ] { SimSun } - \setCJKsansfont - [ BoldFont = { *~Bold } ] { Microsoft~YaHei } - \setCJKmonofont { FangSong } - \setCJKfamilyfont { zhkai } { KaiTi } - \setCJKfamilyfont { zhfs } { FangSong } -% - \setCJKfamilyfont { zhsong } { SimSun } - \setCJKfamilyfont { zhhei } { SimHei } - \setCJKfamilyfont { zhli } { LiSu } - \setCJKfamilyfont { zhyou } { YouYuan } -%<*windowsnew> - \setCJKfamilyfont { zhyahei } - [ BoldFont = { *~Bold } ] { Microsoft~YaHei } -% - } + \ctex_set_upfonts:nnnnnn + { AdobeSongStd-Light.otf } + { AdobeHeitiStd-Regular.otf } + { AdobeKaitiStd-Regular.otf } + { AdobeHeitiStd-Regular.otf } + { AdobeHeitiStd-Regular.otf } + { AdobeFangsongStd-Regular.otf } + \ctex_set_upfamily:nnn { zhsong } { upzhserif } {} + \ctex_set_upfamily:nnn { zhhei } { upzhsans } {} + \ctex_set_upfamily:nnn { zhfs } { upzhmono } {} + \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} + } + { + \setCJKmainfont { AdobeSongStd-Light } + [ BoldFont = AdobeHeitiStd-Regular, ItalicFont = AdobeKaitiStd-Regular ] + \setCJKsansfont { AdobeHeitiStd-Regular } + \setCJKmonofont { AdobeFangsongStd-Regular } + \setCJKfamilyfont { zhsong } { AdobeSongStd-Light } + \setCJKfamilyfont { zhhei } { AdobeHeitiStd-Regular } + \setCJKfamilyfont { zhfs } { AdobeFangsongStd-Regular } + \setCJKfamilyfont { zhkai } { AdobeKaitiStd-Regular } } -% +% % \end{macrocode} % -% \subsubsection{\pkg{ctex-fontset-adobe.def}} -% -% \begin{macrocode} -%<*adobe> -% \end{macrocode} +% \paragraph{\opt{fandol}} % -% \tn{pdfmapline} 不支持 OpenType 字体,因而 \opt{adobe} 字体集在 pdf 模式下 -% 就没有定义。\opt{fandol} 的情况类似。 % \begin{macrocode} -\sys_if_engine_pdftex:TF +%<*fandol> +\ctex_fontset_case:nnnn + { \ctex_fontset_error:n { fandol } } { - \sys_if_output_pdf:TF - { \ctex_fontset_error:n { adobe } } + \ctex_zhmap_case:nnn { - \ctex_zhmap_case:nnn - { - \setCJKmainfont - [ - cmap = UniGB-UTF16-H , - BoldFont = AdobeHeitiStd-Regular.otf , - ItalicFont = AdobeKaitiStd-Regular.otf - ] { AdobeSongStd-Light.otf } - \setCJKsansfont [ cmap = UniGB-UTF16-H ] { AdobeHeitiStd-Regular.otf } - \setCJKmonofont [ cmap = UniGB-UTF16-H ] { AdobeFangsongStd-Regular.otf } - \setCJKfamilyfont { zhsong } - [ cmap = UniGB-UTF16-H ] { AdobeSongStd-Light.otf } - \setCJKfamilyfont { zhhei } - [ cmap = UniGB-UTF16-H ] { AdobeHeitiStd-Regular.otf } - \setCJKfamilyfont { zhkai } - [ cmap = UniGB-UTF16-H ] { AdobeKaitiStd-Regular.otf } - \setCJKfamilyfont { zhfs } - [ cmap = UniGB-UTF16-H ] { AdobeFangsongStd-Regular.otf } - \ctex_punct_set:n { adobe } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } - \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } - \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } - } - { - \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhadobefonts } - \ctex_punct_set:n { adobe } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } - } - { \ctex_fontset_error:n { adobe } } + \setCJKmainfont { FandolSong-Regular.otf } + [ + cmap = UniGB-UTF16-H, + BoldFont = FandolSong-Bold.otf, + ItalicFont = FandolKai-Regular.otf + ] + \setCJKsansfont { FandolHei-Regular.otf } + [ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf ] + \setCJKmonofont { FandolFang-Regular.otf } + [ cmap = UniGB-UTF16-H ] + \setCJKfamilyfont { zhsong } { FandolSong-Regular.otf } + [ cmap = UniGB-UTF16-H, BoldFont = FandolSong-Bold.otf ] + \setCJKfamilyfont { zhhei } { FandolHei-Regular.otf } + [ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf ] + \setCJKfamilyfont { zhfs } { FandolFang-Regular.otf } + [ cmap = UniGB-UTF16-H ] + \setCJKfamilyfont { zhkai } { FandolKai-Regular.otf } + [ cmap = UniGB-UTF16-H ] + \ctex_punct_set:n { fandol } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } + \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } + \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb } + \ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhheib } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } + } + { + \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhfandolfonts } + \ctex_punct_set:n { fandol } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } } + { \ctex_fontset_error:n { fandol } } } { - \sys_if_engine_uptex:TF - { - \ctex_set_upfonts:nnnnnn - {AdobeSongStd-Light.otf} {AdobeHeitiStd-Regular.otf} {AdobeKaitiStd-Regular.otf} - {AdobeHeitiStd-Regular.otf} {AdobeHeitiStd-Regular.otf} - {AdobeFangsongStd-Regular.otf} - \ctex_set_upfamily:nnn { zhsong } { upzhserif } {} - \ctex_set_upfamily:nnn { zhhei } { upzhsans } {} - \ctex_set_upfamily:nnn { zhfs } { upzhmono} {} - \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} - } - { - \setCJKmainfont - [ - BoldFont = AdobeHeitiStd-Regular , - ItalicFont = AdobeKaitiStd-Regular - ] { AdobeSongStd-Light } - \setCJKsansfont { AdobeHeitiStd-Regular} - \setCJKmonofont { AdobeFangsongStd-Regular} - \setCJKfamilyfont { zhsong } { AdobeSongStd-Light } - \setCJKfamilyfont { zhhei } { AdobeHeitiStd-Regular } - \setCJKfamilyfont { zhfs } { AdobeFangsongStd-Regular } - \setCJKfamilyfont { zhkai } { AdobeKaitiStd-Regular } - } + \ctex_set_upfonts:nnnnnn + { FandolSong-Regular.otf } + { FandolSong-Bold.otf } + { FandolKai-Regular.otf } + { FandolHei-Regular.otf } + { FandolHei-Bold.otf } + { FandolFang-Regular.otf } + \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } + \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } + \ctex_set_upfamily:nnn { zhfs } { upzhmono } {} + \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} + } + { + \setCJKmainfont { FandolSong-Regular } + [ + Extension = .otf, + BoldFont = FandolSong-Bold, + ItalicFont = FandolKai-Regular + ] + \setCJKsansfont { FandolHei-Regular } + [ Extension = .otf, BoldFont = FandolHei-Bold ] + \setCJKmonofont { FandolFang-Regular } + [ Extension = .otf ] + \setCJKfamilyfont { zhsong } { FandolSong-Regular } + [ Extension = .otf, BoldFont = FandolSong-Bold ] + \setCJKfamilyfont { zhhei } { FandolHei-Regular } + [ Extension = .otf, BoldFont = FandolHei-Bold ] + \setCJKfamilyfont { zhfs } { FandolFang-Regular } + [ Extension = .otf ] + \setCJKfamilyfont { zhkai } { FandolKai-Regular } + [ Extension = .otf ] } +% % \end{macrocode} % -% \begin{macrocode} -% -%<*fandol> -% \end{macrocode} +% \paragraph{\opt{founder}} % -% \subsubsection{\pkg{ctex-fontset-fandol.def}} +% \changes{v2.4.15}{2019/03/28}{统一“方正细黑一\_GBK”的名称为 \texttt{FZXiHeiI-Z08}。} % % \begin{macrocode} -\sys_if_engine_pdftex:TF - { - \sys_if_output_pdf:TF - { \ctex_fontset_error:n { fandol } } - { - \ctex_zhmap_case:nnn - { - \setCJKmainfont - [ - cmap = UniGB-UTF16-H , - BoldFont = FandolSong-Bold.otf , - ItalicFont = FandolKai-Regular.otf - ] { FandolSong-Regular.otf } - \setCJKsansfont - [ - cmap = UniGB-UTF16-H , - BoldFont = FandolHei-Bold.otf - ] { FandolHei-Regular.otf } - \setCJKmonofont [ cmap = UniGB-UTF16-H ] { FandolFang-Regular.otf } - \setCJKfamilyfont { zhsong } - [ - cmap = UniGB-UTF16-H , - BoldFont = FandolSong-Bold.otf - ] { FandolSong-Regular.otf } - \setCJKfamilyfont { zhhei } - [ - cmap = UniGB-UTF16-H , - BoldFont = FandolHei-Bold.otf - ] { FandolHei-Regular.otf } - \setCJKfamilyfont { zhfs } - [ cmap = UniGB-UTF16-H ] { FandolFang-Regular.otf } - \setCJKfamilyfont { zhkai } - [ cmap = UniGB-UTF16-H ] { FandolKai-Regular.otf } - \ctex_punct_set:n { fandol } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } - \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } - \ctex_punct_map_bfseries:nn { \CJKrmdefault , zhsong } { zhsongb } - \ctex_punct_map_bfseries:nn { \CJKsfdefault , zhhei } { zhheib } - } - { - \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhfandolfonts } - \ctex_punct_set:n { fandol } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } - } - { \ctex_fontset_error:n { fandol } } - } - } +%<*founder> +\ctex_fontset_case:nnn { - \sys_if_engine_uptex:TF + \ctex_zhmap_case:nnn { - \ctex_set_upfonts:nnnnnn - {FandolSong-Regular.otf} {FandolSong-Bold.otf} {FandolKai-Regular.otf} - {FandolHei-Regular.otf} {FandolHei-Bold.otf} - {FandolFang-Regular.otf} - \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } - \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } - \ctex_set_upfamily:nnn { zhfs } { upzhmono} {} - \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} + \setCJKmainfont { FZSSK.TTF } + [ BoldFont = FZXBSK.TTF, ItalicFont = FZKTK.TTF ] + \setCJKsansfont { FZXH1K.TTF } [ BoldFont = FZHTK.TTF ] + \setCJKmonofont { FZFSK.TTF } + \setCJKfamilyfont { zhsong } { FZSSK.TTF } [ BoldFont = FZXBSK.TTF ] + \setCJKfamilyfont { zhhei } { FZHTK.TTF } + \setCJKfamilyfont { zhkai } { FZKTK.TTF } + \setCJKfamilyfont { zhfs } { FZFSK.TTF } + \setCJKfamilyfont { zhli } { FZLSK.TTF } + \setCJKfamilyfont { zhyou } { FZY1K.TTF } [ BoldFont = FZY3K.TTF ] + \ctex_punct_set:n { founder } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_family:nn { \CJKsfdefault } { zhheil } + \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } + \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb } + \ctex_punct_map_bfseries:nn { \CJKsfdefault } { zhhei } + \ctex_punct_map_bfseries:nn { zhyou } { zhyoub } } { - \setCJKmainfont - [ - Extension = .otf , - BoldFont = FandolSong-Bold , ItalicFont = FandolKai-Regular - ] - { FandolSong-Regular } - \setCJKsansfont - [ Extension = .otf , BoldFont = FandolHei-Bold ] { FandolHei-Regular } - \setCJKmonofont [ Extension = .otf ] { FandolFang-Regular } - \setCJKfamilyfont { zhsong } - [ Extension = .otf , BoldFont = FandolSong-Bold ] { FandolSong-Regular } - \setCJKfamilyfont { zhhei } - [ Extension = .otf , BoldFont = FandolHei-Bold ] { FandolHei-Regular } - \setCJKfamilyfont { zhfs } [ Extension = .otf ] { FandolFang-Regular } - \setCJKfamilyfont { zhkai } [ Extension = .otf ] { FandolKai-Regular } + \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhfounderfonts } + \ctex_punct_set:n { founder } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } } + { \ctex_fontset_error:n { founder } } + } + { + \ctex_set_upfonts:nnnnnn + { FZSSK.TTF } + { FZXBSK.TTF } + { FZKTK.TTF } + { FZXH1K.TTF } + { FZHTK.TTF } + { FZFSK.TTF } + \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } + \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } + \ctex_set_upfamily:nnn { zhfs } { upzhmono } {} + \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} + \ctex_set_upfamily:nnn { zhli } { upschrm } {} + \ctex_set_upfamily:nnn { zhyou } { upschgt } {} + \ctex_set_upmap:nnn { upstsl } { FZLSK.TTF } {} + \ctex_set_upmap:nnn { upstht } { FZY1K.TTF } {} + } + { + \setCJKmainfont { FZShuSong-Z01 } + [ BoldFont = FZXiaoBiaoSong-B05, ItalicFont = FZKai-Z03 ] + \setCJKsansfont { FZXiHeiI-Z08 } [ BoldFont = FZHei-B01 ] + \setCJKmonofont { FZFangSong-Z02 } + \setCJKfamilyfont { zhsong } { FZShuSong-Z01 } + [ BoldFont = FZXiaoBiaoSong-B05 ] + \setCJKfamilyfont { zhhei } { FZHei-B01 } + \setCJKfamilyfont { zhkai } { FZKai-Z03 } + \setCJKfamilyfont { zhfs } { FZFangSong-Z02 } + \setCJKfamilyfont { zhli } { FZLiShu-S01 } + \setCJKfamilyfont { zhyou } { FZXiYuan-M01 } + [ BoldFont = FZZhunYuan-M02 ] } +% % \end{macrocode} % -% \begin{macrocode} -% -% \end{macrocode} +% \paragraph{\opt{mac} 相关} % -% \subsubsection{\pkg{ctex-fontset-mac.def} 等} -% \changes{v2.4.14}{2018/05/01}{区分 \texttt{macold} 及 \texttt{macnew}。} +% \changes{v2.4.14}{2018/05/01}{区分 \opt{macold} 及 \opt{macnew}。} % % 按 \href{https://github.com/CTeX-org/ctex-kit/issues/351}{Issue 351} % 的讨论,以 El Capitan 为分界,分别设置 |macold|(El Capitan 之前) @@ -9948,273 +10230,317 @@ Copyright and Licence % % \end{macrocode} % -% |macold| 的设置参考了 ^^A -% \href{https://github.com/CTeX-org/ctex-kit/wiki/OS-X-Mavericks-(10.9)-\%E9\%A2\%84\%E8\%A3\%85\%E7\%9A\%84\%E4\%B8\%BB\%E8\%A6\%81\%E7\%AE\%80\%E4\%BD\%93\%E4\%B8\%AD\%E6\%96\%87\%E5\%AD\%97\%E4\%BD\%93}^^A -% {OS X Mavericks (10.9) 预装的主要简体中文字体列表}。 -% -% 在 \dvipdfmx{} 下,可以通过下述方式使用华文宋体和华文楷体: -% \begin{verbatim} -% \special{pdf:mapline unisong@Unicode@ unicode :4:Songti.ttc} -% \special{pdf:mapline unikai@Unicode@ unicode :4:Kaiti.ttc} -% \end{verbatim} -% 而 \tn{pdfmapline} 似乎不支持带索引的 \texttt{ttc} 字体,\file{Songti.ttc} 默认 -% 使用的是 Songti SC Black,\file{Kaiti.ttc} 默认使用的是 Kaiti SC Black。 -% 华文黑体不能通过这种方式使用: -% \begin{verbatim} -% \special{pdf:mapline unihei@Unicode@ unicode \detokenize{华文黑体}.ttf} -% \end{verbatim} -% \dvipdfmx{} 不能生成 PDF,报下述错误: -% \begin{verbatim} -% ** WARNING ** UCS-4 TrueType cmap table... -% ** ERROR ** Unable to read OpenType/TrueType Unicode cmap table. -% \end{verbatim} -% 如果将 CMap 改为 UniGB-UTF16-H,错误信息是 -% \begin{verbatim} -% ** WARNING ** No usable TrueType cmap table found for font "华文黑体.ttf". -% ** WARNING ** CID character collection for this font is set to "Adobe-GB1" -% ** ERROR ** Cannot continue without this... -% \end{verbatim} -% 在 \pdfTeX{} 下生成的 PDF 只有方框^^A -% \footnote{\url{http://www.newsmth.net/bbscon.php?bid=460&id=312640}}。 -% 华文细黑和华文仿宋的情况类似。 -% 这确认为 \dvipdfmx{} 的 bug^^A -% \begingroup\makeatletter\@makeother\#\@firstofone{\endgroup -% \footnote{\url{https://github.com/clerkma/ptex-ng/blob/master/texk/libdpx/cidtype2.c#L597}}}。 +% \changes{v2.4.14}{2018/05/01}{配置 \opt{macnew} 的默认字体设置。} +% \changes{v2.5}{2019/11/05}{为 \opt{macnew} 增加粗楷体、隶书和圆体的定义。} +% \changes{v2.5}{2019/11/07}{允许 \opt{macnew} 在 \LaTeX{} 和 \upLaTeX{} 下使用。} % -% \changes{v2.4.14}{2018/05/01}{配置 \texttt{macnew} 的默认字体设置。} +% |macold| 的设置参考了 +% \href{https://github.com/CTeX-org/ctex-kit/wiki/OS-X-Mavericks-(10.9)-预装的主要简体中文字体}^^A +% {OS X Mavericks (10.9) 预装的主要简体中文字体列表}。 % % |macnew| 在默认字体设置方面,引入了多字重的宋体作为罗马字族, % 以及引入了苹方黑体作为无衬线字族。 -% % 由于 Songti SC Light 的字重与 STSong 及 Windows 上的 SimSun 更接近,故默认字重 -% 使用 Songti SC Light,而不带后缀的正常字重事实上没有使用。下方关于 |zhsong| 的字族 -% 设置也有同样的情况。 +% 使用 Songti SC Light,而不带后缀的正常字重事实上没有使用。黑体、圆体等设置 +% 也有类似的情况。 % % \begin{macrocode} %<*macold|macnew> -\sys_if_engine_pdftex:TF +\ctex_fontset_case:nnnn { \ctex_fontset_error:n { mac } } - { - \sys_if_engine_uptex:TF - { \ctex_fontset_error:n { mac } } - { %<*macold> - \setCJKmainfont [ BoldFont = STHeiti , ItalicFont = STKaiti ] { STSong } - \setCJKsansfont [ BoldFont = STHeiti ] { STXihei } + { \ctex_fontset_error:n { macold } } + { \ctex_fontset_error:n { macold } } % %<*macnew> - \setCJKmainfont + { + \ctex_zhmap_case:nnn + { + \setCJKmainfont { :3:Songti.ttc } [ - UprightFont = *~Light , - BoldFont = *~Bold , - ItalicFont = Kaiti~SC , - BoldItalicFont = Kaiti~SC~Bold - ] { Songti~SC } - \setCJKsansfont { PingFang~SC } + BoldFont = :1:Songti.ttc, + ItalicFont = :0:Kaiti.ttc, + BoldItalicFont = :3:Kaiti.ttc, + ] + \setCJKsansfont { :2:PingFang.ttc } [ BoldFont = :8:PingFang.ttc ] + \setCJKmonofont { STFANGSO.ttf } + \setCJKfamilyfont { zhsong } { :3:Songti.ttc } [ BoldFont = :1:Songti.ttc ] + \setCJKfamilyfont { zhhei } { :2:PingFang.ttc } [ BoldFont = :8:PingFang.ttc ] + \setCJKfamilyfont { zhkai } { :0:Kaiti.ttc } [ BoldFont = :3:Kaiti.ttc ] + \setCJKfamilyfont { zhfs } { STFANGSO.ttf } + \setCJKfamilyfont { zhli } { :0:Baoli.ttc } + \setCJKfamilyfont { zhyou } { :4:Yuanti.ttc } [ BoldFont = :0:Yuanti.ttc ] + \ctex_punct_set:n { mac } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_family:nn { \CJKsfdefault } { zhheil } + \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } + \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb } + \ctex_punct_map_bfseries:nn { \CJKsfdefault } { zhhei } + \ctex_punct_map_bfseries:nn { zhyou } { zhyoub } + } + { + \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhmacfonts } + \ctex_punct_set:n { mac } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } + } + { \ctex_fontset_error:n { macnew } } + } + { + \ctex_set_upmap:nnn { upserif } { :3:Songti.ttc } { :1:Songti.ttc } + \ctex_set_upmap:nnn { upserifit } { :0:Kaiti.ttc } { } + \ctex_set_upmap:nnn { upstsl } { :0:Baoli.ttc } { } + \ctex_set_upmap:nnn { upstht } { :4:Yuanti.ttc } { } + \ctex_set_upmap_unicode:nnn { upsans } { :2:PingFang.ttc } { :8:PingFang.ttc } + \ctex_set_upmap_unicode:nnn { upmono } { STFANGSO.ttf } { } + \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } + \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } + \ctex_set_upfamily:nnn { zhfs } { upzhmono } { } + \ctex_set_upfamily:nnn { zhkai } { upzhserifit } { } + \ctex_set_upfamily:nnn { zhli } { upschrm } { } + \ctex_set_upfamily:nnn { zhyou } { upschgt } { } + } % - \setCJKmonofont { STFangsong } + { %<*macold> - \setCJKfamilyfont { zhsong } { STSong } - \setCJKfamilyfont { zhhei } { STHeiti } + \setCJKmainfont { STSong } + [ BoldFont = STHeiti, ItalicFont = STKaiti ] + \setCJKsansfont { STXihei } [ BoldFont = STHeiti ] + \setCJKmonofont { STFangsong } + \setCJKfamilyfont { zhsong } { STSong } + \setCJKfamilyfont { zhhei } { STHeiti } + \setCJKfamilyfont { zhfs } { STFangsong } + \setCJKfamilyfont { zhkai } { STKaiti } % %<*macnew> - \setCJKfamilyfont { zhsong } - [ - UprightFont = *~Light , - BoldFont = *~Bold , - ] { Songti~SC } - \setCJKfamilyfont { zhhei } { Heiti~SC } - \setCJKfamilyfont { zhpf } { PingFang~SC } + \setCJKmainfont { Songti~SC~Light } + [ + BoldFont = Songti~SC~Bold, + ItalicFont = Kaiti~SC, + BoldItalicFont = Kaiti~SC~Bold + ] + \setCJKsansfont { PingFang~SC } + \setCJKmonofont { STFangsong } + \setCJKfamilyfont { zhsong } { Songti~SC~Light } [ BoldFont = Songti~SC~Bold ] + \setCJKfamilyfont { zhhei } { Heiti~SC~Light } [ BoldFont = Heiti~SC~Medium ] + \setCJKfamilyfont { zhpf } { PingFang~SC } + \setCJKfamilyfont { zhfs } { STFangsong } + \setCJKfamilyfont { zhkai } { Kaiti~SC } [ BoldFont = Kaiti~SC~Bold ] + \setCJKfamilyfont { zhli } { Baoli~SC } + \setCJKfamilyfont { zhyou } { Yuanti~SC~Light } [ BoldFont = Yuanti~SC~Regular ] % - \setCJKfamilyfont { zhfs } { STFangsong } -%\setCJKfamilyfont { zhkai } { STKaiti } -%\setCJKfamilyfont { zhkai } { Kaiti~SC } - } } % % \end{macrocode} % -% \subsubsection{\pkg{ctex-fontset-founder.def}} +% \paragraph{\opt{ubuntu}} % -% \begin{macrocode} -%<*founder> -% \end{macrocode} -% -% \changes{v2.4.15}{2019/03/28}{统一“方正细黑一\_GBK”的名称为 \texttt{FZXiHeiI-Z08}。} +% \changes{v2.5}{2019/11/07}{\opt{ubuntu} 改用思源(Noto CJK)和文鼎字库,不再 +% 支持使用 \pdfLaTeX{} 编译。} % % \begin{macrocode} -\sys_if_engine_pdftex:TF +%<*ubuntu> +\ctex_fontset_case:nnnn + { \ctex_fontset_error:n { ubuntu } } { \ctex_zhmap_case:nnn { - \setCJKmainfont - [ BoldFont = FZXBSK.TTF , ItalicFont = FZKTK.TTF ] { FZSSK.TTF } - \setCJKsansfont [ BoldFont = FZHTK.TTF ] { FZXH1K.TTF } - \setCJKmonofont { FZFSK.TTF } - \setCJKfamilyfont { zhsong } [ BoldFont = FZXBSK.TTF ] { FZSSK.TTF } - \setCJKfamilyfont { zhhei } { FZHTK.TTF } - \setCJKfamilyfont { zhkai } { FZKTK.TTF } - \setCJKfamilyfont { zhfs } { FZFSK.TTF } - \setCJKfamilyfont { zhli } { FZLSK.TTF } - \setCJKfamilyfont { zhyou } [ BoldFont = FZY3K.TTF ] { FZY1K.TTF } - \ctex_punct_set:n { founder } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_family:nn { \CJKsfdefault } { zhheil } - \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } - \ctex_punct_map_bfseries:nn { \CJKrmdefault , zhsong } { zhsongb } - \ctex_punct_map_bfseries:nn { \CJKsfdefault } { zhhei } - \ctex_punct_map_bfseries:nn { zhyou } { zhyoub } + \setCJKmainfont { :2:NotoSerifCJK-Regular.ttc } + [ BoldFont = :2:NotoSerifCJK-Bold.ttc, ItalicFont = gkai00mp.ttf ] + \setCJKsansfont { :2:NotoSansCJK-Regular.ttc } + [ BoldFont = :2:NotoSansCJK-Bold.ttc ] + \setCJKmonofont { :2:NotoSerifCJK-Regular.ttc } + [ BoldFont = :2:NotoSerifCJK-Bold.ttc ] + \setCJKfamilyfont { zhsong } { :2:NotoSerifCJK-Regular.ttc } + [ BoldFont = :2:NotoSerifCJK-Bold.ttc ] + \setCJKfamilyfont { zhhei } { :2:NotoSansCJK-Regular.ttc } + [ BoldFont = :2:NotoSansCJK-Bold.ttc ] + \setCJKfamilyfont { zhkai } { gkai00mp.ttf } + \ctex_punct_set:n { fandol } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } + \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb } + \ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei } { zhheib } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } } { - \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhfounderfonts } - \ctex_punct_set:n { founder } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } + \ctex_load_zhmap:nnnn { rm } { zhhei } { zhsong } { zhubuntufonts } + \ctex_punct_set:n { ubuntu } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } } - { \ctex_fontset_error:n { founder } } + { \ctex_fontset_error:n { ubuntu } } } { - \sys_if_engine_uptex:TF - { - \ctex_set_upfonts:nnnnnn - { FZSSK.TTF } { FZXBSK.TTF } { FZKTK.TTF } - { FZXH1K.TTF } { FZHTK.TTF } - { FZFSK.TTF } - \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } - \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } - \ctex_set_upfamily:nnn { zhfs } { upzhmono} {} - \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} - \ctex_set_upfamily:nnn { zhli } { upschrm } {} - \ctex_set_upmap:nnn { upstsl } { FZLSK.TTF } {} - \ctex_set_upfamily:nnn { zhyou } { upschgt } {} - \ctex_set_upmap:nnn { upstht } { FZY1K.TTF } {} - } - { - \setCJKmainfont - [ BoldFont = FZXiaoBiaoSong-B05 , ItalicFont = FZKai-Z03 ] { FZShuSong-Z01 } - \setCJKsansfont [ BoldFont = FZHei-B01 ] { FZXiHeiI-Z08 } - \setCJKmonofont { FZFangSong-Z02 } - \setCJKfamilyfont { zhsong } [ BoldFont = FZXiaoBiaoSong-B05 ] { FZShuSong-Z01 } - \setCJKfamilyfont { zhhei } { FZHei-B01 } - \setCJKfamilyfont { zhkai } { FZKai-Z03 } - \setCJKfamilyfont { zhfs } { FZFangSong-Z02 } - \setCJKfamilyfont { zhli } { FZLiShu-S01 } - \setCJKfamilyfont { zhyou } [ BoldFont = FZZhunYuan-M02 ] { FZXiYuan-M01 } - } + \ctex_set_upmap_unicode:nnn { upserif } + { :2:NotoSerifCJK-Regular.ttc } { :2:NotoSerifCJK-Bold.ttc } + \ctex_set_upmap_unicode:nnn { upsans } + { :2:NotoSansCJK-Regular.ttc } { :2:NotoSansCJK-Bold.ttc } + \ctex_set_upmap_unicode:nnn { upmono } + { :2:NotoSerifCJK-Regular.ttc } { } + \ctex_set_upmap:nnn { upserifit } { gkai00mp.ttf } { } + \ctex_set_upfamily:nnn { zhsong } { upzhserif } { upzhserifb } + \ctex_set_upfamily:nnn { zhhei } { upzhsans } { upzhsansb } + \ctex_set_upfamily:nnn { zhkai } { upzhserifit } { } } + { + \setCJKmainfont { Noto~Serif~CJK~SC } [ ItalicFont = AR~PL~KaitiM~GB ] + \setCJKsansfont { Noto~Sans~CJK~SC } + \setCJKmonofont { Noto~Serif~CJK~SC } + \setCJKfamilyfont { zhsong } { Noto~Serif~CJK~SC } + \setCJKfamilyfont { zhhei } { Noto~Sans~CJK~SC } + \setCJKfamilyfont { zhkai } { AR~PL~KaitiM~GB } + } +% % \end{macrocode} % +% \paragraph{\opt{windows}} +% +% \changes{v2.4.1}{2016/05/14}{使用 \file{bootfont.bin} 判断 Windows XP 以避免 +% 权限问题。} +% \changes{v2.5}{2019/11/04}{使用环境变量代替绝对路径查找字体。} +% \changes{v2.5}{2019/11/05}{不再支持 Windows XP 系统,\opt{windowsold} 和 +% \opt{windowsnew} 成为过时字库选项。} +% +% \begin{variable}{ \c_@@_msyh_suffix_tl} +% Windows 8 以后,微软雅黑由原来的 \file{.ttf} 后缀改为 \file{.ttc} 后缀,需要 +% 加以区分。 % \begin{macrocode} -% -%<*ubuntu> +%<*windows> +\file_if_exist:nTF { \c_dollar_str WINDIR/Fonts/msyh.ttc } + { \tl_const:Nn \c_@@_msyh_suffix_tl { ttc } } + { + \file_if_exist:nTF { msyh.ttc } + { \tl_const:Nn \c_@@_msyh_suffix_tl { ttc } } + { \tl_const:Nn \c_@@_msyh_suffix_tl { ttf } } + } % \end{macrocode} +% \end{variable} % -% \subsubsection{\pkg{ctex-fontset-ubuntu.def}} -% -% 以下根据 Ubuntu 12.04 的中文字体情况设置。CMap 不清楚应该是什么,指定为 -% UniGB-UTF16-H 还是有警告: -% \begin{verbatim} -% ** WARNING ** UCS-4 TrueType cmap table... -% \end{verbatim} -% 需要注意的是 \file{uming.ttc} 和 \file{ukai.ttc} 看起来像有四种字形的样子,但 -% 其实只有“令”和“骨”这区区两个字有新字形,其余都取旧字形^^A -% \footnote{\url{http://www.freedesktop.org/wiki/Software/CJKUnifonts/Download/}}。 % \begin{macrocode} -\sys_if_engine_pdftex:TF +\ctex_fontset_case:nnn { \ctex_zhmap_case:nnn { - \setCJKmainfont - [ BoldFont = wqy-zenhei.ttc , ItalicFont = ukai.ttc ] { uming.ttc } - \setCJKsansfont { wqy-zenhei.ttc } - \setCJKmonofont { uming.ttc } - \setCJKfamilyfont { zhsong } { uming.ttc } - \setCJKfamilyfont { zhhei } { wqy-zenhei.ttc } - \setCJKfamilyfont { zhkai } { ukai.ttc } - \ctex_punct_set:n { ubuntu } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_family:nn { \CJKsfdefault } { zhhei } - \ctex_punct_map_family:nn { \CJKttdefault } { zhsong } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } - \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } - } - { - \ctex_load_zhmap:nnnn { rm } { zhhei } { zhsong } { zhubuntufonts } - \ctex_punct_set:n { ubuntu } - \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } - \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } - \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } + \ctex_punct_set:n { windows } + \setCJKmainfont { simsun.ttc } + [ BoldFont = simhei.ttf, ItalicFont = simkai.ttf ] + \setCJKsansfont { msyh.\c_@@_msyh_suffix_tl } + [ BoldFont = msyhbd.\c_@@_msyh_suffix_tl ] + \setCJKmonofont { simfang.ttf } + \setCJKfamilyfont { zhsong } { simsun.ttc } + \setCJKfamilyfont { zhhei } { simhei.ttf } + \setCJKfamilyfont { zhfs } { simfang.ttf } + \setCJKfamilyfont { zhkai } { simkai.ttf } + \setCJKfamilyfont { zhyahei } { msyh.\c_@@_msyh_suffix_tl } + [ BoldFont = msyhbd.\c_@@_msyh_suffix_tl ] + \setCJKfamilyfont { zhli } { simli.ttf } + \setCJKfamilyfont { zhyou } { simyou.ttf } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } + \ctex_punct_map_family:nn { \CJKsfdefault } { zhyahei } + \ctex_punct_map_bfseries:nn { \CJKsfdefault, zhyahei } { zhyaheib } + \ctex_punct_map_family:nn { \CJKttdefault } { zhfs } } - { \ctex_fontset_error:n { ubuntu } } - } - { - \sys_if_engine_uptex:TF { - \ctex_set_upfonts:nnnnnn - { uming.ttc } { wqy-zenhei.ttc } { ukai.ttc } - { wqy-zenhei.ttc } { wqy-zenhei.ttc } - { uming.ttc } - \ctex_set_upfamily:nnn { zhsong } { upzhserif } {} - \ctex_set_upfamily:nnn { zhhei } { upzhsans } {} - \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} + \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { zhwindowsfonts } + \ctex_punct_set:n { windows } + \ctex_punct_map_family:nn { \CJKrmdefault } { zhsong } + \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei } + \ctex_punct_map_itshape:nn { \CJKrmdefault } { zhkai } } { - \setCJKmainfont - [ BoldFont = WenQuanYi~Zen~Hei , ItalicFont = AR~PL~UKai~CN ] { AR~PL~UMing~CN } - \setCJKsansfont { WenQuanYi~Zen~Hei } - \setCJKmonofont { AR~PL~UMing~CN } - \setCJKfamilyfont { zhsong } { AR~PL~UMing~CN } - \setCJKfamilyfont { zhhei } { WenQuanYi~Zen~Hei } - \setCJKfamilyfont { zhkai } { AR~PL~UKai~CN } + \tl_set:Nn \CJKrmdefault { rm } + \tl_set:Nn \CJKsfdefault { sf } + \tl_set:Nn \CJKttdefault { tt } } } -% \end{macrocode} -% -% \begin{macrocode} -% + { + \ctex_set_upfonts:nnnnnn + { simsun.ttc } + { simhei.ttf } + { simkai.ttf } + { msyh.\c_@@_msyh_suffix_tl } + { msyhbd.\c_@@_msyh_suffix_tl } + { simfang.ttf } + \ctex_set_upfamily:nnn { zhsong } { upzhserif } {} + \ctex_set_upfamily:nnn { zhhei } { upzhserifb } {} + \ctex_set_upfamily:nnn { zhfs } { upzhmono } {} + \ctex_set_upfamily:nnn { zhkai } { upzhserifit } {} + \ctex_set_upfamily:nnn { zhyahei } { upzhsans } { upzhsansb } + \ctex_set_upfamily:nnn { zhli } { upschrm } {} + \ctex_set_upfamily:nnn { zhyou } { upschgt } {} + \ctex_set_upmap:nnn { upstsl } { simli.ttf } {} + \ctex_set_upmap:nnn { upstht } { simyou.ttf } {} + } + { + \setCJKmainfont { SimSun } [ BoldFont = SimHei , ItalicFont = KaiTi ] + \setCJKsansfont { Microsoft~YaHei } [ BoldFont = *~Bold ] + \setCJKmonofont { FangSong } + \setCJKfamilyfont { zhsong } { SimSun } + \setCJKfamilyfont { zhhei } { SimHei } + \setCJKfamilyfont { zhfs } { FangSong } + \setCJKfamilyfont { zhkai } { KaiTi } + \setCJKfamilyfont { zhyahei } { Microsoft~YaHei } [ BoldFont = *~Bold ] + \setCJKfamilyfont { zhli } { LiSu } + \setCJKfamilyfont { zhyou } { YouYuan } + } +% % \end{macrocode} % % \subsubsection{中文字体命令} -% \changes{v2.4.14}{2018/05/01}{为 \texttt{macnew} 配置字体命令。} -% -% \begin{macrocode} -%<*!windows&!mac> -% \end{macrocode} -% -% \begin{macrocode} -\NewDocumentCommand \songti { } { \CJKfamily { zhsong } } -\NewDocumentCommand \heiti { } { \CJKfamily { zhhei } } -%\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } } -\NewDocumentCommand \kaishu { } { \CJKfamily { zhkai } } -%<*windowsnew|windowsold|founder> -\NewDocumentCommand \lishu { } { \CJKfamily { zhli } } -\NewDocumentCommand \youyuan { } { \CJKfamily { zhyou } } -% -%\NewDocumentCommand \yahei { } { \CJKfamily { zhyahei } } +% \changes{v2.4.14}{2018/05/01}{为 \opt{macnew} 配置字体命令。} +% +% \begin{macro}{\songti,\heiti,\fangsong,\kaishu,\lishu,\youyuan,\yahei,\pingfang} +% 使用 \upLaTeX{} 编译时,\opt{macnew} 字库中由于传统黑体(黑体-简)无法使用, +% 我们用苹方来代替。同时 \tn{yahei}、\tn{pingfang} 命令被设置为与 \tn{heiti} 相同。 +% \begin{macrocode} +%<*!mac> +\NewDocumentCommand \songti { } { \CJKfamily { zhsong } } +\NewDocumentCommand \heiti { } { \CJKfamily { zhhei } } +%\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } } +\NewDocumentCommand \kaishu { } { \CJKfamily { zhkai } } +%<*windows|founder|macnew> +\NewDocumentCommand \lishu { } { \CJKfamily { zhli } } +\NewDocumentCommand \youyuan { } { \CJKfamily { zhyou } } +% +%\NewDocumentCommand \yahei { } { \CJKfamily { zhyahei } } %<*macnew> -\NewDocumentCommand \yahei { } { \CJKfamily { zhpf } } -\NewDocumentCommand \pingfang { } { \CJKfamily { zhpf } } +\bool_lazy_or:nnTF + { \sys_if_engine_pdftex_p: } + { \sys_if_engine_uptex_p: } + { + \cs_new_eq:NN \yahei \heiti + \cs_new_eq:NN \pingfang \heiti + } + { + \NewDocumentCommand \yahei { } { \CJKfamily { zhpf } } + \NewDocumentCommand \pingfang { } { \CJKfamily { zhpf } } + } % +% % \end{macrocode} +% \end{macro} % % \begin{macrocode} -% % -%<*zhmap> % \end{macrocode} % % \subsubsection{\pkg{zhmetrics} 的字体映射} % % 确认 \tn{catcode},没有重复载入检查。 % \begin{macrocode} +%<*zhmap> \begingroup\catcode61\catcode48\catcode32=10\relax% \catcode 35=6 % # \catcode123=1 % { \catcode125=2 % } \toks0{\endlinechar=\the\endlinechar\relax}% - \toks2{\endlinechar=13 }% + \toks2{\endlinechar=-1 }% \def\x#1 #2 {% \toks0\expandafter{\the\toks0 \catcode#1=\the\catcode#1\relax}% \toks2\expandafter{\the\toks2 \catcode#1=#2 }}% @@ -10244,6 +10570,7 @@ Copyright and Licence \expandafter\x\csname ctex@zhmap@endinput\endcsname % \end{macrocode} % +% \begin{macro}[int]{\ifzhmappdf} % \begin{macrocode} \begingroup\expandafter\endgroup \expandafter\let\csname ifzhmappdf\expandafter\endcsname\csname @@ -10253,7 +10580,9 @@ Copyright and Licence \else ifctexpdf\fi \endcsname % \end{macrocode} +% \end{macro} % +% \begin{macro}[int]{\ProvidesFile} % 提供非 \LaTeX{} 格式下的 \tn{ProvidesFile}。 % \begin{macrocode} \begingroup @@ -10266,112 +10595,50 @@ Copyright and Licence \fi \endgroup % \end{macrocode} +% \end{macro} % -% \paragraph{\pkg{zhwindowsfonts.tex}} -% +% 文件标识信息。 % \begin{macrocode} -%<*windows> -\ProvidesFile{zhwindowsfonts.tex}% - [2019/05/29 v2.4.16 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)] - -\ifzhmappdf - \pdfmapline{=gbk@UGBK@ +%\ProvidesFile{zhadobefonts.tex}% +% [2020/05/01 v2.5 Adobe font map loader for DVIPDFMx (CTEX)] +%\ProvidesFile{zhfandolfonts.tex}% +% [2020/05/01 v2.5 Fandol font map loader for DVIPDFMx (CTEX)] +%\ProvidesFile{zhfounderfonts.tex}% +% [2020/05/01 v2.5 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)] +%\ProvidesFile{zhmacfonts.tex}% +% [2020/05/01 v2.5 Mac font map loader for pdfTeX and DVIPDFMx (CTEX)] +%\ProvidesFile{zhubuntufonts.tex}% +% [2020/05/01 v2.5 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)] +%\ProvidesFile{zhwindowsfonts.tex}% +% [2020/05/01 v2.5 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)] % \end{macrocode} % % \paragraph{\pkg{zhadobefonts.tex}} % % \begin{macrocode} %<*adobe> -\ProvidesFile{zhadobefonts.tex}% - [2019/05/29 v2.4.16 Adobe font map loader for DVIPDFMx (CTEX)] - \ifzhmappdf %% pdfTeX does not support OTF fonts - \else - \special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf} - \special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf} - \special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf} - \special{pdf:mapline gbkhei@UGBK@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf} - \special{pdf:mapline gbkfs@UGBK@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf} - - \special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf} - \special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf} - \special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf} - \special{pdf:mapline unihei@Unicode@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf} - \special{pdf:mapline unifs@Unicode@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf} - - \special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167} - \special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167} - \special{pdf:mapline gbkheisl@UGBK@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167} - \special{pdf:mapline gbkfssl@UGBK@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167} - - \special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167} - \special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167} - \special{pdf:mapline uniheisl@Unicode@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167} + \special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf} + \special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf} + \special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf} + \special{pdf:mapline gbkhei@UGBK@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf} + \special{pdf:mapline gbkfs@UGBK@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf} + \special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf} + \special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf} + \special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf} + \special{pdf:mapline unihei@Unicode@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf} + \special{pdf:mapline unifs@Unicode@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf} + \special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167} + \special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167} + \special{pdf:mapline gbkheisl@UGBK@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167} + \special{pdf:mapline gbkfssl@UGBK@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167} + \special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H AdobeSongStd-Light.otf -s .167} + \special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H AdobeKaitiStd-Regular.otf -s .167} + \special{pdf:mapline uniheisl@Unicode@ UniGB-UTF16-H AdobeHeitiStd-Regular.otf -s .167} \special{pdf:mapline unifssl@Unicode@ UniGB-UTF16-H AdobeFangsongStd-Regular.otf -s .167} - +\fi % % \end{macrocode} % @@ -10379,35 +10646,28 @@ Copyright and Licence % % \begin{macrocode} %<*fandol> -\ProvidesFile{zhfandolfonts.tex}% - [2019/05/29 v2.4.16 Fandol font map loader for DVIPDFMx (CTEX)] - \ifzhmappdf %% pdfTeX does not support OTF fonts - \else - \special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf} - \special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf} - \special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H FandolKai-Regular.otf} - \special{pdf:mapline gbkhei@UGBK@ UniGB-UTF16-H FandolHei-Regular.otf} - \special{pdf:mapline gbkfs@UGBK@ UniGB-UTF16-H FandolFang-Regular.otf} - - \special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf} - \special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf} - \special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H FandolKai-Regular.otf} - \special{pdf:mapline unihei@Unicode@ UniGB-UTF16-H FandolHei-Regular.otf} - \special{pdf:mapline unifs@Unicode@ UniGB-UTF16-H FandolFang-Regular.otf} - - \special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf -s .167} - \special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H FandolKai-Regular.otf -s .167} - \special{pdf:mapline gbkheisl@UGBK@ UniGB-UTF16-H FandolHei-Regular.otf -s .167} - \special{pdf:mapline gbkfssl@UGBK@ UniGB-UTF16-H FandolFang-Regular.otf -s .167} - + \special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf} + \special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf} + \special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H FandolKai-Regular.otf} + \special{pdf:mapline gbkhei@UGBK@ UniGB-UTF16-H FandolHei-Regular.otf} + \special{pdf:mapline gbkfs@UGBK@ UniGB-UTF16-H FandolFang-Regular.otf} + \special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf} + \special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf} + \special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H FandolKai-Regular.otf} + \special{pdf:mapline unihei@Unicode@ UniGB-UTF16-H FandolHei-Regular.otf} + \special{pdf:mapline unifs@Unicode@ UniGB-UTF16-H FandolFang-Regular.otf} + \special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H FandolSong-Regular.otf -s .167} + \special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H FandolKai-Regular.otf -s .167} + \special{pdf:mapline gbkheisl@UGBK@ UniGB-UTF16-H FandolHei-Regular.otf -s .167} + \special{pdf:mapline gbkfssl@UGBK@ UniGB-UTF16-H FandolFang-Regular.otf -s .167} \special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H FandolSong-Regular.otf -s .167} - \special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H FandolKai-Regular.otf -s .167} - \special{pdf:mapline uniheisl@Unicode@ UniGB-UTF16-H FandolHei-Regular.otf -s .167} + \special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H FandolKai-Regular.otf -s .167} + \special{pdf:mapline uniheisl@Unicode@ UniGB-UTF16-H FandolHei-Regular.otf -s .167} \special{pdf:mapline unifssl@Unicode@ UniGB-UTF16-H FandolFang-Regular.otf -s .167} - +\fi % % \end{macrocode} % @@ -10415,137 +10675,195 @@ Copyright and Licence % % \begin{macrocode} %<*founder> -\ProvidesFile{zhfounderfonts.tex}% - [2019/05/29 v2.4.16 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)] - \ifzhmappdf - \pdfmapline{=gbk@UGBK@ % \end{macrocode} % +% \paragraph{\pkg{zhmacfonts.tex}} +% +% \changes{v2.5}{2020/01/15}{增加字体映射文件 \file{zhmacfonts.tex}。} +% +% \begin{macrocode} +%<*mac> +\ifzhmappdf +%% pdfTeX does not support OTF fonts +\else + \special{pdf:mapline gbk@UGBK@ UniGB-UTF16-H :3:Songti.ttc} + \special{pdf:mapline gbksong@UGBK@ UniGB-UTF16-H :3:Songti.ttc} + \special{pdf:mapline gbkkai@UGBK@ UniGB-UTF16-H :0:Kaiti.ttc} + \special{pdf:mapline gbkhei@UGBK@ unicode :2:PingFang.ttc} + \special{pdf:mapline gbkfs@UGBK@ unicode STFANGSO.ttf} + \special{pdf:mapline gbkli@UGBK@ UniGB-UTF16-H :0:Baoli.ttc} + \special{pdf:mapline gbkyou@UGBK@ UniGB-UTF16-H :4:Yuanti.ttc} + \special{pdf:mapline cyberb@Unicode@ UniGB-UTF16-H :3:Songti.ttc} + \special{pdf:mapline unisong@Unicode@ UniGB-UTF16-H :3:Songti.ttc} + \special{pdf:mapline unikai@Unicode@ UniGB-UTF16-H :0:Kaiti.ttc} + \special{pdf:mapline unihei@Unicode@ unicode :2:PingFang.ttc} + \special{pdf:mapline unifs@Unicode@ unicode STFANGSO.ttf} + \special{pdf:mapline unili@Unicode@ UniGB-UTF16-H :0:Baoli.ttc} + \special{pdf:mapline uniyou@Unicode@ UniGB-UTF16-H :4:Yuanti.ttc} + \special{pdf:mapline gbksongsl@UGBK@ UniGB-UTF16-H :3:Songti.ttc -s .167} + \special{pdf:mapline gbkkaisl@UGBK@ UniGB-UTF16-H :0:Kaiti.ttc -s .167} + \special{pdf:mapline gbkheisl@UGBK@ unicode :2:PingFang.ttc -s .167} + \special{pdf:mapline gbkfssl@UGBK@ unicode STFANGSO.ttf -s .167} + \special{pdf:mapline gbklisl@UGBK@ UniGB-UTF16-H :0:Baoli.ttc -s .167} + \special{pdf:mapline gbkyousl@UGBK@ UniGB-UTF16-H :4:Yuanti.ttc -s .167} + \special{pdf:mapline unisongsl@Unicode@ UniGB-UTF16-H :3:Songti.ttc -s .167} + \special{pdf:mapline unikaisl@Unicode@ UniGB-UTF16-H :0:Kaiti.ttc -s .167} + \special{pdf:mapline uniheisl@Unicode@ unicode :2:PingFang.ttc -s .167} + \special{pdf:mapline unifssl@Unicode@ unicode STFANGSO.ttf -s .167} + \special{pdf:mapline unilisl@Unicode@ UniGB-UTF16-H :0:Baoli.ttc -s .167} + \special{pdf:mapline uniyousl@Unicode@ UniGB-UTF16-H :4:Yuanti.ttc -s .167} +\fi +% +% \end{macrocode} +% % \paragraph{\pkg{zhubuntufonts.tex}} % % \begin{macrocode} %<*ubuntu> -\ProvidesFile{zhubuntufonts.tex}% - [2019/05/29 v2.4.16 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)] - \ifzhmappdf - \pdfmapline{=gbk@UGBK@ % \end{macrocode} % +% \paragraph{\pkg{zhwindowsfonts.tex}} +% % \begin{macrocode} +%<*windows> +\ifzhmappdf + \pdfmapline{=gbk@UGBK@ +% \end{macrocode} +% +% \begin{macrocode} \ctex@zhmap@endinput % % \end{macrocode} @@ -10562,7 +10880,7 @@ Copyright and Licence \ExplSyntaxOn \sys_if_engine_xetex:F { - \msg_new:nn { ctex } { xetex } + \msg_new:nnn { ctex } { xetex } { XeTeX~is~required~to~compile~this~document! } \msg_fatal:nn { ctex } { xetex } } @@ -10588,7 +10906,7 @@ Copyright and Licence % \begin{macro}[int]{\ctex_make_spa:nn} % |#1| 是 \file{spa} 文件名,|#2| 是由 CJK 族名与字体构成的逗号列表。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_make_spa:nn #1#2 +\cs_new_protected:Npn \ctex_make_spa:nn #1#2 { \iow_open:Nn \g_@@_spa_iow {#1} \clist_map_inline:nn {#2} @@ -10619,7 +10937,7 @@ Copyright and Licence } \group_end: } -\cs_new_protected_nopar:Npn \@@_save_bounds:n #1 +\cs_new_protected:Npn \@@_save_bounds:n #1 { \clist_put_right:Nx \l_@@_punct_bounds_clist { @@ -10632,7 +10950,7 @@ Copyright and Licence % % \pkg{CJKpunct} 要求的格式是边界空白宽度与 1\,em 的比值的一百倍。 % \begin{macrocode} -\cs_new_nopar:Npn \@@_calc_bounds:nn #1#2 +\cs_new:Npn \@@_calc_bounds:nn #1#2 { \fp_eval:n { @@ -10652,19 +10970,20 @@ Copyright and Licence % \begin{macrocode} %<*make> \input ctexspamacro % - \MAKESPA {ctexpunct.spa} { {adobezhsong} {AdobeSongStd-Light} , {adobezhhei} {AdobeHeitiStd-Regular} , {adobezhkai} {AdobeKaitiStd-Regular} , {adobezhfs} {AdobeFangsongStd-Regular} , +% {fandolzhsong} {FandolSong} , {fandolzhsongb} {FandolSong-Bold} , {fandolzhhei} {FandolHei} , {fandolzhheib} {FandolHei-Bold} , {fandolzhkai} {FandolKai} , {fandolzhfs} {FandolFang} , +% {founderzhsong} {FZShuSong-Z01} , {founderzhsongb} {FZXiaoBiaoSong-B05} , {founderzhhei} {FZHei-B01} , @@ -10674,9 +10993,26 @@ Copyright and Licence {founderzhli} {FZLiShu-S01} , {founderzhyou} {FZXiYuan-M01} , {founderzhyoub} {FZZhunYuan-M02} , - {ubuntuzhsong} {AR PL UMing CN} , - {ubuntuzhhei} {WenQuanYi Zen Hei} , - {ubuntuzhkai} {AR PL UKai CN} , +% + {maczhsong} {Songti SC Light} , + {maczhsongb} {Songti SC Bold} , + {maczhhei} {Heiti SC Medium} , + {maczhheil} {Heiti SC Light} , + {maczhkai} {Kaiti SC} , + {maczhkaib} {Kaiti SC Bold} , + {maczhfs} {STFangsong} , + {maczhli} {Baoli SC} , + {maczhyou} {Yuanti SC Light} , + {maczhyoub} {Yuanti SC Regular} , + {maczhpf} {PingFang SC} , + {maczhpfb} {PingFang SC Semibold} , +% + {ubuntuzhsong} {Noto Serif CJK SC} , + {ubuntuzhsongb} {Noto Serif CJK SC Bold} , + {ubuntuzhhei} {Noto Sans CJK SC} , + {ubuntuzhheib} {Noto Sans CJK SC Bold} , + {ubuntuzhkai} {AR PL KaitiM GB} , +% {windowszhsong} {SimSun} , {windowszhhei} {SimHei} , {windowszhkai} {KaiTi} , @@ -10686,7 +11022,6 @@ Copyright and Licence {windowszhyahei} {Microsoft YaHei} , {windowszhyaheib} {Microsoft YaHei Bold} } - \primitive\end % % @@ -10827,6 +11162,7 @@ Copyright and Licence % \subsection{\pkg{ctexhook} 宏包} % % \changes{v2.2}{2015/06/26}{将文档开头和宏包末尾钩子提取到 \pkg{ctexhook} 宏包中。} +% \changes{v2.5}{2020/04/21}{增加宏包开头钩子。} % % \begin{macrocode} %<*ctexhook> @@ -10835,13 +11171,13 @@ Copyright and Licence % \begin{macro}[int]{\ctex_at_end_preamble:n,\ctex_after_end_preamble:n} % 实现 \pkg{etoolbox} 宏包的 \tn{AtEndPreamble} 和 \tn{AfterEndPreamble}。 % \begin{macrocode} -\cs_new_protected:Npn \ctex_at_end_preamble:n #1 - { \tl_gput_right:Nn \g_@@_end_preamble_hook_tl {#1} } -\cs_new_protected:Npn \ctex_after_end_preamble:n #1 - { \tl_gput_right:Nn \g_@@_after_end_preamble_hook_tl {#1} } -\cs_new_protected_nopar:Npn \CTEX@document@left@hook +\cs_new_protected:Npn \ctex_at_end_preamble:n + { \tl_gput_right:Nn \g_@@_end_preamble_hook_tl } +\cs_new_protected:Npn \ctex_after_end_preamble:n + { \tl_gput_right:Nn \g_@@_after_end_preamble_hook_tl } +\cs_new_protected:Npn \CTEX@document@left@hook { \group_end: \g_@@_end_preamble_hook_tl \group_begin: } -\cs_new_protected_nopar:Npn \CTEX@document@right@hook +\cs_new_protected:Npn \CTEX@document@right@hook { \scan_stop: \g_@@_after_end_preamble_hook_tl \tex_ignorespaces:D } \cs_set_nopar:Npx \document { @@ -10854,51 +11190,93 @@ Copyright and Licence % \end{macrocode} % \end{macro} % +% \begin{macro}[int]{\ctex_at_begin_package:nn} +% 如果宏包已经被载入,则钩子无效,给出警告。 +% 在 \pkg{filehook} 的钩子\emph{之前}起作用。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_at_begin_package:nn #1 + { + \@ifpackageloaded {#1} + { \@@_package_loaded_warning:nn {#1} } + { \ctex_gadd_package_hook:nnn { begin } {#1} } + } +\cs_new_protected:Npn \@@_package_loaded_warning:nn #1#2 + { \msg_warning:nnx { ctex } { invalid-hook } {#1} } +\msg_new:nnn { ctex } { invalid-hook } + { + Package~`#1'~is~loaded. \\ + \token_to_str:N \ctex_at_begin_package:nn \{#1\}\{...\}~is~invalid. + } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[int]{\ctex_at_end_package:nn} % 与 \pkg{filehook} 的 \tn{AtEndOfPackageFile*} 类似,如果原来没有在载入宏包则 % 在宏包末尾执行语句,否则立即执行。 +% 在 \pkg{filehook} 的钩子\emph{之后}起作用。 % \begin{macrocode} -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 +\cs_new_protected:Npn \ctex_at_end_package:nn #1 { \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g_@@_at_end_ #1 _hook_tl } {#2} } + { \use:n } + { \ctex_gadd_package_hook:nnn { end } {#1} } } % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\ctex_gadd_hook:Nn, \ctex_gadd_hook:cn} +% \begin{macro}[int]{\ctex_gadd_package_hook:nnn, +% \ctex_gadd_hook:Nn, \ctex_gadd_hook:cn} % 给钩子附加内容。 % \begin{macrocode} -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 +\cs_new_protected:Npn \ctex_gadd_package_hook:nnn #1#2 + { \ctex_gadd_hook:cn { g_@@_at_ #1 _ #2 _hook_tl } } +\cs_new_protected:Npn \ctex_gadd_hook:Nn #1 { \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} + \tl_gput_right:Nn #1 } \cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\ctex_package_end_hook:n, \ctex_package_end_hook:o} -% 宏包末尾钩子,只执行一次,用后清除。 +% \begin{macro}[int]{\ctex_use_package_hook:nn} +% 宏包钩子,只执行一次,用后清除。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 +\cs_new_protected:Npn \ctex_use_package_hook:nn #1#2 { - \cs_if_exist_use:cT { g_@@_at_end_ #1 _hook_tl } - { \cs_undefine:c { g_@@_at_end_ #1 _hook_tl } } + \group_begin: \exp_args:NNc \group_end: + \@@_use_package_hook_aux:N { g_@@_at_ #1 _ #2 _hook_tl } } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } +\cs_new_protected:Npn \@@_use_package_hook_aux:N #1 + { \cs_if_exist_use:NT #1 { \cs_undefine:N #1 } } % \end{macrocode} % \end{macro} % +% \begin{macro}[int]{\@reset@ptions,\CTEX@reset@ptions@hook} +% \tn{@pushfilename} 内部的 \tn{@currname} 和 \tn{@currext} 保存的是 +% 前一个宏包的状态,不能使用。需要对其后的 \tn{@reset@ptions} 做补丁来实现 +% \cs{ctex_at_begin_package:nn} 的功能。 +% \begin{macrocode} +\tl_put_right:Nn \@reset@ptions { \CTEX@reset@ptions@hook } +\cs_new_protected:Npn \CTEX@reset@ptions@hook + { + \cs_if_eq:NNT \@currext \@pkgextension + { \ctex_use_package_hook:nn { begin } { \@currname } } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\@popfilename,\CTEX@popfilename@hook} % 对 \tn{@popfilename} 做补丁来实现 \cs{ctex_at_end_package:nn} 的功能。 % \begin{macrocode} -\tl_put_left:Nn \@popfilename +\tl_put_left:Nn \@popfilename { \CTEX@popfilename@hook } +\cs_new_protected:Npn \CTEX@popfilename@hook { \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } + { \ctex_use_package_hook:nn { end } { \@currname } } } % \end{macrocode} +% \end{macro} % % \begin{macrocode} % @@ -10913,10 +11291,6 @@ Copyright and Licence %<*ctexpatch> % \end{macrocode} % -% \begin{macrocode} -\cs_if_exist:NF \str_new:N { \RequirePackage { l3str } } -% \end{macrocode} -% % \begin{macro}[int]{\ctex_patch_cmd_once:NnnnTF} % 只进行第一次匹配进行替换。参数 |#2| 是宏重建时的 \tn{catcode} 设置。 % \begin{macrocode} @@ -10988,14 +11362,14 @@ Copyright and Licence % \begin{macrocode} \cs_new_protected:Npn \ctex_patch_boot:NNnnTF #1#2#3#4#5#6 { - \tl_set:Nn \@@_patch_true:w {#5} - \tl_set:Nn \@@_patch_false:w {#6} + \cs_set_protected:Npx \@@_patch_true:w { \exp_not:n {#5} } + \cs_set_protected:Npx \@@_patch_false:w { \exp_not:n {#6} } \group_begin: \char_set_catcode_other:n { 35 } \ctex_parse_name:NN #1 #2 {#3} {#4} } -\tl_new:N \@@_patch_true:w -\tl_new:N \@@_patch_false:w +\cs_new_eq:NN \@@_patch_true:w \use_i:nn +\cs_new_eq:NN \@@_patch_false:w \use_ii:nn % \end{macrocode} % \end{macro} % @@ -11040,7 +11414,7 @@ Copyright and Licence \exp_not:N ##2 \exp_not:c { ##3 ~ } \exp_not:c { #1##3 } - } {##3} ##1 + } { ##3 } ##1 } { ##1##2 } } @@ -11057,8 +11431,8 @@ Copyright and Licence \str_if_eq:eeTF { \exp_not:n { #1@protected@ ##3 #1##3 } } { - \exp_last_unbraced:Nf \@@_parse_name:w - \cs_replacement_spec:N ##3 #3 ~ #2 \q_stop + \exp_last_unbraced:Ne \@@_parse_name:w + { \cs_replacement_spec:N ##3 } #3 ~ #2 \q_stop } { #1##5 ~ } { ##5 ~ } } @@ -11270,903 +11644,4 @@ Copyright and Licence % % \Finale % -% \endinput -% -% \DisableImplementation -% -% \begin{implementation} -% -% \subsection{\cls{ctxdoc}} -% -% \begin{macrocode} -%<*ctxdoc> -% \end{macrocode} -% -% \begin{macrocode} -%<@@=ctxdoc> -% \end{macrocode} -% -% \begin{macrocode} -\ExplSyntaxOff -\let\pdfmdfivesum\mdfivesum -\DeclareOption*{\PassOptionsToClass{\CurrentOption}{l3doc}} -\PassOptionsToClass{a4paper,full}{l3doc} -\ProcessOptions -\@namedef{ver@thumbpdf.sty}{9999/99/99} -\LoadClass{l3doc} -\RequirePackage[UTF8, punct = kaiming, heading, fontset = none, - linespread = 1.2, sub3section]{ctex} -\ifxetex - \xeCJKsetup{AutoFakeBold=false} -\fi -\ctexset{ - fontset, - abstractname = 简介, - indexname = 代码索引, - section = { - format = \Large\bfseries\raggedright, - name = {第,节}, - }, -} -\RequirePackage[toc]{multitoc} -\RequirePackage{geometry} -\RequirePackage{tabularx} -\RequirePackage{makecell} -\RequirePackage{threeparttable} -\RequirePackage{siunitx} -\RequirePackage{unicode-math} -\RequirePackage{xcolor} -\RequirePackage{caption} -\RequirePackage{fancyvrb-ex} -\RequirePackage{zref-base} -\geometry{includemp,hmargin={0mm,15mm},vmargin={25mm,15mm},footskip=7mm} -\hypersetup{pdfstartview=FitH,bookmarksdepth=subparagraph} -\setcounter{secnumdepth}{4} -\setcounter{tocdepth}{2} -\newcommand*\email{\nolinkurl} -\setmainfont{TeX Gyre Pagella} -\setsansfont{TeX Gyre Heros} -\setmonofont[ - HyphenChar = None , - UprightFont=* Light, BoldFont=* Bold, - SlantedFont=* Light Oblique]{CMU Typewriter Text} -\setmathfont{texgyrepagella-math.otf} -\captionsetup{strut=off, labelsep=quad, labelfont+=bf} -%% <--- http://tex.stackexchange.com/a/40896 -\patchcmd{\@addtocurcol}% - {\vskip \intextsep}% - {\edef\save@first@penalty{\the\lastpenalty}\unpenalty - \ifnum \lastpenalty = \@M % hopefully the OR penalty - \unpenalty - \else - \penalty \save@first@penalty \relax % put it back - \fi - \ifnum\outputpenalty <-\@Mii - \addvspace\intextsep - \vskip\parskip - \else - \addvspace\intextsep - \fi}% - {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}} -\patchcmd{\@addtocurcol}% - {\vskip\intextsep \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi}% - {\ifnum\outputpenalty <-\@Mii - \aftergroup\vskip\aftergroup\intextsep - \aftergroup\nointerlineskip - \else - \vskip\intextsep - \fi}% - {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}} -\patchcmd{\@getpen}{\@M}{\@Mi} - {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}} -%% ---> -%% 不对代码实现的 \section 以下标题编目录。 -\AtBeginEnvironment{implementation}{% - \ifnum\value{tocdepth}>\@ne - \addtocontents{toc}{\protect\value{tocdepth}=1\relax}% - \fi} -\ifxetex - \let\ctexdocverbaddon\xeCJKVerbAddon - \def\ctexdisableecglue{\xeCJKsetup{CJKecglue}} - \def\ctexplainps{\xeCJKsetup{PunctStyle=plain}} - \appto\meta@font@select{\ifinner\ctexdisableecglue\fi} -\else - \let\ctexdocverbaddon\relax - \let\ctexplainps\relax - \def\ctexdisableecglue{\ltjsetparameter{autoxspacing=false}} - \appto\meta@font@select{\ctexdisableecglue} -\fi -\setlist{noitemsep,topsep=\smallskipamount} -\setlist[1]{labelindent=\parindent} -\setlist[enumerate]{leftmargin=*} -\setlist[itemize]{leftmargin=*} -\newlist{optdesc}{description}{3} -%% 设置间距为 \marginparsep,与 l3doc 一致 -\setlist[optdesc]{% - font=\mdseries\small\ttfamily,align=right,listparindent=\parindent, - labelsep=\marginparsep,labelindent=-\marginparsep,leftmargin=*} -%% 重新定义 threeparttable 包的 tablenotes 环境 -\renewlist{tablenotes}{description}{1} -\setlist[tablenotes]{% - format=\normalfont\tnote@item,align=right,listparindent=\parindent, - labelindent=\tabcolsep,leftmargin=*,rightmargin=\tabcolsep, - after=\@noparlisttrue} -\AtBeginEnvironment{tablenotes}{% - \setlength\parindent{2\ccwd}% - \normalfont\footnotesize} -\AtBeginEnvironment{threeparttable}{% - \stepcounter{tpt@id}% - \edef\curr@tpt@id{tpt@\arabic{tpt@id}}} -\newcounter{tpt@id} -\def\tnote@item#1{% - \Hy@raisedlink{\hyper@anchor{\curr@tpt@id-#1}}#1} -\def\TPTtagStyle#1{\hyperlink{\curr@tpt@id-#1}{#1}} -\fvset{ - fontsize=\small,baselinestretch=1,numbersep=5pt, - formatcom=\ctexdocverbaddon, - listparameters=\setlength\topsep{\MacrocodeTopsep}} -\DefineVerbatimEnvironment{frameverb}{Verbatim}{% - gobble=4, - frame=single,framesep=8pt, - listparameters= - \setlength\topsep{\medskipamount}% - \appto\FV@EndList{\nointerlineskip}} -\DefineVerbatimEnvironment{ctexexam}{Verbatim}{% - gobble=4, - frame=single,framesep=10pt, - label=\rule{0pt}{12pt}\textnormal{\bfseries 例 \arabic{ctexexam}}, - listparameters= - \setlength\topsep{\bigskipamount}% - \refstepcounter{ctexexam}\ctexexamlabelref - \appto\FV@EndList{\nointerlineskip}} -\define@key{FV}{labelref}{\def\ctexexamlabelref{\label{#1}}} -\let\ctexexamlabelref\empty -\newcounter{ctexexam} -\BeforeBeginEnvironment{function}{\par\nointerlineskip} -\AtEndEnvironment{function}{% - \par\xdef\ctexfixprevdepth{\prevdepth=\the\prevdepth\space}} -\AfterEndEnvironment{function}{\ctexfixprevdepth} -\AtBeginEnvironment{syntax}{\linespread{1}\ctexplainps\ctexdisableecglue} -\BeforeBeginEnvironment{SideBySideExample}{\par\addvspace{\medskipamount}} -\newcommand*\exptarget{\Hy@raisedlink{\hypertarget{expstar}{}}} -\newcommand*\rexptarget{\Hy@raisedlink{\hypertarget{rexpstar}{}}} -\newcommand*\expstar{\hyperlink{expstar}{$\star$}} -\newcommand*\rexpstar{\hyperlink{rexpstar}{\ding{73}}} -\ExplSyntaxOn -%% l3doc 会设置列表环境中 \listparindent=\z@,我们在这里恢复它。 -\cs_set_eq:NN \list \__codedoc_oldlist:nn -\cs_new_nopar:Npn \zihaopt #1 - { - \exp_last_unbraced:Nf \tl_head:w - { \prop_item:Nn \c__ctex_font_size_prop {#1} } { } \q_stop - } -%% 抑制首段的 \parskip -\ctex_patch_cmd_once:NnnnTF \__codedoc_function_descr_start:w - { } - { \noindent } - { \skip_vertical:n { -\parskip } \noindent } - { \iow_term:n { *** ~ SUCCESS ~ *** } } - { \iow_term:n { *** ~ FAIL ~ *** } } -%% l3doc 会在 function 环境的 syntax 和 descr 盒子中间加上 \medskipamount 的距离。 -%% 但是若 syntax 盒子为空(未使用 syntax 环境),就会显得不好看。 -%% 此时我们通过将 \medskipamount 设置为零来修正。若盒子非空,则将 \parskip 还回去。 -\ctex_preto_cmd:NnnTF \__codedoc_function_assemble: - { } - { \ctex_doc_fix_yoffset: } - { \iow_term:n { *** ~ SUCCESS ~ *** } } - { \iow_term:n { *** ~ FAIL ~ *** } } -\cs_new_protected_nopar:Npn \ctex_doc_fix_yoffset: - { - \box_if_empty:NTF \g__codedoc_syntax_box - { \skip_zero:N \medskipamount } - { \skip_add:Nn \medskipamount { \parskip } } - } -%% 左侧边注的函数列表采用单倍行距 -\ctex_preto_cmd:NnnTF \__codedoc_typeset_functions: - { } - { \MacroFont } - { \iow_term:n { *** ~ SUCCESS ~ *** } } - { \iow_term:n { *** ~ FAIL ~ *** } } -\ctex_patch_cmd_once:NnnnTF \__codedoc_macro_init: - { } - { \hbox:n } - { \MacroFont \hbox:n } - { \iow_term:n { *** ~ SUCCESS ~ *** } } - { \iow_term:n { *** ~ FAIL ~ *** } } -\ctex_patch_cmd_once:NnnnTF \__codedoc_macro_dump: - { } - { \hbox_unpack_drop:N } - { \MacroFont \hbox_unpack_drop:N } - { \iow_term:n { *** ~ SUCCESS ~ *** } } - { \iow_term:n { *** ~ FAIL ~ *** } } -\cs_set_eq:NN \__codedoc_macro_end_style:n \use_none:n -\cs_set_protected:Npn \__codedoc_macro_typeset_one:nN #1#2 - { - \vbox_set:Nn \l__codedoc_macro_box - { - \MacroFont - \vbox_unpack_drop:N \l__codedoc_macro_box - \hbox_set:Nn \l_tmpa_box - { \__codedoc_print_macroname:nN {#1} #2 } - \dim_set:Nn \l_tmpa_dim { \marginparwidth - \labelsep } - \dim_compare:nNnT { \box_wd:N \l_tmpa_box } > \l_tmpa_dim - { - \box_resize_to_wd_and_ht:Nnn \l_tmpa_box - { \l_tmpa_dim } - { \box_ht:N \l_tmpa_box } - } - \hbox_overlap_left:n - { - \box_use:N \l_tmpa_box - \skip_horizontal:n { \marginparsep - \labelsep } - } - } - \int_incr:N \l__codedoc_macro_int - } -\cs_set_protected:Npn \__codedoc_print_macroname:nN #1#2 - { - \strut - \__codedoc_get_hyper_target:xN - { - \exp_not:n {#1} - \bool_if:NT #2 { \tl_to_str:n {TF} } - } - \l__codedoc_tmpa_tl - \cs_if_exist:cTF { r@ \l__codedoc_tmpa_tl } - { \exp_args:NNo \label@hyperref [ \l__codedoc_tmpa_tl ] } - { \use:n } - { - \tl_set:Nn \l__codedoc_tmpa_tl {#1} - \tl_replace_all:Non \l__codedoc_tmpa_tl - { \c_catcode_other_space_tl } - { \fontspec_visible_space: } - \__codedoc_macroname_prefix:o \l__codedoc_tmpa_tl - \__codedoc_macroname_suffix:N #2 - } - } -\AtBeginEnvironment { syntax } - { - \char_set_catcode_active:N \| - \char_set_active_eq:NN \| \orbar - \char_set_catcode_active:N \( - \char_set_active_eq:NN \( \defaultvalaux - } -%% 不对目录中出现的 \cs 和 \tn 等编索引 -\DeclareDocumentCommand \StopSpecialIndexModule { } - { \cs_set_eq:NN \__codedoc_special_index_module:nnnnN \use_none:nnnnn } -\tl_map_inline:nn { \actualchar \encapchar \levelchar } - { \exp_args:Nx \DoNotIndex { \bslash \tl_to_str:N #1 } } -\DeclareDocumentCommand \package { o m } - { - \exp_args:Nx \href - { - http \c_colon_str //www.ctan.org/pkg/ - \IfNoValueTF {#1} { \str_fold_case:n {#2} } {#1} - } - { \pkg {#2} } - } -\DeclareDocumentCommand \GetFileId { m } - { - \GetFileInfo {#1} - \file_get:nnNTF { \c_sys_jobname_str .id } - { \int_set:Nn \tex_endlinechar:D { -1 } } \l_@@_tmp_tl - { \exp_after:wN \GetIdInfo \l_@@_tmp_tl } - { \GetIdInfo $Id$ } - { \fileinfo } - } -\cs_new_eq:NN \@@_ltx_changes:nnn \changes@ -\cs_set_protected:Npn \changes@ #1#2 - { - \@@_save_version_date:nn {#1} {#2} - \tl_if_empty:nTF {#1} - { \@@_ltx_changes:nnn } - { \@@_version_zfill:wnnn #1 \q_stop } - {#1} {#2} - } -\cs_new_protected:Npn \@@_version_zfill:wnnn #1#2 \q_stop - { - \str_if_eq:nnTF {#1} { v } - { \@@_version_zfill:nnnn {#2} } - { \@@_ltx_changes:nnn } - } -\cs_new_protected:Npn \@@_version_zfill:nnnn #1#2 - { - \tl_clear:N \l_@@_tmp_tl - \int_zero:N \l_tmpa_int - \seq_set_split:Nnn \l_tmpa_seq { . } {#1} - \seq_map_function:NN \l_tmpa_seq \@@_version_zfill:n - \int_compare:nNnF \l_tmpa_int > 2 - { - \tl_put_right:Nx \l_@@_tmp_tl - { \prg_replicate:nn { 3 - \l_tmpa_int } { 00000 } } - } - \@@_ltx_changes:nnn { \l_@@_tmp_tl \actualchar #2 } - } -\tl_new:N \l_@@_tmp_tl -\cs_new_protected:Npn \@@_version_zfill:n #1 - { - \int_incr:N \l_tmpa_int - \tl_put_right:Nx \l_@@_tmp_tl - { - \prg_replicate:nn - { \int_max:nn { 0 } { 5 - \tl_count:n {#1} } } { 0 } - \exp_not:n {#1} - } - } -\cs_new_protected:Npn \@@_save_version_date:nn #1#2 - { - \prop_get:NnNTF \g_@@_version_date_prop {#1} \l_@@_tmp_tl - { \exp_after:wN \@@_save_version_date:nnnn \l_@@_tmp_tl {#2} {#1} } - { \@@_save_version_date:nnn {#1} {#2} {#2} } - } -\cs_new_protected:Npn \@@_save_version_date:nnnn #1#2#3#4 - { - \@@_if_date_later:nnTF {#1} {#3} - { \@@_save_version_date:nnn {#4} {#3} {#2} } - { - \@@_if_date_later:nnT {#3} {#2} - { \@@_save_version_date:nnn {#4} {#1} {#3} } - } - } -\prg_new_conditional:Npnn \@@_if_date_later:nn #1#2 { TF , T } - { - \if_int_compare:w \@@_parse_date:w #1 / / / 0 \q_stop > - \@@_parse_date:w #2 / / / 0 \q_stop \exp_stop_f: - \prg_return_true: \else: \prg_return_false: \fi: - } -\cs_new:Npn \@@_parse_date:w #1/#2/#3/ #4 \q_stop - { #1#2#3 } -\cs_new_protected:Npn \@@_save_version_date:nnn #1#2#3 - { \prop_gput:Nnn \g_@@_version_date_prop {#1} { {#2} {#3} } } -\cs_new_protected:Npn \CTEX@versionitem #1 \efill - { - \@idxitem - \prop_get:NnNTF \g_@@_version_date_prop {#1} \l_@@_tmp_tl - { \exp_after:wN \@@_version_item:nnn \l_@@_tmp_tl {#1} } - { \BOOM } - } -\cs_new_protected:Npn \@@_version_item:nnn #1#2#3 - { - \noindent - \Hy@raisedlink { \belowpdfbookmark {#3} { HD.#3 } } - \textbf {#3} \hfill - \hbox:n - { - \footnotesize - \str_if_eq:nnTF {#1} {#2} - { ( #1 ) } - { ( #1 ~ -- ~ #2 ) } - } - \par \nopagebreak - } -\prop_new:N \g_@@_version_date_prop -\ctex_patch_cmd:Nnn \HDorg@theglossary - { \let \item \@idxitem } - { \let \item \CTEX@versionitem } -\ctex_patch_cmd:Nnn \l@section { 2.5em } { 1.5em } -\ctex_patch_cmd:Nnn \l@subsection { 2.5em } { 1.5em } -\ctex_patch_cmd:Nnn \@wrglossary - { hdpindex } - { - \ifnum \c@HD@hypercount = \z@ - hdpindex - \else - hdclindex { \the \c@HD@hypercount } - \fi - } -%% 重定义 macrocode 环境的实现,逐行处理 -\cs_set_protected_nopar:Npn \xmacro@code - { \@@_marco_code:w } -\cs_set_protected_nopar:Npn \sxmacro@code - { - \fontspec_print_visible_spaces: - \xmacro@code - } -\cs_new_protected_nopar:Npn \@@_marco_code:w - { - \ifcodeline@index - \@@_marco_every_par:n { \@@_code_line_no: } - \else: - \@@_marco_every_par:n { } - \fi: - \exp_args:Nx \@@_make_finish_tag:n { \@currenvir } - \@@_verbatim_start:w - } -\cs_new_protected:Npn \@@_marco_every_par:n #1 - { - \everypar - { - \everypar {#1} - \if@inlabel - \global \@inlabelfalse - \@noparlistfalse - \llap { \box \@labels \hskip \leftskip } - \fi - #1 - } - } -\ctex_patch_cmd:Nnn \macro@code - { \if@inlabel \leavevmode \fi } - { \partopsep \z@skip } -\group_begin: - \int_set:Nn \tex_endlinechar:D { -1 } - \use:n - { - \char_set_catcode_active:n { 32 } - \tl_const:Nn \c_@@_active_space_tl - } - { } -\group_end: -\group_begin: - \char_set_catcode_active:n { 13 } - \cs_new_protected:Npx \@@_make_finish_tag:n #1 - { - \tl_set:Nn \exp_not:N \l_@@_verbatim_finish_tl - { - \c_percent_str - \prg_replicate:nn { 4 } - { \exp_not:o { \c_@@_active_space_tl } } - \exp_not:o { \active@escape@char } end - \c_left_brace_str #1 \c_right_brace_str - \exp_not:N ^^M - } - } - \cs_new_protected:Npn \@@_verbatim_start:w #1 - { - \str_if_eq:nnTF {#1} { ^^M } - { \@@_verbatim_read_line:w } - { \@@_verbatim_read_line:w #1 } - } - \cs_new_protected:Npn \@@_verbatim_read_line:w #1 ^^M - { - \tl_set:Nn \l_@@_verbatim_line_tl { #1 ^^M } - \tl_if_eq:NNTF \l_@@_verbatim_line_tl \l_@@_verbatim_finish_tl - { \exp_args:Nx \end { \@currenvir } } - { - \@@_verbatim_process_line: - \@@_verbatim_read_line:w - } - } - \cs_new_protected:Npn \@@_swap_cr: - { \exp_after:wN \@@_swap_cr:w \l_@@_verbatim_line_tl } - \cs_new_protected:Npn \@@_swap_cr:w #1 ^^M - { - \group_insert_after:N ^^M - \tl_set:Nn \l_@@_verbatim_line_tl {#1} - } - \tl_const:Nn \c_@@_active_cr_tl { ^^M } -\group_end: -\tl_new:N \l_@@_verbatim_line_tl -\tl_new:N \l_@@_verbatim_finish_tl -\tl_new:N \g_@@_verbatim_verb_stop_tl -\cs_new_protected_nopar:Npn \@@_process_normal_line: - { - \str_if_eq:eeTF - { \str_head:N \l_@@_verbatim_line_tl } { \c_percent_str } - { \@@_check_angle:x { \tl_tail:N \l_@@_verbatim_line_tl } } - { \@@_output_line: } - } -\cs_new_protected_nopar:Npn \@@_process_verb_line: - { - \tl_if_eq:NNTF \l_@@_verbatim_line_tl \g_@@_verbatim_verb_stop_tl - { - \tl_gclear:N \g_@@_verbatim_verb_stop_tl - \cs_gset_eq:NN \@@_verbatim_process_line: \@@_process_normal_line: - \@@_output_module:nn - { \color { verb@guard } } - { - \@@_swap_cr: - \@@_module_pop:n { \l_@@_verbatim_line_tl } - } - } - { \tl_use:N \l_@@_verbatim_line_tl } - } -\cs_new_eq:NN \@@_verbatim_process_line: \@@_process_normal_line: -\DeclareDocumentCommand \CheckModules { } - { \cs_set_eq:NN \@@_verbatim_process_line: \@@_process_normal_line: } -\DeclareDocumentCommand \DontCheckModules { } - { \cs_set_eq:NN \@@_verbatim_process_line: \@@_output_line: } -\cs_new_protected:Npn \@@_check_angle:n #1 - { - \str_if_eq:eeTF { \str_head:n {#1} } { < } - { \@@_check_module:x { \tl_tail:n {#1} } } - { \@@_output_percent_line: } - } -\cs_generate_variant:Nn \@@_check_angle:n { x } -\cs_new_protected:Npn \@@_check_module:n #1 - { - \exp_args:Nx \str_case:nnF { \str_head:n {#1} } - { - { * } { \@@_module_star:w } - { / } { \@@_module_slash:w } - { @ } { \@@_module_at:w } - { < } { \@@_module_verb:w } - } - { \@@_module_pm:w } - #1 \q_stop - } -\cs_generate_variant:Nn \@@_check_module:n { x } -\group_begin: - \char_set_catcode_active:N \> - \cs_new_protected:Npn \@@_module_star:w #1 > #2 \q_stop - { - \@@_output_module:nn - { \@@_star_color: } - { \@@_module_push:n { \@@_module_angle:n {#1} } } - \@@_output_line:n {#2} - \@@_star_format: - } - \cs_new_protected:Npn \@@_module_slash:w #1 > #2 \q_stop - { - \@@_output_module:nn - { \@@_slash_color: } - { \@@_module_pop:n { \@@_module_angle:n {#1} } } - \@@_output_line:n {#2} - \@@_slash_format: - } - \cs_new_protected:Npn \@@_module_at:w @ @ = #1 > #2 \q_stop - { - \@@_output_module:nn - { \color { at@guard } } - { \@@_module_angle:n { @ @ = #1 } } - \tl_gset:Nn \g__codedoc_module_name_tl {#1} - \@@_output_line:n {#2} - } - \cs_new_protected:Npn \@@_module_pm:w #1 > #2 \q_stop - { - \tex_noindent:D - \hbox_overlap_left:n - { - \@@_output_module:nn - { \@@_pm_color: } - { \@@_module_angle:n {#1} } - \skip_horizontal:n { \leftskip + \smallskipamount } - } - \group_begin: - \@@_pm_format: - \@@_output_line:n {#2} - \group_end: - } - \cs_new_protected:Npn \@@_module_verb:w #1 \q_stop - { - \cs_gset_eq:NN \@@_verbatim_process_line: \@@_process_verb_line: - \tl_gset:Nx \g_@@_verbatim_verb_stop_tl - { \c_percent_str \tl_tail:n {#1} } - \@@_output_module:nn - { \color { verb@guard } } - { - \@@_swap_cr: - \@@_module_push:n { \l_@@_verbatim_line_tl } - } - } -\group_end: -\cs_new_protected_nopar:Npn \@@_output_line: - { - \tex_noindent:D - \@@_replace_at_at:N \l_@@_verbatim_line_tl - \tl_use:N \l_@@_verbatim_line_tl - } -\cs_new_protected:Npn \@@_replace_at_at:N #1 - { - \tl_if_empty:NF \g__codedoc_module_name_tl - { - \exp_args:NNo \@@_replace_at_at_aux:Nn - #1 \g__codedoc_module_name_tl - } - } -\cs_new_protected:Npn \@@_replace_at_at_aux:Nn #1#2 - { - \tl_replace_all:Nnn #1 { _ @ @ } { _ _ #2 } - \tl_replace_all:Nnn #1 { @ @ } { _ _ #2 } - } -\cs_new_protected:Npn \@@_output_line:n #1 - { - \tl_set:Nn \l_@@_verbatim_line_tl {#1} - \tl_if_eq:NNTF \l_@@_verbatim_line_tl \c_@@_active_cr_tl - { \tl_use:N \l_@@_verbatim_line_tl } - { - \str_if_eq:eeTF - { \str_head:N \l_@@_verbatim_line_tl } - { \c_percent_str } - { \@@_output_percent_line: } - { \@@_output_line: } - } - } -\cs_new_protected:Npn \@@_output_percent_line: - { - \tex_noindent:D - \group_begin: - \color { code@gray } - \@@_swap_cr: - \str_if_eq:eeTF { \f@shape } { \updefault } - { \slshape } - { \upshape } - \@@_output_line: - \group_end: - } -\cs_new_protected_nopar:Npn \@@_module_push:n - { \exp_args:No \@@_module_push_aux:nn { \int_use:N \c@HD@hypercount } } -\cs_new_protected:Npn \@@_module_push_aux:nn #1 - { - \seq_gpush:Nn \g_@@_module_dest_seq {#1} - \hypersetup { hidelinks } - \exp_args:Nx \hdclindex - { \zref@extractdefault { HD.#1 } { guard@end } { 1 } } { } - } -\cs_new_protected_nopar:Npn \@@_module_pop:n - { - \seq_gpop:NNTF \g_@@_module_dest_seq \l_@@_tmp_tl - { \exp_args:No \@@_module_pop_aux:nn { \l_@@_tmp_tl } } - { \BOOM \use:n } - } -\cs_new_protected:Npn \@@_module_pop_aux:nn #1 - { - \zref@labelbylist { HD.#1 } { ctxdoc } - \hypersetup { hidelinks } - \hdclindex {#1} { } - } -\seq_new:N \g_@@_module_dest_seq -\zref@newlist { ctxdoc } -\zref@newprop { guard@end } [ 1 ] - { \int_eval:n { \c@HD@hypercount - 1 } } -\zref@addprop { ctxdoc } { guard@end } -\cs_new_protected_nopar:Npn \@@_star_format: - { - \seq_gpush:No \g_@@_slash_format_seq { \macro@font } - \seq_gpop:NNF \g_@@_star_format_seq \l_@@_format_tl - { \@@_pop_format: } - \@@_select_format: - } -\cs_new_protected_nopar:Npn \@@_slash_format: - { - \seq_gpop:NNTF \g_@@_slash_format_seq \l_@@_format_tl - { - \seq_gpush:No \g_@@_star_format_seq { \macro@font } - \@@_select_format: - } - { \BOOM } - } -\cs_new_protected_nopar:Npn \@@_pm_format: - { - \seq_get:NNF \g_@@_star_format_seq \l_@@_format_tl - { - \@@_pop_format: - \seq_gpush:No \g_@@_star_format_seq { \l_@@_format_tl } - } - \cs_if_eq:NNF \macro@font \l_@@_format_tl - { \l_@@_format_tl } - } -\cs_new_protected_nopar:Npn \@@_pop_format: - { - \seq_gpop_left:NN \g_@@_format_seq \l_@@_format_tl - \seq_gput_right:No \g_@@_format_seq { \l_@@_format_tl } - } -\cs_new_protected_nopar:Npn \@@_select_format: - { - \cs_if_eq:NNF \macro@font \l_@@_format_tl - { - \cs_gset_eq:NN \macro@font \l_@@_format_tl - \macro@font - } - } -\tl_new:N \l_@@_format_tl -\seq_new:N \g_@@_format_seq -\seq_new:N \g_@@_star_format_seq -\seq_new:N \g_@@_slash_format_seq -\seq_gput_right:Nn \g_@@_format_seq { \MacroFont } -\seq_gput_right:Nn \g_@@_format_seq { \AltMacroFont } -\cs_set_protected:Npn \MacroFont - { - \linespread { 1 } - \small - \fontseries { \mddefault } - \fontshape { \updefault } - \ttfamily - \ctexdocverbaddon - } -\cs_set_protected:Npn \AltMacroFont - { - \linespread { 1 } - \small - \fontseries { \mddefault } - \fontshape { \sldefault } - \ttfamily - \ctexdocverbaddon - } -\AtBeginDocument - { - \tl_gset:Nx \macro@font - { \seq_item:Nn \g_@@_format_seq { 1 } } - } -\cs_new_protected:Npn \@@_output_module:nn #1#2 - { - \tex_noindent:D - \group_begin: - #1 - \footnotesize \normalfont \sffamily #2 - \group_end: - } -\cs_new_protected_nopar:Npn \@@_star_color: - { - \seq_gpop:NNTF \g_@@_star_color_seq \current@color - { \set@color } - { \@@_select_color: } - \seq_gpush:No \g_@@_slash_color_seq { \current@color } - } -\cs_new_protected_nopar:Npn \@@_slash_color: - { - \seq_gpop:NNTF \g_@@_slash_color_seq \current@color - { - \set@color - \seq_gpush:No \g_@@_star_color_seq { \current@color } - } - { \BOOM } - } -\cs_new_protected_nopar:Npn \@@_pm_color: - { - \seq_get:NNTF \g_@@_star_color_seq \current@color - { \set@color } - { - \@@_select_color: - \seq_gpush:No \g_@@_star_color_seq { \current@color } - } - } -\seq_new:N \g_@@_star_color_seq -\seq_new:N \g_@@_slash_color_seq -\cs_new_protected_nopar:Npn \@@_select_color: - { \color { guard@series!!+ } } -\definecolorseries { guard@series } - { cmyk } { last } { blue } { purple } -\resetcolorseries [ 3 ] { guard@series } -\definecolor { verb@guard } { rgb } { 0.5 , 0.5 , 0 } -\definecolor { at@guard } { rgb } { 0.5 , 0 , 0.5 } -\definecolor { code@gray } { gray } { 0.5 } -\cs_new_protected:Npn \@@_module_angle:n #1 - { \textlangle #1 \textrangle } -\cs_new_protected_nopar:Npn \@@_code_line_no: - { - \int_gincr:N \c@CodelineNo - \hbox_overlap_left:n - { - \hbox_to_wd:nn - { \MacroIndent } - { - \HD@target - \tex_hss:D - \@@_code_line_no_style: - \theCodelineNo \enspace - } - \tex_kern:D \@totalleftmargin - } - } -\tl_set:Nn \theCodelineNo - { \arabic { CodelineNo } } -\cs_new_protected_nopar:Npn \@@_code_line_no_style: - { \color { code@gray } \normalfont \sffamily \tiny } -\cs_set_protected:Npn \HD@SetMacroIndent #1 - { - \group_begin: - \settowidth \MacroIndent - { - \@@_code_line_no_style: - \prg_replicate:nn { \tl_count:n {#1} } { 0 } - \enspace - } - \dim_gset_eq:NN \MacroIndent \MacroIndent - \group_end: - } -\ExplSyntaxOff -\AtBeginDocument{\addtocontents{toc}{\StopSpecialIndexModule}} -\pdfstringdefDisableCommands{% - \let\path\meta - \let\opt\@firstofone} -\preto\@thehead{\cslet{MakeUppercase\space}{\@iden}} -\def\orbar{\textup{\textbar}} -\def\defaultval#1{\textbf{\textup{#1}}} -\def\defaultvalaux#1){\defaultval{#1}} -\def\TF{true\orbar false} -\def\TTF{\defaultval{true}\orbar false} -\def\TFF{true\orbar\defaultval{false}} -\protected\def\opt{\texttt} -\def\pdfTeX{\hologo{pdfTeX}} -\def\XeTeX{\hologo{XeTeX}} -\def\XeLaTeX{\hologo{XeLaTeX}} -\def\LuaLaTeX{\hologo{LuaLaTeX}} -\def\pdfLaTeX{\hologo{pdfLaTeX}} -\def\LaTeX{\hologo{LaTeX}} -\def\LaTeXe{\hologo{LaTeX2e}} -\def\LaTeXiii{\hologo{LaTeX3}} -\def\dvipdfmx{DVIPDFM\textit{x}} -\def\TeX{\hologo{TeX}} -\def\ApTeX{Ap\TeX} -\def\ApLaTeX{Ap\LaTeX} -\def\upTeX{up\TeX} -\def\upLaTeX{up\LaTeX} -\def\bashcmd{\texttt} -\def\TeXLive{\TeX\ Live} -\def\MiKTeX{\hologo{MiKTeX}} -\def\BSTACK{\begin{tabular}[t]{@{}l@{}}} -\def\ESTACK{\end{tabular}} -\newenvironment{defaultcapconfig}{% - \MakePercentComment - \input{ctex-name-utf8.cfg}% - \ExplSyntaxOff - \MakePercentIgnore}{} -\def\ctexkit{\href{https://github.com/CTeX-org/ctex-kit/}{\texttt{ctex-kit}}} -\def\ctexkitrev#1{% - \href{https://github.com/CTeX-org/ctex-kit/commit/#1}{\texttt{ctex-kit} rev. #1}} -\appto\GlossaryParms{% - \raggedcolumns - \let\Hy@writebookmark\HDorg@writebookmark - \def\@idxitem{\par\hangindent 2em }% - \def\subitem{\@idxitem\hspace*{1em}}% - \def\subsubitem{\@idxitem\hspace*{2em}}} -\def\glossaryname{版本历史} -\GlossaryPrologue{\section{\glossaryname}} -\IndexPrologue{% - \section{\indexname} - \textit{意大利体的数字表示描述对应索引项的页码; - 带下划线的数字表示定义对应索引项的代码行号; - 罗马字体的数字表示使用对应索引项的代码行号。}} -\def\IndexLayout{% - \newgeometry{hmargin=15mm,vmargin={25mm,15mm},footskip=7mm}% - \setlength\IndexMin{.5\textheight}% - \ctexset{section/numbering=false}% - \StopSpecialIndexModule} -\EnableCrossrefs -\CodelineIndex -\RecordChanges -% \end{macrocode} -% -% \begin{macrocode} -% -% \end{macrocode} -% -% \subsection{\pkg{ctxdocstrip}} -% -% \begin{macrocode} -%<*docstrip> -\csname ctxdocstriploaded\endcsname -\let\ctxdocstriploaded\endinput -\input l3docstrip % -\edef\ctxresetcatcode{% - \catcode\number`\$=\the\catcode`\$\relax} -\makeOther\$ -\def\plusOption+#1>#2$#3$\endLine{% - \maybeMsg{<+#1 . >}% - \Evaluate{#1}% - \def\ctxCMD{#2}% - \def\ctxID{$#3$}% - \def\do##1##2##3{% - \if1\Expr{##2}% - \readIDFile - \StreamPut##1{\inLine}% - \fi - }% - \activefiles -} -\def\readIDFile{% - \openin\inputcheck=\jobname.id\relax - \ifeof\inputcheck\else - \read \inputcheck to \inLine - \closein\inputcheck - \ifx\inLine\empty\else - \let\ctxID\inLine - \fi - \fi - \maybeMsg{^^J\ctxID^^J}% - \def\inLine{\ctxCMD\ctxID}% -} -\keepsilent -\askforoverwritefalse -\declarepreamble\emptypreamble -\endpreamble -\declarepostamble\emptypostamble -\endpostamble -\ctxresetcatcode -% -% \end{macrocode} -% -% \end{implementation} -% \endinput diff --git a/language/chinese/ctex/ctex.pdf b/language/chinese/ctex/ctex.pdf index 88f89a1e10..7f13942d03 100644 Binary files a/language/chinese/ctex/ctex.pdf and b/language/chinese/ctex/ctex.pdf differ diff --git a/language/chinese/ctex/ctexpunct.spa b/language/chinese/ctex/ctexpunct.spa index 2c6e37c497..a535be5ed7 100644 --- a/language/chinese/ctex/ctexpunct.spa +++ b/language/chinese/ctex/ctexpunct.spa @@ -17,9 +17,23 @@ \ctexspadef{founderzhli}{69,19,58,9,48,21,45,27,48,25,47,32,48,27,48,39,48,21,43,17,47,33,47,33,0,0,11,11,11,61,13,63,17,66,7,80,20,70,19,68,20,70,3,54,9,9,25,48,32,47,27,48,40,48,21,48,17,43,33,47,33,47,19,69,9,58,21,48,27,45,,,} \ctexspadef{founderzhyou}{67,16,61,11,48,11,45,14,48,20,48,17,48,16,48,39,48,12,42,16,48,30,48,30,0,0,12,11,11,61,9,59,17,67,11,83,20,70,18,69,21,70,4,54,12,12,20,48,17,48,16,48,39,48,12,48,16,41,30,48,29,48,16,67,11,61,11,48,14,45,,,} \ctexspadef{founderzhyoub}{69,18,60,10,46,13,43,16,46,17,45,20,46,18,46,31,45,13,38,14,44,29,46,30,-3,0,10,9,9,61,9,59,19,69,7,82,18,68,18,67,20,69,2,52,17,17,17,46,20,45,18,46,32,46,13,45,14,38,29,44,30,46,19,69,10,60,14,46,17,43,,,} -\ctexspadef{ubuntuzhsong}{66,21,58,7,58,8,55,11,59,18,71,7,71,2,40,38,58,13,52,4,64,6,58,14,7,7,11,10,38,38,38,38,17,73,21,70,13,78,13,75,27,63,4,52,4,5,18,59,7,71,2,71,38,40,13,58,4,51,6,64,14,58,16,70,8,56,10,58,11,54,,,} -\ctexspadef{ubuntuzhhei}{6,6,4,4,60,10,61,11,62,12,65,15,67,15,62,15,63,13,57,6,19,52,63,13,-0,0,11,11,10,70,10,68,44,44,45,44,44,44,44,44,43,45,27,27,19,16,12,62,15,65,15,67,15,62,13,63,6,56,3,68,13,63,6,6,4,4,10,60,11,61,,,} -\ctexspadef{ubuntuzhkai}{68,20,58,9,58,8,55,11,59,18,59,20,59,18,53,23,58,13,52,4,58,8,58,14,7,7,11,10,38,38,38,38,40,42,43,43,43,43,43,43,43,43,25,28,10,11,18,59,20,59,18,59,24,53,13,58,4,51,8,58,14,58,17,70,9,58,10,58,11,54,,,} +\ctexspadef{maczhsong}{4,4,4,4,63,14,59,7,63,13,64,13,70,12,59,13,61,12,47,7,56,7,58,8,0,0,11,11,10,68,13,63,17,68,20,70,20,70,18,68,20,70,12,59,18,18,14,62,10,66,12,69,9,64,12,61,7,47,7,56,8,58,4,4,4,4,14,63,7,59,,,} +\ctexspadef{maczhsongb}{4,4,4,4,62,13,49,13,62,10,65,10,59,13,62,14,61,12,43,9,56,4,56,14,0,0,11,10,7,67,13,62,15,66,18,67,18,69,16,66,18,69,10,60,14,10,10,62,10,64,12,60,14,62,12,61,9,43,4,56,14,56,4,4,4,4,12,62,12,50,,,} +\ctexspadef{maczhhei}{68,15,58,4,62,13,56,6,61,11,65,12,66,16,63,12,59,14,51,5,55,5,60,10,0,0,8,11,13,60,13,62,20,70,20,70,20,70,20,70,20,70,3,54,9,10,10,62,12,65,16,65,9,66,14,60,7,48,5,55,10,60,14,68,4,58,13,62,6,56,,,} +\ctexspadef{maczhheil}{71,17,65,7,60,11,56,6,59,9,67,10,66,15,64,13,58,14,51,6,53,6,60,8,0,0,9,10,10,61,12,62,20,70,20,70,20,70,20,70,21,71,4,55,9,9,9,59,10,67,15,66,13,64,14,58,6,51,6,53,8,60,17,71,7,65,11,60,6,56,,,} +\ctexspadef{maczhkai}{5,5,6,3,63,14,59,7,63,13,62,12,60,11,61,15,61,12,47,7,56,7,58,8,0,0,12,11,10,68,13,63,18,67,20,69,19,69,17,67,19,70,14,57,15,10,14,62,10,65,10,60,13,63,12,61,7,47,7,56,8,58,4,4,4,5,14,63,7,59,,,} +\ctexspadef{maczhkaib}{5,6,4,4,65,10,54,8,62,14,63,9,65,10,60,14,61,13,50,8,58,10,60,10,0,0,10,10,11,68,13,63,17,68,18,68,18,68,17,68,19,69,11,59,15,12,13,62,9,63,9,66,13,60,13,61,8,50,10,58,10,61,6,5,4,4,9,65,8,55,,,} +\ctexspadef{maczhfs}{71,14,62,8,63,14,59,7,63,13,62,12,60,11,61,15,61,12,47,7,56,7,58,8,0,0,12,11,10,68,13,63,18,67,20,69,19,69,17,67,19,70,7,58,15,10,14,62,10,65,10,60,13,63,12,61,7,47,7,56,8,58,15,68,8,60,14,63,7,59,,,} +\ctexspadef{maczhli}{4,2,7,4,69,2,61,4,65,6,62,6,48,2,46,1,67,5,52,4,61,3,65,3,0,-0,10,7,10,64,11,66,18,67,43,41,18,67,15,67,19,67,11,57,14,13,4,67,6,63,2,47,1,50,5,67,4,52,3,61,3,65,4,2,7,4,6,67,4,61,,,} +\ctexspadef{maczhyou}{5,5,5,9,71,4,58,4,71,4,75,6,75,6,69,5,73,4,57,4,59,4,63,4,0,0,12,12,12,64,13,66,19,70,15,75,19,72,18,71,19,72,5,58,11,11,4,71,6,75,6,75,5,69,4,73,4,57,4,59,4,63,5,5,7,10,4,71,4,58,,,} +\ctexspadef{maczhyoub}{3,3,4,7,69,2,57,2,70,2,74,4,74,6,67,3,71,2,55,2,58,4,63,4,0,0,10,10,9,62,12,62,17,68,13,72,17,68,16,68,18,68,4,56,10,10,2,70,4,74,6,74,3,67,2,71,2,55,4,58,4,63,3,4,5,7,2,69,2,57,,,} +\ctexspadef{maczhpf}{12,8,12,8,65,3,62,3,67,3,70,8,72,4,67,4,65,8,51,6,63,3,66,5,0,0,11,11,13,63,12,62,12,74,12,76,19,69,18,68,19,69,3,53,8,8,3,67,8,70,4,72,4,67,8,65,6,51,3,63,5,66,8,12,8,12,3,65,3,62,,,} +\ctexspadef{maczhpfb}{12,8,12,8,64,3,61,3,66,3,67,8,70,4,65,4,63,8,47,6,61,3,64,5,0,0,9,9,11,61,11,61,11,71,11,73,17,67,17,66,17,67,2,52,7,7,3,66,8,67,4,70,4,65,8,63,6,47,3,61,5,64,8,12,8,12,3,64,3,61,,,} +\ctexspadef{ubuntuzhsong}{77,8,57,8,66,4,60,4,71,4,65,6,71,4,58,3,53,4,52,4,61,4,62,4,4,4,11,11,4,71,4,68,8,77,9,78,17,70,15,70,19,69,6,55,9,9,4,71,6,65,4,71,3,58,4,53,4,52,4,61,4,62,8,77,8,57,4,66,4,60,,,} +\ctexspadef{ubuntuzhsongb}{75,8,53,8,65,3,62,3,72,3,64,6,72,3,57,3,53,3,53,3,62,3,63,3,4,4,11,11,3,69,4,68,5,77,6,77,18,65,18,65,17,67,4,54,7,7,3,72,6,64,3,72,3,57,3,53,3,53,3,62,3,63,8,75,8,53,3,65,3,62,,,} +\ctexspadef{ubuntuzhhei}{81,5,62,4,65,3,60,3,71,4,70,5,71,3,70,4,59,5,53,4,62,3,67,3,5,5,10,10,5,66,4,65,14,67,16,68,18,67,15,66,19,69,3,54,8,8,4,71,5,70,3,71,4,70,5,59,4,53,3,62,3,67,5,81,4,62,3,65,3,60,,,} +\ctexspadef{ubuntuzhheib}{80,4,60,2,64,3,60,3,69,2,66,4,71,3,68,3,56,5,52,3,63,3,66,3,5,5,9,9,4,64,3,64,16,61,18,62,16,66,13,64,16,66,3,53,5,5,2,69,4,66,3,71,3,68,5,56,3,52,3,63,3,66,4,80,2,60,3,64,3,60,,,} +\ctexspadef{ubuntuzhkai}{53,33,53,19,58,8,59,9,61,11,60,10,62,12,60,10,56,6,54,4,58,8,58,8,7,7,15,15,26,53,29,53,19,67,22,68,30,60,27,59,26,63,7,57,25,23,11,61,10,60,12,62,10,60,6,56,3,54,8,58,8,58,32,54,19,53,8,58,9,59,,,} \ctexspadef{windowszhsong}{67,13,46,13,62,14,61,14,65,17,57,14,55,14,53,18,64,11,54,10,47,11,49,14,3,3,10,10,11,64,14,64,11,71,13,73,12,73,12,73,23,63,14,52,15,13,16,66,14,57,14,55,19,52,11,66,9,54,11,48,14,51,14,68,13,48,14,62,14,61,,,} \ctexspadef{windowszhhei}{78,9,56,9,50,20,50,20,50,23,61,11,54,14,50,26,50,16,50,7,47,11,49,14,0,0,9,11,14,64,13,63,14,72,14,73,19,68,18,68,25,64,15,48,12,12,22,50,11,60,14,55,25,50,16,50,7,50,11,48,14,51,8,79,8,56,18,50,18,50,,,} \ctexspadef{windowszhkai}{67,13,46,13,50,20,50,20,50,23,61,11,54,14,50,26,50,16,50,7,47,11,49,14,0,0,10,10,11,64,13,63,11,71,13,73,17,68,17,68,23,63,15,48,12,12,22,50,11,60,14,55,25,50,16,50,7,50,11,48,14,51,14,68,13,48,18,50,18,50,,,} diff --git a/language/chinese/ctex/ctxdoc.cls b/language/chinese/ctex/ctxdoc.cls new file mode 100644 index 0000000000..4cd102e496 --- /dev/null +++ b/language/chinese/ctex/ctxdoc.cls @@ -0,0 +1,867 @@ +%% +%% File ctxdoc.cls +%% +%% Copyright (C) 2016--2020 +%% CTEX.ORG and any individual authors listed in the documentation. +%%--------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3c of this license or (at your option) any later +%% version. This version of this license is in +%% http://www.latex-project.org/lppl/lppl-1-3c.txt +%% and the latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%%--------------------------------------------------------------------- +%% +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\GetIdInfo$Id: ctxdoc.cls 25394ad 2020-04-20 20:56:32 +0800 Qing Lee $ + {ctex documentation (CTEX)} +\ProvidesExplClass{ctxdoc}{\ExplFileDate}{}{\ExplFileDescription} +\ExplSyntaxOff +\DeclareOption*{\PassOptionsToClass{\CurrentOption}{l3doc}} +\PassOptionsToClass{a4paper,full}{l3doc} +\ProcessOptions +\LoadClass{l3doc} +\RequirePackage[UTF8, punct=kaiming, heading, linespread=1.2, sub3section]{ctex} +\ctexset{ + abstractname = 简介, + indexname = 代码索引, + section/format = \Large\bfseries\raggedright, + section/name = {第,节}, +} +\RequirePackage[toc]{multitoc} +\RequirePackage{geometry} +\RequirePackage{tabularx} +\RequirePackage{makecell} +\RequirePackage{threeparttable} +\RequirePackage{siunitx} +\RequirePackage{unicode-math} +\RequirePackage{xcolor} +\RequirePackage{caption} +\RequirePackage{fancyvrb-ex} +\RequirePackage{zref-base} +\geometry{includemp, hmargin={0mm,15mm}, vmargin={25mm,15mm}, footskip=7mm} +\hypersetup{pdfstartview=FitH, bookmarksdepth=subparagraph} +\setcounter{secnumdepth}{4} +\setcounter{tocdepth}{2} +\newcommand*\email{\nolinkurl} +\setmainfont{texgyrepagella}[ + Extension = .otf, + UprightFont = *-regular, + BoldFont = *-bold, + ItalicFont = *-italic, + BoldItalicFont = *-bolditalic] +\setsansfont{texgyreheros}[ + Extension = .otf, + UprightFont = *-regular, + BoldFont = *-bold, + ItalicFont = *-italic, + BoldItalicFont = *-bolditalic] +\setmonofont{cmun}[ + Extension = .otf, + UprightFont = *btl, + BoldFont = *tb, + ItalicFont = *bto, + BoldItalicFont = *tx, + HyphenChar = None] +\setmathfont{texgyrepagella-math.otf} +\captionsetup{strut=off, labelsep=quad, labelfont+=bf} +%% <--- http://tex.stackexchange.com/a/40896 +\patchcmd{\@addtocurcol}% + {\vskip \intextsep}% + {\edef\save@first@penalty{\the\lastpenalty}\unpenalty + \ifnum \lastpenalty = \@M % hopefully the OR penalty + \unpenalty + \else + \penalty \save@first@penalty \relax % put it back + \fi + \ifnum\outputpenalty <-\@Mii + \addvspace\intextsep + \vskip\parskip + \else + \addvspace\intextsep + \fi}% + {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}} +\patchcmd{\@addtocurcol}% + {\vskip\intextsep \ifnum\outputpenalty <-\@Mii \vskip -\parskip\fi}% + {\ifnum\outputpenalty <-\@Mii + \aftergroup\vskip\aftergroup\intextsep + \aftergroup\nointerlineskip + \else + \vskip\intextsep + \fi}% + {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}} +\patchcmd{\@getpen}{\@M}{\@Mi} + {\typeout{*** SUCCESS ***}}{\typeout{*** FAIL ***}} +%% ---> +%% 不对代码实现的 \section 以下标题编目录。 +\AtBeginEnvironment{implementation}{% + \ifnum\value{tocdepth}>\@ne + \addtocontents{toc}{\protect\value{tocdepth}=1\relax}% + \fi} +\ifxetex + \let\ctexdocverbaddon\xeCJKVerbAddon + \def\ctexdisableecglue{\xeCJKsetup{CJKecglue}} + \def\ctexplainps{\xeCJKsetup{PunctStyle=plain}} + \appto\meta@font@select{\ifinner\ctexdisableecglue\fi} +\else + \let\ctexdocverbaddon\relax + \let\ctexplainps\relax + \def\ctexdisableecglue{\ltjsetparameter{autoxspacing=false}} + \appto\meta@font@select{\ctexdisableecglue} +\fi +\setlist{noitemsep,topsep=\smallskipamount} +\setlist[1]{labelindent=\parindent} +\setlist[enumerate]{leftmargin=*} +\setlist[itemize]{leftmargin=*} +\newlist{optdesc}{description}{3} +%% 设置间距为 \marginparsep,与 l3doc 一致 +\setlist[optdesc]{% + font=\mdseries\small\ttfamily,align=right,listparindent=\parindent, + labelsep=\marginparsep,labelindent=-\marginparsep,leftmargin=0pt} +%% 重新定义 threeparttable 包的 tablenotes 环境 +\renewlist{tablenotes}{description}{1} +\setlist[tablenotes]{% + format=\normalfont\tnote@item,align=right,listparindent=\parindent, + labelindent=\tabcolsep,leftmargin=*,rightmargin=\tabcolsep, + after=\@noparlisttrue} +\AtBeginEnvironment{tablenotes}{% + \setlength\parindent{2\ccwd}% + \normalfont\footnotesize} +\AtBeginEnvironment{threeparttable}{% + \stepcounter{tpt@id}% + \edef\curr@tpt@id{tpt@\arabic{tpt@id}}} +\newcounter{tpt@id} +\def\tnote@item#1{% + \Hy@raisedlink{\hyper@anchor{\curr@tpt@id-#1}}#1} +\def\TPTtagStyle#1{\hyperlink{\curr@tpt@id-#1}{#1}} +\fvset{ + fontsize=\small,baselinestretch=1,numbersep=5pt, + formatcom=\ctexdocverbaddon, + listparameters=\setlength\topsep{\MacrocodeTopsep}} +\DefineVerbatimEnvironment{frameverb}{Verbatim}{% + gobble=4, + frame=single,framesep=8pt, + listparameters= + \setlength\topsep{\medskipamount}% + \appto\FV@EndList{\nointerlineskip}} +\DefineVerbatimEnvironment{ctexexam}{Verbatim}{% + gobble=4, + frame=single,framesep=10pt, + label=\rule{0pt}{12pt}\textnormal{\bfseries 例 \arabic{ctexexam}}, + listparameters= + \setlength\topsep{\bigskipamount}% + \refstepcounter{ctexexam}\ctexexamlabelref + \appto\FV@EndList{\nointerlineskip}} +\define@key{FV}{labelref}{\def\ctexexamlabelref{\label{#1}}} +\let\ctexexamlabelref\empty +\newcounter{ctexexam} +\BeforeBeginEnvironment{function}{\par\nointerlineskip} +\AtEndEnvironment{function}{% + \par\xdef\ctexfixprevdepth{\prevdepth=\the\prevdepth\space}} +\AfterEndEnvironment{function}{\ctexfixprevdepth} +\AtBeginEnvironment{syntax}{\linespread{1}\ctexplainps\ctexdisableecglue} +\BeforeBeginEnvironment{SideBySideExample}{\par\addvspace{\medskipamount}} +\newcommand*\exptarget{\Hy@raisedlink{\hypertarget{expstar}{}}} +\newcommand*\rexptarget{\Hy@raisedlink{\hypertarget{rexpstar}{}}} +\newcommand*\expstar{\hyperlink{expstar}{$\star$}} +\newcommand*\rexpstar{\hyperlink{rexpstar}{\ding{73}}} +\ExplSyntaxOn +%% l3doc 会设置列表环境中 \listparindent=\z@,我们在这里恢复它。 +\cs_set_eq:NN \list \__codedoc_oldlist:nn +\cs_new_nopar:Npn \zihaopt #1 + { + \exp_last_unbraced:Nf \tl_head:w + { \prop_item:Nn \c__ctex_font_size_prop {#1} } { } \q_stop + } +%% 抑制首段的 \parskip +\ctex_patch_cmd_once:NnnnTF \__codedoc_function_descr_start:w + { } + { \noindent } + { \skip_vertical:n { -\parskip } \noindent } + { \iow_term:n { *** ~ SUCCESS ~ *** } } + { \iow_term:n { *** ~ FAIL ~ *** } } +%% l3doc 会在 function 环境的 syntax 和 descr 盒子中间加上 \medskipamount 的距离。 +%% 但是若 syntax 盒子为空(未使用 syntax 环境),就会显得不好看。 +%% 此时我们通过将 \medskipamount 设置为零来修正。若盒子非空,则将 \parskip 还回去。 +\ctex_preto_cmd:NnnTF \__codedoc_function_assemble: + { } + { \ctex_doc_fix_yoffset: } + { \iow_term:n { *** ~ SUCCESS ~ *** } } + { \iow_term:n { *** ~ FAIL ~ *** } } +\cs_new_protected_nopar:Npn \ctex_doc_fix_yoffset: + { + \box_if_empty:NTF \g__codedoc_syntax_box + { \skip_zero:N \medskipamount } + { \skip_add:Nn \medskipamount { \parskip } } + } +%% 左侧边注的函数列表采用单倍行距 +\ctex_preto_cmd:NnnTF \__codedoc_typeset_functions: + { } + { \MacroFont } + { \iow_term:n { *** ~ SUCCESS ~ *** } } + { \iow_term:n { *** ~ FAIL ~ *** } } +\ctex_patch_cmd_once:NnnnTF \__codedoc_macro_init: + { } + { \hbox:n } + { \MacroFont \hbox:n } + { \iow_term:n { *** ~ SUCCESS ~ *** } } + { \iow_term:n { *** ~ FAIL ~ *** } } +\ctex_patch_cmd_once:NnnnTF \__codedoc_macro_dump: + { } + { \hbox_unpack_drop:N } + { \MacroFont \hbox_unpack_drop:N } + { \iow_term:n { *** ~ SUCCESS ~ *** } } + { \iow_term:n { *** ~ FAIL ~ *** } } +\cs_set_eq:NN \__codedoc_macro_end_style:n \use_none:n +\cs_set_protected:Npn \__codedoc_macro_typeset_one:nN #1#2 + { + \vbox_set:Nn \l__codedoc_macro_box + { + \MacroFont + \vbox_unpack_drop:N \l__codedoc_macro_box + \hbox_set:Nn \l_tmpa_box + { \__codedoc_print_macroname:nN {#1} #2 } + \dim_set:Nn \l_tmpa_dim { \marginparwidth - \labelsep } + \dim_compare:nNnT { \box_wd:N \l_tmpa_box } > \l_tmpa_dim + { + \box_resize_to_wd_and_ht:Nnn \l_tmpa_box + { \l_tmpa_dim } + { \box_ht:N \l_tmpa_box } + } + \hbox_overlap_left:n + { + \box_use:N \l_tmpa_box + \skip_horizontal:n { \marginparsep - \labelsep } + } + } + \int_incr:N \l__codedoc_macro_int + } +\cs_set_protected:Npn \__codedoc_print_macroname:nN #1#2 + { + \strut + \__codedoc_get_hyper_target:xN + { + \exp_not:n {#1} + \bool_if:NT #2 { \tl_to_str:n {TF} } + } + \l__codedoc_tmpa_tl + \cs_if_exist:cTF { r@ \l__codedoc_tmpa_tl } + { \exp_args:NNo \label@hyperref [ \l__codedoc_tmpa_tl ] } + { \use:n } + { + \tl_set:Nn \l__codedoc_tmpa_tl {#1} + \tl_replace_all:Non \l__codedoc_tmpa_tl + { \c_catcode_other_space_tl } + { \fontspec_visible_space: } + \__codedoc_macroname_prefix:o \l__codedoc_tmpa_tl + \__codedoc_macroname_suffix:N #2 + } + } +\AtBeginEnvironment { syntax } + { + \char_set_catcode_active:N \| + \char_set_active_eq:NN \| \orbar + \char_set_catcode_active:N \( + \char_set_active_eq:NN \( \defaultvalaux + } +%% 不对目录中出现的 \cs 和 \tn 等编索引 +\DeclareDocumentCommand \StopSpecialIndexModule { } + { \cs_set_eq:NN \__codedoc_special_index_module:nnnnN \use_none:nnnnn } +\tl_map_inline:nn { \actualchar \encapchar \levelchar } + { \exp_args:Nx \DoNotIndex { \bslash \tl_to_str:N #1 } } +\DeclareDocumentCommand \package { o m } + { + \exp_args:Nx \href + { + http \c_colon_str //www.ctan.org/pkg/ + \IfNoValueTF {#1} { \str_lowercase:n {#2} } {#1} + } + { \pkg {#2} } + } +\DeclareDocumentCommand \GetFileId { m } + { + \GetFileInfo {#1} + \file_get:nnNTF { \c_sys_jobname_str .id } + { \int_set:Nn \tex_endlinechar:D { -1 } } \l__ctxdoc_tmp_tl + { \exp_after:wN \GetIdInfo \l__ctxdoc_tmp_tl } + { \GetIdInfo $Id$ } + { \fileinfo } + } +\cs_new_eq:NN \__ctxdoc_ltx_changes:nnn \changes@ +\cs_set_protected:Npn \changes@ #1#2 + { + \__ctxdoc_save_version_date:nn {#1} {#2} + \tl_if_empty:nTF {#1} + { \__ctxdoc_ltx_changes:nnn } + { \__ctxdoc_version_zfill:wnnn #1 \q_stop } + {#1} {#2} + } +\cs_new_protected:Npn \__ctxdoc_version_zfill:wnnn #1#2 \q_stop + { + \str_if_eq:nnTF {#1} { v } + { \__ctxdoc_version_zfill:nnnn {#2} } + { \__ctxdoc_ltx_changes:nnn } + } +\cs_new_protected:Npn \__ctxdoc_version_zfill:nnnn #1#2 + { + \tl_clear:N \l__ctxdoc_tmp_tl + \int_zero:N \l_tmpa_int + \seq_set_split:Nnn \l_tmpa_seq { . } {#1} + \seq_map_function:NN \l_tmpa_seq \__ctxdoc_version_zfill:n + \int_compare:nNnF \l_tmpa_int > 2 + { + \tl_put_right:Nx \l__ctxdoc_tmp_tl + { \prg_replicate:nn { 3 - \l_tmpa_int } { 00000 } } + } + \__ctxdoc_ltx_changes:nnn { \l__ctxdoc_tmp_tl \actualchar #2 } + } +\tl_new:N \l__ctxdoc_tmp_tl +\cs_new_protected:Npn \__ctxdoc_version_zfill:n #1 + { + \int_incr:N \l_tmpa_int + \tl_put_right:Nx \l__ctxdoc_tmp_tl + { + \prg_replicate:nn + { \int_max:nn { 0 } { 5 - \tl_count:n {#1} } } { 0 } + \exp_not:n {#1} + } + } +\cs_new_protected:Npn \__ctxdoc_save_version_date:nn #1#2 + { + \prop_get:NnNTF \g__ctxdoc_version_date_prop {#1} \l__ctxdoc_tmp_tl + { \exp_after:wN \__ctxdoc_save_version_date:nnnn \l__ctxdoc_tmp_tl {#2} {#1} } + { \__ctxdoc_save_version_date:nnn {#1} {#2} {#2} } + } +\cs_new_protected:Npn \__ctxdoc_save_version_date:nnnn #1#2#3#4 + { + \__ctxdoc_if_date_later:nnTF {#1} {#3} + { \__ctxdoc_save_version_date:nnn {#4} {#3} {#2} } + { + \__ctxdoc_if_date_later:nnT {#3} {#2} + { \__ctxdoc_save_version_date:nnn {#4} {#1} {#3} } + } + } +\prg_new_conditional:Npnn \__ctxdoc_if_date_later:nn #1#2 { TF , T } + { + \if_int_compare:w \__ctxdoc_parse_date:w #1 / / / 0 \q_stop > + \__ctxdoc_parse_date:w #2 / / / 0 \q_stop \exp_stop_f: + \prg_return_true: \else: \prg_return_false: \fi: + } +\cs_new:Npn \__ctxdoc_parse_date:w #1/#2/#3/ #4 \q_stop + { #1#2#3 } +\cs_new_protected:Npn \__ctxdoc_save_version_date:nnn #1#2#3 + { \prop_gput:Nnn \g__ctxdoc_version_date_prop {#1} { {#2} {#3} } } +\cs_new_protected:Npn \CTEX@versionitem #1 \efill + { + \@idxitem + \prop_get:NnNTF \g__ctxdoc_version_date_prop {#1} \l__ctxdoc_tmp_tl + { \exp_after:wN \__ctxdoc_version_item:nnn \l__ctxdoc_tmp_tl {#1} } + { \BOOM } + } +\cs_new_protected:Npn \__ctxdoc_version_item:nnn #1#2#3 + { + \noindent + \Hy@raisedlink { \belowpdfbookmark {#3} { HD.#3 } } + \textbf {#3} \hfill + \hbox:n + { + \footnotesize + \str_if_eq:nnTF {#1} {#2} + { ( #1 ) } + { ( #1 ~ -- ~ #2 ) } + } + \par \nopagebreak + } +\prop_new:N \g__ctxdoc_version_date_prop +\ctex_patch_cmd:Nnn \HDorg@theglossary + { \let \item \@idxitem } + { \let \item \CTEX@versionitem } +\ctex_patch_cmd:Nnn \l@section { 2.5em } { 1.5em } +\ctex_patch_cmd:Nnn \l@subsection { 2.5em } { 1.5em } +\ctex_patch_cmd:Nnn \@wrglossary + { hdpindex } + { + \ifnum \c@HD@hypercount = \z@ + hdpindex + \else + hdclindex { \the \c@HD@hypercount } + \fi + } +%% 重定义 macrocode 环境的实现,逐行处理 +\cs_set_protected_nopar:Npn \xmacro@code + { \__ctxdoc_marco_code:w } +\cs_set_protected_nopar:Npn \sxmacro@code + { + \fontspec_print_visible_spaces: + \xmacro@code + } +\cs_new_protected_nopar:Npn \__ctxdoc_marco_code:w + { + \ifcodeline@index + \__ctxdoc_marco_every_par:n { \__ctxdoc_code_line_no: } + \else: + \__ctxdoc_marco_every_par:n { } + \fi: + \exp_args:Nx \__ctxdoc_make_finish_tag:n { \@currenvir } + \__ctxdoc_verbatim_start:w + } +\cs_new_protected:Npn \__ctxdoc_marco_every_par:n #1 + { + \everypar + { + \everypar {#1} + \if@inlabel + \global \@inlabelfalse + \@noparlistfalse + \llap { \box \@labels \hskip \leftskip } + \fi + #1 + } + } +\ctex_patch_cmd:Nnn \macro@code + { \if@inlabel \leavevmode \fi } + { \partopsep \z@skip } +\group_begin: + \int_set:Nn \tex_endlinechar:D { -1 } + \use:n + { + \char_set_catcode_active:n { 32 } + \tl_const:Nn \c__ctxdoc_active_space_tl + } + { } +\group_end: +\group_begin: + \char_set_catcode_active:n { 13 } + \cs_new_protected:Npx \__ctxdoc_make_finish_tag:n #1 + { + \tl_set:Nn \exp_not:N \l__ctxdoc_verbatim_finish_tl + { + \c_percent_str + \prg_replicate:nn { 4 } + { \exp_not:o { \c__ctxdoc_active_space_tl } } + \exp_not:o { \active@escape@char } end + \c_left_brace_str #1 \c_right_brace_str + \exp_not:N ^^M + } + } + \cs_new_protected:Npn \__ctxdoc_verbatim_start:w #1 + { + \str_if_eq:nnTF {#1} { ^^M } + { \__ctxdoc_verbatim_read_line:w } + { \__ctxdoc_verbatim_read_line:w #1 } + } + \cs_new_protected:Npn \__ctxdoc_verbatim_read_line:w #1 ^^M + { + \tl_set:Nn \l__ctxdoc_verbatim_line_tl { #1 ^^M } + \tl_if_eq:NNTF \l__ctxdoc_verbatim_line_tl \l__ctxdoc_verbatim_finish_tl + { \exp_args:Nx \end { \@currenvir } } + { + \__ctxdoc_verbatim_process_line: + \__ctxdoc_verbatim_read_line:w + } + } + \cs_new_protected:Npn \__ctxdoc_swap_cr: + { \exp_after:wN \__ctxdoc_swap_cr:w \l__ctxdoc_verbatim_line_tl } + \cs_new_protected:Npn \__ctxdoc_swap_cr:w #1 ^^M + { + \group_insert_after:N ^^M + \tl_set:Nn \l__ctxdoc_verbatim_line_tl {#1} + } + \tl_const:Nn \c__ctxdoc_active_cr_tl { ^^M } +\group_end: +\tl_new:N \l__ctxdoc_verbatim_line_tl +\tl_new:N \l__ctxdoc_verbatim_finish_tl +\tl_new:N \g__ctxdoc_verbatim_verb_stop_tl +\cs_new_protected_nopar:Npn \__ctxdoc_process_normal_line: + { + \str_if_eq:eeTF + { \str_head:N \l__ctxdoc_verbatim_line_tl } { \c_percent_str } + { \__ctxdoc_check_angle:x { \tl_tail:N \l__ctxdoc_verbatim_line_tl } } + { \__ctxdoc_output_line: } + } +\cs_new_protected_nopar:Npn \__ctxdoc_process_verb_line: + { + \tl_if_eq:NNTF \l__ctxdoc_verbatim_line_tl \g__ctxdoc_verbatim_verb_stop_tl + { + \tl_gclear:N \g__ctxdoc_verbatim_verb_stop_tl + \cs_gset_eq:NN \__ctxdoc_verbatim_process_line: \__ctxdoc_process_normal_line: + \__ctxdoc_output_module:nn + { \color { verb@guard } } + { + \__ctxdoc_swap_cr: + \__ctxdoc_module_pop:n { \l__ctxdoc_verbatim_line_tl } + } + } + { \tl_use:N \l__ctxdoc_verbatim_line_tl } + } +\cs_new_eq:NN \__ctxdoc_verbatim_process_line: \__ctxdoc_process_normal_line: +\DeclareDocumentCommand \CheckModules { } + { \cs_set_eq:NN \__ctxdoc_verbatim_process_line: \__ctxdoc_process_normal_line: } +\DeclareDocumentCommand \DontCheckModules { } + { \cs_set_eq:NN \__ctxdoc_verbatim_process_line: \__ctxdoc_output_line: } +\cs_new_protected:Npn \__ctxdoc_check_angle:n #1 + { + \str_if_eq:eeTF { \str_head:n {#1} } { < } + { \__ctxdoc_check_module:x { \tl_tail:n {#1} } } + { \__ctxdoc_output_percent_line: } + } +\cs_generate_variant:Nn \__ctxdoc_check_angle:n { x } +\cs_new_protected:Npn \__ctxdoc_check_module:n #1 + { + \exp_args:Nx \str_case:nnF { \str_head:n {#1} } + { + { * } { \__ctxdoc_module_star:w } + { / } { \__ctxdoc_module_slash:w } + { @ } { \__ctxdoc_module_at:w } + { < } { \__ctxdoc_module_verb:w } + } + { \__ctxdoc_module_pm:w } + #1 \q_stop + } +\cs_generate_variant:Nn \__ctxdoc_check_module:n { x } +\group_begin: + \char_set_catcode_active:N \> + \cs_new_protected:Npn \__ctxdoc_module_star:w #1 > #2 \q_stop + { + \__ctxdoc_output_module:nn + { \__ctxdoc_star_color: } + { \__ctxdoc_module_push:n { \__ctxdoc_module_angle:n {#1} } } + \__ctxdoc_output_line:n {#2} + \__ctxdoc_star_format: + } + \cs_new_protected:Npn \__ctxdoc_module_slash:w #1 > #2 \q_stop + { + \__ctxdoc_output_module:nn + { \__ctxdoc_slash_color: } + { \__ctxdoc_module_pop:n { \__ctxdoc_module_angle:n {#1} } } + \__ctxdoc_output_line:n {#2} + \__ctxdoc_slash_format: + } + \cs_new_protected:Npn \__ctxdoc_module_at:w @ @ = #1 > #2 \q_stop + { + \__ctxdoc_output_module:nn + { \color { at@guard } } + { \__ctxdoc_module_angle:n { @ @ = #1 } } + \tl_gset:Nn \g__codedoc_module_name_tl {#1} + \__ctxdoc_output_line:n {#2} + } + \cs_new_protected:Npn \__ctxdoc_module_pm:w #1 > #2 \q_stop + { + \tex_noindent:D + \hbox_overlap_left:n + { + \__ctxdoc_output_module:nn + { \__ctxdoc_pm_color: } + { \__ctxdoc_module_angle:n {#1} } + \skip_horizontal:n { \leftskip + \smallskipamount } + } + \group_begin: + \__ctxdoc_pm_format: + \__ctxdoc_output_line:n {#2} + \group_end: + } + \cs_new_protected:Npn \__ctxdoc_module_verb:w #1 \q_stop + { + \cs_gset_eq:NN \__ctxdoc_verbatim_process_line: \__ctxdoc_process_verb_line: + \tl_gset:Nx \g__ctxdoc_verbatim_verb_stop_tl + { \c_percent_str \tl_tail:n {#1} } + \__ctxdoc_output_module:nn + { \color { verb@guard } } + { + \__ctxdoc_swap_cr: + \__ctxdoc_module_push:n { \l__ctxdoc_verbatim_line_tl } + } + } +\group_end: +\cs_new_protected_nopar:Npn \__ctxdoc_output_line: + { + \tex_noindent:D + \__ctxdoc_replace_at_at:N \l__ctxdoc_verbatim_line_tl + \tl_use:N \l__ctxdoc_verbatim_line_tl + } +\cs_new_protected:Npn \__ctxdoc_replace_at_at:N #1 + { + \tl_if_empty:NF \g__codedoc_module_name_tl + { + \exp_args:NNo \__ctxdoc_replace_at_at_aux:Nn + #1 \g__codedoc_module_name_tl + } + } +\cs_new_protected:Npx \__ctxdoc_replace_at_at_aux:Nn #1#2 + { + \tl_replace_all:Nnn #1 { \token_to_str:N @ } { @ } + \tl_replace_all:Nnn #1 { \token_to_str:N _ } { _ } + \tl_replace_all:Nnn #1 { @ @ @ @ } { \token_to_str:N a a } + \tl_replace_all:Nnn #1 { _ _ @ @ } { _ _ #2 } + \tl_replace_all:Nnn #1 { _ @ @ } { _ _ #2 } + \tl_replace_all:Nnn #1 { @ @ } { _ _ #2 } + \tl_replace_all:Nnn #1 { \token_to_str:N a a } { @ @ } + } +\cs_new_protected:Npn \__ctxdoc_output_line:n #1 + { + \tl_set:Nn \l__ctxdoc_verbatim_line_tl {#1} + \tl_if_eq:NNTF \l__ctxdoc_verbatim_line_tl \c__ctxdoc_active_cr_tl + { \tl_use:N \l__ctxdoc_verbatim_line_tl } + { + \str_if_eq:eeTF + { \str_head:N \l__ctxdoc_verbatim_line_tl } + { \c_percent_str } + { \__ctxdoc_output_percent_line: } + { \__ctxdoc_output_line: } + } + } +\cs_new_protected:Npn \__ctxdoc_output_percent_line: + { + \tex_noindent:D + \group_begin: + \color { code@gray } + \__ctxdoc_swap_cr: + \str_if_eq:eeTF { \f@shape } { \updefault } + { \slshape } + { \upshape } + \__ctxdoc_output_line: + \group_end: + } +\cs_new_protected_nopar:Npn \__ctxdoc_module_push:n + { \exp_args:No \__ctxdoc_module_push_aux:nn { \int_use:N \c@HD@hypercount } } +\cs_new_protected:Npn \__ctxdoc_module_push_aux:nn #1 + { + \seq_gpush:Nn \g__ctxdoc_module_dest_seq {#1} + \hypersetup { hidelinks } + \exp_args:Nx \hdclindex + { \zref@extractdefault { HD.#1 } { guard@end } { 1 } } { } + } +\cs_new_protected_nopar:Npn \__ctxdoc_module_pop:n + { + \seq_gpop:NNTF \g__ctxdoc_module_dest_seq \l__ctxdoc_tmp_tl + { \exp_args:No \__ctxdoc_module_pop_aux:nn { \l__ctxdoc_tmp_tl } } + { \BOOM \use:n } + } +\cs_new_protected:Npn \__ctxdoc_module_pop_aux:nn #1 + { + \zref@labelbylist { HD.#1 } { ctxdoc } + \hypersetup { hidelinks } + \hdclindex {#1} { } + } +\seq_new:N \g__ctxdoc_module_dest_seq +\zref@newlist { ctxdoc } +\zref@newprop { guard@end } [ 1 ] + { \int_eval:n { \c@HD@hypercount - 1 } } +\zref@addprop { ctxdoc } { guard@end } +\cs_new_protected_nopar:Npn \__ctxdoc_star_format: + { + \seq_gpush:No \g__ctxdoc_slash_format_seq { \macro@font } + \seq_gpop:NNF \g__ctxdoc_star_format_seq \l__ctxdoc_format_tl + { \__ctxdoc_pop_format: } + \__ctxdoc_select_format: + } +\cs_new_protected_nopar:Npn \__ctxdoc_slash_format: + { + \seq_gpop:NNTF \g__ctxdoc_slash_format_seq \l__ctxdoc_format_tl + { + \seq_gpush:No \g__ctxdoc_star_format_seq { \macro@font } + \__ctxdoc_select_format: + } + { \BOOM } + } +\cs_new_protected_nopar:Npn \__ctxdoc_pm_format: + { + \seq_get:NNF \g__ctxdoc_star_format_seq \l__ctxdoc_format_tl + { + \__ctxdoc_pop_format: + \seq_gpush:No \g__ctxdoc_star_format_seq { \l__ctxdoc_format_tl } + } + \cs_if_eq:NNF \macro@font \l__ctxdoc_format_tl + { \l__ctxdoc_format_tl } + } +\cs_new_protected_nopar:Npn \__ctxdoc_pop_format: + { + \seq_gpop_left:NN \g__ctxdoc_format_seq \l__ctxdoc_format_tl + \seq_gput_right:No \g__ctxdoc_format_seq { \l__ctxdoc_format_tl } + } +\cs_new_protected_nopar:Npn \__ctxdoc_select_format: + { + \cs_if_eq:NNF \macro@font \l__ctxdoc_format_tl + { + \cs_gset_eq:NN \macro@font \l__ctxdoc_format_tl + \macro@font + } + } +\tl_new:N \l__ctxdoc_format_tl +\seq_new:N \g__ctxdoc_format_seq +\seq_new:N \g__ctxdoc_star_format_seq +\seq_new:N \g__ctxdoc_slash_format_seq +\seq_gput_right:Nn \g__ctxdoc_format_seq { \MacroFont } +\seq_gput_right:Nn \g__ctxdoc_format_seq { \AltMacroFont } +\cs_set_protected:Npn \MacroFont + { + \linespread { 1 } + \small + \fontseries { \mddefault } + \fontshape { \updefault } + \ttfamily + \ctexdocverbaddon + } +\cs_set_protected:Npn \AltMacroFont + { + \linespread { 1 } + \small + \fontseries { \mddefault } + \fontshape { \sldefault } + \ttfamily + \ctexdocverbaddon + } +\AtBeginDocument + { + \tl_gset:Nx \macro@font + { \seq_item:Nn \g__ctxdoc_format_seq { 1 } } + } +\cs_new_protected:Npn \__ctxdoc_output_module:nn #1#2 + { + \tex_noindent:D + \group_begin: + #1 + \footnotesize \normalfont \sffamily #2 + \group_end: + } +\cs_new_protected_nopar:Npn \__ctxdoc_star_color: + { + \seq_gpop:NNTF \g__ctxdoc_star_color_seq \current@color + { \set@color } + { \__ctxdoc_select_color: } + \seq_gpush:No \g__ctxdoc_slash_color_seq { \current@color } + } +\cs_new_protected_nopar:Npn \__ctxdoc_slash_color: + { + \seq_gpop:NNTF \g__ctxdoc_slash_color_seq \current@color + { + \set@color + \seq_gpush:No \g__ctxdoc_star_color_seq { \current@color } + } + { \BOOM } + } +\cs_new_protected_nopar:Npn \__ctxdoc_pm_color: + { + \seq_get:NNTF \g__ctxdoc_star_color_seq \current@color + { \set@color } + { + \__ctxdoc_select_color: + \seq_gpush:No \g__ctxdoc_star_color_seq { \current@color } + } + } +\seq_new:N \g__ctxdoc_star_color_seq +\seq_new:N \g__ctxdoc_slash_color_seq +\cs_new_protected_nopar:Npn \__ctxdoc_select_color: + { \color { guard@series!!+ } } +\definecolorseries { guard@series } + { cmyk } { last } { blue } { purple } +\resetcolorseries [ 3 ] { guard@series } +\definecolor { verb@guard } { rgb } { 0.5 , 0.5 , 0 } +\definecolor { at@guard } { rgb } { 0.5 , 0 , 0.5 } +\definecolor { code@gray } { gray } { 0.5 } +\cs_new_protected:Npn \__ctxdoc_module_angle:n #1 + { \textlangle #1 \textrangle } +\cs_new_protected_nopar:Npn \__ctxdoc_code_line_no: + { + \int_gincr:N \c@CodelineNo + \hbox_overlap_left:n + { + \hbox_to_wd:nn + { \MacroIndent } + { + \HD@target + \tex_hss:D + \__ctxdoc_code_line_no_style: + \theCodelineNo \enspace + } + \tex_kern:D \@totalleftmargin + } + } +\tl_set:Nn \theCodelineNo + { \arabic { CodelineNo } } +\cs_new_protected_nopar:Npn \__ctxdoc_code_line_no_style: + { \color { code@gray } \normalfont \sffamily \tiny } +\cs_set_protected:Npn \HD@SetMacroIndent #1 + { + \group_begin: + \settowidth \MacroIndent + { + \__ctxdoc_code_line_no_style: + \prg_replicate:nn { \tl_count:n {#1} } { 0 } + \enspace + } + \dim_gset_eq:NN \MacroIndent \MacroIndent + \group_end: + } +\ExplSyntaxOff +\AtBeginDocument{\addtocontents{toc}{\StopSpecialIndexModule}} +\pdfstringdefDisableCommands{% + \let\path\meta + \let\opt\@firstofone} +\preto\@thehead{\cslet{MakeUppercase\space}{\@iden}} +\def\orbar{\textup{\textbar}} +\def\defaultval#1{\textbf{\textup{#1}}} +\def\defaultvalaux#1){\defaultval{#1}} +\def\TF{true\orbar false} +\def\TTF{\defaultval{true}\orbar false} +\def\TFF{true\orbar\defaultval{false}} +\protected\def\opt{\texttt} +\def\pdfTeX{\hologo{pdfTeX}} +\def\XeTeX{\hologo{XeTeX}} +\def\XeLaTeX{\hologo{XeLaTeX}} +\def\LuaLaTeX{\hologo{LuaLaTeX}} +\def\pdfLaTeX{\hologo{pdfLaTeX}} +\def\LaTeX{\hologo{LaTeX}} +\def\LaTeXe{\hologo{LaTeX2e}} +\def\LaTeXiii{\hologo{LaTeX3}} +\def\dvipdfmx{DVIPDFM\textit{x}} +\def\TeX{\hologo{TeX}} +\def\ApTeX{Ap\TeX} +\def\ApLaTeX{Ap\LaTeX} +\def\upTeX{up\TeX} +\def\upLaTeX{up\LaTeX} +\def\bashcmd{\texttt} +\def\TeXLive{\TeX\ Live} +\def\MiKTeX{\hologo{MiKTeX}} +\def\BSTACK{\begin{tabular}[t]{@{}l@{}}} +\def\ESTACK{\end{tabular}} +\newenvironment{defaultcapconfig}{% + \MakePercentComment + \input{ctex-name-utf8.cfg}% + \ExplSyntaxOff + \MakePercentIgnore}{} +\def\ctexkit{\href{https://github.com/CTeX-org/ctex-kit/}{\texttt{ctex-kit}}} +\def\ctexkitrev#1{% + \href{https://github.com/CTeX-org/ctex-kit/commit/#1}{\texttt{ctex-kit} rev. #1}} +\appto\GlossaryParms{% + \raggedcolumns + \let\Hy@writebookmark\HDorg@writebookmark + \def\@idxitem{\par\hangindent 2em }% + \def\subitem{\@idxitem\hspace*{1em}}% + \def\subsubitem{\@idxitem\hspace*{2em}}} +\def\glossaryname{版本历史} +\GlossaryPrologue{\section{\glossaryname}} +\IndexPrologue{% + \section{\indexname} + \textit{意大利体的数字表示描述对应索引项的页码; + 带下划线的数字表示定义对应索引项的代码行号; + 罗马字体的数字表示使用对应索引项的代码行号。}} +\def\IndexLayout{% + \newgeometry{hmargin=15mm,vmargin={25mm,15mm},footskip=7mm}% + \setlength\IndexMin{.5\textheight}% + \ctexset{section/numbering=false}% + \StopSpecialIndexModule} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +%% +%% +%% End of file ctxdoc.cls. diff --git a/language/chinese/ctex/ctxdocstrip.tex b/language/chinese/ctex/ctxdocstrip.tex new file mode 100644 index 0000000000..425496c0e5 --- /dev/null +++ b/language/chinese/ctex/ctxdocstrip.tex @@ -0,0 +1,110 @@ +%% +%% File ctxdocstrip.tex +%% +%% Copyright (C) 2016--2020 +%% CTEX.ORG and any individual authors listed in the documentation. +%%--------------------------------------------------------------------- +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3c of this license or (at your option) any later +%% version. This version of this license is in +%% http://www.latex-project.org/lppl/lppl-1-3c.txt +%% and the latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%%--------------------------------------------------------------------- +%% +\csname ctxDocstripLoaded\endcsname +\let\ctxDocstripLoaded\endinput +\input l3docstrip % +\edef\ctxResetCatcode{% + \catcode\number`\$=\the\catcode`\$\relax + \catcode\number`\@=\the\catcode`\@\relax +} +\makeOther\$ +\catcode`\@=11\relax +\def\plusOption+#1>#2$#3$\endLine{% + \maybeMsg{<+#1 . >}% + \Evaluate{#1}% + \def\ctxCMD{#2}% + \def\ctxID{$#3$}% + \def\do##1##2##3{% + \if1\Expr{##2}% + \ctxReadIDFile + \StreamPut##1{\inLine}% + \fi + }% + \activefiles +} +\def\ctxReadIDFile{% + \openin\inputcheck=\jobname.id\relax + \ifeof\inputcheck\else + \read \inputcheck to \inLine + \closein\inputcheck + \ifx\inLine\empty\else + \let\ctxID\inLine + \fi + \fi + \maybeMsg{^^J\ctxID^^J}% + \def\inLine{\ctxCMD\ctxID}% +} +\keepsilent +\askforoverwritefalse +\declarepreamble\emptypreamble +\endpreamble +\declarepostamble\emptypostamble +\endpostamble +\begingroup\expandafter\expandafter\expandafter\endgroup +\expandafter\ifx\csname directlua\endcsname\relax + \expandafter\ctxResetCatcode\expandafter\endinput +\fi +\let\OriginalStreamClose\StreamClose +\def\ctxStreamClose#1{% + \OriginalStreamClose{#1}% + \ctxConvFile{#1}% +} +\def\ctxConvFile#1{% + \ifcsname zhconv@\csstring#1\endcsname + \ctxConv{\lastnamedcs}% + {\begincsname pth@\csstring#1\endcsname}% + \fi +} +\def\ctxLuaFunc{% + \directlua{ + local zhconv = require("zhconv").conv + local scan_string = token.scan_string + local t = lua.get_functions_table() + local id = 233 + while t[id] do id = id + 1 end + t[id] = function () + local enc = scan_string() + local file = scan_string() + return zhconv(enc, file, file) + end + token.set_lua("ctxConv", id, "global", "protected") + }% + \global\let\ctxLuaFunc\relax +} +\def\convfile{% + \ifx\@file\file + \expandafter\ctxfile\else + \expandafter\setconvfile\fi +} +\def\setconvfile#1#2{% + \ctxLuaFunc + \Name\def{zhconv@#2}{#1}% + \let\StreamClose\ctxStreamClose +} +\def\ctxfile#1#2{% + \setconvfile{#1}{#2}% + \file{#2}% +} +\ctxResetCatcode +%% +%% +%% End of file ctxdocstrip.tex diff --git a/language/chinese/ctex/zhconv-make.lua b/language/chinese/ctex/zhconv-make.lua new file mode 100644 index 0000000000..fe6f00feaa --- /dev/null +++ b/language/chinese/ctex/zhconv-make.lua @@ -0,0 +1,114 @@ +#!/usr/bin/env texlua +-- +-- File zhconv-make.lua +-- +-- Copyright (C) 2020 by Qing Lee +-------------------------------------------------------------------------- +-- +-- This work may be distributed and/or modified under the +-- conditions of the LaTeX Project Public License, either +-- version 1.3c of this license or (at your option) any later +-- version. This version of this license is in +-- http://www.latex-project.org/lppl/lppl-1-3c.txt +-- and the latest version of this license is in +-- http://www.latex-project.org/lppl.txt +-- and version 1.3 or later is part of all distributions of +-- LaTeX version 2005/12/01 or later. +-- +-- This work has the LPPL maintenance status "maintained". +-- +-- The Current Maintainer of this work is Qing Lee. +-- +-- This work consists of the files zhconv.lua, zhconv-make.lua +-- and the derived files zhconv-index.lua, zhconv-index.luc. +-- +-------------------------------------------------------------------------- +-- + +local preamble = [[ +-- +-- File zhconv-index.lua +-- +-- Copyright (C) 2020 by Qing Lee +-------------------------------------------------------------------------- +-- +-- This work may be distributed and/or modified under the +-- conditions of the LaTeX Project Public License, either +-- version 1.3c of this license or (at your option) any later +-- version. This version of this license is in +-- http://www.latex-project.org/lppl/lppl-1-3c.txt +-- and the latest version of this license is in +-- http://www.latex-project.org/lppl.txt +-- and version 1.3 or later is part of all distributions of +-- LaTeX version 2005/12/01 or later. +-- +-- This work has the LPPL maintenance status "maintained". +-- +-- The Current Maintainer of this work is Qing Lee. +-- +-- This work consists of the files zhconv.lua, zhconv-make.lua +-- and the derived files zhconv-index.lua, zhconv-index.luc. +-- +-------------------------------------------------------------------------- +-- +-- Do not edit this file! +-- Generated from the WHATWG Encoding Standard: +-- +-- https://encoding.spec.whatwg.org/index-big5.txt (Date: %s) +-- https://encoding.spec.whatwg.org/index-gb18030.txt (Date: %s) +-- https://encoding.spec.whatwg.org/index-gb18030-ranges.txt (Date: %s) +-- +-- +]] + +local rep, format, dump = string.rep, string.format, string.dump +local insert, unpack, concat = table.insert, table.unpack, table.concat +local io_open, os_execute = io.open, os.execute + +local curlcmd = "curl --silent --output %s https://encoding.spec.whatwg.org/%s" +local function prepare_index (file) + local file_path = file + local handle = io_open(file, "rb") + if handle then return handle end + local ret = os_execute(curlcmd:format(file, file)) + assert(ret == 0, "the curl command failed with: ".. ret) + return assert(io_open(file, "rb")) +end + +local index, date = { }, { } + +local indent = 2 +local begin_enc = "%s[%q] = {" +local end_enc = "%s} ," +local num_item = "%s[%s] = %s ," +local tab_item = "%s{ %6d , %s } ," +local tab = rep(" ", indent) +local tabtab = tab .. tab + +insert(index, "return {") +for i, v in ipairs { { "index-big5.txt", "big5" }, + { "index-gb18030.txt", "gb18030" }, + { "index-gb18030-ranges.txt", "gb18030_ranges" } } do + local file, encode = unpack(v) + local handle = prepare_index(file) + insert(index, begin_enc:format(tab, encode)) + for line in handle:lines() do + if not date[i] then + local s = line:match("Date: (.+)$") + if s then date[i] = s end + end + local pointer, code_point = line:match("^%s*(%d+)\t(0x%x+)") + if pointer and code_point then + insert(index, format(i == 3 and tab_item or num_item, tabtab, pointer, code_point)) + end + end + insert(index, end_enc:format(tab)) + handle:close() +end +insert(index, "}\n") + +local index = concat(index, "\n") + +local handle = io_open("zhconv-index.lua", "wb") +handle:write(preamble:format(unpack(date)), index) +handle:close() diff --git a/language/chinese/ctex/zhconv.lua b/language/chinese/ctex/zhconv.lua new file mode 100644 index 0000000000..8af2161e26 --- /dev/null +++ b/language/chinese/ctex/zhconv.lua @@ -0,0 +1,205 @@ +-- +-- File zhconv.lua +-- +-- Copyright (C) 2020 by Qing Lee +-------------------------------------------------------------------------- +-- +-- This work may be distributed and/or modified under the +-- conditions of the LaTeX Project Public License, either +-- version 1.3c of this license or (at your option) any later +-- version. This version of this license is in +-- http://www.latex-project.org/lppl/lppl-1-3c.txt +-- and the latest version of this license is in +-- http://www.latex-project.org/lppl.txt +-- and version 1.3 or later is part of all distributions of +-- LaTeX version 2005/12/01 or later. +-- +-- This work has the LPPL maintenance status "maintained". +-- +-- The Current Maintainer of this work is Qing Lee. +-- +-- This work consists of the files zhconv.lua, zhconv-make.lua +-- and the derived files zhconv-index.lua. +-- +-------------------------------------------------------------------------- +-- + +if status.kpse_used ~= 1 then + kpse.set_program_name("luatex") +end + +zhconv = zhconv or { } +local zhconv = zhconv +zhconv.module = { + name = "zhconv", + version = "0.1", + date = "2020/05/01", + description = "GBK/GB18030/Big5 encoder", + author = "Qing Lee", + copyright = "Qing Lee", + license = "LPPL v1.3c" +} + +local utf = require("unicode").utf8 +local ubyte, ugsub = utf.byte, utf.gsub + +local floor = math.floor +local unpack, insert, sort = table.unpack, table.insert, table.sort +local char, format = string.char, string.format + +zhconv.index = require("zhconv-index") +local index = zhconv.index + +zhconv.mapping = { } +local mapping = zhconv.mapping + +mapping.big5, mapping.gbk, mapping.gb18030 = { }, { }, { } +local gbk, gb18030, big5 = mapping.gbk, mapping.gb18030, mapping.big5 + +zhconv.bytes = { } +local bytes = zhconv.bytes + +-- Let lead be pointer / 190 + 0x81. +-- Let trail be pointer % 190. +-- Let offset be 0x40 if trail is less than 0x3F and 0x41 otherwise. +-- Return two bytes whose values are lead and trail + offset. +function bytes.gbk (pointer) + local lead = floor(pointer / 190) + 0x81 + local trail = pointer % 190 + local offset = trail < 0x3F and 0x40 or 0x41 + return format("%c%c", lead, trail + offset) +end + +-- Let lead be pointer / 157 + 0x81. +-- If lead is less than 0xA1, return error with code point. +-- Let trail be pointer % 157. +-- Let offset be 0x40 if trail is less than 0x3F and 0x62 otherwise. +-- Return two bytes whose values are lead and trail + offset. +function bytes.big5 (pointer) + local lead = floor(pointer / 157) + 0x81 + local trail = pointer % 157 + local offset = trail < 0x3F and 0x40 or 0x62 + return format("%c%c", lead, trail + offset) +end + +-- Let byte1 be pointer / 10 / 126 / 10. +-- Set pointer to pointer - byte1 × 10 × 126 × 10. +-- Let byte2 be pointer / 10 / 126. +-- Set pointer to pointer - byte2 × 10 × 126. +-- Let byte3 be pointer / 10. +-- Let byte4 be pointer - byte3 × 10. +-- Return four bytes whose values are byte1 + 0x81, byte2 + 0x30, byte3 + 0x81, byte4 + 0x30. +function bytes.gb18030 (pointer) + local pointer = pointer + local byte1 = floor(pointer / 12600) + 0x81 + pointer = pointer % 12600 + local byte2 = floor(pointer / 1260) + 0x30 + pointer = pointer % 1260 + local byte3 = floor(pointer / 10) + 0x81 + local byte4 = pointer % 10 + 0x30 + return format("%c%c%c%c", byte1, byte2, byte3, byte4) +end + +-- Let offset be the last code point in index gb18030 ranges that is equal to or +-- less than code point and let pointer offset be its corresponding pointer. +-- Return a pointer whose value is pointer offset + code point - offset. +do + local metatable = { } + local bytes, ranges = bytes.gb18030, index["gb18030_ranges"] + function metatable.__index (t, key) + if type(key) == "number" then + local n = #ranges + if key < 0x10000 then + local s = gbk[key] + if s then return s end + repeat + n = n - 1 + until ranges[n][2] <= key + end + local pointer, offset = unpack(ranges[n]) + return bytes(pointer + key - offset) + end + end + gb18030 = setmetatable(gb18030, metatable) +end + +-- The index Big5 pointer for code point is the return value of these steps: +-- 1. Let index be index Big5 excluding all entries whose pointer +-- is less than (0xA1 - 0x81) × 157. +-- 2. If code point is U+2550, U+255E, U+2561, U+256A, U+5341, or U+5345, +-- return the last pointer corresponding to code point in index. +local big5_last = { + [0x2550] = true , + [0x255E] = true , + [0x2561] = true , + [0x256A] = true , + [0x5341] = true , + [0x5345] = true , +} + +do + +local function spairs (t) + local a = { } + for i, n in pairs(t) do insert(a, {i, n}) end + sort(a, function(b, c) return b[1] < c[1] end) + local i = 0 + local iter = function () + i = i + 1 + if a[i] then + return a[i][1], a[i][2] + end + end + return iter +end + +local chars = bytes.big5 +local m = (0xA1 - 0x81) * 157 +for i, v in spairs(index.big5) do + if i >= m then + if big5[v] then + if big5_last[v] then big5[v] = chars(i) end + else + big5[v] = chars(i) + end + end +end + +local chars = bytes.gbk +for i, v in pairs(index.gb18030) do + gbk[v] = chars(i) +end + +end + +-- If the gbk flag is set and code point is U+20AC, return byte 0x80. +gb18030[0x20AC] = gbk[0x20AC] +gbk[0x20AC] = char(0x80) + +local io_open = io.open +local encode_error = "Encoding %q not available!" +local file_error = "Open file %q failed!" + +function zhconv.conv (encoding, input, output) + local encoding = encoding:lower() + local mapping = assert(mapping[encoding], encode_error:format(encoding)) + local encoder = function (s) + local code_point = ubyte(s) + return code_point > 0x7F and mapping[code_point] + end + if output then + local handle = assert(io_open(input, "rb"), file_error:format(input)) + local stream = handle:read("*all") + handle:close() + handle = assert(io_open(output, "wb"), file_error:format(output)) + stream = stream:gsub("^\xEF\xBB\xBF", "") + stream = ugsub(stream, ".", encoder) + handle:write(stream) + handle:close() + else + local s = ugsub(input, ".", encoder) + return s + end +end + +return zhconv diff --git a/language/japanese/jlreq/Makefile b/language/japanese/jlreq/Makefile index 139d68925f..2d7b528547 100644 --- a/language/japanese/jlreq/Makefile +++ b/language/japanese/jlreq/Makefile @@ -143,7 +143,7 @@ sty-install: install: jfm-install cls-install sty-install -tds: jfm jlreq.cls README.md README-ja.md LICENSE jlreq.html jlreq-ja.html jlreq-trimmarks.html jlreq-trimmarks-ja.html jlreq.pdf jlreq-ja.pdf jlreq-trimmarks.pdf jlreq-trimmarks-ja.pdf +tds: jfm jlreq.cls README.md README-ja.md LICENSE jlreq.html jlreq-ja.html jlreq-trimmarks.html jlreq-trimmarks-ja.html jlreq.pdf jlreq-ja.pdf mkdir -p ./tds/fonts/tfm/public/jlreq cp -f *.tfm ./tds/fonts/tfm/public/jlreq mkdir -p ./tds/fonts/vf/public/jlreq diff --git a/language/japanese/jlreq/README-ja.md b/language/japanese/jlreq/README-ja.md index a57b5d4f4b..544f1ce7cf 100644 --- a/language/japanese/jlreq/README-ja.md +++ b/language/japanese/jlreq/README-ja.md @@ -178,9 +178,13 @@ pLaTeX / upLaTeX / LuaLaTeX上で動きます.以下のパッケージを内 ### 定理環境 `\jlreqsetup`で指定します. * `theorem_beforeafter_space=<寸法>`:定理環境の前後の空きを指定します. +* `theorem_label_font=<フォント設定コード>`:定理環境のラベル部分のフォントを設定します. +* `theorem_font=<フォント設定コード>`:定理環境本体のフォントを設定します. + +`amsthm`パッケージが読み込まれると,新しい定理スタイル`jlreq`が定義され,現在のスタイルが`jlreq`へと変更されます.このとき,上記設定はこの`jlreq`スタイルへの設定として機能します. ### 前付きなど -`\fontmatter` / `\mainmatter` / `\backmatter` / `\appendix`での処理を`\jlreqsetup`で指定できます. +`\frontmatter` / `\mainmatter` / `\backmatter` / `\appendix`での処理を`\jlreqsetup`で指定できます. * `frontmatter_pagebreak=[cleardoublepage/clearpage/]`:`\frontmatter`実行時の改ページを実行する命令名を指定します.空にすると何もしません. * `frontmatter_counter={<カウンタ名>={value=<値>, the=<コード>, restore=[true/false]},...}`:`\frontmatter`時でのカウンタの操作を指定します.例えば`chapter={value=0,the={[\arabic{chapter]}}`とすると,`chapter`カウンタの値が`0`になり,`\thechapter`が`[\arabic{chapter}]`となります.デフォルトでは`\mainmatter`時に値と`\the<カウンタ名>`の定義を戻しますが,`restore=false`とするとこの動きが抑制されます. * `frontmatter_heading={<見出し命令名>={<設定>},...}`:見出し命令の動きを変更します.`\Delare***Heading`で指定できる項目の他以下を受け付けます. @@ -472,6 +476,9 @@ JFMの名前は次の通りです.`[]`で囲まれている文字は設定に - `\rmfamily`などの再定義をやめ,`\@rmfamilyhook`などにコードを挿入することにした. - `\parskip`を`0pt`に変更. - バグ修正. +* 2020-05-01 + - `\jlreqsetup`に`theorem_label_font`と`theorem_font`を追加. + - バグ修正. -------------- Noriyuki Abe diff --git a/language/japanese/jlreq/README.md b/language/japanese/jlreq/README.md index fb5175fb94..c0ef2c541f 100644 --- a/language/japanese/jlreq/README.md +++ b/language/japanese/jlreq/README.md @@ -124,6 +124,9 @@ This package is distributed under the BSD 2-Clause License. See [LICENSE](LICENS - Removed the redefinitions `\rmfamily` etc and added a code to `\@rmfamilyhook`. - Changed `\parskip` to `0pt`. - Fixed bugs. +* 2020-05-01 + - Added `theorem_label_font` and `theorem_font` to `\jlreqsetup`. + - Fixed bugs. -------------- Noriyuki Abe diff --git a/language/japanese/jlreq/jlreq-helpers.sty b/language/japanese/jlreq/jlreq-helpers.sty index 3594c7d1f8..46a619a84c 100644 --- a/language/japanese/jlreq/jlreq-helpers.sty +++ b/language/japanese/jlreq/jlreq-helpers.sty @@ -73,11 +73,21 @@ \expandafter\expandafter\expandafter\jlreq@ifmacro@noargument@\jlreq@getfirsttoken#1\jlreq@uniqtoken{}\jlreq@endmark@ }}} \long\def\jlreq@ifmacro@noargument@#1{\expandafter\jlreq@ifmacro@noargument@@\expandafter{\meaning #1}} -\edef\jlreq@do{% - \unexpanded{\def\jlreq@ifmacro@noargument@@}##1{\noexpand\jlreq@ifmacro@noargument@@@##1\expandonce{\detokenize{macro:->}}\noexpand\jlreq@endmark} - \unexpanded{\def\jlreq@ifmacro@noargument@@@}##1\expandonce{\detokenize{macro:->}}##2\noexpand\jlreq@endmark{\noexpand\jlreq@ifempty{##1}} +\def\@tempa#1{% + \def\jlreq@ifmacro@noargument@@##1{\jlreq@ifmacro@noargument@@@##1#1\noexpand\jlreq@endmark} + \def\jlreq@ifmacro@noargument@@@##1#1##2\jlreq@endmark{\jlreq@ifempty{##1}} } +\edef\jlreq@do{\noexpand\@tempa{\detokenize{macro:->}}} \jlreq@do +% こちらは単にマクロか +\def\@tempa#1{% + \long\def\jlreq@ifmacro##1{\jlreq@ifempty{##1}{\@secondoftwo}{\expandafter\jlreq@ifmacro@i\meaning##1#1\jlreq@endmark}} + \long\def\jlreq@ifmacro@i##1#1##2\jlreq@endmark{\jlreq@ifempty{##1}} +} +\edef\jlreq@do{\noexpand\@tempa{\detokenize{macro:}}} +\jlreq@do + + % #1(skipレジスタ)が0か(展開不可). \newcommand*\jlreq@ifgluezero[1]{% diff --git a/language/japanese/jlreq/jlreq-ja.pdf b/language/japanese/jlreq/jlreq-ja.pdf index 76cb0ff374..3a0fb1c3f7 100644 Binary files a/language/japanese/jlreq/jlreq-ja.pdf and b/language/japanese/jlreq/jlreq-ja.pdf differ diff --git a/language/japanese/jlreq/jlreq-trimmarks-ja.md b/language/japanese/jlreq/jlreq-trimmarks-ja.md index 7531072932..e75a31512d 100644 --- a/language/japanese/jlreq/jlreq-trimmarks-ja.md +++ b/language/japanese/jlreq/jlreq-trimmarks-ja.md @@ -157,7 +157,10 @@ dviドライバの指定です.エンジンに`lualatex`を利用する場合 * 2019-04-01 - `\jlreqtrimmarkssetup`内の`banner`を更に拡張. - `bleed_margin`を拡張. - +* 2020-05-01 + - `\jlreqtrimmarkssetup`の`banner`を使わない場合,`\@bannertoken`の中身を偶奇ページ両方に出力するようにした. + - `\jlreqtrimmarkssetup`の`banner`を使う場合,`\@bannertoken`の中身を無視するようにした. + - `\jlreqtrimmarkssetup`の`banner_font`が指定された場合,`\@bannerfont`を無視するようにした. -------------- Noriyuki Abe diff --git a/language/japanese/jlreq/jlreq-trimmarks.md b/language/japanese/jlreq/jlreq-trimmarks.md index 3d66dd56ef..a8fb96bf48 100644 --- a/language/japanese/jlreq/jlreq-trimmarks.md +++ b/language/japanese/jlreq/jlreq-trimmarks.md @@ -46,7 +46,7 @@ Set the size of the paper including trim marks. * If `` is empty (e.g. `trimmarks_paper=+2cm`), the current paper size (which is specified usually by the option for the document class) is used. ### `landscape` -Swap the width and the height. This swaps only the width and height which is specified with the option `trimmarks_paper`. For example, `landscape,trimmarks_paper=+{2cm,1cm}`, adds 1cm to the height and 2cm to the width. But the current paper size is not swapped. +Swap the width and the height. This swaps only the width and height which is specified with the option `trimmarks_paper`. For example, `landscape,trimmarks_paper=+{1cm,2cm}`, adds 1cm to the height and 2cm to the width. But the current paper size is not swapped. ### `show` Specify the types of trim marks which the package outputs. It is specified with the comma separated list like `show={trimmarks,banner,digital}`. If no argument is given, everything will be showed. @@ -151,7 +151,10 @@ This package is distributed under the BSD 2-Clause License. See [LICENSE](LICENS * 2019-04-01 - Extended `banner` in `\jlreqtrimmarkssetup`. - Extended `bleed_margin`. - +- 2020-05-01 + - `jlreq-trimmarks` outputs the contents in `\@bannertoken` when `banner` in `\jlreqtrimmarkssetup` is not used. + - `\@bannertoken` is ignored when `banner` in `\jlreqtrimmarkssetup` is used. + - `\@bannerfont` is ignored when `banner_font` in `\jlreqtrimmarkssetup` is used. -------------- Noriyuki Abe diff --git a/language/japanese/jlreq/jlreq-trimmarks.sty b/language/japanese/jlreq/jlreq-trimmarks.sty index 6ba910a240..03c31e521a 100644 --- a/language/japanese/jlreq/jlreq-trimmarks.sty +++ b/language/japanese/jlreq/jlreq-trimmarks.sty @@ -1,5 +1,5 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{jlreq-trimmarks}[2019/04/01 jlreq-trimmarks] +\ProvidesPackage{jlreq-trimmarks}[2020/05/01 jlreq-trimmarks] \RequirePackage{xkeyval,etoolbox} \RequirePackage{jlreq-helpers} @@ -33,16 +33,10 @@ \@ifclassloaded{jlreq}{\let\ifjlreq@trimmarks@jlreqloaded=\@firstoftwo}{\let\ifjlreq@trimmarks@jlreqloaded=\@secondoftwo} -\def\ifjlreq@trimmarks@tate@{% - \if@tate\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi -} +\def\ifjlreq@trimmarks@tate@{\jlreq@if{\if@tate\fi}}% % \@firstoftwo when \if@tate is defined and \if@tate=\iftrue \def\ifjlreq@trimmarks@tate{% - \ifnum0\ifx\if@tate\@undefined 1\fi\ifx\if@tate\relax 1\fi>0 - \expandafter\@secondoftwo - \else - \expandafter\ifjlreq@trimmarks@tate@ - \fi + \jlreq@if{\ifnum0\ifx\if@tate\@undefined 1\fi\ifx\if@tate\relax 1\fi>0 \fi}{\@secondoftwo}{\ifjlreq@trimmarks@tate@}% } @@ -256,9 +250,9 @@ }% }% }{#3}% - \ifx\jlreq@do\@empty + \jlreq@if{\ifx\jlreq@do\@empty\fi}{% \appto\jlreq@do{\jlreq@trimmarks@setbanner@@{yoko@#1}{yoko@#2}{#3}}% - \fi + }{}% \expandafter\endgroup \jlreq@do } @@ -277,9 +271,9 @@ }% }% }{#3}% - \ifx\jlreq@do\@empty + \jlreq@if{\ifx\jlreq@do\@empty\fi}{ \appto\jlreq@do{\jlreq@trimmarks@setbanner@@{before@#1}{before@#2}{#3}}% - \fi + }{}% \expandafter\endgroup \jlreq@do } @@ -296,12 +290,12 @@ }% }% }{#3}% - \ifx\jlreq@do\@empty + \jlreq@if{\ifx\jlreq@do\@empty\fi}{ \appto\jlreq@do{% \expandafter\edef\csname jlreq@trimmarks@banner@odd@#1\endcsname{\unexpanded{#3}}% \expandafter\edef\csname jlreq@trimmarks@banner@even@#2\endcsname{\unexpanded{#3}}% }% - \fi + }{}% \expandafter\endgroup \jlreq@do } @@ -326,11 +320,9 @@ }% }% }% - \@bannertoken{}% \def\jlreq@do{}% \jlreq@parsekeyval@nokey{% \ifjlreq@parsekeyval@nokey@novalue{}{% - \jlreq@tempafalse \edef\jlreq@gutterodd{\ifjlreq@trimmarks@tate{right}{left}}% \if@twoside \edef\jlreq@guttereven{\ifjlreq@trimmarks@tate{left}{right}}% @@ -338,8 +330,8 @@ \let\jlreq@guttereven\jlreq@gutterodd \fi \jlreq@switch*{####1}{ - {top-left}{\jlreq@tempatrue\appto\jlreq@do{\jlreq@trimmarks@setbanner{top@left}{top@left}{####2}}} - {left-top}{\jlreq@tempatrue\appto\jlreq@do{\jlreq@trimmarks@setbanner{top@left}{top@left}{####2}}} + {top-left}{\appto\jlreq@do{\jlreq@trimmarks@setbanner{top@left}{top@left}{####2}}} + {left-top}{\appto\jlreq@do{\jlreq@trimmarks@setbanner{top@left}{top@left}{####2}}} {top-right}{\appto\jlreq@do{\jlreq@trimmarks@setbanner{top@right}{top@right}{####2}}} {right-top}{\appto\jlreq@do{\jlreq@trimmarks@setbanner{top@right}{top@right}{####2}}} {top-gutter}{\appto\jlreq@do{\jlreq@trimmarks@setbanner{top@\jlreq@gutterodd}{top@\jlreq@guttereven}{####2}}} @@ -367,17 +359,12 @@ {center-fore-edge}{\appto\jlreq@do{\jlreq@trimmarks@setbanner@{center@\jlreq@guttereven}{center@\jlreq@gutterodd}{####2}}} {fore-edge-center}{\appto\jlreq@do{\jlreq@trimmarks@setbanner@{center@\jlreq@guttereven}{center@\jlreq@gutterodd}{####2}}} }% - \ifjlreq@tempa - \appto\jlreq@do{\expandafter\@bannertoken\expandafter{\jlreq@trimmarks@banner@odd@yoko@top@left}}% - \fi }% }{##1}% - \ifx\jlreq@do\@empty - \jlreq@trimmarks@setbanner{top@left}{##1}% - \expandafter\@bannertoken\expandafter{\jlreq@trimmarks@banner@odd@yoko@top@left}% - \else - \jlreq@do - \fi + \jlreq@if{\ifx\jlreq@do\@empty\fi}{ + \appto\jlreq@do{\jlreq@trimmarks@setbanner{top@left}{top@left}{##1}}% + }{}% + \jlreq@do } {banner_font}{\def\jlreq@trimmarks@bannerfont{##1}} {trimmarks_width}{\setlength{\@tombowwidth}{##1}} @@ -418,12 +405,13 @@ }{#1}% } \@onlypreamble\jlreqtrimmarkssetup +\@bannertoken{% + \jobname\space(\number\year-\two@digits\month-\two@digits\day + \space\two@digits\hour:\two@digits\minute)% +} \jlreqtrimmarkssetup{ - banner={% - \jobname\space(\number\year-\two@digits\month-\two@digits\day - \space\two@digits\hour:\two@digits\minute)% - }, - banner_font={}, + banner={\the\@bannertoken}, + banner_font={\@bannerfont}, color={} } @@ -461,14 +449,14 @@ }{ \def\@tombowreset@@paper{% \@@topmargin\topmargin - \iftombow + \jlreq@if{\iftombow\fi}{ \@@paperwidth\paperwidth \advance\@@paperwidth 2\dimexpr\@tombowbleed\relax \@@paperheight\paperheight \advance\@@paperheight 10mm\relax \advance\@@paperheight 2\dimexpr\@tombowbleed\relax % 1in -> 1truein \advance\@@topmargin 1truein\relax \advance\@themargin 1truein\relax - \fi + }{}% } } \fi @@ -484,21 +472,21 @@ \setlength{\stockheight}{\dimexpr\jlreq@trimmarks@paperheight\relax} \def\jlreq@trimmarks@outputbanner#1#2{% - \iftombowdate + \jlreq@if{\iftombowdate\fi}{% \expandafter\let\expandafter\jlreq@tempa\csname jlreq@trimmarks@banner@\ifodd\c@page odd\else even\fi @#1\endcsname - \ifx\jlreq@tempa\@empty\else + \jlreq@if{\ifx\jlreq@tempa\@empty\fi}{}{% \def\@tempa##1{#2}% \expandafter\@tempa\expandafter{\jlreq@tempa}% - \fi - \fi + }% + }{}% } \def\jlreq@trimmarks@bleed{3mm} % left=gutter? \def\ifjlreq@trimmarks@leftisgutter{% \ifjlreq@trimmarks@tate{% - \ifnum 0\ifodd\c@page 1\fi\if@twoside\else 1\fi>0 \expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi + \jlreq@if{\ifnum 0\ifodd\c@page 1\fi\if@twoside\else 1\fi>0 \fi}{\@secondoftwo}{\@firstoftwo}% }{% - \ifnum 0\ifodd\c@page 1\fi\if@twoside\else 1\fi>0 \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + \jlreq@if{\ifnum 0\ifodd\c@page 1\fi\if@twoside\else 1\fi>0 \fi}{\@firstoftwo}{\@secondoftwo}% }% } \def\jlreq@trimmarks@bleed@left{\ifjlreq@trimmarks@leftisgutter{\jlreq@trimmarks@bleed@gutter}{\expandafter\csname jlreq@trimmarks@bleed@fore-edge\endcsname}} @@ -516,15 +504,13 @@ \yoko\hss \vrule width\dimexpr 10mm + \jlreq@trimmarks@bleed@left\relax height\@tombowwidth depth\z@ \vrule height10mm width\@tombowwidth depth\z@ - \iftombowdate - \setbox\jlreq@tempboxa=\hbox to\z@{\hskip5mm\@bannerfont\jlreq@trimmarks@bannerfont - \ifodd\c@page\the\@bannertoken\else\jlreq@trimmarks@banner@even@yoko@top@left\fi - \hss}% + \jlreq@trimmarks@outputbanner{yoko@top@left}{% + \setbox\jlreq@tempboxa=\hbox to\z@{\hskip5mm\jlreq@trimmarks@bannerfont##1\hss}% \dp\jlreq@tempboxa=0pt \raise 4pt\box\jlreq@tempboxa - \fi + }% \jlreq@trimmarks@outputbanner{inyoko@top@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\jlreq@trimmarks@bannerfont##1\hss}% \jlreq@tempdima=\dimexpr\ht\jlreq@tempboxa + \jlreq@trimmarks@bleed@top\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise-\jlreq@tempdima\box\jlreq@tempboxa @@ -537,12 +523,12 @@ \yoko \vrule width10mm height\@tombowwidth depth\z@ \jlreq@trimmarks@outputbanner{before@top@center}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\hss\@bannerfont\jlreq@trimmarks@bannerfont##1\hskip 5mm}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\hss\jlreq@trimmarks@bannerfont##1\hskip 5mm}% \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \wd\jlreq@tempboxa=0pt \raise 4pt\box\jlreq@tempboxa }% \jlreq@trimmarks@outputbanner{in@top@center}{% - \setbox\jlreq@tempboxa=\hbox{\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox{\jlreq@trimmarks@bannerfont##1}% \jlreq@tempdima=\dimexpr\ht\jlreq@tempboxa + \jlreq@trimmarks@bleed@top\relax \jlreq@tempdimb=0.5\wd\jlreq@tempboxa \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \wd\jlreq@tempboxa=0pt @@ -550,7 +536,7 @@ }% \vrule height10mm width\@tombowwidth depth\z@ \jlreq@trimmarks@outputbanner{after@top@center}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\hskip 5mm\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\hskip 5mm\jlreq@trimmarks@bannerfont##1\hss}% \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \wd\jlreq@tempboxa=0pt \raise 4pt\box\jlreq@tempboxa }% @@ -562,19 +548,19 @@ \setbox\jlreq@tempboxa=\hbox to\z@{% \@TR \yoko \jlreq@trimmarks@outputbanner{yoko@top@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hss\@bannerfont\jlreq@trimmarks@bannerfont##1\hskip 5mm}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hss\jlreq@trimmarks@bannerfont##1\hskip 5mm}% \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise 4pt\box\jlreq@tempboxa }% \jlreq@trimmarks@outputbanner{inyoko@top@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hss\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hss\jlreq@trimmarks@bannerfont##1}% \jlreq@tempdima=\dimexpr\jlreq@trimmarks@bleed@top + \ht\jlreq@tempboxa\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise-\jlreq@tempdima\box\jlreq@tempboxa }% \vrule height10mm width\@tombowwidth depth\z@ \jlreq@trimmarks@outputbanner{corner@top@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\hskip\dimexpr\jlreq@trimmarks@bleed@right + 4pt\relax\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\hskip\dimexpr\jlreq@trimmarks@bleed@right + 4pt\relax\jlreq@trimmarks@bannerfont##1\hss}% \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise 4pt\box\jlreq@tempboxa }% @@ -590,13 +576,13 @@ \yoko\hss \vrule width10mm height\@tombowwidth depth\z@ \jlreq@trimmarks@outputbanner{corner@top@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\hss\@bannerfont\jlreq@trimmarks@bannerfont##1\hskip 4pt}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\hss\jlreq@trimmarks@bannerfont##1\hskip 4pt}% \dp\jlreq@tempboxa=0pt \ht\jlreq@tempboxa=0pt \raise\dimexpr \jlreq@trimmarks@bleed@top + 4pt\relax\box\jlreq@tempboxa }% \vrule height\dimexpr 10mm + \jlreq@trimmarks@bleed@top\relax width\@tombowwidth depth\z@ \jlreq@trimmarks@outputbanner{tate@top@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\jlreq@trimmarks@bannerfont##1\hss}% \ifx l\jlreq@trimmarks@engine \jlreq@tempdima=\dimexpr 4pt + \ht\jlreq@tempboxa\relax \else @@ -606,7 +592,7 @@ \kern-\jlreq@tempdima\raise-5mm\box\jlreq@tempboxa\kern\jlreq@tempdima }% \jlreq@trimmarks@outputbanner{intate@top@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\jlreq@trimmarks@bannerfont##1\hss}% \jlreq@tempdima=\dimexpr\jlreq@trimmarks@bleed@left \ifx l\jlreq@trimmarks@engine + \ht\jlreq@tempboxa\fi\relax \wd\jlreq@tempboxa=0pt \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \kern\jlreq@tempdima\box\jlreq@tempboxa\kern-\jlreq@tempdima @@ -616,13 +602,13 @@ \hbox to\z@{% \@Tr \yoko \jlreq@trimmarks@outputbanner{tate@top@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\jlreq@trimmarks@bannerfont##1\hss}% \jlreq@tempdima=\dimexpr 4pt \ifx l\jlreq@trimmarks@engine + \dp\jlreq@tempboxa\fi\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \wd\jlreq@tempboxa=0pt \kern\jlreq@tempdima\raise -5mm\box\jlreq@tempboxa\kern-\jlreq@tempdima }% \jlreq@trimmarks@outputbanner{intate@top@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\jlreq@trimmarks@bannerfont##1\hss}% \ifx l\jlreq@trimmarks@engine \jlreq@tempdima=\dimexpr\jlreq@trimmarks@bleed@top + \ht\jlreq@tempboxa\relax \else @@ -642,7 +628,7 @@ \yoko\hss \vrule width10mm height.5\@tombowwidth depth.5\@tombowwidth \jlreq@trimmarks@outputbanner{before@center@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\hss\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1\hskip 5mm}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\hss\adjustbaseline\jlreq@trimmarks@bannerfont##1\hskip 5mm}% \ifx l\jlreq@trimmarks@engine \jlreq@tempdima=\dimexpr 4pt + \ht\jlreq@tempboxa\relax \else @@ -652,7 +638,7 @@ \kern-\jlreq@tempdima\box\jlreq@tempboxa\kern\jlreq@tempdima }% \jlreq@trimmarks@outputbanner{after@center@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\hskip 5mm\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\hskip 5mm\adjustbaseline\jlreq@trimmarks@bannerfont##1\hss}% \ifx l\jlreq@trimmarks@engine \jlreq@tempdima=\dimexpr 4pt + \ht\jlreq@tempboxa\relax \else @@ -663,7 +649,7 @@ }% \vrule height10mm depth10mm width\@tombowwidth \jlreq@trimmarks@outputbanner{in@center@left}{% - \setbox\jlreq@tempboxa=\hbox{\tate\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox{\tate\adjustbaseline\jlreq@trimmarks@bannerfont##1}% \ifx l\jlreq@trimmarks@engine \jlreq@tempdima=\dimexpr\jlreq@trimmarks@bleed@left + \ht\jlreq@tempboxa\relax \jlreq@tempdimb=.5\wd\jlreq@tempboxa @@ -679,7 +665,7 @@ \hbox to\z@{% \@CR \yoko \jlreq@trimmarks@outputbanner{in@center@right}{% - \setbox\jlreq@tempboxa=\hbox{\tate\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox{\tate\adjustbaseline\jlreq@trimmarks@bannerfont##1}% \ifx l\jlreq@trimmarks@engine \jlreq@tempdima=\dimexpr\jlreq@trimmarks@bleed@right + \ht\jlreq@tempboxa\relax \jlreq@tempdimb=0.5\wd\jlreq@tempboxa @@ -692,13 +678,13 @@ }% \vrule height10mm depth10mm width\@tombowwidth \jlreq@trimmarks@outputbanner{before@center@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\hss\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1\hskip 5mm}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\hss\adjustbaseline\jlreq@trimmarks@bannerfont##1\hskip 5mm}% \jlreq@tempdima=\dimexpr 4pt \ifx l\jlreq@trimmarks@engine + \dp\jlreq@tempboxa\fi\relax \dp\jlreq@tempboxa=0pt \ht\jlreq@tempboxa=0pt \wd\jlreq@tempboxa=0pt \kern\jlreq@tempdima\box\jlreq@tempboxa\kern-\jlreq@tempdima }% \jlreq@trimmarks@outputbanner{after@center@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\hskip 5mm\adjustbaseline\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\hskip 5mm\adjustbaseline\jlreq@trimmarks@bannerfont##1\hss}% \jlreq@tempdima=\dimexpr 4pt \ifx l\jlreq@trimmarks@engine + \dp\jlreq@tempboxa\fi\relax \dp\jlreq@tempboxa=0pt \ht\jlreq@tempboxa=0pt \wd\jlreq@tempboxa=0pt \kern\jlreq@tempdima\box\jlreq@tempboxa\kern-\jlreq@tempdima @@ -713,7 +699,7 @@ \vrule width10mm depth\@tombowwidth height\z@ \vrule depth\dimexpr 10mm + \jlreq@trimmarks@bleed@bottom\relax width\@tombowwidth height\z@ \jlreq@trimmarks@outputbanner{tate@bottom@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\hss\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\hss\jlreq@trimmarks@bannerfont##1}% \ifx l\jlreq@trimmarks@engine \jlreq@tempdima=\dimexpr 4pt + \ht\jlreq@tempboxa\relax \else @@ -723,7 +709,7 @@ \kern-\jlreq@tempdima\raise 5mm\box\jlreq@tempboxa\kern\jlreq@tempdima }% \jlreq@trimmarks@outputbanner{intate@bottom@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\hss\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\hss\jlreq@trimmarks@bannerfont##1}% \jlreq@tempdima=\dimexpr\jlreq@trimmarks@bleed@left \ifx l\jlreq@trimmarks@engine + \ht\jlreq@tempboxa\fi\relax \wd\jlreq@tempboxa=0pt \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \kern\jlreq@tempdima\box\jlreq@tempboxa\kern-\jlreq@tempdima @@ -733,13 +719,13 @@ \hbox to\z@{% \@Br \yoko \jlreq@trimmarks@outputbanner{tate@bottom@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\hss\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\hss\jlreq@trimmarks@bannerfont##1}% \jlreq@tempdima=\dimexpr\ifx l\jlreq@trimmarks@engine\ht\jlreq@tempboxa + \fi 4pt\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \wd\jlreq@tempboxa=0pt \kern\jlreq@tempdima\raise5mm\box\jlreq@tempboxa\kern-\jlreq@tempdima }% \jlreq@trimmarks@outputbanner{intate@bottom@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\hss\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\tate\adjustbaseline\hss\jlreq@trimmarks@bannerfont##1}% \ifx l\jlreq@trimmarks@engine \jlreq@tempdima=\dimexpr\jlreq@trimmarks@bleed@right + \ht\jlreq@tempboxa\relax \else @@ -750,7 +736,7 @@ }% \vrule depth\dimexpr 10mm + \jlreq@trimmarks@bleed@bottom\relax width\@tombowwidth height\z@ \jlreq@trimmarks@outputbanner{corner@bottom@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\hskip 4pt\relax\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\hskip 4pt\relax\jlreq@trimmarks@bannerfont##1\hss}% \jlreq@tempdima=\dimexpr\ht\jlreq@tempboxa + \jlreq@trimmarks@bleed@bottom + 4pt\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise-\jlreq@tempdima\box\jlreq@tempboxa @@ -765,20 +751,20 @@ \yoko\hss \vrule width\dimexpr 10mm + \jlreq@trimmarks@bleed@left\relax depth\@tombowwidth height\z@ \jlreq@trimmarks@outputbanner{corner@bottom@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\hss\@bannerfont\jlreq@trimmarks@bannerfont##1\hskip\dimexpr\jlreq@trimmarks@bleed@left + 4pt\relax}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\hss\jlreq@trimmarks@bannerfont##1\hskip\dimexpr\jlreq@trimmarks@bleed@left + 4pt\relax}% \jlreq@tempdima=\dimexpr\ht\jlreq@tempboxa + 4pt\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise-\jlreq@tempdima\box\jlreq@tempboxa }% \vrule depth10mm width\@tombowwidth height\z@ \jlreq@trimmarks@outputbanner{yoko@bottom@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hskip 5mm\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hskip 5mm\jlreq@trimmarks@bannerfont##1\hss}% \jlreq@tempdima=\dimexpr\ht\jlreq@tempboxa + 4pt\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise-\jlreq@tempdima\box\jlreq@tempboxa }% \jlreq@trimmarks@outputbanner{inyoko@bottom@left}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\jlreq@trimmarks@bannerfont##1\hss}% \jlreq@tempdima=\dimexpr\jlreq@trimmarks@bleed@bottom + \dp\jlreq@tempboxa\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise\jlreq@tempdima\box\jlreq@tempboxa @@ -791,13 +777,13 @@ \yoko \vrule width10mm depth\@tombowwidth height\z@ \jlreq@trimmarks@outputbanner{before@bottom@center}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\hss\@bannerfont\jlreq@trimmarks@bannerfont##1\hskip 5mm}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\hss\jlreq@trimmarks@bannerfont##1\hskip 5mm}% \jlreq@tempdima=\dimexpr\ht\jlreq@tempboxa + 4pt\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise-\jlreq@tempdima\box\jlreq@tempboxa }% \jlreq@trimmarks@outputbanner{in@bottom@center}{% - \setbox\jlreq@tempboxa=\hbox{\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox{\jlreq@trimmarks@bannerfont##1}% \jlreq@tempdima=\dimexpr\dp\jlreq@tempboxa + \jlreq@trimmarks@bleed@bottom\relax \jlreq@tempdimb=.5\wd\jlreq@tempboxa \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \wd\jlreq@tempboxa=0pt @@ -805,7 +791,7 @@ }% \vrule depth10mm width\@tombowwidth height\z@ \jlreq@trimmarks@outputbanner{before@bottom@center}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\hskip 5mm\@bannerfont\jlreq@trimmarks@bannerfont##1\hss}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\hskip 5mm\jlreq@trimmarks@bannerfont##1\hss}% \jlreq@tempdima=\dimexpr\ht\jlreq@tempboxa + 4pt\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise-\jlreq@tempdima\box\jlreq@tempboxa @@ -818,13 +804,13 @@ \setbox\jlreq@tempboxa=\hbox to 0pt{% \@BR \yoko \jlreq@trimmarks@outputbanner{yoko@bottom@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hss\@bannerfont\jlreq@trimmarks@bannerfont##1\hskip 5mm}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hss\jlreq@trimmarks@bannerfont##1\hskip 5mm}% \jlreq@tempdima=\dimexpr\ht\jlreq@tempboxa + 4pt\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise-\jlreq@tempdima\box\jlreq@tempboxa }% \jlreq@trimmarks@outputbanner{inyoko@bottom@right}{% - \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hss\@bannerfont\jlreq@trimmarks@bannerfont##1}% + \setbox\jlreq@tempboxa=\hbox to 0pt{\yoko\hss\jlreq@trimmarks@bannerfont##1}% \jlreq@tempdima=\dimexpr\dp\jlreq@tempboxa + \jlreq@trimmarks@bleed@bottom\relax \ht\jlreq@tempboxa=0pt \dp\jlreq@tempboxa=0pt \raise\jlreq@tempdima\box\jlreq@tempboxa diff --git a/language/japanese/jlreq/jlreq.cls b/language/japanese/jlreq/jlreq.cls index 8f1ed6dfb1..913785b02d 100644 --- a/language/japanese/jlreq/jlreq.cls +++ b/language/japanese/jlreq/jlreq.cls @@ -5,7 +5,7 @@ %% % (based on JLReq 20120403 https://www.w3.org/TR/2012/NOTE-jlreq-20120403/ja/) \NeedsTeXFormat{LaTeX2e} -\ProvidesClass{jlreq}[2020/02/07 jlreq] +\ProvidesClass{jlreq}[2020/05/01 jlreq] \RequirePackage{xkeyval,everyhook,filehook,etoolbox,ifthen} \RequirePackage{jlreq-helpers} @@ -3769,6 +3769,14 @@ {% \begingroup \jlreq@pagestyle@parse@position@#1-\jlreq@endmark + \ifthenelse{\equal{\jlreq@tempa}{fore}}{% + \expandafter\jlreq@pagestyle@parse@position@\jlreq@tempb-\jlreq@endmark + \ifthenelse{\equal{\jlreq@tempa}{edge}}{% + \def\jlreq@tempa{fore-edge}% + }{% + \ClassError{jlreq}{Invalid position: fore-\jlreq@tempa}{\@ehc}% + }% + }{}% % \jlreq@tempcに縦方向を,\jlreq@tempdに横方向を入れる \def\jlreq@tempc{}\def\jlreq@tempd{}% \jlreq@pagestyle@parse@position@@{\jlreq@tempa}% @@ -3786,8 +3794,8 @@ \jlreq@ifempty{#2}{% \ifx\jlreq@tempb\@empty\ClassError{jlreq}{Invalid position: #1}{\@ehc}\fi }{% - \def\@tempa##1-{\def\jlreq@tempb{##1}}% - \@tempa#2\relax + \def\@tempa##1-\jlreq@endmark{\def\jlreq@tempb{##1}}% + \@tempa#2\jlreq@endmark\relax }% } @@ -4230,9 +4238,8 @@ \jlreq@if{\ifjlreq@pstate\fi}{% tate % headの方に処理を入れる.footは空. \def\jlreq@oddfoot{}\def\jlreq@evenfoot{}% - \jlreq@for@noexpand\jlreq@position:=\jlreq@nombre@i@position,\jlreq@running@head@i@position\do{% - \expandafter\ifx\jlreq@position\@empty\expandafter\def\jlreq@position{0pt}\fi - }% + \ifx\jlreq@nombre@i@position\@empty\def\jlreq@nombre@i@position{5\jlreq@zw}\fi + \ifx\jlreq@running@head@i@position\@empty\def\jlreq@running@head@i@position{4\jlreq@zw}\fi \edef\jlreq@gapcs{\noexpand\hskip\noexpand\glueexpr\expandonce{\jlreq@nombre@gap}\noexpand\relax}% \jlreq@pagestyle@addifempty{\jlreq@nombre@iii@position}{\jlreq@nombre@ii}{\jlreq@gapcs}{\jlreq@nombre@iii}% \jlreq@pagestyle@addifempty{\jlreq@nombre@ii@position}{\jlreq@nombre@i}{\jlreq@gapcs}{\jlreq@nombre@ii}% @@ -4246,15 +4253,16 @@ \expandafter\let\expandafter\jlreq@position\csname jlreq@nombre@\jlreq@i @position\endcsname \expandafter\ifx\csname jlreq@nombre@\jlreq@i\endcsname\@empty\else \jlreq@ifgluezero{\glueexpr\jlreq@position\relax}{\def\jlreq@position{}}{}% + \expandafter\let\expandafter\jlreq@tempa\expandafter=\csname jlreq@nombre@\jlreq@i\endcsname + \jlreq@pagestyle@addfont@tocs{jlreq@tempa}{jlreq@nombre@font}% \eappto\jlreq@nombre@contents{% \noexpand\hbox to 0pt{\noexpand\hss + \expandonce{\jlreq@tempa}% \ifx\jlreq@position\@empty\else\unexpanded{\hskip \glueexpr}\expandonce{\jlreq@position}\noexpand\relax\fi - \csexpandonce{jlreq@nombre@\jlreq@i}% }% }% \fi }% - \jlreq@pagestyle@addfont@tocs{jlreq@nombre@contents}{jlreq@nombre@font}% % \jlreq@(odd|even)@contentsに柱を入れる(上の方に出力) \@for\jlreq@parity:=odd,even\do{% \expandafter\def\csname jlreq@\jlreq@parity @contents\endcsname{}% @@ -4262,17 +4270,18 @@ \expandafter\let\expandafter\jlreq@position\csname jlreq@running@head@\jlreq@i @position\endcsname \expandafter\ifx\csname jlreq@\jlreq@parity @running@head@\jlreq@i\endcsname\@empty\else \jlreq@ifgluezero{\glueexpr\jlreq@position\relax}{\def\jlreq@position{}}{}% + \expandafter\let\expandafter\jlreq@tempa\expandafter=\csname jlreq@\jlreq@parity @running@head@\jlreq@i\endcsname + \jlreq@pagestyle@addfont@tocs{jlreq@tempa}{jlreq@running@head@font}% \expandafter\eappto\csname jlreq@\jlreq@parity @contents\endcsname{% \noexpand\hbox to 0pt{\unexpanded{\hskip\glueexpr\headsep + \headheight}% \if@tate\else\unexpanded{+ \topskip - \Cht}\fi \ifx\jlreq@position\@empty\else + \expandonce{\jlreq@position}\fi\noexpand\relax - \csexpandonce{jlreq@\jlreq@parity @running@head@\jlreq@i}% + \expandonce{\jlreq@tempa}% \noexpand\hss }% }% \fi }% - \jlreq@pagestyle@addfont@tocs{jlreq@\jlreq@parity @contents}{jlreq@running@head@font}% % \jlreq@(odd|even)headの構築 % 空き指定には基本版面の文字サイズを使う(2.6.1.c) \@ifundefined{jlreq@\jlreq@parity headformat} @@ -4455,7 +4464,7 @@ \jlreq@pagestyle@setheadfoot{\jlreq@oddfoot}{jlreq@odd@bottom@left}{jlreq@odd@bottom@center}{jlreq@odd@bottom@right}% \jlreq@pagestyle@setheadfoot{\jlreq@evenhead}{jlreq@even@top@left}{jlreq@even@top@center}{jlreq@even@top@right}% \jlreq@pagestyle@setheadfoot{\jlreq@evenfoot}{jlreq@even@bottom@left}{jlreq@even@bottom@center}{jlreq@even@bottom@right}% - \ifthenelse{\lengthtest{\marginparwidth>0pt} \AND \(\NOT\boolean{@tate}\)}{% + \ifthenelse{\lengthtest{\jlreq@sidenote@length >0pt} \AND \(\NOT\boolean{@tate}\)}{% \def\jlreq@defaultformat{\hss\hbox to \jlreqyokoheadlength{####1}\hss}% }{% \def\jlreq@defaultformat{####1}% @@ -4465,7 +4474,7 @@ \jlreq@pagestyle@applyformat{\jlreq@oddfoot}{\jlreq@oddfootformat}{\jlreq@defaultformat}% \jlreq@pagestyle@applyformat{\jlreq@evenfoot}{\jlreq@evenfootformat}{\jlreq@defaultformat}% % 傍注用調整 - \ifdim\marginparwidth>0pt + \ifdim\jlreq@sidenote@length>0pt \if@tate\else \if@twocolumn \jlreq@pagestyle@addsidenotemargin@bothside{\jlreq@oddhead}% @@ -4507,14 +4516,14 @@ \if@tate \def\jlreqyokoheadlength{\textheight} \else - \ifdim\marginparwidth>0pt + \ifdim\jlreq@sidenote@length>0pt \if@twocolumn \def\jlreqyokoheadlength{\dimexpr\textwidth + 2\jlreq@sidenote@length + 2\jlreq@sidenote@sep\relax} \else \def\jlreqyokoheadlength{\dimexpr\textwidth + \jlreq@sidenote@length + \jlreq@sidenote@sep\relax} \fi \else - \def\jlreqyokoheadlength{\textwidth} + \def\jlreqyokoheadlength{\dimexpr\textwidth\relax} \fi \fi \edef\jlreqtateheadlength{\unexpanded{\dimexpr\headsep + \headheight + \textheight}\if@tate\else\unexpanded{- \topskip + 1\jlreq@zh}\fi\noexpand\relax} @@ -5615,18 +5624,20 @@ \def\@begintheorem#1#2{\topsep=\dimexpr\jlreq@theorem@beforeafter@space\relax \trivlist\labelsep=1\jlreq@zw \itemindent=\dimexpr\jlreq@theorem@indent\relax - \item[\hskip \labelsep{\sffamily\gtfamily\bfseries #1\ #2}]} + \jlreq@theorem@font + \item[\hskip \labelsep{\reset@font\jlreq@theorem@label@font #1\ #2}]} \def\@opargbegintheorem#1#2#3{\topsep=\dimexpr\jlreq@theorem@beforeafter@space\relax \trivlist\labelsep=1\jlreq@zw \itemindent=\dimexpr\jlreq@theorem@indent\relax - \item[\hskip \labelsep{\sffamily\gtfamily\bfseries #1\ #2(#3)}]} + \jlreq@theorem@font + \item[\hskip \labelsep{\reset@font\jlreq@theorem@label@font #1\ #2(#3)}]} \AtEndOfPackageFile*{amsthm}{% \jlreq@saveoriginalcs{\proof}% \jlreq@saveoriginalcs{\endproof}% \edef\jlreq@do{ \unexpanded{\def\jlreq@proof[#1]}{% \unexpanded{\labelsep=1\jlreq@zw}% - \expandonce{\proof[{\reset@font\sffamily\gtfamily\bfseries #1\inhibitglue}\nopunct]}% + \expandonce{\proof[{\reset@font\jlreq@proof@label@font #1\inhibitglue}\nopunct]}% } } \jlreq@do @@ -5636,17 +5647,29 @@ \theoremstyle{jlreq} } \def\jlreq@setupamsthm{ - \newtheoremstyle{jlreq}{\dimexpr\jlreq@theorem@beforeafter@space\relax}{\dimexpr\jlreq@theorem@beforeafter@space\relax}{\normalfont}{\dimexpr\jlreq@theorem@indent\relax}{\sffamily\gtfamily\bfseries}{}{1\jlreq@zw}{\thmname{##1}\thmnumber{\ ##2}\thmnote{(##3)}} + \newtheoremstyle{jlreq}{\dimexpr\jlreq@theorem@beforeafter@space\relax}{\dimexpr\jlreq@theorem@beforeafter@space\relax}{\jlreq@theorem@font}{\dimexpr\jlreq@theorem@indent\relax}{\jlreq@theorem@label@font}{}{1\jlreq@zw}{\thmname{##1}\thmnumber{\ ##2}\thmnote{(##3)}} } \jlreq@jlreqsetup@add{theorem_beforeafter_space}{ \def\jlreq@theorem@beforeafter@space{#1} + \begingroup\jlreq@tempdima=\dimexpr\jlreq@theorem@beforeafter@space\relax\endgroup \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{} } \jlreq@jlreqsetup@add{theorem_indent}{ \def\jlreq@theorem@indent{#1} + \begingroup\jlreq@tempdima=\dimexpr\jlreq@theorem@indent\relax\endgroup \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{} } - +\jlreq@jlreqsetup@add{theorem_font}{ + \def\jlreq@theorem@font{#1} + \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{} +} +\jlreq@jlreqsetup@add{theorem_label_font}{ + \def\jlreq@theorem@label@font{#1} + \@ifpackageloaded{amsthm}{\jlreq@setupamsthm}{} +} +\jlreq@jlreqsetup@add{proof_label_font}{ + \def\jlreq@proof@label@font{#1} +} %. デフォルト設定 %.. 見出し @@ -5765,7 +5788,7 @@ \jlreqsetup{footnote_second_indent=1\jlreq@zw} \jlreqsetup{endnote_second_indent=2\jlreq@zw} \jlreqsetup{endnote_position=headings} -\ifdim\marginparwidth>0pt +\ifdim\jlreq@sidenote@length>0pt \jlreqsetup{sidenote_type=number} \jlreqsetup{sidenote_symbol=*,sidenote_keyword_font={}} \fi @@ -5930,7 +5953,13 @@ } \jlreqsetup{theindex_pagestyle=plain} \jlreqsetup{year_style=seireki} -\jlreqsetup{theorem_beforeafter_space=1\baselineskip,theorem_indent=0pt} +\jlreqsetup{ + theorem_beforeafter_space=1\baselineskip, + theorem_indent=0pt, + theorem_label_font = {\bfseries\gtfamily\sffamily}, + theorem_font = {\normalfont}, + proof_label_font = {\bfseries\gtfamily\sffamily}, +} \newcommand{\contentsname}{目次} diff --git a/language/japanese/jlreq/jlreq.pdf b/language/japanese/jlreq/jlreq.pdf index 6f92ea5c51..b770c64681 100644 Binary files a/language/japanese/jlreq/jlreq.pdf and b/language/japanese/jlreq/jlreq.pdf differ -- cgit v1.2.3