Newer
Older
% \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 }
}
% \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 }
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
% \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}
title .tl_set:N = \l_@@_info_title_tl,
title .initial:n = { 空 },
title* .tl_set:N = \l_@@_info_title_en_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/keywords,info/keywords*}
% \changes{v0.11}{2021/10/01}{修改了添加关键词的方式。}
% 关键词列表。
% \begin{macrocode}
keywords .clist_set:N = \l_@@_info_keywords_clist,
keywords* .clist_set:N = \l_@@_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 = \l_@@_info_grade_tl,
student-id .tl_set:N = \l_@@_info_id_tl,
author .tl_set:N = \l_@@_info_author_tl,
author* .tl_set:N = \l_@@_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 = \l_@@_info_dept_tl,
department* .tl_set:N = \l_@@_info_dept_en_tl,
major .tl_set:N = \l_@@_info_major_tl,
major* .tl_set:N = \l_@@_info_major_en_tl,
field .tl_set:N = \l_@@_info_field_tl,
field* .tl_set:N = \l_@@_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 = \l_@@_info_supv_clist,
supervisor* .tl_set:N = \l_@@_info_supv_en_tl,
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{info/supervisor-ii,info/supervisor-ii*}
% 第二导师信息。
% \begin{macrocode}
supervisor-ii .clist_set:N = \l_@@_info_supv_ii_clist,
supervisor-ii* .tl_set:N = \l_@@_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 = \l_@@_info_sm_date_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 = \l_@@_info_df_date_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 = \l_@@_info_chairman_tl,
reviewer .clist_set:N = \l_@@_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 = \l_@@_info_clc_tl,
secret-level .tl_set:N = \l_@@_info_seclv_tl,
udc .tl_set:N = \l_@@_info_udc_tl,
supervisor-contact .tl_set:N = \l_@@_info_supv_cont_tl,
}
% \end{macrocode}
% \end{macro}
%
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
% \changes{v0.16}{2022/03/06}{正确处理学位和类型信息。}
% 设置学位信息。该设置需要放在 \cs{ProcessKeysOptions}
% 命令以及载入配置文件中的常量信息后进行。
% \begin{macrocode}
\tl_set:Nx \l_@@_info_degree_tl
{
\clist_item:Nn \c_@@_name_degree_clist
{ \g_@@_info_degree_int }
}
\int_compare:nTF { \g_@@_info_degree_int == 1 }
{ \tl_set:Nn \l_@@_info_diploma_tl { ug } }
{ \tl_set:Nn \l_@@_info_diploma_tl { g } }
% \end{macrocode}
%
% 设置类型信息。
% \begin{macrocode}
\tl_set:Nx \l_@@_info_type_tl
{ \clist_item:Nn \c_@@_name_type_clist { \g_@@_info_type_int } }
\tl_put_left:Nx \l_@@_info_type_tl
{ \tl_use:c { c_@@_name_ \l_@@_info_diploma_tl _tl } }
% \end{macrocode}
%
% 在导言区录入用户信息后进行变量设置。此处使用到了 \pkg{ctex} 提供的命令,
% 应当位于载入文档类之后。
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
3264
3265
3266
3267
3268
% \begin{macrocode}
\ctex_at_end_preamble:n
{
% \end{macrocode}
% 拼合双导师的姓名和职称。
% \begin{macrocode}
\bool_set:Nn \l_@@_second_supv_bool
{ ! \clist_if_empty_p:N \l_@@_info_supv_ii_clist }
\tl_set:Nx \l_@@_info_supv_full_tl
{
\clist_use:Nn \l_@@_info_supv_clist { \@@_hskip: }
\bool_if:NT \l_@@_second_supv_bool
{
\@@_quad:
\clist_use:Nn \l_@@_info_supv_ii_clist { \@@_hskip: }
}
}
\tl_set:Nx \l_@@_info_supv_full_en_tl
{
\l_@@_info_supv_en_tl
\bool_if:NT \l_@@_second_supv_bool
{ \@@_quad: \l_@@_info_supv_ii_en_tl }
}
% \end{macrocode}
% 将 ISO 格式的原始日期字符串格式化为中文日期表示,该字符串需要进行展开。
% \begin{macrocode}
\tl_set:Nn \l_@@_info_sm_date_tl
{
\exp_last_unbraced:NV
\@@_date:www \l_@@_info_sm_date_raw_tl \q_stop
}
% \end{macrocode}
% 英文提交日期以及答辩日期仅用于研究生封面。
% \begin{macrocode}
{
\tl_set:Nn \l_@@_info_sm_date_en_tl
{
\exp_last_unbraced:NV
\@@_date_en:www \l_@@_info_sm_date_raw_tl \q_stop
}
\tl_set:Nn \l_@@_info_df_date_tl
{
\exp_last_unbraced:NV
\@@_date:www \l_@@_info_df_date_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 ]
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
\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 字体
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
\@@_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 }
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
\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 作为思源字体。}
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
% 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:
% 草稿模式下显示页面文字范围边界以及页眉、页脚线。
% \begin{macrocode}
\bool_if:NT \g_@@_draft_bool { \geometry { showframe } }
% \begin{variable}{\c_@@_pagestyle_tl}
% 针对不同学位类型的默认页面样式设置。
%<definition-ug>\tl_const:Nn \c_@@_pagestyle_tl { plain }
%<definition-g>\tl_const:Nn \c_@@_pagestyle_tl { headings }
% \end{macrocode}
% \end{variable}
%
% 提供设置页眉页脚的用户接口。在 \cs{fancyhead} 的可选参数中,
% \opt{E} 和 \opt{O} 分别表示在偶数页(even)和奇数页(odd),
% 而 \opt{L}、\opt{R} 和 \opt{C} 则分别表示左(left)、右
% (right)和中间(center)。按照通常的排版规则,在双面模式下,
% 偶数页的中间页眉文字在左,奇数页则在右。单面模式下,左右页眉都要显示。
% \begin{macrocode}
%<*class>
\keys_define:nn { nju / style }
{
% \end{macrocode}
% \changes{v0.16}{2022/03/18}{可手动指定页眉样式。}
% 页眉格式。
% \begin{macrocode}
header/format .tl_gset:N = \g_@@_header_format_tl,
header/format .initial:n = \small \kaishu,
% \begin{macro}{style/header,style/header*}
% \changes{v0.16}{2022/03/18}{可手动指定页眉内容。}
% 页眉内容,分别对应双面模式和单面模式。
% \begin{macrocode}
header .clist_gset:N = \g_@@_header_twoside_clist,
header* .clist_gset:N = \g_@@_header_oneside_clist,
header .initial:n =
{
{ EL } { \leftmark }, { OR } { \rightmark }
},
header* .initial:n =
{
{ L } { \leftmark }, { R } { \rightmark }
},
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{style/footer/format}
% \changes{v0.16}{2022/03/19}{可手动指定页脚样式。}
% 页脚格式。
% \begin{macrocode}
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
footer/format .initial:n = \small \rmfamily,
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{style/footer,style/footer*}
% \changes{v0.16}{2022/03/18}{可手动指定页脚内容。}
% 页脚内容,同页眉。
% \begin{macrocode}
footer .clist_gset:N = \g_@@_footer_twoside_clist,
footer* .clist_gset:N = \g_@@_footer_oneside_clist,
footer .initial:n = { { C } { \thepage } },
footer* .initial:n = { { C } { \thepage } }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\g_@@_header_clist,\g_@@_footer_clist}
% 设置页眉页脚。
% \begin{macrocode}
\clist_new:N \g_@@_header_clist
\clist_new:N \g_@@_footer_clist
% \end{macrocode}
% \end{macro}
%
% 在导言区末尾确定页眉页脚内容。
% \begin{macrocode}
\ctex_at_end_preamble:n
{
\bool_if:NTF \g_@@_twoside_bool
{
\clist_set_eq:NN \g_@@_header_clist \g_@@_header_twoside_clist
\clist_set_eq:NN \g_@@_footer_clist \g_@@_footer_twoside_clist
}
{
\clist_set_eq:NN \g_@@_header_clist \g_@@_header_oneside_clist
\clist_set_eq:NN \g_@@_footer_clist \g_@@_footer_oneside_clist
%
% \begin{macro}{\@@_header:nn,\@@_footer:nn}
% 对 \pkg{fancyhdr} 的命令进行包装,便于设置页眉页脚。
% \begin{macrocode}
\cs_new_protected:Npn \@@_header:nn #1#2
{ \fancyhead [#1] { \g_@@_header_format_tl #2 } }
\cs_new_protected:Npn \@@_footer:nn #1#2
{ \fancyfoot [#1] { \g_@@_footer_format_tl #2 } }
% \end{macrocode}
% \end{macro}
%
% 重定义 \pkg{fancyhdr} 的 \opt{plain} 样式,即本科生正文和部分特殊页面使用的的
% 页眉页脚样式。页眉无内容;页脚为居中的页码,使用五号新罗马体数字。注意标记页眉
% 页脚横线宽度的变量并不是 |dim| 类型的,但是采取了该类型的格式。
\clist_map_inline:Nn \g_@@_footer_clist { \@@_footer:nn ##1 }
\tl_set:Nn \headrulewidth { \c_zero_dim }
\tl_set:Nn \footrulewidth { \c_zero_dim }
\tl_set:Nn \headrulewidth { 0.4 pt }
\dim_set:Nn \headheight { 20 pt }
\clist_map_inline:Nn \g_@@_header_clist
{ \@@_header:nn ##1 }
\clist_map_inline:Nn \g_@@_footer_clist { \@@_footer:nn ##1 }
% \changes{v0.12}{2021/12/03}{修复了摘要页字体格式泄漏到正文的问题。}
% \changes{v0.12}{2021/12/03}{修复了页眉上长标题重叠的问题。}
% 重定义 \cs{mainmatter},在论文主体部分载入页面样式设置,
% 使用阿拉伯数字重新进行页码编号。
% \begin{macrocode}
\RenewDocumentCommand \mainmatter { }
{
\cleardoublepage
% \changes{v0.16}{2022/03/18}{研究生模板的目录、摘要等页面也显示页眉。}
% 在文档起始位置设置默认页面样式。
% \begin{macrocode}
\AtBeginEnvironment { document }
{
\exp_args:NV \pagestyle \c_@@_pagestyle_tl
\pagenumbering { Roman }
}
% \end{macrocode}
%
\tl_const:Nn \c_@@_sec_format_tl { \large \normalfont \sffamily }
% \begin{macro}{\@@_add_tocline:n,\@@_add_tocline:V}
% 添加目录条目。
\cs_new_protected:Npn \@@_add_tocline:n #1
{ \addcontentsline { toc } { chapter } { \c_@@_sec_format_tl #1 } }
\cs_generate_variant:Nn \@@_add_tocline:n { V }
% \begin{macro}{\@@_chapter:n,\@@_chapter:V}
% 含有目录和 PDF 标签的无编号章。
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_chapter_header:n}
% 单页模式下,目录、摘要、符号表等特殊页面的页眉中间为相应标题,左右为空。这里通
% 过居中的 \tn{leftmark} 实现。
% \begin{macrocode}
\cs_new_protected:Npn \@@_chapter_header:n #1
{
\bool_if:NTF \g_@@_twoside_bool
{ \markboth { #1 } { #1 } }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\njuchapter}
\NewDocumentCommand \njuchapter { m } { \@@_chapter:n { #1 } }
chapter / beforeskip = 10 pt,
chapter / afterskip = 60 pt,
chapter / format = \c_@@_sec_format_tl \centering,
section / format = \c_@@_sec_format_tl,
subsection / format = \c_@@_sec_format_tl,
subsubsection / format = \c_@@_sec_format_tl,
% \changes{v0.13}{2021/12/09}{移除 \pkg{tocloft},用 \pkg{ctex} 修改目录样式。}
chapter / tocline = \c_@@_sec_format_tl \CTEXnumberline { #1 } #2
% \begin{macrocode}
\keys_define:nn { nju / style }
{
% \end{macrocode}
% \begin{macro}{style/toc-in-toc}
% \changes{v0.15}{2022/02/04}{可选择目录自身是否出现在目录中。}
% 是否在目录中显示目录自身。
% \begin{macrocode}
toc-in-toc .bool_gset:N = \g_@@_toc_in_toc_bool,
toc-in-toc .initial:n = true
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_make_toc:nn,\@@_make_toc:Vn}
% 目录自身不出现在目录中时需特别处理。参考
% \url{https://tex.stackexchange.com/a/1821}。
\keys_set:nn { ctex }
{ chapter/format = \centering \zihao { 3 } \bfseries }
\bool_if:NTF \g_@@_toc_in_toc_bool
{ \@@_chapter:n { #1 } }
{
\chapter * { #1 }
\pdfbookmark [0] { #1 } { #2 }
\@@_chapter_header:n { #1 }
}
% \begin{macro}{\tableofcontents,\listoffigures,\listoftables}
% 重定义目录命令,修改标题格式并插入书签。
% 存储传入 \pkg{biblatex} 的选项列表。
% \begin{macrocode}
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{\g_@@_bib_resource_clist}
% 存储参考文献数据源列表。
% \begin{macrocode}
\clist_new:N \g_@@_bib_resource_clist
% \end{macrocode}
% \end{variable}
%
% \begin{macrocode}
\msg_new:nnn { njuthesis } { extra-bib-style }
{
Wrongly-placed~ bib~ style.\\
Please~ use~ the~ `bib/style`~ field.
}
% \end{macrocode}
%
\keys_define:nn { nju / bib }
{
% \end{macrocode}
% \changes{v0.15}{2022/02/11}{可使用国标以外的文献样式。}
% 参考文献样式。国家标准为顺序编码制 \opt{numeric} 和著者-出版年制
% \opt{author-year},分别对应 \pkg{biblatex} 的 \opt{gb7714-2015}
% 和 \opt{gb7714-2015ay} 样式。其余样式一律视作 \opt{unknown}。用户
% 选取的样式会被加入选项列表中,以待传进 \pkg{biblatex} 宏包。
% \begin{macrocode}
style .choice:,
style / numeric .code:n =