diff options
author | Karl Berry <karl@freefriends.org> | 2021-06-02 20:58:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-06-02 20:58:14 +0000 |
commit | 1670128147b961288cd259e2e3824eeda7ec22e9 (patch) | |
tree | d529ea04c95220eb37a7674f51e4bee4a9cfffd3 | |
parent | c7de3b443718d91144c1f540ec7afeae418d0a2a (diff) |
easybook (2jun21)
git-svn-id: svn://tug.org/texlive/trunk@59434 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/easybook/easybook.pdf | bin | 313301 -> 315453 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/easybook/easybook.dtx | 647 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/easybook/easybook.ins | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/easybook/easybase.sty | 1865 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/easybook/easybook.cls | 1818 |
5 files changed, 2231 insertions, 2105 deletions
diff --git a/Master/texmf-dist/doc/latex/easybook/easybook.pdf b/Master/texmf-dist/doc/latex/easybook/easybook.pdf Binary files differindex 80221ec6761..7d7ea10892a 100644 --- a/Master/texmf-dist/doc/latex/easybook/easybook.pdf +++ b/Master/texmf-dist/doc/latex/easybook/easybook.pdf diff --git a/Master/texmf-dist/source/latex/easybook/easybook.dtx b/Master/texmf-dist/source/latex/easybook/easybook.dtx index ad29040915b..c89a99181f4 100644 --- a/Master/texmf-dist/source/latex/easybook/easybook.dtx +++ b/Master/texmf-dist/source/latex/easybook/easybook.dtx @@ -23,11 +23,12 @@ % % \changes{v1.20}{2021/01/09}{修改和完善用户文档。} % \changes{v1.20}{2021/01/09}{模板更改为使用 CC-BY 许可协议。} -% \changes{v1.25p}{2021/05/03}{取消附带的示例文件,可查看历史版本及其它来源的使用样例。} +% \changes{v1.25q}{2021/05/03}{取消附带的示例文件,可查看历史版本及其它来源的使用样例。} +% \changes{v1.25q}{2021/06/02}{将模块的代码独立出来为 \pkg{easybase} 宏包,适用于 \CTeX 文档类。} % % \title{\sffamily easybook 文档类手册} % \author{瞿毅} -% \date{2021/05/31\hskip\ccwd\relax v1.25p\thanks{\url{https://gitee.com/texl3/easybook}}} +% \date{2021/06/02\hskip\ccwd\relax v1.25q\thanks{\url{https://gitee.com/texl3/easybook}}} % % \maketitle % \begin{abstract} @@ -57,6 +58,22 @@ % \end{document} % \end{frameverb} % +% 或者直接使用 \pkg{easybase} 宏包,它的宏包选项有 \opt{class} 和 \opt{draft},包含了节 \ref{sec:interface options} 所示各个模块接口命令的功能,目前只适用于 \cls{ctexbook} 和 \cls{ctexart} 文档类。 +% \begin{frameverb} +% \documentclass{ctexbook} +% +% \usepackage{easybase} +% \ctexset{键值列表} +% +% \usepackage{宏包列表} +% +% \begin{document} +% \chapter{欢迎} +% \section{Welcome to easybook} +% Hello, \LaTeX +% \end{document} +% \end{frameverb} +% % \subsection{编译方式} % 假设您的 \TeX 源文件名为 \opt{easybook.tex},需要使用参考文献和索引功能,并使用 \hologo{XeLaTeX} 和 \hologo{BibTeX} 引擎编译文档,那么需要在命令行中执行 % \begin{frameverb} @@ -117,7 +134,7 @@ % \end{syntax} % 传递给 \cls{ctexbook} 设置字体,最好不要使用原有的 \opt{fontset} 选项,默认情况下使用自定义字体而不开启这个选项,可根据安装的字体及电脑系统选取。\opt{noto} 与 \opt{none} 选项的相关描述见小节 \ref{subsec:font settings},\opt{overleaf} 是一个各系统通用选项,会检测系统环境选取对应字体。 % \changes{v1.21}{2021/01/12}{默认字体与 \CTeX 一致,不再是自定义字体。} -% \changes{v1.25p}{2021/05/04}{修复使用 \pkg{xeCJK} 与 \pkg{fontspec} 宏包的字体设置命令在 \hologo{LuaLaTeX} 下失效的问题。} +% \changes{v1.25q}{2021/05/04}{修复使用 \pkg{xeCJK} 与 \pkg{fontspec} 宏包的字体设置命令在 \hologo{LuaLaTeX} 下失效的问题。} % \end{function} % % \begin{function}[rEXP,added = 2021-01-05,updated = 2021-01-13]{paper} @@ -140,11 +157,10 @@ % \begin{syntax} % class = <(book)|article> % \end{syntax} -% 设置文类风格,默认为 \opt{book} 文档类。选用 \opt{article} 会变为 \opt{oneside} 单面排版,同时使文档编号、结构等与标准 \cls{article} 文档类的特性相似,可用于短篇幅的文章,不需要再使用 \tn{chapter} 命令,此时设置双栏目录的 \opt{style/multoc} 选项、小节 \ref{subsec:document command} 中打印目录命令的 \opt{multoc} 及 \opt{book} 选项均会失效,会以 \opt{section} 标题级别输出目录。 +% 设置文类风格,默认为 \opt{book} 文档类。选用 \opt{article} 会变为 \opt{oneside} 单面排版,同时使文档编号、结构等与标准 \cls{article} 文档类的特性相似,可用于短篇幅的文章,不需要再使用 \tn{chapter} 命令,此时设置双栏目录的 \opt{style/multoc} 选项、小节 \ref{subsec:document command} 中打印目录命令的 \opt{multoc} 及 \opt{book} 选项均会失效,会以 \opt{section} 标题级别输出目录。如果使用 \cls{ctexart} 配合 \pkg{easybase} 宏包,则 \opt{book} 宏包选项会失效。 % \changes{v1.23}{2021/03/16}{增加 article 文章模式,可用于短篇幅的文章。} % \end{function} % -% \clearpage % \subsection{文档命令} % \label{subsec:document command} % \subsubsection{文区命令} @@ -160,7 +176,7 @@ % \end{function} % % \subsubsection{目录命令} -% \begin{function}[added = 2021-02-20,updated = 2021-05-05]{\tableofcontents,\listoffigures,\listoftables,\listoflistings} +% \begin{function}[added = 2021-02-20,updated = 2021-06-02]{\tableofcontents,\listoffigures,\listoftables,\listoflistings} % \begin{syntax} % \tn{tableofcontents+}\oarg{键值列表}\parg{附加代码} % \tn{listoffigures*+}\oarg{键值列表} @@ -168,22 +184,24 @@ % \tn{listoflistings*+}\oarg{键值列表} % \end{syntax} % \tn{listoffigures} 命令输出图片目录,\tn{listoftables} 输出表格目录,\tn{listoflistings} 输出代码目录。带有星号的目录命令不将标题添加进主文档目录,带有+号的目录命令可以使当前标题编号。\tn{tableofcontents+} 与其它命令不同是用于输出双语目录,需要与双语目录标题命令 \tn{bichapter} 等或设置图片、表格和代码等英文目录的标题配合使用,附加代码是中文与英文目录之间的代码,可以插入文本和换页命令等。目录的键值列表选项如下 -% \changes{v1.25p}{2021/05/05}{命令 \tn{tableofcontents} 可以输出双语目录。} +% \changes{v1.25q}{2021/05/05}{命令 \tn{tableofcontents} 可以输出双语目录。} % \end{function} % -% \begin{function}{multoc,title,format,aftertitle,pagestyle,book,article} +% \begin{function}{multoc,columns,title,format,aftertitle,pagestyle,book,article} % \begin{syntax} % multoc = <true|(false)> +% columns = <目录栏数|(2)> % title = \{<中文目录标题>,<英文目录标题>\} % format = <目录标题格式> % aftertitle = <目录标题后的代码> % pagestyle = <标题页的页面格式> % \end{syntax} -% \opt{multoc} 与 \opt{style/multoc} 选项具有相同的效果,但是具有优先性且可单独设置不同目录是否双栏排版。\opt{title} 选项用于更改目录的标题,标题之间用一个半角逗号分开,也可以只有一部分,表示中文目录的标题。当设置了英文目录标题时,英文目录标题将会自动加入主文档目录,与 \tn{tableofcontents+} 配合输出。 +% \opt{multoc} 与 \opt{style/multoc} 选项具有相同的效果,但是具有优先性且可单独设置不同目录是否多栏排版,默认为双栏,可使用 \opt{columns} 更改。\opt{title} 选项用于更改目录的标题,标题之间用一个半角逗号分开,也可以只有一部分,表示中文目录的标题。当设置了英文目录标题时,英文目录标题将会自动加入主文档目录,与 \tn{tableofcontents+} 配合输出。 % % 在书籍模式且 \opt{book} 选项开启或者文章模式的情况下,\opt{format} 用于设置目录标题的格式,\opt{aftertitle} 选项的代码将被插入到目录标题内容之后,\opt{pagestyle} 是目录标题所在页的页面格式,除此之外还支持 \opt{ctexset/chapter} 或 \opt{ctexset/section} 所有的章节标题样式选项。\opt{book} 选项使目录标题按照 chapter 级别输出,\opt{article} 选项使目录标题按照 section 级别输出,默认为 chapter 级别。 % \changes{v1.23}{2021/03/15}{为几个目录增加键值列表的选项,可设置标题输出级别以及是否加入主目录。} % \changes{v1.24}{2021/04/04}{目录命令的可选参数增加标题键值。} +% \changes{v1.25q}{2021/06/02}{目录可设置多栏,并在 article 模式仍然生效。} % \end{function} % % \subsubsection{标题命令} @@ -199,7 +217,7 @@ % 双语目录的标题命令目前设置了常用的三个级别,它们将中文标题正常输出,并使中英文标题加入双语目录,这个功能是为国内一些大学的学位论文模板的要求设计,在一般情况和英文模式下不需要使用。 % % 它们的星号变体命令使文中标题不编号,但是仍然加入双语目录,若英文标题参数空置那么仅加入中文目录而不加入英文目录,这一特点与 \tn{chapter*} 等命令的行为不太一样,在一些情况下会用到。可选参数是目录中的中文标题,默认与中文标题一致,正文标题过长时可用它设置在目录中显示的标题。双语目录的格式是一致的,共享使用 \tn{tocset} 的设置,英文目录的章级别标题名及编号的修改方式如下 -% \changes{v1.25p}{2021/05/05}{增加与双语目录配合的标题命令。} +% \changes{v1.25q}{2021/05/05}{增加与双语目录配合的标题命令。} % \end{function} % % \begin{function}{biname,binmuber} @@ -272,7 +290,7 @@ % \changes{v1.10}{2021/01/08}{可以自定义主题颜色。} % \end{function} % \item[color-all] 统一设置主题的各部分颜色,参数是6个十六进制数字组成的 HTML 颜色代码,任意颜色的代码可以在常见的图片处理工具拾色器中查看。 -% \item[multoc] 开启双栏目录,可与 \opt{onecolumn} 和 \opt{twocolumn} 选项配合出单栏正文、单栏目录,双栏正文、单栏目录,单栏正文、双栏目录和双栏正文、双栏目录四种方式。 +% \item[multoc] 开启多栏目录,与小节 \ref{subsec:document command} 中目录命令的同名选项有相同效果。 % \item[withpart] 使章跟随每一部分编号,默认不跟随。 % \item[footwith] 使脚注跟随编号的计数器,默认跟随章,当开启新的一章时脚注编号从1开始。 % \item[rulewidth] 调整页眉、定理盒子以及代码框线条的粗细。 @@ -299,7 +317,7 @@ % \changes{v1.10}{2021/01/08}{修复了 \opt{linktopage} 选项关闭时目录中标题编号无超链接的问题。} % \changes{v1.23}{2021/03/19}{修复在 \pkg{ctex} v2.5.6 更新后 \cls{easybook} 与 \pkg{hyperref} 冲突问题。} % \changes{v1.24}{2021/04/05}{增加 \pkg{hyperref} 超链接选项完整的支持。} -% \changes{v1.25p}{2021/05/06}{模块名 \opt{link} 改为 \opt{refset},\opt{link} 作为兼容性保留。} +% \changes{v1.25q}{2021/05/06}{模块名 \opt{link} 改为 \opt{refset},\opt{link} 作为兼容性保留。} % \end{function} % % \begin{optdesc} @@ -356,7 +374,7 @@ % \ding{229} 以上选项路径为 \opt{subfont/...} % \changes{v1.10}{2021/01/08}{加入自定义非正文字体选项。} % \changes{v1.23}{2021/02/08}{修复使用 \tn{zihao} 命令设置字体失效的问题。} -% \changes{v1.25p}{2021/05/31}{其它字体模块名由 \opt{elsefont} 改为 \opt{subfont},并增加数学字体的选项 \opt{subfont/math}。} +% \changes{v1.25q}{2021/05/31}{其它字体模块名由 \opt{elsefont} 改为 \opt{subfont},并增加数学字体的选项 \opt{subfont/math}。} % \end{function} % % \begin{optdesc} @@ -381,7 +399,7 @@ % \changes{v1.21}{2021/01/11}{增加 \opt{bibset} 选项,可以使用 \hologo{BibTeX} 或 \hologo{biber} 编译参考文献。} % \changes{v1.23}{2021/02/23}{使用 \opt{bibset} 选项时可设置标注风格。} % \changes{v1.24}{2021/04/09}{可以不载入参考文献包手动配置参考文献格式。} -% \changes{v1.25p}{2021/05/12}{取消 \opt{bib-loadpkg} 选项,由是否设置参考文献数据库来决定载入宏包。} +% \changes{v1.25q}{2021/05/12}{取消 \opt{bib-loadpkg} 选项,由是否设置参考文献数据库来决定载入宏包。} % \end{function} % % \begin{optdesc} @@ -490,8 +508,10 @@ % % \subsection{页面尺寸} % \label{subsec:page margins} -% \begin{function}[EXP,added = 2021-01-13,updated = 2021-05-11]{left,top,hmargin,textwidth,includehead} +% \begin{function}[EXP,added = 2021-01-13,updated = 2021-06-02]{headruleskip,footruleskip,left,top,hmargin,textwidth,includehead} % \begin{syntax} +% headruleskip = <页眉线间距> +% footruleskip = <页脚线间距> % left = <页面左边距> % top = <页面上边距> % hmargin = \marg{左边距,右边距} @@ -499,17 +519,18 @@ % includehead = <true|(false)> % \end{syntax} % \ding{229} 以上选项路径为 \opt{geoset/...} \\ -% 预置的页面尺寸与 \cls{Word} 的默认值接近,\opt{geoset} 会将选项交给 \pkg{geometry} 宏包接口命令 \tn{geometry} 处理,并且选项的键值列表与之相同,上面的选项仅是一小部分,支持的参数可查阅宏包帮助文档。当在此设置页面大小时,会覆盖 \opt{paper} 选项的设置。 +% 预置的页面尺寸与 \cls{Word} 的默认值接近,\opt{geoset} 会将前两个之外的选项交给 \pkg{geometry} 宏包接口命令 \tn{geometry} 处理,并且选项的键值列表与之相同,上面的选项仅是一小部分,支持的参数可查阅宏包帮助文档。当在此设置页面大小时,会覆盖 \opt{paper} 选项的设置。 % \changes{v1.21}{2021/01/13}{增加配置页面尺寸的选项。} % \end{function} % % \begin{ctexexam} % \geoset % { -% top = 2.5cm, -% bottom = 2.5cm, -% left = 3.2cm, -% right = 3.2cm, +% headruleskip = 3pt, +% top = 2.5cm, +% bottom = 2.5cm, +% left = 3.2cm, +% right = 3.2cm, % ignoreall % } % \end{ctexexam} @@ -584,7 +605,7 @@ % 上面几个选项用于设置脚注格式,\opt{fnparskip} 和 \opt{fnparindent} 选项仅在 \opt{fnhang = true} 时有效。\opt{fnhang} 用于将脚注设置为悬挂缩进的格式,\opt{fnmark-pos} 选项设置脚注编号的位置,正常文本或是上标形式。\opt{fnmark-num} 选项设置脚注编号的格式,默认为原生样式 \opt{plain},还可以改为 \opt{pifont} 的各个版本,从左往右依次为普通版、阴文衬线版、阳文无衬线版和阴文无衬线版,缺点是它们的编号仅包括1-10。 % % \opt{fnmark-form} 是脚注标记的格式,在此设置字体命令会覆盖 \opt{subfont/footnote} 的设置,最后一个格式命令可以带有一个参数,这个参数接受脚注编号,一般配合 \opt{fnmark-num = plain} 使用。\opt{afterfnmark} 是脚注标记后的代码,一般用于设置标记与文本间的距离。 -% \changes{v1.25p}{2021/05/12}{增加脚注样式设置选项。} +% \changes{v1.25q}{2021/05/12}{增加脚注样式设置选项。} % \end{function} % % \subsection{目录样式} @@ -603,7 +624,7 @@ % \opt{format} 是目录中标题的格式,可以设置字体和加入垂直间距等,垂直间距最好使用无间距重合的 \tn{addvspace} 命令,带有加号的 \opt{format+} 选项用于在已有的格式命令后附加内容。\opt{indent} 是目录中标题在页面左侧的缩进距离,应该有长度单位。\opt{rule} 选项中一般应当使用 \tn{tocrule} 命令,将会在接下来介绍。\opt{numsep} 是有编号的标题在目录中编号与标题的间距。 % \changes{v1.21}{2021/01/13}{增加配置目录样式的选项。} % \changes{v1.24}{2021/04/20}{增加目录中编号与标题的间距选项 \opt{numsep}。} -% \changes{v1.25p}{2021/05/14}{可以分别设置图片、表格和代码目录的格式。} +% \changes{v1.25q}{2021/05/14}{可以分别设置图片、表格和代码目录的格式。} % \end{function} % % \begin{function}[added = 2021-01-13,updated = 2021-04-20]{\tocrule,\EbNumberLine} @@ -688,7 +709,7 @@ % \tn{end}\marg{环境名} % \end{syntax} % \pkg{tabularray} 是一个较新的宏包,不仅提供了 \pkg{tabularx}、\pkg{multirow}、和 \pkg{booktabs} 宏包的功能,并且不依赖其它宏包与它们同时使用不会产生冲突,还实现了用简便的键值列表方式设置表格样式。目前除了表头斜线以及跨页功能存在不足,其它方面已满足对表格绝大多数格式的需求,具体用法可见宏包的说明文档。 -% \changes{v1.25p}{2021/05/17}{使用功能更便捷齐全的 \pkg{tabularray} 宏包设置表格样式。} +% \changes{v1.25q}{2021/05/17}{使用功能更便捷齐全的 \pkg{tabularray} 宏包设置表格样式。} % \end{function} % % \subsection{列表} @@ -852,7 +873,7 @@ % \tn{qtyrange}\oarg{键值列表}\marg{数字1}\marg{数字2}\marg{单位} % \end{syntax} % \pkg{siunitx} 宏包的 \tn{num} 命令可以输出以科学计数法表示的数值,单位格式化命令 \tn{unit} 包含文字项目(例如字母或数字)时,使用 . 和 \~{} 放置在单元乘积中间,并使用 \_ 和 \^{} 正确放置指定的下标和上标。格式化方法可在数学和文本模式下使用。而 \tn{qty} 命令可用来输出带有单位的量,\tn{qtyrange} 可以输出带有范围和单位的量。 -% \changes{v1.25p}{2021/05/18}{\pkg{siunitx} 宏包 v3.0.0 更新后用法改变,修改相关配置选项。} +% \changes{v1.25q}{2021/05/18}{\pkg{siunitx} 宏包 v3.0.0 更新后用法改变,修改相关配置选项。} % \end{function} % % \begin{ctexexam} @@ -969,6 +990,7 @@ % \item[ulem] 提供可断行多样式的下划线命令。 % \item[geometry] 灵活完整的页面尺寸设置。 % \item[pdfpages] 在 \LaTeX 中插入 pdf 文档。 +% \item[multicol] 混合单栏和多栏排版。 % \item[graphicx] 增强了对图形插入的支持。 % \item[fancyhdr] 广泛控制页面的页眉和页脚。 % \item[titletoc] 设置目录中的标题格式。 @@ -988,42 +1010,8 @@ % \StopEventually{} %<*class> \NeedsTeXFormat{LaTeX2e}[2020/10/01] -\RequirePackage{l3keys2e,etoolbox} -\ProvidesExplClass{easybook}{2021/05/31}{1.25p}{beta} - -\cs_generate_variant:Nn \eb_ctex_define:nn { nx } -\cs_generate_variant:Nn \int_to_arabic:n { v } -\cs_generate_variant:Nn \dim_add:Nn { NV } -\cs_generate_variant:Nn \eb_put_hyperref:n { x } -\cs_generate_variant:Nn \seq_set_from_clist:Nn { No } -\cs_new_protected:Npn \eb_ctex_define:nn #1 - { \keys_define:nn { ctex/#1 } } -\cs_new_protected:Npn \eb_put_ctexbook:n #1 - { \PassOptionsToClass{#1}{ctexbook} } -\cs_new_protected:Npn \eb_patch_cmd:Nnn #1#2#3 - { - \ctex_patch_cmd_once:NnnnTF #1 { } {#2} {#3} - { } { \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \eb_preto_cmd:Nn #1#2 - { - \ctex_preto_cmd:NnnTF #1 { } {#2} - { } { \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \eb_appto_cmd:Nn #1#2 - { - \ctex_appto_cmd:NnnTF #1 { } {#2} - { } { \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \eb_at_begin_environment:nn #1#2 - { - \seq_set_from_clist:No \l__eb_env_hook_name_seq {#1} - \seq_map_inline:Nn \l__eb_env_hook_name_seq - { \AtBeginEnvironment{##1}{#2} } - } -\cs_new_protected:Npn \eb_at_end_preamble:n - { \ctex_gadd_ltxhook:nn { env/document/before } } -\cs_gset_eq:NN \PackageWarning \use_none:nn +\RequirePackage{l3keys2e} +\ProvidesExplClass{easybook}{2021/06/02}{1.25q}{beta} \bool_set_false:N \l__eb_compile_draft_bool \bool_set_false:N \l__eb_title_newline_bool @@ -1032,6 +1020,8 @@ \bool_set_true:N \l__eb_class_book_bool \tl_new:N \g__eb_config_tl \clist_new:N \g__eb_options_clist +\cs_new_protected:Npn \eb_put_ctexbook:n #1 + { \PassOptionsToClass{#1}{ctexbook} } \keys_define:nn { easybook } { @@ -1087,6 +1077,249 @@ } \ProcessKeysOptions{easybook} +\eb_put_ctexbook:n { \g__eb_options_clist } +\LoadClass[UTF8]{ctexbook} + +\RequirePackage{easybase} +\ctex_at_end:n + { + \tl_if_empty:NF \g__eb_config_tl + { \file_input:n { \g__eb_config_tl } } + } + +\sys_if_engine_xetex:TF + { + \cs_new_eq:NN \eb_set_family:nnn \xeCJK_set_family:nnn + \cs_new_eq:NN \eb_switch_family:n \xeCJK_switch_family:n + } + { + \cs_new_eq:NN \eb_set_family:nnn \ctex_ltj_set_family:nnn + \cs_new_eq:NN \eb_switch_family:n \ctex_ltj_switch_family:n + } +\cs_new_protected:Npn \eb_font_double_engine_set:n #1 + { + \exp_args:Nc \RenewDocumentCommand {set#1font}{O{}mO{}} + {\use:c { eb_set#1font:nn } {##2} {##1,##3}} + } +\seq_const_from_clist:Nn \c__eb_font_reset_family_seq + { main,sans,mono,CJKmain,CJKsans,CJKmono } +\seq_map_inline:Nn \c__eb_font_reset_family_seq + { \eb_font_double_engine_set:n {#1} } + +\cs_new_protected:Npn \eb_setmainfont:nn #1#2 + { \__fontspec_main_setmainfont:nn {#2} {#1} } +\cs_new_protected:Npn \eb_setsansfont:nn #1#2 + { \__fontspec_main_setsansfont:nn {#2} {#1} } +\cs_new_protected:Npn \eb_setmonofont:nn #1#2 + { \__fontspec_main_setmonofont:nn {#2} {#1} } +\cs_new_protected:Npn \eb_setCJKmainfont:nn #1#2 + { \eb_set_family:nnn { \CJKrmdefault } {#2} {#1} } +\cs_new_protected:Npn \eb_setCJKsansfont:nn #1#2 + { \eb_set_family:nnn { \CJKsfdefault } {#2} {#1} } +\cs_new_protected:Npn \eb_setCJKmonofont:nn #1#2 + { \eb_set_family:nnn { \CJKttdefault } {#2} {#1} } +\cs_new_protected:Npn \eb_set_zhfont_songti:nn #1#2 + { \eb_set_family:nnn { songti } {#2} {#1} } +\cs_new_protected:Npn \eb_set_zhfont_heiti:nn #1#2 + { \eb_set_family:nnn { heiti } {#2} {#1} } +\cs_new_protected:Npn \eb_set_zhfont_kaishu:nn #1#2 + { \eb_set_family:nnn { kaishu } {#2} {#1} } +\cs_new_protected:Npn \eb_set_zhfont_fangsong:nn #1#2 + { \eb_set_family:nnn { fangsong } {#2} {#1} } + +\tl_const:Nn \eb_option_zhfont_tl + { UprightFont = *,AutoFakeBold = 1.5,ItalicFont = * } +\cs_new_protected:Npx \eb_setCJKmainfont:n #1 + { \eb_setCJKmainfont:nn {#1} { \eb_option_zhfont_tl } } +\cs_new_protected:Npx \eb_setCJKsansfont:n #1 + { \eb_setCJKsansfont:nn {#1} { \eb_option_zhfont_tl } } +\cs_new_protected:Npx \eb_setCJKmonofont:n #1 + { \eb_setCJKmonofont:nn {#1} { \eb_option_zhfont_tl } } +\cs_new_protected:Npx \eb_set_zhfont_songti:n #1 + { \eb_set_zhfont_songti:nn {#1} { \eb_option_zhfont_tl } } +\cs_new_protected:Npx \eb_set_zhfont_heiti:n #1 + { \eb_set_zhfont_heiti:nn {#1} { \eb_option_zhfont_tl } } +\cs_new_protected:Npx \eb_set_zhfont_kaishu:n #1 + { \eb_set_zhfont_kaishu:nn {#1} { \eb_option_zhfont_tl } } +\cs_new_protected:Npx \eb_set_zhfont_fangsong:n #1 + { \eb_set_zhfont_fangsong:nn {#1} { \eb_option_zhfont_tl } } + +\bool_if:NT \l__eb_font_noto_bool + { + \eb_setmainfont:nn { NotoSerif } + { + Extension = .ttf, + UprightFont = *-Regular, + BoldFont = *-Bold, + ItalicFont = *-Italic + } + \eb_setsansfont:nn { NotoSans } + { + Extension = .ttf, + UprightFont = *-Regular, + BoldFont = *-Bold, + ItalicFont = *-Italic + } + \eb_setmonofont:nn { NotoSansMono } + { + Extension = .ttf, + UprightFont = *-Regular, + BoldFont = *-Bold + } + \eb_setCJKmainfont:nn { FZShuSong-Z01S } + { + UprightFont = *, + BoldFont = FZHei-B01S, + ItalicFont = FZKai-Z03S + } + \eb_setCJKsansfont:n { FZHei-B01S } + \eb_setCJKmonofont:n { FZFangSong-Z02S } + \eb_set_zhfont_songti:n { FZShuSong-Z01S } + \eb_set_zhfont_heiti:n { FZHei-B01S } + \eb_set_zhfont_kaishu:n { FZKai-Z03S } + \eb_set_zhfont_fangsong:n { FZFangSong-Z02S } + \cs_new_protected:Npn \songti { \eb_switch_family:n { songti } } + \cs_new_protected:Npn \heiti { \eb_switch_family:n { heiti } } + \cs_new_protected:Npn \kaishu { \eb_switch_family:n { kaishu } } + \cs_new_protected:Npn \fangsong { \eb_switch_family:n { fangsong } } + } + +\ctex_set:n + { + secnumdepth = 3, + tocdepth = \bool_if:NTF \l__eb_class_book_bool { 1 } { 2 }, + part = + { + pagestyle = empty, + tocline = \EbNumberLine{#1}#2, + format = \color{ctex@frame}\sffamily\Huge, + aftername = + { + \bool_if:NTF \l__eb_title_newline_bool + { \par\nobreak } { \hspace{\ccwd} } + } + }, + chapter = + { + % pagestyle = fancy, + format = + { + \color{ctex@frame}\sffamily\LARGE + \bool_if:NF \l__eb_title_newline_bool { \centering } + }, + aftername = + { + \bool_if:NTF \l__eb_title_newline_bool + { \par\nobreak\vskip 1.5pc } { \hspace{\ccwd} } + }, + beforeskip = -1.5ex, + afterskip = 3ex, + lotskip = 0.8pc, + lofskip = 0.8pc + }, + section = + { + hang = true, + format = \color{ctex@frame}\sffamily\Large, + aftername = \hspace{0.5\ccwd}, + beforeskip = 1.5ex plus .2ex minus .1ex, + afterskip = 1.5ex plus .2ex minus .1ex + }, + subsection = + { + hang = true, + format = \color{ctex@frame}\sffamily\large, + aftername = \hspace{0.5\ccwd}, + beforeskip = 1.3ex plus .2ex minus .1ex, + afterskip = 1.3ex plus .2ex minus .1ex + }, + subsubsection = + { + hang = true, + format = \color{ctex@frame}\sffamily, + aftername = \hspace{0.5\ccwd}, + beforeskip = \parskip, + afterskip = \parskip + } + } + +\bool_if:NF \l__eb_title_newline_bool + { + \ctex_set:n + { + part/hang = true, + chapter/hang = true + } + } +%</class> +%<*package> +\NeedsTeXFormat{LaTeX2e}[2020/10/01] +\RequirePackage{etoolbox} +\ProvidesExplPackage{easybase}{2021/06/02}{1.25q}{beta} + +\cs_generate_variant:Nn \eb_ctex_define:nn { nx } +\cs_generate_variant:Nn \int_to_arabic:n { v } +\cs_generate_variant:Nn \dim_add:Nn { NV } +\cs_generate_variant:Nn \eb_put_hyperref:n { x } +\cs_generate_variant:Nn \seq_set_from_clist:Nn { No } +\cs_generate_variant:Nn \int_compare:nNnT { oNnT } +\cs_new_protected:Npn \eb_ctex_define:nn #1 + { \keys_define:nn { ctex/#1 } } +\cs_new_protected:Npn \eb_patch_cmd:Nnn #1#2#3 + { + \ctex_patch_cmd_once:NnnnTF #1 { } {#2} {#3} + { } { \ctex_patch_failure:N #1 } + } +\cs_new_protected:Npn \eb_preto_cmd:Nn #1#2 + { + \ctex_preto_cmd:NnnTF #1 { } {#2} + { } { \ctex_patch_failure:N #1 } + } +\cs_new_protected:Npn \eb_appto_cmd:Nn #1#2 + { + \ctex_appto_cmd:NnnTF #1 { } {#2} + { } { \ctex_patch_failure:N #1 } + } +\cs_new_protected:Npn \eb_at_begin_environment:nn #1#2 + { + \seq_set_from_clist:No \l__eb_env_hook_name_seq {#1} + \seq_map_inline:Nn \l__eb_env_hook_name_seq + { \AtBeginEnvironment{##1}{#2} } + } +\NewDocumentCommand{\eb@package@load}{O{}m} + { + \seq_set_from_clist:No \l__eb_package_name_seq {#2} + \int_compare:oNnT + { \seq_count:N \l__eb_package_name_seq } = { 1 } + { \PassOptionsToPackage{#1}{#2} } + \seq_map_inline:Nn \l__eb_package_name_seq + { \@ifpackageloaded{##1}{}{\RequirePackage{##1}} } + } +\cs_new_protected:Npn \eb_at_end_preamble:n + { \ctex_gadd_ltxhook:nn { env/document/before } } +\cs_gset_eq:NN \PackageWarning \use_none:nn + +\bool_if_exist:NF \l__eb_class_book_bool + { \bool_set_true:N \l__eb_class_book_bool } +\bool_if_exist:NF \l__eb_page_twoside_bool + { \bool_set_true:N \l__eb_page_twoside_bool } +\bool_if_exist:NF \l__eb_compile_draft_bool + { \bool_set_false:N \l__eb_compile_draft_bool } + +\keys_define:nn { easybase } + { + draft .code:n = + { \bool_set_true:N \l__eb_compile_draft_bool }, + + class .choice:, + class .value_required:n = true, + class/book .code:n = { }, + class/article .code:n = + { + \bool_set_false:N \l__eb_class_book_bool + \bool_set_false:N \l__eb_page_twoside_bool + } + } \clist_map_inline:nn { @@ -1098,13 +1331,12 @@ { shortlabels,inline } { enumitem }, { many } { tcolorbox }, { xindy } { imakeidx }, - { CJKmath = true } { xeCJK }, + { CJKmath } { xeCJK }, { no-math } { fontspec }, { upint } { newtxmath } } { \PassOptionsToPackage #1 } -\eb_put_ctexbook:n { \g__eb_options_clist } -\LoadClass[UTF8]{ctexbook} +\ProcessKeysOptions{easybase} \bool_new:N \l__eb_multoc_bool \bool_new:N \l__eb_uppercase_bool @@ -1137,7 +1369,7 @@ withpart .bool_set:N = \l__eb_chap_withpart_bool, withpart .default:n = true, withpart .initial:n = false, - rulewidth .dim_set:N = \l__eb_rule_width_dim, + rulewidth .dim_set:N = \eb@rule@width@dim, rulewidth .initial:n = 0.75pt, uppercase .bool_set:N = \l__eb_uppercase_bool, uppercase .default:n = true, @@ -1167,31 +1399,25 @@ number-sep .initial:n = { . } } -\RequirePackage +\eb@package@load { xcolor, footmisc,setspace, amsmath,amsthm,thmtools, chemformula,siunitx,ulem,pifont, geometry,marginnote,nccfoots, - pdfpages,graphicx, + pdfpages,graphicx,multicol, fancyhdr,titletoc,caption, tabularray, enumitem, listings } -\ctex_at_end:n - { - \tl_if_empty:NF \g__eb_config_tl - { \file_input:n { \g__eb_config_tl } } - } - \cs_new_protected:Npn \eb_package_later_bool:nn #1#2 { \@ifpackagelater{#1}{#2} - {}{\msg_warning:nnn { easybook } { package-old } {#1}} + {}{\msg_warning:nnn { easybase } { package-old } {#1}} } -\msg_new:nnn { easybook } { package-old } +\msg_new:nnn { easybase } { package-old } { Package~#1~has~been~out~of~date. \\ Some~problems~or~errors~may~occur \\ @@ -1210,109 +1436,12 @@ } { \eb_package_later_bool:nn #1 } -\sys_if_engine_xetex:TF - { - \cs_new_eq:NN \eb_set_family:nnn \xeCJK_set_family:nnn - \cs_new_eq:NN \eb_switch_family:n \xeCJK_switch_family:n - } - { - \cs_new_eq:NN \eb_set_family:nnn \ctex_ltj_set_family:nnn - \cs_new_eq:NN \eb_switch_family:n \ctex_ltj_switch_family:n - } -\cs_new_protected:Npn \eb_font_double_engine_set:n #1 - { - \exp_args:Nc \RenewDocumentCommand {set#1font}{O{}mO{}} - {\use:c { eb_set#1font:nn } {##2} {##1,##3}} - } -\seq_const_from_clist:Nn \c__eb_font_reset_family_seq - { main,sans,mono,CJKmain,CJKsans,CJKmono } -\seq_map_inline:Nn \c__eb_font_reset_family_seq - { \eb_font_double_engine_set:n {#1} } - -\cs_new_protected:Npn \eb_setmainfont:nn #1#2 - { \__fontspec_main_setmainfont:nn {#2} {#1} } -\cs_new_protected:Npn \eb_setsansfont:nn #1#2 - { \__fontspec_main_setsansfont:nn {#2} {#1} } -\cs_new_protected:Npn \eb_setmonofont:nn #1#2 - { \__fontspec_main_setmonofont:nn {#2} {#1} } -\cs_new_protected:Npn \eb_setCJKmainfont:nn #1#2 - { \eb_set_family:nnn { \CJKrmdefault } {#2} {#1} } -\cs_new_protected:Npn \eb_setCJKsansfont:nn #1#2 - { \eb_set_family:nnn { \CJKsfdefault } {#2} {#1} } -\cs_new_protected:Npn \eb_setCJKmonofont:nn #1#2 - { \eb_set_family:nnn { \CJKttdefault } {#2} {#1} } -\cs_new_protected:Npn \eb_set_zhfont_songti:nn #1#2 - { \eb_set_family:nnn { songti } {#2} {#1} } -\cs_new_protected:Npn \eb_set_zhfont_heiti:nn #1#2 - { \eb_set_family:nnn { heiti } {#2} {#1} } -\cs_new_protected:Npn \eb_set_zhfont_kaishu:nn #1#2 - { \eb_set_family:nnn { kaishu } {#2} {#1} } -\cs_new_protected:Npn \eb_set_zhfont_fangsong:nn #1#2 - { \eb_set_family:nnn { fangsong } {#2} {#1} } - -\tl_const:Nn \eb_option_zhfont_tl - { UprightFont = *,AutoFakeBold = 1.5,ItalicFont = * } -\cs_new_protected:Npx \eb_setCJKmainfont:n #1 - { \eb_setCJKmainfont:nn {#1} { \eb_option_zhfont_tl } } -\cs_new_protected:Npx \eb_setCJKsansfont:n #1 - { \eb_setCJKsansfont:nn {#1} { \eb_option_zhfont_tl } } -\cs_new_protected:Npx \eb_setCJKmonofont:n #1 - { \eb_setCJKmonofont:nn {#1} { \eb_option_zhfont_tl } } -\cs_new_protected:Npx \eb_set_zhfont_songti:n #1 - { \eb_set_zhfont_songti:nn {#1} { \eb_option_zhfont_tl } } -\cs_new_protected:Npx \eb_set_zhfont_heiti:n #1 - { \eb_set_zhfont_heiti:nn {#1} { \eb_option_zhfont_tl } } -\cs_new_protected:Npx \eb_set_zhfont_kaishu:n #1 - { \eb_set_zhfont_kaishu:nn {#1} { \eb_option_zhfont_tl } } -\cs_new_protected:Npx \eb_set_zhfont_fangsong:n #1 - { \eb_set_zhfont_fangsong:nn {#1} { \eb_option_zhfont_tl } } - -\bool_if:NT \l__eb_font_noto_bool - { - \eb_setmainfont:nn { NotoSerif } - { - Extension = .ttf, - UprightFont = *-Regular, - BoldFont = *-Bold, - ItalicFont = *-Italic - } - \eb_setsansfont:nn { NotoSans } - { - Extension = .ttf, - UprightFont = *-Regular, - BoldFont = *-Bold, - ItalicFont = *-Italic - } - \eb_setmonofont:nn { NotoSansMono } - { - Extension = .ttf, - UprightFont = *-Regular, - BoldFont = *-Bold - } - \eb_setCJKmainfont:nn { FZShuSong-Z01S } - { - UprightFont = *, - BoldFont = FZHei-B01S, - ItalicFont = FZKai-Z03S - } - \eb_setCJKsansfont:n { FZHei-B01S } - \eb_setCJKmonofont:n { FZFangSong-Z02S } - \eb_set_zhfont_songti:n { FZShuSong-Z01S } - \eb_set_zhfont_heiti:n { FZHei-B01S } - \eb_set_zhfont_kaishu:n { FZKai-Z03S } - \eb_set_zhfont_fangsong:n { FZFangSong-Z02S } - \cs_new_protected:Npn \songti { \eb_switch_family:n { songti } } - \cs_new_protected:Npn \heiti { \eb_switch_family:n { heiti } } - \cs_new_protected:Npn \kaishu { \eb_switch_family:n { kaishu } } - \cs_new_protected:Npn \fangsong { \eb_switch_family:n { fangsong } } - } - \includepdfset{fitpaper = true} \geometry { vmargin = 2.54cm, hmargin = 3.17cm, - columnsep = 2\ccwd, + columnsep = \ccwd, headheight = 2.04cm, headsep = 0.5cm, footskip = 0.79cm, @@ -1323,6 +1452,9 @@ \clist_new:N \g__eb_geometry_clist \eb_ctex_define:nn { geoset } { + headruleskip .tl_set:N = \headruleskip, + headruleskip .initial:n = 1.5pt, + footruleskip .tl_set:N = \footruleskip, unknown .code:n = { \clist_gput_right:Nx \g__eb_geometry_clist @@ -1342,13 +1474,13 @@ { \hbox:n { }\thispagestyle{#1}\clearpage } } } -\RenewDocumentCommand{\frontmatter}{sO{Roman}} +\DeclareDocumentCommand{\frontmatter}{sO{Roman}} { \IfBooleanTF{#1}{\clearpage}{\cleardoublepage} \boolfalse{@mainmatter} \pagenumbering{#2} } -\RenewDocumentCommand{\mainmatter}{s} +\DeclareDocumentCommand{\mainmatter}{s} { \IfBooleanTF{#1}{\clearpage}{\cleardoublepage} \booltrue{@mainmatter} @@ -1429,8 +1561,8 @@ headrule .initial:n = { \group_begin: - \color{ctex@frame}\vspace*{1.5pt} - \hrule width \textwidth height \l__eb_rule_width_dim + \color{ctex@frame} + \hrule\@width\textwidth\@height\eb@rule@width@dim \group_end: }, footrule .tl_gset:N = \footrule, @@ -1440,7 +1572,7 @@ { \group_begin: \color{ctex@frame} - \hrule width 0.35\columnwidth height \l__eb_rule_width_dim + \hrule\@width 0.35\columnwidth\@height\eb@rule@width@dim \vspace*{2.6pt} \group_end: }, @@ -1674,7 +1806,7 @@ figure/#1 = ##1, table/#1 = ##1, lstlisting/#1 = ##1 - } + } } } @@ -1686,6 +1818,12 @@ \hspace{\use:c { eb@toc@#1@numsep }} }{} } +\cs_if_exist:NF \chapter + { + \newcounter{chapter} + \bool_set_false:N \l__eb_class_book_bool + \ctex_define:n { chapter/tocline .code:n = { } } + } \newbool{eb@titletoc@hang@fix} \eb_ctex_define:nn { tocset } { @@ -1863,29 +2001,32 @@ } } } - -\eb_appto_cmd:Nn \@chapter +\cs_if_exist:NT \chapter { - \skip_if_eq:nnF { \l__eb_toc_lolskip_skip } { \c_zero_skip } + \eb_appto_cmd:Nn \@chapter { - \addtocontents{lol} - {\protect\addvspace{\skip_use:N \l__eb_toc_lolskip_skip}} + \skip_if_eq:nnF { \l__eb_toc_lolskip_skip } { \c_zero_skip } + { + \addtocontents{lol} + {\protect\addvspace{\skip_use:N \l__eb_toc_lolskip_skip}} + } + \bool_if:NF \l__eb_class_book_bool + { \msg_error:nn { easybase } { no-chapter } } + } + \eb_appto_cmd:Nn \@schapter + { + \bool_if:NF \l__eb_class_book_bool + { \msg_error:nn { easybase } { no-chapter } } } - \bool_if:NF \l__eb_class_book_bool - { \msg_error:nn { easybook } { no-chapter } } - } -\eb_appto_cmd:Nn \@schapter - { - \bool_if:NF \l__eb_class_book_bool - { \msg_error:nn { easybook } { no-chapter } } } -\msg_new:nnn { easybook } { no-chapter } +\msg_new:nnn { easybase } { no-chapter } { Your~document~class~is~in~article~mode. \\ The~\string\chapter\space~command~will~not~be~used. } -\tl_set:Nn \l__eb_toc_type_tl { book } +\tl_set:Nx \l__eb_toc_type_tl + { \bool_if:NTF \l__eb_class_book_bool { book } { article } } \tl_new:N \eb@bitoc@title \keys_define:nn { eb/listoc } { @@ -1894,7 +2035,9 @@ multoc .bool_set:N = \l__eb_multoc_bool, multoc .default:n = true, multoc .initial:n = false, - title .code:n = \eb_assign_toc_title:n {#1} + title .code:n = \eb_assign_toc_title:n {#1}, + columns .int_set:N = \l__eb_toc_columns_int, + columns .initial:n = 2 } \bool_if:NTF \l__eb_class_book_bool { \keys_define:nn { } { eb/listoc .inherit:n = ctex/chapter } } @@ -1978,32 +2121,19 @@ } \cs_new_protected:Npn \eb_multoc_pre_bool: { - \bool_if:NTF \l__eb_class_book_bool - { - \ifbool{@twocolumn} - { - \booltrue{@restonecol} - \bool_if:NF \l__eb_multoc_bool { \onecolumn } - }{ - \boolfalse{@restonecol} - \bool_if:NT \l__eb_multoc_bool { \twocolumn } - } - } - { \tl_set:Nn \l__eb_toc_type_tl { article } } + \bool_if:NT \l__eb_multoc_bool + { \begin{multicols}{\int_use:N \l__eb_toc_columns_int} } } \cs_new_protected:Npn \eb_multoc_post_bool: - { - \bool_if:NT \l__eb_class_book_bool - { \ifbool{@restonecol}{\twocolumn}{\onecolumn} } - } + { \bool_if:NT \l__eb_multoc_bool { \end{multicols} } } \RenewDocumentCommand{\tableofcontents}{t+oD(){}} { \group_begin: \tl_set_eq:NN \eb@toc@title \contentsname \tl_set:Nn \eb@bitoc@title { Contents } \IfValueT{#2}{\keys_set:nn { eb/listoc } {#2}} - \eb_multoc_pre_bool: \eb_title_mark_notoc:n { \eb@toc@title } + \eb_multoc_pre_bool: \vspace*{\dim_use:N \l__eb_toc_offset_dim} \@starttoc{toc}#3 \IfBooleanT{#1} @@ -2020,8 +2150,8 @@ \group_begin: \tl_set_eq:NN \eb@toc@title \listfigurename \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} - \eb_multoc_pre_bool: \eb_title_number_intoc_bool:nn {#2} {#1} + \eb_multoc_pre_bool: \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_figure_offset_dim \vspace*{\dim_use:N \l__eb_toc_offset_dim} \@starttoc{lof} @@ -2033,8 +2163,8 @@ \group_begin: \tl_set_eq:NN \eb@toc@title \listtablename \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} - \eb_multoc_pre_bool: \eb_title_number_intoc_bool:nn {#2} {#1} + \eb_multoc_pre_bool: \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_table_offset_dim \vspace*{\dim_use:N \l__eb_toc_offset_dim} \@starttoc{lot} @@ -2046,8 +2176,8 @@ \group_begin: \tl_set_eq:NN \eb@toc@title \lstlistlistingname \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} - \eb_multoc_pre_bool: \eb_title_number_intoc_bool:nn {#2} {#1} + \eb_multoc_pre_bool: \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_lstlisting_offset_dim \vspace*{\dim_use:N \l__eb_toc_offset_dim} \@starttoc{lol} @@ -2189,7 +2319,7 @@ \c__eb_subfont_math_charter_tl { \eb_put_newtxmath:n { charter,noOT1 } } } - { \RequirePackage{newtxmath,bm} } + { \eb@package@load{newtxmath,bm} } } \fp_new:N \l__eb_spread_line_fp @@ -2438,6 +2568,7 @@ label = (\Alph*), column-sep = \ccwd, item-indent = 2\ccwd, + label-offset = 0.5\ccwd, label-width = 1.5\ccwd, after-item-skip = 0ex plus .1ex } @@ -2545,7 +2676,7 @@ boxsep = 0pt, arc = 0pt, fonttitle = \sffamily, - boxrule = \l__eb_rule_width_dim + boxrule = \eb@rule@width@dim } \newtcbox[auto~counter]{\eb@exercise@box}[1]{tc-exercise,#1} \NewDocumentEnvironment{outline}{O{}D(){\abstractname}o+b} @@ -2632,7 +2763,7 @@ { standard~jigsaw, nobeforeafter,tcbox~raise~base, - top = 1.25pt,bottom = 1.25pt,left = 1.25pt,right = 1.25pt, + top = 1.25qt,bottom = 1.25qt,left = 1.25qt,right = 1.25qt, boxrule = 0.75pt,arc = 1pt, colback = #1,opacityback = 0.12,colframe = #1,#3 }{#2} @@ -2697,9 +2828,11 @@ \group_begin: \tl_set_eq:NN \eb@toc@title \bibname \IfValueT{##3}{ \keys_set:nn { eb/listoc } {##3} } - \eb_multoc_pre_bool: \tl_set:Nn \bibsection - { \eb_title_number_intoc_bool:nn {##2} {##1} } + { + \eb_title_number_intoc_bool:nn {##2} {##1} + \eb_multoc_pre_bool: + } \exp_args:NV \bibliography \l__eb_bib_datafile_tl \eb_multoc_post_bool: \group_end: @@ -2735,12 +2868,12 @@ { \bool_if:NTF \l__eb_backend_bibtex_bool { - \RequirePackage[sort&compress]{natbib} + \eb@package@load[sort&compress]{natbib} \EbBibtexSet } { \EbBiblatexPreset - \RequirePackage{biblatex} + \eb@package@load{biblatex} \EbBiblatexPostset } } @@ -2799,7 +2932,7 @@ aboveskip = 1.5ex plus .2ex minus .1ex, belowskip = 0.55ex plus .2ex minus .1ex, keepspaces = true, - framerule = \l__eb_rule_width_dim, + framerule = \eb@rule@width@dim, columns = flexible, abovecaptionskip = -1ex, belowcaptionskip = 1.5ex @@ -2931,7 +3064,7 @@ } \ctex_at_end_preamble:n { - \RequirePackage{hyperref} + \eb@package@load{hyperref} \urlstyle{same} \eb_allow_urlbreak: \ctex_hypersetup:n { pdfstartview = FitH } @@ -2969,73 +3102,5 @@ \labelformat{section}{Section~#1} \labelformat{subsection}{Subsection~#1} } - -\ctex_set:n - { - secnumdepth = 3, - tocdepth = \bool_if:NTF \l__eb_class_book_bool { 1 } { 2 }, - part = - { - pagestyle = empty, - tocline = \EbNumberLine{#1}#2, - format = \color{ctex@frame}\sffamily\Huge, - aftername = - { - \bool_if:NTF \l__eb_title_newline_bool - { \par\nobreak } { \hspace{\ccwd} } - } - }, - chapter = - { - % pagestyle = fancy, - format = - { - \color{ctex@frame}\sffamily\LARGE - \bool_if:NF \l__eb_title_newline_bool { \centering } - }, - aftername = - { - \bool_if:NTF \l__eb_title_newline_bool - { \par\nobreak\vskip 1.5pc } { \hspace{\ccwd} } - }, - beforeskip = -1.5ex, - afterskip = 3ex, - lotskip = 0.8pc, - lofskip = 0.8pc - }, - section = - { - hang = true, - format = \color{ctex@frame}\sffamily\Large, - aftername = \hspace{0.5\ccwd}, - beforeskip = 1.5ex plus .2ex minus .1ex, - afterskip = 1.5ex plus .2ex minus .1ex - }, - subsection = - { - hang = true, - format = \color{ctex@frame}\sffamily\large, - aftername = \hspace{0.5\ccwd}, - beforeskip = 1.3ex plus .2ex minus .1ex, - afterskip = 1.3ex plus .2ex minus .1ex - }, - subsubsection = - { - hang = true, - format = \color{ctex@frame}\sffamily, - aftername = \hspace{0.5\ccwd}, - beforeskip = \parskip, - afterskip = \parskip - } - } - -\bool_if:NF \l__eb_title_newline_bool - { - \ctex_set:n - { - part/hang = true, - chapter/hang = true - } - } -%</class> +%</package> \endinput
\ No newline at end of file diff --git a/Master/texmf-dist/source/latex/easybook/easybook.ins b/Master/texmf-dist/source/latex/easybook/easybook.ins index af8f3f81340..b70169f22a9 100644 --- a/Master/texmf-dist/source/latex/easybook/easybook.ins +++ b/Master/texmf-dist/source/latex/easybook/easybook.ins @@ -20,6 +20,10 @@ The latest version of this license is in https://creativecommons.org/licenses/by/4.0/legalcode \endpreamble -\generate{\file{\jobname.cls}{\from{\jobname.dtx}{class}}} +\generate + { + \file{easybook.cls}{\from{\jobname.dtx}{class}} + \file{easybase.sty}{\from{\jobname.dtx}{package}} + } \endbatchfile
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/easybook/easybase.sty b/Master/texmf-dist/tex/latex/easybook/easybase.sty new file mode 100644 index 00000000000..bbff3cd8e9e --- /dev/null +++ b/Master/texmf-dist/tex/latex/easybook/easybase.sty @@ -0,0 +1,1865 @@ +%% +%% This is file `easybase.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% easybook.dtx (with options: `package') +%% Copyright (C) 2021 by Qu Yi <quee123@foxmail.com> +%% +%% This work may be distributed and/or modified under the +%% conditions of the CC-BY 4.0 License. +%% The latest version of this license is in +%% https://creativecommons.org/licenses/by/4.0/legalcode +\NeedsTeXFormat{LaTeX2e}[2020/10/01] +\RequirePackage{etoolbox} +\ProvidesExplPackage{easybase}{2021/06/02}{1.25q}{beta} + +\cs_generate_variant:Nn \eb_ctex_define:nn { nx } +\cs_generate_variant:Nn \int_to_arabic:n { v } +\cs_generate_variant:Nn \dim_add:Nn { NV } +\cs_generate_variant:Nn \eb_put_hyperref:n { x } +\cs_generate_variant:Nn \seq_set_from_clist:Nn { No } +\cs_generate_variant:Nn \int_compare:nNnT { oNnT } +\cs_new_protected:Npn \eb_ctex_define:nn #1 + { \keys_define:nn { ctex/#1 } } +\cs_new_protected:Npn \eb_patch_cmd:Nnn #1#2#3 + { + \ctex_patch_cmd_once:NnnnTF #1 { } {#2} {#3} + { } { \ctex_patch_failure:N #1 } + } +\cs_new_protected:Npn \eb_preto_cmd:Nn #1#2 + { + \ctex_preto_cmd:NnnTF #1 { } {#2} + { } { \ctex_patch_failure:N #1 } + } +\cs_new_protected:Npn \eb_appto_cmd:Nn #1#2 + { + \ctex_appto_cmd:NnnTF #1 { } {#2} + { } { \ctex_patch_failure:N #1 } + } +\cs_new_protected:Npn \eb_at_begin_environment:nn #1#2 + { + \seq_set_from_clist:No \l__eb_env_hook_name_seq {#1} + \seq_map_inline:Nn \l__eb_env_hook_name_seq + { \AtBeginEnvironment{##1}{#2} } + } +\NewDocumentCommand{\eb@package@load}{O{}m} + { + \seq_set_from_clist:No \l__eb_package_name_seq {#2} + \int_compare:oNnT + { \seq_count:N \l__eb_package_name_seq } = { 1 } + { \PassOptionsToPackage{#1}{#2} } + \seq_map_inline:Nn \l__eb_package_name_seq + { \@ifpackageloaded{##1}{}{\RequirePackage{##1}} } + } +\cs_new_protected:Npn \eb_at_end_preamble:n + { \ctex_gadd_ltxhook:nn { env/document/before } } +\cs_gset_eq:NN \PackageWarning \use_none:nn + +\bool_if_exist:NF \l__eb_class_book_bool + { \bool_set_true:N \l__eb_class_book_bool } +\bool_if_exist:NF \l__eb_page_twoside_bool + { \bool_set_true:N \l__eb_page_twoside_bool } +\bool_if_exist:NF \l__eb_compile_draft_bool + { \bool_set_false:N \l__eb_compile_draft_bool } + +\keys_define:nn { easybase } + { + draft .code:n = + { \bool_set_true:N \l__eb_compile_draft_bool }, + + class .choice:, + class .value_required:n = true, + class/book .code:n = { }, + class/article .code:n = + { + \bool_set_false:N \l__eb_class_book_bool + \bool_set_false:N \l__eb_page_twoside_bool + } + } + +\clist_map_inline:nn + { + { svgnames } { xcolor }, + { stable } { footmisc }, + { normalem } { ulem }, + { protrusion = false } { microtype }, + { list = off } { bicaption }, + { shortlabels,inline } { enumitem }, + { many } { tcolorbox }, + { xindy } { imakeidx }, + { CJKmath } { xeCJK }, + { no-math } { fontspec }, + { upint } { newtxmath } + } + { \PassOptionsToPackage #1 } +\ProcessKeysOptions{easybase} + +\bool_new:N \l__eb_multoc_bool +\bool_new:N \l__eb_uppercase_bool +\bool_new:N \l__eb_chap_withpart_bool +\tl_new:N \l__eb_foot_numparent_choice_tl + +\seq_const_from_clist:Nn \c__eb_options_path_seq + { + style,subfont,spread, + refset,bibset,thmset, + geoset,hdrset,tocset + } +\seq_map_inline:Nn \c__eb_options_path_seq + { + \ctex_define:n { #1 .meta:nn = { ctex/#1 } {##1} } + \cs_new:cpn {#1} ##1 { \keys_set:nn { ctex/#1 } {##1} } + } +\keys_define:nn { } { ctex/link .inherit:n = ctex/refset } +\cs_set_eq:NN \link \refset +\ctex_define:n + { + link .meta:nn = { ctex/link } {#1}, + lstlistlistingname .tl_set:N = \lstlistlistingname, + lstlistingname .tl_set:N = \lstlistingname + } +\eb_ctex_define:nn { style } + { + multoc .bool_set:N = \l__eb_multoc_bool, + multoc .default:n = true, + withpart .bool_set:N = \l__eb_chap_withpart_bool, + withpart .default:n = true, + withpart .initial:n = false, + rulewidth .dim_set:N = \eb@rule@width@dim, + rulewidth .initial:n = 0.75pt, + uppercase .bool_set:N = \l__eb_uppercase_bool, + uppercase .default:n = true, + uppercase .initial:n = true, + figurepath .tl_set:N = \l_eb_graphics_path_tl, + + footwith .choices:nn = + { part,page,chapter } + { + \tl_set_eq:NN + \l__eb_foot_numparent_choice_tl \l_keys_choice_tl + }, + footwith .value_required:n = true, + footwith .initial:n = chapter, + + figure-sep .tl_set:N = \l__eb_figure_separator_tl, + table-sep .tl_set:N = \l__eb_table_separator_tl, + listing-sep .tl_set:N = \l__eb_lstlisting_separator_tl, + equation-sep .tl_set:N = \l__eb_equation_separator_tl, + number-sep .meta:n = + { + figure-sep = #1, + table-sep = #1, + listing-sep = #1, + equation-sep = #1 + }, + number-sep .initial:n = { . } + } + +\eb@package@load + { + xcolor, + footmisc,setspace, + amsmath,amsthm,thmtools, + chemformula,siunitx,ulem,pifont, + geometry,marginnote,nccfoots, + pdfpages,graphicx,multicol, + fancyhdr,titletoc,caption, + tabularray, + enumitem, + listings + } +\cs_new_protected:Npn \eb_package_later_bool:nn #1#2 + { + \@ifpackagelater{#1}{#2} + {}{\msg_warning:nnn { easybase } { package-old } {#1}} + } +\msg_new:nnn { easybase } { package-old } + { + Package~#1~has~been~out~of~date. \\ + Some~problems~or~errors~may~occur \\ + if~you~continue~compiling. \\\\ + Please~update~your~macro~package~from~CTAN. + } +\clist_map_inline:nn + { + { expl3 } { 2020/10/27 }, + { xparse } { 2020/10/27 }, + { l3keys2e } { 2020/10/27 }, + { ctex } { 2021/03/14 }, + { thmtools } { 2020/08/01 }, + { caption } { 2020/08/24 }, + { siunitx } { 2021/05/17 } + } + { \eb_package_later_bool:nn #1 } + +\includepdfset{fitpaper = true} +\geometry + { + vmargin = 2.54cm, + hmargin = 3.17cm, + columnsep = \ccwd, + headheight = 2.04cm, + headsep = 0.5cm, + footskip = 0.79cm, + footnotesep = 0.5cm, + marginparsep = 8pt, + marginparwidth = 2.54cm + } +\clist_new:N \g__eb_geometry_clist +\eb_ctex_define:nn { geoset } + { + headruleskip .tl_set:N = \headruleskip, + headruleskip .initial:n = 1.5pt, + footruleskip .tl_set:N = \footruleskip, + unknown .code:n = + { + \clist_gput_right:Nx \g__eb_geometry_clist + { + \l_keys_key_str + \tl_if_empty:NF \l_keys_value_tl { = {#1} } + } + } + } + +\RenewDocumentCommand{\cleardoublepage}{O{empty}} + { + \clearpage + \bool_if:NT \l__eb_page_twoside_bool + { + \int_if_odd:nF { \c@page } + { \hbox:n { }\thispagestyle{#1}\clearpage } + } + } +\DeclareDocumentCommand{\frontmatter}{sO{Roman}} + { + \IfBooleanTF{#1}{\clearpage}{\cleardoublepage} + \boolfalse{@mainmatter} + \pagenumbering{#2} + } +\DeclareDocumentCommand{\mainmatter}{s} + { + \IfBooleanTF{#1}{\clearpage}{\cleardoublepage} + \booltrue{@mainmatter} + \pagenumbering{arabic} + } +\seq_const_from_clist:Nn \c__eb_mark_title_level_seq + { chapter,section,subsection } +\seq_map_inline:Nn \c__eb_mark_title_level_seq + { + \exp_args:Nc \NewDocumentCommand { eb@mark@#1@label@layout } + {O{\use:c { CTEXthe#1 }}m} + {\tl_set:cn { eb@mark@#1@label } {##1##2}} + \cs_new:cpn { eb_mark_#1_number_bool:n } ##1 + { + \tl_if_in:nnTF {##1} { [ } + { \use:c { eb@mark@#1@label@layout } ##1 } + { \use:c { eb@mark@#1@label@layout } {##1} } + } + } + +\cs_gset_eq:NN \easyhead \fancyhead +\cs_gset_eq:NN \easyfoot \fancyfoot +\eb_ctex_define:nn { hdrset } + { + head-foot .tl_set:N = \l__eb_fancyhf_content_tl, + head-foot .initial:n = + { + \bool_if:NTF \l__eb_page_twoside_bool + { + \easyhead[EC]{\color{ctex@frame}\kaishu\leftmark} + \easyhead[OC]{\color{ctex@frame}\kaishu\rightmark} + \easyhead[EL,OR]{\color{ctex@frame}\thepage} + } + { + \easyhead[L]{\color{ctex@frame}\kaishu\leftmark} + \easyhead[R]{\color{ctex@frame}\thepage} + } + }, + + chap-mark .cs_set:Np = \eb_fancyhf_chapter_mark:n #1, + chap-mark .initial:n = + { + \int_compare:nNnT { \c@secnumdepth } > { -1 } + { + \ifbool{@mainmatter} + { + \int_if_odd:nT { \CTEX@chapter@numbering } + { \eb@mark@chapter@label } + }{} + }#1 + }, + sec-mark .cs_set:Np = \eb_fancyhf_section_mark:n #1, + sec-mark .initial:n = + { + \int_compare:nNnT { \c@secnumdepth } > { 0 } + { + \int_if_odd:nT { \CTEX@section@numbering } + { \eb@mark@section@label } + }#1 + }, + subsec-mark .cs_set:Np = \eb_fancyhf_subsection_mark:n #1, + subsec-mark .initial:n = + { + \int_compare:nNnT { \c@secnumdepth } > { 1 } + { + \int_if_odd:nT { \CTEX@subsection@numbering } + { \eb@mark@subsection@label } + }#1 + }, + chap-label .code:n = \eb_mark_chapter_number_bool:n {#1}, + chap-label .initial:n = \hspace{\ccwd}, + sec-label .code:n = \eb_mark_section_number_bool:n {#1}, + sec-label .initial:n = \hspace{0.5\ccwd}, + subsec-label .code:n = \eb_mark_subsection_number_bool:n {#1}, + subsec-label .initial:n = \hspace{0.5\ccwd}, + + headrule .tl_gset:N = \headrule, + headrule .initial:n = + { + \group_begin: + \color{ctex@frame} + \hrule\@width\textwidth\@height\eb@rule@width@dim + \group_end: + }, + footrule .tl_gset:N = \footrule, + footrule .initial:n = { }, + footnoterule .tl_gset:N = \footnoterule, + footnoterule .initial:n = + { + \group_begin: + \color{ctex@frame} + \hrule\@width 0.35\columnwidth\@height\eb@rule@width@dim + \vspace*{2.6pt} + \group_end: + }, + + fnmargin .dim_set:N = \footnotemargin, + fnmargin .initial:n = 0.75\ccwd, + fnparskip .tl_set:N = \hangfootparskip, + fnparskip .initial:n = 0ex, + fnparindent .tl_set:N = \hangfootparindent, + fnparindent .initial:n = 2\ccwd, + + fnhang .bool_set:N = \l__eb_footnote_hang_bool, + fnhang .default:n = true, + fnhang .initial:n = true, + fnmark-pos .tl_set:N = \l__eb_fnmark_position_tl, + fnmark-pos .initial:n = super, + afterfnmark .tl_set:N = \l__eb_fnmark_after_tl, + afterfnmark .initial:n = + { \tl_if_eq:NnF \l__eb_fnmark_position_tl { super } { \space } }, + fnmark-form .tl_set:N = \l__eb_fnmark_format_tl, + + fnmark-num .choices:nn = + { plain,pifont,pifont*,pifont-sans,pifont-sans* } + { + \tl_gset_eq:NN + \l__eb_fnmark_number_choice_tl \l_keys_choice_tl + }, + fnmark-num .value_required:n = true + } + +\cs_new:Npn \eb_upper_number_mark_bool:nn #1#2 + { + \bool_if:NT \l__eb_uppercase_bool + { \text_uppercase:n } {\use:c { eb_fancyhf_#1_mark:n } {#2}} + } +\cs_new:Npn \eb@number@markdouble #1#2 + { + \markboth + {\eb_upper_number_mark_bool:nn {#1} {#2}} + { + \bool_if:NT \l__eb_page_twoside_bool + { \eb_upper_number_mark_bool:nn {#1} {#2} } + } + } +\cs_new:Npn \eb@number@markright #1#2 + { \markright{\eb_upper_number_mark_bool:nn {#1} {#2}} } +\ctex_at_end_preamble:n + { + \exp_args:NV \geometry \g__eb_geometry_clist + \fancyhf{} + \tl_use:N \l__eb_fancyhf_content_tl + \cs_gset_eq:NN \ps@plain \ps@empty + \pagestyle{fancy} + \bool_if:NTF \l__eb_class_book_bool + { + \cs_gset:Npn \chaptermark #1 + { \eb@number@markdouble{chapter}{#1} } + \cs_gset:Npn \sectionmark #1 + { \eb@number@markright{section}{#1} } + } + { + \cs_gset:Npn \sectionmark #1 + { \eb@number@markdouble{section}{#1} } + \cs_gset:Npn \subsectionmark #1 + { \eb@number@markright{subsection}{#1} } + } + \bool_if:NT \l__eb_compile_draft_bool + { + \easyfoot[C]{\color{SlateGray}\sffamily\today} + \geometry{showframe} + } + \tl_if_empty:NF \l_eb_graphics_path_tl + { \exp_args:No \graphicspath { \l_eb_graphics_path_tl } } + \cs_if_exist:NF \kaishu { \cs_gset_eq:NN \kaishu \itshape } + } + +\eb_at_end_preamble:n + { + \group_begin: + \footnotesize + \exp_args:Nx + \linespread{\fp_use:N \l__eb_spread_footnote_fp}\selectfont + \exp_args:NNNo \group_end: + \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } + \bool_if:NT \l__eb_chap_withpart_bool + { \counterwithin*{chapter}{part} } + \tl_if_eq:NnT \l__eb_foot_numparent_choice_tl { part } + { + \counterwithout*{footnote}{chapter} + \counterwithin*{footnote}{part} + } + \tl_if_eq:NnT \l__eb_foot_numparent_choice_tl { page } + { + \counterwithout*{footnote}{chapter} + \counterwithin*{footnote}{page} + } + \bool_if:NTF \l__eb_footnote_hang_bool + { \booltrue{FN@hangfoot} } { \boolfalse{FN@hangfoot} } + } +\eb_patch_cmd:Nnn \@footnotetext + { \reset@font } + { + \linespread{\fp_use:N \l__eb_spread_footnote_fp} + \selectfont\ignorespaces + \l__eb_subfont_footnote_tl + } +\eb_patch_cmd:Nnn \@mpfootnotetext + { \reset@font } + { + \linespread{\fp_use:N \l__eb_spread_footnote_fp} + \selectfont\ignorespaces + \l__eb_subfont_footnote_tl + } +\ctex_after_end_preamble:n + { + \ExplSyntaxOn\char_set_catcode_letter:N \@ + \eb_patch_cmd:Nnn \@footnotemark + { \@makefnmark } + { + \tl_use:N \l__eb_subfont_footnote_tl + \tl_use:N \l__eb_fnmark_format_tl + {\hbox:n { \textsuperscript{\@thefnmark} }} + } + \ExplSyntaxOff\char_set_catcode_other:N \@ + } +\cs_set:Npn \@makefnmark + { + \tl_use:N \l__eb_subfont_footnote_tl + \tl_use:N \l__eb_fnmark_format_tl + { + \hbox:n + { + \tl_if_eq:NnT \l__eb_fnmark_position_tl { super } + { \textsuperscript }{\@thefnmark} + \tl_use:N \l__eb_fnmark_after_tl + } + } + } +\cs_set:Npn \thefootnote { \eb_footnote_counter:N \c@footnote } +\cs_set:Npn \thempfootnote { \int_to_alph:n { \c@mpfootnote } } + +\cs_new_protected:Npn \eb_fnmark_number_set:nn #1#2 + { \tl_const:cn { c__eb_fnmark_number_#1_tl } {#2} } +\clist_map_inline:nn + { + { plain } { plain }, + { pifont } { pifont }, + { pifont_neg } { pifont* }, + { pifont_sans } { pifont-sans }, + { pifont_sans_neg } { pifont-sans* } + } + { \eb_fnmark_number_set:nn #1 } +\cs_new:Npn \eb_fnmark_counter_pifont:N #1 + { \ding{\int_eval:n { 171 + #1 }} } +\cs_new:Npn \eb_fnmark_counter_pifont_neg:N #1 + { \ding{\int_eval:n { 181 + #1 }} } +\cs_new:Npn \eb_fnmark_counter_pifont_sans:N #1 + { \ding{\int_eval:n { 191 + #1 }} } +\cs_new:Npn \eb_fnmark_counter_pifont_sans_neg:N #1 + { \ding{\int_eval:n { 201 + #1 }} } +\cs_new:Npn \eb_footnote_counter:N #1 + { + \tl_case:NnF \l__eb_fnmark_number_choice_tl + { + \c__eb_fnmark_number_plain_tl + { \int_use:N #1 } + \c__eb_fnmark_number_pifont_tl + { \eb_fnmark_counter_pifont:N #1 } + \c__eb_fnmark_number_pifont_neg_tl + { \eb_fnmark_counter_pifont_neg:N #1 } + \c__eb_fnmark_number_pifont_sans_tl + { \eb_fnmark_counter_pifont_sans:N #1 } + \c__eb_fnmark_number_pifont_sans_neg_tl + { \eb_fnmark_counter_pifont_sans_neg:N #1 } + } + { \int_use:N #1 } + } + +\contentsuse{lstlisting}{lol} +\seq_const_from_clist:Nn \c__eb_toc_heading_level_seq + { part,chapter,section,subsection,figure,table,lstlisting } +\cs_new_protected:Npn \eb_toc_assign_keys:n #1 + { + \ctex_define:n { tocset/#1 .meta:nn = { ctex/tocset/#1 } {##1} } + \eb_ctex_define:nn { tocset } + { + #1/format .tl_set:c = l__eb_toc_#1_format_tl, + #1/format+ .code:n = + { \tl_put_right:cn { l__eb_toc_#1_format_tl } {##1} }, + #1/format~+ .code:n = + { \tl_put_right:cn { l__eb_toc_#1_format_tl } {##1} }, + #1/indent .tl_set:c = l__eb_toc_#1_indent_tl, + #1/rule .tl_set:c = l__eb_toc_#1_rule_tl, + #1/numsep .tl_set:c = eb@toc@#1@numsep + } + \seq_if_in:NnF \c__eb_toc_heading_level_seq { subsection } + { + \eb_ctex_define:nn { tocset } + { #1/belowoffset .dim_set:c = l__eb_toc_#1_offset_dim } + } + \seq_pop:NN \c__eb_toc_heading_level_seq \l_tmpa_tl + \titlecontents{#1} + [\use:c { l__eb_toc_#1_indent_tl }] + {\use:c { l__eb_toc_#1_format_tl }} + { + \ifbool{eb@titletoc@hang@fix} + { + \contentspush + { + \bool_if:NT \l__eb_toc_number_color_bool + { \color{ctex@toc@number} } + \thecontentslabel + \hspace{\use:c { eb@toc@#1@numsep }} + } + }{} + }{} + {\use:c { l__eb_toc_#1_rule_tl }} + } +\seq_map_function:NN +\c__eb_toc_heading_level_seq \eb_toc_assign_keys:n + +\seq_const_from_clist:Nn \c__eb_toc_list_meta_keys_seq + { format,format+,format~+,indent,rule,numsep,belowoffset } +\ctex_define:n { tocset/list .meta:nn = { ctex/tocset/list } {#1} } +\seq_map_inline:Nn \c__eb_toc_list_meta_keys_seq + { + \eb_ctex_define:nn { tocset } + { + list/#1 .meta:n = + { + figure/#1 = ##1, + table/#1 = ##1, + lstlisting/#1 = ##1 + } + } + } + +\cs_new:Npn \EbNumberLine #1 + { + \CTEXifname + { + \use:c { CTEXthe#1 } + \hspace{\use:c { eb@toc@#1@numsep }} + }{} + } +\cs_if_exist:NF \chapter + { + \newcounter{chapter} + \bool_set_false:N \l__eb_class_book_bool + \ctex_define:n { chapter/tocline .code:n = { } } + } +\newbool{eb@titletoc@hang@fix} +\eb_ctex_define:nn { tocset } + { + lolskip .skip_set:N = \l__eb_toc_lolskip_skip, + lolskip .initial:n = 0.8pc, + + belowoffset .dim_set:N = \l__eb_toc_offset_dim, + belowoffset .initial:n = + { \bool_if:NTF \l__eb_class_book_bool { -1pc } { -0.35pc } }, + tocline-fig .cs_set:Np = \eb@labelname@lof #1, + tocline-fig .initial:n = + { + \figurename\space #1 + \notbool{eb@titletoc@hang@fix} + {\hspace{\eb@toc@figure@numsep}}{} + }, + tocline-tab .cs_set:Np = \eb@labelname@lot #1, + tocline-tab .initial:n = + { + \tablename\space #1 + \notbool{eb@titletoc@hang@fix} + {\hspace{\eb@toc@table@numsep}}{} + }, + tocline-lst .tl_set:N = \eb@labelname@lol, + tocline-lst .initial:n = + { + \lstlistingname\space\thelstlisting + \notbool{eb@titletoc@hang@fix} + {\hspace{\eb@toc@lstlisting@numsep}}{} + }, + line-align .bool_set:N = \l__eb_toc_line_align_bool, + line-align .default:n = true, + line-align .initial:n = true, + + hang .choice:, + hang/true .code:n = + { + \booltrue{eb@titletoc@hang@fix} + \ctex_set:n + { + chapter/tocline = \CTEXnumberline{##1}##2, + section/tocline = \CTEXnumberline{##1}##2, + subsection/tocline = \CTEXnumberline{##1}##2 + } + }, + hang/false .code:n = + { + \ctex_set:n + { + chapter/tocline = \EbNumberLine{##1}##2, + section/tocline = \EbNumberLine{##1}##2, + subsection/tocline = \EbNumberLine{##1}##2 + } + }, + hang .default:n = true, + hang .initial:n = false, + + numsep-all .meta:n = + { + part/numsep = #1, + chapter/numsep = #1, + section/numsep = #1, + subsection/numsep = #1, + list/numsep = #1 + }, + numsep-all .initial:n = \ccwd, + indent-all .meta:n = + { + part/indent = #1, + chapter/indent = #1, + section/indent = #1, + subsection/indent = #1, + list/indent = #1 + }, + rule-all .meta:n = + { + part/rule = #1, + chapter/rule = #1, + section/rule = #1, + subsection/rule = #1, + list/rule = #1 + } + } + +\NewDocumentCommand{\tocrule}{sO{0.7pc}D(){1.2}mO{}} + { + \normalsize\normalfont + \titlerule*[#2]{\scalebox{#3}{#4}}#5 + \IfBooleanTF{#1} + {\thecontentspage} + { + \bool_if:NTF \l__eb_toc_line_align_bool + { \contentspage } { \thecontentspage } + } + } +\ctex_set:nn { tocset } + { + part/format = \addvspace{1pc}\sffamily\large, + part/indent = 0\ccwd, + part/rule = \tocrule{}[\bfseries], + + chapter/format = \addvspace{1pc}\sffamily\large, + chapter/indent = 0\ccwd, + chapter/rule = \tocrule{$\cdot$}[\bfseries], + + section/format = \addvspace{0.35pc}, + section/indent = + { \bool_if:NTF \l__eb_class_book_bool { 1.5\ccwd } { 0\ccwd } }, + section/rule = \tocrule{$\cdot$}, + + subsection/format = \addvspace{0.35pc}, + subsection/indent = + { \bool_if:NTF \l__eb_class_book_bool { 3.8\ccwd } { 1.4\ccwd } }, + subsection/rule = \tocrule{$\cdot$}, + + list/format = \addvspace{0.2pc}, + list/indent = 0\ccwd, + list/rule = \tocrule{$\cdot$}, + list/belowoffset = + { \bool_if:NTF \l__eb_class_book_bool { 0pc } { 0.15pc } } + } + +\prop_new:N \l__eb_label_name_prop +\prop_set_from_keyval:Nn \l__eb_label_name_prop + { + figure = \eb@labelname@lof, + table = \eb@labelname@lot + } +\cs_gset:Npn \caption@@@addcontentsline #1#2#3#4 + { + \addcontentsline{#1}{#2} + { + \ifbool{eb@titletoc@hang@fix}{\protect\numberline}{} + {\prop_item:Nn \l__eb_label_name_prop {#2}{#3}}#4 + } + } +\ctex_patch_cmd:Nnn \lst@MakeCaption + { + \addcontentsline{lol}{lstlisting} + {\protect\numberline{\thelstlisting}\lst@@caption} + } + { + \addcontentsline{lol}{lstlisting} + { + \ifbool{eb@titletoc@hang@fix}{\protect\numberline}{} + {\eb@labelname@lol}\lst@@caption + } + } + +\contentsuse{}{tec} +\cs_set_protected:Npn \CTEX@addbitocline #1#2 + { + \group_begin: + \def\CTEX@prechapter{\CTEX@prebichapter} + \def\CTEX@thechapter{\CTEX@bichapter@number} + \def\CTEX@postchapter{\CTEX@postbichapter} + \addcontentsline{tec}{#1} + {\use:c { CTEX@#1@tocline }{#1}{#2}} + \group_end: + } +\seq_const_from_clist:Nn \c__eb_bitoc_title_level_seq + { chapter,section,subsection } +\seq_map_inline:Nn \c__eb_bitoc_title_level_seq + { + \exp_args:Nc \NewDocumentCommand {bi#1}{sO{##3}mm} + { + \IfBooleanTF{##1} + { + \use:c {#1}*{\phantomsection ##3} + \CTEX@addtocline{#1}{##2} + \tl_if_empty:oF {##4} { \CTEX@addbitocline{#1}{##4} } + }{ + \use:c {#1}[##2]{##3} + \tl_if_empty:oF {##4} { \CTEX@addbitocline{#1}{##4} } + } + } + } +\cs_if_exist:NT \chapter + { + \eb_appto_cmd:Nn \@chapter + { + \skip_if_eq:nnF { \l__eb_toc_lolskip_skip } { \c_zero_skip } + { + \addtocontents{lol} + {\protect\addvspace{\skip_use:N \l__eb_toc_lolskip_skip}} + } + \bool_if:NF \l__eb_class_book_bool + { \msg_error:nn { easybase } { no-chapter } } + } + \eb_appto_cmd:Nn \@schapter + { + \bool_if:NF \l__eb_class_book_bool + { \msg_error:nn { easybase } { no-chapter } } + } + } +\msg_new:nnn { easybase } { no-chapter } + { + Your~document~class~is~in~article~mode. \\ + The~\string\chapter\space~command~will~not~be~used. + } + +\tl_set:Nx \l__eb_toc_type_tl + { \bool_if:NTF \l__eb_class_book_bool { book } { article } } +\tl_new:N \eb@bitoc@title +\keys_define:nn { eb/listoc } + { + article .code:n = \tl_set:Nn \l__eb_toc_type_tl { article }, + book .code:n = { }, + multoc .bool_set:N = \l__eb_multoc_bool, + multoc .default:n = true, + multoc .initial:n = false, + title .code:n = \eb_assign_toc_title:n {#1}, + columns .int_set:N = \l__eb_toc_columns_int, + columns .initial:n = 2 + } +\bool_if:NTF \l__eb_class_book_bool + { \keys_define:nn { } { eb/listoc .inherit:n = ctex/chapter } } + { \keys_define:nn { } { eb/listoc .inherit:n = ctex/section } } +\NewDocumentCommand{\eb_assign_toc_title:n} + {>{\SplitArgument{1}{,}}m} + {\eb_assign_toc_title_judge:nn #1} +\cs_new_protected:Npn \eb_assign_toc_title_judge:nn #1#2 + { + \tl_set:Nn \eb@toc@title {#1} + \tl_if_novalue:nTF {#2} + { \tl_clear:N \eb@bitoc@title } + { \tl_set:Nn \eb@bitoc@title {#2} } + } + +\cs_new:Npn \eb_upper_nonumber_mark_bool:n #1 + { + \bool_if:NTF \l__eb_uppercase_bool + { \text_uppercase:n {#1} } + { \text_titlecase_first:n {#1} } + } +\cs_new:Npn \eb@nonumber@markdouble #1 + { + \markboth + {\eb_upper_nonumber_mark_bool:n {#1}} + { + \bool_if:NT \l__eb_page_twoside_bool + { \eb_upper_nonumber_mark_bool:n {#1} } + } + } +\cs_new:Npn \eb@nonumber@markright #1 + { \markright{\eb_upper_nonumber_mark_bool:n {#1}} } + +\cs_new_protected:Npn \eb_title_mark_intoc:n #1 + { + \tl_if_eq:NnTF \l__eb_toc_type_tl { book } + { + \bichapter*{#1}{\eb@bitoc@title} + \eb@nonumber@markdouble{#1} + } + { + \bisection*{#1}{\eb@bitoc@title} + \bool_if:NTF \l__eb_class_book_bool + { \eb@nonumber@markright{#1} } + { \eb@nonumber@markdouble{#1} } + } + } +\cs_new_protected:Npn \eb_title_mark_notoc:n #1 + { + \tl_if_eq:NnTF \l__eb_toc_type_tl { book } + { + \chapter*{\phantomsection #1} + \eb@nonumber@markdouble{#1} + } + { + \section*{\phantomsection #1} + \bool_if:NTF \l__eb_class_book_bool + { \eb@nonumber@markright{#1} } + { \eb@nonumber@markdouble{#1} } + } + } +\cs_new_protected:Npn \eb_title_number_intoc_bool:nn #1#2 + { + \IfBooleanTF{#1} + { + \tl_if_eq:NnTF \l__eb_toc_type_tl { book } + { \bichapter{\eb@toc@title}{\eb@bitoc@title} } + { \bisection{\eb@toc@title}{\eb@bitoc@title} } + }{ + \IfBooleanTF{#2} + {\eb_title_mark_notoc:n {\eb@toc@title}} + {\eb_title_mark_intoc:n {\eb@toc@title}} + } + } +\cs_new_protected:Npn \eb_biber_title_level_bool:n #1 + { + \bool_if:NTF \l__eb_class_book_bool + { \bichapter*{#1}{\l__eb_bib_bitoc_title} } + { \bisection*{#1}{\l__eb_bib_bitoc_title} } + \eb@nonumber@markdouble{#1} + } +\cs_new_protected:Npn \eb_multoc_pre_bool: + { + \bool_if:NT \l__eb_multoc_bool + { \begin{multicols}{\int_use:N \l__eb_toc_columns_int} } + } +\cs_new_protected:Npn \eb_multoc_post_bool: + { \bool_if:NT \l__eb_multoc_bool { \end{multicols} } } +\RenewDocumentCommand{\tableofcontents}{t+oD(){}} + { + \group_begin: + \tl_set_eq:NN \eb@toc@title \contentsname + \tl_set:Nn \eb@bitoc@title { Contents } + \IfValueT{#2}{\keys_set:nn { eb/listoc } {#2}} + \eb_title_mark_notoc:n { \eb@toc@title } + \eb_multoc_pre_bool: + \vspace*{\dim_use:N \l__eb_toc_offset_dim} + \@starttoc{toc}#3 + \IfBooleanT{#1} + { + \eb_title_mark_notoc:n { \eb@bitoc@title } + \vspace*{\dim_use:N \l__eb_toc_offset_dim} + \@starttoc{tec} + } + \eb_multoc_post_bool: + \group_end: + } +\RenewDocumentCommand{\listoffigures}{st+o} + { + \group_begin: + \tl_set_eq:NN \eb@toc@title \listfigurename + \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} + \eb_title_number_intoc_bool:nn {#2} {#1} + \eb_multoc_pre_bool: + \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_figure_offset_dim + \vspace*{\dim_use:N \l__eb_toc_offset_dim} + \@starttoc{lof} + \eb_multoc_post_bool: + \group_end: + } +\RenewDocumentCommand{\listoftables}{st+o} + { + \group_begin: + \tl_set_eq:NN \eb@toc@title \listtablename + \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} + \eb_title_number_intoc_bool:nn {#2} {#1} + \eb_multoc_pre_bool: + \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_table_offset_dim + \vspace*{\dim_use:N \l__eb_toc_offset_dim} + \@starttoc{lot} + \eb_multoc_post_bool: + \group_end: + } +\NewDocumentCommand{\listoflistings}{st+o} + { + \group_begin: + \tl_set_eq:NN \eb@toc@title \lstlistlistingname + \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} + \eb_title_number_intoc_bool:nn {#2} {#1} + \eb_multoc_pre_bool: + \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_lstlisting_offset_dim + \vspace*{\dim_use:N \l__eb_toc_offset_dim} + \@starttoc{lol} + \eb_multoc_post_bool: + \group_end: + } + +\ctex_at_end_package:nn { imakeidx } + { + \makeindex[ + options = -M~texindy~-C~utf8, + program = truexindy, + columns = 2, + columnsep = 2\ccwd + ] + \RenewDocumentCommand{\printindex}{st+D(){\imki@jobname}o} + { + \group_begin: + \tl_set_eq:NN \eb@toc@title \indexname + \cs_set_eq:NN \imki@indexlevel \use_none:n + \setkeys{imki}{intoc = false} + \IfValueT{#4}{\keys_set:nn { eb/listoc } {#4}} + \bool_if:NF \l__eb_class_book_bool + { \tl_set:Nn \l__eb_toc_type_tl { article } } + \tl_set:Nn \imki@indexheaders + { + \eb_title_number_intoc_bool:nn {#2} {#1} + \cs_set_eq:NN \thispagestyle \use_none:n + \cs_undefine:N \imki@firstpagestyle + } + \imki@putindex{#3} + \group_end: + } + } + +\eb_ctex_define:nn { chapter } + { + biname .code:n = + { \ctex_assign_heading_name:nn { bichapter } {#1} }, + biname .initial:n = Chapter\space, + binmuber .tl_set:N = \CTEX@bichapter@number, + binmuber .initial:n = \arabic{chapter} + } +\RenewDocumentCommand{\appendix} + {O{Appendix\space}D(){\Alph{chapter}}} + { + \ctex_assign_heading_name:nn { biappendix } {#1} + \int_compare:nNnTF { \c@chapter } > { 0 } + { + \ExplSyntaxOn\char_set_catcode_letter:N \@ + \eb_patch_cmd:Nnn \CTEX@addbitocline + { + \def\CTEX@prechapter{\CTEX@prebichapter} + \def\CTEX@thechapter{\CTEX@bichapter@number} + \def\CTEX@postchapter{\CTEX@postbichapter} + } + { + \def\CTEX@prechapter{\CTEX@prebiappendix} + \def\CTEX@thechapter{#2} + \def\CTEX@postchapter{\CTEX@postbiappendix} + } + \ExplSyntaxOff\char_set_catcode_other:N \@ + \setcounter{chapter}{0} + \setcounter{section}{0} + \gdef\thechapter{\@Alph\c@chapter} + \gdef\CTEX@prechapter{\CTEX@preappendix} + \gdef\CTEX@thechapter{\CTEX@appendix@number} + \gdef\CTEX@postchapter{\CTEX@postappendix} + \gdef\CTEX@chapter@numbering{\CTEX@appendix@numbering} + } + { + \setcounter{section}{0} + \setcounter{subsection}{0} + \gdef\thesection{\@Alph\c@section} + \gdef\CTEX@presection{\CTEX@preappendix} + \gdef\CTEX@thesection{\CTEX@appendix@number} + \gdef\CTEX@postsection{\CTEX@postappendix} + \gdef\CTEX@section@numbering{\CTEX@appendix@numbering} + \ctex_set:nn { appendix } { number = \@Alph\c@section,name = { } } + } + } + +\tl_new:N \l__eb_subfont_table_tl +\tl_new:N \l__eb_subfont_figure_tl +\tl_new:N \l__eb_subfont_listing_tl +\tl_new:N \l__eb_subfont_footnote_tl + +\seq_const_from_clist:Nn \c__eb_subfont_math_choice_seq + { + noto,notosans,times,scholax,stix, + charter,ebgaramond,libertine,none + } +\seq_map_inline:Nn \c__eb_subfont_math_choice_seq + { \tl_const:cn { c__eb_subfont_math_#1_tl } {#1} } + +\eb_ctex_define:nn { subfont } + { + table-cap .tl_set:N = \l__eb_subfont_table_tl, + table-cap .initial:n = \sffamily\small, + figure-cap .tl_set:N = \l__eb_subfont_figure_tl, + figure-cap .initial:n = \sffamily\small, + listing-cap .tl_set:N = \l__eb_subfont_listing_tl, + listing-cap .initial:n = \sffamily\small, + footnote .tl_set:N = \l__eb_subfont_footnote_tl, + footnote .initial:n = \rmfamily, + marginpar .tl_set:N = \marginfont, + marginpar .initial:n = \rmfamily\footnotesize, + + math .choices:xn = + { \seq_use:Nn \c__eb_subfont_math_choice_seq { , } } + { + \tl_gset_eq:NN + \l__eb_subfont_math_choice_tl \l_keys_choice_tl + }, + math .value_required:n = true, + math .initial:n = noto + } + +\cs_new_protected:Npn \eb_put_newtxmath:n #1 + { \PassOptionsToPackage{#1}{newtxmath} } +\eb_at_end_preamble:n + { + \tl_case:NnT \l__eb_subfont_math_choice_tl + { + \c__eb_subfont_math_noto_tl + { \eb_put_newtxmath:n { noto } } + \c__eb_subfont_math_notosans_tl + { \eb_put_newtxmath:n { notosans } } + \c__eb_subfont_math_ebgaramond_tl + { \eb_put_newtxmath:n { ebgaramond } } + \c__eb_subfont_math_times_tl + { \eb_put_newtxmath:n { noOT1 } } + \c__eb_subfont_math_libertine_tl + { \eb_put_newtxmath:n { libertine,noOT1 } } + \c__eb_subfont_math_stix_tl + { \eb_put_newtxmath:n { stix2,noOT1 } } + \c__eb_subfont_math_scholax_tl + { \eb_put_newtxmath:n { nc,noOT1 } } + \c__eb_subfont_math_charter_tl + { \eb_put_newtxmath:n { charter,noOT1 } } + } + { \eb@package@load{newtxmath,bm} } + } + +\fp_new:N \l__eb_spread_line_fp +\fp_new:N \l__eb_spread_table_fp +\fp_new:N \l__eb_spread_math_fp +\fp_new:N \l__eb_spread_caption_fp +\fp_new:N \l__eb_spread_footnote_fp + +\eb_ctex_define:nn { spread } + { + line .fp_set:N = \l__eb_spread_line_fp, + line .initial:n = 1.3, + table .fp_set:N = \l__eb_spread_table_fp, + table .initial:n = 1.05, + math .fp_set:N = \l__eb_spread_math_fp, + math .initial:n = 1.05, + caption .fp_set:N = \l__eb_spread_caption_fp, + caption .initial:n = 1, + footnote .fp_set:N = \l__eb_spread_footnote_fp, + footnote .initial:n = 1, + spread-all .meta:n = + { + line = #1, + table = #1, + math = #1, + caption = #1, + footnote = #1 + } + } + +\DeclareCaptionLabelSeparator{ccwd}{\hspace{\ccwd}} +\DeclareCaptionLabelFormat{parens}{\bothIfFirst{#1}{~}(#2)} +\DeclareCaptionFont{eb@table@font}{\l__eb_subfont_table_tl} +\DeclareCaptionFont{eb@figure@font}{\l__eb_subfont_figure_tl} +\DeclareCaptionFont{eb@listing@font}{\l__eb_subfont_listing_tl} +\captionsetup + { + format = hang, + font = {stretch = \fp_use:N \l__eb_spread_caption_fp}, + labelfont = {color = ctex@frame}, + labelsep = ccwd, + singlelinecheck = true, + belowskip = 0pt, + aboveskip = 10pt + } +\captionsetup[table]{font += eb@table@font} +\captionsetup[figure]{font += eb@figure@font} +\captionsetup[lstlisting]{font += eb@listing@font} +\captionsetup[subfigure] + { + labelformat = parens, + font+ = eb@figure@font, + belowskip = 2pt, + aboveskip = 6pt + } +\ctex_at_end_package:nn { bicaption } + { + \captionsetup[figure][bi-second]{name = Figure} + \captionsetup[table][bi-second]{name = Table} + } +\prop_gset_from_keyval:Nn \g__tblr_default_tblr_table_prop + { stretch = \fp_use:N \l__eb_spread_table_fp } +\SetTblrDefault{rows = {abovesep = 4pt,belowsep = 2pt}} +\eb_at_begin_environment:nn { tabular,tabularx } + { + \exp_args:Nx \linespread { \fp_use:N \l__eb_spread_table_fp } + \selectfont\ignorespaces + } +\ctex_after_end_preamble:n + { + \exp_args:Nx \linespread { \fp_use:N \l__eb_spread_line_fp } + \selectfont\ignorespaces + } + +\cs_new:Npn \eb_arabic:n #1 { \int_to_arabic:v { c@#1 } } +\cs_gset:cpn { thesection } + { + \int_compare:nNnT { \c@chapter } > { 0 } { \thechapter. } + \eb_arabic:n { section } + } +\seq_const_from_clist:Nn \c__eb_serial_number_counter_seq + { figure,table,lstlisting,equation } +\seq_map_inline:Nn \c__eb_serial_number_counter_seq + { + \cs_set:cpn { the#1 } + { + \int_compare:nNnT { \c@chapter } > { 0 } + { + \thechapter + \use:c { l__eb_#1_separator_tl } + } + \eb_arabic:n {#1} + } + } + +\skip_set:Nn \parskip { 0pt plus 2pt minus 1pt } +\skip_set:Nn \floatsep { 12pt plus 2pt minus 2pt } +\skip_set:Nn \intextsep { 14pt plus 2pt minus 2pt } +\skip_set:Nn \textfloatsep { 16pt plus 2pt minus 4pt } +\skip_set:Nn \dbltextfloatsep { 16pt plus 2pt minus 4pt } +\skip_set:Nn \@fpsep { 8pt plus 2.0fil } +\setcounter{topnumber}{4} +\setcounter{bottomnumber}{4} +\setcounter{totalnumber}{8} +\tl_gset:Nn \textfraction { 0.18 } +\tl_gset:Nn \topfraction { 0.85 } +\tl_gset:Nn \bottomfraction { 0.65 } +\tl_gset:Nn \floatpagefraction { 0.60 } +\tl_gset:Nn \ULthickness { 0.75pt } +\allowdisplaybreaks[4] +\DeclareGraphicsExtensions{.pdf,.png,.jpg,.eps,.tif} + +\cs_new_protected:Npn \eb_enumitem_label_set:nn #1#2 + { \SetEnumitemValue{label}{#1}{\color{ctex@emph}#2} } +\clist_map_inline:nn + { + { bullet } { \textbullet }, + { endash } { \normalfont\bfseries\textendash }, + { asterisk } { \textasteriskcentered }, + { arabic } { \arabic*. }, + { alph } { (\alph*) }, + { roman } { \roman*. }, + { outline } { \upshape\ding{111} } + } + { \eb_enumitem_label_set:nn #1 } +\SetEnumitemValue{font}{sf}{\color{ctex@emph}\normalfont\sffamily} +\SetEnumitemValue{ref}{enumii}{\arabic{enumi}.\alph*} +\SetEnumitemValue{ref}{enumiii}{\arabic{enumi}.\alph{enumii}.\roman*} +\setlist + { + labelsep = .75\ccwd,listparindent = 2\ccwd,leftmargin = *, + itemsep = .75ex plus .1ex,topsep = .75ex plus .1ex, + partopsep = 0ex,parsep = 0ex + } +\newlist{eb@outline@list}{itemize}{1} +\setlist[eb@outline@list]{label = outline,itemsep = .5ex plus .1ex} +\setlist[itemize,1]{label = bullet} +\setlist[itemize,2]{label = endash} +\setlist[itemize,3]{label = asterisk} +\setlist[enumerate,1]{label = arabic,ref = \arabic*} +\setlist[enumerate,2]{label = alph,ref = enumii} +\setlist[enumerate,3]{label = roman,ref = enumiii,labelwidth = *} +\setlist[description]{font = sf,labelwidth = *,leftmargin = 2\ccwd} + +\cs_new_protected:Npn \eb_thmname_set:nnn #1#2#3 + { + \tl_if_eq:NnTF \l__ctex_scheme_tl { chinese } + { \tl_const:cn { c__eb_name_#1_tl } {#3} } + { \tl_const:cn { c__eb_name_#1_tl } {#2} } + } +\NewDocumentCommand{\EbNewTheorem} + {mO{\text_titlecase_first:n {#1}}mD(){tc-theorem}O{}} + { + \ctex_at_end_preamble:n + { + \eb_thmname_set:nnn {#1} {#2} {#3} + \exp_args:No \declaretheorem@i + { + name = \use:c { c__eb_name_#1_tl }, + style = easy-theorem,#5 + }{#1}[] + \bool_if:NT \l__eb_thmbox_bool + { + \@ifpackageloaded{tcolorbox} + {\tcolorboxenvironment{#1}{#4}}{} + } + \labelformat{#1}{\use:c { c__eb_name_#1_tl }~##1} + } + } + +\bool_new:N \l__eb_thmbox_bool +\tl_new:N \l__eb_thm_numberwith_tl +\tl_new:N \l__eb_thm_headpunct_tl +\tl_new:N \l__eb_thm_bodyfont_tl +\tl_new:N \l__eb_thm_notefont_tl +\tl_new:N \l__eb_thm_headindent_tl +\tl_new:N \l__eb_thm_spaceabove_tl +\tl_new:N \l__eb_thm_spacebelow_tl + +\RenewDocumentCommand{\newtheorem}{O{}m} + {\AfterPreamble{\declaretheorem[#1]{#2}}} +\eb_ctex_define:nn { thmset } + { + thmbox .bool_set:N = \l__eb_thmbox_bool, + thmbox .default:n = true, + thmbox .initial:n = false, + within .tl_set:N = \l__eb_thm_numberwith_tl, + within .initial:n = \bool_if:NT \l__eb_class_book_bool { chapter }, + bodyfont .tl_set:N = \l__eb_thm_bodyfont_tl, + bodyfont .initial:n = { }, + notefont .tl_set:N = \l__eb_thm_notefont_tl, + notefont .initial:n = { }, + headfont .tl_set:N = \l__eb_thm_headfont_tl, + headfont .initial:n = \color{ctex@emph}\sffamily, + headpunct .tl_set:N = \l__eb_thm_headpunct_tl, + headpunct .initial:n = { }, + spacepost .tl_set:N = \l__eb_thm_spacepost_tl, + spacepost .initial:n = \ccwd, + headindent .tl_set:N = \l__eb_thm_headindent_tl, + headindent .initial:n = 0\ccwd, + spaceabove .tl_set:N = \l__eb_thm_spaceabove_tl, + spaceabove .initial:n = .75ex plus .1ex, + spacebelow .tl_set:N = \l__eb_thm_spacebelow_tl, + spacebelow .initial:n = .75ex plus .1ex + } +\tl_const:Nn \c__eb_thmtools_keyval_tl + { + [ + spaceabove = \l__eb_thm_spaceabove_tl, + spacebelow = \l__eb_thm_spacebelow_tl, + headindent = \l__eb_thm_headindent_tl, + headfont = \l__eb_thm_headfont_tl, + notefont = \l__eb_thm_notefont_tl, + notebraces = { }{ }, + bodyfont = \l__eb_thm_bodyfont_tl, + headpunct = \l__eb_thm_headpunct_tl, + postheadspace = \l__eb_thm_spacepost_tl, + within = \l__eb_thm_numberwith_tl, + headformat = \NAME\space\NUMBER\NOTE + ] + } +\eb_at_end_preamble:n + { + \exp_last_unbraced:No + \declaretheoremstyle{\c__eb_thmtools_keyval_tl}{easy-theorem} + \eb_thmname_set:nnn { exercise } { Exercise } { 练习 } + \cs_undefine:N \proof + \clist_map_inline:nn + { + { lemma } { 引理 }, + { example } { 例 }, + { theorem } { 定理 }, + { corollary } { 推论 }, + { definition } { 定义 }, + { proposition } { 性质 }, + { remark } { 注 } [ numbered = no ], + { { proof } { 证明 } [ numbered = no,qed = \qedsymbol ] } + } + { \EbNewTheorem #1 } + } + +\ctex_at_end_package:nn { tasks } + { + \settasks + { + label = (\Alph*), + column-sep = \ccwd, + item-indent = 2\ccwd, + label-offset = 0.5\ccwd, + label-width = 1.5\ccwd, + after-item-skip = 0ex plus .1ex + } + } +\setchemformula + { + math-scripts = false, + charge-hshift = 0.25\ccwd, + subscript-vshift = -0.2ex + } +\sisetup + { + mode = match, + table-parse-only, + propagate-math-font, + text-family-to-math, + text-series-to-math, + reset-text-family = false, + reset-text-series = false, + reset-text-shape = false, + reset-math-version = false, + range-phrase = \ensuremath{\sim}, + range-units = single, + group-digits = none + } +\eb_at_begin_environment:nn + { + array,matrix,pmatrix,bmatrix,Bmatrix,vmatrix,Vmatrix, + matrix*,pmatrix*,bmatrix*,Bmatrix*,vmatrix*,Vmatrix*, + cases,cases*,dcases,dcases*,rcases,rcases*,drcases,drcases*, + aligned,alignedat,gathered,multlined,lgathered,rgathered + } + { + \linespread{\fp_use:N \l__eb_spread_math_fp} + \selectfont\ignorespaces + } +\eb_patch_cmd:Nnn \start@gather + { \collect@body } + { + \linespread{\fp_use:N \l__eb_spread_math_fp} + \selectfont\collect@body + } +\eb_patch_cmd:Nnn \start@align + { \collect@body } + { + \linespread{\fp_use:N \l__eb_spread_math_fp} + \selectfont\collect@body + } +\eb_patch_cmd:Nnn \start@multline + { \collect@body } + { + \linespread{\fp_use:N \l__eb_spread_math_fp} + \selectfont\collect@body + } +\eb_patch_cmd:Nnn \gather@split + { \spread@equation } + { + \linespread{\fp_use:N \l__eb_spread_math_fp} + \selectfont\spread@equation + } +\ctex_after_end_preamble:n + { + \skip_set:Nn \abovedisplayskip { 5pt plus 1pt minus 1pt } + \skip_set:Nn \belowdisplayskip { 5pt plus 1pt minus 1pt } + \skip_set:Nn \abovedisplayshortskip { 0pt } + \skip_set:Nn \belowdisplayshortskip { 5pt plus 1pt minus 1pt } + } +\cs_gset:Npn \tagform@ #1 + { \maketag@@@{\color{ctex@emph}(\ignorespaces #1\unskip\@@italiccorr)} } +\ctex_at_end_package:nn { unicode-math } + { \msg_redirect_module:nnn { unicode-math } { warning } { none } } + +\ctex_at_end_package:nn { tcolorbox } + { + \eb_package_later_bool:nn { tcolorbox } { 2020/10/09 } + \tcbset + { + tc-theorem/.style = + { + enhanced~jigsaw,pad~at~break* = 3pt, + opacityback = 0, + colframe = ctex@emph, + left = 6pt,right = 6pt,top = 8pt,bottom = 8pt,middle= 8pt + }, + tc-outline/.style = + { + enhanced,nofloat, + tikznode~boxed~title, + interior~style = white,colframe = ctex@emph, + colbacktitle = white,coltitle = ctex@emph, + fonttitle = \large\sffamily,fontupper = \itshape, + boxed~title~style = {size = normal,opacityframe = 0,boxrule = 0pt}, + attach~boxed~title~to~top~center = {yshift = -\tcboxedtitleheight/2}, + arc = 3pt,boxsep = 5pt, + after~skip = 3ex, + left = 1.5pc,right = 1.5pc,top = 1pc,bottom = 0.5pc + }, + tc-exercise/.style = + { + blank,on~line,center, + fontupper = \Large\sffamily, + before~skip = 3.75ex,after~skip = 2.5ex + }, + breakable, + boxsep = 0pt, + arc = 0pt, + fonttitle = \sffamily, + boxrule = \eb@rule@width@dim + } + \newtcbox[auto~counter]{\eb@exercise@box}[1]{tc-exercise,#1} + \NewDocumentEnvironment{outline}{O{}D(){\abstractname}o+b} + { + \begin{tcolorbox}[tc-outline,title = #2,IfValueT = {#3}{#3}] + \begin{eb@outline@list}[#1] + #4 + \end{eb@outline@list} + \end{tcolorbox} + }{} + \NewDocumentEnvironment{exercise} + {st+O{LightSkyBlue}O{1.}D(){\c__eb_name_exercise_tl}o+O{}+b} + { + \IfBooleanTF{#2} + { + \eb@exercise@box + { + fuzzy~halo = 5pt~with~#3, + IfValueT = {#6}{#6}, + phantom = + \IfBooleanF{#1} + { + \markright{\thetcbcounter\hspace{0.5\ccwd}#5} + \addcontentsline{toc}{section} + {\thetcbcounter\hspace{\eb@toc@section@numsep}#5} + } + } + {\IfBooleanF{#1}{\thetcbcounter\hspace{0.5\ccwd}}#5} + }{ + \group_begin: + \ctex_set:nn { section } { format += \centering } + \IfValueT{#6}{\ctex_set:nn { section } {#6}} + \IfBooleanTF{#1}{\section*{#5}}{\section{#5}} + \group_end: + }#7 + \begin{enumerate}[#4,labelsep = 0.5\ccwd] + #8 + \end{enumerate} + }{} + \DeclareTColorBox{easybox}{sO{DarkCyan}d()O{}} + { + enhanced~jigsaw,pad~at~break* = 3pt, + IfBooleanTF = {#1} + {toptitle = 8pt,top = 8pt} + {frame~hidden,boxrule = 0pt,toptitle = 8pt,top = 0pt}, + IfValueT = {#3}{title = #3}, + colback = #2,colbacktitle = #2, + opacityback = 0.12,opacitybacktitle = 0.12, + coltitle = black,colframe = black, + left = 6pt,right = 6pt,bottom = 8pt,middle= 8pt, + bottomtitle = 8pt, + beforeafter~skip = 2ex, + halign~upper = left,halign~lower = left, + center~title,#4 + } + \DeclareTColorBox{ebparbox}{sO{Purple}d()O{}} + { + frame~hidden, + enhanced~jigsaw,pad~at~break* = 3pt, + boxrule = 0pt, + borderline~west = {3pt}{0pt}{#2}, + IfBooleanTF = {#1} + { + colback = white, + IfValueT = {#3}{title = #3}, + top = 0pt,bottom = 0pt,toptitle = 0pt + }{ + colback = #2,colbacktitle = #2, + opacityback = 0.12,opacitybacktitle = 0.12, + IfValueTF = {#3}{title = #3,top = 0pt}{top = 8pt}, + bottom = 8pt,toptitle = 8pt + }, + left = 8pt,right = 8pt,middle= 8pt, + bottomtitle = 8pt, + beforeafter~skip = 1.5ex, + colframe = #2,coltitle = #2,#4 + } + \DeclareTotalTCBox{\ebemph}{O{DarkSeaGreen}vO{}} + { + nobeforeafter,tcbox~raise~base, + blank,fuzzy~halo = 2pt~with~#1,#3 + }{#2} + \DeclareTotalTCBox{\eblink}{O{Aqua}vO{}} + { + standard~jigsaw, + nobeforeafter,tcbox~raise~base, + top = 1.25qt,bottom = 1.25qt,left = 1.25qt,right = 1.25qt, + boxrule = 0.75pt,arc = 1pt, + colback = #1,opacityback = 0.12,colframe = #1,#3 + }{#2} + } + +\bool_set_true:N \l__eb_backend_bibtex_bool +\tl_new:N \l__eb_bib_style_tl +\tl_new:N \l__eb_bib_otherstyle_tl +\tl_new:N \l__eb_bib_citestyle_tl +\tl_new:N \l__eb_bib_datafile_tl + +\eb_ctex_define:nn { bibset } + { + backend .choice:, + backend/bibtex .code:n = { }, + backend/biblatex .code:n = + { \bool_set_false:N \l__eb_backend_bibtex_bool }, + + bib-style .choice:, + bib-style .value_required:n = true, + bib-style/numerical .code:n = + { + \tl_set:Nn \l__eb_bib_style_tl {#1} + \tl_clear:N \l__eb_bib_otherstyle_tl + }, + bib-style/authoryear .code:n = + { + \tl_set:Nn \l__eb_bib_style_tl {#1} + \tl_clear:N \l__eb_bib_otherstyle_tl + }, + bib-style/unknown .code:n = + { \tl_set_eq:NN \l__eb_bib_otherstyle_tl \l_keys_value_tl }, + bib-style .initial:n = numerical, + + cite-style .code:n = + { \tl_set:Nn \l__eb_bib_citestyle_tl {#1} }, + datafile .tl_set:N = \l__eb_bib_datafile_tl, + + bitoc-title .tl_set:N = \l__eb_bib_bitoc_title, + bitoc-title .initial:n = Reference + } + +\cs_new_protected:Npn \EbBibtexSet + { + \tl_if_empty:NTF \l__eb_bib_otherstyle_tl + { + \tl_if_eq:NnT \l__eb_bib_style_tl { numerical } + { + \bibliographystyle{gbt7714-numerical} + \setcitestyle{comma,square,super} + } + \tl_if_eq:NnT \l__eb_bib_style_tl { authoryear } + { \bibliographystyle{gbt7714-author-year} } + \cs_set_eq:NN \cite \citep + } + { \exp_args:NV \bibliographystyle \l__eb_bib_otherstyle_tl } + \tl_if_empty:NF \l__eb_bib_citestyle_tl + { \exp_args:NV \setcitestyle \l__eb_bib_citestyle_tl } + \skip_zero:N \bibsep + \NewDocumentCommand{\printbibliography}{st+o} + { + \group_begin: + \tl_set_eq:NN \eb@toc@title \bibname + \IfValueT{##3}{ \keys_set:nn { eb/listoc } {##3} } + \tl_set:Nn \bibsection + { + \eb_title_number_intoc_bool:nn {##2} {##1} + \eb_multoc_pre_bool: + } + \exp_args:NV \bibliography \l__eb_bib_datafile_tl + \eb_multoc_post_bool: + \group_end: + } + } +\cs_new_protected:Npn \eb_put_biblatex:n #1 + { \PassOptionsToPackage{#1}{biblatex} } +\cs_new_protected:Npn \EbBiblatexPreset + { + \tl_if_empty:NTF \l__eb_bib_otherstyle_tl + { + \tl_if_eq:NnT \l__eb_bib_style_tl { numerical } + { \eb_put_biblatex:n { style = gb7714-2015 } } + \tl_if_eq:NnT \l__eb_bib_style_tl { authoryear } + { \eb_put_biblatex:n { style = gb7714-2015ay } } + } + { \eb_put_biblatex:n { style = \l__eb_bib_otherstyle_tl } } + \tl_if_empty:NF \l__eb_bib_citestyle_tl + { \eb_put_biblatex:n { citestyle = \l__eb_bib_citestyle_tl } } + \eb_put_biblatex:n { backend = biber } + } +\cs_new_protected:Npn \EbBiblatexPostset + { + \exp_args:NV \addbibresource \l__eb_bib_datafile_tl + \tl_gset:Nn \blx@default@theheading { bibintoc } + \defbibheading{bibintoc}[\bibname] + {\eb_biber_title_level_bool:n {##1}} + \skip_zero:N \bibitemsep + } +\eb_at_end_preamble:n + { + \tl_if_empty:NF \l__eb_bib_datafile_tl + { + \bool_if:NTF \l__eb_backend_bibtex_bool + { + \eb@package@load[sort&compress]{natbib} + \EbBibtexSet + } + { + \EbBiblatexPreset + \eb@package@load{biblatex} + \EbBiblatexPostset + } + } + } + +\lstdefinestyle{easy-listings} + { + language = [LaTeX]TeX, + texcsstyle = + { + *\lst@ifdisplaystyle + \bfseries\color{ctex@verb} + \else + \color{ctex@verb} + \fi + }, + basicstyle = + { + \ttfamily\lst@ifdisplaystyle + \small + \else + \color{ctex@verb} + \fi + }, + keywordstyle = + { + \lst@ifdisplaystyle + \bfseries\color{ctex@verb} + \else + \color{ctex@verb} + \fi + }, + framexleftmargin = 0pt, + framexrightmargin = 0pt, + xleftmargin = 3pt, + xrightmargin = 3pt, + numbersep = 10pt, + framesep = 3pt, + frame = single, + rulecolor = \color{ctex@frame}, + commentstyle = \color{SlateGray}, + emphstyle = \color{ctex@emph}, + % emph = {}, + morekeywords = + { + includegraphics,setmainfont,setsansfont,setmonofont,setCJKmainfont,setCJKsansfont,setCJKmonofont,setCJKfamilyfont,RequirePackage + } + } +\lstset + { + style = easy-listings, + breaklines = true, + resetmargins = true, + % numbers = left, + numberstyle = \footnotesize, + aboveskip = 1.5ex plus .2ex minus .1ex, + belowskip = 0.55ex plus .2ex minus .1ex, + keepspaces = true, + framerule = \eb@rule@width@dim, + columns = flexible, + abovecaptionskip = -1ex, + belowcaptionskip = 1.5ex + } +\lstloadlanguages{C,C++,Java,Python,Matlab} + +\clist_new:N \l__eb_hyperref_clist +\cs_new_protected:Npn \eb_put_hyperref:n #1 + { \clist_put_right:Nn \l__eb_hyperref_clist {#1} } +\cs_new_protected:Npn \eb_define_linkcolor:nnn #1#2#3 + { \definecolorset{HTML}{ctex@}{}{link,#1;url,#2;cite,#3} } +\cs_new_protected:Npn \eb_define_themecolor:nnn #1#2#3 + { \definecolorset{HTML}{ctex@}{}{frame,#1;emph,#2;verb,#3} } +\cs_new_protected:Npn \eb_define_linkcolor:n #1 + { \definecolorset{HTML}{ctex@}{}{link,#1;url,#1;cite,#1} } +\cs_new_protected:Npn \eb_define_themecolor:n #1 + { \definecolorset{HTML}{ctex@}{}{frame,#1;emph,#1;verb,#1} } +\cs_new:Npn \eb_linkcolor_set:n #1 + { + linkcolor/\clist_item:nn {#1} {1} .code:n = + { + \eb_define_linkcolor:nnn + { \clist_item:nn {#1} {2} } + { \clist_item:nn {#1} {3} } + { \clist_item:nn {#1} {4} } + \eb_put_hyperref:n + { + linkcolor = ctex@link,linkbordercolor = ctex@link, + urlcolor = ctex@url,urlbordercolor = ctex@url, + citecolor = ctex@cite,citebordercolor = ctex@cite + } + }, + } +\cs_new:Npn \eb_themecolor_set:n #1 + { + color/\clist_item:nn {#1} {1} .code:n = + { + \eb_define_themecolor:nnn + { \clist_item:nn {#1} {2} } + { \clist_item:nn {#1} {3} } + { \clist_item:nn {#1} {4} } + }, + } + +\bool_set_false:N \l__eb_toc_number_color_bool +\eb_ctex_define:nn { refset } + { + linktype .choice:, + linktype/edge .code:n = { }, + linktype/none .code:n = \eb_put_hyperref:n { hidelinks }, + linktype/various .code:n = + { + \bool_set_true:N \l__eb_toc_number_color_bool + \eb_put_hyperref:n { colorlinks } + }, + linktype .value_required:n = true, + linktype .initial:n = edge, + + linktoc .choice:, + linktoc/unknown .code:n = + { + \eb_put_hyperref:n { linktoc = #1 } + \clist_map_inline:nn { page,none } + { + \tl_if_eq:NnT \l_keys_value_tl {##1} + { + \clist_map_break:n + { \colorlet{ctex@toc@number}{black} } + } + } + }, + linktoc .default:n = all, + linktoc .initial:n = all, + unknown .code:n = + { + \eb_put_hyperref:x + { + \l_keys_key_str + \tl_if_empty:NF \l_keys_value_tl { = {#1} } + } + } + } +\eb_ctex_define:nx { refset } + { + linkcolor .choice:, + \clist_map_function:nN + { + { fresh, 62d71f,0000B2,005752 }, + { cutepink, ff69b4,9d5196,57b5e5 }, + { navyblue, 000080,004986,eb6877 }, + { crimson, dc143c,00c1c9,afcd20 } + } + \eb_linkcolor_set:n + linkcolor .default:n = navyblue, + linkcolor .initial:n = navyblue, + linkcol-all .code:n = + { \eb_define_linkcolor:n { \exp_not:n {#1} } } + } +\colorlet{ctex@toc@number}{ctex@link} +\eb_ctex_define:nx { style } + { + color .choice:, + color .value_required:n = true, + \clist_map_function:nN + { + { none, 000000,000000,000000 }, + { seaside, 4169e1,708090,9932cc }, + { energy, f39800,00a0e9,893895 }, + { cyberpunk, 601986,eb6877,a4005b } + } + \eb_themecolor_set:n + color .initial:n = none, + color-all .code:n = + { \eb_define_themecolor:n { \exp_not:n {#1} } } + } + +\cs_new:Npn \eb_allow_urlbreak: + { + \cs_new:Npn \eb_add_urlbreak_points: + { \tl_map_function:NN \c__eb_urlbreak_points_tl \do } + \eb_appto_cmd:Nn \UrlBreaks + { \UrlOrds\eb_add_urlbreak_points: } + } +\tl_const:Nn \c__eb_urlbreak_points_tl + { + ABCDEFGHIJKLMNOPQRSTUVWXYZ + abcdefghijklmnopqrstuvwxyz + 0123456789 + } +\ctex_at_end_preamble:n + { + \eb@package@load{hyperref} + \urlstyle{same} + \eb_allow_urlbreak: + \ctex_hypersetup:n { pdfstartview = FitH } + \exp_args:NV \hypersetup \l__eb_hyperref_clist + } + +\labelformat{part}{\CTEXthepart} +\labelformat{chapter}{\CTEXthechapter} +\labelformat{figure}{\figurename~#1} +\labelformat{table}{\tablename~#1} +\tl_if_eq:NnTF \l__ctex_scheme_tl { chinese } + { + \keys_set_known:nn { ctex } + { + contentsname = 目\hspace{\ccwd}录, + indexname = 索\hspace{\ccwd}引, + listfigurename = 图片索引, + listtablename = 表格索引, + abstractname = 摘\hspace{\ccwd}要, + lstlistlistingname = 代码索引, + lstlistingname = 代码 + } + \labelformat{equation}{式(#1)} + \labelformat{section}{节 #1} + \labelformat{subsection}{小节 #1} + } + { + \keys_set_known:nn { ctex } + { + abstractname = Abstract, + lstlistlistingname = List~of~Codes, + lstlistingname = Code + } + \labelformat{equation}{Equation~(#1)} + \labelformat{section}{Section~#1} + \labelformat{subsection}{Subsection~#1} + } +\endinput +%% +%% End of file `easybase.sty'. diff --git a/Master/texmf-dist/tex/latex/easybook/easybook.cls b/Master/texmf-dist/tex/latex/easybook/easybook.cls index 43e8a2d0679..1be9f3f00e8 100644 --- a/Master/texmf-dist/tex/latex/easybook/easybook.cls +++ b/Master/texmf-dist/tex/latex/easybook/easybook.cls @@ -12,42 +12,8 @@ %% The latest version of this license is in %% https://creativecommons.org/licenses/by/4.0/legalcode \NeedsTeXFormat{LaTeX2e}[2020/10/01] -\RequirePackage{l3keys2e,etoolbox} -\ProvidesExplClass{easybook}{2021/05/31}{1.25p}{beta} - -\cs_generate_variant:Nn \eb_ctex_define:nn { nx } -\cs_generate_variant:Nn \int_to_arabic:n { v } -\cs_generate_variant:Nn \dim_add:Nn { NV } -\cs_generate_variant:Nn \eb_put_hyperref:n { x } -\cs_generate_variant:Nn \seq_set_from_clist:Nn { No } -\cs_new_protected:Npn \eb_ctex_define:nn #1 - { \keys_define:nn { ctex/#1 } } -\cs_new_protected:Npn \eb_put_ctexbook:n #1 - { \PassOptionsToClass{#1}{ctexbook} } -\cs_new_protected:Npn \eb_patch_cmd:Nnn #1#2#3 - { - \ctex_patch_cmd_once:NnnnTF #1 { } {#2} {#3} - { } { \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \eb_preto_cmd:Nn #1#2 - { - \ctex_preto_cmd:NnnTF #1 { } {#2} - { } { \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \eb_appto_cmd:Nn #1#2 - { - \ctex_appto_cmd:NnnTF #1 { } {#2} - { } { \ctex_patch_failure:N #1 } - } -\cs_new_protected:Npn \eb_at_begin_environment:nn #1#2 - { - \seq_set_from_clist:No \l__eb_env_hook_name_seq {#1} - \seq_map_inline:Nn \l__eb_env_hook_name_seq - { \AtBeginEnvironment{##1}{#2} } - } -\cs_new_protected:Npn \eb_at_end_preamble:n - { \ctex_gadd_ltxhook:nn { env/document/before } } -\cs_gset_eq:NN \PackageWarning \use_none:nn +\RequirePackage{l3keys2e} +\ProvidesExplClass{easybook}{2021/06/02}{1.25q}{beta} \bool_set_false:N \l__eb_compile_draft_bool \bool_set_false:N \l__eb_title_newline_bool @@ -56,6 +22,8 @@ \bool_set_true:N \l__eb_class_book_bool \tl_new:N \g__eb_config_tl \clist_new:N \g__eb_options_clist +\cs_new_protected:Npn \eb_put_ctexbook:n #1 + { \PassOptionsToClass{#1}{ctexbook} } \keys_define:nn { easybook } { @@ -111,129 +79,16 @@ } \ProcessKeysOptions{easybook} - -\clist_map_inline:nn - { - { svgnames } { xcolor }, - { stable } { footmisc }, - { normalem } { ulem }, - { protrusion = false } { microtype }, - { list = off } { bicaption }, - { shortlabels,inline } { enumitem }, - { many } { tcolorbox }, - { xindy } { imakeidx }, - { CJKmath = true } { xeCJK }, - { no-math } { fontspec }, - { upint } { newtxmath } - } - { \PassOptionsToPackage #1 } \eb_put_ctexbook:n { \g__eb_options_clist } \LoadClass[UTF8]{ctexbook} -\bool_new:N \l__eb_multoc_bool -\bool_new:N \l__eb_uppercase_bool -\bool_new:N \l__eb_chap_withpart_bool -\tl_new:N \l__eb_foot_numparent_choice_tl - -\seq_const_from_clist:Nn \c__eb_options_path_seq - { - style,subfont,spread, - refset,bibset,thmset, - geoset,hdrset,tocset - } -\seq_map_inline:Nn \c__eb_options_path_seq - { - \ctex_define:n { #1 .meta:nn = { ctex/#1 } {##1} } - \cs_new:cpn {#1} ##1 { \keys_set:nn { ctex/#1 } {##1} } - } -\keys_define:nn { } { ctex/link .inherit:n = ctex/refset } -\cs_set_eq:NN \link \refset -\ctex_define:n - { - link .meta:nn = { ctex/link } {#1}, - lstlistlistingname .tl_set:N = \lstlistlistingname, - lstlistingname .tl_set:N = \lstlistingname - } -\eb_ctex_define:nn { style } - { - multoc .bool_set:N = \l__eb_multoc_bool, - multoc .default:n = true, - withpart .bool_set:N = \l__eb_chap_withpart_bool, - withpart .default:n = true, - withpart .initial:n = false, - rulewidth .dim_set:N = \l__eb_rule_width_dim, - rulewidth .initial:n = 0.75pt, - uppercase .bool_set:N = \l__eb_uppercase_bool, - uppercase .default:n = true, - uppercase .initial:n = true, - figurepath .tl_set:N = \l_eb_graphics_path_tl, - - footwith .choices:nn = - { part,page,chapter } - { - \tl_set_eq:NN - \l__eb_foot_numparent_choice_tl \l_keys_choice_tl - }, - footwith .value_required:n = true, - footwith .initial:n = chapter, - - figure-sep .tl_set:N = \l__eb_figure_separator_tl, - table-sep .tl_set:N = \l__eb_table_separator_tl, - listing-sep .tl_set:N = \l__eb_lstlisting_separator_tl, - equation-sep .tl_set:N = \l__eb_equation_separator_tl, - number-sep .meta:n = - { - figure-sep = #1, - table-sep = #1, - listing-sep = #1, - equation-sep = #1 - }, - number-sep .initial:n = { . } - } - -\RequirePackage - { - xcolor, - footmisc,setspace, - amsmath,amsthm,thmtools, - chemformula,siunitx,ulem,pifont, - geometry,marginnote,nccfoots, - pdfpages,graphicx, - fancyhdr,titletoc,caption, - tabularray, - enumitem, - listings - } +\RequirePackage{easybase} \ctex_at_end:n { \tl_if_empty:NF \g__eb_config_tl { \file_input:n { \g__eb_config_tl } } } -\cs_new_protected:Npn \eb_package_later_bool:nn #1#2 - { - \@ifpackagelater{#1}{#2} - {}{\msg_warning:nnn { easybook } { package-old } {#1}} - } -\msg_new:nnn { easybook } { package-old } - { - Package~#1~has~been~out~of~date. \\ - Some~problems~or~errors~may~occur \\ - if~you~continue~compiling. \\\\ - Please~update~your~macro~package~from~CTAN. - } -\clist_map_inline:nn - { - { expl3 } { 2020/10/27 }, - { xparse } { 2020/10/27 }, - { l3keys2e } { 2020/10/27 }, - { ctex } { 2021/03/14 }, - { thmtools } { 2020/08/01 }, - { caption } { 2020/08/24 }, - { siunitx } { 2021/05/17 } - } - { \eb_package_later_bool:nn #1 } - \sys_if_engine_xetex:TF { \cs_new_eq:NN \eb_set_family:nnn \xeCJK_set_family:nnn @@ -331,1669 +186,6 @@ \cs_new_protected:Npn \fangsong { \eb_switch_family:n { fangsong } } } -\includepdfset{fitpaper = true} -\geometry - { - vmargin = 2.54cm, - hmargin = 3.17cm, - columnsep = 2\ccwd, - headheight = 2.04cm, - headsep = 0.5cm, - footskip = 0.79cm, - footnotesep = 0.5cm, - marginparsep = 8pt, - marginparwidth = 2.54cm - } -\clist_new:N \g__eb_geometry_clist -\eb_ctex_define:nn { geoset } - { - unknown .code:n = - { - \clist_gput_right:Nx \g__eb_geometry_clist - { - \l_keys_key_str - \tl_if_empty:NF \l_keys_value_tl { = {#1} } - } - } - } - -\RenewDocumentCommand{\cleardoublepage}{O{empty}} - { - \clearpage - \bool_if:NT \l__eb_page_twoside_bool - { - \int_if_odd:nF { \c@page } - { \hbox:n { }\thispagestyle{#1}\clearpage } - } - } -\RenewDocumentCommand{\frontmatter}{sO{Roman}} - { - \IfBooleanTF{#1}{\clearpage}{\cleardoublepage} - \boolfalse{@mainmatter} - \pagenumbering{#2} - } -\RenewDocumentCommand{\mainmatter}{s} - { - \IfBooleanTF{#1}{\clearpage}{\cleardoublepage} - \booltrue{@mainmatter} - \pagenumbering{arabic} - } -\seq_const_from_clist:Nn \c__eb_mark_title_level_seq - { chapter,section,subsection } -\seq_map_inline:Nn \c__eb_mark_title_level_seq - { - \exp_args:Nc \NewDocumentCommand { eb@mark@#1@label@layout } - {O{\use:c { CTEXthe#1 }}m} - {\tl_set:cn { eb@mark@#1@label } {##1##2}} - \cs_new:cpn { eb_mark_#1_number_bool:n } ##1 - { - \tl_if_in:nnTF {##1} { [ } - { \use:c { eb@mark@#1@label@layout } ##1 } - { \use:c { eb@mark@#1@label@layout } {##1} } - } - } - -\cs_gset_eq:NN \easyhead \fancyhead -\cs_gset_eq:NN \easyfoot \fancyfoot -\eb_ctex_define:nn { hdrset } - { - head-foot .tl_set:N = \l__eb_fancyhf_content_tl, - head-foot .initial:n = - { - \bool_if:NTF \l__eb_page_twoside_bool - { - \easyhead[EC]{\color{ctex@frame}\kaishu\leftmark} - \easyhead[OC]{\color{ctex@frame}\kaishu\rightmark} - \easyhead[EL,OR]{\color{ctex@frame}\thepage} - } - { - \easyhead[L]{\color{ctex@frame}\kaishu\leftmark} - \easyhead[R]{\color{ctex@frame}\thepage} - } - }, - - chap-mark .cs_set:Np = \eb_fancyhf_chapter_mark:n #1, - chap-mark .initial:n = - { - \int_compare:nNnT { \c@secnumdepth } > { -1 } - { - \ifbool{@mainmatter} - { - \int_if_odd:nT { \CTEX@chapter@numbering } - { \eb@mark@chapter@label } - }{} - }#1 - }, - sec-mark .cs_set:Np = \eb_fancyhf_section_mark:n #1, - sec-mark .initial:n = - { - \int_compare:nNnT { \c@secnumdepth } > { 0 } - { - \int_if_odd:nT { \CTEX@section@numbering } - { \eb@mark@section@label } - }#1 - }, - subsec-mark .cs_set:Np = \eb_fancyhf_subsection_mark:n #1, - subsec-mark .initial:n = - { - \int_compare:nNnT { \c@secnumdepth } > { 1 } - { - \int_if_odd:nT { \CTEX@subsection@numbering } - { \eb@mark@subsection@label } - }#1 - }, - chap-label .code:n = \eb_mark_chapter_number_bool:n {#1}, - chap-label .initial:n = \hspace{\ccwd}, - sec-label .code:n = \eb_mark_section_number_bool:n {#1}, - sec-label .initial:n = \hspace{0.5\ccwd}, - subsec-label .code:n = \eb_mark_subsection_number_bool:n {#1}, - subsec-label .initial:n = \hspace{0.5\ccwd}, - - headrule .tl_gset:N = \headrule, - headrule .initial:n = - { - \group_begin: - \color{ctex@frame}\vspace*{1.5pt} - \hrule width \textwidth height \l__eb_rule_width_dim - \group_end: - }, - footrule .tl_gset:N = \footrule, - footrule .initial:n = { }, - footnoterule .tl_gset:N = \footnoterule, - footnoterule .initial:n = - { - \group_begin: - \color{ctex@frame} - \hrule width 0.35\columnwidth height \l__eb_rule_width_dim - \vspace*{2.6pt} - \group_end: - }, - - fnmargin .dim_set:N = \footnotemargin, - fnmargin .initial:n = 0.75\ccwd, - fnparskip .tl_set:N = \hangfootparskip, - fnparskip .initial:n = 0ex, - fnparindent .tl_set:N = \hangfootparindent, - fnparindent .initial:n = 2\ccwd, - - fnhang .bool_set:N = \l__eb_footnote_hang_bool, - fnhang .default:n = true, - fnhang .initial:n = true, - fnmark-pos .tl_set:N = \l__eb_fnmark_position_tl, - fnmark-pos .initial:n = super, - afterfnmark .tl_set:N = \l__eb_fnmark_after_tl, - afterfnmark .initial:n = - { \tl_if_eq:NnF \l__eb_fnmark_position_tl { super } { \space } }, - fnmark-form .tl_set:N = \l__eb_fnmark_format_tl, - - fnmark-num .choices:nn = - { plain,pifont,pifont*,pifont-sans,pifont-sans* } - { - \tl_gset_eq:NN - \l__eb_fnmark_number_choice_tl \l_keys_choice_tl - }, - fnmark-num .value_required:n = true - } - -\cs_new:Npn \eb_upper_number_mark_bool:nn #1#2 - { - \bool_if:NT \l__eb_uppercase_bool - { \text_uppercase:n } {\use:c { eb_fancyhf_#1_mark:n } {#2}} - } -\cs_new:Npn \eb@number@markdouble #1#2 - { - \markboth - {\eb_upper_number_mark_bool:nn {#1} {#2}} - { - \bool_if:NT \l__eb_page_twoside_bool - { \eb_upper_number_mark_bool:nn {#1} {#2} } - } - } -\cs_new:Npn \eb@number@markright #1#2 - { \markright{\eb_upper_number_mark_bool:nn {#1} {#2}} } -\ctex_at_end_preamble:n - { - \exp_args:NV \geometry \g__eb_geometry_clist - \fancyhf{} - \tl_use:N \l__eb_fancyhf_content_tl - \cs_gset_eq:NN \ps@plain \ps@empty - \pagestyle{fancy} - \bool_if:NTF \l__eb_class_book_bool - { - \cs_gset:Npn \chaptermark #1 - { \eb@number@markdouble{chapter}{#1} } - \cs_gset:Npn \sectionmark #1 - { \eb@number@markright{section}{#1} } - } - { - \cs_gset:Npn \sectionmark #1 - { \eb@number@markdouble{section}{#1} } - \cs_gset:Npn \subsectionmark #1 - { \eb@number@markright{subsection}{#1} } - } - \bool_if:NT \l__eb_compile_draft_bool - { - \easyfoot[C]{\color{SlateGray}\sffamily\today} - \geometry{showframe} - } - \tl_if_empty:NF \l_eb_graphics_path_tl - { \exp_args:No \graphicspath { \l_eb_graphics_path_tl } } - \cs_if_exist:NF \kaishu { \cs_gset_eq:NN \kaishu \itshape } - } - -\eb_at_end_preamble:n - { - \group_begin: - \footnotesize - \exp_args:Nx - \linespread{\fp_use:N \l__eb_spread_footnote_fp}\selectfont - \exp_args:NNNo \group_end: - \dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox } - \bool_if:NT \l__eb_chap_withpart_bool - { \counterwithin*{chapter}{part} } - \tl_if_eq:NnT \l__eb_foot_numparent_choice_tl { part } - { - \counterwithout*{footnote}{chapter} - \counterwithin*{footnote}{part} - } - \tl_if_eq:NnT \l__eb_foot_numparent_choice_tl { page } - { - \counterwithout*{footnote}{chapter} - \counterwithin*{footnote}{page} - } - \bool_if:NTF \l__eb_footnote_hang_bool - { \booltrue{FN@hangfoot} } { \boolfalse{FN@hangfoot} } - } -\eb_patch_cmd:Nnn \@footnotetext - { \reset@font } - { - \linespread{\fp_use:N \l__eb_spread_footnote_fp} - \selectfont\ignorespaces - \l__eb_subfont_footnote_tl - } -\eb_patch_cmd:Nnn \@mpfootnotetext - { \reset@font } - { - \linespread{\fp_use:N \l__eb_spread_footnote_fp} - \selectfont\ignorespaces - \l__eb_subfont_footnote_tl - } -\ctex_after_end_preamble:n - { - \ExplSyntaxOn\char_set_catcode_letter:N \@ - \eb_patch_cmd:Nnn \@footnotemark - { \@makefnmark } - { - \tl_use:N \l__eb_subfont_footnote_tl - \tl_use:N \l__eb_fnmark_format_tl - {\hbox:n { \textsuperscript{\@thefnmark} }} - } - \ExplSyntaxOff\char_set_catcode_other:N \@ - } -\cs_set:Npn \@makefnmark - { - \tl_use:N \l__eb_subfont_footnote_tl - \tl_use:N \l__eb_fnmark_format_tl - { - \hbox:n - { - \tl_if_eq:NnT \l__eb_fnmark_position_tl { super } - { \textsuperscript }{\@thefnmark} - \tl_use:N \l__eb_fnmark_after_tl - } - } - } -\cs_set:Npn \thefootnote { \eb_footnote_counter:N \c@footnote } -\cs_set:Npn \thempfootnote { \int_to_alph:n { \c@mpfootnote } } - -\cs_new_protected:Npn \eb_fnmark_number_set:nn #1#2 - { \tl_const:cn { c__eb_fnmark_number_#1_tl } {#2} } -\clist_map_inline:nn - { - { plain } { plain }, - { pifont } { pifont }, - { pifont_neg } { pifont* }, - { pifont_sans } { pifont-sans }, - { pifont_sans_neg } { pifont-sans* } - } - { \eb_fnmark_number_set:nn #1 } -\cs_new:Npn \eb_fnmark_counter_pifont:N #1 - { \ding{\int_eval:n { 171 + #1 }} } -\cs_new:Npn \eb_fnmark_counter_pifont_neg:N #1 - { \ding{\int_eval:n { 181 + #1 }} } -\cs_new:Npn \eb_fnmark_counter_pifont_sans:N #1 - { \ding{\int_eval:n { 191 + #1 }} } -\cs_new:Npn \eb_fnmark_counter_pifont_sans_neg:N #1 - { \ding{\int_eval:n { 201 + #1 }} } -\cs_new:Npn \eb_footnote_counter:N #1 - { - \tl_case:NnF \l__eb_fnmark_number_choice_tl - { - \c__eb_fnmark_number_plain_tl - { \int_use:N #1 } - \c__eb_fnmark_number_pifont_tl - { \eb_fnmark_counter_pifont:N #1 } - \c__eb_fnmark_number_pifont_neg_tl - { \eb_fnmark_counter_pifont_neg:N #1 } - \c__eb_fnmark_number_pifont_sans_tl - { \eb_fnmark_counter_pifont_sans:N #1 } - \c__eb_fnmark_number_pifont_sans_neg_tl - { \eb_fnmark_counter_pifont_sans_neg:N #1 } - } - { \int_use:N #1 } - } - -\contentsuse{lstlisting}{lol} -\seq_const_from_clist:Nn \c__eb_toc_heading_level_seq - { part,chapter,section,subsection,figure,table,lstlisting } -\cs_new_protected:Npn \eb_toc_assign_keys:n #1 - { - \ctex_define:n { tocset/#1 .meta:nn = { ctex/tocset/#1 } {##1} } - \eb_ctex_define:nn { tocset } - { - #1/format .tl_set:c = l__eb_toc_#1_format_tl, - #1/format+ .code:n = - { \tl_put_right:cn { l__eb_toc_#1_format_tl } {##1} }, - #1/format~+ .code:n = - { \tl_put_right:cn { l__eb_toc_#1_format_tl } {##1} }, - #1/indent .tl_set:c = l__eb_toc_#1_indent_tl, - #1/rule .tl_set:c = l__eb_toc_#1_rule_tl, - #1/numsep .tl_set:c = eb@toc@#1@numsep - } - \seq_if_in:NnF \c__eb_toc_heading_level_seq { subsection } - { - \eb_ctex_define:nn { tocset } - { #1/belowoffset .dim_set:c = l__eb_toc_#1_offset_dim } - } - \seq_pop:NN \c__eb_toc_heading_level_seq \l_tmpa_tl - \titlecontents{#1} - [\use:c { l__eb_toc_#1_indent_tl }] - {\use:c { l__eb_toc_#1_format_tl }} - { - \ifbool{eb@titletoc@hang@fix} - { - \contentspush - { - \bool_if:NT \l__eb_toc_number_color_bool - { \color{ctex@toc@number} } - \thecontentslabel - \hspace{\use:c { eb@toc@#1@numsep }} - } - }{} - }{} - {\use:c { l__eb_toc_#1_rule_tl }} - } -\seq_map_function:NN -\c__eb_toc_heading_level_seq \eb_toc_assign_keys:n - -\seq_const_from_clist:Nn \c__eb_toc_list_meta_keys_seq - { format,format+,format~+,indent,rule,numsep,belowoffset } -\ctex_define:n { tocset/list .meta:nn = { ctex/tocset/list } {#1} } -\seq_map_inline:Nn \c__eb_toc_list_meta_keys_seq - { - \eb_ctex_define:nn { tocset } - { - list/#1 .meta:n = - { - figure/#1 = ##1, - table/#1 = ##1, - lstlisting/#1 = ##1 - } - } - } - -\cs_new:Npn \EbNumberLine #1 - { - \CTEXifname - { - \use:c { CTEXthe#1 } - \hspace{\use:c { eb@toc@#1@numsep }} - }{} - } -\newbool{eb@titletoc@hang@fix} -\eb_ctex_define:nn { tocset } - { - lolskip .skip_set:N = \l__eb_toc_lolskip_skip, - lolskip .initial:n = 0.8pc, - - belowoffset .dim_set:N = \l__eb_toc_offset_dim, - belowoffset .initial:n = - { \bool_if:NTF \l__eb_class_book_bool { -1pc } { -0.35pc } }, - tocline-fig .cs_set:Np = \eb@labelname@lof #1, - tocline-fig .initial:n = - { - \figurename\space #1 - \notbool{eb@titletoc@hang@fix} - {\hspace{\eb@toc@figure@numsep}}{} - }, - tocline-tab .cs_set:Np = \eb@labelname@lot #1, - tocline-tab .initial:n = - { - \tablename\space #1 - \notbool{eb@titletoc@hang@fix} - {\hspace{\eb@toc@table@numsep}}{} - }, - tocline-lst .tl_set:N = \eb@labelname@lol, - tocline-lst .initial:n = - { - \lstlistingname\space\thelstlisting - \notbool{eb@titletoc@hang@fix} - {\hspace{\eb@toc@lstlisting@numsep}}{} - }, - line-align .bool_set:N = \l__eb_toc_line_align_bool, - line-align .default:n = true, - line-align .initial:n = true, - - hang .choice:, - hang/true .code:n = - { - \booltrue{eb@titletoc@hang@fix} - \ctex_set:n - { - chapter/tocline = \CTEXnumberline{##1}##2, - section/tocline = \CTEXnumberline{##1}##2, - subsection/tocline = \CTEXnumberline{##1}##2 - } - }, - hang/false .code:n = - { - \ctex_set:n - { - chapter/tocline = \EbNumberLine{##1}##2, - section/tocline = \EbNumberLine{##1}##2, - subsection/tocline = \EbNumberLine{##1}##2 - } - }, - hang .default:n = true, - hang .initial:n = false, - - numsep-all .meta:n = - { - part/numsep = #1, - chapter/numsep = #1, - section/numsep = #1, - subsection/numsep = #1, - list/numsep = #1 - }, - numsep-all .initial:n = \ccwd, - indent-all .meta:n = - { - part/indent = #1, - chapter/indent = #1, - section/indent = #1, - subsection/indent = #1, - list/indent = #1 - }, - rule-all .meta:n = - { - part/rule = #1, - chapter/rule = #1, - section/rule = #1, - subsection/rule = #1, - list/rule = #1 - } - } - -\NewDocumentCommand{\tocrule}{sO{0.7pc}D(){1.2}mO{}} - { - \normalsize\normalfont - \titlerule*[#2]{\scalebox{#3}{#4}}#5 - \IfBooleanTF{#1} - {\thecontentspage} - { - \bool_if:NTF \l__eb_toc_line_align_bool - { \contentspage } { \thecontentspage } - } - } -\ctex_set:nn { tocset } - { - part/format = \addvspace{1pc}\sffamily\large, - part/indent = 0\ccwd, - part/rule = \tocrule{}[\bfseries], - - chapter/format = \addvspace{1pc}\sffamily\large, - chapter/indent = 0\ccwd, - chapter/rule = \tocrule{$\cdot$}[\bfseries], - - section/format = \addvspace{0.35pc}, - section/indent = - { \bool_if:NTF \l__eb_class_book_bool { 1.5\ccwd } { 0\ccwd } }, - section/rule = \tocrule{$\cdot$}, - - subsection/format = \addvspace{0.35pc}, - subsection/indent = - { \bool_if:NTF \l__eb_class_book_bool { 3.8\ccwd } { 1.4\ccwd } }, - subsection/rule = \tocrule{$\cdot$}, - - list/format = \addvspace{0.2pc}, - list/indent = 0\ccwd, - list/rule = \tocrule{$\cdot$}, - list/belowoffset = - { \bool_if:NTF \l__eb_class_book_bool { 0pc } { 0.15pc } } - } - -\prop_new:N \l__eb_label_name_prop -\prop_set_from_keyval:Nn \l__eb_label_name_prop - { - figure = \eb@labelname@lof, - table = \eb@labelname@lot - } -\cs_gset:Npn \caption@@@addcontentsline #1#2#3#4 - { - \addcontentsline{#1}{#2} - { - \ifbool{eb@titletoc@hang@fix}{\protect\numberline}{} - {\prop_item:Nn \l__eb_label_name_prop {#2}{#3}}#4 - } - } -\ctex_patch_cmd:Nnn \lst@MakeCaption - { - \addcontentsline{lol}{lstlisting} - {\protect\numberline{\thelstlisting}\lst@@caption} - } - { - \addcontentsline{lol}{lstlisting} - { - \ifbool{eb@titletoc@hang@fix}{\protect\numberline}{} - {\eb@labelname@lol}\lst@@caption - } - } - -\contentsuse{}{tec} -\cs_set_protected:Npn \CTEX@addbitocline #1#2 - { - \group_begin: - \def\CTEX@prechapter{\CTEX@prebichapter} - \def\CTEX@thechapter{\CTEX@bichapter@number} - \def\CTEX@postchapter{\CTEX@postbichapter} - \addcontentsline{tec}{#1} - {\use:c { CTEX@#1@tocline }{#1}{#2}} - \group_end: - } -\seq_const_from_clist:Nn \c__eb_bitoc_title_level_seq - { chapter,section,subsection } -\seq_map_inline:Nn \c__eb_bitoc_title_level_seq - { - \exp_args:Nc \NewDocumentCommand {bi#1}{sO{##3}mm} - { - \IfBooleanTF{##1} - { - \use:c {#1}*{\phantomsection ##3} - \CTEX@addtocline{#1}{##2} - \tl_if_empty:oF {##4} { \CTEX@addbitocline{#1}{##4} } - }{ - \use:c {#1}[##2]{##3} - \tl_if_empty:oF {##4} { \CTEX@addbitocline{#1}{##4} } - } - } - } - -\eb_appto_cmd:Nn \@chapter - { - \skip_if_eq:nnF { \l__eb_toc_lolskip_skip } { \c_zero_skip } - { - \addtocontents{lol} - {\protect\addvspace{\skip_use:N \l__eb_toc_lolskip_skip}} - } - \bool_if:NF \l__eb_class_book_bool - { \msg_error:nn { easybook } { no-chapter } } - } -\eb_appto_cmd:Nn \@schapter - { - \bool_if:NF \l__eb_class_book_bool - { \msg_error:nn { easybook } { no-chapter } } - } -\msg_new:nnn { easybook } { no-chapter } - { - Your~document~class~is~in~article~mode. \\ - The~\string\chapter\space~command~will~not~be~used. - } - -\tl_set:Nn \l__eb_toc_type_tl { book } -\tl_new:N \eb@bitoc@title -\keys_define:nn { eb/listoc } - { - article .code:n = \tl_set:Nn \l__eb_toc_type_tl { article }, - book .code:n = { }, - multoc .bool_set:N = \l__eb_multoc_bool, - multoc .default:n = true, - multoc .initial:n = false, - title .code:n = \eb_assign_toc_title:n {#1} - } -\bool_if:NTF \l__eb_class_book_bool - { \keys_define:nn { } { eb/listoc .inherit:n = ctex/chapter } } - { \keys_define:nn { } { eb/listoc .inherit:n = ctex/section } } -\NewDocumentCommand{\eb_assign_toc_title:n} - {>{\SplitArgument{1}{,}}m} - {\eb_assign_toc_title_judge:nn #1} -\cs_new_protected:Npn \eb_assign_toc_title_judge:nn #1#2 - { - \tl_set:Nn \eb@toc@title {#1} - \tl_if_novalue:nTF {#2} - { \tl_clear:N \eb@bitoc@title } - { \tl_set:Nn \eb@bitoc@title {#2} } - } - -\cs_new:Npn \eb_upper_nonumber_mark_bool:n #1 - { - \bool_if:NTF \l__eb_uppercase_bool - { \text_uppercase:n {#1} } - { \text_titlecase_first:n {#1} } - } -\cs_new:Npn \eb@nonumber@markdouble #1 - { - \markboth - {\eb_upper_nonumber_mark_bool:n {#1}} - { - \bool_if:NT \l__eb_page_twoside_bool - { \eb_upper_nonumber_mark_bool:n {#1} } - } - } -\cs_new:Npn \eb@nonumber@markright #1 - { \markright{\eb_upper_nonumber_mark_bool:n {#1}} } - -\cs_new_protected:Npn \eb_title_mark_intoc:n #1 - { - \tl_if_eq:NnTF \l__eb_toc_type_tl { book } - { - \bichapter*{#1}{\eb@bitoc@title} - \eb@nonumber@markdouble{#1} - } - { - \bisection*{#1}{\eb@bitoc@title} - \bool_if:NTF \l__eb_class_book_bool - { \eb@nonumber@markright{#1} } - { \eb@nonumber@markdouble{#1} } - } - } -\cs_new_protected:Npn \eb_title_mark_notoc:n #1 - { - \tl_if_eq:NnTF \l__eb_toc_type_tl { book } - { - \chapter*{\phantomsection #1} - \eb@nonumber@markdouble{#1} - } - { - \section*{\phantomsection #1} - \bool_if:NTF \l__eb_class_book_bool - { \eb@nonumber@markright{#1} } - { \eb@nonumber@markdouble{#1} } - } - } -\cs_new_protected:Npn \eb_title_number_intoc_bool:nn #1#2 - { - \IfBooleanTF{#1} - { - \tl_if_eq:NnTF \l__eb_toc_type_tl { book } - { \bichapter{\eb@toc@title}{\eb@bitoc@title} } - { \bisection{\eb@toc@title}{\eb@bitoc@title} } - }{ - \IfBooleanTF{#2} - {\eb_title_mark_notoc:n {\eb@toc@title}} - {\eb_title_mark_intoc:n {\eb@toc@title}} - } - } -\cs_new_protected:Npn \eb_biber_title_level_bool:n #1 - { - \bool_if:NTF \l__eb_class_book_bool - { \bichapter*{#1}{\l__eb_bib_bitoc_title} } - { \bisection*{#1}{\l__eb_bib_bitoc_title} } - \eb@nonumber@markdouble{#1} - } -\cs_new_protected:Npn \eb_multoc_pre_bool: - { - \bool_if:NTF \l__eb_class_book_bool - { - \ifbool{@twocolumn} - { - \booltrue{@restonecol} - \bool_if:NF \l__eb_multoc_bool { \onecolumn } - }{ - \boolfalse{@restonecol} - \bool_if:NT \l__eb_multoc_bool { \twocolumn } - } - } - { \tl_set:Nn \l__eb_toc_type_tl { article } } - } -\cs_new_protected:Npn \eb_multoc_post_bool: - { - \bool_if:NT \l__eb_class_book_bool - { \ifbool{@restonecol}{\twocolumn}{\onecolumn} } - } -\RenewDocumentCommand{\tableofcontents}{t+oD(){}} - { - \group_begin: - \tl_set_eq:NN \eb@toc@title \contentsname - \tl_set:Nn \eb@bitoc@title { Contents } - \IfValueT{#2}{\keys_set:nn { eb/listoc } {#2}} - \eb_multoc_pre_bool: - \eb_title_mark_notoc:n { \eb@toc@title } - \vspace*{\dim_use:N \l__eb_toc_offset_dim} - \@starttoc{toc}#3 - \IfBooleanT{#1} - { - \eb_title_mark_notoc:n { \eb@bitoc@title } - \vspace*{\dim_use:N \l__eb_toc_offset_dim} - \@starttoc{tec} - } - \eb_multoc_post_bool: - \group_end: - } -\RenewDocumentCommand{\listoffigures}{st+o} - { - \group_begin: - \tl_set_eq:NN \eb@toc@title \listfigurename - \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} - \eb_multoc_pre_bool: - \eb_title_number_intoc_bool:nn {#2} {#1} - \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_figure_offset_dim - \vspace*{\dim_use:N \l__eb_toc_offset_dim} - \@starttoc{lof} - \eb_multoc_post_bool: - \group_end: - } -\RenewDocumentCommand{\listoftables}{st+o} - { - \group_begin: - \tl_set_eq:NN \eb@toc@title \listtablename - \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} - \eb_multoc_pre_bool: - \eb_title_number_intoc_bool:nn {#2} {#1} - \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_table_offset_dim - \vspace*{\dim_use:N \l__eb_toc_offset_dim} - \@starttoc{lot} - \eb_multoc_post_bool: - \group_end: - } -\NewDocumentCommand{\listoflistings}{st+o} - { - \group_begin: - \tl_set_eq:NN \eb@toc@title \lstlistlistingname - \IfValueT{#3}{\keys_set:nn { eb/listoc } {#3}} - \eb_multoc_pre_bool: - \eb_title_number_intoc_bool:nn {#2} {#1} - \dim_add:NV \l__eb_toc_offset_dim \l__eb_toc_lstlisting_offset_dim - \vspace*{\dim_use:N \l__eb_toc_offset_dim} - \@starttoc{lol} - \eb_multoc_post_bool: - \group_end: - } - -\ctex_at_end_package:nn { imakeidx } - { - \makeindex[ - options = -M~texindy~-C~utf8, - program = truexindy, - columns = 2, - columnsep = 2\ccwd - ] - \RenewDocumentCommand{\printindex}{st+D(){\imki@jobname}o} - { - \group_begin: - \tl_set_eq:NN \eb@toc@title \indexname - \cs_set_eq:NN \imki@indexlevel \use_none:n - \setkeys{imki}{intoc = false} - \IfValueT{#4}{\keys_set:nn { eb/listoc } {#4}} - \bool_if:NF \l__eb_class_book_bool - { \tl_set:Nn \l__eb_toc_type_tl { article } } - \tl_set:Nn \imki@indexheaders - { - \eb_title_number_intoc_bool:nn {#2} {#1} - \cs_set_eq:NN \thispagestyle \use_none:n - \cs_undefine:N \imki@firstpagestyle - } - \imki@putindex{#3} - \group_end: - } - } - -\eb_ctex_define:nn { chapter } - { - biname .code:n = - { \ctex_assign_heading_name:nn { bichapter } {#1} }, - biname .initial:n = Chapter\space, - binmuber .tl_set:N = \CTEX@bichapter@number, - binmuber .initial:n = \arabic{chapter} - } -\RenewDocumentCommand{\appendix} - {O{Appendix\space}D(){\Alph{chapter}}} - { - \ctex_assign_heading_name:nn { biappendix } {#1} - \int_compare:nNnTF { \c@chapter } > { 0 } - { - \ExplSyntaxOn\char_set_catcode_letter:N \@ - \eb_patch_cmd:Nnn \CTEX@addbitocline - { - \def\CTEX@prechapter{\CTEX@prebichapter} - \def\CTEX@thechapter{\CTEX@bichapter@number} - \def\CTEX@postchapter{\CTEX@postbichapter} - } - { - \def\CTEX@prechapter{\CTEX@prebiappendix} - \def\CTEX@thechapter{#2} - \def\CTEX@postchapter{\CTEX@postbiappendix} - } - \ExplSyntaxOff\char_set_catcode_other:N \@ - \setcounter{chapter}{0} - \setcounter{section}{0} - \gdef\thechapter{\@Alph\c@chapter} - \gdef\CTEX@prechapter{\CTEX@preappendix} - \gdef\CTEX@thechapter{\CTEX@appendix@number} - \gdef\CTEX@postchapter{\CTEX@postappendix} - \gdef\CTEX@chapter@numbering{\CTEX@appendix@numbering} - } - { - \setcounter{section}{0} - \setcounter{subsection}{0} - \gdef\thesection{\@Alph\c@section} - \gdef\CTEX@presection{\CTEX@preappendix} - \gdef\CTEX@thesection{\CTEX@appendix@number} - \gdef\CTEX@postsection{\CTEX@postappendix} - \gdef\CTEX@section@numbering{\CTEX@appendix@numbering} - \ctex_set:nn { appendix } { number = \@Alph\c@section,name = { } } - } - } - -\tl_new:N \l__eb_subfont_table_tl -\tl_new:N \l__eb_subfont_figure_tl -\tl_new:N \l__eb_subfont_listing_tl -\tl_new:N \l__eb_subfont_footnote_tl - -\seq_const_from_clist:Nn \c__eb_subfont_math_choice_seq - { - noto,notosans,times,scholax,stix, - charter,ebgaramond,libertine,none - } -\seq_map_inline:Nn \c__eb_subfont_math_choice_seq - { \tl_const:cn { c__eb_subfont_math_#1_tl } {#1} } - -\eb_ctex_define:nn { subfont } - { - table-cap .tl_set:N = \l__eb_subfont_table_tl, - table-cap .initial:n = \sffamily\small, - figure-cap .tl_set:N = \l__eb_subfont_figure_tl, - figure-cap .initial:n = \sffamily\small, - listing-cap .tl_set:N = \l__eb_subfont_listing_tl, - listing-cap .initial:n = \sffamily\small, - footnote .tl_set:N = \l__eb_subfont_footnote_tl, - footnote .initial:n = \rmfamily, - marginpar .tl_set:N = \marginfont, - marginpar .initial:n = \rmfamily\footnotesize, - - math .choices:xn = - { \seq_use:Nn \c__eb_subfont_math_choice_seq { , } } - { - \tl_gset_eq:NN - \l__eb_subfont_math_choice_tl \l_keys_choice_tl - }, - math .value_required:n = true, - math .initial:n = noto - } - -\cs_new_protected:Npn \eb_put_newtxmath:n #1 - { \PassOptionsToPackage{#1}{newtxmath} } -\eb_at_end_preamble:n - { - \tl_case:NnT \l__eb_subfont_math_choice_tl - { - \c__eb_subfont_math_noto_tl - { \eb_put_newtxmath:n { noto } } - \c__eb_subfont_math_notosans_tl - { \eb_put_newtxmath:n { notosans } } - \c__eb_subfont_math_ebgaramond_tl - { \eb_put_newtxmath:n { ebgaramond } } - \c__eb_subfont_math_times_tl - { \eb_put_newtxmath:n { noOT1 } } - \c__eb_subfont_math_libertine_tl - { \eb_put_newtxmath:n { libertine,noOT1 } } - \c__eb_subfont_math_stix_tl - { \eb_put_newtxmath:n { stix2,noOT1 } } - \c__eb_subfont_math_scholax_tl - { \eb_put_newtxmath:n { nc,noOT1 } } - \c__eb_subfont_math_charter_tl - { \eb_put_newtxmath:n { charter,noOT1 } } - } - { \RequirePackage{newtxmath,bm} } - } - -\fp_new:N \l__eb_spread_line_fp -\fp_new:N \l__eb_spread_table_fp -\fp_new:N \l__eb_spread_math_fp -\fp_new:N \l__eb_spread_caption_fp -\fp_new:N \l__eb_spread_footnote_fp - -\eb_ctex_define:nn { spread } - { - line .fp_set:N = \l__eb_spread_line_fp, - line .initial:n = 1.3, - table .fp_set:N = \l__eb_spread_table_fp, - table .initial:n = 1.05, - math .fp_set:N = \l__eb_spread_math_fp, - math .initial:n = 1.05, - caption .fp_set:N = \l__eb_spread_caption_fp, - caption .initial:n = 1, - footnote .fp_set:N = \l__eb_spread_footnote_fp, - footnote .initial:n = 1, - spread-all .meta:n = - { - line = #1, - table = #1, - math = #1, - caption = #1, - footnote = #1 - } - } - -\DeclareCaptionLabelSeparator{ccwd}{\hspace{\ccwd}} -\DeclareCaptionLabelFormat{parens}{\bothIfFirst{#1}{~}(#2)} -\DeclareCaptionFont{eb@table@font}{\l__eb_subfont_table_tl} -\DeclareCaptionFont{eb@figure@font}{\l__eb_subfont_figure_tl} -\DeclareCaptionFont{eb@listing@font}{\l__eb_subfont_listing_tl} -\captionsetup - { - format = hang, - font = {stretch = \fp_use:N \l__eb_spread_caption_fp}, - labelfont = {color = ctex@frame}, - labelsep = ccwd, - singlelinecheck = true, - belowskip = 0pt, - aboveskip = 10pt - } -\captionsetup[table]{font += eb@table@font} -\captionsetup[figure]{font += eb@figure@font} -\captionsetup[lstlisting]{font += eb@listing@font} -\captionsetup[subfigure] - { - labelformat = parens, - font+ = eb@figure@font, - belowskip = 2pt, - aboveskip = 6pt - } -\ctex_at_end_package:nn { bicaption } - { - \captionsetup[figure][bi-second]{name = Figure} - \captionsetup[table][bi-second]{name = Table} - } -\prop_gset_from_keyval:Nn \g__tblr_default_tblr_table_prop - { stretch = \fp_use:N \l__eb_spread_table_fp } -\SetTblrDefault{rows = {abovesep = 4pt,belowsep = 2pt}} -\eb_at_begin_environment:nn { tabular,tabularx } - { - \exp_args:Nx \linespread { \fp_use:N \l__eb_spread_table_fp } - \selectfont\ignorespaces - } -\ctex_after_end_preamble:n - { - \exp_args:Nx \linespread { \fp_use:N \l__eb_spread_line_fp } - \selectfont\ignorespaces - } - -\cs_new:Npn \eb_arabic:n #1 { \int_to_arabic:v { c@#1 } } -\cs_gset:cpn { thesection } - { - \int_compare:nNnT { \c@chapter } > { 0 } { \thechapter. } - \eb_arabic:n { section } - } -\seq_const_from_clist:Nn \c__eb_serial_number_counter_seq - { figure,table,lstlisting,equation } -\seq_map_inline:Nn \c__eb_serial_number_counter_seq - { - \cs_set:cpn { the#1 } - { - \int_compare:nNnT { \c@chapter } > { 0 } - { - \thechapter - \use:c { l__eb_#1_separator_tl } - } - \eb_arabic:n {#1} - } - } - -\skip_set:Nn \parskip { 0pt plus 2pt minus 1pt } -\skip_set:Nn \floatsep { 12pt plus 2pt minus 2pt } -\skip_set:Nn \intextsep { 14pt plus 2pt minus 2pt } -\skip_set:Nn \textfloatsep { 16pt plus 2pt minus 4pt } -\skip_set:Nn \dbltextfloatsep { 16pt plus 2pt minus 4pt } -\skip_set:Nn \@fpsep { 8pt plus 2.0fil } -\setcounter{topnumber}{4} -\setcounter{bottomnumber}{4} -\setcounter{totalnumber}{8} -\tl_gset:Nn \textfraction { 0.18 } -\tl_gset:Nn \topfraction { 0.85 } -\tl_gset:Nn \bottomfraction { 0.65 } -\tl_gset:Nn \floatpagefraction { 0.60 } -\tl_gset:Nn \ULthickness { 0.75pt } -\allowdisplaybreaks[4] -\DeclareGraphicsExtensions{.pdf,.png,.jpg,.eps,.tif} - -\cs_new_protected:Npn \eb_enumitem_label_set:nn #1#2 - { \SetEnumitemValue{label}{#1}{\color{ctex@emph}#2} } -\clist_map_inline:nn - { - { bullet } { \textbullet }, - { endash } { \normalfont\bfseries\textendash }, - { asterisk } { \textasteriskcentered }, - { arabic } { \arabic*. }, - { alph } { (\alph*) }, - { roman } { \roman*. }, - { outline } { \upshape\ding{111} } - } - { \eb_enumitem_label_set:nn #1 } -\SetEnumitemValue{font}{sf}{\color{ctex@emph}\normalfont\sffamily} -\SetEnumitemValue{ref}{enumii}{\arabic{enumi}.\alph*} -\SetEnumitemValue{ref}{enumiii}{\arabic{enumi}.\alph{enumii}.\roman*} -\setlist - { - labelsep = .75\ccwd,listparindent = 2\ccwd,leftmargin = *, - itemsep = .75ex plus .1ex,topsep = .75ex plus .1ex, - partopsep = 0ex,parsep = 0ex - } -\newlist{eb@outline@list}{itemize}{1} -\setlist[eb@outline@list]{label = outline,itemsep = .5ex plus .1ex} -\setlist[itemize,1]{label = bullet} -\setlist[itemize,2]{label = endash} -\setlist[itemize,3]{label = asterisk} -\setlist[enumerate,1]{label = arabic,ref = \arabic*} -\setlist[enumerate,2]{label = alph,ref = enumii} -\setlist[enumerate,3]{label = roman,ref = enumiii,labelwidth = *} -\setlist[description]{font = sf,labelwidth = *,leftmargin = 2\ccwd} - -\cs_new_protected:Npn \eb_thmname_set:nnn #1#2#3 - { - \tl_if_eq:NnTF \l__ctex_scheme_tl { chinese } - { \tl_const:cn { c__eb_name_#1_tl } {#3} } - { \tl_const:cn { c__eb_name_#1_tl } {#2} } - } -\NewDocumentCommand{\EbNewTheorem} - {mO{\text_titlecase_first:n {#1}}mD(){tc-theorem}O{}} - { - \ctex_at_end_preamble:n - { - \eb_thmname_set:nnn {#1} {#2} {#3} - \exp_args:No \declaretheorem@i - { - name = \use:c { c__eb_name_#1_tl }, - style = easy-theorem,#5 - }{#1}[] - \bool_if:NT \l__eb_thmbox_bool - { - \@ifpackageloaded{tcolorbox} - {\tcolorboxenvironment{#1}{#4}}{} - } - \labelformat{#1}{\use:c { c__eb_name_#1_tl }~##1} - } - } - -\bool_new:N \l__eb_thmbox_bool -\tl_new:N \l__eb_thm_numberwith_tl -\tl_new:N \l__eb_thm_headpunct_tl -\tl_new:N \l__eb_thm_bodyfont_tl -\tl_new:N \l__eb_thm_notefont_tl -\tl_new:N \l__eb_thm_headindent_tl -\tl_new:N \l__eb_thm_spaceabove_tl -\tl_new:N \l__eb_thm_spacebelow_tl - -\RenewDocumentCommand{\newtheorem}{O{}m} - {\AfterPreamble{\declaretheorem[#1]{#2}}} -\eb_ctex_define:nn { thmset } - { - thmbox .bool_set:N = \l__eb_thmbox_bool, - thmbox .default:n = true, - thmbox .initial:n = false, - within .tl_set:N = \l__eb_thm_numberwith_tl, - within .initial:n = \bool_if:NT \l__eb_class_book_bool { chapter }, - bodyfont .tl_set:N = \l__eb_thm_bodyfont_tl, - bodyfont .initial:n = { }, - notefont .tl_set:N = \l__eb_thm_notefont_tl, - notefont .initial:n = { }, - headfont .tl_set:N = \l__eb_thm_headfont_tl, - headfont .initial:n = \color{ctex@emph}\sffamily, - headpunct .tl_set:N = \l__eb_thm_headpunct_tl, - headpunct .initial:n = { }, - spacepost .tl_set:N = \l__eb_thm_spacepost_tl, - spacepost .initial:n = \ccwd, - headindent .tl_set:N = \l__eb_thm_headindent_tl, - headindent .initial:n = 0\ccwd, - spaceabove .tl_set:N = \l__eb_thm_spaceabove_tl, - spaceabove .initial:n = .75ex plus .1ex, - spacebelow .tl_set:N = \l__eb_thm_spacebelow_tl, - spacebelow .initial:n = .75ex plus .1ex - } -\tl_const:Nn \c__eb_thmtools_keyval_tl - { - [ - spaceabove = \l__eb_thm_spaceabove_tl, - spacebelow = \l__eb_thm_spacebelow_tl, - headindent = \l__eb_thm_headindent_tl, - headfont = \l__eb_thm_headfont_tl, - notefont = \l__eb_thm_notefont_tl, - notebraces = { }{ }, - bodyfont = \l__eb_thm_bodyfont_tl, - headpunct = \l__eb_thm_headpunct_tl, - postheadspace = \l__eb_thm_spacepost_tl, - within = \l__eb_thm_numberwith_tl, - headformat = \NAME\space\NUMBER\NOTE - ] - } -\eb_at_end_preamble:n - { - \exp_last_unbraced:No - \declaretheoremstyle{\c__eb_thmtools_keyval_tl}{easy-theorem} - \eb_thmname_set:nnn { exercise } { Exercise } { 练习 } - \cs_undefine:N \proof - \clist_map_inline:nn - { - { lemma } { 引理 }, - { example } { 例 }, - { theorem } { 定理 }, - { corollary } { 推论 }, - { definition } { 定义 }, - { proposition } { 性质 }, - { remark } { 注 } [ numbered = no ], - { { proof } { 证明 } [ numbered = no,qed = \qedsymbol ] } - } - { \EbNewTheorem #1 } - } - -\ctex_at_end_package:nn { tasks } - { - \settasks - { - label = (\Alph*), - column-sep = \ccwd, - item-indent = 2\ccwd, - label-width = 1.5\ccwd, - after-item-skip = 0ex plus .1ex - } - } -\setchemformula - { - math-scripts = false, - charge-hshift = 0.25\ccwd, - subscript-vshift = -0.2ex - } -\sisetup - { - mode = match, - table-parse-only, - propagate-math-font, - text-family-to-math, - text-series-to-math, - reset-text-family = false, - reset-text-series = false, - reset-text-shape = false, - reset-math-version = false, - range-phrase = \ensuremath{\sim}, - range-units = single, - group-digits = none - } -\eb_at_begin_environment:nn - { - array,matrix,pmatrix,bmatrix,Bmatrix,vmatrix,Vmatrix, - matrix*,pmatrix*,bmatrix*,Bmatrix*,vmatrix*,Vmatrix*, - cases,cases*,dcases,dcases*,rcases,rcases*,drcases,drcases*, - aligned,alignedat,gathered,multlined,lgathered,rgathered - } - { - \linespread{\fp_use:N \l__eb_spread_math_fp} - \selectfont\ignorespaces - } -\eb_patch_cmd:Nnn \start@gather - { \collect@body } - { - \linespread{\fp_use:N \l__eb_spread_math_fp} - \selectfont\collect@body - } -\eb_patch_cmd:Nnn \start@align - { \collect@body } - { - \linespread{\fp_use:N \l__eb_spread_math_fp} - \selectfont\collect@body - } -\eb_patch_cmd:Nnn \start@multline - { \collect@body } - { - \linespread{\fp_use:N \l__eb_spread_math_fp} - \selectfont\collect@body - } -\eb_patch_cmd:Nnn \gather@split - { \spread@equation } - { - \linespread{\fp_use:N \l__eb_spread_math_fp} - \selectfont\spread@equation - } -\ctex_after_end_preamble:n - { - \skip_set:Nn \abovedisplayskip { 5pt plus 1pt minus 1pt } - \skip_set:Nn \belowdisplayskip { 5pt plus 1pt minus 1pt } - \skip_set:Nn \abovedisplayshortskip { 0pt } - \skip_set:Nn \belowdisplayshortskip { 5pt plus 1pt minus 1pt } - } -\cs_gset:Npn \tagform@ #1 - { \maketag@@@{\color{ctex@emph}(\ignorespaces #1\unskip\@@italiccorr)} } -\ctex_at_end_package:nn { unicode-math } - { \msg_redirect_module:nnn { unicode-math } { warning } { none } } - -\ctex_at_end_package:nn { tcolorbox } - { - \eb_package_later_bool:nn { tcolorbox } { 2020/10/09 } - \tcbset - { - tc-theorem/.style = - { - enhanced~jigsaw,pad~at~break* = 3pt, - opacityback = 0, - colframe = ctex@emph, - left = 6pt,right = 6pt,top = 8pt,bottom = 8pt,middle= 8pt - }, - tc-outline/.style = - { - enhanced,nofloat, - tikznode~boxed~title, - interior~style = white,colframe = ctex@emph, - colbacktitle = white,coltitle = ctex@emph, - fonttitle = \large\sffamily,fontupper = \itshape, - boxed~title~style = {size = normal,opacityframe = 0,boxrule = 0pt}, - attach~boxed~title~to~top~center = {yshift = -\tcboxedtitleheight/2}, - arc = 3pt,boxsep = 5pt, - after~skip = 3ex, - left = 1.5pc,right = 1.5pc,top = 1pc,bottom = 0.5pc - }, - tc-exercise/.style = - { - blank,on~line,center, - fontupper = \Large\sffamily, - before~skip = 3.75ex,after~skip = 2.5ex - }, - breakable, - boxsep = 0pt, - arc = 0pt, - fonttitle = \sffamily, - boxrule = \l__eb_rule_width_dim - } - \newtcbox[auto~counter]{\eb@exercise@box}[1]{tc-exercise,#1} - \NewDocumentEnvironment{outline}{O{}D(){\abstractname}o+b} - { - \begin{tcolorbox}[tc-outline,title = #2,IfValueT = {#3}{#3}] - \begin{eb@outline@list}[#1] - #4 - \end{eb@outline@list} - \end{tcolorbox} - }{} - \NewDocumentEnvironment{exercise} - {st+O{LightSkyBlue}O{1.}D(){\c__eb_name_exercise_tl}o+O{}+b} - { - \IfBooleanTF{#2} - { - \eb@exercise@box - { - fuzzy~halo = 5pt~with~#3, - IfValueT = {#6}{#6}, - phantom = - \IfBooleanF{#1} - { - \markright{\thetcbcounter\hspace{0.5\ccwd}#5} - \addcontentsline{toc}{section} - {\thetcbcounter\hspace{\eb@toc@section@numsep}#5} - } - } - {\IfBooleanF{#1}{\thetcbcounter\hspace{0.5\ccwd}}#5} - }{ - \group_begin: - \ctex_set:nn { section } { format += \centering } - \IfValueT{#6}{\ctex_set:nn { section } {#6}} - \IfBooleanTF{#1}{\section*{#5}}{\section{#5}} - \group_end: - }#7 - \begin{enumerate}[#4,labelsep = 0.5\ccwd] - #8 - \end{enumerate} - }{} - \DeclareTColorBox{easybox}{sO{DarkCyan}d()O{}} - { - enhanced~jigsaw,pad~at~break* = 3pt, - IfBooleanTF = {#1} - {toptitle = 8pt,top = 8pt} - {frame~hidden,boxrule = 0pt,toptitle = 8pt,top = 0pt}, - IfValueT = {#3}{title = #3}, - colback = #2,colbacktitle = #2, - opacityback = 0.12,opacitybacktitle = 0.12, - coltitle = black,colframe = black, - left = 6pt,right = 6pt,bottom = 8pt,middle= 8pt, - bottomtitle = 8pt, - beforeafter~skip = 2ex, - halign~upper = left,halign~lower = left, - center~title,#4 - } - \DeclareTColorBox{ebparbox}{sO{Purple}d()O{}} - { - frame~hidden, - enhanced~jigsaw,pad~at~break* = 3pt, - boxrule = 0pt, - borderline~west = {3pt}{0pt}{#2}, - IfBooleanTF = {#1} - { - colback = white, - IfValueT = {#3}{title = #3}, - top = 0pt,bottom = 0pt,toptitle = 0pt - }{ - colback = #2,colbacktitle = #2, - opacityback = 0.12,opacitybacktitle = 0.12, - IfValueTF = {#3}{title = #3,top = 0pt}{top = 8pt}, - bottom = 8pt,toptitle = 8pt - }, - left = 8pt,right = 8pt,middle= 8pt, - bottomtitle = 8pt, - beforeafter~skip = 1.5ex, - colframe = #2,coltitle = #2,#4 - } - \DeclareTotalTCBox{\ebemph}{O{DarkSeaGreen}vO{}} - { - nobeforeafter,tcbox~raise~base, - blank,fuzzy~halo = 2pt~with~#1,#3 - }{#2} - \DeclareTotalTCBox{\eblink}{O{Aqua}vO{}} - { - standard~jigsaw, - nobeforeafter,tcbox~raise~base, - top = 1.25pt,bottom = 1.25pt,left = 1.25pt,right = 1.25pt, - boxrule = 0.75pt,arc = 1pt, - colback = #1,opacityback = 0.12,colframe = #1,#3 - }{#2} - } - -\bool_set_true:N \l__eb_backend_bibtex_bool -\tl_new:N \l__eb_bib_style_tl -\tl_new:N \l__eb_bib_otherstyle_tl -\tl_new:N \l__eb_bib_citestyle_tl -\tl_new:N \l__eb_bib_datafile_tl - -\eb_ctex_define:nn { bibset } - { - backend .choice:, - backend/bibtex .code:n = { }, - backend/biblatex .code:n = - { \bool_set_false:N \l__eb_backend_bibtex_bool }, - - bib-style .choice:, - bib-style .value_required:n = true, - bib-style/numerical .code:n = - { - \tl_set:Nn \l__eb_bib_style_tl {#1} - \tl_clear:N \l__eb_bib_otherstyle_tl - }, - bib-style/authoryear .code:n = - { - \tl_set:Nn \l__eb_bib_style_tl {#1} - \tl_clear:N \l__eb_bib_otherstyle_tl - }, - bib-style/unknown .code:n = - { \tl_set_eq:NN \l__eb_bib_otherstyle_tl \l_keys_value_tl }, - bib-style .initial:n = numerical, - - cite-style .code:n = - { \tl_set:Nn \l__eb_bib_citestyle_tl {#1} }, - datafile .tl_set:N = \l__eb_bib_datafile_tl, - - bitoc-title .tl_set:N = \l__eb_bib_bitoc_title, - bitoc-title .initial:n = Reference - } - -\cs_new_protected:Npn \EbBibtexSet - { - \tl_if_empty:NTF \l__eb_bib_otherstyle_tl - { - \tl_if_eq:NnT \l__eb_bib_style_tl { numerical } - { - \bibliographystyle{gbt7714-numerical} - \setcitestyle{comma,square,super} - } - \tl_if_eq:NnT \l__eb_bib_style_tl { authoryear } - { \bibliographystyle{gbt7714-author-year} } - \cs_set_eq:NN \cite \citep - } - { \exp_args:NV \bibliographystyle \l__eb_bib_otherstyle_tl } - \tl_if_empty:NF \l__eb_bib_citestyle_tl - { \exp_args:NV \setcitestyle \l__eb_bib_citestyle_tl } - \skip_zero:N \bibsep - \NewDocumentCommand{\printbibliography}{st+o} - { - \group_begin: - \tl_set_eq:NN \eb@toc@title \bibname - \IfValueT{##3}{ \keys_set:nn { eb/listoc } {##3} } - \eb_multoc_pre_bool: - \tl_set:Nn \bibsection - { \eb_title_number_intoc_bool:nn {##2} {##1} } - \exp_args:NV \bibliography \l__eb_bib_datafile_tl - \eb_multoc_post_bool: - \group_end: - } - } -\cs_new_protected:Npn \eb_put_biblatex:n #1 - { \PassOptionsToPackage{#1}{biblatex} } -\cs_new_protected:Npn \EbBiblatexPreset - { - \tl_if_empty:NTF \l__eb_bib_otherstyle_tl - { - \tl_if_eq:NnT \l__eb_bib_style_tl { numerical } - { \eb_put_biblatex:n { style = gb7714-2015 } } - \tl_if_eq:NnT \l__eb_bib_style_tl { authoryear } - { \eb_put_biblatex:n { style = gb7714-2015ay } } - } - { \eb_put_biblatex:n { style = \l__eb_bib_otherstyle_tl } } - \tl_if_empty:NF \l__eb_bib_citestyle_tl - { \eb_put_biblatex:n { citestyle = \l__eb_bib_citestyle_tl } } - \eb_put_biblatex:n { backend = biber } - } -\cs_new_protected:Npn \EbBiblatexPostset - { - \exp_args:NV \addbibresource \l__eb_bib_datafile_tl - \tl_gset:Nn \blx@default@theheading { bibintoc } - \defbibheading{bibintoc}[\bibname] - {\eb_biber_title_level_bool:n {##1}} - \skip_zero:N \bibitemsep - } -\eb_at_end_preamble:n - { - \tl_if_empty:NF \l__eb_bib_datafile_tl - { - \bool_if:NTF \l__eb_backend_bibtex_bool - { - \RequirePackage[sort&compress]{natbib} - \EbBibtexSet - } - { - \EbBiblatexPreset - \RequirePackage{biblatex} - \EbBiblatexPostset - } - } - } - -\lstdefinestyle{easy-listings} - { - language = [LaTeX]TeX, - texcsstyle = - { - *\lst@ifdisplaystyle - \bfseries\color{ctex@verb} - \else - \color{ctex@verb} - \fi - }, - basicstyle = - { - \ttfamily\lst@ifdisplaystyle - \small - \else - \color{ctex@verb} - \fi - }, - keywordstyle = - { - \lst@ifdisplaystyle - \bfseries\color{ctex@verb} - \else - \color{ctex@verb} - \fi - }, - framexleftmargin = 0pt, - framexrightmargin = 0pt, - xleftmargin = 3pt, - xrightmargin = 3pt, - numbersep = 10pt, - framesep = 3pt, - frame = single, - rulecolor = \color{ctex@frame}, - commentstyle = \color{SlateGray}, - emphstyle = \color{ctex@emph}, - % emph = {}, - morekeywords = - { - includegraphics,setmainfont,setsansfont,setmonofont,setCJKmainfont,setCJKsansfont,setCJKmonofont,setCJKfamilyfont,RequirePackage - } - } -\lstset - { - style = easy-listings, - breaklines = true, - resetmargins = true, - % numbers = left, - numberstyle = \footnotesize, - aboveskip = 1.5ex plus .2ex minus .1ex, - belowskip = 0.55ex plus .2ex minus .1ex, - keepspaces = true, - framerule = \l__eb_rule_width_dim, - columns = flexible, - abovecaptionskip = -1ex, - belowcaptionskip = 1.5ex - } -\lstloadlanguages{C,C++,Java,Python,Matlab} - -\clist_new:N \l__eb_hyperref_clist -\cs_new_protected:Npn \eb_put_hyperref:n #1 - { \clist_put_right:Nn \l__eb_hyperref_clist {#1} } -\cs_new_protected:Npn \eb_define_linkcolor:nnn #1#2#3 - { \definecolorset{HTML}{ctex@}{}{link,#1;url,#2;cite,#3} } -\cs_new_protected:Npn \eb_define_themecolor:nnn #1#2#3 - { \definecolorset{HTML}{ctex@}{}{frame,#1;emph,#2;verb,#3} } -\cs_new_protected:Npn \eb_define_linkcolor:n #1 - { \definecolorset{HTML}{ctex@}{}{link,#1;url,#1;cite,#1} } -\cs_new_protected:Npn \eb_define_themecolor:n #1 - { \definecolorset{HTML}{ctex@}{}{frame,#1;emph,#1;verb,#1} } -\cs_new:Npn \eb_linkcolor_set:n #1 - { - linkcolor/\clist_item:nn {#1} {1} .code:n = - { - \eb_define_linkcolor:nnn - { \clist_item:nn {#1} {2} } - { \clist_item:nn {#1} {3} } - { \clist_item:nn {#1} {4} } - \eb_put_hyperref:n - { - linkcolor = ctex@link,linkbordercolor = ctex@link, - urlcolor = ctex@url,urlbordercolor = ctex@url, - citecolor = ctex@cite,citebordercolor = ctex@cite - } - }, - } -\cs_new:Npn \eb_themecolor_set:n #1 - { - color/\clist_item:nn {#1} {1} .code:n = - { - \eb_define_themecolor:nnn - { \clist_item:nn {#1} {2} } - { \clist_item:nn {#1} {3} } - { \clist_item:nn {#1} {4} } - }, - } - -\bool_set_false:N \l__eb_toc_number_color_bool -\eb_ctex_define:nn { refset } - { - linktype .choice:, - linktype/edge .code:n = { }, - linktype/none .code:n = \eb_put_hyperref:n { hidelinks }, - linktype/various .code:n = - { - \bool_set_true:N \l__eb_toc_number_color_bool - \eb_put_hyperref:n { colorlinks } - }, - linktype .value_required:n = true, - linktype .initial:n = edge, - - linktoc .choice:, - linktoc/unknown .code:n = - { - \eb_put_hyperref:n { linktoc = #1 } - \clist_map_inline:nn { page,none } - { - \tl_if_eq:NnT \l_keys_value_tl {##1} - { - \clist_map_break:n - { \colorlet{ctex@toc@number}{black} } - } - } - }, - linktoc .default:n = all, - linktoc .initial:n = all, - unknown .code:n = - { - \eb_put_hyperref:x - { - \l_keys_key_str - \tl_if_empty:NF \l_keys_value_tl { = {#1} } - } - } - } -\eb_ctex_define:nx { refset } - { - linkcolor .choice:, - \clist_map_function:nN - { - { fresh, 62d71f,0000B2,005752 }, - { cutepink, ff69b4,9d5196,57b5e5 }, - { navyblue, 000080,004986,eb6877 }, - { crimson, dc143c,00c1c9,afcd20 } - } - \eb_linkcolor_set:n - linkcolor .default:n = navyblue, - linkcolor .initial:n = navyblue, - linkcol-all .code:n = - { \eb_define_linkcolor:n { \exp_not:n {#1} } } - } -\colorlet{ctex@toc@number}{ctex@link} -\eb_ctex_define:nx { style } - { - color .choice:, - color .value_required:n = true, - \clist_map_function:nN - { - { none, 000000,000000,000000 }, - { seaside, 4169e1,708090,9932cc }, - { energy, f39800,00a0e9,893895 }, - { cyberpunk, 601986,eb6877,a4005b } - } - \eb_themecolor_set:n - color .initial:n = none, - color-all .code:n = - { \eb_define_themecolor:n { \exp_not:n {#1} } } - } - -\cs_new:Npn \eb_allow_urlbreak: - { - \cs_new:Npn \eb_add_urlbreak_points: - { \tl_map_function:NN \c__eb_urlbreak_points_tl \do } - \eb_appto_cmd:Nn \UrlBreaks - { \UrlOrds\eb_add_urlbreak_points: } - } -\tl_const:Nn \c__eb_urlbreak_points_tl - { - ABCDEFGHIJKLMNOPQRSTUVWXYZ - abcdefghijklmnopqrstuvwxyz - 0123456789 - } -\ctex_at_end_preamble:n - { - \RequirePackage{hyperref} - \urlstyle{same} - \eb_allow_urlbreak: - \ctex_hypersetup:n { pdfstartview = FitH } - \exp_args:NV \hypersetup \l__eb_hyperref_clist - } - -\labelformat{part}{\CTEXthepart} -\labelformat{chapter}{\CTEXthechapter} -\labelformat{figure}{\figurename~#1} -\labelformat{table}{\tablename~#1} -\tl_if_eq:NnTF \l__ctex_scheme_tl { chinese } - { - \keys_set_known:nn { ctex } - { - contentsname = 目\hspace{\ccwd}录, - indexname = 索\hspace{\ccwd}引, - listfigurename = 图片索引, - listtablename = 表格索引, - abstractname = 摘\hspace{\ccwd}要, - lstlistlistingname = 代码索引, - lstlistingname = 代码 - } - \labelformat{equation}{式(#1)} - \labelformat{section}{节 #1} - \labelformat{subsection}{小节 #1} - } - { - \keys_set_known:nn { ctex } - { - abstractname = Abstract, - lstlistlistingname = List~of~Codes, - lstlistingname = Code - } - \labelformat{equation}{Equation~(#1)} - \labelformat{section}{Section~#1} - \labelformat{subsection}{Subsection~#1} - } - \ctex_set:n { secnumdepth = 3, |