Newer
Older
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
{
l =
{ \tl_set_eq:NN \l_@@_begin_align_tl \flushleft
\tl_set_eq:NN \l_@@_end_align_tl \endflushleft },
r =
{ \tl_set_eq:NN \l_@@_begin_align_tl \flushright
\tl_set_eq:NN \l_@@_end_align_tl \endflushright },
c =
{ \tl_set_eq:NN \l_@@_begin_align_tl \center
\tl_set_eq:NN \l_@@_end_align_tl \endcenter },
n =
{ \tl_clear:N \l_@@_begin_align_tl
\tl_clear:N \l_@@_end_align_tl }
}
}
{
\AssignTemplateKeys
\group_begin:
\l_@@_begin_align_tl
\l_@@_format_tl
\l_@@_content_tl \par
\l_@@_end_align_tl
\group_end:
\__nju_vskip:N \l_@@_bottom_skip
}
% \end{macrocode}
%
% 定义页面模板。
% \begin{macrocode}
%<@@=njupage>
% \end{macrocode}
%
% 声明页面模板接口。
% 页面是元素的集合。一个抽象的页面应当具备以下属性:
% \begin{description}
% \item[\opt{element}] 包含的元素,这里使用的是名称列表
% \item[\opt{prefix}] 元素名称前缀
% \item[\opt{format}] 格式,例如行距
% \item[\opt{top-skip}] 上间距,即与页面顶部的距离
% \item[\opt{bottom-skip}] 下间距,即与页面底部的距离
% \end{description}
% \begin{macrocode}
\DeclareTemplateInterface { nju } { page } { \c_zero_int }
{
element : commalist = \c_empty_clist,
prefix : tokenlist = \c_empty_tl,
format : tokenlist = \c_empty_tl,
top-skip : skip = \c_zero_skip,
bottom-skip : skip = \c_zero_skip
}
% \end{macrocode}
%
% 声明页面模板代码。
% \begin{macrocode}
\DeclareTemplateCode { nju } { page } { \c_zero_int }
{
element = \l_@@_element_clist,
prefix = \l_@@_prefix_tl,
format = \l_@@_format_tl,
top-skip = \l_@@_top_skip,
bottom-skip = \l_@@_bottom_skip
}
{
\AssignTemplateKeys
\newpage
\__nju_vskip:N \l_@@_top_skip
\group_begin:
\l_@@_format_tl
\clist_map_inline:Nn \l_@@_element_clist
{ \UseInstance { nju } { \l_@@_prefix_tl ##1 } }
\group_end:
\__nju_vskip:N \l_@@_bottom_skip
}
%<@@=nju>
% \end{macrocode}
%
% \begin{macro}{\@@_declare_element:nn,\@@_declare_page:nn}
% 封装 \pkg{xtemplate} 提供的函数,简化创建实例的过程。
% \begin{arguments}
% \item 实例名称
% \item 参数列表
% \end{arguments}
% \begin{macrocode}
\cs_new_protected:Npn \@@_declare_element:nn #1#2
{ \DeclareInstance { nju } {#1} { element } {#2} }
\cs_new_protected:Npn \@@_declare_page:nn #1#2
{ \DeclareInstance { nju } {#1} { page } {#2} }
% \end{macrocode}
% \end{macro}
%
%
% \subsection{模板选项}
% \changes{v0.11}{2021/11/15}{进行了效率优化。}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{type}
nlcover .bool_set:N = \g_@@_nlcover_bool,
nlcover .initial:n = false,
% \footnote{原创性声明的英文翻译为 Declaration of Originality,
% 为了使选项表义更清晰同时缩减名称长度,将其修改为“声明页”这一名称。}
% \begin{macro}{draft}
% \changes{v0.13}{2021/12/15}{新增草稿模式选项。}
% 是否开启草稿模式(默认关闭)。
% \begin{macrocode}
draft .bool_gset:N = \g_@@_draft_bool,
draft .initial:n = false,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{oneside,twoside}
% \changes{v0.14}{2022/01/14}{新增单双面模式选项。}
% 单双面模式(默认为双面)。
% \begin{macrocode}
oneside .value_forbidden:n = true,
twoside .value_forbidden:n = true,
{ gyre, mac, win, none }
{ \tl_set_eq:NN \g_@@_latin_font_tl \l_keys_choice_tl },
{ fandol, founder, mac, noto, source, win, none }
{ \tl_set_eq:NN \g_@@_cjk_font_tl \l_keys_choice_tl },
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{config}
% \changes{v0.16}{2022/02/23}{新增 \opt{config} 选项。}
% 配置文件路径。
% \begin{macrocode}
% \begin{macrocode}
\ProcessKeysOptions { nju }
% \end{macrocode}
bib .meta:nn = { nju / bib } { #1 },
info .meta:nn = { nju / info } { #1 },
style .meta:nn = { nju / style } { #1 }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\njusetup}
% \changes{v0.6}{2021/09/10}{改用键值对输入信息。}
% 定义用于设置信息的命令。
% \begin{macrocode}
\NewDocumentCommand \njusetup { m } { \keys_set:nn { nju } { #1 } }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\njusetformat}
% \changes{v0.17}{2022/04/09}{提供修改默认样式的接口。}
% 定义修改固定文本的接口。
% \begin{macrocode}
\NewDocumentCommand \njusetformat { m m }
{ \tl_gset:cn { g_@@_fmt_ #1 _tl } { #2 } }
% \end{macrocode}
% \end{macro}
%
% 定义修改长度值的接口。可选星号表示修改弹性长度。
% \begin{macrocode}
\NewDocumentCommand \njusetlength { s m m }
{
\bool_if:nTF { #1 }
{ \skip_gset:cn { g_@@_ #2 _skip } { #3 } }
{ \dim_gset:cn { g_@@_ #2 _dim } { #3 } }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\njusetname,\njusetname*,\njusettext,\njusettext*}
% \changes{v0.17}{2022/04/01}{提供修改固定文本的接口。}
% 定义修改固定文本的接口。
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
% \begin{macrocode}
\NewDocumentCommand \njusetname { s m o m }
{ \@@_set_tokenlist:nnnnn {#1} {#2} {#3} {#4} { name } }
\NewDocumentCommand \njusettext { s m o m }
{ \@@_set_tokenlist:nnnnn {#1} {#2} {#3} {#4} { text } }
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_set_tokenlist:nnnnn}
% 用于修改名称、文字常量的辅助函数。
% \begin{arguments}
% \item 是否含有可选星号,传入 |bool| 型变量
% \item 被修改变量名称
% \item 可选的变体,用字母标记
% \item 修改后的内容
% \item 类别,name 或者 text
% \end{arguments}
% \begin{macrocode}
\cs_new_protected:Npn \@@_set_tokenlist:nnnnn #1#2#3#4#5
{
\tl_if_novalue:nTF { #3 }
{ \tl_clear:N \l_@@_tmpa_tl }
{ \tl_set:Nn \l_@@_tmpa_tl { _ #3 } }
\bool_if:nTF { #1 }
{ \tl_set:Nn \l_@@_tmpb_tl { _en } }
{ \tl_clear:N \l_@@_tmpb_tl }
\tl_gset:cn { g_@@_ #5 _ #2 \l_@@_tmpa_tl \l_@@_tmpb_tl _tl } {#4}
}
% \end{macrocode}
% \end{macro}
%
%
% \changes{v0.12}{2021/12/07}{重新组织宏包载入顺序。}
% 将选项传入 \cls{ctexbook} 文档类。
% 传入单双面模式选项。
% \begin{macrocode}
\bool_if:NTF \g_@@_twoside_bool { twoside, } { oneside, }
% \end{macrocode}
% 开启草稿模式后传入 |draft| 选项。
% \begin{macrocode}
\bool_if:NT \g_@@_draft_bool { draft, }
% \end{macrocode}
% 关于行距,\hologo{LaTeX} 默认1.2行距,MS Word 默认行距是1.3,要求1.5倍
% Word 行距,故 $1.5\times\frac{1.3}{1.2} = 1.625$
% \end{macrocode}
% 默认不载入任何字体,供本模板自行设置。
% \begin{macrocode}
% \end{macrocode}
% 正文字体设置为小四号。
% \begin{macrocode}
%
% 传入各宏包选项。
% \begin{macrocode}
\clist_map_inline:nn
{
{ no-math } { fontspec },
{ perpage } { footmisc },
{ amsmath, thmmarks } { ntheorem },
{ hyphens } { url },
{ warnings-off={ mathtools-colon, mathtools-overbracket } }
{ unicode-math },
{ capitalise, nameinlink, noabbrev }
}
{ \PassOptionsToPackage #1 }
% \end{macrocode}
%
% 使用\pkg{ctexbook}作为基础文档类。
% \changes{v0.13}{2021/12/13}{使用 \pkg{ntheorem} 创建定理环境,删除
% \pkg{amsthm} 和 \pkg{thmtools}。}
% \changes{v0.16}{2022/03/19}{不显式载入 \pkg{amsmath}。}
% 数学相关的宏包。其中,\pkg{amsmath} 必须在 \pkg{unicode-math} 前加载。
% \pkg{unicode-math} 指定了 \hologo{XeTeX} 和 \hologo{LuaTeX} 下所使用的
% 数学字体。用于配置数学环境的 \pkg{mathtools} 会与 \pkg{unicode-math}
% \changes{v0.14}{2021/12/21}{移除内置的 \pkg{multirow}、\pkg{subcaption}
% 和 \pkg{wrapfig}。}
% 按以下顺序加载两个关于引用的包。
% \pkg{hyperref} 覆写了大量命令,因此需要在其他包最后载入。
% 仅有 \pkg{cleveref} 需要在 \pkg{hyperref} 后载入,否则会报错。
% \begin{macrocode}
hyperref,
cleveref
}
% 在双面模式下,使用 \pkg{emptypage} 清除空白页的页眉、页脚和页码。
% \begin{macrocode}
\bool_if:NT \g_@@_twoside_bool { \RequirePackage{ emptypage } }
% \end{macrocode}
%
% \changes{v0.13}{2021/12/13}{删除会与 \pkg{ntheorem} 冲突的 \pkg{microtype}。}
% \begin{macro}{\njuline}
% 针对编译引擎,使用不同的宏包构建可以对中文正常换行的下划线命令。
\NewDocumentCommand \njuline { m } { \CJKunderline{#1} }
}
\NewDocumentCommand \njuline { m } { \underLine{#1} \null }
}
% 使用 \pkg{tabularray} 绘制研究生的出版授权书。
% \begin{macrocode}
\bool_lazy_and:nnT
{ \g_@@_decl_bool }
{ !\int_compare_p:n { \g_@@_info_degree_int == 1 } }
{ \RequirePackage { tabularray } }
% \end{macrocode}
%
% \begin{macro}{\@@_check_package:nnn}
% 检查过时宏包。
% \begin{macrocode}
\msg_new:nnn { njuthesis } { package-too-old }
{
The~ njuthesis~ class~ only~ supports~ "#1"~ with~
a~ version higher~ than~ v#2.\\
Please~ update~ an~ up-to-date~ version~ of~ it~
}
\cs_new_protected:Npn \@@_check_package:nnn #1#2#3
{
\@ifpackagelater {#1} {#2}
{ } { \msg_error:nnnn { njuthesis } { package-too-old } {#1} {#3} }
}
% \end{macrocode}
% \end{macro}
%
% 检查绘制下划线所需的 \pkg{luatexja} 包版本。该宏包在 2021-09-18 的更新
% 解决了下划线中断问题,然而在 2021-10-24 的更新才提供了正确的内嵌日期。
{ \@@_check_package:nnn { luatexja } { 2021/10/24 } { 20211024.0 } }
% \subsection{配置文件}
%
% \cls{njuthesis} 包含\emph{本科生}和\emph{研究生}两套区别较大的模板配置。
% 出于定义的简洁起见,本模板将其拆分为两个单独的参数配置文件,
% 编译过程中将会根据设置的学位信息,载入相应默认配置。
% 注意,尽管在手册的实现细节部分封面、摘要、常量等位于靠后部分,
% 拆分后实际上是在此处载入运行的,务必要注意逻辑顺序。
%
% 下文中,本科生模板配置对应 \agrd{definition-ug},用于生成
% \file{njuthesis-undergraduate.def};研究生模板配置对应
% \agrd{definition-g},用于生成 \file{njuthesis-graduate.def}。
% \begin{macrocode}
{ \file_input:n { njuthesis-undergraduate.def } }
{ \file_input:n { njuthesis- graduate.def } }
% \end{macrocode}
%
% 载入用户设置,可用于对模板做额外修改。
% \begin{macrocode}
\msg_new:nnn { njuthesis } { load-config }
{ I~ am~ loading~ config~ file~ "#1". }
\msg_info:nnn { njuthesis } { load-config } { #1 }
\file_input:n { #1 }
% \subsection{个人信息}
% \changes{v0.11}{2021/10/01}{将个人信息变量名改为小写字母加连字符的形式。}
% \changes{v0.15}{2022/01/22}{将个人信息设置移到载入宏包后。}
%
% \begin{macrocode}
\keys_define:nn { nju / info }
{
% \end{macrocode}
%
% \begin{macro}{info/title,info/title*}
% \changes{v0.13}{2021/12/12}{简化多行标题的输入方式。}
% \changes{v0.14}{2022/01/14}{将标题断行控制符修改为 |\\|。}
% 题目。中文题目可使用 |\\| 手动断行。以下标注星号(|*|)的皆为对应的英文字段。
% \begin{macrocode}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/keywords,info/keywords*}
% \changes{v0.11}{2021/10/01}{修改了添加关键词的方式。}
% 关键词列表。
% \begin{macrocode}
keywords .clist_set:N = \g_@@_info_keywords_clist,
keywords* .clist_set:N = \g_@@_info_keywords_en_clist,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/grade,info/student-id,info/author,info/author*}
% 年级、学号、姓名。
% \begin{macrocode}
grade .tl_set:N = \g_@@_info_grade_tl,
student-id .tl_set:N = \g_@@_info_id_tl,
author .tl_set:N = \g_@@_info_author_tl,
author* .tl_set:N = \g_@@_info_author_en_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/department,info/department*,info/major,info/major*,info/field,info/field*}
% 院系、专业、方向。
% \begin{macrocode}
department .tl_set:N = \g_@@_info_dept_tl,
department* .tl_set:N = \g_@@_info_dept_en_tl,
major .tl_set:N = \g_@@_info_major_tl,
major* .tl_set:N = \g_@@_info_major_en_tl,
field .tl_set:N = \g_@@_info_field_tl,
field* .tl_set:N = \g_@@_info_field_en_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/supervisor,info/supervisor*}
% \changes{v0.13}{2021/12/11}{修改了导师选项的变量名称。}
% \changes{v0.14}{2022/01/12}{精简导师信息选项。}
% 导师信息。中文导师全称使用 |clist| 存储,便于在本科生封面中进行分割。
% \begin{macrocode}
supervisor .clist_set:N = \g_@@_info_supv_clist,
supervisor* .tl_set:N = \g_@@_info_supv_en_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/supervisor-ii,info/supervisor-ii*}
% 第二导师信息。
% \begin{macrocode}
supervisor-ii .clist_set:N = \g_@@_info_supv_ii_clist,
supervisor-ii* .tl_set:N = \g_@@_info_supv_ii_en_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/submit-date}
% \changes{v0.14}{2022/01/14}{精简提交日期选项。}
% 提交日期,初始值为编译当天日期。
% \begin{macrocode}
submit-date .tl_set:N = \g_@@_info_submitdate_raw_tl,
submit-date .initial:V = \c_@@_today_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/defend-date}
% \changes{v0.14}{2022/01/14}{精简答辩日期选项。}
% 答辩日期。
% \begin{macrocode}
defend-date .tl_set:N = \g_@@_info_defenddate_raw_tl,
defend-date .initial:V = \c_@@_today_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/defend-date,info/chairman,info/reviewer}
% 答辩委员会信息。
% \begin{macrocode}
chairman .tl_set:N = \g_@@_info_chairman_tl,
reviewer .clist_set:N = \g_@@_info_reviewer_clist,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/clc,info/secret-level,info/udc,info/supervisor-contact}
% 国家图书馆封面相关信息。
% \begin{macrocode}
clc .tl_set:N = \g_@@_info_clc_tl,
secret-level .tl_set:N = \g_@@_info_secretlv_tl,
udc .tl_set:N = \g_@@_info_udc_tl,
supervisor-contact .tl_set:N = \g_@@_info_supv_cont_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/email}
% \changes{v0.14}{2022/01/12}{新增电邮地址信息项。}
% 用于学位论文出版授权书的电子邮件地址。
% \begin{macrocode}
email .tl_set:N = \g_@@_info_email_tl
}
% \end{macrocode}
% \end{macro}
%
% \changes{v0.16}{2022/03/06}{正确处理学位和类型信息。}
% 设置学位信息。该设置需要放在 \cs{ProcessKeysOptions}
% 命令以及载入配置文件中的常量信息后进行。
% \begin{macrocode}
{ \g_@@_info_degree_int }
}
\int_compare:nTF { \g_@@_info_degree_int == 1 }
{ \tl_set:Nn \g_@@_info_diploma_tl { ug } }
{ \tl_set:Nn \g_@@_info_diploma_tl { g } }
% \end{macrocode}
%
% 设置类型信息。
% \begin{macrocode}
\tl_set:Nx \g_@@_info_type_tl
{ \clist_item:Nn \g_@@_name_type_clist { \g_@@_info_type_int } }
\tl_set:Nx \g_@@_info_type_en_tl
{ \clist_item:Nn \g_@@_name_type_en_clist { \g_@@_info_type_int } }
\tl_put_left:Nx \g_@@_info_type_tl
{ \tl_use:c { g_@@_name_ \g_@@_info_diploma_tl _tl } }
% 在导言区录入用户信息后进行变量设置。此处使用到了 \pkg{ctex} 提供的命令,
% 应当位于载入文档类之后。
% \begin{macrocode}
\ctex_at_end_preamble:n
{
% \end{macrocode}
% 拼合双导师的姓名和职称。
% \begin{macrocode}
\bool_set:Nn \l_@@_second_supv_bool
{ ! \clist_if_empty_p:N \g_@@_info_supv_ii_clist }
\tl_set:Nx \g_@@_info_supvfull_tl
\bool_if:NT \l_@@_second_supv_bool
{
\@@_quad:
\clist_use:Nn \g_@@_info_supv_ii_clist { \@@_hskip: }
}
% \end{macrocode}
% 将 ISO 格式的原始日期字符串格式化为中文日期表示,该字符串需要进行展开。
% \begin{macrocode}
}
% \end{macrocode}
% 英文提交日期以及答辩日期仅用于研究生封面。
% \begin{macrocode}
\@@_date_en:www \g_@@_info_submitdate_raw_tl \q_stop
}
}
}
% \end{macrocode}
%
%
\bool_lazy_or:nnT
{ \tl_if_empty_p:N \g_@@_latin_font_tl }
{ \tl_if_empty_p:N \g_@@_cjk_font_tl }
% 检测 Windows 的命令由 \pkg{l3kernel} 提供,
% 检测 macOS 的命令由 \pkg{ctex} 提供,
{
\tl_set:Nn \g_@@_latin_font_tl { win }
\tl_set:Nn \g_@@_cjk_font_tl { win }
}
{
\ctex_if_platform_macos:TF
{
\tl_set:Nn \g_@@_latin_font_tl { mac }
\tl_set:Nn \g_@@_cjk_font_tl { mac }
}
{
\tl_set:Nn \g_@@_latin_font_tl { gyre }
\tl_set:Nn \g_@@_cjk_font_tl { fandol }
}
}
\setmainfont { Times~New~Roman }
\setsansfont { Arial }
\setmonofont { Courier~New }
[ Scale = MatchLowercase ]
\setmainfont { Times~New~Roman }
\setsansfont { Arial }
\setmonofont { Menlo }
[ Scale = MatchLowercase ]
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
\setmainfont { texgyretermes }
[
Extension = .otf,
UprightFont = *-regular,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic
]
\setsansfont { texgyreheros }
[
Extension = .otf,
UprightFont = *-regular,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic
]
\setmonofont { texgyrecursor }
[
Extension = .otf,
UprightFont = *-regular,
BoldFont = *-bold,
ItalicFont = *-italic,
BoldItalicFont = *-bolditalic,
Scale = MatchLowercase,
Ligatures = CommonOff
]
% \begin{macro}{\@@_hide_no_script_msg:}
% 隐藏 |does not contain script "CJK"| 警告。
{ \msg_redirect_name:nnn { fontspec } { no-script } { info } }
% \end{macrocode}
% \end{macro}
%
\setCJKmainfont { SimSun }
[ AutoFakeBold = 2.17, ItalicFont = KaiTi ]
\setCJKsansfont { SimHei } [ AutoFakeBold = 2.17 ]
\setCJKmonofont { FangSong } [ AutoFakeBold = 2.17 ]
\setCJKfamilyfont { zhsong } { SimSun } [ AutoFakeBold = 2.17 ]
\setCJKfamilyfont { zhhei } { SimHei } [ AutoFakeBold = 2.17 ]
\setCJKfamilyfont { zhfs } { FangSong } [ AutoFakeBold = 2.17 ]
\setCJKfamilyfont { zhkai } { KaiTi } [ AutoFakeBold = 2.17 ]
\setCJKmainfont{Songti~SC~Light}[
BoldFont=Songti~SC~Bold,
ItalicFont=Kaiti~SC,
BoldItalicFont=Kaiti~SC~Bold]
\setCJKsansfont{Heiti~SC~Light}[BoldFont=Heiti~SC~Medium]
\setCJKmonofont{STFangsong}
\setCJKfamilyfont{zhsong}{Songti~SC~Light}[BoldFont=Songti~SC~Bold]
\setCJKfamilyfont{zhhei}{Heiti~SC~Light}[BoldFont=Heiti~SC~Medium]
\setCJKfamilyfont{zhfs}{STFangsong}
\setCJKfamilyfont{zhkai}{Kaiti~SC}[BoldFont=Kaiti~SC~Bold]
\setCJKfamilyfont{zhnewhei}{PingFang~SC}
}
% \begin{macro}{\@@_load_cjk_font_fandol:}
% Fandol 字体
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
\@@_hide_no_script_msg:
\setCJKmainfont { FandolSong-Regular }
[
Extension = .otf,
BoldFont = FandolSong-Bold,
ItalicFont = FandolKai-Regular
]
\setCJKsansfont { FandolHei-Regular }
[
Extension = .otf,
BoldFont = FandolHei-Bold
]
\setCJKmonofont { FandolFang-Regular }
[ Extension = .otf ]
\setCJKfamilyfont { zhsong } { FandolSong-Regular }
[
Extension = .otf,
BoldFont = FandolSong-Bold
]
\setCJKfamilyfont { zhhei } { FandolHei-Regular }
[
Extension = .otf,
BoldFont = FandolHei-Bold
]
\setCJKfamilyfont { zhfs } { FandolFang-Regular }
[ Extension = .otf ]
\setCJKfamilyfont { zhkai } { FandolKai-Regular }
[
Extension = .otf,
AutoFakeBold = 2.17
]
%
% \begin{macro}{\@@_load_cjk_font_founder:}
% 调整方正字体括号位置。\footnote{\hologo{XeTeX} 的调整方法来自 \url{https://www.zhihu.com/question/46241367/answer/101660183}。}
\sys_if_engine_xetex:T
{ \xeCJKEditPunctStyle {quanjiao} { optimize-kerning = true } }
\sys_if_engine_luatex:T
{ \defaultCJKfontfeatures { JFM = { zh_CN/{quanjiao,fzpr} } } }
[ BoldFont = FZXiaoBiaoSong-B05, ItalicFont = FZKai-Z03 ]
\setCJKsansfont { FZXiHeiI-Z08 } [ BoldFont = FZHei-B01 ]
\setCJKmonofont { FZFangSong-Z02 }
\setCJKfamilyfont { zhsong } { FZShuSong-Z01 }
[ BoldFont = FZXiaoBiaoSong-B05 ]
\setCJKfamilyfont { zhhei } { FZHei-B01 }
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
\setCJKmainfont
[
UprightFont = NotoSerifCJKsc-Regular,
BoldFont = NotoSerifCJKsc-Bold,
ItalicFont = NotoSerifCJKsc-Regular,
BoldItalicFont = NotoSerifCJKsc-Bold,
ItalicFeatures = FakeSlant,
BoldItalicFeatures = FakeSlant
] { Noto~Serif~CJK~SC }
\setCJKsansfont
[
UprightFont = NotoSansCJKsc-Regular,
BoldFont = NotoSansCJKsc-Bold,
ItalicFont = NotoSansCJKsc-Regular,
BoldItalicFont = NotoSansCJKsc-Bold,
ItalicFeatures = FakeSlant,
BoldItalicFeatures = FakeSlant
] { Noto~Sans~CJK~SC }
\setCJKmonofont { Noto~Sans~Mono~CJK~SC }
\setCJKfamilyfont { zhsong } { Noto~Serif~CJK~SC }
\setCJKfamilyfont { zhhei } { Noto~Sans~CJK~SC }
\setCJKfamilyfont { zhfs } { FZFangSong-Z02 }
\setCJKfamilyfont { zhkai } { FZKai-Z03 }
[AutoFakeBold=2.17]
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_load_cjk_font_source:}
% \changes{v0.14}{2021/12/20}{增加 Adobe Source Han 作为思源字体。}
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
% Source Han 思源字体。
% \begin{macrocode}
\cs_new_protected:Npn \@@_load_cjk_font_source:
{
\setCJKmainfont
[
UprightFont = SourceHanSerifSC-Regular,
BoldFont = SourceHanSerifSC-Bold,
ItalicFont = SourceHanSerifSC-Regular,
BoldItalicFont = SourceHanSerifSC-Bold,
ItalicFeatures = FakeSlant,
BoldItalicFeatures = FakeSlant
] { Source~Han~Serif~SC }
\setCJKsansfont
[
UprightFont = SourceHanSansSC-Regular,
BoldFont = SourceHanSansSC-Bold,
ItalicFont = SourceHanSansSC-Regular,
BoldItalicFont = SourceHanSansSC-Bold,
ItalicFeatures = FakeSlant,
BoldItalicFeatures = FakeSlant
] { Source~Han~Sans~SC }
\setCJKmonofont { FZFangSong-Z02 }
\setCJKfamilyfont { zhsong } { Source~Han~Serif~SC }
\setCJKfamilyfont { zhhei } { Source~Han~Sans~SC }
\setCJKfamilyfont { zhfs } { FZFangSong-Z02 }
\setCJKfamilyfont { zhkai } { FZKai-Z03 }
[AutoFakeBold=2.17]
% \subsubsection{定义数学字库}
%
% \begin{macro}{\@@_load_math_font:}
% 设置数学字体 (XITS, 或者 \href{https://www.stixfonts.org}{STIX}, 与 Times New Roman 最为相近)
% 通用数学字体。
% \begin{macrocode}
\cs_new_protected:Npn \@@_load_math_font:
{
% \setmathfont{STIXTwoMath-Regular}[Extension = .otf]
\setmathfont{XITSMath-Regular}[
BoldFont = XITSMath-Bold,
Extension = .otf]
\setmathfont{NewCMMath-Regular.otf}[range={cal,bb,frak}]
\setmathfont{NewCMMath-Regular.otf}[version=bold,range={bfcal}]
}
% \end{macrocode}
% \end{macro}
%
%
\use:c { @@_load_latin_font_ \g_@@_latin_font_tl : }
\use:c { @@_load_cjk_font_ \g_@@_cjk_font_tl : }
% \changes{v0.10}{2021/09/28}{修正了数学字体。}
% \begin{macrocode}
\NewDocumentCommand \songti { } { \CJKfamily { zhsong } }
\NewDocumentCommand \heiti { } { \CJKfamily { zhhei } }
\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } }
\NewDocumentCommand \kaishu { } { \CJKfamily { zhkai } }
% \end{macrocode}
% 重定义字号命令。
% \begin{macrocode}
\RenewDocumentCommand \large { } { \zihao { 4 } }
% 载入设置的字体。此处设置与文档类一同载入,否则在导言区后载入字体可能导致一部分覆盖字体的命令失效。
% \BeforeBeginEnvironment { document } { \@@_load_font: }
\@@_load_font: