diff options
author | Karl Berry <karl@freefriends.org> | 2015-06-30 21:26:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-06-30 21:26:14 +0000 |
commit | aaec8ff3cf7236ae9429a6d9238b1838af2441d6 (patch) | |
tree | 7d00cf0ec8459200ac8e721eed28d09e155012c9 | |
parent | 56e4ae7a5ecbbf9bf7b858d20cb0c3e0d21edc8a (diff) |
ctex (30jun15)
git-svn-id: svn://tug.org/texlive/trunk@37720 c570f23f-e606-0410-a88d-b1316a301751
52 files changed, 3739 insertions, 2301 deletions
diff --git a/Master/texmf-dist/doc/latex/ctex/README b/Master/texmf-dist/doc/latex/ctex/README index e4c1135eef3..67afc3bbc3c 100644 --- a/Master/texmf-dist/doc/latex/ctex/README +++ b/Master/texmf-dist/doc/latex/ctex/README @@ -27,12 +27,14 @@ This package consists of the file ctex.dtx, and the derived files ctex.pdf, ctex.ins, ctex.sty, - ctexcap.sty, ctexsize.sty, ctexheading.sty, ctexart.cls, ctexbook.cls, ctexrep.cls, + ctexcap.sty, + ctexhook.sty, + ctexpatch.sty, ctex-c5size.clo, ctex-cs4size.clo, ctex-article.def, diff --git a/Master/texmf-dist/doc/latex/ctex/ctex.pdf b/Master/texmf-dist/doc/latex/ctex/ctex.pdf Binary files differindex c67685ec9cc..e135914f912 100644 --- a/Master/texmf-dist/doc/latex/ctex/ctex.pdf +++ b/Master/texmf-dist/doc/latex/ctex/ctex.pdf diff --git a/Master/texmf-dist/source/latex/ctex/ctex.dtx b/Master/texmf-dist/source/latex/ctex/ctex.dtx index b635785a8d9..353a630cdd8 100644 --- a/Master/texmf-dist/source/latex/ctex/ctex.dtx +++ b/Master/texmf-dist/source/latex/ctex/ctex.dtx @@ -55,12 +55,14 @@ This package consists of the file ctex.dtx, and the derived files ctex.pdf, ctex.ins, ctex.sty, - ctexcap.sty, ctexsize.sty, ctexheading.sty, ctexart.cls, ctexbook.cls, ctexrep.cls, + ctexcap.sty, + ctexhook.sty, + ctexpatch.sty, ctex-c5size.clo, ctex-cs4size.clo, ctex-article.def, @@ -191,12 +193,14 @@ This package consists of the file ctex.dtx, and the derived files and the derived files ctex.pdf, ctex.ins, ctex.sty, - ctexcap.sty, ctexsize.sty, ctexheading.sty, ctexart.cls, ctexbook.cls, ctexrep.cls, + ctexcap.sty, + ctexhook.sty, + ctexpatch.sty, ctex-c5size.clo, ctex-cs4size.clo, ctex-article.def, @@ -251,13 +255,15 @@ This package consists of the file ctex.dtx, and the derived files { \usedir{tex/latex/ctex} \file{ctex.sty} {\from{\jobname.dtx}{style,ctex}} - \file{ctexcap.sty} {\from{\jobname.dtx}{ctexcap}} \file{ctexsize.sty} {\from{\jobname.dtx}{style,ctexsize}} \file{ctexheading.sty} {\from{\jobname.dtx}{style,ctexheading}} \file{ctexart.cls} {\from{\jobname.dtx}{class,article}} \file{ctexbook.cls} {\from{\jobname.dtx}{class,book}} \file{ctexrep.cls} {\from{\jobname.dtx}{class,report}} \usepostamble\emptypostamble + \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}} @@ -321,12 +327,14 @@ This package consists of the file ctex.dtx, and the derived files \Msg{* The recommended directory is TDS:tex/latex/ctex *} \Msg{* *} \Msg{* ctex.sty *} -\Msg{* ctexcap.sty *} \Msg{* ctexsize.sty *} \Msg{* ctexheading.sty *} \Msg{* ctexart.cls *} \Msg{* ctexbook.cls *} \Msg{* ctexrep.cls *} +\Msg{* ctexcap.sty *} +\Msg{* ctexhook.sty *} +\Msg{* ctexpatch.sty *} \Msg{* ctex-c5size.clo *} \Msg{* ctex-cs4size.clo *} \Msg{* ctex-article.def *} @@ -384,10 +392,10 @@ This package consists of the file ctex.dtx, and the derived files %</internal> %<*!(readme|install|zhmap|spa)> %<*!(c19|c70|ctexspa)> -%<*driver|class|style|ctexcap> +%<*driver|class|style|ctexcap|ctexhook|ctexpatch> \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -%</driver|class|style|ctexcap> +%</driver|class|style|ctexcap|ctexhook|ctexpatch> %<.!(readme|install|zhmap|spa|c19|c70|ctexspa)>\ctexPutVersion %<*driver> \InputIfFileExists{ctex.ver}{}{ @@ -398,8 +406,6 @@ This package consists of the file ctex.dtx, and the derived files %</driver> %<ctex> {Chinese adapter in LaTeX (CTEX)} %<ctex>\ProvidesExplPackage{\ExplFileName} -%<ctexcap> {Chinese adapter in LaTeX (CTEX)} -%<ctexcap>\ProvidesExplPackage{ctexcap} %<ctexsize> {Chinese font size definition (CTEX)} %<ctexsize>\ProvidesExplPackage{ctexsize} %<ctexheading> {Heading style modification (CTEX)} @@ -410,6 +416,12 @@ This package consists of the file ctex.dtx, and the derived files %<class&book>\ProvidesExplClass{ctexbook} %<class&report> {Chinese adapter for class report (CTEX)} %<class&report>\ProvidesExplClass{ctexrep} +%<ctexcap> {Chinese adapter in LaTeX (CTEX)} +%<ctexcap>\ProvidesExplPackage{ctexcap} +%<ctexhook> {Document and package hooks (CTEX)} +%<ctexhook>\ProvidesExplPackage{ctexhook} +%<ctexpatch> {Patching commands (CTEX)} +%<ctexpatch>\ProvidesExplPackage{ctexpatch} %<c5size> {c5size option (CTEX)} %<c5size>\ProvidesExplFile{ctex-c5size.clo} %<cs4size> {cs4size option (CTEX)} @@ -466,7 +478,7 @@ This package consists of the file ctex.dtx, and the derived files %<founder>\ProvidesExplFile{ctex-fontset-founder.def} %<ubuntu> {Ubuntu fonts definition (CTEX)} %<ubuntu>\ProvidesExplFile{ctex-fontset-ubuntu.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} %</!(c19|c70|ctexspa)> %<rm&c19>\ProvidesFile{c19rm.fd}% %<sf&c19>\ProvidesFile{c19sf.fd}% @@ -475,8 +487,8 @@ This package consists of the file ctex.dtx, and the derived files %<sf&c70>\ProvidesFile{c70sf.fd}% %<tt&c70>\ProvidesFile{c70tt.fd}% %<ctexspa>\ProvidesFile{ctexspa.def}% -%<c19|c70> [2015/05/15 v2.1 Chinese font definition (CTEX)] -%<ctexspa> [2015/05/15 v2.1 Space info for CJKpunct (CTEX)] +%<c19|c70> [2015/07/01 v2.2 Chinese font definition (CTEX)] +%<ctexspa> [2015/07/01 v2.2 Space info for CJKpunct (CTEX)] %</!(readme|install|zhmap|spa)> %<*driver> \ExplSyntaxOff @@ -493,7 +505,6 @@ This package consists of the file ctex.dtx, and the derived files name = {第,节}, }, } -\appto\abstract{\parindent=2\ccwd} ^^A l3doc.cls 设置列表环境中 \listparindent=\z@ \usepackage[toc]{multitoc} \usepackage{geometry} \usepackage{tabularx} @@ -547,7 +558,7 @@ This package consists of the file ctex.dtx, and the derived files %% 不对代码实现的 \section 以下标题编目录。 \AtBeginEnvironment{implementation}{% \ifnum\value{tocdepth}>\@ne - \addtocontents{toc}{\noexpand\value{tocdepth}=1\relax}% + \addtocontents{toc}{\protect\value{tocdepth}=1\relax}% \fi} \ifxetex \let\ctexdocverbaddon\xeCJKVerbAddon @@ -560,16 +571,23 @@ This package consists of the file ctex.dtx, and the derived files \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, + font=\mdseries\small\ttfamily,align=right,listparindent=\parindent, labelsep=\marginparsep,labelindent=-\marginparsep,leftmargin=*} \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, @@ -600,7 +618,13 @@ This package consists of the file ctex.dtx, and the derived files \appto\AltMacroFont{\hyphenchar\font\m@ne\ctexdocverbaddon} \def\Module#1{\mbox{% \color{purple}\footnotesize\normalfont\sffamily\textlangle#1\textrangle}} +\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 @@ -677,6 +701,7 @@ This package consists of the file ctex.dtx, and the derived files \let\tn\bookmarkcstn \let\meta\bookmarkmeta \let\opt\@firstofone} +\preto\@thehead{\cslet{MakeUppercase\space}{\@iden}} \def\orbar{\textup{\textbar}} \def\defaultval#1{\textbf{\textup{#1}}} \def\defaultvalaux#1){\defaultval{#1}} @@ -687,11 +712,11 @@ This package consists of the file ctex.dtx, and the derived files \def\pdfTeX{\hologo{pdfTeX}} \def\XeTeX{\hologo{XeTeX}} \def\XeLaTeX{\hologo{XeLaTeX}} -\DeclareRobustCommand\LuaLaTeX{\hologo{LuaLaTeX}} +\def\LuaLaTeX{\hologo{LuaLaTeX}} \def\pdfLaTeX{\hologo{pdfLaTeX}} \def\LaTeX{\hologo{LaTeX}} \def\LaTeXe{\hologo{LaTeX2e}} -\def\LTXIII{\hologo{LaTeX3}} +\def\LaTeXiii{\hologo{LaTeX3}} \def\dvipdfmx{DVIPDFM\textit{x}} \def\ctexkitrev#1{% \href{https://github.com/CTeX-org/ctex-kit/commit/#1}{\texttt{ctex-kit} rev. #1}} @@ -718,25 +743,21 @@ This package consists of the file ctex.dtx, and the derived files \CodelineIndex \RecordChanges \def\glossaryname{版本历史} -\GlossaryPrologue{\section*{\glossaryname}} +\GlossaryPrologue{\section{\glossaryname}} \IndexPrologue{% - \section*{\indexname} + \section{\indexname} \textit{意大利体的数字表示描述对应索引项的页码; 带下划线的数字表示定义对应索引项的代码行号; 罗马字体的数字表示使用对应索引项的代码行号。}} \usepackage{makecell} +\newcommand{\bashcmd}{\texttt} \newcommand{\TeXLive}{\TeX\ Live} -\newcommand{\opos}[1]{\texttt{\small #1}} ^^A option position -\newcommand{\OPC} - {\opos{该选项只能在调用 \CTeX{} 宏包/文档类时作为选项使用}} -\newcommand{\OSET} - {\opos{该选项只能用 \tn{ctexset} 来设置}} -\newcommand{\OBOTH} - {\opos{该选项既可以作为宏包/文档类选项使用,也可以使用 \tn{ctexset} 来设置}} +\newcommand{\MiKTeX}{\hologo{MiKTeX}} \usepackage{threeparttable} \begin{document} \DocInput{\jobname.dtx} \newgeometry{hmargin=15mm,vmargin={25mm,15mm},footskip=7mm} + \ctexset{section/numbering=false} \PrintChanges \PrintIndex \end{document} @@ -744,13 +765,14 @@ This package consists of the file ctex.dtx, and the derived files % % \fi % -% \changes{v2.0}{2014/03/06}{应用 \LTXIII{} 重新整理代码。} +% \changes{v2.0}{2014/03/06}{应用 \LaTeXiii{} 重新整理代码。} % \changes{v2.0}{2014/03/12}{删除 \file{c19gbsn.fd} 和 \file{c19gkai.fd}。} % \changes{v2.1}{2015/05/18}{将章节标题设置功能提取到可以独立使用的宏包 % \pkg{ctexheading} 中。} +% \changes{v2.2}{2015/06/24}{不再依赖 \pkg{etoolbox} 宏包。} % % -% \CheckSum{4523} +% \CheckSum{5026} % % \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 @@ -810,8 +832,8 @@ This package consists of the file ctex.dtx, and the derived files % 在开发新版本时,考虑到合作开发和调试的方便,我们放弃了 \pkg{doc} 和 \pkg{DocStrip}, % 采取了直接编写宏包代码的方式。 % -% 2014 年 3 月,为了适应 \LaTeX{} 的最新发展,特别是 \LTXIII{} 的逐渐成熟,李清用 -% \LTXIII{} 重构了整个宏包的代码,并重新使用 \pkg{doc} 和 \pkg{DocStrip} 工具进行代码 +% 2014 年 3 月,为了适应 \LaTeX{} 的最新发展,特别是 \LaTeXiii{} 的逐渐成熟,李清用 +% \LaTeXiii{} 重构了整个宏包的代码,并重新使用 \pkg{doc} 和 \pkg{DocStrip} 工具进行代码 % 的管理,升级版本号为 2.0,并改称 \CTeX{} 宏集。 % % 2015 年 3 月,由于 Google Code 即将停止服务,ctex-kit 项目迁移至 @@ -829,7 +851,7 @@ This package consists of the file ctex.dtx, and the derived files % % 另一方面,随着 \TeX{} 引擎和 \LaTeX{} 宏包的不断发展,\LaTeX{} 的中文支持方式从早期的 % 专用系统(如 \pkg{CCT})发展为适用于不同引擎的多种方式^^A -% \footnote{比如:\pdfTeX{} 引擎下的 \pkg{CJK}、\pkg{zhmCJK}宏包、 +% \footnote{比如:\pdfTeX{} 引擎下的 \pkg{CJK}、\pkg{zhmCJK}宏包, % \XeTeX{} 引擎下的 \pkg{xeCJK} 宏包和 \LuaTeX{} 引擎下的 \pkg{LuaTeX-ja} 宏 % 包}。这些方式的适用情况和使用方式有不少细节上的差异,同时操作系统的不同、语言环境的不同等 % 客观情况又进一步带来了更多的细节差异。我们设计 \CTeX{} 宏集的另一个主要目的就是 @@ -845,7 +867,7 @@ This package consists of the file ctex.dtx, and the derived files % 结合而成的。在纯文本环境下,该名字应写作“CTeX”。 % % \CTeX{} 宏集是由 \href{http://bbs.ctex.org}{\CTeX{} 社区} 发起并维护的 -% LaTeX \emph{宏包和文档类的集合}。 +% \LaTeX{} \emph{宏包和文档类的集合}。 % 社区另有发布名为 \href{http://www.ctex.org/CTeX}{\CTeX{} 套装} % 的 \TeX{} 发行版,与本文档所述的 \CTeX{} 宏集并非是同一事物。 % @@ -887,6 +909,51 @@ This package consists of the file ctex.dtx, and the derived files % \end{tabularx} % \end{table} % +% \subsection{\CTeX{} 宏集的安装和更新} +% \label{subsec:easy-ins} +% +% \CTeX{} 宏集依赖的宏包和宏集已被最常见的 \TeX{} 发行版 \TeXLive{} 和 \MiKTeX{} +% 所收录。如果本地安装 \TeXLive{} 或 \MiKTeX{} 不是完全版本,就可能需要通过这 +% 两个发行版提供的\emph{宏包管理器}来安装宏包。 +% +% \TeXLive{} 的宏包管理器是 tlmgr。用户可以在系统命令行中^^A +% \footnote{Windows 系统的命令行是 CMD 命令提示符,你可以使用 Win + R 组合键^^A +% 打开“运行”对话框,然后输入 cmd 确认打开命令提示符窗口。}^^A +% 执行 +% \begin{frameverb} +% tlmgr gui +% \end{frameverb} +% 启动管理器的图形界面(Windows 用户也可以通过开始菜单的 +% TeX Live 2015 \ding{212} TeX Live Manager 打开)。 +% 连接上远程仓库之后,搜索 ctex 安装即可。 +% tlmgr 的图形界面使用 Perl 编写,容易造成系统假死。遇到这种问题的用户, +% 也可以直接在系统命令行执行 +% \begin{frameverb} +% tlmgr install ctex +% \end{frameverb} +% 来安装 \CTeX{} 宏集\footnote{*nix 用户可能需要超级用户权限才能正确安装宏集。}。 +% +% \MiKTeX{} 的宏包管理器是 mpm (\MiKTeX{} Package Manager)。用户可以在开始菜单 +% 找到 MiKTeX \ding{212} Maintenance (Admin) \ding{212} Package Manager (Admin), +% 打开管理器,连接上远程仓库之后,搜索 ctex 安装即可。 +% +% 若希望了解 \CTeX{} 宏集具体的依赖情况和手工安装宏集的方法, +% 请参阅第 \ref{sec:dep-ins}~节。 +% +% 当宏包发布新版本,并被发行版在远程仓库安装之后,在本地就可以通过宏包管理器来 +% 取得新版本。 +% +% 对于 \TeXLive{},可以在 tlmgr 的图形界面点击“更新全部已安装的”按钮或者在 +% 命令行执行 +% \begin{frameverb} +% tlmgr update --all +% \end{frameverb} +% 来完整更新已安装的宏包。 +% +% 对于 \MiKTeX{},在开始菜单找到 +% MiKTeX \ding{212} Maintenance (Admin) \ding{212} Update (Admin), +% 按照界面说明更新即可。 +% % \subsection{使用 \CTeX{} 文档类} % % \emph{如果用户需要在标准文档类的基础上添加中文支持和中文版式支持,我们建议用户使用 \CTeX{} @@ -940,68 +1007,6 @@ This package consists of the file ctex.dtx, and the derived files % \end{document} % \end{ctexexam} % -% \section{依赖与安装} -% -% \CTeX{} 是一个 \LaTeX{} 宏包,只有一个源文件 \file{ctex.dtx}。 -% 使用不同的编译方式时,\CTeX{} 依赖的宏包略有不同。在安装 \CTeX{} 宏集之前,请确保 -% 你的系统里已经正确安装了这些宏包。\CTeX{} 依赖宏包的详情叙述如下: -% -% \begin{itemize} -% \item \pkg{expl3}、\pkg{xparse} 和 \pkg{l3keys2e} 宏包。它们属于 \pkg{l3kernel} -% 和 \pkg{l3packages} 宏集,它们还依赖 -% \begin{itemize} -% \item \pkg{etex} 宏包。 -% \end{itemize} -% \item \pkg{indentfirst} 宏包,属于 \pkg{tools} 宏集。 -% \item \pkg{etoolbox} 宏包。 -% \item \pkg{everysel} 宏包,属于 \pkg{ms} 宏集。 -% \item \pkg{zhnumber} 宏包。 -% \item[\ding{229}] 以上是各种编译方式都必需的依赖项。 -% \item \pkg{CJK} 宏集,它的下划线功能依赖 \pkg{ulem} 宏包。 -% \item \pkg{CJKpunct} 宏包。 -% \item \pkg{xCJK2uni} 宏包。 -% \item \pkg{zhmetrics} 宏包。 -% \item \pkg{zhmCJK} 宏包。 -% \item[\ding{229}] 以上是使用 \pdfLaTeX{} 或 \LaTeX{} + \dvipdfmx{} 的编译方式所需要 -% 的依赖项,其中 \pkg{zhmCJK} 是可选的。 -% \item \pkg{xeCJK} 宏包,它还依赖 -% \begin{itemize} -% \item \pkg{fontspec} 宏包,它还依赖 -% \begin{itemize} -% \item \pkg{euenc} 宏包。 -% \item \pkg{xunicode} 宏包,它还依赖 \pkg{tipa} 宏包。 -% \end{itemize} -% \end{itemize} -% \item[\ding{229}] 以上是使用 \XeLaTeX{} 编译时的依赖项。 -% \item \pkg{LuaTeX-ja} 宏集,它还依赖 -% \begin{itemize} -% \item \pkg{luaotfload} 宏包,它还依赖 \pkg{luatexbase} 宏包。 -% \item \pkg{xkeyval} 宏包。 -% \end{itemize} -% \item[\ding{229}] 以上是使用 \LuaLaTeX{} 编译时的依赖项。 -% \end{itemize} -% -% \CTeX{} 依赖的各个宏包和宏集均已被 \TeXLive{} 和 \hologo{MiKTeX} 收录。如果 -% 你是这两个 \TeX{} 发行版的用户,可以使用他们提供的宏包管理器来安装这些宏包,或将他们 -% 更新到最新版本。如果你不使用这两个发行版,请参考你使用的 \TeX{} 发行版和相关宏包 -% 的说明文档。 -% -% 出于一些原因,\pkg{zhmCJK} 尚未被收入 \TeXLive{} 和 \hologo{MiKTeX}。因此,若 -% 你希望使用 \pkg{zhmCJK} 作为 \CTeX{} 宏集的底层中文支持方式,需要自行安装该宏包。 -% \pkg{zhmCJK} 的安装较为复杂。我们建议你从 CTAN 下载 \pkg{zhmCJK} 的 -% \href{http://mirrors.ctan.org/install/language/chinese/zhmcjk.tds.zip}{TDS -% 安装包},按目录结构将文件复制到 \TeX{} 发行版的本地 TDS 根目录,然后刷新文件 -% 名数据库。关于安装的详细内容,可以参照其 -% \href{http://mirrors.ctan.org/language/chinese/zhmcjk/zhmCJK.pdf}{宏包手册} -% 中第 3 节的指导。 -% -% \CTeX{} 的正式版本也已被 \TeXLive{} 和 \hologo{MiKTeX} 收录。因此,使用这两个发行版 -% 的用户可以如常使用宏包管理器来安装。如果你不使用者两个发行版,我们建议你从 CTAN -% 下载 \CTeX{} 的 -% \href{http://mirrors.ctan.org/install/language/chinese/ctex.tds.zip}{TDS -% 安装包} 按目录结构将文件复制到 \TeX{} 发行版的本地 TDS 根目录,然后刷新文件 -% 名数据库。 -% % \section{宏包选项与 \tn{ctexset} 命令} % \label{sec:options} % @@ -1016,12 +1021,18 @@ This package consists of the file ctex.dtx, and the derived files % 也有的以 \meta{key}|=|\meta{value} 的形式提供。对于以键值对形式提供的选项, % 在下面的说明中使用\textbf{粗体}来表示 \CTeX{} 的默认设置。 % -% 另一方面,在这些选项里,有些选项只能作为宏包/文档类选项,需要在引入宏包/文档类的时候指定; -% 有些选项只能通过 \CTeX{} 宏集提供的用户接口 \tn{ctexset} 来设定; -% 也有一些选项既可以作为宏包/文档类选项,也可以通过 \tn{ctexset} 来设定。 -% 后续文档中将在使用说明中对每个选项的使用方式做说明。 +% 另一方面,这些选项可以分为以下三类: +% \begin{itemize} +% \item 名字后带有 \rexptarget\rexpstar{} 号的选项,只能作为宏包/文档类选项,需要 +% 在引入宏包/文档类的时候指定; +% \item 名字后带有 \exptarget\expstar{} 号的选项,只能通过 \CTeX{} 宏集提供的 +% 用户接口 \tn{ctexset} 来设定; +% \item 名字后不带有特殊符号的选项,既可以作为宏包/文档类选项,也可以通过 +% \tn{ctexset} 来设定。 +% \end{itemize} +% 后续文档将在使用说明中对某些特殊的选项加以说明。 % -% \begin{function}{\ctexset} +% \begin{function}[added=2014-03-18]{\ctexset} % \begin{syntax} % \tn{ctexset} \Arg{键值列表} % \end{syntax} @@ -1039,7 +1050,7 @@ This package consists of the file ctex.dtx, and the derived files % } % \end{ctexexam} % -% \tn{ctexset} 采用 \LaTeX3 风格的键值设置,支持不同类型的选项与层次化的选 +% \tn{ctexset} 采用 \LaTeXiii{} 风格的键值设置,支持不同类型的选项与层次化的选 % 项设置,相关示例见 \ref{sec:secstyle}~节。 % % \section{编译方式、编码与中文字库} @@ -1077,10 +1088,7 @@ This package consists of the file ctex.dtx, and the derived files % \subsection{中文编码} % \label{subs:encoding} % -% \begin{function}{GBK, UTF8} -% \begin{syntax} -% \OPC -% \end{syntax} +% \begin{function}[rEXP]{GBK, UTF8} % 指明编写文档时使用的编码格式。\CTeX{} 宏集无法检测用户编写文档时使用的编码格式,因此 % 需要用户自行指定编码。\emph{我们建议用户总是使用 UTF-8 编码,并显式指定 \opt{UTF8} % 选项,并使用 \XeLaTeX{} 或 \LuaLaTeX{} 编译。} @@ -1129,6 +1137,7 @@ This package consists of the file ctex.dtx, and the derived files % \makecell{\pkg{CJK} + \pkg{zhmetrics}\\Fandol 字库} \\ % \bottomrule % \end{tabular} +% \smallskip % \begin{tablenotes}\footnotesize % \item [1] Windows Vista 及以后的 Windows 操作系统。 % \item [2] Windows XP 及以前的 Windows 操作系统。 @@ -1145,12 +1154,11 @@ This package consists of the file ctex.dtx, and the derived files % 意外情况失效,或者在用户有特殊需求的情况下使用。\emph{除非必要,用户不 % 应使用这些选项。} % -% \begin{function}{zhmap} +% \begin{function}[rEXP,updated=2014-03-08]{zhmap} % \begin{syntax} % zhmap = <\TTF|zhmCJK> -% \OPC\opos{,并且只在使用 \pdfLaTeX{}/\LaTeX{} 编译时有意义} % \end{syntax} -% 指定字体映射机制。 +% 指定字体映射机制。本选项只在使用 \pdfLaTeX/\LaTeX{} 编译时有意义。 % \end{function} % \begin{optdesc} % \item[true] 使用 \pkg{zhmetrics} 宏包,将 CJK 字库通过 \tn{special} @@ -1165,11 +1173,10 @@ This package consists of the file ctex.dtx, and the derived files % ,由 \pkg{zhmCJK} 宏包提供从 CJK 字库到 \file{.ttf} 的映射。 % \end{optdesc} % -% \begin{function}{fontset} +% \begin{function}[added=2014-03-08]{fontset} % \begin{syntax} % fontset =^^A -% <none|adobe|fandol|founder|mac|ubuntu|windows|windowsnew|windowsold...> -% \OBOTH +% <none|adobe|fandol|founder|mac|ubuntu|windows|windowsnew|windowsold|...> % \end{syntax} % 指定 \CTeX{} 宏集加载的字库。 % @@ -1193,7 +1200,7 @@ This package consists of the file ctex.dtx, and the derived files % \end{optdesc} % % 注意:使用 (pdf)\LaTeX{} 编译的时候,若设置 \opt{zhmap = false}(比如需要 -% 使用 \LaTeX{} + DVIPS 编译),则需要按照传统方式^^A +% 使用 \LaTeX{} + Dvips 编译),则需要按照传统方式^^A % \footnote{可以使用 \pkg{zhmetrics} 宏包提供的脚本 % \href{https://github.com/CTeX-org/ctex-kit/blob/master/zhmetrics/CTeXFonts.lua} % {\file{CTeXFonts.lua}}。}^^A @@ -1217,7 +1224,7 @@ This package consists of the file ctex.dtx, and the derived files % \documentclass[fontset = none]{ctexart} % \ctexset{fontset = founder} % \begin{document} -% 在文档类选项中声明 \verb|fontset = none|,随后在导言区用 \tn{ctexset} +% 在文档类选项中声明 \verb|fontset = none|,随后在导言区用 \verb|\ctexset| % 指定字体。 % \end{document} % \end{ctexexam} @@ -1246,10 +1253,9 @@ This package consists of the file ctex.dtx, and the derived files % \subsection{文档默认字号} % \label{subs:options-class} % -% \begin{function}{zihao} +% \begin{function}[rEXP,added=2015-05-06]{zihao} % \begin{syntax} % zihao = <-4|5|false> -% \OPC % \end{syntax} % 将文章默认字号(\tn{normalsize})设置为小四号字或五号字, % 具体情况见表 \ref{tab:fontsize}。\opt{false} 禁用本功能。 @@ -1269,8 +1275,8 @@ This package consists of the file ctex.dtx, and the derived files % \multicolumn1c{|10pt|} & \multicolumn1c{|11pt|} & \multicolumn1c{|12pt|} \\ % \cmidrule(lr){2-3} \cmidrule(lr){4-5} % \cmidrule(lr){6-6} \cmidrule(lr){7-7} \cmidrule(lr){8-8} -% 字体命令 & 字号 & \textrm{bp} & 字号 & \textrm{bp} -% & \textrm{pt} & \textrm{pt} & \textrm{pt} \\ +% 字体命令 & 字号 & \si{bp} & 字号 & \si{bp} +% & \si{pt} & \si{pt} & \si{pt} \\ % \midrule % |\tiny| & 七号 & 5.5 & 小六 & 6.5 & ~5 & ~6 & ~6 \\ % |\scriptsize| & 小六 & 6.5 & 六号 & 7.5 & ~7 & ~8 & ~8 \\ @@ -1286,10 +1292,7 @@ This package consists of the file ctex.dtx, and the derived files % \end{tabular} %\end{table} % -% \begin{function}{10pt, 11pt, 12pt} -% \begin{syntax} -% \OPC -% \end{syntax} +% \begin{function}[rEXP]{10pt, 11pt, 12pt} % \CTeX{} 文档类是在 \LaTeX{} 标准文档类之上开发的。因此,除了可以使用 \CTeX{} % 宏包定义的字号选项之外,还可以使用标准文档类的同类选项(\opt{10pt}、\opt{11pt} % 和 \opt{12pt})。在使用这些来自标准文档类的选项的时候,\CTeX{} 文档类的字号 @@ -1307,11 +1310,12 @@ This package consists of the file ctex.dtx, and the derived files % \subsection{章节标题风格} % \label{subs:options-heading} % -% \begin{function}{heading} +% \begin{function}[rEXP,added=2014-03-08]{heading} % \begin{syntax} % heading = <\TFF> -% \opos{该选项只能在调用 \pkg{ctex.sty} 时作为宏包选项使用} % \end{syntax} +% 本选项只能在调用 \pkg{ctex.sty} 时作为宏包选项使用。 +% % \CTeX{} 宏集提供了一套用于修改文档章节标题格式的接口。该选项用于选择是否 % 启用该功能。详细的设置方法请参见 % \ref{sec:secstyle}~节和 \ref{subs:pagestyle}~节。 @@ -1323,11 +1327,8 @@ This package consists of the file ctex.dtx, and the derived files % 三个中文文档类\emph{完全}一致;若不然,则会根据 \tn{chapter} % 是否有定义来使用 \cls{ctexbook} 或者 \cls{ctexart} 的标题设置。 % -% \begin{function}{sub3section, sub4section} -% \begin{syntax} -% \OPC -% \end{syntax} -% 会修改 \tn{paragraph} 和 \tn{subparagraph} 的格式。 +% \begin{function}[rEXP]{sub3section, sub4section} +% 修改 \tn{paragraph} 和 \tn{subparagraph} 的格式。 % % 默认情况下,\tn{paragraph} 和 \tn{subparagraph} 会将标题与随后的正文 % 排版在同一个段落。启用 \opt{sub3section} 会将 \tn{paragraph} 的格式修改为 @@ -1346,32 +1347,31 @@ This package consists of the file ctex.dtx, and the derived files % \subsection{排版方案选项} % \label{subs:options-type-style} % -% \begin{function}{scheme} +% \begin{function}[rEXP,added=2015-04-15]{scheme} % \begin{syntax} % scheme = <(chinese)|plain> -% \OPC % \end{syntax} % 选择文章的排版方案,预设有 \opt{chinese} 和 \opt{plain} 两种方案。% % \end{function} -% \begin{optdesc} +% \begin{optdesc}[itemsep=\medskipamount] % \item[chinese] 调整默认字号为五号字,并调整行距为 |1.3|; % 汉化文档中的标题名字(如“图”、“表”、“目录”和“参考文献”, % 见 \ref{subs:capname}~节); % 在 \opt{heading = true} 的情况下^^A % \footnote{使用 \CTeX{} 文档类,或者使用 \pkg{ctex} 宏包且开启该选项时。}^^A % (\ref{subs:options-heading}~节),还会将章节标题的风格修改为 -% 中文样式(见 \ref{sec:secstyle}~节)。当 \pkg{ctex} 宏包与标准文档类及其 -% 衍生文档类联用时,会载入 \pkg{indentfirst} 宏包, -% 以实现章节标题后的段首缩进。 +% 中文样式(见 \ref{sec:secstyle}~节)。 +% +% 当关闭 \opt{heading} 选项的 \pkg{ctex} 宏包与标准文档类或其衍生文档类 +% 联用时,会载入 \pkg{indentfirst} 宏包,以实现章节标题后的段首缩进。 % \item[plain] 不调整默认字号和行距,不会汉化文档中的标题名字,也不会将章节 % 标题风格修改为中文样式,同时不会调整 \tn{pagestyle},并禁用 \opt{autoindent} % 选项。事实上,此时的 \CTeX{} 宏集只提供了中文支持功能,而不对文章版式进行任何修改。 % \end{optdesc} % -% \begin{function}{punct} +% \begin{function}[updated=2014-04-11]{punct} % \begin{syntax} % punct = <(quanjiao)|banjiao|kaiming|CCT|plain> -% \OBOTH % \end{syntax} % 设置标点处理格式。预定义好的格式有: % \end{function} @@ -1386,10 +1386,9 @@ This package consists of the file ctex.dtx, and the derived files % \item[plain] 原样(不调整标点间距)。 % \end{optdesc} % -% \begin{function}{space} +% \begin{function}[updated=2014-03-08]{space} % \begin{syntax} % space = <\TF|(auto)> -% \OBOTH % \end{syntax} % 是否在生成的 PDF 中保留汉字后面的空格。 % \end{function} @@ -1420,10 +1419,9 @@ This package consists of the file ctex.dtx, and the derived files % \emph{使用 \textup{\LuaLaTeX} 编译的时候,该选项无效:汉字间的空格以及汉字与西文字符 % 之间的空格总是有效,不会被忽略,但可以自动忽略掉由换行产生的空格。} % -% \begin{function}{linespread} +% \begin{function}[rEXP,added=2014-04-23]{linespread} % \begin{syntax} % linespread = <数值> -% \OPC % \end{syntax} % 接受一个浮点数值,设置行距倍数。本选项的初始值与 \opt{scheme} 有关。 % \end{function} @@ -1435,10 +1433,9 @@ This package consists of the file ctex.dtx, and the derived files % 其他宏包或用户设置决定。 % \end{optdesc} % -% \begin{function}{autoindent} +% \begin{function}[added=2014-03-13]{autoindent} % \begin{syntax} % autoindent = <\TTF|数值|带单位的数值> -% \OBOTH % \end{syntax} % 在字体大小发生变化时,是否自动调整段首缩进(\tn{parindent})的大小。 % \end{function} @@ -1455,10 +1452,9 @@ This package consists of the file ctex.dtx, and the derived files % \end{ctexexam} % \end{optdesc} % -% \begin{function}{linestretch} +% \begin{function}[EXP,added=2014-03-26]{linestretch} % \begin{syntax} % linestretch = <数值或长度> -% \OSET % \end{syntax} % \opt{linestretch} 是一个比较特殊的选项,它用来设置汉字之间弹性间距的弹性程 % 度。如果有单位,则可以在选项中直接写;如果是数字,单位则是汉字宽度 @@ -1485,10 +1481,9 @@ This package consists of the file ctex.dtx, and the derived files % \CTeX 宏包对显示当前日期的 \tn{today} 命令进行了汉化,使之以中文的方式显示今 % 天的日期。如编译本文档的日期就是“\today”。 % -% \begin{function}{today} +% \begin{function}[EXP]{today} % \begin{syntax} % today = <(small)|big|old> -% \OSET % \end{syntax} % 该选项用来控制 \tn{today} 命令的输出格式: % \begin{optdesc} @@ -1521,75 +1516,66 @@ This package consists of the file ctex.dtx, and the derived files % % \begin{defaultcapconfig} % -% \begin{function}{contentsname} +% \begin{function}[EXP]{contentsname} % \begin{syntax} % contentsname = <名字> -% \OSET % \end{syntax} % 设置目录标题名 \tn{contentsname}。中文默认为“\contentsname”。 % \end{function} % -% \begin{function}{listfigurename} +% \begin{function}[EXP]{listfigurename} % \begin{syntax} % listfigurename = <名字> -% \OSET % \end{syntax} % 设置插图目录标题名 \tn{listfigurename}。中文默认为“\listfigurename”。 % \end{function} % -% \begin{function}{listtablename} +% \begin{function}[EXP]{listtablename} % \begin{syntax} % listtablename = <名字> -% \OSET % \end{syntax} % 设置表格目录标题名 \tn{listtablename}。中文默认为“\listtablename”。 % \end{function} % -% \begin{function}{figurename} +% \begin{function}[EXP]{figurename} % \begin{syntax} % figurename = <名字> -% \OSET % \end{syntax} % 设置图片环境标题名 \tn{figurename}。中文默认为“\figurename”。 % \end{function} % -% \begin{function}{tablename} +% \begin{function}[EXP]{tablename} % \begin{syntax} % tablename = <名字> -% \OSET % \end{syntax} % 设置表格环境标题名 \tn{tablename}。中文默认为“\tablename”。 % \end{function} % -% \begin{function}{abstractname} +% \begin{function}[EXP]{abstractname} % \begin{syntax} % abstractname = <名字> -% \OSET % \end{syntax} % 设置摘要 \env{abstract} 环境标题名 \tn{abstractname}。中文默认 % 为“\abstractname”。注意 \cls{book} 类没有摘要,该选项无效。 % \end{function} % -% \begin{function}{indexname} +% \begin{function}[EXP]{indexname} % \begin{syntax} % indexname = <名字> -% \OSET % \end{syntax} % 设置索引标题名 \tn{indexname}。中文默认为“\indexname”。 % \end{function} % -% \begin{function}{appendixname} +% \begin{function}[EXP]{appendixname} % \begin{syntax} % appendixname = <名字> -% \OSET % \end{syntax} % 设置附录标题名 \tn{appendixname}。中文默认为“\appendixname”。 % \end{function} % -% \begin{function}{bibname} +% \begin{function}[EXP]{bibname} % \begin{syntax} % bibname = <名字> -% \OSET % \end{syntax} % 设置参考文献标题名 \tn{refname}(对 \cls{article})或 \tn{bibname}(对 % \cls{report} 和 \cls{book})。中文默认为“\refname”。 @@ -1602,9 +1588,9 @@ This package consists of the file ctex.dtx, and the derived files % % 当使用了 \CTeX 的文档类或是用 \pkg{ctex} 宏包加载了 \opt{heading} 选项时,会 % 设置整个文档的页面格式(page style)为 |headings|,即相当于设置了 -% \begin{verbatim}[gobble=2] -% \pagestyle{headings} -% \end{verbatim} +% \begin{frameverb} +% \pagestyle{headings} +% \end{frameverb} % 在页眉中显示当前章节的编号与标题。 % % 同时,\CTeX 宏包也会对默认的 |headings| 页面格式进行修改,使之调用 @@ -1709,22 +1695,59 @@ This package consists of the file ctex.dtx, and the derived files % \changes{v2.0}{2015/03/21}{\tn{CTEXsetup}, \tn{CTEXoptions} 是过时命令。} % 章节标题的格式选项是分层设置的。顶层的选项是章节标题名称,次一级的选项是章节 % 标题的格式。章节标题名包括 |part|, |chapter|, |section|, |subsection|, -% |subsubsecton|, |paragraph|, |subparagraph|;而可用的格式包括 \opt{name}, -% \opt{number}, \opt{format}, \opt{nameformat}, \opt{numberformat}, -% \opt{aftername}, \opt{titleformat}, \opt{beforeskip}, \opt{afterskip}, -% \opt{indent}, \opt{pagestyle} 等。但注意,对 \cls{article} 及其衍生的 +% |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{indent}, +% \opt{pagestyle} 等。但注意,对 \cls{article} 及其衍生的 % \cls{ctexart} 等文档类,没有 |chapter| 级别的标题。 % % 多级选项之间用斜线分开,例如,\opt{part/name} 选项设置 \tn{part} 标题的在数 % 字前后的名称,而 \opt{section/number} 选项设置 \tn{section} 标题的数字类型。 % 注意斜线前后都不要有空格。 % -% \begin{function}{part/name, chapter/name, section/name, subsection/name, -% subsubsection/name, paragraph/name, subparagraph/name} +% 使用 \tn{ctexset} 设置多级选项时,可以在同一个上级选项下设置多个下级选项。 +% +% 例如,同时设置 |part| 一级标题的 \opt{pagestyle} 选项,|chapter| 一级标题的 +% \opt{format} 与 \opt{pagestyle} 选项和 |section| 一级标题的 \opt{name} 与 +% \opt{number} 选项: +% \begin{ctexexam} +% \ctexset { +% part/pagestyle = empty, +% chapter = { +% format = \raggedright, +% pagestyle = empty, +% }, +% section = { +% name = {第,节}, +% number = \chinese{section}, +% } +% } +% \end{ctexexam} +% +% \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}。 +% +% 我们知道,\LaTeX{} 带星号的章节标题命令(如 \tn{section*})不会对标题编号, +% 但也不会将该没编号的标题编入目录中。本选项控制的是不带星号的标题命令是否编号。 +% 设置本选项为 \opt{false},除了不对标题编号以外,功能与正常标题一致, +% 比如可以编目录,正确的 \pkg{hyperref} 目录超链接位置和页眉标记。 +% +% 注意,章节标题的编号深度受 \LaTeX{} 计数器 |secnumdepth| 的控制。 +% \opt{numbering} 选项在 |secnumdepth| 的控制下起作用。 +% \end{function} +% +% 如果没有特别说明,以下将用 “|...|” 代表各级章节标题名。 +% +% \begin{function}[EXP,updated=2014-03-08]{.../name} % \begin{syntax} % name = \{<前名字>,<后名字>\} % name = \Arg{前名字} -% \OSET % \end{syntax} % 设置章节的名字。名字可以分为前后两部分,即章节编号前后的词语,两个词之间用 % 一个半角逗号分开;也可以只有一部分,表示只有章节编号之前的名字。例如: @@ -1743,26 +1766,23 @@ This package consists of the file ctex.dtx, and the derived files % \caption{\opt{name} 选项的默认设置} % \begin{tabular}{llll} % \toprule -% 标题名 & \opt{scheme = chinese} & -% \opt{scheme = plain} & 注 \\ +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} & 注 \\ % \midrule % part & |{第,部分}| & |{\partname\space}| & 原 \tn{partname} 为 Part \\ % chapter & |{第,章}| & |{\chaptername\space}| % & 原 \tn{chaptername} 为 Chapter \\ -% section & |{}| & |{}| & \\ -% subsection & |{}| & |{}| & \\ -% subsubsection & |{}| & |{}| & \\ -% paragraph & |{}| & |{}| & \\ -% subparagraph & |{}| & |{}| & \\ +% section & 同右 & |{}| & \\ +% subsection & 同右 & |{}| & \\ +% subsubsection & 同右 & |{}| & \\ +% paragraph & 同右 & |{}| & \\ +% subparagraph & 同右 & |{}| & \\ % \bottomrule % \end{tabular} % \end{table} % -% \begin{function}{part/number, chapter/number, section/number, subsection/number, -% subsubsection/number, paragraph/number, subparagraph/number} +% \begin{function}[EXP]{.../number} % \begin{syntax} % number = \Arg{数字输出命令} -% \OSET % \end{syntax} % 设置章节编号的数字输出格式。\meta{数字输出命令} 通常是对应章节编号计数器的 % 输出命令,如 \tn{thesection} 或 |\chinese{chapter}| 之类。 @@ -1786,8 +1806,7 @@ This package consists of the file ctex.dtx, and the derived files % \setlength\leftskip{0pt plus 1 fil minus \marginparwidth} % \begin{tabular}{llll} % \toprule -% 标题名 & \opt{scheme = chinese} & -% \opt{scheme = plain} +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} % & 原 |\the|\meta{标题} 等价定义 \\ % \midrule % part & |\chinese{part}| & |\thepart| & |\Roman{part}| \\ @@ -1815,26 +1834,10 @@ This package consists of the file ctex.dtx, and the derived files % 节的完整编号。例如用于帮助定义自定义的目录格式、页眉格式等。 % \end{function} % -% 使用 \tn{ctexset} 设置多级选项时,可以在同一个上级选项下设置多个下级选项。例 -% 如同时设置 |section| 一级标题的 \opt{name} 与 \opt{number} 选项: -% \begin{ctexexam} -% \ctexset{ -% section = { -% name = {第,节}, -% number = \chinese{section} -% } -% } -% \end{ctexexam} -% -% -% \begin{function}{part/format, chapter/format, section/format, -% subsection/format, subsubsection/format, paragraph/format, -% subparagraph/format, -% .../format+} +% \begin{function}[EXP,updated=2015-06-30]{.../format, .../format+} % \begin{syntax} % format = \Arg{格式命令} % format+= \Arg{格式命令} -% \OSET % \end{syntax} % \opt{format} 选项用于控制章节标题的全局格式,作用域为章节名字和随后的标题 % 内容。可以用于控制章节标题的对齐方式、整体字体字号等格式。 @@ -1842,25 +1845,24 @@ This package consists of the file ctex.dtx, and the derived files % 带加号的 \opt{format+} 选项则用于在已有格式之后追加新的格式命令。 % % 例如,设置章格式为无衬线字体左对齐,为节格式增加无衬线字体设置: +% \end{function} % \begin{ctexexam} % \ctexset{ -% chapter/format=\sffamily\raggedright, -% section/format+=\sffamily +% chapter/format = \sffamily\raggedright, +% section/format+ = \sffamily % } % \end{ctexexam} -% \end{function} % % \begin{table}[htbp] % \small\centering % \caption{\opt{format} 选项的默认设置} % \begin{tabular}{lll} % \toprule -% 标题名 & \opt{scheme = chinese} & -% \opt{scheme = plain} \\ +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ % \midrule -% part (article) & |\centering| & |\raggedright| \\ -% part & 同右 & |\centering| \\ -% chapter & |\centering| & |\raggedright| \\ +% part (article) & |\Large\bfseries\centering| & |\raggedright| \\ +% part & |\huge\bfseries\centering| & |\centering| \\ +% chapter & |\huge\bfseries\centering| & |\raggedright| \\ % section & |\Large\bfseries\centering| & |\Large\bfseries| \\ % subsection & 同右 & |\large\bfseries| \\ % subsubsection & 同右 & |\normalsize\bfseries| \\ @@ -1870,14 +1872,10 @@ This package consists of the file ctex.dtx, and the derived files % \end{tabular} % \end{table} % -% \begin{function}{part/nameformat, chapter/nameformat, section/nameformat, -% subsection/nameformat, subsubsection/nameformat, paragraph/nameformat, -% subparagraph/nameformat, -% .../nameformat+} +% \begin{function}[EXP,updated=2015-06-30]{.../nameformat, .../nameformat+} % \begin{syntax} % nameformat = \Arg{格式命令} % nameformat+= \Arg{格式命令} -% \OSET % \end{syntax} % \opt{nameformat} 用于控制章节名字的格式,作用域为章节名字,包括编号。它一 % 般用于章节名(包括编号)与章节标题的字体、字号等设置不一致的情形。参见 @@ -1887,6 +1885,8 @@ This package consists of the file ctex.dtx, and the derived files % % \opt{nameformat} 选项的最后一个格式命令可以是一个有一个参数的命令。 % 这个命令的参数用于接受章节名字和编号,实现特殊效果(见例~\ref{exam:miscopt})。 +% +% \opt{nameformat} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 % \end{function} % % \begin{table}[htbp] @@ -1894,12 +1894,11 @@ This package consists of the file ctex.dtx, and the derived files % \caption{\opt{nameformat} 选项的默认设置} % \begin{tabular}{lll} % \toprule -% 标题名 & \opt{scheme = chinese} & -% \opt{scheme = plain} \\ +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ % \midrule -% part (article) & 同右 & |\Large\bfseries| \\ -% part & 同右 & |\huge\bfseries| \\ -% chapter & 同右 & |\huge\bfseries| \\ +% part (article) & |{}| & |\Large\bfseries| \\ +% part & |{}| & |\huge\bfseries| \\ +% chapter & |{}| & |\huge\bfseries| \\ % section & 同右 & |{}| \\ % subsection & 同右 & |{}| \\ % subsubsection & 同右 & |{}| \\ @@ -1909,14 +1908,10 @@ This package consists of the file ctex.dtx, and the derived files % \end{tabular} % \end{table} % -% \begin{function}{part/numberformat, chapter/numberformat, -% section/numberformat, subsection/numberformat, subsubsection/numberformat, -% paragraph/numberformat, subparagraph/numberformat, -% .../numberformat+} +% \begin{function}[EXP,updated=2015-06-19]{.../numberformat, .../numberformat+} % \begin{syntax} % numberformat = \Arg{格式命令} % numberformat+= \Arg{格式命令} -% \OSET % \end{syntax} % \opt{numberformat} 选项用于控制章节编号的格式,作用域仅为编号数字本身。对 % 各级标题默认均为空,当你需要编号的格式和前后的章节名字不一样时可以使用。 @@ -1939,14 +1934,10 @@ This package consists of the file ctex.dtx, and the derived files % \huge\bfseries 第 \textit{\color{blue}\zihao{0}4} 章 % \end{center} % -% \begin{function}{part/aftername, chapter/aftername, section/aftername, -% subsection/aftername, subsubsection/aftername, paragraph/aftername, -% subparagraph/aftername, -% .../aftername+} +% \begin{function}[EXP,updated=2014-03-08]{.../aftername, .../aftername+} % \begin{syntax} % aftername = \Arg{代码} % aftername+= \Arg{代码} -% \OSET % \end{syntax} % \opt{aftername} 选项的参数 \meta{代码} 将被插入到章节编号与其后的标题内容之 % 间,用于控制格式变换。常用于控制章节编号与标题内容之间的距离,或者控制标题 @@ -1960,8 +1951,7 @@ This package consists of the file ctex.dtx, and the derived files % \caption{\opt{aftername} 选项的默认设置} % \begin{tabular}{lll} % \toprule -% 标题名 & \opt{scheme = chinese} & -% \opt{scheme = plain} \\ +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ % \midrule % part (article) & |\quad| & |\par\nobreak| \\ % part & 同右 & |\par\vskip 20pt| \\ @@ -1975,14 +1965,10 @@ This package consists of the file ctex.dtx, and the derived files % \end{tabular} % \end{table} % -% \begin{function}{part/titleformat, chapter/titleformat, section/titleformat, -% subsection/titleformat, subsubsection/titleformat, paragraph/titleformat, -% subparagraph/titleformat, -% .../titleformat+} +% \begin{function}[EXP,updated=2015-06-30]{.../titleformat, .../titleformat+} % \begin{syntax} % titleformat = \Arg{格式命令} % titleformat+= \Arg{格式命令} -% \OSET % \end{syntax} % \opt{titleformat} 选项用于控制标题内容的格式,作用域为章节标题内容。 % @@ -2017,12 +2003,11 @@ This package consists of the file ctex.dtx, and the derived files % \caption{\opt{titleformat} 选项的默认设置} % \begin{tabular}{lll} % \toprule -% 标题名 & \opt{scheme = chinese} & -% \opt{scheme = plain} \\ +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ % \midrule -% part (article) & |\Large\bfseries| & |\huge\bfseries| \\ -% part & |\huge\bfseries| & |\Huge\bfseries| \\ -% chapter & |\huge\bfseries| & |\Huge\bfseries| \\ +% part (article) & |{}| & |\huge\bfseries| \\ +% part & |{}| & |\Huge\bfseries| \\ +% chapter & |{}| & |\Huge\bfseries| \\ % section & 同右 & |{}| \\ % subsection & 同右 & |{}| \\ % subsubsection & 同右 & |{}| \\ @@ -2032,109 +2017,157 @@ This package consists of the file ctex.dtx, and the derived files % \end{tabular} % \end{table} % -% \begin{function}{part/aftertitle, chapter/aftertitle, section/aftertitle, -% subsection/aftertitle, subsubsection/aftertitle, paragraph/aftertitle, -% subparagraph/aftertitle, -% .../aftertitle+} +% \begin{function}[EXP,added=2015-06-19]{.../aftertitle, .../aftertitle+} % \begin{syntax} % aftertitle = \Arg{代码} % aftertitle+= \Arg{代码} -% \OSET % \end{syntax} % \opt{aftertitle} 选项的参数 \meta{代码} 将被插入到章节标题内容之后。 -% 可用于控制标题内容结束后是否另起一段。 % % \opt{aftertitle+} 选项用于在原有代码后面附加代码。 % % \opt{aftertitle} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 % -% 使用 \opt{sub3section} 或 \opt{sub4section} 宏包选项(见 -% \ref{subs:options-heading}~节)后,\tn{paragraph} 与 \tn{subparagraph} -% 这两级标题会改为排在不同段,会影响 \opt{aftertitle} 选项的默认值。 +% \opt{sub3section} 或 \opt{sub4section} 宏包选项(见 +% \ref{subs:options-heading}~节)会影响 \opt{aftertitle} 选项的默认值。 % \end{function} % -% \begin{function}{part/beforeskip, chapter/beforeskip, section/beforeskip, -% subsection/beforeskip, subsubsection/beforeskip, paragraph/beforeskip, -% subparagraph/beforeskip} +% \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} +% \end{table} +% +% \begin{function}[EXP,added=2015-06-27]{section/runin, subsection/runin, +% subsubsection/runin, paragraph/runin, subparagraph/runin} % \begin{syntax} -% beforeskip = \Arg{弹性间距} -% \OSET +% runin = \TF +% \end{syntax} +% \opt{runin} 选项只对 \tn{section} 级以下标题有意义。 +% 用于确定标题与随后的正文是否排在同一段之上。 +% +% \opt{runin} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 +% +% 默认情况下,\tn{paragraph}、\tn{subparagraph} 两级标题是与后面正文排在同一 +% 段的,\opt{runin} 选项为 \opt{true};但使用 \opt{sub3section} 或 +% \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)后, +% 将对这两级标题设 \opt{runin} 选项为 \opt{false},这两级标题会改为排在不同段。 +% \end{function} +% +% \begin{function}[EXP,added=2015-06-27]{.../afterindent} +% \begin{syntax} +% afterindent = \TF % \end{syntax} -% \opt{beforeskip} 选项用于设置章节标题前的垂直间距及章节标题后首段的缩进。 +% \opt{afterindent} 选项用于设置章节标题后首段的缩进。 % -% \meta{弹性间距} 的绝对值被用于设置标题间的垂直间距,而 \meta{弹性间距} 的正 -% 负号用于设置标题后第一段的首行缩进。当参数是负值时,章节标题后的第一段按英 -% 文文档的排版习惯,没有首行缩进;参数是正值时,则保留首行缩进。 +% \cls{book} 和 \cls{report} 类的 \tn{part} 标题被单独排在一页之上, +% \opt{afterindent} 选项没有意义。 % -% 使用 \opt{sub3section} 或 \opt{sub4section} 宏包选项(见 -% \ref{subs:options-heading}~节)后,\tn{paragraph} 与 \tn{subparagraph} -% 这两级标题会改为排在不同段,会影响 \opt{beforeskip} 选项的默认值。 +% 对于 \tn{section} 级以下标题,若设置了 \opt{runin} 选项为 \opt{true}, +% 即标题与随后正文排在同一段,\opt{afterindent} 选项也就没有了意义。 % \end{function} % % \begin{table}[htbp] % \small\centering -% \caption{\opt{beforeskip} 选项的默认设置} +% \caption{\opt{afterindent} 选项的默认设置} % \begin{tabular}{lll} % \toprule -% 标题名 & \opt{scheme = chinese} & -% \opt{scheme = plain} \\ +% 标题名 & \opt{scheme = chinese} & \opt{scheme = plain} \\ % \midrule -% part (article) & |4ex| & |-4ex| \\ +% part (article) & |true| & |false| \\ % part & 无效 & 无效 \\ -% chapter & |50pt| & |-50pt| \\ -% section & |3.5ex plus 1ex minus .2ex| & |-3.5ex plus -1ex minus -.2ex| \\ -% subsection & |3.25ex plus 1ex minus .2ex| & |-3.25ex plus -1ex minus -.2ex| \\ -% subsubsection & |3.25ex plus 1ex minus .2ex| & |-3.25ex plus -1ex minus -.2ex| \\ -% paragraph & 同右 & |3.25ex plus 1ex minus .2ex| \\ -% \qquad(sub3section) & |3.25ex plus 1ex minus .2ex| & |-3.25ex plus -1ex minus -.2ex| \\ -% \qquad(sub4section) & 同上 & 同上 \\ -% subparagraph & 同右 & |3.25ex plus 1ex minus .2ex| \\ -% \qquad(sub4section) & |3.25ex plus 1ex minus .2ex| & |-3.25ex plus -1ex minus -.2ex| \\ +% 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}{part/afterskip, chapter/afterskip, section/afterskip, -% subsection/afterskip, subsubsection/afterskip, paragraph/afterskip, -% subparagraph/afterskip} +% \begin{function}[EXP,updated=2015-06-27]{.../beforeskip} % \begin{syntax} -% afterskip = \Arg{弹性间距} -% \OSET +% beforeskip = \Arg{弹性间距} % \end{syntax} -% \opt{afterskip} 选项控制章节标题与后面下方之间的距离。\meta{弹性间距} 的正 -% 负号确定标题与后面正文是否排在同一段。如果是正值则正文另起一段,\meta{弹性 -% 间距} 给出垂直间距;如果是负值则章节标题与正文第一段排在同一段,\meta{弹性 -% 间距} 的绝对值给出水平间距。 +% \opt{beforeskip} 选项用于设置章节标题前的垂直间距。 % -% 默认情况下,\tn{paragraph}、\tn{subparagraph} 两级标题是与后面正文排在同一 -% 段的,\opt{afterskip} 选项取负数;但使用 \opt{sub3section} 或 -% \opt{sub4section} 宏包选项(见 \ref{subs:options-heading}~节)后,则这 -% 两级标题会改为排在不同段。 -% -% \opt{afterskip} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 +% \opt{beforeskip} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 % \end{function} % % \begin{table}[htbp] -% \begin{minipage}[t]{.5\linewidth} % \small\centering -% \caption{\opt{aftertitle} 选项的默认设置} +% \caption{\opt{beforeskip} 选项的默认设置} % \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| \\ +% part (article) & |4ex| \\ +% part & |0pt plus 1fil| \\ +% chapter & |50pt| \\ +% section & |3.5ex plus 1ex minus .2ex| \\ +% 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}% +% \end{table} +% +% \begin{function}[EXP,updated=2015-06-27]{.../afterskip} +% \begin{syntax} +% afterskip = \Arg{弹性间距} +% \end{syntax} +% \opt{afterskip} 选项控制章节标题与后面下方之间的距离。 +% +% 对于 \tn{section} 级以下标题,\opt{runin} 选项会影响 \opt{afterskip} 选项的意义: +% 若 \opt{runin} 为 \opt{true},标题与随后正文排在同一段,\meta{弹性间距} 给出水平间距。 +% 否则,正文另起一段,\meta{弹性间距} 给出的是垂直间距。 +% +% \opt{afterskip} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 +% +% \opt{sub3section} 或 \opt{sub4section} 宏包选项(见 +% \ref{subs:options-heading}~节)会影响 \opt{aftertitle} 选项的默认值。 +% \end{function} +% +% \begin{table}[htbp] % \begin{minipage}[t]{.5\linewidth} % \small\centering % \caption{\opt{afterskip} 选项的默认设置} @@ -2143,33 +2176,51 @@ This package consists of the file ctex.dtx, and the derived files % 标题名 & 默认值 \\ % \midrule % part (article) & |3ex| \\ -% part & 无效 \\ +% part & |0pt plus 1fil| \\ % chapter & |40pt| \\ % section & |2.3ex plus .2ex| \\ % subsection & |1.5ex plus .2ex| \\ % subsubsection & |1.5ex plus .2ex| \\ -% paragraph & |-1em| \\ +% paragraph & |1em| \\ % \qquad(sub3section) & |1ex plus .2ex| \\ % \qquad(sub4section) & 同上 \\ -% subparagraph & |-1em| \\ +% subparagraph & |1em| \\ % \qquad(sub4section) & |1ex plus .2ex| \\ % \bottomrule % \end{tabular} % \end{minipage}% +% \begin{minipage}[t]{.5\linewidth} +% \small\centering +% \caption{\opt{indent} 选项的默认设置} +% \begin{tabular}{ll} +% \toprule +% 标题名 & 默认值 \\ +% \midrule +% part (article) & |0pt| \\ +% part & 无效 \\ +% 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}{part/indent, chapter/indent, section/indent, -% subsection/indent, subsubsection/indent, paragraph/indent, -% subparagraph/indent} +% \begin{function}[EXP,updated=2015-06-27]{.../indent} % \begin{syntax} % indent = \Arg{缩进间距} -% \OSET % \end{syntax} % \opt{indent} 选项用于设置章节标题本身的首行缩进。 % % \opt{indent} 选项的默认值,在 \opt{scheme} 选项的不同取值下相同。 -% \end{function} % +% 例如,设置 \tn{section} 标题缩进 \SI{20}{pt}: +% \end{function} % \begin{ctexexam} % \ctexset{section={ % format=\Large\bfseries, @@ -2180,28 +2231,15 @@ This package consists of the file ctex.dtx, and the derived files % \noindent 无缩进的正文。 % \end{ctexexam} % +% \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)。 +% \end{function} +% % \begin{table}[htbp] -% \begin{minipage}[t]{.5\linewidth} -% \small\centering -% \caption{\opt{indent} 选项的默认设置} -% \begin{tabular}{ll} -% \toprule -% 标题名 & 默认值 \\ -% \midrule -% part (article) & |0pt| \\ -% part & 无效 \\ -% chapter & |0pt| \\ -% section & |0pt| \\ -% subsection & |0pt| \\ -% subsubsection & |0pt| \\ -% paragraph & |0pt| \\ -% subparagraph & |\parindent| \\ -% \qquad(sub3section) & |0pt| \\ -% \qquad(sub4section) & |0pt| \\ -% \bottomrule -% \end{tabular} -% \end{minipage}% -% \begin{minipage}[t]{.5\linewidth} % \small\centering % \caption{\opt{pagestyle} 选项的默认设置} % \begin{tabular}{ll} @@ -2213,26 +2251,27 @@ This package consists of the file ctex.dtx, and the derived files % chapter & |plain| \\ % \bottomrule % \end{tabular} -% \end{minipage}% % \end{table} % -% \begin{function}{part/pagestyle, chapter/pagestyle} +% \begin{function}[EXP,added=2015-06-21]{appendix/numbering} % \begin{syntax} -% pagestyle = \Arg{页面格式} -% \OSET +% numbering = \TTF % \end{syntax} -% 设置 \cls{book}/\cls{ctexbook} 或 \cls{report}/\cls{ctexrep} 文档类 -% 中,\tn{part} 与 \tn{chapter} 标题所在页的页面格式(page style)。 +% 控制是否对附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article}) +% 进行编号。 +% +% 用法与普通章节 \opt{numbering} 选项类似。 % \end{function} % -% \begin{function}{appendix/name} +% \begin{function}[updated=2014-03-08]{appendix/name} % \begin{syntax} % name = \{<前名字>,<后名字>\} % name = \Arg{前名字} -% \OSET % \end{syntax} % 设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article})的 -% 名字。用法与普通章节 \opt{name} 选项类似。 +% 名字。 +% +% 用法与普通章节 \opt{name} 选项类似。 % % 注意该选项与 \opt{appendixname} 选项(\ref{subs:capname}~节)在意义上有 % 些重叠,但意义不同。\opt{appendixname} 选项只用来重定义 @@ -2255,13 +2294,14 @@ This package consists of the file ctex.dtx, and the derived files % \end{tabular} % \end{table} % -% \begin{function}{appendix/number} +% \begin{function}[EXP]{appendix/number} % \begin{syntax} % number = \Arg{数字输出命令} -% \OSET % \end{syntax} % 设置附录章(对 \cls{book} 与 \cls{report})或附录节(对 \cls{article})编 -% 号的数字输出格式。用法与普通章节的 \opt{number} 选项类似。 +% 号的数字输出格式。 +% +% 用法与普通章节的 \opt{number} 选项类似。 % % 该选项也同时控制附录章节计数器的交叉引用。 % @@ -2287,12 +2327,11 @@ This package consists of the file ctex.dtx, and the derived files % \begin{ctexexam}[labelref=exam:miscopt] % \ctexset { % chapter = { -% format = \Huge\bfseries, -% nameformat = \hrule height 1bp \relax\bigskip\hfill\chapternamebox, -% number = \arabic{chapter}, -% aftername = \par\medskip, -% titleformat = {}, -% aftertitle = \bigskip\hrule height 2bp \relax +% format = \Huge\bfseries, +% nameformat = \hrule height 1bp \relax\bigskip\hfill\chapternamebox, +% number = \arabic{chapter}, +% aftername = \par\medskip, +% aftertitle = \bigskip\hrule height 2bp \relax % } % } % \newcommand\chapternamebox[1]{% @@ -2316,15 +2355,15 @@ This package consists of the file ctex.dtx, and the derived files % \label{sec:useful-commands} % \subsection{字号与间距} % -% \begin{function}{\zihao} +% \begin{function}[updated=2014-03-08]{\zihao} % \begin{syntax} -% \tn{zihao}\Arg{字号} +% \tn{zihao} \Arg{字号} % \end{syntax} % 用于调整字号大小。其中 \meta{字号} 的有效值共有 16 个,如表 \ref{tab:zihao} % 所示。使用 \tn{zihao} 命令调整字体大小时,西文字号大小会始终和中文字号保持一致。 % \end{function} % -% \begin{table}[htbp] +% \begin{table}[!htbp] % \centering % \def\ZH#1{\zihaopt{#1} & \zihao{#1}} % \tabcolsep=1em @@ -2354,9 +2393,9 @@ This package consists of the file ctex.dtx, and the derived files % \end{tabular} % \end{table} % -% \begin{function}{\ziju} +% \begin{function}[updated=2014-03-28]{\ziju} % \begin{syntax} -% \tn{ziju}\Arg{中文字符宽度的倍数} +% \tn{ziju} \Arg{中文字符宽度的倍数} % \end{syntax} % 用于调整相邻汉字之间的间距,即(在正常中文行文中)前一个汉字的右边缘与后一个汉字 % 的左边缘之间的距离。其中参数可以是任意浮点数值;而中文字符宽度指的是实际汉字的 @@ -2365,22 +2404,17 @@ This package consists of the file ctex.dtx, and the derived files % 这个命令会影响 \tn{ccwd} 的值,但不会影响英文字距。 % \end{function} % -% \begin{function}{\ccwd} +% \begin{function}[updated=2014-03-27]{\ccwd} % 当前汉字的字宽保存在长度寄存器 \tn{ccwd} 之中。汉字字宽是相邻两个汉字中心 % 之间的距离,包含字距在内。因此修改字距会间接修改字宽。 % \end{function} % -% \begin{function}{\CTEXsetfont} -% 更新当前的中文字体信息,包括当前字距(\tn{ccwd})和段首缩进(\tn{parindent})。 -% 一般来说,用户无需使用这个命令。 -% \end{function} -% % \subsection{中文数字转换} % % \CTeX{} 宏集的中文数字转换功能实际上是调用 \pkg{zhnumber} 宏包来完成。下面只 % 介绍一些基本的用法,更高级的用法可以查阅 \pkg{zhnumber} 宏包的文档。 % -% \begin{function}{\chinese} +% \begin{function}[updated=2014-03-08]{\chinese} % \begin{syntax} % \tn{chinese} \Arg{counter} % \end{syntax} @@ -2388,14 +2422,14 @@ This package consists of the file ctex.dtx, and the derived files % 计数器上,将计数器的值以中文数字的形式输出。 % \end{function} % -% \begin{function}{\zhnumber} +% \begin{function}[added=2014-03-08]{\zhnumber} % \begin{syntax} % \tn{zhnumber} \Arg{number} % \end{syntax} % 以中文格式输出数字。这里的数字可以是整数、小数和分数。 % \end{function} % -% \begin{function}{\zhdigits} +% \begin{function}[added=2014-03-08]{\zhdigits} % \begin{syntax} % \tn{zhdigits} \Arg{number} % \end{syntax} @@ -2444,7 +2478,7 @@ This package consists of the file ctex.dtx, and the derived files % % \subsection{\LuaLaTeX{} 下替代字体的设置} % -% \begin{function}{AlternateFont} +% \begin{function}[added=2014-04-14]{AlternateFont} % \begin{syntax} % \tn{setCJKfamilyfont} \Arg{family} % \ [ @@ -2461,7 +2495,7 @@ This package consists of the file ctex.dtx, and the derived files % \meta{character range_n} 内,对应字形的替代字体。 % \end{function} % -% \begin{function}{CharRange} +% \begin{function}[added=2014-04-14]{CharRange} % \begin{syntax} % \tn{setCJKfamilyfont} \Arg{family} % \ [ @@ -2482,7 +2516,7 @@ This package consists of the file ctex.dtx, and the derived files % \setCJKmainfont[CharRange={"6800->"9FFF}, ...]{...} % \end{ctexexam} % -% \begin{function}{declarecharrange} +% \begin{function}[EXP,added=2014-04-14]{declarecharrange} % \begin{syntax} % \tn{ctexset} % \ \{ @@ -2508,7 +2542,7 @@ This package consists of the file ctex.dtx, and the derived files % 一起使用。如果没有给 \meta{name} 设置值,则等价于设置 \opt{CharRange=\meta{name}}, % 即只设置 \meta{name} 对应的字符范围的替代字体。 % -% \begin{function}{clearalternatefont,resetalternatefont} +% \begin{function}[EXP,added=2014-04-15]{clearalternatefont,resetalternatefont} % \begin{syntax} % \tn{ctexset} % \ \{ @@ -2538,12 +2572,12 @@ This package consists of the file ctex.dtx, and the derived files % 与本机不同。 % \end{itemize} % -% 与 \CTeX{} 宏集的源代码一样,配置文件采用 \LaTeX3 的语法编写。 +% 与 \CTeX{} 宏集的源代码一样,配置文件采用 \LaTeXiii{} 的语法编写。 % % \CTeX{} 宏集的配置文件随宏包其他文件一起安装在 \TeX{} 系统 TDS 目录树中,文 % 件后缀是 \file{.cfg}。为了避免本地配置文件内容因 \CTeX{} 宏集的更新而丢失, % 不要直接修改系统 TDS 目录树中的配置文件,而应该将系统自带的配置文件复制到本 -% 地的或用户私有的 TDS 目录树中修改,并运行 |texhash| 命令刷新文件名数据库。 +% 地的或用户私有的 TDS 目录树中修改,并运行 \bashcmd{texhash} 命令刷新文件名数据库。 % % 例如对于 \TeX{} Live,系统自带的配置文件就在 \TeX{} Live 安装目录下的 % \path{texmf-dist/tex/latex/ctex/config/} 子目录下,可以修改它的副本,保存在 @@ -2551,8 +2585,8 @@ This package consists of the file ctex.dtx, and the derived files % \path{~/.texlive2015/texmf-var/tex/latex/ctex/} 目录下,作为本地/用户专有的 % 配置文件。复制配置文件后需要运行 |texhash| 命令使本地配置文件生效。 % -% \hologo{MiKTeX} 的配置文件也保存在类似的目录结构中,\hologo{MiKTeX} 管理的 -% 几个 TDS 根目录可以在 \hologo{MiKTeX} Options 设置项中查看到,这里不再赘述。 +% \MiKTeX{} 的配置文件也保存在类似的目录结构中,\MiKTeX{} 管理的 +% 几个 TDS 根目录可以在 \MiKTeX{} Options 设置项中查看到,这里不再赘述。 % % 除了修改本地 \TeX{} 系统中的配置文件,对于特定文档,也可以将修改过的配置文件 % 保存在文档的工作目录下。此时配置文件就只对工作目录下的所有文档生效。 @@ -2568,7 +2602,7 @@ This package consists of the file ctex.dtx, and the derived files % % 该设置可以用在安装了 Windows 字体的非 Windows 系统中。 % \keys_set:nn { ctex / option } { fontset = windowsnew } % \end{ctexexam} -% 如上例所示,宏包选项通常使用 \LaTeX3 的 \cs{keys_set:nn} 命令完成键值设置, +% 如上例所示,宏包选项通常使用 \LaTeXiii{} 的 \cs{keys_set:nn} 命令完成键值设置, % 第一个参数是固定的子模块 |ctex/option|,第二个参数中是用户定义的新的默认宏包 % 选项。 % @@ -2579,7 +2613,7 @@ This package consists of the file ctex.dtx, and the derived files % % 配置文件 \file{ctex.cfg} 将在宏包的末尾被载入生效。可以用它完成任意的设置, % 或是覆盖已有的定义。随系统安装的配置文件除版本信息外没有实际内容,注意配置文 -% 件中也使用 \LaTeX3 语法。 +% 件中也使用 \LaTeXiii{} 语法。 % % \begin{ctexexam} % % 简单的 ctex.cfg 内容示例。 @@ -2652,14 +2686,11 @@ This package consists of the file ctex.dtx, and the derived files % \end{function} % % \begin{function}{indent, noindent} -% \opt{indent} 什么也不做,\pkg{ctex} 宏包的相关功能在与标准文档类及其衍生 -% 文档类联用时默认打开;\CTeX{} 文档类的相关功能由章节 -% \opt{beforeskip} 选项的值来确定。过时选项。 -% -% \opt{noindent} 什么也不做,也不会使章节首行停止缩进。需要使用 \tn{ctexset} -% 命令设置章节的 \opt{beforeskip} 选项为正数才能完成原来 \opt{noindent} 选项的 -% 工作。另外,设置 \opt{scheme = plain} 可以保持原有英文文档类的效果,使章节首行停止缩 -% 进。过时选项。 +% \opt{indent} 和 \opt{noindent} 什么也不做,过时选项。 +% +% 在中文版式下,\pkg{ctex} 宏包的相关功能在与标准文档类及其衍生文档类联用时 +% 默认打开。\CTeX{} 文档类的相关功能由章节标题的 \opt{afterindent} 选项的值 +% 来确定。 % \end{function} % % \begin{function}{zhmap, nozhmap} @@ -2735,6 +2766,11 @@ This package consists of the file ctex.dtx, and the derived files % 在新版本中,上述由 \opt{fntef} 衍生的相关宏都成为过时命令。 % \end{function} % +% \begin{function}{\CTEXsetfont} +% 更新当前的中文字体信息,包括当前字距(\tn{ccwd})和段首缩进(\tn{parindent})。 +% 一般来说,用户无需使用这个命令。 +% \end{function} +% % \begin{function}{\CTEXindent} % 更新 \tn{ccwd} 宽度后设置 |\parindent=2\ccwd|。过时命令。 % \end{function} @@ -2781,7 +2817,6 @@ This package consists of the file ctex.dtx, and the derived files % \end{ctexexam} % \end{function} % -% % \subsection{\CTeX\ 1.02c 以后的 SVN 开发版} % % \CTeX 宏包在 1.02c 版本(2011/03/11)之后在 Google code 上的 SVN 开发版本, @@ -2790,6 +2825,105 @@ This package consists of the file ctex.dtx, and the derived files % % \CTeX 宏包第 2 版不保证对未发布的 SVN 开发版兼容。 % +% \subsection{\CTeX\ 2.2 之前的版本} +% +% \begin{function}{part/beforeskip, chapter/beforeskip, section/beforeskip, +% subsection/beforeskip, subsubsection/beforeskip, paragraph/beforeskip, +% subparagraph/beforeskip} +% 在 \CTeX\ 2.2 之前的版本中,\opt{beforeskip} 选项的符号还用于确定章节标题后 +% 首段的缩进。当 \opt{beforeskip} 是负值时,章节标题后的第一段按英文文档的排版 +% 习惯,没有首行缩进,否则保留首行缩进。 +% +% 这一特性在 2.2 版和后续版本中不再保留,相应的功能通过新的 \opt{afterindent} +% 选项来设置。如果原先设置 \opt{beforeskip} 为负值,在新版本中需要改为正值, +% 并设置相应的 \opt{afterindent} 选项为 \opt{false}。 +% \end{function} +% +% \begin{function}{section/afterskip, subsection/afterskip, +% subsubsection/afterskip, paragraph/afterskip, subparagraph/afterskip} +% 在 \CTeX\ 2.2 之前的版本中,对于 \tn{section} 级以下标题,\opt{afterskip} +% 选项的符号用于确定标题与随后正文是否排在同一段。 +% 如果是正值,则正文另起一段,否则标题与随后正文排在同一段, +% \opt{afterskip} 的绝对值给出水平间距。 +% +% 这一特性在 2.2 版和后续版本中不再保留,相应的功能通过新的 \opt{runin} +% 选项来设置。如果原先设置 \opt{afterskip} 为负值,在新版本中需要改为正值, +% 并设置相应的 \opt{runin} 选项为 \opt{true}。 +% \end{function} +% +% \section{宏集依赖情况与手工安装方法} +% \label{sec:dep-ins} +% +% 本节介绍 \CTeX{} 宏集的依赖情况,并介绍手工编译安装的具体方法。 +% 通常用户只需参照第 \ref{subsec:easy-ins}~节介绍的方法,使用发行版自带的宏包管理器安装 +% 本宏集。 +% +% \CTeX{} 宏集有两个源文件:\file{ctex.dtx}、\file{ctexpunct.spa}。 +% 使用不同的编译方式时,\CTeX{} 依赖的宏包略有不同。在手工安装 \CTeX{} 宏集之前,请确保 +% 你的 \TeX{} 发行版中已经正确安装了这些宏包。\CTeX{} 依赖宏包的详情叙述如下: +% +% \begin{itemize} +% \item \pkg{expl3}、\pkg{xparse} 和 \pkg{l3keys2e} 宏包。它们属于 \pkg{l3kernel} +% 和 \pkg{l3packages} 宏集,它们还依赖 +% \begin{itemize} +% \item \pkg{etex} 宏包。 +% \end{itemize} +% \item \pkg{indentfirst} 宏包,属于 \pkg{tools} 宏集。 +% \item \pkg{everysel} 宏包,属于 \pkg{ms} 宏集。 +% \item \pkg{zhnumber} 宏包。 +% \item[\ding{229}] 以上是各种编译方式都必需的依赖项。 +% \item \pkg{CJK} 宏集,它的下划线功能依赖 \pkg{ulem} 宏包。 +% \item \pkg{CJKpunct} 宏包。 +% \item \pkg{xCJK2uni} 宏包。 +% \item \pkg{zhmetrics} 宏包。 +% \item \pkg{zhmCJK} 宏包。 +% \item[\ding{229}] 以上是使用 \pdfLaTeX{} 或 \LaTeX{} + \dvipdfmx{} 的编译方式所需要 +% 的依赖项,其中 \pkg{zhmCJK} 是可选的。 +% \item \pkg{xeCJK} 宏包,它还依赖 +% \begin{itemize} +% \item \pkg{fontspec} 宏包,它还依赖 +% \begin{itemize} +% \item \pkg{euenc} 宏包。 +% \item \pkg{xunicode} 宏包,它还依赖 \pkg{tipa} 宏包。 +% \end{itemize} +% \end{itemize} +% \item[\ding{229}] 以上是使用 \XeLaTeX{} 编译时的依赖项。 +% \item \pkg{LuaTeX-ja} 宏集,它还依赖 +% \begin{itemize} +% \item \pkg{oberdiek} 宏集。 +% \item \pkg{xkeyval} 宏包。 +% \item \pkg{lualibs} 宏包。 +% \item \pkg{luaotfload} 宏包,它还依赖 \pkg{luatexbase} 宏包。 +% \end{itemize} +% \item[\ding{229}] 以上是使用 \LuaLaTeX{} 编译时的依赖项。 +% \end{itemize} +% +% 出于一些原因,\pkg{zhmCJK} 尚未被收入 \TeXLive{} 和 \MiKTeX。因此,若 +% 你希望使用 \pkg{zhmCJK} 作为 \CTeX{} 宏集的底层中文支持方式,那么你需要自行安装该宏包。 +% \pkg{zhmCJK} 的安装较为复杂。我们建议你 +% \begin{enumerate} +% \item 从 CTAN 下载 \pkg{zhmCJK} 宏包的 +% \href{http://mirrors.ctan.org/install/language/chinese/zhmcjk.tds.zip} +% {TDS 安装包}, +% \item 按目录结构将文件复制到 \TeX{} 发行版的本地 TDS 根目录, +% \item 最后执行 \bashcmd{texhash} 刷新 \TeX{} 发行版的 ls-R 数据库以完成安装。 +% \end{enumerate} +% 其他细节,可参照其 +% \href{http://mirrors.ctan.org/language/chinese/zhmcjk/zhmCJK.pdf}{宏包手册} +% 中第 3 节的指导。 +% +% \emph{\CTeX{} 宏集已被 \TeXLive{} 和 \MiKTeX{} 收录,若无特别理由, +% 我们强烈建议用户使用宏包管理器安装本宏集。} +% +% 若要手工安装,请遵循如下步骤: +% \begin{enumerate} +% \item 从 CTAN 下载 \CTeX{} 宏集的 +% \href{http://mirrors.ctan.org/install/language/chinese/ctex.tds.zip} +% {TDS 安装包}, +% \item 按目录结构将文件复制到 \TeX{} 发行版的本地 TDS 根目录, +% \item 最后执行 \bashcmd{texhash} 刷新 \TeX{} 发行版的 ls-R 数据库以完成安装。 +% \end{enumerate} +% % \section{开发人员} % % \begin{itemize} @@ -2803,6 +2937,9 @@ This package consists of the file ctex.dtx, and the derived files % \item 黄晨成 (\email{liamhuang0205@gmail.com}) % \end{itemize} % +% 目前比较活跃的开发维护人员是刘海洋、李清和黄晨成。 +% +% % \begin{thebibliography}{9} % \bibitem{knuthtex1986} % \textsc{Donald~Ervin Knuth}. @@ -2832,14 +2969,6 @@ This package consists of the file ctex.dtx, and the derived files %<@@=ctex> % \end{macrocode} % -% \pkg{ctexcap} 是默认打开 \opt{heading} 选项的 \pkg{ctex}。 -% \begin{macrocode} -%<*ctexcap> -\PassOptionsToPackage { heading = true } { ctexcap } -\RequirePackageWithOptions { ctex } -%</ctexcap> -% \end{macrocode} -% % 宏包载入检查。 % \begin{macrocode} %<*class|ctex> @@ -2896,14 +3025,13 @@ This package consists of the file ctex.dtx, and the derived files % \end{macrocode} % % \begin{macrocode} -\RequirePackage { etoolbox } +\RequirePackage { ctexhook , ctexpatch } %<!ctexheading>\RequirePackage { fix-cm , everysel } % \end{macrocode} % % \subsection{内部函数与变量} % -% \begin{variable}[int] -% {\l_@@_tmp_tl,\l_@@_tmp_int,\l_@@_tmp_dim,\l_@@_tmp_box} +% \begin{variable}[int]{\l_@@_tmp_tl,\l_@@_tmp_int,\l_@@_tmp_dim,\l_@@_tmp_box} % \begin{macrocode} \tl_new:N \l_@@_tmp_tl \int_new:N \l_@@_tmp_int @@ -2912,55 +3040,9 @@ This package consists of the file ctex.dtx, and the derived files % \end{macrocode} % \end{variable} % -% \begin{macro}[int]{\ctex_at_end_package:nn} -% 与 \pkg{filehook} 的 \tn{AtEndOfPackageFile*} 类似,如果原来没有在载入宏包则 -% 在宏包末尾执行语句,否则立即执行。 -% \begin{macrocode} -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 - { - \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g_@@_at_end_ #1 _hook_tl } {#2} } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[int]{\ctex_gadd_hook:Nn, \ctex_gadd_hook:cn} -% 给钩子附加内容。 -% \begin{macrocode} -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 - { - \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} - } -\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{macrocode} -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 - { - \cs_if_exist_use:cT { g_@@_at_end_ #1 _hook_tl } - { \cs_undefine:c { g_@@_at_end_ #1 _hook_tl } } - } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } -% \end{macrocode} -% \end{macro} -% -% 对 \tn{@popfilename} 做补丁来实现 \cs{ctex_at_end_package:nn} 的功能。 -% \begin{macrocode} -\tl_put_left:Nn \@popfilename - { - \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } - } -% \end{macrocode} -% % \begin{macro}[int]{\ctex_file_wrapper:nnn} % 设置文件操作的 \tn{catcode} 环境,参数 |#1| 是设置,|#2| 是文件操作,|#3| 是恢复。 -% 默认关闭 \LTXIII{} 语法环境,并设置 |@| 的 \tn{catcode} 为 $11$。 +% 默认关闭 \LaTeXiii{} 语法环境,并设置 |@| 的 \tn{catcode} 为 $11$。 % \begin{macrocode} \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { @@ -3009,128 +3091,6 @@ This package consists of the file ctex.dtx, and the derived files % \end{macrocode} % \end{macro} % -% \begin{macro}[int]{\ctex_parse_name:NN} -% 用 \tn{DeclareRobustCommand} 定义的宏或者由 \tn{newcommand} 或 \tn{newrobustcmd} -% 定义的带一个可选参数的宏第一次展开的结果都不是其实际定义,实际定义被保存在另外的 -% 宏中。由这些命令定义的宏的第一次展开结果可以有下面的形式(细节可查阅 \pkg{xpatch} -% 的文档): -% \begin{verbatim}[numbers=left,gobble=4] -% \protect␣\xaa␣␣ % \DeclareRobustCommand\xaa[1]{...} -% \protect␣\xab␣␣ % \DeclareRobustCommand\xab[1][]{...} -% \@protected@testopt␣\xac␣\\xac␣{} % \newcommand\xac[1][]{...} -% \@testopt␣\\xad␣{} % \newrobustcmd\xad[1][]{...} -% \x@protect␣\1\protect␣\1␣␣ % \DeclareRobustCommand\1[1]{...} -% \x@protect␣\2\protect␣\2␣␣ % \DeclareRobustCommand\2[1][]{...} -% \@protected@testopt␣\3\\3␣{} % \newcommand\3[1][]{...} -% \@testopt␣\\4␣{} % \newrobustcmd\4[1][]{...} -% \end{verbatim} -% \pkg{etoolbox} 的 \tn{patchcmd} 的主要原理是先对宏的 \tn{meaning} 作字符串 -% 替换,然后再用 \tn{scantokens} 来重建它。我们希望对宏的实际定义打补丁,为此需要 -% 先得到对应的名字。\pkg{letltxmacro}、\pkg{show2e} 和 \pkg{xpatch} 宏包中都有 -% 类似的工作。我们不想依赖 \pkg{xpatch},主要是因为它与同作者的 \pkg{regexpatch} -% 宏包共用了主要函数的名字,从而将导致用户不能使用 \pkg{regexpatch}。 -% \begin{macrocode} -\cs_new_protected:Npn \ctex_parse_name:NN #1#2 - { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } -\group_begin: -\char_set_lccode:nn { `\< } { `\{ } -\char_set_lccode:nn { `\/ } { `\\ } -\char_set_lccode:nn { `\A } { `\t } -\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N -\tex_lowercase:D - { - \group_end: - \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 - { - \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } - { - \group_begin: - \use:x - { - \group_end: - \@@_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } - \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } - } {#3} #1 - } - { #1#2 } - } - \cs_new_protected:Npn \@@_parse_name:nNNNnN #1#2#3#4#5#6 - { - \exp_args:Nc #6 - { - \str_case:nnTF {#1} - { - { \protect #3 } { } - { \x@protect #2 \protect #3 } { } - } - { - \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } - { - \exp_last_unbraced:Nf \@@_parse_name:w - \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop - } - { /#5 ~ } { #5 ~ } - } - { - \str_case:onTF { \@@_parse_name:w #1 AESAOPA ~ < \q_stop } - { - { /@protected@ #2 #4 } { } - { /@ #4 } { } - } - { /#5 } {#5} - } - } - } - \cs_new:Npn \@@_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } - } -\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[int] -% {\ctex_patch_cmd:NnnTF,\ctex_preto_cmd:NnTF,\ctex_appto_cmd:NnTF} -% 在打补丁前先解析实际名字。 -% \begin{macrocode} -\cs_new_protected_nopar:Npn \ctex_patch_cmd:NnnTF { \ctex_parse_name:NN \patchcmd } -\cs_new_protected_nopar:Npn \ctex_preto_cmd:NnTF { \ctex_parse_name:NN \pretocmd } -\cs_new_protected_nopar:Npn \ctex_appto_cmd:NnTF { \ctex_parse_name:NN \apptocmd } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}[int]{\ctex_patch_cmd:Nnn} -% 参数记号 |#| 作为宏的参数被读入时,总是会双写,会影响随后的字符串替换。需要先 -% 将它转换为普通符号。并且在补丁的时候关闭 \LTXIII{} 语法。 -% \begin{macrocode} -\cs_new_protected:Npn \ctex_patch_cmd:Nnn - { - \group_begin: - \char_set_catcode_other:N \# - \@@_patch_cmd:Nnn - } -\cs_new_protected:Npn \@@_patch_cmd:Nnn #1#2#3 - { - \group_end: - \group_begin: - \ExplSyntaxOff - \ctex_patch_cmd:NnnTF #1 {#2} {#3} - { - \cs_gset_eq:NN \@@_tmp:w #1 - \group_end: - \cs_set_eq:NN #1 \@@_tmp:w - \cs_undefine:N \@@_tmp:w - } - { \group_end: \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \ctex_patch_failure:N #1 - { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } -\msg_new:nnn { ctex } { patch-failure } - { - Patching~command~`#1'~failed.\\ - ctex~may~not~work~as~expected. - } -% \end{macrocode} -% \end{macro} -% % \begin{variable}[int]{\g_@@_section_depth_flag} % 若大于 |3|,则 \tn{paragraph} 和 \tn{subparagraph} 标题单独占一行;若为 |3|,则 % \tn{paragraph} 单独占一行。 @@ -3183,12 +3143,12 @@ This package consists of the file ctex.dtx, and the derived files % \end{macro} % % \begin{macro}[int]{\ctex_if_preamble:TF} -% 测试是否在 \LaTeXe{} 的导言区。在宏包内部初始为真,在 \tn{AfterEndPreamble} -% 钩子中再设置为假。注意,\tn{AfterEndPreamble} 在 \tn{AtBeginDocument} 之后执行, +% 测试是否在 \LaTeXe{} 的导言区。在宏包内部初始为真,文档最开始位置再设置为假。 +% 注意,钩子 \cs{ctex_after_end_preamble:n} 在 \tn{AtBeginDocument} 之后执行, % 可以与 \tn{@onlypreamble} 的行为一致。 % \begin{macrocode} \cs_new_eq:NN \ctex_if_preamble:TF \use_i:nn -\AfterEndPreamble { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } +\ctex_after_end_preamble:n { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } % \end{macrocode} % \end{macro} % @@ -3394,8 +3354,8 @@ This package consists of the file ctex.dtx, and the derived files { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options.~ } } , @@ -3404,8 +3364,8 @@ This package consists of the file ctex.dtx, and the derived files { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options. } } , @@ -3625,7 +3585,7 @@ This package consists of the file ctex.dtx, and the derived files \cs_if_exist:NF \hypersetup { \cs_new_eq:NN \hypersetup \ctex_hypersetup:n } } - \AtEndPreamble { \RequirePackage { hyperref } } + \ctex_at_end_preamble:n { \RequirePackage { hyperref } } } , } % \end{macrocode} @@ -3831,14 +3791,13 @@ This package consists of the file ctex.dtx, and the derived files \ctex_if_pdfmode:TF { \group_end: - \ExplSyntaxOff - \ctex_appto_cmd:NnTF \DeclareFontFamily { \CTEX@Family@CMap {#1} {#2} } + \ctex_appto_cmd:NnnTF \DeclareFontFamily { \ExplSyntaxOff } + { \CTEX@Family@CMap {#1} {#2} } { \ctex_at_end_package:nn { cmap } { \cs_gset_eq:NN \CTEX@Family@CMap \use_none:nn } } { \ctex_patch_failure:N \DeclareFontFamily } - \ExplSyntaxOn } { \group_end: } % \end{macrocode} @@ -3881,13 +3840,20 @@ This package consists of the file ctex.dtx, and the derived files \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:NnTF \rmfamily { \CJKfamily { \CJKrmdefault } } { } + \ctex_preto_cmd:NnnTF \rmfamily { \ExplSyntaxOff } + { \CJKfamily { \CJKrmdefault } } + { } { \ctex_patch_failure:N \rmfamily } - \ctex_preto_cmd:NnTF \sffamily { \CJKfamily { \CJKsfdefault } } { } + \ctex_preto_cmd:NnnTF \sffamily { \ExplSyntaxOff } + { \CJKfamily { \CJKsfdefault } } + { } { \ctex_patch_failure:N \sffamily } - \ctex_preto_cmd:NnTF \ttfamily { \CJKfamily { \CJKttdefault } } { } + \ctex_preto_cmd:NnnTF \ttfamily { \ExplSyntaxOff } + { \CJKfamily { \CJKttdefault } } + { } { \ctex_patch_failure:N \ttfamily } - \ctex_preto_cmd:NnTF \normalfont { \CJKfamily { \CJKfamilydefault } } + \ctex_preto_cmd:NnnTF \normalfont { \ExplSyntaxOff } + { \CJKfamily { \CJKfamilydefault } } { \cs_set_eq:NN \reset@font \normalfont } { \ctex_patch_failure:N \normalfont } % \end{macrocode} @@ -4006,7 +3972,7 @@ This package consists of the file ctex.dtx, and the derived files % \tn{CJK@envStart}。这样可以避免将 \env{CJK} 环境内置入 \env{document} 环境的 % 最里层,最后也就不需要 \tn{clearpage}。\pkg{zhmCJK} 已经提供类似功能。 % \begin{macrocode} - \exp_args:Nx \AtEndPreamble + \exp_args:Nx \ctex_at_end_preamble:n { \exp_not:N \CJK@envStart { } { \l_@@_encoding_tl } { \exp_not:N \CJKfamilydefault } @@ -4995,13 +4961,20 @@ This package consists of the file ctex.dtx, and the derived files \tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { rm } } \tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { sf } } \tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { tt } } -\ctex_preto_cmd:NnTF \rmfamily { \CJKfamily { \CJKrmdefault } } { } +\ctex_preto_cmd:NnnTF \rmfamily { \ExplSyntaxOff } + { \CJKfamily { \CJKrmdefault } } + { } { \ctex_patch_failure:N \rmfamily } -\ctex_preto_cmd:NnTF \sffamily { \CJKfamily { \CJKsfdefault } } { } +\ctex_preto_cmd:NnnTF \sffamily { \ExplSyntaxOff } + { \CJKfamily { \CJKsfdefault } } + { } { \ctex_patch_failure:N \sffamily } -\ctex_preto_cmd:NnTF \ttfamily { \CJKfamily { \CJKttdefault } } { } +\ctex_preto_cmd:NnnTF \ttfamily { \ExplSyntaxOff } + { \CJKfamily { \CJKttdefault } } + { } { \ctex_patch_failure:N \ttfamily } -\ctex_preto_cmd:NnTF \normalfont { \CJKfamily { \CJKfamilydefault } } +\ctex_preto_cmd:NnnTF \normalfont { \ExplSyntaxOff } + { \CJKfamily { \CJKfamilydefault } } { \cs_set_eq:NN \reset@font \normalfont } { \ctex_patch_failure:N \normalfont } % \end{macrocode} @@ -5549,8 +5522,11 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macrocode} \AtBeginDocument { - \ctex_appto_cmd:NnTF \verbatim@font { \CTEX@verbatim@font@hook } - { } { \ctex_patch_failure:N \verbatim@font } + \ctex_appto_cmd:NnnTF \verbatim@font + { \char_set_catcode_letter:n { 64 } } + { \CTEX@verbatim@font@hook } + { } + { \ctex_patch_failure:N \verbatim@font } } \cs_new_protected_nopar:Npn \CTEX@verbatim@font@hook { \ltjsetparameter { autospacing = false , autoxspacing = false } } @@ -5597,7 +5573,7 @@ This package consists of the file ctex.dtx, and the derived files \ctex_ltj_ensure_default_family: %</luatex> } -\AtEndPreamble { \ctex_update_default_family: } +\ctex_at_end_preamble:n { \ctex_update_default_family: } % \end{macrocode} % \end{macro} % @@ -5964,17 +5940,13 @@ This package consists of the file ctex.dtx, and the derived files } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: \cs_new_eq:Nc \@@_save_selectfont: { selectfont ~ } -\use:n +\ctex_preto_cmd:NnnTF \selectfont { \ExplSyntaxOff } + { \CTEX@selectfont@hook } { - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \selectfont { \CTEX@selectfont@hook } - { - \tl_put_left:Nn \@EverySelectfont@Init - { \cs_set_eq:cN { selectfont ~ } \@@_save_selectfont: } - } - { \ctex_patch_failure:N \selectfont } + \tl_put_left:Nn \@EverySelectfont@Init + { \cs_set_eq:cN { selectfont ~ } \@@_save_selectfont: } } -\ExplSyntaxOn + { \ctex_patch_failure:N \selectfont } % \end{macrocode} % \end{macro} % @@ -6129,6 +6101,8 @@ This package consists of the file ctex.dtx, and the derived files % \end{macrocode} % \end{macro} % +% \changes{v2.0}{2014/03/26}{新增 \opt{linestretch} 选项。} +% % \begin{macro}{linestretch} % 若行宽不是汉字宽度的整数倍,自然要求伸展它们之间的差。这里设置的是在此基础上的 % 额外伸展量。初始化为一个汉字的宽度。若设置为 \tn{maxdimen},则禁用此功能。 @@ -6307,6 +6281,21 @@ This package consists of the file ctex.dtx, and the derived files % \end{macrocode} % \end{macro} % +% \changes{v2.2}{2015/06/29}{给 \pkg{enumitem} 宏包注册 \tn{chinese} 和 +% \tn{zhnum}。} +% +% 给 \pkg{enumitem} 宏包注册 \tn{chinese} 和 \tn{zhnum}。 +% \begin{macrocode} +\ctex_at_end_package:nn { enumitem } + { + \cs_if_free:NF \AddEnumerateCounter + { + \AddEnumerateCounter * { \zhnum } { \zhnum_int:n } { 1 } + \AddEnumerateCounter * { \chinese } { \zhnum_int:n } { 1 } + } + } +% \end{macrocode} +% % \begin{macro}{\CTEXnumber,\CTEXdigits} % \begin{macrocode} \NewDocumentCommand \CTEXnumber { m m } @@ -6395,16 +6384,23 @@ This package consists of the file ctex.dtx, and the derived files % \end{macrocode} % % \subsubsection{定义标题格式选项} + +% +% \begin{variable}[int]{\c_@@_section_headings_seq} +% 保存 \tn{section} 级以下标题名字。 +% \begin{macrocode} +\seq_new:N \c_@@_section_headings_seq +\seq_gset_from_clist:Nn \c_@@_section_headings_seq + { section , subsection , subsubsection , paragraph , subparagraph } +% \end{macrocode} +% \end{variable} % % \begin{variable}[int]{\c_@@_headings_seq} % \begin{macrocode} \seq_new:N \c_@@_headings_seq -\seq_gset_from_clist:Nn \c_@@_headings_seq - { -%<article> part , section , subsection , subsubsection , -%<book|report> part , chapter , section , subsection , subsubsection , - paragraph , subparagraph - } +\seq_gset_eq:NN \c_@@_headings_seq \c_@@_section_headings_seq +%<book|report>\seq_gput_left:Nn \c_@@_headings_seq { chapter } +\seq_gput_left:Nn \c_@@_headings_seq { part } % \end{macrocode} % \end{variable} % @@ -6444,8 +6440,13 @@ This package consists of the file ctex.dtx, and the derived files % \end{macro} % % \changes{v2.1}{2015/05/22}{\opt{format+}, \opt{nameformat+} 等带加号的选项, -% 加号与前面的文字之间可以有可选的空格。} +% 加号与前面的文字之间可以有可选的空格。} % \changes{v2.1}{2015/06/19}{新的标题格式选项 \opt{aftertitle}。} +% \changes{v2.2}{2015/06/21}{新的标题格式选项 \opt{numbering}。} +% \changes{v2.2}{2015/06/27}{\opt{beforeskip} 和 \opt{afterskip} 选项的符号 +% 不再有特殊意义。} +% \changes{v2.2}{2015/06/27}{新的标题格式选项 \opt{afterindent}。} +% \changes{v2.2}{2015/06/27}{新的标题格式选项 \opt{runin}。} % % \begin{macro}[int]{\@@_def_heading_keys:n} % \begin{macrocode} @@ -6453,56 +6454,60 @@ This package consists of the file ctex.dtx, and the derived files { \tl_put_right:Nx \l_@@_tmp_tl { - #1 .meta:nn = { ctex / #1 } { ####1 } , - #1 / name .code:n = + #1 .meta:nn = { ctex / #1 } { ####1 } , + #1 / name .code:n = { \ctex_assign_heading_name:nn {#1} { ####1 } } , - #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , - #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , - #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , - #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , - #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , - #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , - #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , - #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , - #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , - #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , - #1 / format+ .code:n = + #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , + #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , + #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , + #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , + #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , + #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , + #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , + #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , + #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , + #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , + #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , + #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , + #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / format~+ .code:n = + #1 / format~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / nameformat+ .code:n = + #1 / nameformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / nameformat~+ .code:n = + #1 / nameformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / numberformat+ .code:n = + #1 / numberformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / numberformat~+ .code:n = + #1 / numberformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / aftername+ .code:n = + #1 / aftername+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / aftername~+ .code:n = + #1 / aftername~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / titleformat+ .code:n = + #1 / titleformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / titleformat~+ .code:n = + #1 / titleformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / aftertitle+ .code:n = + #1 / aftertitle+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / aftertitle~+ .code:n = + #1 / aftertitle~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / beforeskip .initial:n = \c_zero_skip , - #1 / afterskip .initial:n = \c_zero_skip , - #1 / indent .initial:n = \c_zero_dim , - #1 / beforeskip .value_required: , - #1 / afterskip .value_required: , - #1 / indent .value_required: , + #1 / numbering .initial:n = true , + #1 / beforeskip .initial:n = \c_zero_skip , + #1 / afterskip .initial:n = \c_zero_skip , + #1 / indent .initial:n = \c_zero_dim , + #1 / beforeskip .value_required: , + #1 / afterskip .value_required: , + #1 / indent .value_required: , } } % \end{macrocode} % \end{macro} % % \begin{macro}[int]{\ctex_assign_heading_name:nn,\@@_assign_heading_name:nnn} -% \opt{name} 的值是一个至多两个元素的逗号分隔列表。由于 \LTXIII{} 的 +% \opt{name} 的值是一个至多两个元素的逗号分隔列表。由于 \LaTeXiii{} 的 % \texttt{clist} 总是会自动忽略空元素,所以设置 |name={,章}| 后,第一个元素将会 % 是“章”,必须用空的分组保护空元素:|name={{},章}|,这在使用中有些许不便。我们 % 可以改用 \texttt{seq} 或者手写函数解析参数来加以改进。为实现的简单起见,这里用 @@ -6550,12 +6555,27 @@ This package consists of the file ctex.dtx, and the derived files % % \subsubsection{标准标题命令的修改} % +% \begin{macro}[int]{\CTEX@makeheadinganchor} +% 用于 |numbering=false| 时,设置超链接跳转描点。 +% \begin{macrocode} +\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } +\ctex_at_end_package:nn { hyperref } + { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } +% \end{macrocode} +% \end{macro} +% +% \changes{v2.2}{2015/06/27}{\opt{beforeskip}、\opt{afterskip} 和 \opt{indent} +% 选项支持表达式。} +% % \paragraph{part 的标题} % % \begin{macrocode} %<@@=> % \end{macrocode} % +% \changes{v2.2}{2015/06/27}{非 \cls{ctexart} 类的 \opt{part/beforeskip} 和 +% \opt{part/afterskip} 选项有意义。} +% % \begin{macro}[int]{\part} % \begin{macrocode} %<*article> @@ -6563,15 +6583,33 @@ This package consists of the file ctex.dtx, and the derived files \if@noskipsec \leavevmode \fi \par % \addvspace{4ex}% - \@tempskipa \CTEX@part@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else + \addvspace{\glueexpr\CTEX@part@beforeskip\relax}% + \ifodd \CTEX@part@afterindent \@afterindenttrue + \else + \@afterindentfalse \fi - \addvspace{\@tempskipa}% \secdef\@part\@spart} %</article> +%<*book|report> +\renewcommand\part{% + \if@openright + \cleardoublepage + \else + \clearpage + \fi +% \thispagestyle{plain}% + \thispagestyle{\CTEX@part@pagestyle}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi +% \null\vfil + \null\vskip \glueexpr \CTEX@part@beforeskip \relax + \secdef\@part\@spart} +%</book|report> % \end{macrocode} % \end{macro} % @@ -6580,40 +6618,44 @@ This package consists of the file ctex.dtx, and the derived files %<*article> \def\@part[#1]#2{% \ifnum \c@secnumdepth >\m@ne - \refstepcounter{part}% -% \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% +% \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi {\interlinepenalty \@M % \normalfont \parindent \z@ \raggedright - \normalfont \parindent \CTEX@part@indent \CTEX@part@format - \ifnum \c@secnumdepth >\m@ne + \normalfont \parindent \dimexpr \CTEX@part@indent \relax \CTEX@part@format + \ifnum \c@secnumdepth >\m@ne \ifodd \CTEX@part@numbering % \Large\bfseries\partname\nobreakspace\thepart\par\nobreak \CTEX@partname - \fi + \fi \fi % \huge\bfseries #2% \CTEX@part@titleformat{#2}% \markboth{}{}% \CTEX@part@aftertitle}% \nobreak % \vskip 3ex - \vskip \CTEX@part@afterskip + \vskip \glueexpr \CTEX@part@afterskip \relax \@afterheading} %</article> -% \end{macrocode} -% -% 标准文档类是在 \tn{part} 和 \tn{chapter} 定义的最开始设置 \tn{thispagestyle}, -% 我们这里的修改出现在它之后,可以覆盖之前的设置。 -% \begin{macrocode} %<*book|report> \def\@part[#1]#2{% - \thispagestyle{\CTEX@part@pagestyle}% \ifnum \c@secnumdepth >-2\relax - \refstepcounter{part}% -% \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% +% \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi @@ -6621,10 +6663,10 @@ This package consists of the file ctex.dtx, and the derived files {\interlinepenalty \@M % \normalfont \centering \normalfont \CTEX@part@format - \ifnum \c@secnumdepth >-2\relax + \ifnum \c@secnumdepth >-2\relax \ifodd \CTEX@part@numbering % \huge\bfseries\partname\nobreakspace\thepart\par\vskip 20\p@ \CTEX@partname - \fi + \fi \fi % \Huge\bfseries #2\par}% \CTEX@part@titleformat{#2}% \CTEX@part@aftertitle}% @@ -6639,13 +6681,14 @@ This package consists of the file ctex.dtx, and the derived files \def\@spart#1{% {\interlinepenalty \@M % \normalfont \parindent \z@ \raggedright - \normalfont \parindent \CTEX@part@indent \CTEX@part@format + \normalfont \parindent \dimexpr \CTEX@part@indent \relax + \CTEX@part@format % \huge \bfseries #1\par}% \CTEX@part@titleformat{#1}% \CTEX@part@aftertitle}% \nobreak % \vskip 3ex - \vskip \CTEX@part@afterskip + \vskip \glueexpr \CTEX@part@afterskip \relax \@afterheading} %</article> %<*book|report> @@ -6661,23 +6704,65 @@ This package consists of the file ctex.dtx, and the derived files % \end{macrocode} % \end{macro} % +% \begin{macro}[int]{\@endpart} +% \begin{macrocode} +%<*book|report> +\def\@endpart{% +% \vfil + \vskip \glueexpr \CTEX@part@afterskip \relax + \newpage + \if@twoside + \if@openright + \null + \thispagestyle{empty}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi} +%</book|report> +% \end{macrocode} +% \end{macro} +% % \paragraph{chapter 的标题} % % \begin{macrocode} %<*book|report> % \end{macrocode} % +% \begin{macro}[int]{\chapter} +% \begin{macrocode} +\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi +% \thispagestyle{plain}% + \thispagestyle{\CTEX@chapter@pagestyle}% + \global\@topnum\z@ +% \@afterindentfalse + \ifodd \CTEX@chapter@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \secdef\@chapter\@schapter} +% \end{macrocode} +% \end{macro} +% % \begin{macro}[int]{\@chapter} % \begin{macrocode} \def\@chapter[#1]#2{% \ifnum \c@secnumdepth >\m@ne %<book> \if@mainmatter - \refstepcounter{chapter}% -% \typeout{\@chapapp\space\thechapter.}% - \typeout{\CTEXthechapter}% - \addcontentsline{toc}{chapter} -% {\protect\numberline{\thechapter}#1}% - {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \ifodd \CTEX@chapter@numbering + \refstepcounter{chapter}% +% \typeout{\@chapapp\space\thechapter.}% + \typeout{\CTEXthechapter}% + \addcontentsline{toc}{chapter} +% {\protect\numberline{\thechapter}#1}% + {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{chapter}{#1}% + \fi %<book> \else %<book> \addcontentsline{toc}{chapter}{#1}% %<book> \fi @@ -6699,21 +6784,17 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macro}[int]{\@makechapterhead} % \begin{macrocode} \def\@makechapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% % \vspace*{50\p@}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% % {\normalfont \parindent \z@ \raggedright - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \ifnum \c@secnumdepth >\m@ne %<book> \if@mainmatter -% \huge\bfseries\@chapapp\space\thechapter\par\nobreak\vskip 20\p@ - \CTEX@chaptername + \ifodd \CTEX@chapter@numbering +% \huge\bfseries\@chapapp\space\thechapter\par\nobreak\vskip 20\p@ + \CTEX@chaptername + \fi %<book> \fi \fi \interlinepenalty\@M @@ -6722,7 +6803,7 @@ This package consists of the file ctex.dtx, and the derived files \CTEX@chapter@aftertitle \nobreak % \vskip 40\p@ - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} % \end{macrocode} % \end{macro} @@ -6730,24 +6811,18 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macro}[int]{\@makeschapterhead} % \begin{macrocode} \def\@makeschapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% % \vspace*{50\p@}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% % {\normalfont \parindent \z@ \raggedright - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \interlinepenalty\@M % \Huge \bfseries #1\par\nobreak \CTEX@chapter@titleformat{#1} \CTEX@chapter@aftertitle \nobreak % \vskip 40\p@ - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} % \end{macrocode} % \end{macro} @@ -6758,6 +6833,34 @@ This package consists of the file ctex.dtx, and the derived files % % \paragraph{section 类的标题} % +% \begin{macro}[int]{\@startsection} +% \begin{macrocode} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par +% \@tempskipa #4\relax +% \@afterindenttrue +% \ifdim \@tempskipa <\z@ +% \@tempskipa -\@tempskipa \@afterindentfalse +% \fi + \CTEX@update@sectionformat@n{#1}% + \ifodd \CTEX@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else +% \addpenalty\@secpenalty\addvspace\@tempskipa + \addpenalty\@secpenalty\addvspace{\glueexpr #4\relax}% + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} +% \end{macrocode} +% \end{macro} +% % \begin{macro}[int]{\@seccntformat} % \begin{macrocode} \def\@seccntformat#1{% @@ -6773,14 +6876,20 @@ This package consists of the file ctex.dtx, and the derived files \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \ifodd \csname CTEX@#1@numbering\endcsname + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \else + \CTEX@makeheadinganchor + \let\@svsec\@empty + \fi \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ +% \@tempskipa #5\relax +% \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #6{% - \@hangfrom{\hskip #3\relax\@svsec}% + \@hangfrom{\hskip\glueexpr #3\relax\@svsec}% % \interlinepenalty \@M #8\@@par}% \interlinepenalty \@M \csname CTEX@#1@titleformat\endcsname{#8}% @@ -6789,15 +6898,17 @@ This package consists of the file ctex.dtx, and the derived files \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else -% \protect\numberline{\csname the#1\endcsname}% - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname +% \protect\numberline{\csname the#1\endcsname}% + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}% \else \def\@svsechd{% - #6{\hskip #3\relax + #6{\hskip\glueexpr #3\relax % \@svsec #8}% \@svsec \csname CTEX@#1@titleformat\endcsname{#8}% @@ -6805,10 +6916,12 @@ This package consists of the file ctex.dtx, and the derived files \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else -% \protect\numberline{\csname the#1\endcsname}% - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname +% \protect\numberline{\csname the#1\endcsname}% + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}}% \fi @@ -6817,51 +6930,84 @@ This package consists of the file ctex.dtx, and the derived files % \end{macro} % % \begin{macro}[int]{\@ssect} -% \tn{@ssect} 并没有参数给出当前标题的名字,扩展它的参数会与 \pkg{hyperref} 冲突。 -% 它的第二个参数是 BEFORESKIP(\tn{@startsection} 的第四个参数),在定义中并没有 -% 被用到,应该可以用它来传递名字。我们这里通过函数 \tn{CTEX@titleformat@n} 来传递, -% 它将在 |#4| 中被重定义为相应的 \opt{titleformat}。 % \begin{macrocode} \def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ +% \@tempskipa #3\relax +% \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #4{% - \@hangfrom{\hskip #1}% + \@hangfrom{\hskip\glueexpr #1\relax}% % \interlinepenalty \@M #5\@@par}% \interlinepenalty \@M \CTEX@titleformat@n{#5}% \CTEX@aftertitle}% \endgroup \else -% \def\@svsechd{#4{\hskip #1\relax #5}}% - \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% +% \def\@svsechd{#4{\hskip\glueexpr #1\relax #5}}% + \def\@svsechd{#4{\hskip\glueexpr #1\relax + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} % \end{macrocode} % \end{macro} % +% \begin{macro}[int]{\@xsect} +% \begin{macrocode} +\def\@xsect#1{% +% \@tempskipa #1\relax +% \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin + \par \nobreak +% \vskip \@tempskipa + \vskip\glueexpr #1\relax + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \begingroup \@svsechd \endgroup + \unskip +% \@tempskipa #1\relax +% \hskip -\@tempskipa + \hskip\glueexpr #1\relax + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +% \end{macrocode} +% \end{macro} +% % \begin{macrocode} %<@@=ctex> % \end{macrocode} % -% \begin{macro}[int]{\CTEX@set@titleformat@n, \CTEX@titleformat@n} -% 在 \tn{@startsection} 中设置 \tn{CTEX@titleformat@n} 为相应函数。 +% \begin{macro}[int]{\CTEX@update@sectionformat@n} +% 在 \tn{@startsection} 中设置 \tn{CTEX@titleformat@n} 等为相应函数。 % \begin{macrocode} -\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1 +\cs_new_protected_nopar: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 } + \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } + \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } } \cs_new_eq:NN \CTEX@titleformat@n \use:n \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: +\cs_new_eq:NN \CTEX@afterindent \c_true_bool +\cs_new_eq:NN \CTEX@runin \c_false_bool % \end{macrocode} % \end{macro} % % \begin{macrocode} \int_zero:N \l_@@_tmp_int -\clist_map_inline:nn - { section , subsection , subsubsection , paragraph , subparagraph } +\seq_map_inline:Nn \c_@@_section_headings_seq { \int_incr:N \l_@@_tmp_int \cs_gset_protected_nopar:cpx {#1} @@ -6871,25 +7017,23 @@ This package consists of the file ctex.dtx, and the derived files { \exp_not:c { CTEX@#1@indent } } { \exp_not:c { CTEX@#1@beforeskip } } { \exp_not:c { CTEX@#1@afterskip } } - { - \CTEX@set@titleformat@n {#1} - \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } - } + { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } } } % \end{macrocode} % -% % \paragraph{附录标题} % -% \begin{macro}[int]{appendix/name,appendix/number} +% \begin{macro}[int]{appendix/name,appendix/number,appendix/numbering} % \begin{macrocode} \keys_define:nn { ctex } { - appendix .meta:nn = { ctex / appendix } {#1} , - appendix / name .code:n = + appendix .meta:nn = { ctex / appendix } {#1} , + appendix / name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } , - appendix / number .tl_set:N = \CTEX@appendixnumber + appendix / number .tl_set:N = \CTEX@appendix@number , + appendix / numbering .bool_set:N = \CTEX@appendix@numbering , + appendix / numbering .initial:n = true } \tl_new:N \CTEX@preappendix \tl_new:N \CTEX@postappendix @@ -6904,18 +7048,121 @@ This package consists of the file ctex.dtx, and the derived files \CTEX@save@appendix %<*article> \gdef \CTEX@presection { \CTEX@preappendix } - \gdef \CTEX@thesection { \CTEX@appendixnumber } + \gdef \CTEX@thesection { \CTEX@appendix@number } \gdef \CTEX@postsection { \CTEX@postappendix } + \gdef \CTEX@section@numbering { \CTEX@appendix@numbering } %</article> %<*book|report> \gdef \CTEX@prechapter { \CTEX@preappendix } - \gdef \CTEX@thechapter { \CTEX@appendixnumber } + \gdef \CTEX@thechapter { \CTEX@appendix@number } \gdef \CTEX@postchapter { \CTEX@postappendix } + \gdef \CTEX@chapter@numbering { \CTEX@appendix@numbering } %</book|report> } % \end{macrocode} % \end{macro} % +% \paragraph{兼容 \pkg{titlesec} 宏包} +% +% 我们修改了 \tn{@startsection} 的定义,它的第四个(\meta{beforeskip})和 +% 第五个(\meta{afterskip})参数的符号不再有特殊意义,改由相应的选项 +% \opt{afterindent} 和 \opt{runin} 来控制。 +% +% 引入 \pkg{titlesec} 宏包,并且未设置它的 \opt{loadonly} 选项时,\pkg{titlesec} +% 会展开 section 类标题获取它们的参数,进行初始设置。我们需要进行一些调整。 +% +% \begin{macro}[int]{\ctex_titlesec_hook:} +% \tn{titleformat} 的设置保存在名为 |\ttlf@|\meta{section} 的宏中备用,它的内容是 +% \begin{center}\small +% |\ttlh@|\meta{shape}\Arg{format}\Arg{label}\Arg{sep}\Arg{before}\Arg{after} +% \end{center} +% 我们这里的 \meta{shape} 为 |hang| 或者 |runin|。\tn{titlespacing} 的设置保存在 +% |\ttls@|\meta{section} 之中,它的内容是 +% \begin{center}\small +% \Arg{left}\Arg{right}\Arg{before}\Arg{after}\Arg{afterindent} +% \end{center} +% 其中 \meta{afterindent} 为 |1| 或 |0|,分别对应是否保留段首缩进。 +% 我们需要根据 \CTeX{} 的 \opt{runin} 和 \opt{afterindent} 选项调整 +% |\ttlh@|\meta{shape} 和 \meta{afterindent}。注意,由 \tn{ttl@extract} 得的 +% \meta{before} 和 \meta{after} 的值总是非负的,而 \CTeX{} 的 \opt{beforeskip} +% 和 \opt{afterskip} 是可以取负值的,但我们不打算调整它们了。 +% 如果使用了 \pkg{titlesec} 的 \opt{indentafter} 等选项,也不需要调整 +% |\ttls@|\meta{section}。 +% \begin{macrocode} +\cs_new_protected_nopar:Npn \ctex_titlesec_hook: + { + \@ifpackagewith { titlesec } { explicit } + { + \cs_set_eq:NN \@@_titlesec_format:Nn + \@@_titlesec_format_explicit:Nn + } + { } + \clist_map_inline:nn + { indentafter , noindentafter , indentfirst , nonindentfirst } + { + \@ifpackagewith { titlesec } { ##1 } + { + \clist_map_break:n + { \cs_set_eq:NN \@@_titlesec_hook:n \@@_titlesec_format:n } + } + { } + } + \seq_map_function:NN \c_@@_section_headings_seq \@@_titlesec_hook:n + } +\cs_new_protected_nopar: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_if_free:cF { ttlf@#1 } + { \exp_args:Nc \@@_titlesec_format:Nn { ttlf@#1 } {#1} } + } +\cs_new_protected_nopar:Npn \@@_titlesec_format:Nn #1#2 + { + \tl_set:Nx #1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \tl_tail:N #1 + } + } +\cs_new_protected_nopar:Npn \@@_titlesec_format_explicit:Nn #1#2 + { + \cs_set_nopar:Npx #1 ##1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \exp_args:No \tl_tail:n { #1 { } } + } + } +\cs_new_protected_nopar: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 + { + \exp_not:n { {#1} {#2} {#3} {#4} } + { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\@ifpackageloaded { titlesec } + { } + { + \ctex_at_end_package:nn { titlesec } + { + \@ifpackagewith { titlesec } { loadonly } + { } + { \ctex_titlesec_hook: } + } + } +% \end{macrocode} +% +% % \subsubsection{目录标签的宽度} % % \begin{macro}[int]{\numberline} @@ -6934,19 +7181,22 @@ This package consists of the file ctex.dtx, and the derived files \use:n { \group_end: - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } \@ifpackageloaded { tocloft } { } { \ctex_at_end_package:nn { tocloft } { - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } } } - \ExplSyntaxOn } % \end{macrocode} % \end{macro} @@ -6956,16 +7206,23 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macro}[int]{\ps@headings} % \begin{macrocode} %<*article> -\ctex_patch_cmd:Nnn \ps@headings { \thesection } { \CTEXthesection } +\ctex_patch_cmd:Nnn \ps@headings + { \thesection \quad } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesubsection } { \CTEXthesubsection } + \ctex_patch_cmd:Nnn \ps@headings + { \thesubsection \quad } + { \ifodd \CTEX@subsection@numbering \CTEXthesubsection \quad \fi } \fi: %</article> %<*book|report> \ctex_patch_cmd:Nnn \ps@headings - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesection.~\ } { \CTEXthesection \quad } + \ctex_patch_cmd:Nnn \ps@headings + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \fi: %</book|report> % \end{macrocode} @@ -6981,16 +7238,20 @@ This package consists of the file ctex.dtx, and the derived files { %<*article> \ctex_patch_cmd:Nnn \ps@fancy - { \thesection \hskip 1em \relax } { \CTEXthesection \quad } + { \thesection \hskip 1em \relax } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesubsection \hskip 1em \relax } { \CTEXthesubsection \quad } + { \thesubsection \hskip 1em \relax } + { \ifodd \CTEX@subsection@numbering \CTEXthesubsection \quad \fi } %</article> %<*book|report> \ctex_patch_cmd:Nnn \ps@fancy -%<book> { \@chapapp\ \thechapter.~\ } { \if@mainmatter \CTEXthechapter \quad \fi } -%<report> { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } +%<book> { \if@mainmatter \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi \fi } +%<report> { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesection.~\ } { \CTEXthesection \quad } + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } %</book|report> } % \end{macrocode} @@ -7082,6 +7343,9 @@ This package consists of the file ctex.dtx, and the derived files % % \changes{v2.1}{2015/05/30}{修复 \cls{ctexbook} 和 \cls{ctexrep} 类的中文 % \opt{part/number} 选项初值为空的错误。} +% \changes{v2.2}{2015/06/30}{将中文版式下的 \texttt{part} 和 \texttt{chapter} +% 标题的 \opt{nameformat} 和 \opt{titleformat} 选项的初值合并到 \opt{format} 中。} +% % \begin{macrocode} \keys_set:nn { ctex / part } { @@ -7094,31 +7358,33 @@ This package consists of the file ctex.dtx, and the derived files number = \chinese { part } , %</chinese> %<*article> - nameformat = \Large \bfseries , + beforeskip = 4ex , afterskip = 3ex , %<*plain> format = \raggedright , + nameformat = \Large \bfseries , aftername = \par \nobreak , titleformat = \huge \bfseries , - beforeskip = -4ex + afterindent = false %</plain> %<*chinese> - format = \centering , + format = \Large \bfseries \centering , aftername = \quad , - titleformat = \Large \bfseries , - beforeskip = 4ex + afterindent = true %</chinese> %</article> %<*book|report> - format = \centering , - nameformat = \huge \bfseries , aftername = \par \vskip 20 \p@ , + beforeskip = 0pt \@plus 1fil , + afterskip = 0pt \@plus 1fil , pagestyle = plain , %<*plain> + format = \centering , + nameformat = \huge \bfseries , titleformat = \Huge \bfseries %</plain> %<*chinese> - titleformat = \huge \bfseries + format = \huge \bfseries \centering %</chinese> %</book|report> } @@ -7129,23 +7395,23 @@ This package consists of the file ctex.dtx, and the derived files \keys_set:nn { ctex / chapter } { pagestyle = plain , - nameformat = \huge \bfseries , aftertitle = \par , + beforeskip = 50 \p@ , afterskip = 40 \p@ , %<*plain> name = \chaptername \space , number = \thechapter , format = \raggedright , + nameformat = \huge \bfseries , aftername = \par \nobreak \vskip 20 \p@ , titleformat = \Huge \bfseries , - beforeskip = -50 \p@ + afterindent = false %</plain> %<*chinese> number = \chinese { chapter } , - format = \centering , + format = \huge \bfseries \centering , aftername = \quad , - titleformat = \huge \bfseries , - beforeskip = 50 \p@ + afterindent = true %</chinese> } %</book|report> @@ -7161,14 +7427,16 @@ This package consists of the file ctex.dtx, and the derived files number = \thesection , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.5ex \@plus 1ex \@minus .2ex , afterskip = 2.3ex \@plus .2ex , + runin = false , %<*plain> format = \Large \bfseries , - beforeskip = -3.5ex \@plus -1ex \@minus -.2ex + afterindent = false %</plain> %<*chinese> format = \Large \bfseries \centering , - beforeskip = 3.5ex \@plus 1ex \@minus .2ex + afterindent = true %</chinese> } % \end{macrocode} @@ -7180,12 +7448,14 @@ This package consists of the file ctex.dtx, and the derived files format = \large \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , + runin = false , %<*plain> - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex + afterindent = false %</plain> %<*chinese> - beforeskip = 3.25ex \@plus 1ex \@minus .2ex + afterindent = true %</chinese> } % \end{macrocode} @@ -7197,12 +7467,14 @@ This package consists of the file ctex.dtx, and the derived files format = \normalsize \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , + runin = false , %<*plain> - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex + afterindent = false %</plain> %<*chinese> - beforeskip = 3.25ex \@plus 1ex \@minus .2ex + afterindent = true %</chinese> } % \end{macrocode} @@ -7212,7 +7484,14 @@ This package consists of the file ctex.dtx, and the derived files { number = \theparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , +%<*plain> + afterindent = false +%</plain> +%<*chinese> + afterindent = true +%</chinese> } % \end{macrocode} % @@ -7221,7 +7500,14 @@ This package consists of the file ctex.dtx, and the derived files { number = \thesubparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , +%<*plain> + afterindent = false +%</plain> +%<*chinese> + afterindent = true +%</chinese> } % \end{macrocode} % @@ -7232,20 +7518,15 @@ This package consists of the file ctex.dtx, and the derived files \keys_set:nn { ctex / paragraph } { aftertitle = \@@par , -%<*plain> - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex , -%</plain> -%<*chinese> - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , -%</chinese> - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / paragraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_three @@ -7253,20 +7534,15 @@ This package consists of the file ctex.dtx, and the derived files \keys_set:nn { ctex / subparagraph } { aftertitle = \@@par , -%<*plain> - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex , -%</plain> -%<*chinese> - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , -%</chinese> - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / subparagraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two @@ -7430,7 +7706,7 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macrocode} %<*generic> \tl_if_exist:NT \c_@@_std_class_tl - { \RequirePackage{ indentfirst } } + { \RequirePackage { indentfirst } } %</generic> % \end{macrocode} % @@ -7689,7 +7965,7 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macrocode} \fp_compare:nNnF { \l_@@_line_spread_fp } ? { \c_zero_fp } { - \linespread { \fp_use:N \l_@@_line_spread_fp } + \exp_args:Nx \linespread { \fp_use:N \l_@@_line_spread_fp } % \end{macrocode} % % \changes{v2.0}{2014/04/23}{调整 \tn{footnotesep} 的大小,以适合行距的变化。} @@ -7763,46 +8039,9 @@ This package consists of the file ctex.dtx, and the derived files %<*class|ctex> % \end{macrocode} % -% \subsubsection{其他兼容性修改} -% -% \begin{macro}[int]{\end} % \changes{v2.0}{2014/03/09} % {解决 \pkg{etoolbox} 与 \pkg{breqn} 关于 \tn{end} 的冲突。} -% \pkg{breqn} 宏包对 \tn{end} 作了如下处理,然而这个处理并不保险。 -% \begin{verbatim} -% \def\@tempa#1\endcsname#2\@nil{\def\latex@end##1{#2}} -% \expandafter\@tempa\end{#1}\@nil -% \def\end#1{\csname end#1\endcsname \latex@end{#1}}% -% \end{verbatim} -% \pkg{etoolbox} 在 \tn{end} 定义中的 \tn{csname} 前加入 -% 钩子 |\csuse{@end@#1@hook}|。如果 \pkg{etoolbox} 先于 \pkg{breqn} 被载入(这 -% 在使用 \cls{ctexart} 等文档类时几乎是必然的),|\csuse{@end@#1@hook}| 将会被 -% 忽略,即 \tn{AtEndEnvironment} 失效。如果交换两个宏包的载入顺序,则 -% \pkg{etoolbox} 会给出警告:\tn{AfterEndEnvironment} 失效,我们不打算处理这种 -% 情况。 -% \begin{macrocode} -\group_begin: -\char_set_catcode_other:N \# -\use:n - { - \group_end: - \ExplSyntaxOff - \ctex_at_end_package:nn { breqn } - { - \ctex_patch_cmd:NnnTF \end { \csname end#1 \endcsname } - { - \csuse { @end@#1@hook } - \csname end#1 \endcsname - } { } - { - \ctex_preto_cmd:NnTF \end { \csuse { @end@#1@hook } } - { } { \ctex_patch_failure:N \end } - } - } - \ExplSyntaxOn - } -% \end{macrocode} -% \end{macro} +% \changes{v2.2}{2015/06/23}{删去 \pkg{etoolbox} 与 \pkg{breqn} 的兼容补丁。} % % \subsection{载入中文字体} % @@ -8572,7 +8811,7 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macrocode} %<*windows> \ProvidesFile{zhwindowsfonts.tex}% - [2015/05/25 v2.1 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)] \ifzhmappdf \pdfmapline{=gbk@UGBK@ <simsun.ttc} @@ -8644,7 +8883,7 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macrocode} %<*adobe> \ProvidesFile{zhadobefonts.tex}% - [2015/05/25 v2.1 Adobe font map loader for DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Adobe font map loader for DVIPDFMx (CTEX)] \ifzhmappdf %% pdfTeX does not support OTF fonts @@ -8680,7 +8919,7 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macrocode} %<*fandol> \ProvidesFile{zhfandolfonts.tex}% - [2015/05/25 v2.1 Fandol font map loader for DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Fandol font map loader for DVIPDFMx (CTEX)] \ifzhmappdf %% pdfTeX does not support OTF fonts @@ -8716,7 +8955,7 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macrocode} %<*founder> \ProvidesFile{zhfounderfonts.tex}% - [2015/05/25 v2.1 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)] \ifzhmappdf \pdfmapline{=gbk@UGBK@ <FZSSK.TTF} @@ -8788,7 +9027,7 @@ This package consists of the file ctex.dtx, and the derived files % \begin{macrocode} %<*ubuntu> \ProvidesFile{zhubuntufonts.tex}% - [2015/05/25 v2.1 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)] \ifzhmappdf \pdfmapline{=gbk@UGBK@ <uming.ttc} @@ -8993,6 +9232,463 @@ This package consists of the file ctex.dtx, and the derived files %</spa> % \end{macrocode} % +% +% \subsection{\pkg{ctexcap} 宏包} +% +% \begin{macrocode} +%<*ctexcap> +% \end{macrocode} +% +% \pkg{ctexcap} 是过时宏包。 +% \begin{macrocode} +\clist_new:N \l_@@_ctexcap_options_clist +\clist_set:Nx \l_@@_ctexcap_options_clist + { \exp_not:v { opt@ \@currname . \@currext } , heading } +\msg_new:nnn { ctexcap } { deprecated } + { + Package~`ctexcap'~is~deprecated.\\ + Please~use~package~`ctex'~with~option~`#1'~instead: \\\\ + \iow_indent:n { \token_to_str:N \usepackage [#1] \{ ctex \} } \\ + } +\msg_warning:nnx { ctexcap } { deprecated } + { \clist_use:Nn \l_@@_ctexcap_options_clist { , ~ } } +% \end{macrocode} +% +% \pkg{ctexcap} 是默认打开 \opt{heading} 选项的 \pkg{ctex}。 +% \begin{macrocode} +\PassOptionsToPackage { heading = true } { ctexcap } +\RequirePackageWithOptions { ctex } +% \end{macrocode} +% +% \begin{macrocode} +%</ctexcap> +% \end{macrocode} +% +% +% \subsection{\pkg{ctexhook} 宏包} +% +% \changes{v2.2}{2015/06/26}{将文档开头和宏包末尾钩子提取到 \pkg{ctexhook} 宏包中。} +% +% \begin{macrocode} +%<*ctexhook> +% \end{macrocode} +% +% \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 + { \group_end: \g_@@_end_preamble_hook_tl \group_begin: } +\cs_new_protected_nopar:Npn \CTEX@document@right@hook + { \scan_stop: \g_@@_after_end_preamble_hook_tl \tex_ignorespaces:D } +\cs_set_nopar:Npx \document + { + \CTEX@document@left@hook + \exp_not:o { \document } + \CTEX@document@right@hook + } +\tl_new:N \g_@@_end_preamble_hook_tl +\tl_new:N \g_@@_after_end_preamble_hook_tl +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_at_end_package:nn} +% 与 \pkg{filehook} 的 \tn{AtEndOfPackageFile*} 类似,如果原来没有在载入宏包则 +% 在宏包末尾执行语句,否则立即执行。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 + { + \@ifpackageloaded {#1} + {#2} + { \ctex_gadd_hook:cn { g_@@_at_end_ #1 _hook_tl } {#2} } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_gadd_hook:Nn, \ctex_gadd_hook:cn} +% 给钩子附加内容。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 + { + \tl_if_exist:NF #1 { \tl_new:N #1 } + \tl_gput_right:Nn #1 {#2} + } +\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{macrocode} +\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 + { + \cs_if_exist_use:cT { g_@@_at_end_ #1 _hook_tl } + { \cs_undefine:c { g_@@_at_end_ #1 _hook_tl } } + } +\cs_generate_variant:Nn \ctex_package_end_hook:n { o } +% \end{macrocode} +% \end{macro} +% +% 对 \tn{@popfilename} 做补丁来实现 \cs{ctex_at_end_package:nn} 的功能。 +% \begin{macrocode} +\tl_put_left:Nn \@popfilename + { + \cs_if_eq:NNT \@currext \@pkgextension + { \ctex_package_end_hook:o { \@currname } } + } +% \end{macrocode} +% +% \begin{macrocode} +%</ctexhook> +% \end{macrocode} +% +% +% \subsection{\pkg{ctexpatch} 宏包} +% +% \changes{v2.2}{2015/06/23}{新增子宏包 \pkg{ctexpatch} 实现给宏打补丁功能。} +% +% \begin{macrocode} +%<*ctexpatch> +% \end{macrocode} +% +% \begin{macro}[int]{\ctex_patch_cmd_once:NnnnTF} +% 只进行第一次匹配进行替换。参数 |#2| 是宏重建时的 \tn{catcode} 设置。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_patch_cmd_once:NnnnTF #1#2 + { + \ctex_patch_boot:NNnnTF \@@_patch_cmd:Nnnnnw #1 + { once } {#2} { \use_i:nn } { \use_ii:nn } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_patch_cmd_all:NnnnTF} +% 替换所有匹配到的文本。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_patch_cmd_all:NnnnTF #1#2 + { + \ctex_patch_boot:NNnnTF \@@_patch_cmd:Nnnnnw #1 + { all } {#2} { \use_i:nn } { \use_ii:nn } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_patch_cmd:Nnn} +% 快捷方式,在补丁的时候关闭 \LaTeXiii{} 语法和设置 |@| 为字母类,补丁失败时给出警告。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_patch_cmd:Nnn #1 + { + \ctex_patch_boot:NNnnTF \@@_patch_cmd:Nnnnnw #1 + { once } + { + \ExplSyntaxOff + \char_set_catcode_letter:n { 64 } + } + { } + { \ctex_patch_failure:N #1 } + } +\cs_new_protected:Npn \ctex_patch_failure:N #1 + { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } +\msg_new:nnn { ctex } { patch-failure } + { Oops!~Command~`#1'~is~NOT~patchable.\\ } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_preto_cmd:NnnTF} +% 在宏的原本定义前面增加钩子。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_preto_cmd:NnnTF #1#2 + { + \ctex_patch_boot:NNnnTF \@@_hookto_cmd:Nnnnw #1 + { left } {#2} { \use_i:nn } { \use_ii:nn } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_appto_cmd:NnnTF} +% 在宏的原本定义后面追加钩子。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_appto_cmd:NnnTF #1#2 + { + \ctex_patch_boot:NNnnTF \@@_hookto_cmd:Nnnnw #1 + { right } {#2} { \use_i:nn } { \use_ii:nn } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_patch_boot:NNnnTF} +% 参数记号 |#| 作为宏的参数被读入时,总是会双写,会影响随后的字符串替换。需要先 +% 将它转换为普通符号。 +% \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} + \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 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\ctex_parse_name:NN} +% 用 \tn{DeclareRobustCommand} 定义的宏或者由 \tn{newcommand} 或 \tn{newrobustcmd} +% 定义的带一个可选参数的宏第一次展开的结果都不是其实际定义,实际定义被保存在另外的 +% 宏中。由这些命令定义的宏的第一次展开结果可以有下面的形式(细节可查阅 \pkg{xpatch} +% 的文档): +% \begin{verbatim}[numbers=left,gobble=4] +% \protect␣\xaa␣␣ % \DeclareRobustCommand\xaa[1]{...} +% \protect␣\xab␣␣ % \DeclareRobustCommand\xab[1][]{...} +% \@protected@testopt␣\xac␣\\xac␣{} % \newcommand\xac[1][]{...} +% \@testopt␣\\xad␣{} % \newrobustcmd\xad[1][]{...} +% \x@protect␣\1\protect␣\1␣␣ % \DeclareRobustCommand\1[1]{...} +% \x@protect␣\2\protect␣\2␣␣ % \DeclareRobustCommand\2[1][]{...} +% \@protected@testopt␣\3\\3␣{} % \newcommand\3[1][]{...} +% \@testopt␣\\4␣{} % \newrobustcmd\4[1][]{...} +% \end{verbatim} +% \pkg{ctexpatch} 的主要原理是先对宏的 \tn{meaning} 作字符串替换,然后再用 +% \tn{scantokens} 来重建它。我们希望对宏的实际定义打补丁,为此需要先得到 +% 对应的名字。\pkg{letltxmacro}、\pkg{show2e} 和 \pkg{xpatch} 宏包中都有 +% 类似的工作。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_parse_name:NN #1#2 + { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } +\group_begin: +\char_set_lccode:nn { `\< } { `\{ } +\char_set_lccode:nn { `\/ } { `\\ } +\char_set_lccode:nn { `\A } { `\t } +\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N +\tex_lowercase:D + { + \group_end: + \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 + { + \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } + { + \group_begin: + \use:x + { + \group_end: + \@@_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } + \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } + } {#3} #1 + } + { #1#2 } + } + \cs_new_protected:Npn \@@_parse_name:nNNNnN #1#2#3#4#5#6 + { + \exp_args:Nc #6 + { + \str_case:nnTF {#1} + { + { \protect #3 } { } + { \x@protect #2 \protect #3 } { } + } + { + \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } + { + \exp_last_unbraced:Nf \@@_parse_name:w + \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop + } + { /#5 ~ } { #5 ~ } + } + { + \str_case:onTF { \@@_parse_name:w #1 AESAOPA ~ < \q_stop } + { + { /@protected@ #2 #4 } { } + { /@ #4 } { } + } + { /#5 } {#5} + } + } + } + \cs_new:Npn \@@_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } + } +\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } +% \end{macrocode} +% \end{macro} +% +% \begin{variable}[int]{\l_@@_prefix_tl,\l_@@_parameter_tl,\l_@@_replacement_tl} +% 分别保存宏的 \tn{meaning} 中的前缀、参数文本和替换文本。 +% \begin{macrocode} +\tl_new:N \l_@@_prefix_tl +\tl_new:N \l_@@_parameter_tl +\tl_new:N \l_@@_replacement_tl +% \end{macrocode} +% \end{variable} +% +% \begin{macro}[int]{\ctex_get_macro_meaning:NTF} +% \begin{macro}[aux]{\@@_get_macro_meaning:w} +% 解构待补丁宏的 \tn{meaning}。若命令不是宏,则走向 |false| 分支。 +% \begin{macrocode} +\group_begin: + \char_set_lccode:nn { `\; } { `\: } + \tl_map_function:nN { \M \A \C \R \O \; } \char_set_catcode_other:N +\tex_lowercase:D + { + \group_end: + \cs_new_protected:Npn \ctex_get_macro_meaning:NTF #1 + { + \exp_after:wN \@@_get_macro_meaning:w + \token_to_meaning:N #1 \q_stop MACRO ; -> \q_no_value \q_stop + } + \cs_new_protected:Npn \@@_get_macro_meaning:w #1 MACRO ; #2 -> #3 \q_stop + { + \tl_set:Nn \l_@@_replacement_tl {#3} + \quark_if_no_value:NTF \l_@@_replacement_tl + { \use_ii:nn } + { + \tl_set:Nn \l_@@_prefix_tl {#1} + \tl_set:Nn \l_@@_parameter_tl {#2} + \use_i_delimit_by_q_stop:nw { \use_i:nn } + } + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}[int]{\ctex_if_rescanable:NnTF} +% 检查宏是否可以重建。 +% \begin{macrocode} +\cs_new_protected:Npn \ctex_if_rescanable:NnTF #1#2#3#4 + { + \ctex_get_macro_meaning:NTF #1 + { + \@@_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#2} + \cs_if_eq:NNTF #1 \CTEXPATCHRESCANCMD {#3} {#4} + } + {#4} + } +\cs_new_eq:NN \CTEXPATCHRESCANCMD \prg_do_nothing: +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\@@_patch_rebuild:Nn} +% 使用 \cs{tl_rescan:nn} 来重新记号化 \tn{meaning} 字符串。 +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_rebuild:Nn #1#2 + { + \tl_if_empty:nTF {#2} + { \tl_rescan:nx {#2} } + { + \tl_rescan:nx + { + #2 \scan_stop: + \int_set_eq:NN \tex_endlinechar:D \c_minus_one + \int_set_eq:NN \tex_newlinechar:D \c_minus_one + } + } + { + \l_@@_prefix_tl \exp_not:N \def \exp_not:N #1 \l_@@_parameter_tl + { \l_@@_replacement_tl } + } + } +\cs_generate_variant:Nn \tl_rescan:nn { nx } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\@@_patch_cmd:Nnnnnw} +% 对宏的替换文本进行字符串替换,然后重建。 +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_cmd:Nnnnnw #1#2#3#4#5 + { + \group_end: + \ctex_if_rescanable:NnTF #1 {#3} + { + \use:x + { + \@@_patch_replace:nnnTF {#2} + { \tl_to_str:n {#4} } + { \tl_to_str:n {#5} } + } + { + \@@_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3} + \cs_set_eq:NN #1 \CTEXPATCHRESCANCMD + \@@_patch_true:w + } + { \@@_patch_false:w } + } + { \@@_patch_false:w } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\@@_patch_replace:nnnTF} +% 替换前先检查原文本是否存在。 +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_replace:nnnTF #1#2#3#4 + { + \tl_if_in:NnTF \l_@@_replacement_tl {#2} + { \use:c { tl_replace_ #1 :Nnn } \l_@@_replacement_tl {#2} {#3} #4 } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[int]{\@@_hookto_cmd:Nnnnw} +% 在宏的前/后附加钩子。 +% \begin{macrocode} +\cs_new_protected:Npn \@@_hookto_cmd:Nnnnw #1#2#3#4 + { + \group_end: + \ctex_get_macro_meaning:NTF #1 + { + \tl_if_empty:NTF \l_@@_parameter_tl + { \@@_hookto_cmd_parameterless:Nnnw #1 {#2} {#4} } + { \@@_hookto_cmd_parameter:Nnnnw #1 {#2} {#3} {#4} } + } + { \@@_patch_false:w } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[aux]{\@@_hookto_cmd_parameterless:Nnnw} +% 如果宏没有参数,可以直接进行附加操作。注意保持宏的前缀。 +% \begin{macrocode} +\cs_new_protected:Npn \@@_hookto_cmd_parameterless:Nnnw #1#2#3 + { + \tl_if_empty:NF \l_@@_prefix_tl + { \tl_rescan:nx { } { \l_@@_prefix_tl } } + \edef #1 + { + \use:c { @@_ #2 _hook_aux:nn } + { \exp_not:o {#1} } + { \exp_not:n {#3} } + } + \@@_patch_true:w + } +\cs_new:Npn \@@_left_hook_aux:nn #1#2 { #2#1 } +\cs_new_eq:NN \@@_right_hook_aux:nn \use:nn +% \end{macrocode} +% \end{macro} +% +% \begin{macro}[aux]{\@@_hookto_cmd_parameter:Nnnnw} +% 如果宏有参数,需要在字符串中进行附加,然后再重建。 +% \begin{macrocode} +\cs_new_protected:Npn \@@_hookto_cmd_parameter:Nnnnw #1#2#3#4 + { + \@@_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3} + \cs_if_eq:NNTF #1 \CTEXPATCHRESCANCMD + { + \use:c { tl_put_ #2 :Nx } \l_@@_replacement_tl { \tl_to_str:n {#4} } + \@@_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3} + \cs_set_eq:NN #1 \CTEXPATCHRESCANCMD + \@@_patch_true:w + } + { \@@_patch_false:w } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%</ctexpatch> +% \end{macrocode} +% % \end{implementation} % % \Finale diff --git a/Master/texmf-dist/tex/generic/ctex/zhadobefonts.tex b/Master/texmf-dist/tex/generic/ctex/zhadobefonts.tex index 15290ad2039..2fb29caa89f 100644 --- a/Master/texmf-dist/tex/generic/ctex/zhadobefonts.tex +++ b/Master/texmf-dist/tex/generic/ctex/zhadobefonts.tex @@ -76,7 +76,7 @@ \fi \endgroup \ProvidesFile{zhadobefonts.tex}% - [2015/05/25 v2.1 Adobe font map loader for DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Adobe font map loader for DVIPDFMx (CTEX)] \ifzhmappdf %% pdfTeX does not support OTF fonts diff --git a/Master/texmf-dist/tex/generic/ctex/zhfandolfonts.tex b/Master/texmf-dist/tex/generic/ctex/zhfandolfonts.tex index 301c2d9e893..ddc33ab7737 100644 --- a/Master/texmf-dist/tex/generic/ctex/zhfandolfonts.tex +++ b/Master/texmf-dist/tex/generic/ctex/zhfandolfonts.tex @@ -76,7 +76,7 @@ \fi \endgroup \ProvidesFile{zhfandolfonts.tex}% - [2015/05/25 v2.1 Fandol font map loader for DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Fandol font map loader for DVIPDFMx (CTEX)] \ifzhmappdf %% pdfTeX does not support OTF fonts diff --git a/Master/texmf-dist/tex/generic/ctex/zhfounderfonts.tex b/Master/texmf-dist/tex/generic/ctex/zhfounderfonts.tex index 9295e4b5b0f..9df31d39992 100644 --- a/Master/texmf-dist/tex/generic/ctex/zhfounderfonts.tex +++ b/Master/texmf-dist/tex/generic/ctex/zhfounderfonts.tex @@ -76,7 +76,7 @@ \fi \endgroup \ProvidesFile{zhfounderfonts.tex}% - [2015/05/25 v2.1 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Founder font map loader for pdfTeX and DVIPDFMx (CTEX)] \ifzhmappdf \pdfmapline{=gbk@UGBK@ <FZSSK.TTF} diff --git a/Master/texmf-dist/tex/generic/ctex/zhubuntufonts.tex b/Master/texmf-dist/tex/generic/ctex/zhubuntufonts.tex index 00e952ffa53..e26a0d0545c 100644 --- a/Master/texmf-dist/tex/generic/ctex/zhubuntufonts.tex +++ b/Master/texmf-dist/tex/generic/ctex/zhubuntufonts.tex @@ -76,7 +76,7 @@ \fi \endgroup \ProvidesFile{zhubuntufonts.tex}% - [2015/05/25 v2.1 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Ubuntu font map loader for pdfTeX and DVIPDFMx (CTEX)] \ifzhmappdf \pdfmapline{=gbk@UGBK@ <uming.ttc} diff --git a/Master/texmf-dist/tex/generic/ctex/zhwindowsfonts.tex b/Master/texmf-dist/tex/generic/ctex/zhwindowsfonts.tex index 9b163944cbf..0775bf882d0 100644 --- a/Master/texmf-dist/tex/generic/ctex/zhwindowsfonts.tex +++ b/Master/texmf-dist/tex/generic/ctex/zhwindowsfonts.tex @@ -76,7 +76,7 @@ \fi \endgroup \ProvidesFile{zhwindowsfonts.tex}% - [2015/05/25 v2.1 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)] + [2015/07/01 v2.2 Windows font map loader for pdfTeX and DVIPDFMx (CTEX)] \ifzhmappdf \pdfmapline{=gbk@UGBK@ <simsun.ttc} diff --git a/Master/texmf-dist/tex/latex/ctex/config/ctex-name-gbk.cfg b/Master/texmf-dist/tex/latex/ctex/config/ctex-name-gbk.cfg index 445383b47fd..e7b67910cf2 100644 --- a/Master/texmf-dist/tex/latex/ctex/config/ctex-name-gbk.cfg +++ b/Master/texmf-dist/tex/latex/ctex/config/ctex-name-gbk.cfg @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Caption with encoding GBK (CTEX)} \ProvidesExplFile{ctex-name-gbk.cfg} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \keys_set:nn { ctex } { contentsname = Ŀ¼ , diff --git a/Master/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg b/Master/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg index 28f8903bb40..7b7304d527c 100644 --- a/Master/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg +++ b/Master/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Caption with encoding UTF8 (CTEX)} \ProvidesExplFile{ctex-name-utf8.cfg} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \keys_set:nn { ctex } { contentsname = 目录 , diff --git a/Master/texmf-dist/tex/latex/ctex/config/ctex.cfg b/Master/texmf-dist/tex/latex/ctex/config/ctex.cfg index 9441ebf9045..b27c064532a 100644 --- a/Master/texmf-dist/tex/latex/ctex/config/ctex.cfg +++ b/Master/texmf-dist/tex/latex/ctex/config/ctex.cfg @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Configuration file (CTEX)} \ProvidesExplFile{\ExplFileName.cfg} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} %% %% %% diff --git a/Master/texmf-dist/tex/latex/ctex/config/ctexopts.cfg b/Master/texmf-dist/tex/latex/ctex/config/ctexopts.cfg index 0d1bf614b7e..82074e82836 100644 --- a/Master/texmf-dist/tex/latex/ctex/config/ctexopts.cfg +++ b/Master/texmf-dist/tex/latex/ctex/config/ctexopts.cfg @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Option configuration file (CTEX)} \ProvidesExplFile{ctexopts.cfg} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} %% %% \keys_set:nn { ctex / option } { fontset = windowsnew } %% diff --git a/Master/texmf-dist/tex/latex/ctex/ctex-article.def b/Master/texmf-dist/tex/latex/ctex/ctex-article.def index be98bfc12e0..c1dfb48076e 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctex-article.def +++ b/Master/texmf-dist/tex/latex/ctex/ctex-article.def @@ -26,16 +26,17 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Heading modification for article (CTEX)} \ProvidesExplFile{ctex-article.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} + +\seq_new:N \c__ctex_section_headings_seq +\seq_gset_from_clist:Nn \c__ctex_section_headings_seq + { section , subsection , subsubsection , paragraph , subparagraph } \seq_new:N \c__ctex_headings_seq -\seq_gset_from_clist:Nn \c__ctex_headings_seq - { - part , section , subsection , subsubsection , - paragraph , subparagraph - } +\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq +\seq_gput_left:Nn \c__ctex_headings_seq { part } \cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1 { \tl_new:c { CTEX@pre#1 } @@ -68,49 +69,53 @@ { \tl_put_right:Nx \l__ctex_tmp_tl { - #1 .meta:nn = { ctex / #1 } { ####1 } , - #1 / name .code:n = + #1 .meta:nn = { ctex / #1 } { ####1 } , + #1 / name .code:n = { \ctex_assign_heading_name:nn {#1} { ####1 } } , - #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , - #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , - #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , - #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , - #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , - #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , - #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , - #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , - #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , - #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , - #1 / format+ .code:n = + #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , + #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , + #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , + #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , + #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , + #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , + #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , + #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , + #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , + #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , + #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , + #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , + #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / format~+ .code:n = + #1 / format~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / nameformat+ .code:n = + #1 / nameformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / nameformat~+ .code:n = + #1 / nameformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / numberformat+ .code:n = + #1 / numberformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / numberformat~+ .code:n = + #1 / numberformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / aftername+ .code:n = + #1 / aftername+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / aftername~+ .code:n = + #1 / aftername~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / titleformat+ .code:n = + #1 / titleformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / titleformat~+ .code:n = + #1 / titleformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / aftertitle+ .code:n = + #1 / aftertitle+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / aftertitle~+ .code:n = + #1 / aftertitle~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / beforeskip .initial:n = \c_zero_skip , - #1 / afterskip .initial:n = \c_zero_skip , - #1 / indent .initial:n = \c_zero_dim , - #1 / beforeskip .value_required: , - #1 / afterskip .value_required: , - #1 / indent .value_required: , + #1 / numbering .initial:n = true , + #1 / beforeskip .initial:n = \c_zero_skip , + #1 / afterskip .initial:n = \c_zero_skip , + #1 / indent .initial:n = \c_zero_dim , + #1 / beforeskip .value_required: , + #1 / afterskip .value_required: , + #1 / indent .value_required: , } } \NewDocumentCommand \ctex_assign_heading_name:nn @@ -130,43 +135,68 @@ } \use:x { \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } } \tl_clear:N \l__ctex_tmp_tl +\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } +\ctex_at_end_package:nn { hyperref } + { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } \renewcommand\part{% \if@noskipsec \leavevmode \fi \par - \@tempskipa \CTEX@part@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else + \addvspace{\glueexpr\CTEX@part@beforeskip\relax}% + \ifodd \CTEX@part@afterindent \@afterindenttrue + \else + \@afterindentfalse \fi - \addvspace{\@tempskipa}% \secdef\@part\@spart} \def\@part[#1]#2{% \ifnum \c@secnumdepth >\m@ne - \refstepcounter{part}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi {\interlinepenalty \@M - \normalfont \parindent \CTEX@part@indent \CTEX@part@format - \ifnum \c@secnumdepth >\m@ne + \normalfont \parindent \dimexpr \CTEX@part@indent \relax \CTEX@part@format + \ifnum \c@secnumdepth >\m@ne \ifodd \CTEX@part@numbering \CTEX@partname - \fi + \fi \fi \CTEX@part@titleformat{#2}% \markboth{}{}% \CTEX@part@aftertitle}% \nobreak - \vskip \CTEX@part@afterskip + \vskip \glueexpr \CTEX@part@afterskip \relax \@afterheading} \def\@spart#1{% {\interlinepenalty \@M - \normalfont \parindent \CTEX@part@indent \CTEX@part@format + \normalfont \parindent \dimexpr \CTEX@part@indent \relax + \CTEX@part@format \CTEX@part@titleformat{#1}% \CTEX@part@aftertitle}% \nobreak - \vskip \CTEX@part@afterskip + \vskip \glueexpr \CTEX@part@afterskip \relax \@afterheading} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \CTEX@update@sectionformat@n{#1}% + \ifodd \CTEX@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace{\glueexpr #4\relax}% + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} \def\@seccntformat#1{% \@ifundefined{CTEX@#1name}% {\csname the#1\endcsname\quad}% @@ -175,14 +205,18 @@ \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \ifodd \csname CTEX@#1@numbering\endcsname + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \else + \CTEX@makeheadinganchor + \let\@svsec\@empty + \fi \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #6{% - \@hangfrom{\hskip #3\relax\@svsec}% + \@hangfrom{\hskip\glueexpr #3\relax\@svsec}% \interlinepenalty \@M \csname CTEX@#1@titleformat\endcsname{#8}% \csname CTEX@#1@aftertitle\endcsname}% @@ -190,51 +224,80 @@ \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}% \else \def\@svsechd{% - #6{\hskip #3\relax + #6{\hskip\glueexpr #3\relax \@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{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}}% \fi \@xsect{#5}} \def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #4{% - \@hangfrom{\hskip #1}% + \@hangfrom{\hskip\glueexpr #1\relax}% \interlinepenalty \@M \CTEX@titleformat@n{#5}% \CTEX@aftertitle}% \endgroup \else - \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% + \def\@svsechd{#4{\hskip\glueexpr #1\relax + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} -\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1 +\def\@xsect#1{% + \unless \ifodd \CTEX@runin + \par \nobreak + \vskip\glueexpr #1\relax + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \begingroup \@svsechd \endgroup + \unskip + \hskip\glueexpr #1\relax + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +\cs_new_protected_nopar: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 } + \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } + \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } } \cs_new_eq:NN \CTEX@titleformat@n \use:n \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: +\cs_new_eq:NN \CTEX@afterindent \c_true_bool +\cs_new_eq:NN \CTEX@runin \c_false_bool \int_zero:N \l__ctex_tmp_int -\clist_map_inline:nn - { section , subsection , subsubsection , paragraph , subparagraph } +\seq_map_inline:Nn \c__ctex_section_headings_seq { \int_incr:N \l__ctex_tmp_int \cs_gset_protected_nopar:cpx {#1} @@ -244,18 +307,17 @@ { \exp_not:c { CTEX@#1@indent } } { \exp_not:c { CTEX@#1@beforeskip } } { \exp_not:c { CTEX@#1@afterskip } } - { - \CTEX@set@titleformat@n {#1} - \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } - } + { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } } } \keys_define:nn { ctex } { - appendix .meta:nn = { ctex / appendix } {#1} , - appendix / name .code:n = + appendix .meta:nn = { ctex / appendix } {#1} , + appendix / name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } , - appendix / number .tl_set:N = \CTEX@appendixnumber + appendix / number .tl_set:N = \CTEX@appendix@number , + appendix / numbering .bool_set:N = \CTEX@appendix@numbering , + appendix / numbering .initial:n = true } \tl_new:N \CTEX@preappendix \tl_new:N \CTEX@postappendix @@ -264,8 +326,76 @@ { \CTEX@save@appendix \gdef \CTEX@presection { \CTEX@preappendix } - \gdef \CTEX@thesection { \CTEX@appendixnumber } + \gdef \CTEX@thesection { \CTEX@appendix@number } \gdef \CTEX@postsection { \CTEX@postappendix } + \gdef \CTEX@section@numbering { \CTEX@appendix@numbering } + } +\cs_new_protected_nopar:Npn \ctex_titlesec_hook: + { + \@ifpackagewith { titlesec } { explicit } + { + \cs_set_eq:NN \__ctex_titlesec_format:Nn + \__ctex_titlesec_format_explicit:Nn + } + { } + \clist_map_inline:nn + { indentafter , noindentafter , indentfirst , nonindentfirst } + { + \@ifpackagewith { titlesec } { ##1 } + { + \clist_map_break:n + { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n } + } + { } + } + \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1 + { + \__ctex_titlesec_format:n {#1} + \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1} + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1 + { + \cs_if_free:cF { ttlf@#1 } + { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2 + { + \tl_set:Nx #1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \tl_tail:N #1 + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2 + { + \cs_set_nopar:Npx #1 ##1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \exp_args:No \tl_tail:n { #1 { } } + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } } +\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6 + { + \exp_not:n { {#1} {#2} {#3} {#4} } + { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } + } +\@ifpackageloaded { titlesec } + { } + { + \ctex_at_end_package:nn { titlesec } + { + \@ifpackagewith { titlesec } { loadonly } + { } + { \ctex_titlesec_hook: } + } } \cs_new_protected:Npn \CTEX@toc@width@n #1 { @@ -281,30 +411,39 @@ \use:n { \group_end: - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } \@ifpackageloaded { tocloft } { } { \ctex_at_end_package:nn { tocloft } { - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } } } - \ExplSyntaxOn } -\ctex_patch_cmd:Nnn \ps@headings { \thesection } { \CTEXthesection } +\ctex_patch_cmd:Nnn \ps@headings + { \thesection \quad } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesubsection } { \CTEXthesubsection } + \ctex_patch_cmd:Nnn \ps@headings + { \thesubsection \quad } + { \ifodd \CTEX@subsection@numbering \CTEXthesubsection \quad \fi } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \thesection \hskip 1em \relax } { \CTEXthesection \quad } + { \thesection \hskip 1em \relax } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesubsection \hskip 1em \relax } { \CTEXthesubsection \quad } + { \thesubsection \hskip 1em \relax } + { \ifodd \CTEX@subsection@numbering \CTEXthesubsection \quad \fi } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { diff --git a/Master/texmf-dist/tex/latex/ctex/ctex-book.def b/Master/texmf-dist/tex/latex/ctex/ctex-book.def index 43125e9a69b..5978f8e9c95 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctex-book.def +++ b/Master/texmf-dist/tex/latex/ctex/ctex-book.def @@ -26,16 +26,18 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Heading modification for book (CTEX)} \ProvidesExplFile{ctex-book.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} + +\seq_new:N \c__ctex_section_headings_seq +\seq_gset_from_clist:Nn \c__ctex_section_headings_seq + { section , subsection , subsubsection , paragraph , subparagraph } \seq_new:N \c__ctex_headings_seq -\seq_gset_from_clist:Nn \c__ctex_headings_seq - { - part , chapter , section , subsection , subsubsection , - paragraph , subparagraph - } +\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq +\seq_gput_left:Nn \c__ctex_headings_seq { chapter } +\seq_gput_left:Nn \c__ctex_headings_seq { part } \cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1 { \tl_new:c { CTEX@pre#1 } @@ -68,49 +70,53 @@ { \tl_put_right:Nx \l__ctex_tmp_tl { - #1 .meta:nn = { ctex / #1 } { ####1 } , - #1 / name .code:n = + #1 .meta:nn = { ctex / #1 } { ####1 } , + #1 / name .code:n = { \ctex_assign_heading_name:nn {#1} { ####1 } } , - #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , - #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , - #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , - #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , - #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , - #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , - #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , - #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , - #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , - #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , - #1 / format+ .code:n = + #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , + #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , + #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , + #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , + #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , + #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , + #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , + #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , + #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , + #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , + #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , + #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , + #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / format~+ .code:n = + #1 / format~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / nameformat+ .code:n = + #1 / nameformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / nameformat~+ .code:n = + #1 / nameformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / numberformat+ .code:n = + #1 / numberformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / numberformat~+ .code:n = + #1 / numberformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / aftername+ .code:n = + #1 / aftername+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / aftername~+ .code:n = + #1 / aftername~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / titleformat+ .code:n = + #1 / titleformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / titleformat~+ .code:n = + #1 / titleformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / aftertitle+ .code:n = + #1 / aftertitle+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / aftertitle~+ .code:n = + #1 / aftertitle~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / beforeskip .initial:n = \c_zero_skip , - #1 / afterskip .initial:n = \c_zero_skip , - #1 / indent .initial:n = \c_zero_dim , - #1 / beforeskip .value_required: , - #1 / afterskip .value_required: , - #1 / indent .value_required: , + #1 / numbering .initial:n = true , + #1 / beforeskip .initial:n = \c_zero_skip , + #1 / afterskip .initial:n = \c_zero_skip , + #1 / indent .initial:n = \c_zero_dim , + #1 / beforeskip .value_required: , + #1 / afterskip .value_required: , + #1 / indent .value_required: , } } \NewDocumentCommand \ctex_assign_heading_name:nn @@ -135,20 +141,42 @@ } \use:x { \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } } \tl_clear:N \l__ctex_tmp_tl -\def\@part[#1]#2{% +\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } +\ctex_at_end_package:nn { hyperref } + { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } +\renewcommand\part{% + \if@openright + \cleardoublepage + \else + \clearpage + \fi \thispagestyle{\CTEX@part@pagestyle}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi + \null\vskip \glueexpr \CTEX@part@beforeskip \relax + \secdef\@part\@spart} +\def\@part[#1]#2{% \ifnum \c@secnumdepth >-2\relax - \refstepcounter{part}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi \markboth{}{}% {\interlinepenalty \@M \normalfont \CTEX@part@format - \ifnum \c@secnumdepth >-2\relax + \ifnum \c@secnumdepth >-2\relax \ifodd \CTEX@part@numbering \CTEX@partname - \fi + \fi \fi \CTEX@part@titleformat{#2}% \CTEX@part@aftertitle}% \@endpart} @@ -158,13 +186,40 @@ \CTEX@part@titleformat{#1}% \CTEX@part@aftertitle}% \@endpart} +\def\@endpart{% + \vskip \glueexpr \CTEX@part@afterskip \relax + \newpage + \if@twoside + \if@openright + \null + \thispagestyle{empty}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi} +\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi + \thispagestyle{\CTEX@chapter@pagestyle}% + \global\@topnum\z@ + \ifodd \CTEX@chapter@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \secdef\@chapter\@schapter} \def\@chapter[#1]#2{% \ifnum \c@secnumdepth >\m@ne \if@mainmatter - \refstepcounter{chapter}% - \typeout{\CTEXthechapter}% - \addcontentsline{toc}{chapter} - {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \ifodd \CTEX@chapter@numbering + \refstepcounter{chapter}% + \typeout{\CTEXthechapter}% + \addcontentsline{toc}{chapter} + {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{chapter}{#1}% + \fi \else \addcontentsline{toc}{chapter}{#1}% \fi @@ -181,42 +236,49 @@ \@afterheading \fi} \def\@makechapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \ifnum \c@secnumdepth >\m@ne \if@mainmatter - \CTEX@chaptername + \ifodd \CTEX@chapter@numbering + \CTEX@chaptername + \fi \fi \fi \interlinepenalty\@M \CTEX@chapter@titleformat{#1}% \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} \def\@makeschapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \interlinepenalty\@M \CTEX@chapter@titleformat{#1} \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \CTEX@update@sectionformat@n{#1}% + \ifodd \CTEX@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace{\glueexpr #4\relax}% + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} \def\@seccntformat#1{% \@ifundefined{CTEX@#1name}% {\csname the#1\endcsname\quad}% @@ -225,14 +287,18 @@ \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \ifodd \csname CTEX@#1@numbering\endcsname + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \else + \CTEX@makeheadinganchor + \let\@svsec\@empty + \fi \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #6{% - \@hangfrom{\hskip #3\relax\@svsec}% + \@hangfrom{\hskip\glueexpr #3\relax\@svsec}% \interlinepenalty \@M \csname CTEX@#1@titleformat\endcsname{#8}% \csname CTEX@#1@aftertitle\endcsname}% @@ -240,51 +306,80 @@ \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}% \else \def\@svsechd{% - #6{\hskip #3\relax + #6{\hskip\glueexpr #3\relax \@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{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}}% \fi \@xsect{#5}} \def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #4{% - \@hangfrom{\hskip #1}% + \@hangfrom{\hskip\glueexpr #1\relax}% \interlinepenalty \@M \CTEX@titleformat@n{#5}% \CTEX@aftertitle}% \endgroup \else - \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% + \def\@svsechd{#4{\hskip\glueexpr #1\relax + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} -\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1 +\def\@xsect#1{% + \unless \ifodd \CTEX@runin + \par \nobreak + \vskip\glueexpr #1\relax + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \begingroup \@svsechd \endgroup + \unskip + \hskip\glueexpr #1\relax + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +\cs_new_protected_nopar: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 } + \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } + \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } } \cs_new_eq:NN \CTEX@titleformat@n \use:n \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: +\cs_new_eq:NN \CTEX@afterindent \c_true_bool +\cs_new_eq:NN \CTEX@runin \c_false_bool \int_zero:N \l__ctex_tmp_int -\clist_map_inline:nn - { section , subsection , subsubsection , paragraph , subparagraph } +\seq_map_inline:Nn \c__ctex_section_headings_seq { \int_incr:N \l__ctex_tmp_int \cs_gset_protected_nopar:cpx {#1} @@ -294,18 +389,17 @@ { \exp_not:c { CTEX@#1@indent } } { \exp_not:c { CTEX@#1@beforeskip } } { \exp_not:c { CTEX@#1@afterskip } } - { - \CTEX@set@titleformat@n {#1} - \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } - } + { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } } } \keys_define:nn { ctex } { - appendix .meta:nn = { ctex / appendix } {#1} , - appendix / name .code:n = + appendix .meta:nn = { ctex / appendix } {#1} , + appendix / name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } , - appendix / number .tl_set:N = \CTEX@appendixnumber + appendix / number .tl_set:N = \CTEX@appendix@number , + appendix / numbering .bool_set:N = \CTEX@appendix@numbering , + appendix / numbering .initial:n = true } \tl_new:N \CTEX@preappendix \tl_new:N \CTEX@postappendix @@ -314,8 +408,76 @@ { \CTEX@save@appendix \gdef \CTEX@prechapter { \CTEX@preappendix } - \gdef \CTEX@thechapter { \CTEX@appendixnumber } + \gdef \CTEX@thechapter { \CTEX@appendix@number } \gdef \CTEX@postchapter { \CTEX@postappendix } + \gdef \CTEX@chapter@numbering { \CTEX@appendix@numbering } + } +\cs_new_protected_nopar:Npn \ctex_titlesec_hook: + { + \@ifpackagewith { titlesec } { explicit } + { + \cs_set_eq:NN \__ctex_titlesec_format:Nn + \__ctex_titlesec_format_explicit:Nn + } + { } + \clist_map_inline:nn + { indentafter , noindentafter , indentfirst , nonindentfirst } + { + \@ifpackagewith { titlesec } { ##1 } + { + \clist_map_break:n + { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n } + } + { } + } + \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1 + { + \__ctex_titlesec_format:n {#1} + \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1} + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1 + { + \cs_if_free:cF { ttlf@#1 } + { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2 + { + \tl_set:Nx #1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \tl_tail:N #1 + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2 + { + \cs_set_nopar:Npx #1 ##1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \exp_args:No \tl_tail:n { #1 { } } + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } } +\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6 + { + \exp_not:n { {#1} {#2} {#3} {#4} } + { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } + } +\@ifpackageloaded { titlesec } + { } + { + \ctex_at_end_package:nn { titlesec } + { + \@ifpackagewith { titlesec } { loadonly } + { } + { \ctex_titlesec_hook: } + } } \cs_new_protected:Npn \CTEX@toc@width@n #1 { @@ -331,31 +493,39 @@ \use:n { \group_end: - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } \@ifpackageloaded { tocloft } { } { \ctex_at_end_package:nn { tocloft } { - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } } } - \ExplSyntaxOn } \ctex_patch_cmd:Nnn \ps@headings - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesection.~\ } { \CTEXthesection \quad } + \ctex_patch_cmd:Nnn \ps@headings + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \@chapapp\ \thechapter.~\ } { \if@mainmatter \CTEXthechapter \quad \fi } + { \@chapapp\ \thechapter.~\ } + { \if@mainmatter \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesection.~\ } { \CTEXthesection \quad } + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { diff --git a/Master/texmf-dist/tex/latex/ctex/ctex-c5size.clo b/Master/texmf-dist/tex/latex/ctex/ctex-c5size.clo index 963071bf90b..26993a98cf9 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctex-c5size.clo +++ b/Master/texmf-dist/tex/latex/ctex/ctex-c5size.clo @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {c5size option (CTEX)} \ProvidesExplFile{ctex-c5size.clo} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \ctex_set_font_size:Nnn \normalsize { 5 } { \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ diff --git a/Master/texmf-dist/tex/latex/ctex/ctex-cs4size.clo b/Master/texmf-dist/tex/latex/ctex/ctex-cs4size.clo index 36ea15530d6..0aa0c4088b8 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctex-cs4size.clo +++ b/Master/texmf-dist/tex/latex/ctex/ctex-cs4size.clo @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {cs4size option (CTEX)} \ProvidesExplFile{ctex-cs4size.clo} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \ctex_set_font_size:Nnn \normalsize { -4 } { \abovedisplayskip 12\p@ \@plus3\p@ \@minus7\p@ diff --git a/Master/texmf-dist/tex/latex/ctex/ctex-report.def b/Master/texmf-dist/tex/latex/ctex/ctex-report.def index 42b4b0b15bd..629360a2279 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctex-report.def +++ b/Master/texmf-dist/tex/latex/ctex/ctex-report.def @@ -26,16 +26,18 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Heading modification for report (CTEX)} \ProvidesExplFile{ctex-report.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} + +\seq_new:N \c__ctex_section_headings_seq +\seq_gset_from_clist:Nn \c__ctex_section_headings_seq + { section , subsection , subsubsection , paragraph , subparagraph } \seq_new:N \c__ctex_headings_seq -\seq_gset_from_clist:Nn \c__ctex_headings_seq - { - part , chapter , section , subsection , subsubsection , - paragraph , subparagraph - } +\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq +\seq_gput_left:Nn \c__ctex_headings_seq { chapter } +\seq_gput_left:Nn \c__ctex_headings_seq { part } \cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1 { \tl_new:c { CTEX@pre#1 } @@ -68,49 +70,53 @@ { \tl_put_right:Nx \l__ctex_tmp_tl { - #1 .meta:nn = { ctex / #1 } { ####1 } , - #1 / name .code:n = + #1 .meta:nn = { ctex / #1 } { ####1 } , + #1 / name .code:n = { \ctex_assign_heading_name:nn {#1} { ####1 } } , - #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , - #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , - #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , - #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , - #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , - #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , - #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , - #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , - #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , - #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , - #1 / format+ .code:n = + #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , + #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , + #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , + #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , + #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , + #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , + #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , + #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , + #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , + #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , + #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , + #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , + #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / format~+ .code:n = + #1 / format~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / nameformat+ .code:n = + #1 / nameformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / nameformat~+ .code:n = + #1 / nameformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / numberformat+ .code:n = + #1 / numberformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / numberformat~+ .code:n = + #1 / numberformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / aftername+ .code:n = + #1 / aftername+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / aftername~+ .code:n = + #1 / aftername~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / titleformat+ .code:n = + #1 / titleformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / titleformat~+ .code:n = + #1 / titleformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / aftertitle+ .code:n = + #1 / aftertitle+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / aftertitle~+ .code:n = + #1 / aftertitle~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / beforeskip .initial:n = \c_zero_skip , - #1 / afterskip .initial:n = \c_zero_skip , - #1 / indent .initial:n = \c_zero_dim , - #1 / beforeskip .value_required: , - #1 / afterskip .value_required: , - #1 / indent .value_required: , + #1 / numbering .initial:n = true , + #1 / beforeskip .initial:n = \c_zero_skip , + #1 / afterskip .initial:n = \c_zero_skip , + #1 / indent .initial:n = \c_zero_dim , + #1 / beforeskip .value_required: , + #1 / afterskip .value_required: , + #1 / indent .value_required: , } } \NewDocumentCommand \ctex_assign_heading_name:nn @@ -135,20 +141,42 @@ } \use:x { \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } } \tl_clear:N \l__ctex_tmp_tl -\def\@part[#1]#2{% +\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } +\ctex_at_end_package:nn { hyperref } + { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } +\renewcommand\part{% + \if@openright + \cleardoublepage + \else + \clearpage + \fi \thispagestyle{\CTEX@part@pagestyle}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi + \null\vskip \glueexpr \CTEX@part@beforeskip \relax + \secdef\@part\@spart} +\def\@part[#1]#2{% \ifnum \c@secnumdepth >-2\relax - \refstepcounter{part}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi \markboth{}{}% {\interlinepenalty \@M \normalfont \CTEX@part@format - \ifnum \c@secnumdepth >-2\relax + \ifnum \c@secnumdepth >-2\relax \ifodd \CTEX@part@numbering \CTEX@partname - \fi + \fi \fi \CTEX@part@titleformat{#2}% \CTEX@part@aftertitle}% \@endpart} @@ -158,12 +186,39 @@ \CTEX@part@titleformat{#1}% \CTEX@part@aftertitle}% \@endpart} +\def\@endpart{% + \vskip \glueexpr \CTEX@part@afterskip \relax + \newpage + \if@twoside + \if@openright + \null + \thispagestyle{empty}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi} +\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi + \thispagestyle{\CTEX@chapter@pagestyle}% + \global\@topnum\z@ + \ifodd \CTEX@chapter@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \secdef\@chapter\@schapter} \def\@chapter[#1]#2{% \ifnum \c@secnumdepth >\m@ne - \refstepcounter{chapter}% - \typeout{\CTEXthechapter}% - \addcontentsline{toc}{chapter} - {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \ifodd \CTEX@chapter@numbering + \refstepcounter{chapter}% + \typeout{\CTEXthechapter}% + \addcontentsline{toc}{chapter} + {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{chapter}{#1}% + \fi \else \addcontentsline{toc}{chapter}{#1}% \fi @@ -177,40 +232,47 @@ \@afterheading \fi} \def\@makechapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \ifnum \c@secnumdepth >\m@ne - \CTEX@chaptername + \ifodd \CTEX@chapter@numbering + \CTEX@chaptername + \fi \fi \interlinepenalty\@M \CTEX@chapter@titleformat{#1}% \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} \def\@makeschapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \interlinepenalty\@M \CTEX@chapter@titleformat{#1} \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \CTEX@update@sectionformat@n{#1}% + \ifodd \CTEX@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace{\glueexpr #4\relax}% + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} \def\@seccntformat#1{% \@ifundefined{CTEX@#1name}% {\csname the#1\endcsname\quad}% @@ -219,14 +281,18 @@ \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \ifodd \csname CTEX@#1@numbering\endcsname + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \else + \CTEX@makeheadinganchor + \let\@svsec\@empty + \fi \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #6{% - \@hangfrom{\hskip #3\relax\@svsec}% + \@hangfrom{\hskip\glueexpr #3\relax\@svsec}% \interlinepenalty \@M \csname CTEX@#1@titleformat\endcsname{#8}% \csname CTEX@#1@aftertitle\endcsname}% @@ -234,51 +300,80 @@ \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}% \else \def\@svsechd{% - #6{\hskip #3\relax + #6{\hskip\glueexpr #3\relax \@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{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}}% \fi \@xsect{#5}} \def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #4{% - \@hangfrom{\hskip #1}% + \@hangfrom{\hskip\glueexpr #1\relax}% \interlinepenalty \@M \CTEX@titleformat@n{#5}% \CTEX@aftertitle}% \endgroup \else - \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% + \def\@svsechd{#4{\hskip\glueexpr #1\relax + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} -\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1 +\def\@xsect#1{% + \unless \ifodd \CTEX@runin + \par \nobreak + \vskip\glueexpr #1\relax + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \begingroup \@svsechd \endgroup + \unskip + \hskip\glueexpr #1\relax + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +\cs_new_protected_nopar: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 } + \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } + \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } } \cs_new_eq:NN \CTEX@titleformat@n \use:n \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: +\cs_new_eq:NN \CTEX@afterindent \c_true_bool +\cs_new_eq:NN \CTEX@runin \c_false_bool \int_zero:N \l__ctex_tmp_int -\clist_map_inline:nn - { section , subsection , subsubsection , paragraph , subparagraph } +\seq_map_inline:Nn \c__ctex_section_headings_seq { \int_incr:N \l__ctex_tmp_int \cs_gset_protected_nopar:cpx {#1} @@ -288,18 +383,17 @@ { \exp_not:c { CTEX@#1@indent } } { \exp_not:c { CTEX@#1@beforeskip } } { \exp_not:c { CTEX@#1@afterskip } } - { - \CTEX@set@titleformat@n {#1} - \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } - } + { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } } } \keys_define:nn { ctex } { - appendix .meta:nn = { ctex / appendix } {#1} , - appendix / name .code:n = + appendix .meta:nn = { ctex / appendix } {#1} , + appendix / name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } , - appendix / number .tl_set:N = \CTEX@appendixnumber + appendix / number .tl_set:N = \CTEX@appendix@number , + appendix / numbering .bool_set:N = \CTEX@appendix@numbering , + appendix / numbering .initial:n = true } \tl_new:N \CTEX@preappendix \tl_new:N \CTEX@postappendix @@ -308,8 +402,76 @@ { \CTEX@save@appendix \gdef \CTEX@prechapter { \CTEX@preappendix } - \gdef \CTEX@thechapter { \CTEX@appendixnumber } + \gdef \CTEX@thechapter { \CTEX@appendix@number } \gdef \CTEX@postchapter { \CTEX@postappendix } + \gdef \CTEX@chapter@numbering { \CTEX@appendix@numbering } + } +\cs_new_protected_nopar:Npn \ctex_titlesec_hook: + { + \@ifpackagewith { titlesec } { explicit } + { + \cs_set_eq:NN \__ctex_titlesec_format:Nn + \__ctex_titlesec_format_explicit:Nn + } + { } + \clist_map_inline:nn + { indentafter , noindentafter , indentfirst , nonindentfirst } + { + \@ifpackagewith { titlesec } { ##1 } + { + \clist_map_break:n + { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n } + } + { } + } + \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1 + { + \__ctex_titlesec_format:n {#1} + \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1} + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1 + { + \cs_if_free:cF { ttlf@#1 } + { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2 + { + \tl_set:Nx #1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \tl_tail:N #1 + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2 + { + \cs_set_nopar:Npx #1 ##1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \exp_args:No \tl_tail:n { #1 { } } + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } } +\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6 + { + \exp_not:n { {#1} {#2} {#3} {#4} } + { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } + } +\@ifpackageloaded { titlesec } + { } + { + \ctex_at_end_package:nn { titlesec } + { + \@ifpackagewith { titlesec } { loadonly } + { } + { \ctex_titlesec_hook: } + } } \cs_new_protected:Npn \CTEX@toc@width@n #1 { @@ -325,31 +487,39 @@ \use:n { \group_end: - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } \@ifpackageloaded { tocloft } { } { \ctex_at_end_package:nn { tocloft } { - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } } } - \ExplSyntaxOn } \ctex_patch_cmd:Nnn \ps@headings - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesection.~\ } { \CTEXthesection \quad } + \ctex_patch_cmd:Nnn \ps@headings + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesection.~\ } { \CTEXthesection \quad } + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { diff --git a/Master/texmf-dist/tex/latex/ctex/ctex.sty b/Master/texmf-dist/tex/latex/ctex/ctex.sty index 615e615d807..82a943cb854 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctex.sty +++ b/Master/texmf-dist/tex/latex/ctex/ctex.sty @@ -28,10 +28,10 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese adapter in LaTeX (CTEX)} \ProvidesExplPackage{\ExplFileName} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \tl_const:Nx \c__ctex_version_tl { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } } \msg_new:nnnn { ctex } { subpackage-loaded } @@ -47,35 +47,12 @@ { \msg_error:nnn { ctex } { subpackage-loaded } { ctexheading } } { \cs_new_eq:cN { ver@ctexheading. \@pkgextension } \c__ctex_version_tl } \RequirePackage { xparse , l3keys2e } -\RequirePackage { etoolbox } +\RequirePackage { ctexhook , ctexpatch } \RequirePackage { fix-cm , everysel } \tl_new:N \l__ctex_tmp_tl \int_new:N \l__ctex_tmp_int \dim_new:N \l__ctex_tmp_dim \box_new:N \l__ctex_tmp_box -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 - { - \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} } - } -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 - { - \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} - } -\cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 - { - \cs_if_exist_use:cT { g__ctex_at_end_ #1 _hook_tl } - { \cs_undefine:c { g__ctex_at_end_ #1 _hook_tl } } - } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } -\tl_put_left:Nn \@popfilename - { - \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } - } \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { \use:x @@ -108,90 +85,6 @@ { } } \cs_generate_variant:Nn \ctex_scheme_input:n { o } -\cs_new_protected:Npn \ctex_parse_name:NN #1#2 - { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } -\group_begin: -\char_set_lccode:nn { `\< } { `\{ } -\char_set_lccode:nn { `\/ } { `\\ } -\char_set_lccode:nn { `\A } { `\t } -\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N -\tex_lowercase:D - { - \group_end: - \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 - { - \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } - { - \group_begin: - \use:x - { - \group_end: - \__ctex_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } - \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } - } {#3} #1 - } - { #1#2 } - } - \cs_new_protected:Npn \__ctex_parse_name:nNNNnN #1#2#3#4#5#6 - { - \exp_args:Nc #6 - { - \str_case:nnTF {#1} - { - { \protect #3 } { } - { \x@protect #2 \protect #3 } { } - } - { - \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } - { - \exp_last_unbraced:Nf \__ctex_parse_name:w - \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop - } - { /#5 ~ } { #5 ~ } - } - { - \str_case:onTF { \__ctex_parse_name:w #1 AESAOPA ~ < \q_stop } - { - { /@protected@ #2 #4 } { } - { /@ #4 } { } - } - { /#5 } {#5} - } - } - } - \cs_new:Npn \__ctex_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } - } -\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } -\cs_new_protected_nopar:Npn \ctex_patch_cmd:NnnTF { \ctex_parse_name:NN \patchcmd } -\cs_new_protected_nopar:Npn \ctex_preto_cmd:NnTF { \ctex_parse_name:NN \pretocmd } -\cs_new_protected_nopar:Npn \ctex_appto_cmd:NnTF { \ctex_parse_name:NN \apptocmd } -\cs_new_protected:Npn \ctex_patch_cmd:Nnn - { - \group_begin: - \char_set_catcode_other:N \# - \__ctex_patch_cmd:Nnn - } -\cs_new_protected:Npn \__ctex_patch_cmd:Nnn #1#2#3 - { - \group_end: - \group_begin: - \ExplSyntaxOff - \ctex_patch_cmd:NnnTF #1 {#2} {#3} - { - \cs_gset_eq:NN \__ctex_tmp:w #1 - \group_end: - \cs_set_eq:NN #1 \__ctex_tmp:w - \cs_undefine:N \__ctex_tmp:w - } - { \group_end: \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \ctex_patch_failure:N #1 - { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } -\msg_new:nnn { ctex } { patch-failure } - { - Patching~command~`#1'~failed.\\ - ctex~may~not~work~as~expected. - } \cs_new_eq:NN \g__ctex_section_depth_flag \c_two \msg_new:nnnn { ctex } { package-too-old } { Support~package~`#1'~too~old. } @@ -214,7 +107,7 @@ \cs_new_eq:NN \ctex_if_pdfmode:TF \use_ii:nn } \cs_new_eq:NN \ctex_if_preamble:TF \use_i:nn -\AfterEndPreamble { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } +\ctex_after_end_preamble:n { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } \cs_new:Npn \ctex_set_default_ccwd:Nn #1#2 { \dim_compare:nNnTF @@ -299,8 +192,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options.~ } } , @@ -309,8 +202,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options. } } , @@ -442,7 +335,7 @@ \cs_if_exist:NF \hypersetup { \cs_new_eq:NN \hypersetup \ctex_hypersetup:n } } - \AtEndPreamble { \RequirePackage { hyperref } } + \ctex_at_end_preamble:n { \RequirePackage { hyperref } } } , } \tl_clear:N \l__ctex_tmp_tl @@ -638,6 +531,14 @@ \cs_new_eq:NN \chinese \zhnum \cs_new_eq:NN \Chinese \chinese \cs_new_eq:NN \CTEXcounter \use_none:n +\ctex_at_end_package:nn { enumitem } + { + \cs_if_free:NF \AddEnumerateCounter + { + \AddEnumerateCounter * { \zhnum } { \zhnum_int:n } { 1 } + \AddEnumerateCounter * { \chinese } { \zhnum_int:n } { 1 } + } + } \NewDocumentCommand \CTEXnumber { m m } { \protected@edef #1 { \zhnumber {#2} } } \NewDocumentCommand \CTEXdigits { m m } @@ -818,7 +719,7 @@ \fi: \fp_compare:nNnF { \l__ctex_line_spread_fp } ? { \c_zero_fp } { - \linespread { \fp_use:N \l__ctex_line_spread_fp } + \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp } \group_begin: \footnotesize \exp_args:NNNo \group_end: \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } } @@ -835,26 +736,6 @@ { You~can~load~the~package~`caption'~to~get~its~functionality. } } } -\group_begin: -\char_set_catcode_other:N \# -\use:n - { - \group_end: - \ExplSyntaxOff - \ctex_at_end_package:nn { breqn } - { - \ctex_patch_cmd:NnnTF \end { \csname end#1 \endcsname } - { - \csuse { @end@#1@hook } - \csname end#1 \endcsname - } { } - { - \ctex_preto_cmd:NnTF \end { \csuse { @end@#1@hook } } - { } { \ctex_patch_failure:N \end } - } - } - \ExplSyntaxOn - } \cs_new_protected_nopar:Npn \ctex_fontset_error:n #1 { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} } \msg_new:nnn { ctex } { fontset-unavailable } @@ -928,12 +809,14 @@ %% and the derived files ctex.pdf, %% ctex.ins, %% ctex.sty, -%% ctexcap.sty, %% ctexsize.sty, %% ctexheading.sty, %% ctexart.cls, %% ctexbook.cls, %% ctexrep.cls, +%% ctexcap.sty, +%% ctexhook.sty, +%% ctexpatch.sty, %% ctex-c5size.clo, %% ctex-cs4size.clo, %% ctex-article.def, diff --git a/Master/texmf-dist/tex/latex/ctex/ctexart.cls b/Master/texmf-dist/tex/latex/ctex/ctexart.cls index 0af93272ce1..85cd0e3f0ab 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexart.cls +++ b/Master/texmf-dist/tex/latex/ctex/ctexart.cls @@ -28,10 +28,10 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese adapter for class article (CTEX)} \ProvidesExplClass{ctexart} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \tl_const:Nx \c__ctex_version_tl { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } } \cs_new_eq:cN { ver@ctex. \@pkgextension } \c__ctex_version_tl @@ -50,35 +50,12 @@ { \msg_error:nnn { ctex } { l3-too-old } { expl3 } } \@ifpackagelater { l3keys2e } { 2014/05/05 } { } { \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } } -\RequirePackage { etoolbox } +\RequirePackage { ctexhook , ctexpatch } \RequirePackage { fix-cm , everysel } \tl_new:N \l__ctex_tmp_tl \int_new:N \l__ctex_tmp_int \dim_new:N \l__ctex_tmp_dim \box_new:N \l__ctex_tmp_box -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 - { - \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} } - } -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 - { - \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} - } -\cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 - { - \cs_if_exist_use:cT { g__ctex_at_end_ #1 _hook_tl } - { \cs_undefine:c { g__ctex_at_end_ #1 _hook_tl } } - } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } -\tl_put_left:Nn \@popfilename - { - \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } - } \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { \use:x @@ -111,90 +88,6 @@ { } } \cs_generate_variant:Nn \ctex_scheme_input:n { o } -\cs_new_protected:Npn \ctex_parse_name:NN #1#2 - { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } -\group_begin: -\char_set_lccode:nn { `\< } { `\{ } -\char_set_lccode:nn { `\/ } { `\\ } -\char_set_lccode:nn { `\A } { `\t } -\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N -\tex_lowercase:D - { - \group_end: - \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 - { - \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } - { - \group_begin: - \use:x - { - \group_end: - \__ctex_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } - \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } - } {#3} #1 - } - { #1#2 } - } - \cs_new_protected:Npn \__ctex_parse_name:nNNNnN #1#2#3#4#5#6 - { - \exp_args:Nc #6 - { - \str_case:nnTF {#1} - { - { \protect #3 } { } - { \x@protect #2 \protect #3 } { } - } - { - \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } - { - \exp_last_unbraced:Nf \__ctex_parse_name:w - \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop - } - { /#5 ~ } { #5 ~ } - } - { - \str_case:onTF { \__ctex_parse_name:w #1 AESAOPA ~ < \q_stop } - { - { /@protected@ #2 #4 } { } - { /@ #4 } { } - } - { /#5 } {#5} - } - } - } - \cs_new:Npn \__ctex_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } - } -\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } -\cs_new_protected_nopar:Npn \ctex_patch_cmd:NnnTF { \ctex_parse_name:NN \patchcmd } -\cs_new_protected_nopar:Npn \ctex_preto_cmd:NnTF { \ctex_parse_name:NN \pretocmd } -\cs_new_protected_nopar:Npn \ctex_appto_cmd:NnTF { \ctex_parse_name:NN \apptocmd } -\cs_new_protected:Npn \ctex_patch_cmd:Nnn - { - \group_begin: - \char_set_catcode_other:N \# - \__ctex_patch_cmd:Nnn - } -\cs_new_protected:Npn \__ctex_patch_cmd:Nnn #1#2#3 - { - \group_end: - \group_begin: - \ExplSyntaxOff - \ctex_patch_cmd:NnnTF #1 {#2} {#3} - { - \cs_gset_eq:NN \__ctex_tmp:w #1 - \group_end: - \cs_set_eq:NN #1 \__ctex_tmp:w - \cs_undefine:N \__ctex_tmp:w - } - { \group_end: \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \ctex_patch_failure:N #1 - { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } -\msg_new:nnn { ctex } { patch-failure } - { - Patching~command~`#1'~failed.\\ - ctex~may~not~work~as~expected. - } \cs_new_eq:NN \g__ctex_section_depth_flag \c_two \msg_new:nnnn { ctex } { package-too-old } { Support~package~`#1'~too~old. } @@ -217,7 +110,7 @@ \cs_new_eq:NN \ctex_if_pdfmode:TF \use_ii:nn } \cs_new_eq:NN \ctex_if_preamble:TF \use_i:nn -\AfterEndPreamble { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } +\ctex_after_end_preamble:n { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } \cs_new:Npn \ctex_set_default_ccwd:Nn #1#2 { \dim_compare:nNnTF @@ -303,8 +196,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options.~ } } , @@ -313,8 +206,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options. } } , @@ -446,7 +339,7 @@ \cs_if_exist:NF \hypersetup { \cs_new_eq:NN \hypersetup \ctex_hypersetup:n } } - \AtEndPreamble { \RequirePackage { hyperref } } + \ctex_at_end_preamble:n { \RequirePackage { hyperref } } } , } \tl_clear:N \l__ctex_tmp_tl @@ -658,6 +551,14 @@ \cs_new_eq:NN \chinese \zhnum \cs_new_eq:NN \Chinese \chinese \cs_new_eq:NN \CTEXcounter \use_none:n +\ctex_at_end_package:nn { enumitem } + { + \cs_if_free:NF \AddEnumerateCounter + { + \AddEnumerateCounter * { \zhnum } { \zhnum_int:n } { 1 } + \AddEnumerateCounter * { \chinese } { \zhnum_int:n } { 1 } + } + } \NewDocumentCommand \CTEXnumber { m m } { \protected@edef #1 { \zhnumber {#2} } } \NewDocumentCommand \CTEXdigits { m m } @@ -696,12 +597,13 @@ appendixname .tl_set:N = \appendixname , bibname .tl_set:N = \refname } + +\seq_new:N \c__ctex_section_headings_seq +\seq_gset_from_clist:Nn \c__ctex_section_headings_seq + { section , subsection , subsubsection , paragraph , subparagraph } \seq_new:N \c__ctex_headings_seq -\seq_gset_from_clist:Nn \c__ctex_headings_seq - { - part , section , subsection , subsubsection , - paragraph , subparagraph - } +\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq +\seq_gput_left:Nn \c__ctex_headings_seq { part } \cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1 { \tl_new:c { CTEX@pre#1 } @@ -734,49 +636,53 @@ { \tl_put_right:Nx \l__ctex_tmp_tl { - #1 .meta:nn = { ctex / #1 } { ####1 } , - #1 / name .code:n = + #1 .meta:nn = { ctex / #1 } { ####1 } , + #1 / name .code:n = { \ctex_assign_heading_name:nn {#1} { ####1 } } , - #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , - #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , - #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , - #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , - #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , - #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , - #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , - #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , - #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , - #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , - #1 / format+ .code:n = + #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , + #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , + #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , + #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , + #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , + #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , + #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , + #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , + #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , + #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , + #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , + #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , + #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / format~+ .code:n = + #1 / format~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / nameformat+ .code:n = + #1 / nameformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / nameformat~+ .code:n = + #1 / nameformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / numberformat+ .code:n = + #1 / numberformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / numberformat~+ .code:n = + #1 / numberformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / aftername+ .code:n = + #1 / aftername+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / aftername~+ .code:n = + #1 / aftername~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / titleformat+ .code:n = + #1 / titleformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / titleformat~+ .code:n = + #1 / titleformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / aftertitle+ .code:n = + #1 / aftertitle+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / aftertitle~+ .code:n = + #1 / aftertitle~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / beforeskip .initial:n = \c_zero_skip , - #1 / afterskip .initial:n = \c_zero_skip , - #1 / indent .initial:n = \c_zero_dim , - #1 / beforeskip .value_required: , - #1 / afterskip .value_required: , - #1 / indent .value_required: , + #1 / numbering .initial:n = true , + #1 / beforeskip .initial:n = \c_zero_skip , + #1 / afterskip .initial:n = \c_zero_skip , + #1 / indent .initial:n = \c_zero_dim , + #1 / beforeskip .value_required: , + #1 / afterskip .value_required: , + #1 / indent .value_required: , } } \NewDocumentCommand \ctex_assign_heading_name:nn @@ -796,43 +702,68 @@ } \use:x { \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } } \tl_clear:N \l__ctex_tmp_tl +\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } +\ctex_at_end_package:nn { hyperref } + { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } \renewcommand\part{% \if@noskipsec \leavevmode \fi \par - \@tempskipa \CTEX@part@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else + \addvspace{\glueexpr\CTEX@part@beforeskip\relax}% + \ifodd \CTEX@part@afterindent \@afterindenttrue + \else + \@afterindentfalse \fi - \addvspace{\@tempskipa}% \secdef\@part\@spart} \def\@part[#1]#2{% \ifnum \c@secnumdepth >\m@ne - \refstepcounter{part}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi {\interlinepenalty \@M - \normalfont \parindent \CTEX@part@indent \CTEX@part@format - \ifnum \c@secnumdepth >\m@ne + \normalfont \parindent \dimexpr \CTEX@part@indent \relax \CTEX@part@format + \ifnum \c@secnumdepth >\m@ne \ifodd \CTEX@part@numbering \CTEX@partname - \fi + \fi \fi \CTEX@part@titleformat{#2}% \markboth{}{}% \CTEX@part@aftertitle}% \nobreak - \vskip \CTEX@part@afterskip + \vskip \glueexpr \CTEX@part@afterskip \relax \@afterheading} \def\@spart#1{% {\interlinepenalty \@M - \normalfont \parindent \CTEX@part@indent \CTEX@part@format + \normalfont \parindent \dimexpr \CTEX@part@indent \relax + \CTEX@part@format \CTEX@part@titleformat{#1}% \CTEX@part@aftertitle}% \nobreak - \vskip \CTEX@part@afterskip + \vskip \glueexpr \CTEX@part@afterskip \relax \@afterheading} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \CTEX@update@sectionformat@n{#1}% + \ifodd \CTEX@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace{\glueexpr #4\relax}% + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} \def\@seccntformat#1{% \@ifundefined{CTEX@#1name}% {\csname the#1\endcsname\quad}% @@ -841,14 +772,18 @@ \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \ifodd \csname CTEX@#1@numbering\endcsname + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \else + \CTEX@makeheadinganchor + \let\@svsec\@empty + \fi \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #6{% - \@hangfrom{\hskip #3\relax\@svsec}% + \@hangfrom{\hskip\glueexpr #3\relax\@svsec}% \interlinepenalty \@M \csname CTEX@#1@titleformat\endcsname{#8}% \csname CTEX@#1@aftertitle\endcsname}% @@ -856,51 +791,80 @@ \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}% \else \def\@svsechd{% - #6{\hskip #3\relax + #6{\hskip\glueexpr #3\relax \@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{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}}% \fi \@xsect{#5}} \def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #4{% - \@hangfrom{\hskip #1}% + \@hangfrom{\hskip\glueexpr #1\relax}% \interlinepenalty \@M \CTEX@titleformat@n{#5}% \CTEX@aftertitle}% \endgroup \else - \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% + \def\@svsechd{#4{\hskip\glueexpr #1\relax + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} -\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1 +\def\@xsect#1{% + \unless \ifodd \CTEX@runin + \par \nobreak + \vskip\glueexpr #1\relax + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \begingroup \@svsechd \endgroup + \unskip + \hskip\glueexpr #1\relax + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +\cs_new_protected_nopar: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 } + \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } + \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } } \cs_new_eq:NN \CTEX@titleformat@n \use:n \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: +\cs_new_eq:NN \CTEX@afterindent \c_true_bool +\cs_new_eq:NN \CTEX@runin \c_false_bool \int_zero:N \l__ctex_tmp_int -\clist_map_inline:nn - { section , subsection , subsubsection , paragraph , subparagraph } +\seq_map_inline:Nn \c__ctex_section_headings_seq { \int_incr:N \l__ctex_tmp_int \cs_gset_protected_nopar:cpx {#1} @@ -910,18 +874,17 @@ { \exp_not:c { CTEX@#1@indent } } { \exp_not:c { CTEX@#1@beforeskip } } { \exp_not:c { CTEX@#1@afterskip } } - { - \CTEX@set@titleformat@n {#1} - \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } - } + { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } } } \keys_define:nn { ctex } { - appendix .meta:nn = { ctex / appendix } {#1} , - appendix / name .code:n = + appendix .meta:nn = { ctex / appendix } {#1} , + appendix / name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } , - appendix / number .tl_set:N = \CTEX@appendixnumber + appendix / number .tl_set:N = \CTEX@appendix@number , + appendix / numbering .bool_set:N = \CTEX@appendix@numbering , + appendix / numbering .initial:n = true } \tl_new:N \CTEX@preappendix \tl_new:N \CTEX@postappendix @@ -930,8 +893,76 @@ { \CTEX@save@appendix \gdef \CTEX@presection { \CTEX@preappendix } - \gdef \CTEX@thesection { \CTEX@appendixnumber } + \gdef \CTEX@thesection { \CTEX@appendix@number } \gdef \CTEX@postsection { \CTEX@postappendix } + \gdef \CTEX@section@numbering { \CTEX@appendix@numbering } + } +\cs_new_protected_nopar:Npn \ctex_titlesec_hook: + { + \@ifpackagewith { titlesec } { explicit } + { + \cs_set_eq:NN \__ctex_titlesec_format:Nn + \__ctex_titlesec_format_explicit:Nn + } + { } + \clist_map_inline:nn + { indentafter , noindentafter , indentfirst , nonindentfirst } + { + \@ifpackagewith { titlesec } { ##1 } + { + \clist_map_break:n + { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n } + } + { } + } + \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1 + { + \__ctex_titlesec_format:n {#1} + \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1} + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1 + { + \cs_if_free:cF { ttlf@#1 } + { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2 + { + \tl_set:Nx #1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \tl_tail:N #1 + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2 + { + \cs_set_nopar:Npx #1 ##1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \exp_args:No \tl_tail:n { #1 { } } + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } } +\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6 + { + \exp_not:n { {#1} {#2} {#3} {#4} } + { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } + } +\@ifpackageloaded { titlesec } + { } + { + \ctex_at_end_package:nn { titlesec } + { + \@ifpackagewith { titlesec } { loadonly } + { } + { \ctex_titlesec_hook: } + } } \cs_new_protected:Npn \CTEX@toc@width@n #1 { @@ -947,30 +978,39 @@ \use:n { \group_end: - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } \@ifpackageloaded { tocloft } { } { \ctex_at_end_package:nn { tocloft } { - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } } } - \ExplSyntaxOn } -\ctex_patch_cmd:Nnn \ps@headings { \thesection } { \CTEXthesection } +\ctex_patch_cmd:Nnn \ps@headings + { \thesection \quad } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesubsection } { \CTEXthesubsection } + \ctex_patch_cmd:Nnn \ps@headings + { \thesubsection \quad } + { \ifodd \CTEX@subsection@numbering \CTEXthesubsection \quad \fi } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \thesection \hskip 1em \relax } { \CTEXthesection \quad } + { \thesection \hskip 1em \relax } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesubsection \hskip 1em \relax } { \CTEXthesubsection \quad } + { \thesubsection \hskip 1em \relax } + { \ifodd \CTEX@subsection@numbering \CTEXthesubsection \quad \fi } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { @@ -1102,7 +1142,7 @@ \fi: \fp_compare:nNnF { \l__ctex_line_spread_fp } ? { \c_zero_fp } { - \linespread { \fp_use:N \l__ctex_line_spread_fp } + \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp } \group_begin: \footnotesize \exp_args:NNNo \group_end: \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } } @@ -1119,26 +1159,6 @@ { You~can~load~the~package~`caption'~to~get~its~functionality. } } } -\group_begin: -\char_set_catcode_other:N \# -\use:n - { - \group_end: - \ExplSyntaxOff - \ctex_at_end_package:nn { breqn } - { - \ctex_patch_cmd:NnnTF \end { \csname end#1 \endcsname } - { - \csuse { @end@#1@hook } - \csname end#1 \endcsname - } { } - { - \ctex_preto_cmd:NnTF \end { \csuse { @end@#1@hook } } - { } { \ctex_patch_failure:N \end } - } - } - \ExplSyntaxOn - } \cs_new_protected_nopar:Npn \ctex_fontset_error:n #1 { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} } \msg_new:nnn { ctex } { fontset-unavailable } @@ -1212,12 +1232,14 @@ %% and the derived files ctex.pdf, %% ctex.ins, %% ctex.sty, -%% ctexcap.sty, %% ctexsize.sty, %% ctexheading.sty, %% ctexart.cls, %% ctexbook.cls, %% ctexrep.cls, +%% ctexcap.sty, +%% ctexhook.sty, +%% ctexpatch.sty, %% ctex-c5size.clo, %% ctex-cs4size.clo, %% ctex-article.def, diff --git a/Master/texmf-dist/tex/latex/ctex/ctexbook.cls b/Master/texmf-dist/tex/latex/ctex/ctexbook.cls index 3e6a5d76736..41e4f5b9690 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexbook.cls +++ b/Master/texmf-dist/tex/latex/ctex/ctexbook.cls @@ -28,10 +28,10 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese adapter for class book (CTEX)} \ProvidesExplClass{ctexbook} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \tl_const:Nx \c__ctex_version_tl { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } } \cs_new_eq:cN { ver@ctex. \@pkgextension } \c__ctex_version_tl @@ -50,35 +50,12 @@ { \msg_error:nnn { ctex } { l3-too-old } { expl3 } } \@ifpackagelater { l3keys2e } { 2014/05/05 } { } { \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } } -\RequirePackage { etoolbox } +\RequirePackage { ctexhook , ctexpatch } \RequirePackage { fix-cm , everysel } \tl_new:N \l__ctex_tmp_tl \int_new:N \l__ctex_tmp_int \dim_new:N \l__ctex_tmp_dim \box_new:N \l__ctex_tmp_box -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 - { - \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} } - } -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 - { - \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} - } -\cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 - { - \cs_if_exist_use:cT { g__ctex_at_end_ #1 _hook_tl } - { \cs_undefine:c { g__ctex_at_end_ #1 _hook_tl } } - } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } -\tl_put_left:Nn \@popfilename - { - \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } - } \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { \use:x @@ -111,90 +88,6 @@ { } } \cs_generate_variant:Nn \ctex_scheme_input:n { o } -\cs_new_protected:Npn \ctex_parse_name:NN #1#2 - { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } -\group_begin: -\char_set_lccode:nn { `\< } { `\{ } -\char_set_lccode:nn { `\/ } { `\\ } -\char_set_lccode:nn { `\A } { `\t } -\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N -\tex_lowercase:D - { - \group_end: - \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 - { - \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } - { - \group_begin: - \use:x - { - \group_end: - \__ctex_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } - \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } - } {#3} #1 - } - { #1#2 } - } - \cs_new_protected:Npn \__ctex_parse_name:nNNNnN #1#2#3#4#5#6 - { - \exp_args:Nc #6 - { - \str_case:nnTF {#1} - { - { \protect #3 } { } - { \x@protect #2 \protect #3 } { } - } - { - \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } - { - \exp_last_unbraced:Nf \__ctex_parse_name:w - \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop - } - { /#5 ~ } { #5 ~ } - } - { - \str_case:onTF { \__ctex_parse_name:w #1 AESAOPA ~ < \q_stop } - { - { /@protected@ #2 #4 } { } - { /@ #4 } { } - } - { /#5 } {#5} - } - } - } - \cs_new:Npn \__ctex_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } - } -\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } -\cs_new_protected_nopar:Npn \ctex_patch_cmd:NnnTF { \ctex_parse_name:NN \patchcmd } -\cs_new_protected_nopar:Npn \ctex_preto_cmd:NnTF { \ctex_parse_name:NN \pretocmd } -\cs_new_protected_nopar:Npn \ctex_appto_cmd:NnTF { \ctex_parse_name:NN \apptocmd } -\cs_new_protected:Npn \ctex_patch_cmd:Nnn - { - \group_begin: - \char_set_catcode_other:N \# - \__ctex_patch_cmd:Nnn - } -\cs_new_protected:Npn \__ctex_patch_cmd:Nnn #1#2#3 - { - \group_end: - \group_begin: - \ExplSyntaxOff - \ctex_patch_cmd:NnnTF #1 {#2} {#3} - { - \cs_gset_eq:NN \__ctex_tmp:w #1 - \group_end: - \cs_set_eq:NN #1 \__ctex_tmp:w - \cs_undefine:N \__ctex_tmp:w - } - { \group_end: \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \ctex_patch_failure:N #1 - { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } -\msg_new:nnn { ctex } { patch-failure } - { - Patching~command~`#1'~failed.\\ - ctex~may~not~work~as~expected. - } \cs_new_eq:NN \g__ctex_section_depth_flag \c_two \msg_new:nnnn { ctex } { package-too-old } { Support~package~`#1'~too~old. } @@ -217,7 +110,7 @@ \cs_new_eq:NN \ctex_if_pdfmode:TF \use_ii:nn } \cs_new_eq:NN \ctex_if_preamble:TF \use_i:nn -\AfterEndPreamble { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } +\ctex_after_end_preamble:n { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } \cs_new:Npn \ctex_set_default_ccwd:Nn #1#2 { \dim_compare:nNnTF @@ -303,8 +196,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options.~ } } , @@ -313,8 +206,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options. } } , @@ -446,7 +339,7 @@ \cs_if_exist:NF \hypersetup { \cs_new_eq:NN \hypersetup \ctex_hypersetup:n } } - \AtEndPreamble { \RequirePackage { hyperref } } + \ctex_at_end_preamble:n { \RequirePackage { hyperref } } } , } \tl_clear:N \l__ctex_tmp_tl @@ -658,6 +551,14 @@ \cs_new_eq:NN \chinese \zhnum \cs_new_eq:NN \Chinese \chinese \cs_new_eq:NN \CTEXcounter \use_none:n +\ctex_at_end_package:nn { enumitem } + { + \cs_if_free:NF \AddEnumerateCounter + { + \AddEnumerateCounter * { \zhnum } { \zhnum_int:n } { 1 } + \AddEnumerateCounter * { \chinese } { \zhnum_int:n } { 1 } + } + } \NewDocumentCommand \CTEXnumber { m m } { \protected@edef #1 { \zhnumber {#2} } } \NewDocumentCommand \CTEXdigits { m m } @@ -696,12 +597,14 @@ appendixname .tl_set:N = \appendixname , bibname .tl_set:N = \bibname } + +\seq_new:N \c__ctex_section_headings_seq +\seq_gset_from_clist:Nn \c__ctex_section_headings_seq + { section , subsection , subsubsection , paragraph , subparagraph } \seq_new:N \c__ctex_headings_seq -\seq_gset_from_clist:Nn \c__ctex_headings_seq - { - part , chapter , section , subsection , subsubsection , - paragraph , subparagraph - } +\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq +\seq_gput_left:Nn \c__ctex_headings_seq { chapter } +\seq_gput_left:Nn \c__ctex_headings_seq { part } \cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1 { \tl_new:c { CTEX@pre#1 } @@ -734,49 +637,53 @@ { \tl_put_right:Nx \l__ctex_tmp_tl { - #1 .meta:nn = { ctex / #1 } { ####1 } , - #1 / name .code:n = + #1 .meta:nn = { ctex / #1 } { ####1 } , + #1 / name .code:n = { \ctex_assign_heading_name:nn {#1} { ####1 } } , - #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , - #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , - #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , - #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , - #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , - #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , - #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , - #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , - #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , - #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , - #1 / format+ .code:n = + #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , + #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , + #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , + #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , + #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , + #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , + #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , + #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , + #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , + #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , + #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , + #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , + #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / format~+ .code:n = + #1 / format~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / nameformat+ .code:n = + #1 / nameformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / nameformat~+ .code:n = + #1 / nameformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / numberformat+ .code:n = + #1 / numberformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / numberformat~+ .code:n = + #1 / numberformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / aftername+ .code:n = + #1 / aftername+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / aftername~+ .code:n = + #1 / aftername~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / titleformat+ .code:n = + #1 / titleformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / titleformat~+ .code:n = + #1 / titleformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / aftertitle+ .code:n = + #1 / aftertitle+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / aftertitle~+ .code:n = + #1 / aftertitle~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / beforeskip .initial:n = \c_zero_skip , - #1 / afterskip .initial:n = \c_zero_skip , - #1 / indent .initial:n = \c_zero_dim , - #1 / beforeskip .value_required: , - #1 / afterskip .value_required: , - #1 / indent .value_required: , + #1 / numbering .initial:n = true , + #1 / beforeskip .initial:n = \c_zero_skip , + #1 / afterskip .initial:n = \c_zero_skip , + #1 / indent .initial:n = \c_zero_dim , + #1 / beforeskip .value_required: , + #1 / afterskip .value_required: , + #1 / indent .value_required: , } } \NewDocumentCommand \ctex_assign_heading_name:nn @@ -801,20 +708,42 @@ } \use:x { \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } } \tl_clear:N \l__ctex_tmp_tl -\def\@part[#1]#2{% +\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } +\ctex_at_end_package:nn { hyperref } + { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } +\renewcommand\part{% + \if@openright + \cleardoublepage + \else + \clearpage + \fi \thispagestyle{\CTEX@part@pagestyle}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi + \null\vskip \glueexpr \CTEX@part@beforeskip \relax + \secdef\@part\@spart} +\def\@part[#1]#2{% \ifnum \c@secnumdepth >-2\relax - \refstepcounter{part}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi \markboth{}{}% {\interlinepenalty \@M \normalfont \CTEX@part@format - \ifnum \c@secnumdepth >-2\relax + \ifnum \c@secnumdepth >-2\relax \ifodd \CTEX@part@numbering \CTEX@partname - \fi + \fi \fi \CTEX@part@titleformat{#2}% \CTEX@part@aftertitle}% \@endpart} @@ -824,13 +753,40 @@ \CTEX@part@titleformat{#1}% \CTEX@part@aftertitle}% \@endpart} +\def\@endpart{% + \vskip \glueexpr \CTEX@part@afterskip \relax + \newpage + \if@twoside + \if@openright + \null + \thispagestyle{empty}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi} +\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi + \thispagestyle{\CTEX@chapter@pagestyle}% + \global\@topnum\z@ + \ifodd \CTEX@chapter@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \secdef\@chapter\@schapter} \def\@chapter[#1]#2{% \ifnum \c@secnumdepth >\m@ne \if@mainmatter - \refstepcounter{chapter}% - \typeout{\CTEXthechapter}% - \addcontentsline{toc}{chapter} - {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \ifodd \CTEX@chapter@numbering + \refstepcounter{chapter}% + \typeout{\CTEXthechapter}% + \addcontentsline{toc}{chapter} + {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{chapter}{#1}% + \fi \else \addcontentsline{toc}{chapter}{#1}% \fi @@ -847,42 +803,49 @@ \@afterheading \fi} \def\@makechapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \ifnum \c@secnumdepth >\m@ne \if@mainmatter - \CTEX@chaptername + \ifodd \CTEX@chapter@numbering + \CTEX@chaptername + \fi \fi \fi \interlinepenalty\@M \CTEX@chapter@titleformat{#1}% \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} \def\@makeschapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \interlinepenalty\@M \CTEX@chapter@titleformat{#1} \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \CTEX@update@sectionformat@n{#1}% + \ifodd \CTEX@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace{\glueexpr #4\relax}% + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} \def\@seccntformat#1{% \@ifundefined{CTEX@#1name}% {\csname the#1\endcsname\quad}% @@ -891,14 +854,18 @@ \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \ifodd \csname CTEX@#1@numbering\endcsname + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \else + \CTEX@makeheadinganchor + \let\@svsec\@empty + \fi \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #6{% - \@hangfrom{\hskip #3\relax\@svsec}% + \@hangfrom{\hskip\glueexpr #3\relax\@svsec}% \interlinepenalty \@M \csname CTEX@#1@titleformat\endcsname{#8}% \csname CTEX@#1@aftertitle\endcsname}% @@ -906,51 +873,80 @@ \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}% \else \def\@svsechd{% - #6{\hskip #3\relax + #6{\hskip\glueexpr #3\relax \@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{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}}% \fi \@xsect{#5}} \def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #4{% - \@hangfrom{\hskip #1}% + \@hangfrom{\hskip\glueexpr #1\relax}% \interlinepenalty \@M \CTEX@titleformat@n{#5}% \CTEX@aftertitle}% \endgroup \else - \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% + \def\@svsechd{#4{\hskip\glueexpr #1\relax + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} -\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1 +\def\@xsect#1{% + \unless \ifodd \CTEX@runin + \par \nobreak + \vskip\glueexpr #1\relax + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \begingroup \@svsechd \endgroup + \unskip + \hskip\glueexpr #1\relax + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +\cs_new_protected_nopar: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 } + \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } + \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } } \cs_new_eq:NN \CTEX@titleformat@n \use:n \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: +\cs_new_eq:NN \CTEX@afterindent \c_true_bool +\cs_new_eq:NN \CTEX@runin \c_false_bool \int_zero:N \l__ctex_tmp_int -\clist_map_inline:nn - { section , subsection , subsubsection , paragraph , subparagraph } +\seq_map_inline:Nn \c__ctex_section_headings_seq { \int_incr:N \l__ctex_tmp_int \cs_gset_protected_nopar:cpx {#1} @@ -960,18 +956,17 @@ { \exp_not:c { CTEX@#1@indent } } { \exp_not:c { CTEX@#1@beforeskip } } { \exp_not:c { CTEX@#1@afterskip } } - { - \CTEX@set@titleformat@n {#1} - \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } - } + { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } } } \keys_define:nn { ctex } { - appendix .meta:nn = { ctex / appendix } {#1} , - appendix / name .code:n = + appendix .meta:nn = { ctex / appendix } {#1} , + appendix / name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } , - appendix / number .tl_set:N = \CTEX@appendixnumber + appendix / number .tl_set:N = \CTEX@appendix@number , + appendix / numbering .bool_set:N = \CTEX@appendix@numbering , + appendix / numbering .initial:n = true } \tl_new:N \CTEX@preappendix \tl_new:N \CTEX@postappendix @@ -980,8 +975,76 @@ { \CTEX@save@appendix \gdef \CTEX@prechapter { \CTEX@preappendix } - \gdef \CTEX@thechapter { \CTEX@appendixnumber } + \gdef \CTEX@thechapter { \CTEX@appendix@number } \gdef \CTEX@postchapter { \CTEX@postappendix } + \gdef \CTEX@chapter@numbering { \CTEX@appendix@numbering } + } +\cs_new_protected_nopar:Npn \ctex_titlesec_hook: + { + \@ifpackagewith { titlesec } { explicit } + { + \cs_set_eq:NN \__ctex_titlesec_format:Nn + \__ctex_titlesec_format_explicit:Nn + } + { } + \clist_map_inline:nn + { indentafter , noindentafter , indentfirst , nonindentfirst } + { + \@ifpackagewith { titlesec } { ##1 } + { + \clist_map_break:n + { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n } + } + { } + } + \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1 + { + \__ctex_titlesec_format:n {#1} + \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1} + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1 + { + \cs_if_free:cF { ttlf@#1 } + { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2 + { + \tl_set:Nx #1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \tl_tail:N #1 + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2 + { + \cs_set_nopar:Npx #1 ##1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \exp_args:No \tl_tail:n { #1 { } } + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } } +\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6 + { + \exp_not:n { {#1} {#2} {#3} {#4} } + { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } + } +\@ifpackageloaded { titlesec } + { } + { + \ctex_at_end_package:nn { titlesec } + { + \@ifpackagewith { titlesec } { loadonly } + { } + { \ctex_titlesec_hook: } + } } \cs_new_protected:Npn \CTEX@toc@width@n #1 { @@ -997,31 +1060,39 @@ \use:n { \group_end: - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } \@ifpackageloaded { tocloft } { } { \ctex_at_end_package:nn { tocloft } { - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } } } - \ExplSyntaxOn } \ctex_patch_cmd:Nnn \ps@headings - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesection.~\ } { \CTEXthesection \quad } + \ctex_patch_cmd:Nnn \ps@headings + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \@chapapp\ \thechapter.~\ } { \if@mainmatter \CTEXthechapter \quad \fi } + { \@chapapp\ \thechapter.~\ } + { \if@mainmatter \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesection.~\ } { \CTEXthesection \quad } + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { @@ -1153,7 +1224,7 @@ \fi: \fp_compare:nNnF { \l__ctex_line_spread_fp } ? { \c_zero_fp } { - \linespread { \fp_use:N \l__ctex_line_spread_fp } + \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp } \group_begin: \footnotesize \exp_args:NNNo \group_end: \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } } @@ -1170,26 +1241,6 @@ { You~can~load~the~package~`caption'~to~get~its~functionality. } } } -\group_begin: -\char_set_catcode_other:N \# -\use:n - { - \group_end: - \ExplSyntaxOff - \ctex_at_end_package:nn { breqn } - { - \ctex_patch_cmd:NnnTF \end { \csname end#1 \endcsname } - { - \csuse { @end@#1@hook } - \csname end#1 \endcsname - } { } - { - \ctex_preto_cmd:NnTF \end { \csuse { @end@#1@hook } } - { } { \ctex_patch_failure:N \end } - } - } - \ExplSyntaxOn - } \cs_new_protected_nopar:Npn \ctex_fontset_error:n #1 { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} } \msg_new:nnn { ctex } { fontset-unavailable } @@ -1263,12 +1314,14 @@ %% and the derived files ctex.pdf, %% ctex.ins, %% ctex.sty, -%% ctexcap.sty, %% ctexsize.sty, %% ctexheading.sty, %% ctexart.cls, %% ctexbook.cls, %% ctexrep.cls, +%% ctexcap.sty, +%% ctexhook.sty, +%% ctexpatch.sty, %% ctex-c5size.clo, %% ctex-cs4size.clo, %% ctex-article.def, diff --git a/Master/texmf-dist/tex/latex/ctex/ctexcap.sty b/Master/texmf-dist/tex/latex/ctex/ctexcap.sty index f899abbf14f..e537e094f39 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexcap.sty +++ b/Master/texmf-dist/tex/latex/ctex/ctexcap.sty @@ -28,66 +28,23 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese adapter in LaTeX (CTEX)} \ProvidesExplPackage{ctexcap} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} +\clist_new:N \l__ctex_ctexcap_options_clist +\clist_set:Nx \l__ctex_ctexcap_options_clist + { \exp_not:v { opt@ \@currname . \@currext } , heading } +\msg_new:nnn { ctexcap } { deprecated } + { + Package~`ctexcap'~is~deprecated.\\ + Please~use~package~`ctex'~with~option~`#1'~instead: \\\\ + \iow_indent:n { \token_to_str:N \usepackage [#1] \{ ctex \} } \\ + } +\msg_warning:nnx { ctexcap } { deprecated } + { \clist_use:Nn \l__ctex_ctexcap_options_clist { , ~ } } \PassOptionsToPackage { heading = true } { ctexcap } \RequirePackageWithOptions { ctex } %% -%% This package consists of the file ctex.dtx, -%% and the derived files ctex.pdf, -%% ctex.ins, -%% ctex.sty, -%% ctexcap.sty, -%% ctexsize.sty, -%% ctexheading.sty, -%% ctexart.cls, -%% ctexbook.cls, -%% ctexrep.cls, -%% ctex-c5size.clo, -%% ctex-cs4size.clo, -%% ctex-article.def, -%% ctex-book.def, -%% ctex-report.def, -%% ctex-scheme-plain.def, -%% ctex-scheme-plain-article.def, -%% ctex-scheme-plain-book.def, -%% ctex-scheme-plain-report.def, -%% ctex-scheme-chinese.def, -%% ctex-scheme-chinese-article.def, -%% ctex-scheme-chinese-book.def, -%% ctex-scheme-chinese-report.def, -%% ctex-name-gbk.cfg, -%% ctex-name-utf8.cfg, -%% ctex.cfg, -%% ctexopts.cfg, -%% ctex-engine-pdftex.def, -%% ctex-engine-xetex.def, -%% ctex-engine-luatex.def, -%% c19rm.fd, -%% c19sf.fd, -%% c19tt.fd, -%% c70rm.fd, -%% c70sf.fd, -%% c70tt.fd, -%% ctex-fontset-windows.def, -%% ctex-fontset-windowsnew.def, -%% ctex-fontset-windowsold.def, -%% ctex-fontset-adobe.def, -%% ctex-fontset-fandol.def, -%% ctex-fontset-mac.def, -%% ctex-fontset-founder.def, -%% ctex-fontset-ubuntu.def, -%% ctexspa.def, -%% ctexpunct.spa, -%% ctexmakespa.tex, -%% ctexspamacro.tex, -%% zhadobefonts.tex, -%% zhfandolfonts.tex, -%% zhfounderfonts.tex, -%% zhubuntufonts.tex, -%% zhwindowsfonts.tex, and -%% README. %% %% End of file `ctexcap.sty'. diff --git a/Master/texmf-dist/tex/latex/ctex/ctexheading.sty b/Master/texmf-dist/tex/latex/ctex/ctexheading.sty index efff90fbbdd..92d61d817d6 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexheading.sty +++ b/Master/texmf-dist/tex/latex/ctex/ctexheading.sty @@ -28,38 +28,15 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Heading style modification (CTEX)} \ProvidesExplPackage{ctexheading} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \RequirePackage { xparse , l3keys2e } -\RequirePackage { etoolbox } +\RequirePackage { ctexhook , ctexpatch } \tl_new:N \l__ctex_tmp_tl \int_new:N \l__ctex_tmp_int \box_new:N \l__ctex_tmp_box -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 - { - \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} } - } -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 - { - \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} - } -\cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 - { - \cs_if_exist_use:cT { g__ctex_at_end_ #1 _hook_tl } - { \cs_undefine:c { g__ctex_at_end_ #1 _hook_tl } } - } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } -\tl_put_left:Nn \@popfilename - { - \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } - } \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { \use:x @@ -92,90 +69,6 @@ { } } \cs_generate_variant:Nn \ctex_scheme_input:n { o } -\cs_new_protected:Npn \ctex_parse_name:NN #1#2 - { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } -\group_begin: -\char_set_lccode:nn { `\< } { `\{ } -\char_set_lccode:nn { `\/ } { `\\ } -\char_set_lccode:nn { `\A } { `\t } -\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N -\tex_lowercase:D - { - \group_end: - \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 - { - \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } - { - \group_begin: - \use:x - { - \group_end: - \__ctex_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } - \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } - } {#3} #1 - } - { #1#2 } - } - \cs_new_protected:Npn \__ctex_parse_name:nNNNnN #1#2#3#4#5#6 - { - \exp_args:Nc #6 - { - \str_case:nnTF {#1} - { - { \protect #3 } { } - { \x@protect #2 \protect #3 } { } - } - { - \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } - { - \exp_last_unbraced:Nf \__ctex_parse_name:w - \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop - } - { /#5 ~ } { #5 ~ } - } - { - \str_case:onTF { \__ctex_parse_name:w #1 AESAOPA ~ < \q_stop } - { - { /@protected@ #2 #4 } { } - { /@ #4 } { } - } - { /#5 } {#5} - } - } - } - \cs_new:Npn \__ctex_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } - } -\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } -\cs_new_protected_nopar:Npn \ctex_patch_cmd:NnnTF { \ctex_parse_name:NN \patchcmd } -\cs_new_protected_nopar:Npn \ctex_preto_cmd:NnTF { \ctex_parse_name:NN \pretocmd } -\cs_new_protected_nopar:Npn \ctex_appto_cmd:NnTF { \ctex_parse_name:NN \apptocmd } -\cs_new_protected:Npn \ctex_patch_cmd:Nnn - { - \group_begin: - \char_set_catcode_other:N \# - \__ctex_patch_cmd:Nnn - } -\cs_new_protected:Npn \__ctex_patch_cmd:Nnn #1#2#3 - { - \group_end: - \group_begin: - \ExplSyntaxOff - \ctex_patch_cmd:NnnTF #1 {#2} {#3} - { - \cs_gset_eq:NN \__ctex_tmp:w #1 - \group_end: - \cs_set_eq:NN #1 \__ctex_tmp:w - \cs_undefine:N \__ctex_tmp:w - } - { \group_end: \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \ctex_patch_failure:N #1 - { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } -\msg_new:nnn { ctex } { patch-failure } - { - Patching~command~`#1'~failed.\\ - ctex~may~not~work~as~expected. - } \cs_new_eq:NN \g__ctex_section_depth_flag \c_two \keys_define:nn { ctex / option } { @@ -224,12 +117,14 @@ %% and the derived files ctex.pdf, %% ctex.ins, %% ctex.sty, -%% ctexcap.sty, %% ctexsize.sty, %% ctexheading.sty, %% ctexart.cls, %% ctexbook.cls, %% ctexrep.cls, +%% ctexcap.sty, +%% ctexhook.sty, +%% ctexpatch.sty, %% ctex-c5size.clo, %% ctex-cs4size.clo, %% ctex-article.def, diff --git a/Master/texmf-dist/tex/latex/ctex/ctexhook.sty b/Master/texmf-dist/tex/latex/ctex/ctexhook.sty new file mode 100644 index 00000000000..f492b7444dd --- /dev/null +++ b/Master/texmf-dist/tex/latex/ctex/ctexhook.sty @@ -0,0 +1,76 @@ +%% +%% This is file `ctexhook.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% ctex.dtx (with options: `ctexhook') +%% +%% Copyright (C) 2003--2015 +%% 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'. +%% +%% The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang. +%% +%% ------------------------------------------------------------------------------ +%% +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ + {Document and package hooks (CTEX)} +\ProvidesExplPackage{ctexhook} + {\ExplFileDate}{2.2}{\ExplFileDescription} +\cs_new_protected:Npn \ctex_at_end_preamble:n #1 + { \tl_gput_right:Nn \g__ctex_end_preamble_hook_tl {#1} } +\cs_new_protected:Npn \ctex_after_end_preamble:n #1 + { \tl_gput_right:Nn \g__ctex_after_end_preamble_hook_tl {#1} } +\cs_new_protected_nopar:Npn \CTEX@document@left@hook + { \group_end: \g__ctex_end_preamble_hook_tl \group_begin: } +\cs_new_protected_nopar:Npn \CTEX@document@right@hook + { \scan_stop: \g__ctex_after_end_preamble_hook_tl \tex_ignorespaces:D } +\cs_set_nopar:Npx \document + { + \CTEX@document@left@hook + \exp_not:o { \document } + \CTEX@document@right@hook + } +\tl_new:N \g__ctex_end_preamble_hook_tl +\tl_new:N \g__ctex_after_end_preamble_hook_tl +\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 + { + \@ifpackageloaded {#1} + {#2} + { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} } + } +\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 + { + \tl_if_exist:NF #1 { \tl_new:N #1 } + \tl_gput_right:Nn #1 {#2} + } +\cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } +\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 + { + \cs_if_exist_use:cT { g__ctex_at_end_ #1 _hook_tl } + { \cs_undefine:c { g__ctex_at_end_ #1 _hook_tl } } + } +\cs_generate_variant:Nn \ctex_package_end_hook:n { o } +\tl_put_left:Nn \@popfilename + { + \cs_if_eq:NNT \@currext \@pkgextension + { \ctex_package_end_hook:o { \@currname } } + } +%% +%% +%% End of file `ctexhook.sty'. diff --git a/Master/texmf-dist/tex/latex/ctex/ctexpatch.sty b/Master/texmf-dist/tex/latex/ctex/ctexpatch.sty new file mode 100644 index 00000000000..c0e571bfd26 --- /dev/null +++ b/Master/texmf-dist/tex/latex/ctex/ctexpatch.sty @@ -0,0 +1,252 @@ +%% +%% This is file `ctexpatch.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% ctex.dtx (with options: `ctexpatch') +%% +%% Copyright (C) 2003--2015 +%% 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'. +%% +%% The Current Maintainers of this work are Leo Liu, Qing Lee and Liam Huang. +%% +%% ------------------------------------------------------------------------------ +%% +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ + {Patching commands (CTEX)} +\ProvidesExplPackage{ctexpatch} + {\ExplFileDate}{2.2}{\ExplFileDescription} +\cs_new_protected:Npn \ctex_patch_cmd_once:NnnnTF #1#2 + { + \ctex_patch_boot:NNnnTF \__ctex_patch_cmd:Nnnnnw #1 + { once } {#2} { \use_i:nn } { \use_ii:nn } + } +\cs_new_protected:Npn \ctex_patch_cmd_all:NnnnTF #1#2 + { + \ctex_patch_boot:NNnnTF \__ctex_patch_cmd:Nnnnnw #1 + { all } {#2} { \use_i:nn } { \use_ii:nn } + } +\cs_new_protected:Npn \ctex_patch_cmd:Nnn #1 + { + \ctex_patch_boot:NNnnTF \__ctex_patch_cmd:Nnnnnw #1 + { once } + { + \ExplSyntaxOff + \char_set_catcode_letter:n { 64 } + } + { } + { \ctex_patch_failure:N #1 } + } +\cs_new_protected:Npn \ctex_patch_failure:N #1 + { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } +\msg_new:nnn { ctex } { patch-failure } + { Oops!~Command~`#1'~is~NOT~patchable.\\ } +\cs_new_protected:Npn \ctex_preto_cmd:NnnTF #1#2 + { + \ctex_patch_boot:NNnnTF \__ctex_hookto_cmd:Nnnnw #1 + { left } {#2} { \use_i:nn } { \use_ii:nn } + } +\cs_new_protected:Npn \ctex_appto_cmd:NnnTF #1#2 + { + \ctex_patch_boot:NNnnTF \__ctex_hookto_cmd:Nnnnw #1 + { right } {#2} { \use_i:nn } { \use_ii:nn } + } +\cs_new_protected:Npn \ctex_patch_boot:NNnnTF #1#2#3#4#5#6 + { + \tl_set:Nn \__ctex_patch_true:w {#5} + \tl_set:Nn \__ctex_patch_false:w {#6} + \group_begin: + \char_set_catcode_other:n { 35 } + \ctex_parse_name:NN #1 #2 {#3} {#4} + } +\tl_new:N \__ctex_patch_true:w +\tl_new:N \__ctex_patch_false:w +\cs_new_protected:Npn \ctex_parse_name:NN #1#2 + { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } +\group_begin: +\char_set_lccode:nn { `\< } { `\{ } +\char_set_lccode:nn { `\/ } { `\\ } +\char_set_lccode:nn { `\A } { `\t } +\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N +\tex_lowercase:D + { + \group_end: + \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 + { + \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } + { + \group_begin: + \use:x + { + \group_end: + \__ctex_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } + \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } + } {#3} #1 + } + { #1#2 } + } + \cs_new_protected:Npn \__ctex_parse_name:nNNNnN #1#2#3#4#5#6 + { + \exp_args:Nc #6 + { + \str_case:nnTF {#1} + { + { \protect #3 } { } + { \x@protect #2 \protect #3 } { } + } + { + \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } + { + \exp_last_unbraced:Nf \__ctex_parse_name:w + \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop + } + { /#5 ~ } { #5 ~ } + } + { + \str_case:onTF { \__ctex_parse_name:w #1 AESAOPA ~ < \q_stop } + { + { /@protected@ #2 #4 } { } + { /@ #4 } { } + } + { /#5 } {#5} + } + } + } + \cs_new:Npn \__ctex_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } + } +\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } +\tl_new:N \l__ctex_prefix_tl +\tl_new:N \l__ctex_parameter_tl +\tl_new:N \l__ctex_replacement_tl +\group_begin: + \char_set_lccode:nn { `\; } { `\: } + \tl_map_function:nN { \M \A \C \R \O \; } \char_set_catcode_other:N +\tex_lowercase:D + { + \group_end: + \cs_new_protected:Npn \ctex_get_macro_meaning:NTF #1 + { + \exp_after:wN \__ctex_get_macro_meaning:w + \token_to_meaning:N #1 \q_stop MACRO ; -> \q_no_value \q_stop + } + \cs_new_protected:Npn \__ctex_get_macro_meaning:w #1 MACRO ; #2 -> #3 \q_stop + { + \tl_set:Nn \l__ctex_replacement_tl {#3} + \quark_if_no_value:NTF \l__ctex_replacement_tl + { \use_ii:nn } + { + \tl_set:Nn \l__ctex_prefix_tl {#1} + \tl_set:Nn \l__ctex_parameter_tl {#2} + \use_i_delimit_by_q_stop:nw { \use_i:nn } + } + } + } +\cs_new_protected:Npn \ctex_if_rescanable:NnTF #1#2#3#4 + { + \ctex_get_macro_meaning:NTF #1 + { + \__ctex_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#2} + \cs_if_eq:NNTF #1 \CTEXPATCHRESCANCMD {#3} {#4} + } + {#4} + } +\cs_new_eq:NN \CTEXPATCHRESCANCMD \prg_do_nothing: +\cs_new_protected:Npn \__ctex_patch_rebuild:Nn #1#2 + { + \tl_if_empty:nTF {#2} + { \tl_rescan:nx {#2} } + { + \tl_rescan:nx + { + #2 \scan_stop: + \int_set_eq:NN \tex_endlinechar:D \c_minus_one + \int_set_eq:NN \tex_newlinechar:D \c_minus_one + } + } + { + \l__ctex_prefix_tl \exp_not:N \def \exp_not:N #1 \l__ctex_parameter_tl + { \l__ctex_replacement_tl } + } + } +\cs_generate_variant:Nn \tl_rescan:nn { nx } +\cs_new_protected:Npn \__ctex_patch_cmd:Nnnnnw #1#2#3#4#5 + { + \group_end: + \ctex_if_rescanable:NnTF #1 {#3} + { + \use:x + { + \__ctex_patch_replace:nnnTF {#2} + { \tl_to_str:n {#4} } + { \tl_to_str:n {#5} } + } + { + \__ctex_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3} + \cs_set_eq:NN #1 \CTEXPATCHRESCANCMD + \__ctex_patch_true:w + } + { \__ctex_patch_false:w } + } + { \__ctex_patch_false:w } + } +\cs_new_protected:Npn \__ctex_patch_replace:nnnTF #1#2#3#4 + { + \tl_if_in:NnTF \l__ctex_replacement_tl {#2} + { \use:c { tl_replace_ #1 :Nnn } \l__ctex_replacement_tl {#2} {#3} #4 } + } +\cs_new_protected:Npn \__ctex_hookto_cmd:Nnnnw #1#2#3#4 + { + \group_end: + \ctex_get_macro_meaning:NTF #1 + { + \tl_if_empty:NTF \l__ctex_parameter_tl + { \__ctex_hookto_cmd_parameterless:Nnnw #1 {#2} {#4} } + { \__ctex_hookto_cmd_parameter:Nnnnw #1 {#2} {#3} {#4} } + } + { \__ctex_patch_false:w } + } +\cs_new_protected:Npn \__ctex_hookto_cmd_parameterless:Nnnw #1#2#3 + { + \tl_if_empty:NF \l__ctex_prefix_tl + { \tl_rescan:nx { } { \l__ctex_prefix_tl } } + \edef #1 + { + \use:c { __ctex_ #2 _hook_aux:nn } + { \exp_not:o {#1} } + { \exp_not:n {#3} } + } + \__ctex_patch_true:w + } +\cs_new:Npn \__ctex_left_hook_aux:nn #1#2 { #2#1 } +\cs_new_eq:NN \__ctex_right_hook_aux:nn \use:nn +\cs_new_protected:Npn \__ctex_hookto_cmd_parameter:Nnnnw #1#2#3#4 + { + \__ctex_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3} + \cs_if_eq:NNTF #1 \CTEXPATCHRESCANCMD + { + \use:c { tl_put_ #2 :Nx } \l__ctex_replacement_tl { \tl_to_str:n {#4} } + \__ctex_patch_rebuild:Nn \CTEXPATCHRESCANCMD {#3} + \cs_set_eq:NN #1 \CTEXPATCHRESCANCMD + \__ctex_patch_true:w + } + { \__ctex_patch_false:w } + } +%% +%% +%% End of file `ctexpatch.sty'. diff --git a/Master/texmf-dist/tex/latex/ctex/ctexrep.cls b/Master/texmf-dist/tex/latex/ctex/ctexrep.cls index 0f7dfdeff5a..c9f8798891e 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexrep.cls +++ b/Master/texmf-dist/tex/latex/ctex/ctexrep.cls @@ -28,10 +28,10 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese adapter for class report (CTEX)} \ProvidesExplClass{ctexrep} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \tl_const:Nx \c__ctex_version_tl { \cs_if_exist_use:cF { ver@ \@currname . \@currext } { 9999/99/99 } } \cs_new_eq:cN { ver@ctex. \@pkgextension } \c__ctex_version_tl @@ -50,35 +50,12 @@ { \msg_error:nnn { ctex } { l3-too-old } { expl3 } } \@ifpackagelater { l3keys2e } { 2014/05/05 } { } { \msg_error:nnn { ctex } { l3-too-old } { l3keys2e } } -\RequirePackage { etoolbox } +\RequirePackage { ctexhook , ctexpatch } \RequirePackage { fix-cm , everysel } \tl_new:N \l__ctex_tmp_tl \int_new:N \l__ctex_tmp_int \dim_new:N \l__ctex_tmp_dim \box_new:N \l__ctex_tmp_box -\cs_new_protected:Npn \ctex_at_end_package:nn #1#2 - { - \@ifpackageloaded {#1} - {#2} - { \ctex_gadd_hook:cn { g__ctex_at_end_ #1 _hook_tl } {#2} } - } -\cs_new_protected:Npn \ctex_gadd_hook:Nn #1#2 - { - \tl_if_exist:NF #1 { \tl_new:N #1 } - \tl_gput_right:Nn #1 {#2} - } -\cs_generate_variant:Nn \ctex_gadd_hook:Nn { c } -\cs_new_protected_nopar:Npn \ctex_package_end_hook:n #1 - { - \cs_if_exist_use:cT { g__ctex_at_end_ #1 _hook_tl } - { \cs_undefine:c { g__ctex_at_end_ #1 _hook_tl } } - } -\cs_generate_variant:Nn \ctex_package_end_hook:n { o } -\tl_put_left:Nn \@popfilename - { - \cs_if_eq:NNT \@currext \@pkgextension - { \ctex_package_end_hook:o { \@currname } } - } \cs_new_protected:Npn \ctex_file_wrapper:nnn #1#2#3 { \use:x @@ -111,90 +88,6 @@ { } } \cs_generate_variant:Nn \ctex_scheme_input:n { o } -\cs_new_protected:Npn \ctex_parse_name:NN #1#2 - { \ctex_parse_name:NNx #1#2 { \cs_to_str:N #2 } } -\group_begin: -\char_set_lccode:nn { `\< } { `\{ } -\char_set_lccode:nn { `\/ } { `\\ } -\char_set_lccode:nn { `\A } { `\t } -\tl_map_function:nN { \A \E \S \O \P } \char_set_catcode_other:N -\tex_lowercase:D - { - \group_end: - \cs_new_protected:Npn \ctex_parse_name:NNn #1#2#3 - { - \bool_if:nTF { \cs_if_exist_p:c { #3 ~ } || \cs_if_exist_p:c { /#3 } } - { - \group_begin: - \use:x - { - \group_end: - \__ctex_parse_name:nNNNnN { \token_get_replacement_spec:N #2 } - \exp_not:N #2 \exp_not:c { #3 ~ } \exp_not:c { /#3 } - } {#3} #1 - } - { #1#2 } - } - \cs_new_protected:Npn \__ctex_parse_name:nNNNnN #1#2#3#4#5#6 - { - \exp_args:Nc #6 - { - \str_case:nnTF {#1} - { - { \protect #3 } { } - { \x@protect #2 \protect #3 } { } - } - { - \str_if_eq_x:nnTF { \exp_not:n { /@protected@ #3 /#3 } } - { - \exp_last_unbraced:Nf \__ctex_parse_name:w - \token_get_replacement_spec:N #3 AESAOPA ~ < \q_stop - } - { /#5 ~ } { #5 ~ } - } - { - \str_case:onTF { \__ctex_parse_name:w #1 AESAOPA ~ < \q_stop } - { - { /@protected@ #2 #4 } { } - { /@ #4 } { } - } - { /#5 } {#5} - } - } - } - \cs_new:Npn \__ctex_parse_name:w #1 AESAOPA ~ #2 < #3 \q_stop { #1#2 } - } -\cs_generate_variant:Nn \ctex_parse_name:NNn { NNx } -\cs_new_protected_nopar:Npn \ctex_patch_cmd:NnnTF { \ctex_parse_name:NN \patchcmd } -\cs_new_protected_nopar:Npn \ctex_preto_cmd:NnTF { \ctex_parse_name:NN \pretocmd } -\cs_new_protected_nopar:Npn \ctex_appto_cmd:NnTF { \ctex_parse_name:NN \apptocmd } -\cs_new_protected:Npn \ctex_patch_cmd:Nnn - { - \group_begin: - \char_set_catcode_other:N \# - \__ctex_patch_cmd:Nnn - } -\cs_new_protected:Npn \__ctex_patch_cmd:Nnn #1#2#3 - { - \group_end: - \group_begin: - \ExplSyntaxOff - \ctex_patch_cmd:NnnTF #1 {#2} {#3} - { - \cs_gset_eq:NN \__ctex_tmp:w #1 - \group_end: - \cs_set_eq:NN #1 \__ctex_tmp:w - \cs_undefine:N \__ctex_tmp:w - } - { \group_end: \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \ctex_patch_failure:N #1 - { \msg_warning:nnx { ctex } { patch-failure } { \token_to_str:N #1 } } -\msg_new:nnn { ctex } { patch-failure } - { - Patching~command~`#1'~failed.\\ - ctex~may~not~work~as~expected. - } \cs_new_eq:NN \g__ctex_section_depth_flag \c_two \msg_new:nnnn { ctex } { package-too-old } { Support~package~`#1'~too~old. } @@ -217,7 +110,7 @@ \cs_new_eq:NN \ctex_if_pdfmode:TF \use_ii:nn } \cs_new_eq:NN \ctex_if_preamble:TF \use_i:nn -\AfterEndPreamble { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } +\ctex_after_end_preamble:n { \cs_set_eq:NN \ctex_if_preamble:TF \use_ii:nn } \cs_new:Npn \ctex_set_default_ccwd:Nn #1#2 { \dim_compare:nNnTF @@ -303,8 +196,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options.~ } } , @@ -313,8 +206,8 @@ { \msg_warning:nnn { ctex } { deprecated-option } { - The~ functionality~ has~ been~ removed.~ - It's~ better~ to~ set~ the~ heading~ styles~ via~ beforeskip~ + The~ functionality~ has~ been~ removed.\\ + It's~ better~ to~ set~ the~ heading~ styles~ via~ `afterindent'~ options. } } , @@ -446,7 +339,7 @@ \cs_if_exist:NF \hypersetup { \cs_new_eq:NN \hypersetup \ctex_hypersetup:n } } - \AtEndPreamble { \RequirePackage { hyperref } } + \ctex_at_end_preamble:n { \RequirePackage { hyperref } } } , } \tl_clear:N \l__ctex_tmp_tl @@ -658,6 +551,14 @@ \cs_new_eq:NN \chinese \zhnum \cs_new_eq:NN \Chinese \chinese \cs_new_eq:NN \CTEXcounter \use_none:n +\ctex_at_end_package:nn { enumitem } + { + \cs_if_free:NF \AddEnumerateCounter + { + \AddEnumerateCounter * { \zhnum } { \zhnum_int:n } { 1 } + \AddEnumerateCounter * { \chinese } { \zhnum_int:n } { 1 } + } + } \NewDocumentCommand \CTEXnumber { m m } { \protected@edef #1 { \zhnumber {#2} } } \NewDocumentCommand \CTEXdigits { m m } @@ -696,12 +597,14 @@ appendixname .tl_set:N = \appendixname , bibname .tl_set:N = \bibname } + +\seq_new:N \c__ctex_section_headings_seq +\seq_gset_from_clist:Nn \c__ctex_section_headings_seq + { section , subsection , subsubsection , paragraph , subparagraph } \seq_new:N \c__ctex_headings_seq -\seq_gset_from_clist:Nn \c__ctex_headings_seq - { - part , chapter , section , subsection , subsubsection , - paragraph , subparagraph - } +\seq_gset_eq:NN \c__ctex_headings_seq \c__ctex_section_headings_seq +\seq_gput_left:Nn \c__ctex_headings_seq { chapter } +\seq_gput_left:Nn \c__ctex_headings_seq { part } \cs_new_protected_nopar:Npn \__ctex_initial_heading:n #1 { \tl_new:c { CTEX@pre#1 } @@ -734,49 +637,53 @@ { \tl_put_right:Nx \l__ctex_tmp_tl { - #1 .meta:nn = { ctex / #1 } { ####1 } , - #1 / name .code:n = + #1 .meta:nn = { ctex / #1 } { ####1 } , + #1 / name .code:n = { \ctex_assign_heading_name:nn {#1} { ####1 } } , - #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , - #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , - #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , - #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , - #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , - #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , - #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , - #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , - #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , - #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , - #1 / format+ .code:n = + #1 / number .tl_set:N = \exp_not:c { CTEX@the#1 } , + #1 / format .tl_set:N = \exp_not:c { CTEX@#1@format } , + #1 / nameformat .tl_set:N = \exp_not:c { CTEX@#1@nameformat } , + #1 / numberformat .tl_set:N = \exp_not:c { CTEX@#1@numberformat } , + #1 / aftername .tl_set:N = \exp_not:c { CTEX@#1@aftername } , + #1 / titleformat .tl_set:N = \exp_not:c { CTEX@#1@titleformat } , + #1 / aftertitle .tl_set:N = \exp_not:c { CTEX@#1@aftertitle } , + #1 / beforeskip .tl_set:N = \exp_not:c { CTEX@#1@beforeskip } , + #1 / afterskip .tl_set:N = \exp_not:c { CTEX@#1@afterskip} , + #1 / indent .tl_set:N = \exp_not:c { CTEX@#1@indent } , + #1 / numbering .bool_set:N = \exp_not:c { CTEX@#1@numbering } , + #1 / afterindent .bool_set:N = \exp_not:c { CTEX@#1@afterindent } , + #1 / runin .bool_set:N = \exp_not:c { CTEX@#1@runin } , + #1 / format+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / format~+ .code:n = + #1 / format~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@format } { ####1 } } , - #1 / nameformat+ .code:n = + #1 / nameformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / nameformat~+ .code:n = + #1 / nameformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@nameformat } { ####1 } } , - #1 / numberformat+ .code:n = + #1 / numberformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / numberformat~+ .code:n = + #1 / numberformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@numberformat } { ####1 } } , - #1 / aftername+ .code:n = + #1 / aftername+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / aftername~+ .code:n = + #1 / aftername~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftername } { ####1 } } , - #1 / titleformat+ .code:n = + #1 / titleformat+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / titleformat~+ .code:n = + #1 / titleformat~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@titleformat } { ####1 } } , - #1 / aftertitle+ .code:n = + #1 / aftertitle+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / aftertitle~+ .code:n = + #1 / aftertitle~+ .code:n = { \tl_put_right:Nn \exp_not:c { CTEX@#1@aftertitle } { ####1 } } , - #1 / beforeskip .initial:n = \c_zero_skip , - #1 / afterskip .initial:n = \c_zero_skip , - #1 / indent .initial:n = \c_zero_dim , - #1 / beforeskip .value_required: , - #1 / afterskip .value_required: , - #1 / indent .value_required: , + #1 / numbering .initial:n = true , + #1 / beforeskip .initial:n = \c_zero_skip , + #1 / afterskip .initial:n = \c_zero_skip , + #1 / indent .initial:n = \c_zero_dim , + #1 / beforeskip .value_required: , + #1 / afterskip .value_required: , + #1 / indent .value_required: , } } \NewDocumentCommand \ctex_assign_heading_name:nn @@ -801,20 +708,42 @@ } \use:x { \keys_define:nn { ctex } { \exp_not:o { \l__ctex_tmp_tl } } } \tl_clear:N \l__ctex_tmp_tl -\def\@part[#1]#2{% +\cs_new_protected_nopar:Npn \CTEX@makeheadinganchor { } +\ctex_at_end_package:nn { hyperref } + { \cs_gset_protected_nopar:Npn \CTEX@makeheadinganchor { \phantomsection } } +\renewcommand\part{% + \if@openright + \cleardoublepage + \else + \clearpage + \fi \thispagestyle{\CTEX@part@pagestyle}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi + \null\vskip \glueexpr \CTEX@part@beforeskip \relax + \secdef\@part\@spart} +\def\@part[#1]#2{% \ifnum \c@secnumdepth >-2\relax - \refstepcounter{part}% - \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \ifodd \CTEX@part@numbering + \refstepcounter{part}% + \addcontentsline{toc}{part}{\CTEXthepart\hspace{1em}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{part}{#1}% + \fi \else \addcontentsline{toc}{part}{#1}% \fi \markboth{}{}% {\interlinepenalty \@M \normalfont \CTEX@part@format - \ifnum \c@secnumdepth >-2\relax + \ifnum \c@secnumdepth >-2\relax \ifodd \CTEX@part@numbering \CTEX@partname - \fi + \fi \fi \CTEX@part@titleformat{#2}% \CTEX@part@aftertitle}% \@endpart} @@ -824,12 +753,39 @@ \CTEX@part@titleformat{#1}% \CTEX@part@aftertitle}% \@endpart} +\def\@endpart{% + \vskip \glueexpr \CTEX@part@afterskip \relax + \newpage + \if@twoside + \if@openright + \null + \thispagestyle{empty}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi} +\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi + \thispagestyle{\CTEX@chapter@pagestyle}% + \global\@topnum\z@ + \ifodd \CTEX@chapter@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \secdef\@chapter\@schapter} \def\@chapter[#1]#2{% \ifnum \c@secnumdepth >\m@ne - \refstepcounter{chapter}% - \typeout{\CTEXthechapter}% - \addcontentsline{toc}{chapter} - {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \ifodd \CTEX@chapter@numbering + \refstepcounter{chapter}% + \typeout{\CTEXthechapter}% + \addcontentsline{toc}{chapter} + {\protect\numberline{\CTEXthechapter\hspace{0.3em}}#1}% + \else + \CTEX@makeheadinganchor + \addcontentsline{toc}{chapter}{#1}% + \fi \else \addcontentsline{toc}{chapter}{#1}% \fi @@ -843,40 +799,47 @@ \@afterheading \fi} \def\@makechapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \ifnum \c@secnumdepth >\m@ne - \CTEX@chaptername + \ifodd \CTEX@chapter@numbering + \CTEX@chaptername + \fi \fi \interlinepenalty\@M \CTEX@chapter@titleformat{#1}% \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} \def\@makeschapterhead#1{% - \thispagestyle{\CTEX@chapter@pagestyle}% - \@tempskipa \CTEX@chapter@beforeskip \relax - \ifdim \@tempskipa <\z@ - \@tempskipa -\@tempskipa \@afterindentfalse - \else - \@afterindenttrue - \fi - \vspace*{\@tempskipa}% - {\normalfont \parindent \CTEX@chapter@indent \CTEX@chapter@format + \vspace*{\glueexpr\CTEX@chapter@beforeskip\relax}% + {\normalfont \parindent \dimexpr \CTEX@chapter@indent \relax + \CTEX@chapter@format \interlinepenalty\@M \CTEX@chapter@titleformat{#1} \CTEX@chapter@aftertitle \nobreak - \vskip \CTEX@chapter@afterskip + \vskip \glueexpr \CTEX@chapter@afterskip \relax }} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \CTEX@update@sectionformat@n{#1}% + \ifodd \CTEX@afterindent + \@afterindenttrue + \else + \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty\addvspace{\glueexpr #4\relax}% + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} \def\@seccntformat#1{% \@ifundefined{CTEX@#1name}% {\csname the#1\endcsname\quad}% @@ -885,14 +848,18 @@ \ifnum #2>\c@secnumdepth \let\@svsec\@empty \else - \refstepcounter{#1}% - \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \ifodd \csname CTEX@#1@numbering\endcsname + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \else + \CTEX@makeheadinganchor + \let\@svsec\@empty + \fi \fi - \@tempskipa #5\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #6{% - \@hangfrom{\hskip #3\relax\@svsec}% + \@hangfrom{\hskip\glueexpr #3\relax\@svsec}% \interlinepenalty \@M \csname CTEX@#1@titleformat\endcsname{#8}% \csname CTEX@#1@aftertitle\endcsname}% @@ -900,51 +867,80 @@ \csname #1mark\endcsname{#7}% \addcontentsline{toc}{#1}{% \ifnum #2>\c@secnumdepth \else - \protect\numberline{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}% \else \def\@svsechd{% - #6{\hskip #3\relax + #6{\hskip\glueexpr #3\relax \@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{\@ifundefined{CTEXthe#1}% + \ifodd \csname CTEX@#1@numbering\endcsname + \protect\numberline{\@ifundefined{CTEXthe#1}% {\csname the#1\endcsname}% {\csname CTEXthe#1\endcsname}}% + \fi \fi #7}}% \fi \@xsect{#5}} \def\@ssect#1#2#3#4#5{% - \@tempskipa #3\relax - \ifdim \@tempskipa>\z@ + \unless \ifodd \CTEX@runin \begingroup #4{% - \@hangfrom{\hskip #1}% + \@hangfrom{\hskip\glueexpr #1\relax}% \interlinepenalty \@M \CTEX@titleformat@n{#5}% \CTEX@aftertitle}% \endgroup \else - \def\@svsechd{#4{\hskip #1\relax \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% + \def\@svsechd{#4{\hskip\glueexpr #1\relax + \CTEX@titleformat@n{#5}\CTEX@aftertitle}}% \fi \@xsect{#3}} -\cs_new_protected_nopar:Npn \CTEX@set@titleformat@n #1 +\def\@xsect#1{% + \unless \ifodd \CTEX@runin + \par \nobreak + \vskip\glueexpr #1\relax + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \begingroup \@svsechd \endgroup + \unskip + \hskip\glueexpr #1\relax + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +\cs_new_protected_nopar: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 } + \cs_set_eq:Nc \CTEX@afterindent { CTEX@#1@afterindent } + \cs_set_eq:Nc \CTEX@runin { CTEX@#1@runin } } \cs_new_eq:NN \CTEX@titleformat@n \use:n \cs_new_eq:NN \CTEX@aftertitle \prg_do_nothing: +\cs_new_eq:NN \CTEX@afterindent \c_true_bool +\cs_new_eq:NN \CTEX@runin \c_false_bool \int_zero:N \l__ctex_tmp_int -\clist_map_inline:nn - { section , subsection , subsubsection , paragraph , subparagraph } +\seq_map_inline:Nn \c__ctex_section_headings_seq { \int_incr:N \l__ctex_tmp_int \cs_gset_protected_nopar:cpx {#1} @@ -954,18 +950,17 @@ { \exp_not:c { CTEX@#1@indent } } { \exp_not:c { CTEX@#1@beforeskip } } { \exp_not:c { CTEX@#1@afterskip } } - { - \CTEX@set@titleformat@n {#1} - \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } - } + { \exp_not:N \normalfont \exp_not:c { CTEX@#1@format } } } } \keys_define:nn { ctex } { - appendix .meta:nn = { ctex / appendix } {#1} , - appendix / name .code:n = + appendix .meta:nn = { ctex / appendix } {#1} , + appendix / name .code:n = { \ctex_assign_heading_name:nn { appendix } {#1} } , - appendix / number .tl_set:N = \CTEX@appendixnumber + appendix / number .tl_set:N = \CTEX@appendix@number , + appendix / numbering .bool_set:N = \CTEX@appendix@numbering , + appendix / numbering .initial:n = true } \tl_new:N \CTEX@preappendix \tl_new:N \CTEX@postappendix @@ -974,8 +969,76 @@ { \CTEX@save@appendix \gdef \CTEX@prechapter { \CTEX@preappendix } - \gdef \CTEX@thechapter { \CTEX@appendixnumber } + \gdef \CTEX@thechapter { \CTEX@appendix@number } \gdef \CTEX@postchapter { \CTEX@postappendix } + \gdef \CTEX@chapter@numbering { \CTEX@appendix@numbering } + } +\cs_new_protected_nopar:Npn \ctex_titlesec_hook: + { + \@ifpackagewith { titlesec } { explicit } + { + \cs_set_eq:NN \__ctex_titlesec_format:Nn + \__ctex_titlesec_format_explicit:Nn + } + { } + \clist_map_inline:nn + { indentafter , noindentafter , indentfirst , nonindentfirst } + { + \@ifpackagewith { titlesec } { ##1 } + { + \clist_map_break:n + { \cs_set_eq:NN \__ctex_titlesec_hook:n \__ctex_titlesec_format:n } + } + { } + } + \seq_map_function:NN \c__ctex_section_headings_seq \__ctex_titlesec_hook:n + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_hook:n #1 + { + \__ctex_titlesec_format:n {#1} + \exp_args:Nc \__ctex_titlesec_spacing:Nn { ttls@#1 } {#1} + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:n #1 + { + \cs_if_free:cF { ttlf@#1 } + { \exp_args:Nc \__ctex_titlesec_format:Nn { ttlf@#1 } {#1} } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format:Nn #1#2 + { + \tl_set:Nx #1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \tl_tail:N #1 + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_format_explicit:Nn #1#2 + { + \cs_set_nopar:Npx #1 ##1 + { + \bool_if:cTF { CTEX@#2@runin } + { \exp_not:N \ttlh@runin } + { \exp_not:N \ttlh@hang } + \exp_args:No \tl_tail:n { #1 { } } + } + } +\cs_new_protected_nopar:Npn \__ctex_titlesec_spacing:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__ctex_titlesec_spacing:nnnnnn #1 {#2} } } +\cs_new:Npn \__ctex_titlesec_spacing:nnnnnn #1#2#3#4#5#6 + { + \exp_not:n { {#1} {#2} {#3} {#4} } + { \bool_if:cTF { CTEX@#6@afterindent } { \@ne } { \z@ } } + } +\@ifpackageloaded { titlesec } + { } + { + \ctex_at_end_package:nn { titlesec } + { + \@ifpackagewith { titlesec } { loadonly } + { } + { \ctex_titlesec_hook: } + } } \cs_new_protected:Npn \CTEX@toc@width@n #1 { @@ -991,31 +1054,39 @@ \use:n { \group_end: - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline { \ExplSyntaxOff } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } \@ifpackageloaded { tocloft } { } { \ctex_at_end_package:nn { tocloft } { - \ctex_preto_cmd:NnTF \numberline { \CTEX@toc@width@n {#1} } { } + \ctex_preto_cmd:NnnTF \numberline + { \char_set_catcode_letter:n { 64 } } + { \CTEX@toc@width@n {#1} } + { } { \ctex_patch_failure:N \numberline } } } - \ExplSyntaxOn } \ctex_patch_cmd:Nnn \ps@headings - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \if@twoside - \ctex_patch_cmd:Nnn \ps@headings { \thesection.~\ } { \CTEXthesection \quad } + \ctex_patch_cmd:Nnn \ps@headings + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } \fi: \ctex_at_end_package:nn { fancyhdr } { \ctex_patch_cmd:Nnn \ps@fancy - { \@chapapp\ \thechapter.~\ } { \CTEXthechapter \quad } + { \@chapapp\ \thechapter.~\ } + { \ifodd \CTEX@chapter@numbering \CTEXthechapter \quad \fi } \ctex_patch_cmd:Nnn \ps@fancy - { \thesection.~\ } { \CTEXthesection \quad } + { \thesection.~\ } + { \ifodd \CTEX@section@numbering \CTEXthesection \quad \fi } } \cs_new_protected_nopar:Npn \CTEX@setcurrentlabel@n #1 { @@ -1147,7 +1218,7 @@ \fi: \fp_compare:nNnF { \l__ctex_line_spread_fp } ? { \c_zero_fp } { - \linespread { \fp_use:N \l__ctex_line_spread_fp } + \exp_args:Nx \linespread { \fp_use:N \l__ctex_line_spread_fp } \group_begin: \footnotesize \exp_args:NNNo \group_end: \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } } @@ -1164,26 +1235,6 @@ { You~can~load~the~package~`caption'~to~get~its~functionality. } } } -\group_begin: -\char_set_catcode_other:N \# -\use:n - { - \group_end: - \ExplSyntaxOff - \ctex_at_end_package:nn { breqn } - { - \ctex_patch_cmd:NnnTF \end { \csname end#1 \endcsname } - { - \csuse { @end@#1@hook } - \csname end#1 \endcsname - } { } - { - \ctex_preto_cmd:NnTF \end { \csuse { @end@#1@hook } } - { } { \ctex_patch_failure:N \end } - } - } - \ExplSyntaxOn - } \cs_new_protected_nopar:Npn \ctex_fontset_error:n #1 { \msg_critical:nnn { ctex } { fontset-unavailable } {#1} } \msg_new:nnn { ctex } { fontset-unavailable } @@ -1257,12 +1308,14 @@ %% and the derived files ctex.pdf, %% ctex.ins, %% ctex.sty, -%% ctexcap.sty, %% ctexsize.sty, %% ctexheading.sty, %% ctexart.cls, %% ctexbook.cls, %% ctexrep.cls, +%% ctexcap.sty, +%% ctexhook.sty, +%% ctexpatch.sty, %% ctex-c5size.clo, %% ctex-cs4size.clo, %% ctex-article.def, diff --git a/Master/texmf-dist/tex/latex/ctex/ctexsize.sty b/Master/texmf-dist/tex/latex/ctex/ctexsize.sty index 59d56038732..9dcee563f86 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexsize.sty +++ b/Master/texmf-dist/tex/latex/ctex/ctexsize.sty @@ -28,10 +28,10 @@ %% \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese font size definition (CTEX)} \ProvidesExplPackage{ctexsize} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \RequirePackage { xparse , l3keys2e } \cs_new_eq:NN \g__ctex_font_size_flag \c_minus_one \keys_define:nn { ctex / option } @@ -162,12 +162,14 @@ %% and the derived files ctex.pdf, %% ctex.ins, %% ctex.sty, -%% ctexcap.sty, %% ctexsize.sty, %% ctexheading.sty, %% ctexart.cls, %% ctexbook.cls, %% ctexrep.cls, +%% ctexcap.sty, +%% ctexhook.sty, +%% ctexpatch.sty, %% ctex-c5size.clo, %% ctex-cs4size.clo, %% ctex-article.def, diff --git a/Master/texmf-dist/tex/latex/ctex/ctexspa.def b/Master/texmf-dist/tex/latex/ctex/ctexspa.def index 91048dd0a27..9e61e7c8870 100644 --- a/Master/texmf-dist/tex/latex/ctex/ctexspa.def +++ b/Master/texmf-dist/tex/latex/ctex/ctexspa.def @@ -28,7 +28,7 @@ %% ------------------------------------------------------------------------------ %% \ProvidesFile{ctexspa.def}% - [2015/05/15 v2.1 Space info for CJKpunct (CTEX)] + [2015/07/01 v2.2 Space info for CJKpunct (CTEX)] \ctexspadef{adobezhsong}{70,15,61,8,63,14,58,7,64,13,62,12,60,11,61,15,62,14,51,6,58,5,58,8,7,5,12,12,10,68,13,63,17,63,20,69,19,69,17,63,19,70,17,55,10,10,14,63,10,65,10,61,13,62,15,61,7,49,7,56,8,58,15,69,8,61,14,63,8,57,,,} \ctexspadef{adobezhhei}{78,3,64,3,64,2,61,3,72,3,70,3,72,3,70,3,60,3,51,3,62,3,66,3,0,0,10,10,3,70,5,70,6,75,6,78,17,67,13,67,17,67,4,50,8,8,3,72,3,70,3,72,3,70,3,60,3,51,3,62,3,66,3,78,7,62,3,63,3,61,,,} \ctexspadef{adobezhkai}{76,10,55,8,63,4,62,4,71,4,65,4,71,4,74,4,54,4,54,4,62,4,62,4,0,0,11,11,5,72,6,71,7,78,7,79,18,68,18,68,18,68,2,46,14,12,4,71,4,65,4,71,4,74,4,54,4,54,4,62,4,62,10,76,8,55,4,63,4,62,,,} diff --git a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def index b8c8b3e325b..902e0e3e832 100644 --- a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def +++ b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-luatex.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {LuaLaTeX adapter (CTEX)} \ProvidesExplFile{ctex-engine-luatex.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \msg_new:nnn { ctex } { luatexja-loaded } { Package~`luatexja'~can~not~be~loaded~before~`ctex'.\\ @@ -565,13 +565,20 @@ \tl_if_exist:NF \CJKrmdefault { \tl_const:Nn \CJKrmdefault { rm } } \tl_if_exist:NF \CJKsfdefault { \tl_const:Nn \CJKsfdefault { sf } } \tl_if_exist:NF \CJKttdefault { \tl_const:Nn \CJKttdefault { tt } } -\ctex_preto_cmd:NnTF \rmfamily { \CJKfamily { \CJKrmdefault } } { } +\ctex_preto_cmd:NnnTF \rmfamily { \ExplSyntaxOff } + { \CJKfamily { \CJKrmdefault } } + { } { \ctex_patch_failure:N \rmfamily } -\ctex_preto_cmd:NnTF \sffamily { \CJKfamily { \CJKsfdefault } } { } +\ctex_preto_cmd:NnnTF \sffamily { \ExplSyntaxOff } + { \CJKfamily { \CJKsfdefault } } + { } { \ctex_patch_failure:N \sffamily } -\ctex_preto_cmd:NnTF \ttfamily { \CJKfamily { \CJKttdefault } } { } +\ctex_preto_cmd:NnnTF \ttfamily { \ExplSyntaxOff } + { \CJKfamily { \CJKttdefault } } + { } { \ctex_patch_failure:N \ttfamily } -\ctex_preto_cmd:NnTF \normalfont { \CJKfamily { \CJKfamilydefault } } +\ctex_preto_cmd:NnnTF \normalfont { \ExplSyntaxOff } + { \CJKfamily { \CJKfamilydefault } } { \cs_set_eq:NN \reset@font \normalfont } { \ctex_patch_failure:N \normalfont } \cs_new_protected_nopar:Npn \ctex_ltj_ensure_default_family: @@ -929,8 +936,11 @@ \skip_set:Nn \l__ctex_ltj_xkanjiskip_skip { .25 \zw plus 1pt minus 1pt } \AtBeginDocument { - \ctex_appto_cmd:NnTF \verbatim@font { \CTEX@verbatim@font@hook } - { } { \ctex_patch_failure:N \verbatim@font } + \ctex_appto_cmd:NnnTF \verbatim@font + { \char_set_catcode_letter:n { 64 } } + { \CTEX@verbatim@font@hook } + { } + { \ctex_patch_failure:N \verbatim@font } } \cs_new_protected_nopar:Npn \CTEX@verbatim@font@hook { \ltjsetparameter { autospacing = false , autoxspacing = false } } @@ -954,7 +964,7 @@ } \ctex_ltj_ensure_default_family: } -\AtEndPreamble { \ctex_update_default_family: } +\ctex_at_end_preamble:n { \ctex_update_default_family: } \tl_new:N \l__ctex_family_default_init_tl \cs_new_eq:NN \__ctex_family_default_wrap:n \use:n \tl_set:Nx \l__ctex_family_default_init_tl @@ -1008,17 +1018,13 @@ } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: \cs_new_eq:Nc \__ctex_save_selectfont: { selectfont ~ } -\use:n +\ctex_preto_cmd:NnnTF \selectfont { \ExplSyntaxOff } + { \CTEX@selectfont@hook } { - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \selectfont { \CTEX@selectfont@hook } - { - \tl_put_left:Nn \@EverySelectfont@Init - { \cs_set_eq:cN { selectfont ~ } \__ctex_save_selectfont: } - } - { \ctex_patch_failure:N \selectfont } + \tl_put_left:Nn \@EverySelectfont@Init + { \cs_set_eq:cN { selectfont ~ } \__ctex_save_selectfont: } } -\ExplSyntaxOn + { \ctex_patch_failure:N \selectfont } \EverySelectfont { \CTEX@selectfont@hook } \ctex_add_to_selectfont:n { diff --git a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def index 8b8d9f876cb..49dc80aca67 100644 --- a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def +++ b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {(pdf)LaTeX adapter (CTEX)} \ProvidesExplFile{ctex-engine-pdftex.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \seq_new:N \c__ctex_cmap_encoding_seq \seq_set_from_clist:Nn \c__ctex_cmap_encoding_seq { C19 , C10 , C00 , C09 , C40 , C60 } @@ -69,14 +69,13 @@ \ctex_if_pdfmode:TF { \group_end: - \ExplSyntaxOff - \ctex_appto_cmd:NnTF \DeclareFontFamily { \CTEX@Family@CMap {#1} {#2} } + \ctex_appto_cmd:NnnTF \DeclareFontFamily { \ExplSyntaxOff } + { \CTEX@Family@CMap {#1} {#2} } { \ctex_at_end_package:nn { cmap } { \cs_gset_eq:NN \CTEX@Family@CMap \use_none:nn } } { \ctex_patch_failure:N \DeclareFontFamily } - \ExplSyntaxOn } { \group_end: } \if_bool:N \g__ctex_zhmCJK_bool @@ -102,13 +101,20 @@ \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:NnTF \rmfamily { \CJKfamily { \CJKrmdefault } } { } + \ctex_preto_cmd:NnnTF \rmfamily { \ExplSyntaxOff } + { \CJKfamily { \CJKrmdefault } } + { } { \ctex_patch_failure:N \rmfamily } - \ctex_preto_cmd:NnTF \sffamily { \CJKfamily { \CJKsfdefault } } { } + \ctex_preto_cmd:NnnTF \sffamily { \ExplSyntaxOff } + { \CJKfamily { \CJKsfdefault } } + { } { \ctex_patch_failure:N \sffamily } - \ctex_preto_cmd:NnTF \ttfamily { \CJKfamily { \CJKttdefault } } { } + \ctex_preto_cmd:NnnTF \ttfamily { \ExplSyntaxOff } + { \CJKfamily { \CJKttdefault } } + { } { \ctex_patch_failure:N \ttfamily } - \ctex_preto_cmd:NnTF \normalfont { \CJKfamily { \CJKfamilydefault } } + \ctex_preto_cmd:NnnTF \normalfont { \ExplSyntaxOff } + { \CJKfamily { \CJKfamilydefault } } { \cs_set_eq:NN \reset@font \normalfont } { \ctex_patch_failure:N \normalfont } \fi: @@ -160,7 +166,7 @@ \CJK@makeActive \CJK@loadBinding { standard } } - \exp_args:Nx \AtEndPreamble + \exp_args:Nx \ctex_at_end_preamble:n { \exp_not:N \CJK@envStart { } { \l__ctex_encoding_tl } { \exp_not:N \CJKfamilydefault } @@ -248,7 +254,7 @@ \group_end: } } -\AtEndPreamble { \ctex_update_default_family: } +\ctex_at_end_preamble:n { \ctex_update_default_family: } \tl_new:N \l__ctex_family_default_init_tl \cs_new_eq:NN \__ctex_family_default_wrap:n \use:n \tl_set:Nx \l__ctex_family_default_init_tl @@ -363,17 +369,13 @@ } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: \cs_new_eq:Nc \__ctex_save_selectfont: { selectfont ~ } -\use:n +\ctex_preto_cmd:NnnTF \selectfont { \ExplSyntaxOff } + { \CTEX@selectfont@hook } { - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \selectfont { \CTEX@selectfont@hook } - { - \tl_put_left:Nn \@EverySelectfont@Init - { \cs_set_eq:cN { selectfont ~ } \__ctex_save_selectfont: } - } - { \ctex_patch_failure:N \selectfont } + \tl_put_left:Nn \@EverySelectfont@Init + { \cs_set_eq:cN { selectfont ~ } \__ctex_save_selectfont: } } -\ExplSyntaxOn + { \ctex_patch_failure:N \selectfont } \EverySelectfont { \cs_if_exist:NF \CJK@plane { \CTEX@selectfont@hook } } \keys_define:nn { ctex } { diff --git a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def index 11f036799e0..6a6e2a0cbf4 100644 --- a/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def +++ b/Master/texmf-dist/tex/latex/ctex/engine/ctex-engine-xetex.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {XeLaTeX adapter (CTEX)} \ProvidesExplFile{ctex-engine-xetex.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \RequirePackage { xeCJK } \exp_args:Nx \xeCJKsetup { @@ -119,17 +119,13 @@ } \cs_new_eq:NN \CTEX@selectfont@hook \prg_do_nothing: \cs_new_eq:Nc \__ctex_save_selectfont: { selectfont ~ } -\use:n +\ctex_preto_cmd:NnnTF \selectfont { \ExplSyntaxOff } + { \CTEX@selectfont@hook } { - \ExplSyntaxOff - \ctex_preto_cmd:NnTF \selectfont { \CTEX@selectfont@hook } - { - \tl_put_left:Nn \@EverySelectfont@Init - { \cs_set_eq:cN { selectfont ~ } \__ctex_save_selectfont: } - } - { \ctex_patch_failure:N \selectfont } + \tl_put_left:Nn \@EverySelectfont@Init + { \cs_set_eq:cN { selectfont ~ } \__ctex_save_selectfont: } } -\ExplSyntaxOn + { \ctex_patch_failure:N \selectfont } \EverySelectfont { \CTEX@selectfont@hook } \keys_define:nn { ctex } { diff --git a/Master/texmf-dist/tex/latex/ctex/fd/c19rm.fd b/Master/texmf-dist/tex/latex/ctex/fd/c19rm.fd index 30d2f7fce75..b748cdf5f57 100644 --- a/Master/texmf-dist/tex/latex/ctex/fd/c19rm.fd +++ b/Master/texmf-dist/tex/latex/ctex/fd/c19rm.fd @@ -27,7 +27,7 @@ %% ------------------------------------------------------------------------------ %% \ProvidesFile{c19rm.fd}% - [2015/05/15 v2.1 Chinese font definition (CTEX)] + [2015/07/01 v2.2 Chinese font definition (CTEX)] %% %% Chinese characters %% diff --git a/Master/texmf-dist/tex/latex/ctex/fd/c19sf.fd b/Master/texmf-dist/tex/latex/ctex/fd/c19sf.fd index 704ad030883..f473966f375 100644 --- a/Master/texmf-dist/tex/latex/ctex/fd/c19sf.fd +++ b/Master/texmf-dist/tex/latex/ctex/fd/c19sf.fd @@ -27,7 +27,7 @@ %% ------------------------------------------------------------------------------ %% \ProvidesFile{c19sf.fd}% - [2015/05/15 v2.1 Chinese font definition (CTEX)] + [2015/07/01 v2.2 Chinese font definition (CTEX)] %% %% Chinese characters %% diff --git a/Master/texmf-dist/tex/latex/ctex/fd/c19tt.fd b/Master/texmf-dist/tex/latex/ctex/fd/c19tt.fd index 0986f6b8be2..443363529e0 100644 --- a/Master/texmf-dist/tex/latex/ctex/fd/c19tt.fd +++ b/Master/texmf-dist/tex/latex/ctex/fd/c19tt.fd @@ -27,7 +27,7 @@ %% ------------------------------------------------------------------------------ %% \ProvidesFile{c19tt.fd}% - [2015/05/15 v2.1 Chinese font definition (CTEX)] + [2015/07/01 v2.2 Chinese font definition (CTEX)] %% %% Chinese characters %% diff --git a/Master/texmf-dist/tex/latex/ctex/fd/c70rm.fd b/Master/texmf-dist/tex/latex/ctex/fd/c70rm.fd index 914baac86f3..99eb8e23466 100644 --- a/Master/texmf-dist/tex/latex/ctex/fd/c70rm.fd +++ b/Master/texmf-dist/tex/latex/ctex/fd/c70rm.fd @@ -27,7 +27,7 @@ %% ------------------------------------------------------------------------------ %% \ProvidesFile{c70rm.fd}% - [2015/05/15 v2.1 Chinese font definition (CTEX)] + [2015/07/01 v2.2 Chinese font definition (CTEX)] %% %% Chinese characters %% diff --git a/Master/texmf-dist/tex/latex/ctex/fd/c70sf.fd b/Master/texmf-dist/tex/latex/ctex/fd/c70sf.fd index 492cf166309..aaca4cec351 100644 --- a/Master/texmf-dist/tex/latex/ctex/fd/c70sf.fd +++ b/Master/texmf-dist/tex/latex/ctex/fd/c70sf.fd @@ -27,7 +27,7 @@ %% ------------------------------------------------------------------------------ %% \ProvidesFile{c70sf.fd}% - [2015/05/15 v2.1 Chinese font definition (CTEX)] + [2015/07/01 v2.2 Chinese font definition (CTEX)] %% %% Chinese characters %% diff --git a/Master/texmf-dist/tex/latex/ctex/fd/c70tt.fd b/Master/texmf-dist/tex/latex/ctex/fd/c70tt.fd index 305df75675f..115bb4df8fb 100644 --- a/Master/texmf-dist/tex/latex/ctex/fd/c70tt.fd +++ b/Master/texmf-dist/tex/latex/ctex/fd/c70tt.fd @@ -27,7 +27,7 @@ %% ------------------------------------------------------------------------------ %% \ProvidesFile{c70tt.fd}% - [2015/05/15 v2.1 Chinese font definition (CTEX)] + [2015/07/01 v2.2 Chinese font definition (CTEX)] %% %% Chinese characters %% diff --git a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-adobe.def b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-adobe.def index 5fd609c3abf..24e30e0f28d 100644 --- a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-adobe.def +++ b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-adobe.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Adobe fonts definition (CTEX)} \ProvidesExplFile{ctex-fontset-adobe.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \pdftex_if_engine:TF { \ctex_if_pdfmode:TF diff --git a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-fandol.def b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-fandol.def index bcdabfb49ff..8d29591debf 100644 --- a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-fandol.def +++ b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-fandol.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Fandol fonts definition (CTEX)} \ProvidesExplFile{ctex-fontset-fandol.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \pdftex_if_engine:TF { \ctex_if_pdfmode:TF diff --git a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-founder.def b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-founder.def index 715bd19771b..8a8cd79d2dc 100644 --- a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-founder.def +++ b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-founder.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Founder fonts definition (CTEX)} \ProvidesExplFile{ctex-fontset-founder.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \pdftex_if_engine:TF { \ctex_zhmap_case:nnn diff --git a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-mac.def b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-mac.def index 041926b2c35..74fd11e0a80 100644 --- a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-mac.def +++ b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-mac.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Mac OS X fonts definition (CTEX)} \ProvidesExplFile{ctex-fontset-mac.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \pdftex_if_engine:TF { \ctex_fontset_error:n { mac } } { diff --git a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-ubuntu.def b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-ubuntu.def index b24ab4be269..6b4c840a77d 100644 --- a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-ubuntu.def +++ b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-ubuntu.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Ubuntu fonts definition (CTEX)} \ProvidesExplFile{ctex-fontset-ubuntu.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \pdftex_if_engine:TF { \ctex_zhmap_case:nnn diff --git a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def index 296514caca3..46d2f765513 100644 --- a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def +++ b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Windows fonts definition (CTEX)} \ProvidesExplFile{ctex-fontset-windows.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \file_if_exist:nTF { C:/boot.ini } { \ctex_file_input:n { ctex-fontset-windowsold.def } } { \ctex_file_input:n { ctex-fontset-windowsnew.def } } diff --git a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsnew.def b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsnew.def index bd52407f505..19c4b348e7a 100644 --- a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsnew.def +++ b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsnew.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Windows fonts definition for Vista or later version (CTEX)} \ProvidesExplFile{ctex-fontset-windowsnew.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \pdftex_if_engine:TF { \ctex_zhmap_case:nnn diff --git a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsold.def b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsold.def index 6156c9e30e8..8bb2f56860e 100644 --- a/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsold.def +++ b/Master/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windowsold.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Windows fonts definition for XP or earlier version (CTEX)} \ProvidesExplFile{ctex-fontset-windowsold.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \pdftex_if_engine:TF { \ctex_zhmap_case:nnn diff --git a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-article.def b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-article.def index b21208988d8..744ddadda77 100644 --- a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-article.def +++ b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-article.def @@ -26,29 +26,30 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese scheme for article (CTEX)} \ProvidesExplFile{ctex-scheme-chinese-article.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \keys_set:nn { ctex / part } { aftertitle = \par , number = \chinese { part } , - nameformat = \Large \bfseries , + beforeskip = 4ex , afterskip = 3ex , - format = \centering , + format = \Large \bfseries \centering , aftername = \quad , - titleformat = \Large \bfseries , - beforeskip = 4ex + afterindent = true } \keys_set:nn { ctex / section } { number = \thesection , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.5ex \@plus 1ex \@minus .2ex , afterskip = 2.3ex \@plus .2ex , + runin = false , format = \Large \bfseries \centering , - beforeskip = 3.5ex \@plus 1ex \@minus .2ex + afterindent = true } \keys_set:nn { ctex / subsection } { @@ -56,8 +57,10 @@ format = \large \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex + runin = false , + afterindent = true } \keys_set:nn { ctex / subsubsection } { @@ -65,35 +68,41 @@ format = \normalsize \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex + runin = false , + afterindent = true } \keys_set:nn { ctex / paragraph } { number = \theparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = true } \keys_set:nn { ctex / subparagraph } { number = \thesubparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = true } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two { \keys_set:nn { ctex / paragraph } { aftertitle = \@@par , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / paragraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_three @@ -101,15 +110,15 @@ \keys_set:nn { ctex / subparagraph } { aftertitle = \@@par , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / subparagraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two diff --git a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-book.def b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-book.def index 2d83f7e708f..055ca1c859d 100644 --- a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-book.def +++ b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-book.def @@ -26,40 +26,41 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese scheme for book (CTEX)} \ProvidesExplFile{ctex-scheme-chinese-book.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \keys_set:nn { ctex / part } { aftertitle = \par , number = \chinese { part } , - format = \centering , - nameformat = \huge \bfseries , aftername = \par \vskip 20 \p@ , + beforeskip = 0pt \@plus 1fil , + afterskip = 0pt \@plus 1fil , pagestyle = plain , - titleformat = \huge \bfseries + format = \huge \bfseries \centering } \keys_set:nn { ctex / chapter } { pagestyle = plain , - nameformat = \huge \bfseries , aftertitle = \par , + beforeskip = 50 \p@ , afterskip = 40 \p@ , number = \chinese { chapter } , - format = \centering , + format = \huge \bfseries \centering , aftername = \quad , - titleformat = \huge \bfseries , - beforeskip = 50 \p@ + afterindent = true } \keys_set:nn { ctex / section } { number = \thesection , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.5ex \@plus 1ex \@minus .2ex , afterskip = 2.3ex \@plus .2ex , + runin = false , format = \Large \bfseries \centering , - beforeskip = 3.5ex \@plus 1ex \@minus .2ex + afterindent = true } \keys_set:nn { ctex / subsection } { @@ -67,8 +68,10 @@ format = \large \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex + runin = false , + afterindent = true } \keys_set:nn { ctex / subsubsection } { @@ -76,35 +79,41 @@ format = \normalsize \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex + runin = false , + afterindent = true } \keys_set:nn { ctex / paragraph } { number = \theparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = true } \keys_set:nn { ctex / subparagraph } { number = \thesubparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = true } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two { \keys_set:nn { ctex / paragraph } { aftertitle = \@@par , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / paragraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_three @@ -112,15 +121,15 @@ \keys_set:nn { ctex / subparagraph } { aftertitle = \@@par , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / subparagraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two diff --git a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-report.def b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-report.def index 0bf4aa05931..017ee477859 100644 --- a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-report.def +++ b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-report.def @@ -26,40 +26,41 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese scheme for report (CTEX)} \ProvidesExplFile{ctex-scheme-chinese-report.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \keys_set:nn { ctex / part } { aftertitle = \par , number = \chinese { part } , - format = \centering , - nameformat = \huge \bfseries , aftername = \par \vskip 20 \p@ , + beforeskip = 0pt \@plus 1fil , + afterskip = 0pt \@plus 1fil , pagestyle = plain , - titleformat = \huge \bfseries + format = \huge \bfseries \centering } \keys_set:nn { ctex / chapter } { pagestyle = plain , - nameformat = \huge \bfseries , aftertitle = \par , + beforeskip = 50 \p@ , afterskip = 40 \p@ , number = \chinese { chapter } , - format = \centering , + format = \huge \bfseries \centering , aftername = \quad , - titleformat = \huge \bfseries , - beforeskip = 50 \p@ + afterindent = true } \keys_set:nn { ctex / section } { number = \thesection , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.5ex \@plus 1ex \@minus .2ex , afterskip = 2.3ex \@plus .2ex , + runin = false , format = \Large \bfseries \centering , - beforeskip = 3.5ex \@plus 1ex \@minus .2ex + afterindent = true } \keys_set:nn { ctex / subsection } { @@ -67,8 +68,10 @@ format = \large \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex + runin = false , + afterindent = true } \keys_set:nn { ctex / subsubsection } { @@ -76,35 +79,41 @@ format = \normalsize \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex + runin = false , + afterindent = true } \keys_set:nn { ctex / paragraph } { number = \theparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = true } \keys_set:nn { ctex / subparagraph } { number = \thesubparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = true } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two { \keys_set:nn { ctex / paragraph } { aftertitle = \@@par , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / paragraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_three @@ -112,15 +121,15 @@ \keys_set:nn { ctex / subparagraph } { aftertitle = \@@par , - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / subparagraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two diff --git a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def index b3be5572070..e5b315b71c9 100644 --- a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def +++ b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Chinese scheme for generic (CTEX)} \ProvidesExplFile{ctex-scheme-chinese.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \str_if_eq:onTF { \l__ctex_encoding_tl } { GBK } { \ctex_file_input:n { ctex-name-gbk.cfg } } { \ctex_file_input:n { ctex-name-utf8.cfg } } @@ -41,7 +41,7 @@ \ctex_if_autoindent_touched:F { \keys_set:nn { ctex } { autoindent = true } } \tl_if_exist:NT \c__ctex_std_class_tl - { \RequirePackage{ indentfirst } } + { \RequirePackage { indentfirst } } %% %% %% End of file `ctex-scheme-chinese.def'. diff --git a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-article.def b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-article.def index 752fefd584d..771341156b2 100644 --- a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-article.def +++ b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-article.def @@ -26,30 +26,33 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Plain scheme for article (CTEX)} \ProvidesExplFile{ctex-scheme-plain-article.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \keys_set:nn { ctex / part } { aftertitle = \par , name = \partname \space , number = \thepart , - nameformat = \Large \bfseries , + beforeskip = 4ex , afterskip = 3ex , format = \raggedright , + nameformat = \Large \bfseries , aftername = \par \nobreak , titleformat = \huge \bfseries , - beforeskip = -4ex + afterindent = false } \keys_set:nn { ctex / section } { number = \thesection , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.5ex \@plus 1ex \@minus .2ex , afterskip = 2.3ex \@plus .2ex , + runin = false , format = \Large \bfseries , - beforeskip = -3.5ex \@plus -1ex \@minus -.2ex + afterindent = false } \keys_set:nn { ctex / subsection } { @@ -57,8 +60,10 @@ format = \large \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex + runin = false , + afterindent = false } \keys_set:nn { ctex / subsubsection } { @@ -66,35 +71,41 @@ format = \normalsize \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex + runin = false , + afterindent = false } \keys_set:nn { ctex / paragraph } { number = \theparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = false } \keys_set:nn { ctex / subparagraph } { number = \thesubparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = false } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two { \keys_set:nn { ctex / paragraph } { aftertitle = \@@par , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / paragraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_three @@ -102,15 +113,15 @@ \keys_set:nn { ctex / subparagraph } { aftertitle = \@@par , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / subparagraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two diff --git a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-book.def b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-book.def index 202db21f8c7..e3ab04495eb 100644 --- a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-book.def +++ b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-book.def @@ -26,42 +26,47 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Plain scheme for book (CTEX)} \ProvidesExplFile{ctex-scheme-plain-book.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \keys_set:nn { ctex / part } { aftertitle = \par , name = \partname \space , number = \thepart , - format = \centering , - nameformat = \huge \bfseries , aftername = \par \vskip 20 \p@ , + beforeskip = 0pt \@plus 1fil , + afterskip = 0pt \@plus 1fil , pagestyle = plain , + format = \centering , + nameformat = \huge \bfseries , titleformat = \Huge \bfseries } \keys_set:nn { ctex / chapter } { pagestyle = plain , - nameformat = \huge \bfseries , aftertitle = \par , + beforeskip = 50 \p@ , afterskip = 40 \p@ , name = \chaptername \space , number = \thechapter , format = \raggedright , + nameformat = \huge \bfseries , aftername = \par \nobreak \vskip 20 \p@ , titleformat = \Huge \bfseries , - beforeskip = -50 \p@ + afterindent = false } \keys_set:nn { ctex / section } { number = \thesection , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.5ex \@plus 1ex \@minus .2ex , afterskip = 2.3ex \@plus .2ex , + runin = false , format = \Large \bfseries , - beforeskip = -3.5ex \@plus -1ex \@minus -.2ex + afterindent = false } \keys_set:nn { ctex / subsection } { @@ -69,8 +74,10 @@ format = \large \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex + runin = false , + afterindent = false } \keys_set:nn { ctex / subsubsection } { @@ -78,35 +85,41 @@ format = \normalsize \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex + runin = false , + afterindent = false } \keys_set:nn { ctex / paragraph } { number = \theparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = false } \keys_set:nn { ctex / subparagraph } { number = \thesubparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = false } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two { \keys_set:nn { ctex / paragraph } { aftertitle = \@@par , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / paragraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_three @@ -114,15 +127,15 @@ \keys_set:nn { ctex / subparagraph } { aftertitle = \@@par , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / subparagraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two diff --git a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-report.def b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-report.def index fac90d7aea7..61d509648d8 100644 --- a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-report.def +++ b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain-report.def @@ -26,42 +26,47 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Plain scheme for report (CTEX)} \ProvidesExplFile{ctex-scheme-plain-report.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} \keys_set:nn { ctex / part } { aftertitle = \par , name = \partname \space , number = \thepart , - format = \centering , - nameformat = \huge \bfseries , aftername = \par \vskip 20 \p@ , + beforeskip = 0pt \@plus 1fil , + afterskip = 0pt \@plus 1fil , pagestyle = plain , + format = \centering , + nameformat = \huge \bfseries , titleformat = \Huge \bfseries } \keys_set:nn { ctex / chapter } { pagestyle = plain , - nameformat = \huge \bfseries , aftertitle = \par , + beforeskip = 50 \p@ , afterskip = 40 \p@ , name = \chaptername \space , number = \thechapter , format = \raggedright , + nameformat = \huge \bfseries , aftername = \par \nobreak \vskip 20 \p@ , titleformat = \Huge \bfseries , - beforeskip = -50 \p@ + afterindent = false } \keys_set:nn { ctex / section } { number = \thesection , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.5ex \@plus 1ex \@minus .2ex , afterskip = 2.3ex \@plus .2ex , + runin = false , format = \Large \bfseries , - beforeskip = -3.5ex \@plus -1ex \@minus -.2ex + afterindent = false } \keys_set:nn { ctex / subsection } { @@ -69,8 +74,10 @@ format = \large \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex + runin = false , + afterindent = false } \keys_set:nn { ctex / subsubsection } { @@ -78,35 +85,41 @@ format = \normalsize \bfseries , aftername = \quad , aftertitle = \@@par , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , afterskip = 1.5ex \@plus .2ex , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex + runin = false , + afterindent = false } \keys_set:nn { ctex / paragraph } { number = \theparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = false } \keys_set:nn { ctex / subparagraph } { number = \thesubparagraph , format = \normalsize \bfseries , - aftername = \quad + aftername = \quad , + beforeskip = 3.25ex \@plus 1ex \@minus .2ex , + afterindent = false } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two { \keys_set:nn { ctex / paragraph } { aftertitle = \@@par , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / paragraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_three @@ -114,15 +127,15 @@ \keys_set:nn { ctex / subparagraph } { aftertitle = \@@par , - beforeskip = -3.25ex \@plus -1ex \@minus -.2ex , - afterskip = 1ex \@plus .2ex + afterskip = 1ex \@plus .2ex , + runin = false } } { \keys_set:nn { ctex / subparagraph } { - beforeskip = 3.25ex \@plus 1ex \@minus .2ex , - afterskip = -1em + afterskip = 1em , + runin = true } } \int_compare:nNnTF \g__ctex_section_depth_flag > \c_two diff --git a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain.def b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain.def index 7823ef28251..c3cee4ceabb 100644 --- a/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain.def +++ b/Master/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-plain.def @@ -26,10 +26,10 @@ %% %% ------------------------------------------------------------------------------ %% -\GetIdInfo$Id: ctex.dtx ca75f0e 2015-06-19 17:39:23 +0800 Qing Lee <sobenlee@gmail.com> $ +\GetIdInfo$Id: ctex.dtx 6255367 2015-07-01 01:15:24 +0800 Qing Lee <sobenlee@gmail.com> $ {Plain scheme for generic (CTEX)} \ProvidesExplFile{ctex-scheme-plain.def} - {\ExplFileDate}{2.1}{\ExplFileDescription} + {\ExplFileDate}{2.2}{\ExplFileDescription} %% %% %% End of file `ctex-scheme-plain.def'. |