diff options
author | Karl Berry <karl@freefriends.org> | 2022-08-08 21:00:24 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-08-08 21:00:24 +0000 |
commit | 06ce399249a627e8cfab294d85b39a9cbc91490b (patch) | |
tree | abfdefc701f72706341e437f956363ad07c3de2e /Master/texmf-dist/tex/latex/njuthesis/njuthesis.cls | |
parent | 8ca2c0f2f725360c1d1c530fc5a918bb593da82a (diff) |
njuthesis (8aug22)
git-svn-id: svn://tug.org/texlive/trunk@64081 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/njuthesis/njuthesis.cls')
-rw-r--r-- | Master/texmf-dist/tex/latex/njuthesis/njuthesis.cls | 1379 |
1 files changed, 887 insertions, 492 deletions
diff --git a/Master/texmf-dist/tex/latex/njuthesis/njuthesis.cls b/Master/texmf-dist/tex/latex/njuthesis/njuthesis.cls index 5bc6ba2267b..018a77f98df 100644 --- a/Master/texmf-dist/tex/latex/njuthesis/njuthesis.cls +++ b/Master/texmf-dist/tex/latex/njuthesis/njuthesis.cls @@ -24,10 +24,12 @@ %% `.dtx' through XeTeX. %% \NeedsTeXFormat{LaTeX2e} -\GetIdInfo $Id: njuthesis.dtx 0.20.0 2022-06-10 14:42:00 +0800 NJU LUG <git+nju-lug-email-3104-issue-@yaoge123.cn>$ +\GetIdInfo $Id: njuthesis.dtx 1.0.0 2022-08-08 14:50:00 + +0800 NJU LUG <git+nju-lug-email-3104-issue-@yaoge123.cn>$ {Thesis template for Nanjing University} \ProvidesExplClass{njuthesis} {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} + \RequirePackage { xtemplate, l3keys2e } \msg_new:nnn { njuthesis } { l3-too-old } { @@ -53,30 +55,44 @@ { \sys_if_engine_xetex_p: } { \sys_if_engine_luatex_p: } { \msg_fatal:nnx { njuthesis } { unsupported-engine } { \c_sys_engine_str } } -\box_new:N \l__nju_tmp_box +\box_new:N \l__nju_tmpa_box +\box_new:N \l__nju_tmpb_box +\box_new:N \l__nju_tmpc_box \clist_new:N \l__nju_tmp_clist \dim_new:N \l__nju_tmpa_dim \dim_new:N \l__nju_tmpb_dim \int_new:N \l__nju_tmpa_int \int_new:N \l__nju_tmpb_int +\skip_new:N \l__nju_tmp_skip \tl_new:N \l__nju_tmpa_tl \tl_new:N \l__nju_tmpb_tl \int_new:N \g__nju_info_degree_int -\int_new:N \g__nju_info_diploma_int \int_new:N \g__nju_info_type_int \tl_new:N \g__nju_info_degree_tl -\tl_new:N \g__nju_info_diploma_tl -\tl_new:N \g__nju_info_type_tl \tl_new:N \g__nju_info_type_en_tl -\bool_new:N \g__nju_twoside_bool -\bool_set_true:N \g__nju_twoside_bool -\bool_new:N \l__nju_second_supv_bool +\bool_new:N \g__nju_opt_twoside_bool +\bool_set_true:N \g__nju_opt_twoside_bool +\bool_new:N \l__nju_second_supvbool \tl_new:N \g__nju_info_supvfull_tl \tl_new:N \g__nju_info_supvfull_en_tl -\tl_new:N \g__nju_latin_font_tl -\tl_new:N \g__nju_cjk_font_tl +\tl_new:N \g__nju_font_latin_tl +\tl_new:N \g__nju_font_cjk_tl +\tl_new:N \g__nju_font_math_tl +\tl_new:N \g__nju_font_path_tl +\bool_new:N \g__nju_font_path_bool +\bool_gset_false:N \g__nju_font_path_bool \tl_new:N \g__nju_config_tl -\clist_new:N \g__nju_theorem_type_clist +\clist_new:N \g__nju_thm_type_clist +\clist_gset:Nn \g__nju_thm_type_clist + { + { axiom } { 公理 }, + { corollary } { 推论 }, + { definition } { 定义 }, + { example } { 例 }, + { lemma } { 引理 }, + { proof, *+ } { 证明 }, + { theorem } { 定理 } + } \tl_const:Nx \c__nju_today_tl { \int_to_arabic:n { \c_sys_year_int } - @@ -84,37 +100,35 @@ \int_to_arabic:n { \c_sys_day_int } } \clist_const:Nn \c__nju_name_type_clist - { 毕业论文, 毕业设计 } + { 学士, 硕士, 博士 } \clist_const:Nn \c__nju_name_type_en_clist - { THESIS, DESIGN } + { Bachelor, Master, Doctor~of~Philosophy } \clist_const:Nn \c__nju_name_degree_clist - { 学士, 硕士, 硕士专业, 博士 } -\clist_const:Nn \c__nju_name_degree_en_clist - { Bachelor, Master, Master, Doctor~of~Philosophy } -\clist_const:Nn \c__nju_month_en_clist + { \c_empty_tl, 专业 } +\clist_const:Nn \c__nju_name_month_en_clist { January, February, March, April, May, June, July, August, September, October, November, December } -\clist_const:Nn \c__nju_blind_info_clist +\clist_const:Nn \c__nju_name_anon_clist { author, chairman, clc, dept, email, field, grade, id, major, secretlv, supvcont, udc } -\clist_const:Nn \c__nju_blind_info_en_clist - { author, dept, field, major, supv, supv_ii } -\clist_const:Nn \c__nju_blind_infolist_clist - { reviewer, supv, supv_ii } +\clist_const:Nn \c__nju_name_anon_en_clist + { author, dept, field, major, supv, supvii } +\clist_const:Nn \c__nju_name_anonlist_clist + { reviewer, supv, supvii } \cs_new:Nn \__nju_quad: { \skip_horizontal:n { 1 em } } \cs_new:Nn \__nju_qquad: { \skip_horizontal:n { 2 em } } -\cs_new:Nn \__nju_vskip: { \skip_vertical:N \c__nju_smallvskip_dim } -\cs_new:Nn \__nju_hskip: { \skip_horizontal:N \c__nju_smallhskip_dim } -\cs_new_protected:Npn \__nju_vskip:N #1 +\cs_new:Nn \__nju_vskip: { \skip_vertical:N \c__nju_vsep_dim } +\cs_new:Nn \__nju_hskip: { \skip_horizontal:N \c__nju_hsep_dim } +\cs_set_protected:Npn \__nju_vskip:N #1 { - \hrule height \c_zero_dim - \nobreak - \skip_vertical:n { - \baselineskip - \lineskip } + \tex_hrule:D \@height \c_zero_dim \scan_stop: + \tex_penalty:D \@M \skip_vertical:N #1 + \skip_vertical:N \c_zero_dim } \cs_new_protected:Npn \__nju_define_name:nn #1#2 { \tl_const:cn { c__nju_name_ #1 _tl } { #2 } } @@ -129,91 +143,108 @@ { \dim_const:cn { c__nju_ #1 _dim } { #2 } } \cs_new_protected:Npn \__nju_define_skip:nn #1#2 { \skip_const:cn { c__nju_ #1 _skip } { #2 } } -\cs_new_protected:Npn \__nju_add_theorem_type:nnn #1#2#3 - { - \clist_gput_right:Nn \g__nju_theorem_type_clist { #1 } - \__nju_define_name:nnn { #1 } { #2 } { #3 } - } \cs_new:Npn \__nju_name:n #1 { \tl_use:c { c__nju_name_ #1 _tl } } \cs_new:Npn \__nju_info:n #1 { \tl_use:c { g__nju_info_ #1 _tl } } -\cs_new_protected:Npn \__nju_ulined_center_box:nn #1#2 +\cs_new:Npn \__nju_fmt:n #1 { \tl_use:c { c__nju_fmt_ #1 _tl } } +\cs_new:Npn \__nju_name:nn #1#2 + { \group_begin: \__nju_fmt:n {#1} \__nju_name:n {#2} \group_end: } +\cs_new_protected:Npn \__nju_box_ulined:NN #1#2 { \mode_leave_vertical: - \rule [ -0.55 ex ] { #1 } { 0.4 pt } + \rule [ \c__nju_ruledpi_dim ] { #1 } { \c__nju_rulehti_dim } \skip_horizontal:n { -#1 } - \hbox_to_wd:nn { #1 } { \hfil #2 \hfil } + \hbox_to_wd:nn { #1 } { \tex_hfil:D #2 \tex_hfil:D } } -\cs_new_protected:Npn \__nju_spread_box:nnn #1#2#3 +\cs_generate_variant:Nn \__nju_box_ulined:NN { Nc } +\cs_new_protected:Npn \__nju_box_ulined_info:Nn #1#2 + { \__nju_box_ulined:Nc #1 { g__nju_info_ #2 _tl } } +\cs_new_protected:Npn \__nju_box_spread:NNn #1#2#3 { \mode_leave_vertical: - \__nju_get_text_width:Nn \l__nju_tmpa_dim { #2 #3 } + \__nju_get_width:Nn \l__nju_tmpa_dim { #2 #3 } \hbox_to_wd:nn { #1 } { \dim_compare:nTF { \l__nju_tmpa_dim > #1 } { - \scalebox + \tex_hfil:D \scalebox { \dim_to_decimal_in_unit:nn { #1 } { \l__nju_tmpa_dim } } - [ 1.0 ] { #2 #3 } + [ 1.0 ] { #2 #3 } \tex_hfil:D } - { #2 \tl_map_inline:nn { #3 } { ##1 \hfil } \unskip } + { #2 \tl_map_inline:nn { #3 } { ##1 \tex_hfil:D } \tex_unskip:D } } } -\cs_generate_variant:Nn \__nju_spread_box:nnn { nnV } -\cs_generate_variant:Nn \__nju_spread_box:nnn { nnx } -\cs_new_protected:Npn \__nju_multiline_box:NNNn #1#2#3#4 +\cs_generate_variant:Nn \__nju_box_spread:NNn { NNv } +\cs_new_protected:Npn \__nju_box_spread_name:Nn #1#2 + { \__nju_box_spread:NNv #1 \c_empty_tl { c__nju_name_ #2 _tl } } +\cs_new_protected:Npn \__nju_box_spread_name:NNn #1#2#3 + { \__nju_box_spread:NNv #1 #2 { c__nju_name_ #3 _tl } } +\cs_new_protected:Npn \__nju_box_center:Nn #1#2 + { + \mode_leave_vertical: + \hbox_to_wd:nn {#1} { \tex_hfil:D #2 \tex_hfil:D } + } +\cs_new_protected:Npn \__nju_box_multiline:NNNN #1#2#3#4 { \int_set:Nn #1 { 1 } \int_set:Nn #2 { \clist_count:N #3 } - \int_compare:nF { #2 > 4 } - { \int_set:Nn #2 { 4 } } + \int_compare:nF { #2 > 4 } { \int_set:Nn #2 { 4 } } \int_do_until:nn { #1 > #2 } { - \__nju_ulined_center_box:nn { #4 } - { \clist_item:Nn #3 { #1 } } \\ + \clist_pop:NN #3 \l__nju_tmpa_tl + \__nju_box_ulined:NN #4 \l__nju_tmpa_tl \tex_par:D \int_incr:N #1 } } \cs_new_protected:Npn \__nju_uline:n #1 { \mode_leave_vertical: - \rule [ -0.55 ex ] { #1 } { 0.4 pt } + \rule [ \c__nju_ruledpi_dim ] { #1 } { \c__nju_rulehti_dim } \skip_horizontal:n { -#1 } } -\cs_new_protected:Npn \__nju_uuline:n #1 +\cs_new_protected:Npn \__nju_uuline:N #1 { \mode_leave_vertical: - \rule [ -0.5 ex ] { #1 } { 0.4 pt } + \rule [ \c__nju_ruledpii_dim ] { #1 } { \c__nju_rulehtii_dim } \skip_horizontal:n { -#1 } - \rule [ -0.6 ex ] { #1 } { 0.4 pt } + \rule [ \c__nju_ruledpiii_dim ] { #1 } { \c__nju_rulehtii_dim } \skip_horizontal:n { -#1 } } -\cs_new:Npn \__nju_get_text_width:Nn #1#2 +\cs_new:Npn \__nju_get_width:Nn #1#2 { - \hbox_set:Nn \l__nju_tmp_box {#2} - \dim_set:Nn #1 { \box_wd:N \l__nju_tmp_box } + \hbox_set:Nn \l__nju_tmpa_box {#2} + \dim_set:Nn #1 { \box_wd:N \l__nju_tmpa_box } + } +\cs_generate_variant:Nn \__nju_get_width:Nn { NV } +\cs_generate_variant:Nn \__nju_get_width:Nn { Nv } +\cs_new:Npn \__nju_get_max_width:NN #1#2 + { + \clist_map_inline:Nn #2 + { + \__nju_get_width:Nv \l__nju_tmpa_dim { g__nju_info_ ##1 _tl } + \dim_gset:Nn #1 { \dim_max:nn {#1} { \l__nju_tmpa_dim } } + } } -\cs_generate_variant:Nn \__nju_get_text_width:Nn { NV } \cs_new_protected:Npn \__nju_full_uline:Nn #1#2 { - \__nju_get_text_width:Nn #1 { #2 } + \__nju_get_width:Nn #1 { #2 } \dim_set:Nn #1 { \textwidth - #1 } #2 } -\cs_generate_variant:Nn \__nju_full_uline:Nn { NV } +\cs_generate_variant:Nn \__nju_full_uline:Nn { Nx } \cs_new_protected:Npn \__nju_uline_entry:Nnnn #1#2#3#4 { - \__nju_full_uline:NV #1 { \__nju_name:n { #2 } #4 } - \__nju_ulined_center_box:nn { #1 } { \__nju_info:n { #3 } } + \__nju_full_uline:Nx #1 { \__nju_name:n { #2 } #4 } + \__nju_box_ulined_info:Nn #1 { #3 } } \cs_new_protected:Npn \__nju_uline_bientry:Nnnn #1#2#3#4 { - \__nju_full_uline:NV #1 { \__nju_name:n { #2 } #4 } + \__nju_full_uline:Nx #1 { \__nju_name:n { #2 } #4 } \dim_sub:Nn #1 { \textwidth / 2 } - \__nju_ulined_center_box:nn { #1 } { \__nju_info:n { #3 } } + \__nju_box_ulined_info:Nn #1 { #3 } } \cs_new:Npn \__nju_date:www #1-#2-#3 \q_stop { \__zhnum_date_aux:nnn { #1 } { #2 } { #3 } } \cs_new:Npn \__nju_date_en:www #1-#2-#3 \q_stop - { \clist_item:Nn \c__nju_month_en_clist { #2 } ~#3 , ~#1 } + { \clist_item:Nn \c__nju_name_month_en_clist { #2 } ~#3 , ~#1 } \cs_new_protected:Npn \__nju_date:n #1 { \__nju_date:nn { #1 } { } } \cs_new_protected:Npn \__nju_date_en:n #1 { \__nju_date:nn { #1 } { _en } } \cs_generate_variant:Nn \exp_last_unbraced:NV { cV } @@ -225,74 +256,106 @@ { \tl_if_empty:NTF \l__nju_tmpa_tl { \__nju_name:n { blankdate #2 } } - { \exp_last_unbraced:cV { __nju_date #2 :www } \l__nju_tmpa_tl \q_stop } + { + \exp_last_unbraced:cV { __nju_date #2 :www } + \l__nju_tmpa_tl \q_stop + } } } +\cs_new_protected:Npn \__nju_at_begin_document:n #1 + { \hook_gput_next_code:nn { begin document } { #1 } } +\cs_new_protected:Npn \__nju_cs_clear:N #1 + { \cs_set_eq:NN #1 \prg_do_nothing: } \msg_new:nnn { njuthesis } { missing-title } { The~ title~ should~ not~ be~ left~ blank.\\ Please~ check~ whether~ you~ have~ fill~ in~ both~ Chinese~ and~ English~ titles. } +\cs_new:Npn \__nju_loop_until:nnn #1#2#3 + { #2 \bool_if:nF {#1} { #3 \__nju_loop_until:nnn {#1} {#2} {#3} } } +\cs_new:Npn \__nju_breakpar_loop:n #1 + { + \dim_set:Nn \l__nju_tmpa_dim + { - \tex_prevdepth:D - \c__nju_ruledpi_dim - \c__nju_rulehti_dim } + \hbox_gset:Nn \l__nju_tmpc_box { } + \__nju_loop_until:nnn { \box_if_empty_p:N \l__nju_tmpb_box } + { + \box_gset_to_last:N \l__nju_tmpb_box + \tex_unskip:D \tex_unpenalty:D + } + { + \hbox_gset:Nn \l__nju_tmpc_box + { + \vbox_top:n + { + \box_use_drop:N \l__nju_tmpb_box + \__kernel_kern:n { \l__nju_tmpa_dim } + \tex_hrule:D + } + \tex_penalty:D + \l__nju_tmpa_box + \hbox_unpack_drop:N \l__nju_tmpc_box + } + #1 + } + } +\cs_new:Npn \__nju_breakpar_print:nn #1#2 + { + \group_begin: + \tex_noindent:D #1 + \hbox_unpack_drop:N \l__nju_tmpc_box #2 + \tex_par:D + \group_end: + } \cs_new_protected:Npn \__nju_uline_title: { - \setbox0 = \vbox{ - \leftskip=0.5em plus 1 fill - \rightskip=\leftskip \parskip=1cm - \parindent=\z@ \g__nju_info_title_tl \par - \global\setbox2=\hbox{} - \loop - \setbox1=\lastbox \unskip\unpenalty - \unless\ifvoid1 - \global\setbox2=\hbox{\__nju_uline_box:\penalty0\unhbox2} - \repeat + \vbox_set:Nn \l__nju_tmpa_box + { + \skip_set:Nn \tex_leftskip:D { .5 em plus 1 fill } + \skip_set_eq:NN \tex_rightskip:D \tex_leftskip:D + \g__nju_info_title_tl \tex_par:D + \__nju_breakpar_loop:n { } } - { \noindent \unhbox2 \par } + \__nju_breakpar_print:nn { } { } } -\cs_new_protected:Npn \__nju_cover_entry_title:nnn #1#2#3 +\cs_new_protected:Npn \__nju_cover_entry_title:NNN #1#2#3 { \tl_if_empty:NT \g__nju_info_title_tl { \msg_error:nn { njuthesis } { missing-title } } - \__nju_spread_box:nnV { #2 } { \kaishu } \c__nju_name_title_tl + \__nju_box_spread_name:NNn #1 #3 { title } \mode_leave_vertical: \__nju_hskip: - \parbox [ t ] { #3 } + \parbox [ t ] { #2 } { - \dim_set_eq:NN \baselineskip \c__nju_coverlineskip_dim - #1 \__nju_uline_title: - \dim_gset_eq:NN \l__nju_tmpa_dim \prevdepth + \dim_set_eq:NN \tex_baselineskip:D \c__nju_clineskip_dim + \c__nju_fmt_covertitle_tl \__nju_uline_title: + \dim_gset_eq:NN \l__nju_tmpa_dim \tex_prevdepth:D } - \par \prevdepth \l__nju_tmpa_dim - } -\cs_new_protected:Npn \__nju_cover_entry:nnn #1#2#3 - { - \__nju_spread_box:nnx { #2 } { \kaishu } { \__nju_name:n { #1 } } - \__nju_hskip: - \__nju_ulined_center_box:nn { #3 } { \__nju_info:n { #1 } } - \par - } -\cs_new_protected:Npn \__nju_cover_bientry:nnnn #1#2#3#4 - { - \__nju_spread_box:nnx { #3 } { \kaishu } { \__nju_name:n { #1 } } - \__nju_hskip: - \__nju_ulined_center_box:nn { #4 } { \__nju_info:n { #1 } } - \__nju_hskip: - \__nju_spread_box:nnx { #3 } { \kaishu } { \__nju_name:n { #2 } } - \__nju_hskip: - \__nju_ulined_center_box:nn { #4 } { \__nju_info:n { #2 } } - \par - } -\cs_new_protected:Npn \__nju_cover_entry_supv:nnn #1#2#3 - { - \__nju_spread_box:nnx { #2 } { \kaishu } { \__nju_name:n { #1 } } - \__nju_hskip: - \__nju_ulined_center_box:nn { #3 } - { \clist_item:cn { g__nju_info_ #1 _clist } { 1 } } - \__nju_hskip: - \__nju_spread_box:nnV { #2 } { \kaishu } \c__nju_name_supv_ttl_tl - \__nju_hskip: - \__nju_ulined_center_box:nn { #3 } - { \clist_item:cn { g__nju_info_ #1 _clist } { 2 } } - \par + \tex_par:D + \dim_set_eq:NN \tex_prevdepth:D \l__nju_tmpa_dim + } +\cs_new_protected:Npn \__nju_cover_entry:NNNn #1#2#3#4 + { + \__nju_box_spread_name:NNn #1 #3 { #4 } \__nju_hskip: + \__nju_box_ulined_info:Nn #2 { #4 } \tex_par:D + } +\cs_new_protected:Npn \__nju_cover_entry:NNNnn #1#2#3#4#5 + { + \__nju_box_spread_name:NNn #1 #3 { #4 } \__nju_hskip: + \__nju_box_ulined_info:Nn #2 { #4 } \__nju_hskip: + \__nju_box_spread_name:NNn #1 #3 { #5 } \__nju_hskip: + \__nju_box_ulined_info:Nn #2 { #5 } \tex_par:D + } +\cs_new_protected:Npn \__nju_cover_entry_supv:NNNn #1#2#3#4 + { + \tl_set:Nn \l__nju_tmpa_tl + { \clist_item:cn { g__nju_info_ #4 _clist } { 1 } } + \tl_set:Nn \l__nju_tmpb_tl + { \clist_item:cn { g__nju_info_ #4 _clist } { 2 } } + \__nju_box_spread_name:NNn #1 #3 { #4 } \__nju_hskip: + \__nju_box_ulined:NN #2 \l__nju_tmpa_tl \__nju_hskip: + \__nju_box_spread_name:NNn #1 #3 { supvtitle } \__nju_hskip: + \__nju_box_ulined:NN #2 \l__nju_tmpb_tl \tex_par:D } \cs_new_protected:Npn \__nju_emblem:N #1 { \njuemblem [ \c__nju_fmt_emblemcolor_tl ] { #1 } { ! } } @@ -301,59 +364,52 @@ \cs_new_protected:Npn \__nju_abs_bookmark:nn #1#2 { \phantomsection - \bool_if:NTF \g__nju_abs_in_toc_bool - { \__nju_add_tocline:n { #1 } } - { \pdfbookmark [0] { #1 } { #2 } } + \__nju_bookmark:Nnn \g__nju_abs_showentry_bool {#1} {#2} \__nju_chapter_header:n { #1 } } \cs_generate_variant:Nn \__nju_abs_bookmark:nn { Vn } -\cs_new_protected:Npn \__nju_abs_title:n #1 +\cs_new_protected:Npn \__nju_abs_title:N #1 { - \__nju_get_text_width:Nn \l__nju_tmpa_dim {#1} - \__nju_uuline:n { \l__nju_tmpa_dim } #1 + \__nju_get_width:NV \l__nju_tmpa_dim #1 + \__nju_uuline:N \l__nju_tmpa_dim #1 } -\cs_generate_variant:Nn \__nju_abs_title:n { V } -\cs_new_protected:Npn \__nju_uline_box: - { \vtop{\box1\kern-\prevdepth\kern0.5ex\hrule} } \msg_new:nnn { njuthesis } { abs-title-too-long } { Your~ title~ is~ too~ long~ to~ fit~ in~ two~ lines.\\ I~ have~ drawn~ additional~ lines~ to~ contain~ it,~ which~ will~ probably~ make~ your~ abstract~ page~ look~ slightly~ different~ from~ the~ standard.\\ - You~ can~ use~ the~ "style/abstract-title"~ key~ + You~ can~ use~ the~ "abstract/title-style"~ key~ to~ disable~ this~ message. } -\cs_new_protected:Npn \__nju_uline_list:nnn #1#2#3 +\cs_new_protected:Npn \__nju_uline_list:NNn #1#2#3 { - \hbox_set:Nn \l__nju_tmp_box {#1} - \setbox0 = \vbox{\hangindent=\wd\l__nju_tmp_box \hangafter=-1 - \leftskip=#3 \rightskip=\leftskip \parindent=\z@ #2\par - \global\setbox2=\hbox{} + \vbox_set:Nn \l__nju_tmpa_box + { + \__nju_get_width:Nn \tex_hangindent:D { #3 } + \int_set:Nn \tex_hangafter:D { -1 } + \skip_set_eq:NN \tex_leftskip:D #2 + \skip_set_eq:NN \tex_rightskip:D \tex_leftskip:D + \tex_noindent:D #1 \tex_par:D \int_gzero:N \l__nju_tmpa_int - \loop - \setbox1=\lastbox \unskip\unpenalty - \unless\ifvoid1 - \global\setbox2=\hbox{\__nju_uline_box:\penalty0\unhbox2} - \int_gincr:N \l__nju_tmpa_int - \repeat + \__nju_breakpar_loop:n { \int_gincr:N \l__nju_tmpa_int } } - { - \noindent\copy\l__nju_tmp_box\unhbox2 - \bool_if:NT \g__nju_strict_abs_title_bool + \__nju_breakpar_print:nn { #3 } + { + \bool_if:NT \g__nju_abs_title_strict_bool { \int_case:nnF { \l__nju_tmpa_int } { { 0 } { \msg_error:nn { njuthesis } { missing-title } } { 1 } { \__nju_uline:n { \textwidth } } - { 2 } { \prg_do_nothing: } + { 2 } { } } { \msg_warning:nn { njuthesis } { abs-title-too-long } } - \par + \tex_par:D } } } -\cs_generate_variant:Nn \__nju_uline_list:nnn { xnn } +\cs_generate_variant:Nn \__nju_uline_list:NNn { NNx } \DeclareObjectType { nju } { \c_zero_int } \DeclareTemplateInterface { nju } { element } { \c_zero_int } { @@ -369,37 +425,31 @@ bottom-skip = \l__njuelem_bottom_skip, align = { - l = - { \tl_set_eq:NN \l__njuelem_begin_align_tl \flushleft - \tl_set_eq:NN \l__njuelem_end_align_tl \endflushleft }, - r = - { \tl_set_eq:NN \l__njuelem_begin_align_tl \flushright - \tl_set_eq:NN \l__njuelem_end_align_tl \endflushright }, - c = - { \tl_set_eq:NN \l__njuelem_begin_align_tl \center - \tl_set_eq:NN \l__njuelem_end_align_tl \endcenter }, - n = - { \tl_clear:N \l__njuelem_begin_align_tl - \tl_clear:N \l__njuelem_end_align_tl } + l = { \cs_set_eq:NN \__njuelem_align: \raggedright }, + r = { \cs_set_eq:NN \__njuelem_align: \raggedleft }, + c = { \cs_set_eq:NN \__njuelem_align: \centering }, + n = { \__nju_cs_clear:N \__njuelem_align: } } } { \AssignTemplateKeys \group_begin: - \l__njuelem_begin_align_tl - \l__njuelem_format_tl - \l__njuelem_content_tl \par - \l__njuelem_end_align_tl + \__njuelem_align: + \l__njuelem_format_tl \l__njuelem_content_tl \tex_par:D \group_end: \__nju_vskip:N \l__njuelem_bottom_skip } +\exp_args_generate:n { NVV } \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 + bottom-skip : skip = \c_zero_skip, + bm-text : tokenlist = \c_empty_tl, + bm-name : tokenlist = \c_empty_tl, + bookmark : choice { toc, pdf, none } = none } \DeclareTemplateCode { nju } { page } { \c_zero_int } { @@ -407,13 +457,23 @@ prefix = \l__njupage_prefix_tl, format = \l__njupage_format_tl, top-skip = \l__njupage_top_skip, - bottom-skip = \l__njupage_bottom_skip + bottom-skip = \l__njupage_bottom_skip, + bm-text = \l__njupage_bm_text_tl, + bm-name = \l__njupage_bm_name_tl, + bookmark = + { + toc = { \cs_set_eq:NN \__njupage_bookmark:nn \__nju_bookmark_toc:nn }, + pdf = { \cs_set_eq:NN \__njupage_bookmark:nn \__nju_bookmark_pdf:nn }, + none = { \cs_set:Nn \__njupage_bookmark:nn { } } + } } { \AssignTemplateKeys \clearpage \thispagestyle { empty } \__nju_vskip:N \l__njupage_top_skip + \exp_args:NVV \__njupage_bookmark:nn + \l__njupage_bm_text_tl \l__njupage_bm_name_tl \group_begin: \l__njupage_format_tl \clist_map_inline:Nn \l__njupage_element_clist @@ -421,53 +481,110 @@ \group_end: \__nju_vskip:N \l__njupage_bottom_skip } -\cs_new_protected:Npn \__nju_declare_element:nn #1#2 +\cs_new:Npn \__nju_declare_element:nn #1#2 { \DeclareInstance { nju } {#1} { element } {#2} } -\cs_new_protected:Npn \__nju_declare_page:nn #1#2 +\cs_new:Npn \__nju_declare_page:nn #1#2 { \DeclareInstance { nju } {#1} { page } {#2} } \keys_define:nn { nju } { - degree .choices:nn = { ug, mg, mf, phd } - { \int_gset_eq:NN \g__nju_info_degree_int \l_keys_choice_int }, - degree .initial:n = ug, - type .choices:nn = { thesis, design } + type .choices:nn = { bachelor, master, doctor, postdoc } { \int_gset_eq:NN \g__nju_info_type_int \l_keys_choice_int }, - type .initial:n = thesis, - nlcover .bool_set:N = \g__nju_nlcover_bool, - nlcover .initial:n = false, - decl-page .bool_set:N = \g__nju_decl_bool, + type .initial:n = bachelor, + degree .choices:nn = { academic, professional } + { \int_gset_eq:NN \g__nju_info_degree_int \l_keys_choice_int }, + degree .initial:n = academic, + nl-cover .bool_set:N = \g__nju_opt_nlcover_bool, + nl-cover .initial:n = false, + decl-page .bool_set:N = \g__nju_opt_decl_bool, decl-page .initial:n = false, - draft .bool_gset:N = \g__nju_draft_bool, + draft .bool_gset:N = \g__nju_opt_draft_bool, draft .initial:n = false, oneside .value_forbidden:n = true, twoside .value_forbidden:n = true, - oneside .bool_gset_inverse:N = \g__nju_twoside_bool, - blind .value_forbidden:n = true, - blind .bool_set:N = \g__nju_blind_bool, + oneside .bool_gset_inverse:N = \g__nju_opt_twoside_bool, + anonymous .bool_set:N = \g__nju_opt_anon_bool, + anonymous .initial:n = false, latin-font .choices:nn = { gyre, mac, win, none } - { \tl_set_eq:NN \g__nju_latin_font_tl \l_keys_choice_tl }, + { \tl_set_eq:NN \g__nju_font_latin_tl \l_keys_choice_tl }, cjk-font .choices:nn = { fandol, founder, mac, noto, source, win, none } - { \tl_set_eq:NN \g__nju_cjk_font_tl \l_keys_choice_tl }, - config .tl_set:N = \g__nju_config_clist + { \tl_set_eq:NN \g__nju_font_cjk_tl \l_keys_choice_tl }, + math-font .choices:nn = + { + asana, cambria, fira, garamond, lm, libertinus, newcm, + stix, bonum, dejavu, pagella, schola, termes, xits, none + } + { \tl_set_eq:NN \g__nju_font_math_tl \l_keys_choice_tl }, + math-font .initial:n = xits, + font-path .code:n = + { + \bool_set_true:N \g__nju_font_path_bool + \tl_set_eq:NN \g__nju_font_path_tl \l_keys_choice_tl + }, + zihao .tl_set:N = \g__nju_opt_zihao_tl, + zihao .initial:n = -4, + linespread .tl_set:N = \g__nju_opt_linespread_tl, + linespread .initial:n = 1.625, + config .clist_set:N = \g__nju_config_clist } -\ProcessKeysOptions { nju } +\clist_new:N \g__nju_name_optional_pkg_clist +\cs_new_protected:Npn \__nju_define_pkg_keys:nnn #1#2#3 + { + \keys_define:nn { nju } + { + #1 .bool_gset:c = { g__nju_opt_load_ #2 _bool }, + #1 .initial:n = #3 + } + \cs_new_protected:cpn { __nju_loadpkg_ #2 : } + { + \bool_if:cT { g__nju_opt_load_ #2 _bool } + { \RequirePackage { #1 } } + } + \clist_put_right:Nn \g__nju_name_optional_pkg_clist {#1} + } +\clist_map_inline:nn + { + { biblatex } { blx } { true }, + { cleveref } { cref } { true }, + { ntheorem } { nthm } { true }, + { enumitem } { enit } { true }, + { footmisc } { fm } { true }, + { unicode-math } { um } { true } + } + { \__nju_define_pkg_keys:nnn #1 } \keys_define:nn { nju } { - % abstract .meta:nn = { nju / abstract } { #1 }, - bib .meta:nn = { nju / bib } { #1 }, - % cover .meta:nn = { nju / cover } { #1 }, - % font .meta:nn = { nju / font } { #1 }, - % footer .meta:nn = { nju / footer } { #1 }, - % footnote .meta:nn = { nju / footnote } { #1 }, - % header .meta:nn = { nju / header } { #1 }, - info .meta:nn = { nju / info } { #1 }, - style .meta:nn = { nju / style } { #1 }, - theorem .meta:nn = { nju / theorem } { #1 } - % toc .meta:nn = { nju / toc } { #1 } - } -\NewDocumentCommand \njusetup { m } { \keys_set:nn { nju } { #1 } } + minimal .value_forbidden:n = true, + minimal .code:n = + { + \clist_map_inline:Nn \g__nju_name_optional_pkg_clist + { \keys_set:nn { nju } { ##1 = false } } + \keys_set:nn { nju } { math-font = none } + } + } +\ProcessKeysOptions { nju } +\bool_if:NTF \g__nju_opt_twoside_bool + { \tl_const:Nn \c__nju_name_pagemode_tl { twoside } } + { \tl_const:Nn \c__nju_name_pagemode_tl { oneside } } +\clist_map_inline:nn + { + abstract, bib, image, footer, footnote, header, + info, label-sep, listoffigures, listoftables, + math, style, theorem, tableofcontents + } + { \keys_define:nn { nju } { #1 .meta:nn = { nju / #1 } {##1} } } +\NewDocumentCommand \njusetup { o m } + { + \tl_if_novalue:nTF { #1 } + { \keys_set:nn { nju } { #2 } } + { + \tl_if_in:nnTF { #1 } { / } + { \keys_set:nn { nju } { #1 = {#2} } } + { \keys_set:nn { nju / #1 } {#2} } + } + } +\@onlypreamble \njusetup \NewDocumentCommand \njusetformat { m m } { \tl_gset:cn { c__nju_fmt_ #1 _tl } { #2 } } \NewDocumentCommand \njusetlength { s m m } @@ -482,68 +599,64 @@ { \__nju_set_tokenlist:nnnnn {#1} {#2} {#3} {#4} { text } } \cs_new_protected:Npn \__nju_set_tokenlist:nnnnn #1#2#3#4#5 { - \tl_if_novalue:nTF { #3 } - { \tl_clear:N \l__nju_tmpa_tl } - { \tl_set:Nn \l__nju_tmpa_tl { _ #3 } } - \bool_if:nTF { #1 } - { \tl_set:Nn \l__nju_tmpb_tl { _en } } - { \tl_clear:N \l__nju_tmpb_tl } - \tl_gset:cn { c__nju_ #5 _ #2 \l__nju_tmpa_tl \l__nju_tmpb_tl _tl } {#4} + \bool_if:nTF { #1 } + { \tl_set_eq:NN \l__nju_tmpb_tl \c__nju_name_suffix_en_tl } + { \tl_clear:N \l__nju_tmpb_tl } + \tl_gset:cn { c__nju_ #5 _ #2 #3 \l__nju_tmpb_tl _tl } {#4} } -\PassOptionsToClass +\exp_args:Nx \PassOptionsToClass { a4paper, UTF8, scheme = chinese, - \bool_if:NTF \g__nju_twoside_bool { twoside, } { oneside, } - \bool_if:NT \g__nju_draft_bool { draft, } - linespread = 1.625, - fontset = none, - zihao = -4 + \c__nju_name_pagemode_tl, + \bool_if:NT \g__nju_opt_draft_bool { draft, } + linespread = \g__nju_opt_linespread_tl, + fontset = none, + zihao = \g__nju_opt_zihao_tl } { ctexbook } \clist_map_inline:nn { { no-math } { fontspec }, { perpage } { footmisc }, - { hyphens } { url }, - { warnings-off={ mathtools-colon, mathtools-overbracket } } - { unicode-math }, { capitalise, nameinlink, noabbrev } { cleveref } } { \PassOptionsToPackage #1 } \LoadClass { ctexbook } [ 2018/04/01 ] +\__nju_loadpkg_enit: +\__nju_loadpkg_fm: +\bool_if:NTF \g__nju_opt_load_um_bool + { \RequirePackage { unicode-math } } + { \RequirePackage { amsmath } } \RequirePackage { geometry, fancyhdr, - footmisc, setspace, - mathtools, - unicode-math, booktabs, caption, graphicx, - enumitem, - hyperref, - cleveref + hyperref } -\bool_if:NT \g__nju_twoside_bool { \RequirePackage{ emptypage } } +\__nju_loadpkg_cref: +\bool_if:NT \g__nju_opt_load_nthm_bool + { + \PassOptionsToPackage { amsmath, thmmarks, noconfig } { ntheorem } + \RequirePackage { ntheorem } + } +\bool_if:NT \g__nju_opt_twoside_bool { \RequirePackage { emptypage } } \sys_if_engine_xetex:T { - \RequirePackage{xeCJKfntef} + \RequirePackage { xeCJKfntef } \NewDocumentCommand \njuline { m } { \CJKunderline{#1} } } \sys_if_engine_luatex:T { - \RequirePackage{lua-ul} + \RequirePackage { lua-ul } \NewDocumentCommand \njuline { m } { \underLine{#1} \null } } -\bool_lazy_and:nnT - { \g__nju_decl_bool } - { !\int_compare_p:n { \g__nju_info_degree_int == 1 } } - { \RequirePackage { tabularray } } \msg_new:nnn { njuthesis } { package-too-old } { Package~ "#1"~ is~ too~ old.\\ @@ -559,7 +672,6 @@ } \sys_if_engine_luatex:T { \__nju_check_pkg_version:nnn { luatexja } { 2021/10/24 } { 20211024.0 } } -\RequirePackage { filehook } \msg_new:nnn { njuthesis } { package-conflict } { The~ "#2"~ package~ is~ incompatible~ with~ "#1".\\ @@ -568,21 +680,30 @@ } \cs_new_protected:Npn \__nju_check_pkg_conflict:nn #1#2 { - \AtEndOfPackageFile * { #1 } + \ctex_at_begin_package:nn { #2 } + { \msg_warning:nnnn { njuthesis } { package-conflict } {#1} {#2} } + } +\bool_if:NT \g__nju_opt_load_um_bool + { + \clist_map_inline:nn { - \AtBeginOfPackageFile * { #2 } - { \msg_error:nnnn { njuthesis } { package-conflict } {#1} {#2} } + amscd, amsfonts, amssymb, bbm, bm, eucal, + eufrak, mathrsfs, newtxmath, upgreek } + { \__nju_check_pkg_conflict:nn { unicode-math } { #1 } } } -\clist_map_inline:nn +\exp_args:Nx \file_input:n { - amscd, amsfonts, amssymb, bbm, bm, eucal, - eufrak, mathrsfs, newtxmath, upgreek + njuthesis- + \int_case:nn { \g__nju_info_type_int } + { + { 1 } { undergraduate } + { 2 } { graduate } + { 3 } { graduate } + { 4 } { postdoctoral } + } + .def } - { \__nju_check_pkg_conflict:nn { unicode-math } { #1 } } -\int_compare:nTF { \g__nju_info_degree_int == 1 } - { \file_input:n { njuthesis-undergraduate.def } } - { \file_input:n { njuthesis- graduate.def } } \msg_new:nnn { njuthesis } { load-config } { I~ am~ loading~ config~ file~ "#1". } \clist_map_inline:Nn \g__nju_config_clist @@ -610,8 +731,8 @@ field* .tl_set:N = \g__nju_info_field_en_tl, supervisor .clist_set:N = \g__nju_info_supv_clist, supervisor* .tl_set:N = \g__nju_info_supv_en_tl, - supervisor-ii .clist_set:N = \g__nju_info_supv_ii_clist, - supervisor-ii* .tl_set:N = \g__nju_info_supv_ii_en_tl, + supervisor-ii .clist_set:N = \g__nju_info_supvii_clist, + supervisor-ii* .tl_set:N = \g__nju_info_supvii_en_tl, submit-date .tl_set:N = \g__nju_info_submitdate_raw_tl, submit-date .initial:V = \c__nju_today_tl, defend-date .tl_set:N = \g__nju_info_defenddate_raw_tl, @@ -628,126 +749,112 @@ supervisor-contact .tl_set:N = \g__nju_info_supvcont_tl, email .tl_set:N = \g__nju_info_email_tl } +\tl_set:Nx \g__nju_info_type_tl + { + \clist_item:Nn \c__nju_name_type_clist + { \g__nju_info_type_int } + } \tl_set:Nx \g__nju_info_degree_tl { + \g__nju_info_type_tl \clist_item:Nn \c__nju_name_degree_clist { \g__nju_info_degree_int } } -\int_compare:nTF { \g__nju_info_degree_int == 1 } - { \tl_set:Nn \g__nju_info_diploma_tl { ug } } - { \tl_set:Nn \g__nju_info_diploma_tl { g } } \ctex_at_end_preamble:n { - \tl_set:Nx \g__nju_info_type_tl - { \clist_item:Nn \c__nju_name_type_clist { \g__nju_info_type_int } } \tl_set:Nx \g__nju_info_type_en_tl { \clist_item:Nn \c__nju_name_type_en_clist { \g__nju_info_type_int } } - \tl_put_left:Nx \g__nju_info_type_tl - { \tl_use:c { c__nju_name_ \g__nju_info_diploma_tl _tl } } - \bool_set:Nn \l__nju_second_supv_bool - { ! \clist_if_empty_p:N \g__nju_info_supv_ii_clist } + \bool_set:Nn \l__nju_second_supvbool + { ! \clist_if_empty_p:N \g__nju_info_supvii_clist } \tl_set:Nx \g__nju_info_supvfull_tl { \clist_use:Nn \g__nju_info_supv_clist { \__nju_hskip: } - \bool_if:NT \l__nju_second_supv_bool + \bool_if:NT \l__nju_second_supvbool { \__nju_quad: - \clist_use:Nn \g__nju_info_supv_ii_clist { \__nju_hskip: } + \clist_use:Nn \g__nju_info_supvii_clist { \__nju_hskip: } } } \tl_set:Nx \g__nju_info_supvfull_en_tl { \g__nju_info_supv_en_tl - \bool_if:NT \l__nju_second_supv_bool - { \__nju_quad: \g__nju_info_supv_ii_en_tl } - } - \__nju_date:n { submit } - \int_compare:nF { \g__nju_info_degree_int == 1 } - { - \__nju_date_en:n { submit } - \__nju_date:n { defend } - \bool_if:NT \g__nju_nlcover_bool - { - \__nju_date:n { bottom } - \__nju_date:n { confer } - \tl_new:N \g__nju_info_confer_tl - \tl_set:Nn \g__nju_info_confer_tl - { - \textbf { \c__nju_name_nju_tl } \hfil - \g__nju_info_conferdate_tl - } - } + \bool_if:NT \l__nju_second_supvbool + { \__nju_quad: \g__nju_info_supvii_en_tl } } } -\bool_if:NT \g__nju_blind_bool +\bool_if:NT \g__nju_opt_anon_bool { \ctex_at_end_preamble:n { - \clist_map_inline:Nn \c__nju_blind_info_clist + \clist_map_inline:Nn \c__nju_name_anon_clist { \tl_gclear:c { g__nju_info_ #1 _tl } } - \clist_map_inline:Nn \c__nju_blind_info_en_clist + \clist_map_inline:Nn \c__nju_name_anon_en_clist { \tl_gclear:c { g__nju_info_ #1 _en_tl } } - \clist_map_inline:Nn \c__nju_blind_infolist_clist + \clist_map_inline:Nn \c__nju_name_anonlist_clist { \clist_gclear:c { g__nju_info_ #1 _clist } } \tl_gclear:N \c__nju_name_nju_tl \tl_gclear:N \c__nju_name_nju_en_tl } } \bool_lazy_or:nnT - { \tl_if_empty_p:N \g__nju_latin_font_tl } - { \tl_if_empty_p:N \g__nju_cjk_font_tl } + { \tl_if_empty_p:N \g__nju_font_latin_tl } + { \tl_if_empty_p:N \g__nju_font_cjk_tl } { \sys_if_platform_windows:TF { - \tl_set:Nn \g__nju_latin_font_tl { win } - \tl_set:Nn \g__nju_cjk_font_tl { win } + \tl_set:Nn \g__nju_font_latin_tl { win } + \tl_set:Nn \g__nju_font_cjk_tl { win } } { \ctex_if_platform_macos:TF { - \tl_set:Nn \g__nju_latin_font_tl { mac } - \tl_set:Nn \g__nju_cjk_font_tl { mac } + \tl_set:Nn \g__nju_font_latin_tl { mac } + \tl_set:Nn \g__nju_font_cjk_tl { mac } } { - \tl_set:Nn \g__nju_latin_font_tl { gyre } - \tl_set:Nn \g__nju_cjk_font_tl { fandol } + \tl_set:Nn \g__nju_font_latin_tl { gyre } + \tl_set:Nn \g__nju_font_cjk_tl { fandol } } } } -\cs_new_protected:Npn \__nju_load_latin_font_win: +\cs_new_protected:Npn \__nju_loadfont_latin_win: { - \setmainfont { Times~New~Roman } - \setsansfont { Arial } - \setmonofont { Courier~New } - [ Scale = MatchLowercase ] + \__fontspec_main_setmainfont:nn { } { Times~New~Roman } + \__fontspec_main_setsansfont:nn { } { Arial } + \__fontspec_main_setmonofont:nn + { Scale = MatchLowercase } + { Courier~New } } -\cs_new_protected:Npn \__nju_load_latin_font_mac: +\cs_new_protected:Npn \__nju_loadfont_latin_mac: { - \setmainfont { Times~New~Roman } - \setsansfont { Arial } - \setmonofont { Menlo } - [ Scale = MatchLowercase ] + \__fontspec_main_setmainfont:nn { } { Times~New~Roman } + \__fontspec_main_setsansfont:nn { } { Arial } + \__fontspec_main_setmonofont:nn + { Scale = MatchLowercase } + { Menlo } } -\cs_new_protected:Npn \__nju_load_latin_font_gyre: +\cs_new_protected:Npn \__nju_loadfont_latin_gyre: { - \setmainfont { texgyretermes } - [ + \__fontspec_main_setmainfont:nn + { Extension = .otf, UprightFont = *-regular, BoldFont = *-bold, ItalicFont = *-italic, BoldItalicFont = *-bolditalic - ] - \setsansfont { texgyreheros } - [ + } + { texgyretermes } + \__fontspec_main_setsansfont:nn + { Extension = .otf, UprightFont = *-regular, BoldFont = *-bold, ItalicFont = *-italic, BoldItalicFont = *-bolditalic - ] - \setmonofont { texgyrecursor } - [ + } + { texgyreheros } + \__fontspec_main_setmonofont:nn + { Extension = .otf, UprightFont = *-regular, BoldFont = *-bold, @@ -755,11 +862,12 @@ BoldItalicFont = *-bolditalic, Scale = MatchLowercase, Ligatures = CommonOff - ] + } + { texgyrecursor } } \cs_new_protected:Npn \__nju_hide_no_script_msg: { \msg_redirect_name:nnn { fontspec } { no-script } { info } } -\cs_new_protected:Npn \__nju_load_cjk_font_win: +\cs_new_protected:Npn \__nju_loadfont_cjk_win: { \setCJKmainfont { SimSun } [ AutoFakeBold = 2.17, ItalicFont = KaiTi ] @@ -770,7 +878,7 @@ \setCJKfamilyfont { zhfs } { FangSong } [ AutoFakeBold = 2.17 ] \setCJKfamilyfont { zhkai } { KaiTi } [ AutoFakeBold = 2.17 ] } -\cs_new_protected:Npn \__nju_load_cjk_font_mac: +\cs_new_protected:Npn \__nju_loadfont_cjk_mac: { \__nju_hide_no_script_msg: \setCJKmainfont{Songti~SC~Light}[ @@ -785,7 +893,7 @@ \setCJKfamilyfont{zhkai}{Kaiti~SC}[BoldFont=Kaiti~SC~Bold] \setCJKfamilyfont{zhnewhei}{PingFang~SC} } -\cs_new_protected:Npn \__nju_load_cjk_font_fandol: +\cs_new_protected:Npn \__nju_loadfont_cjk_fandol: { \__nju_hide_no_script_msg: \setCJKmainfont { FandolSong-Regular } @@ -819,7 +927,7 @@ AutoFakeBold = 2.17 ] } -\cs_new_protected:Npn \__nju_load_cjk_font_founder: +\cs_new_protected:Npn \__nju_loadfont_cjk_founder: { \sys_if_engine_xetex:T { \xeCJKEditPunctStyle {quanjiao} { optimize-kerning = true } } @@ -838,7 +946,7 @@ \setCJKfamilyfont { zhfs } { FZFangSong-Z02 } \defaultCJKfontfeatures{} } -\cs_new_protected:Npn \__nju_load_cjk_font_noto: +\cs_new_protected:Npn \__nju_loadfont_cjk_noto: { \setCJKmainfont [ @@ -865,7 +973,7 @@ \setCJKfamilyfont { zhkai } { FZKai-Z03 } [AutoFakeBold=2.17] } -\cs_new_protected:Npn \__nju_load_cjk_font_source: +\cs_new_protected:Npn \__nju_loadfont_cjk_source: { \setCJKmainfont [ @@ -892,66 +1000,145 @@ \setCJKfamilyfont { zhkai } { FZKai-Z03 } [AutoFakeBold=2.17] } -\cs_new_protected:Npn \__nju_load_math_font: +\cs_new:Npn \__nju_define_math_font:nn #1#2 { - % \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}] + \cs_new:cpn { __nju_loadfont_math_ #1 : } + { \__um_setmathfont:nn { } { #2 } } } -\cs_new_protected:Npn \__nju_load_font: +\clist_map_inline:nn { - \use:c { __nju_load_latin_font_ \g__nju_latin_font_tl : } - \use:c { __nju_load_cjk_font_ \g__nju_cjk_font_tl : } - \__nju_load_math_font: + { asana } { Asana-Math.otf }, + { fira } { FiraMath-Regular.otf }, + { garamond } { Garamond-Math.otf }, + { lm } { latinmodern-math.otf }, + { libertinus } { LibertinusMath-Regular.otf }, + { stix } { STIXMath-Regular.otf }, + { bonum } { texgyrebonum-math.otf }, + { dejavu } { texgyredejavu-math.otf }, + { pagella } { texgyrepagella-math.otf }, + { schola } { texgyreschola-math.otf }, + { termes } { texgyretermes-math.otf } + } + { \__nju_define_math_font:nn #1 } +\cs_new:Npn \__nju_loadfont_math_cambria: + { + \bool_if:NTF \g__nju_font_path_bool + { + \__um_setmathfont:nn + { Path = \g__nju_font_path_tl/, FontIndex = 1 } + { cambria.ttc } + } + { \__um_setmathfont:nn { } { Cambria~Math } } + } +\cs_new:Npn \__nju_loadfont_math_xits: + { + \bool_if:NTF \g__nju_opt_math_int_bool + { \tl_set:Nn \l__nju_tmpa_tl { 8 } } + { \tl_clear:N \l__nju_tmpa_tl } + \__um_setmathfont:nn + { + Extension = .otf, + StylisticSet = \l__nju_tmpa_tl, + BoldFont = XITSMath-Bold + } + { XITSMath-Regular } + \__um_setmathfont:nn + { + Extension = .otf, + StylisticSet = 1, + range = {cal,bfcal} + } + { XITSMath-Regular } + } +\cs_new:Npn \__nju_loadfont_math_newcm: + { + \bool_if:NTF \g__nju_opt_math_int_bool + { \tl_set:Nn \l__nju_tmpa_tl { 2 } } + { \tl_clear:N \l__nju_tmpa_tl } + \__um_setmathfont:nn + { + Extension = .otf, + StylisticSet = \l__nju_tmpa_tl + } + { NewCMMath-Book } + \__um_setmathfont:nn + { + Extension = .otf, + StylisticSet = 1, + range = {scr,bfscr} + } + { NewCMMath-Book } + \__fontspec_main_setmathrm:nn + { + Extension = .otf, + UprightFont = *-Book, + BoldFont = *-Bold, + ItalicFont = *-BookItalic, + BoldItalicFont = *-BoldItalic + } + { NewCM10 } + \__fontspec_main_setmathsf:nn + { + Extension = .otf, + UprightFont = *-Book, + BoldFont = *-Bold, + ItalicFont = *-BookOblique, + BoldItalicFont = *-BoldOblique + } + { NewCMSans10 } + \__fontspec_main_setmathtt:nn + { + Extension = .otf, + UprightFont = *-Book, + ItalicFont = *-BookItalic, + BoldFont = *-Bold, + BoldItalicFont = *-BoldOblique + } + { NewCMMono10 } + } +\cs_new:Npn \__nju_loadfont_math_none: { } +\cs_new_protected:Npn \__nju_loadfont: + { + \use:c { __nju_loadfont_latin_ \g__nju_font_latin_tl : } + \use:c { __nju_loadfont_cjk_ \g__nju_font_cjk_tl : } \NewDocumentCommand \songti { } { \CJKfamily { zhsong } } \NewDocumentCommand \heiti { } { \CJKfamily { zhhei } } \NewDocumentCommand \fangsong { } { \CJKfamily { zhfs } } \NewDocumentCommand \kaishu { } { \CJKfamily { zhkai } } - \RenewDocumentCommand \large { } { \zihao { 4 } } + \NewDocumentCommand \bigger { } { \ctex_zihao:n { 4 } } } -\__nju_load_font: +\__nju_loadfont: \geometry { vmargin = 2.5 cm, hmargin = 3.2 cm, headheight = 15 pt } -\bool_if:NT \g__nju_draft_bool { \geometry { showframe } } -\keys_define:nn { nju / style } +\bool_if:NT \g__nju_opt_draft_bool { \geometry { showframe } } +\keys_define:nn { nju / header } { - header/format .tl_gset:N = \c__nju_fmt_header_tl, - header .clist_gset:N = \g__nju_header_twoside_clist, - header* .clist_gset:N = \g__nju_header_oneside_clist, - header .initial:n = - { - { EL } { \leftmark }, { OR } { \rightmark } - }, - header* .initial:n = - { - { L } { \leftmark }, { R } { \rightmark } - }, - footer/format .tl_gset:N = \c__nju_fmt_footer_tl, - footer .clist_gset:N = \g__nju_footer_twoside_clist, - footer* .clist_gset:N = \g__nju_footer_oneside_clist, - footer .initial:n = { { C } { \thepage } }, - footer* .initial:n = { { C } { \thepage } } + content .clist_gset:N = \g__nju_header_twoside_clist, + content* .clist_gset:N = \g__nju_header_oneside_clist, + content .initial:n = + { { EL } { \leftmark }, { OR } { \rightmark } }, + content* .initial:n = + { { L } { \leftmark }, { R } { \rightmark } } + } +\keys_define:nn { nju / footer } + { + content .clist_gset:N = \g__nju_footer_twoside_clist, + content* .clist_gset:N = \g__nju_footer_oneside_clist, + content .initial:n = { { C } { \thepage } }, + content* .initial:n = { { C } { \thepage } } } \clist_new:N \g__nju_header_clist \clist_new:N \g__nju_footer_clist \ctex_at_end_preamble:n { - \bool_if:NTF \g__nju_twoside_bool - { - \clist_set_eq:NN \g__nju_header_clist \g__nju_header_twoside_clist - \clist_set_eq:NN \g__nju_footer_clist \g__nju_footer_twoside_clist - } - { - \clist_set_eq:NN \g__nju_header_clist \g__nju_header_oneside_clist - \clist_set_eq:NN \g__nju_footer_clist \g__nju_footer_oneside_clist - } + \clist_set_eq:Nc \g__nju_header_clist + { g__nju_header_ \c__nju_name_pagemode_tl _clist } + \clist_set_eq:Nc \g__nju_footer_clist + { g__nju_footer_ \c__nju_name_pagemode_tl _clist } } \cs_new_protected:Npn \__nju_header:nn #1#2 { \fancyhead [#1] { \c__nju_fmt_header_tl \nouppercase {#2} } } @@ -998,27 +1185,42 @@ \exp_args:NV \pagestyle \c__nju_fmt_pagestyle_tl \pagenumbering { Roman } } -\cs_new_protected:Npn \__nju_add_tocline:n #1 +\cs_new:Npn \__nju_bookmark_toc:n #1 { \addcontentsline { toc } { chapter } { \c__nju_fmt_chapterintoc_tl #1 } } -\cs_generate_variant:Nn \__nju_add_tocline:n { V } -\cs_new_protected:Npn \__nju_chapter:n #1 - { - \chapter * { #1 } - \__nju_add_tocline:n { #1 } - \__nju_chapter_header:n { #1 } - } -\cs_generate_variant:Nn \__nju_chapter:n { V } +\cs_generate_variant:Nn \__nju_bookmark_toc:n { V } +\cs_new:Npn \__nju_bookmark_toc:nn #1#2 + { \phantomsection \__nju_bookmark_toc:n {#1} } +\cs_new:Npn \__nju_bookmark_pdf_nosec:nn #1#2 + { \pdfbookmark [0] { #1 } { #2 } } +\cs_new:Npn \__nju_bookmark_pdf:nn #1#2 + { \phantomsection \__nju_bookmark_pdf_nosec:nn {#1} {#2} } +\cs_new:Npn \__nju_bookmark:Nnn #1#2#3 + { + \bool_if:NTF #1 + { \__nju_bookmark_toc:n { #2 } } + { \__nju_bookmark_pdf_nosec:nn { #2 } { #3 } } + } +\cs_new:Npn \__nju_chapter:Nnn #1#2#3 + { + \chapter * { #2 } + \__nju_bookmark:Nnn #1 { #2 } { #3 } + \__nju_chapter_header:n { #2 } + } +\cs_new:Npn \__nju_chapter:n #1 + { \__nju_chapter:Nnn \c_true_bool {#1} { } } +\cs_generate_variant:Nn \__nju_chapter:Nnn { cnn } +\cs_generate_variant:Nn \__nju_chapter:n { V } \cs_new_protected:Npn \__nju_chapter_header:n #1 { - \bool_if:NTF \g__nju_twoside_bool + \bool_if:NTF \g__nju_opt_twoside_bool { \markboth { #1 } { #1 } } { \markboth { \hfill #1 \hfill } { } } } \NewDocumentCommand \njuchapter { m } { \__nju_chapter:n { #1 } } \keys_set:nn { ctex } { - chapter / beforeskip = 10 pt, - chapter / afterskip = 60 pt, + chapter / beforeskip = \c__nju_chapterbefore_dim, + chapter / afterskip = \c__nju_chapterafter_dim, chapter / format = \c__nju_fmt_chapter_tl, section / format = \c__nju_fmt_section_tl, subsection / format = \c__nju_fmt_subsection_tl, @@ -1028,37 +1230,58 @@ contentsname = \c__nju_name_tableofcontents_tl, listfigurename = \c__nju_name_listoffigures_tl, listtablename = \c__nju_name_listoftables_tl, - chapter / tocline = \c__nju_fmt_chapterintoc_tl \CTEXnumberline { #1 } #2 - } -\keys_define:nn { nju / style } - { - toc-in-toc .bool_gset:N = \g__nju_toc_in_toc_bool, - toc-in-toc .initial:n = true + chapter / tocline = \c__nju_fmt_chapterintoc_tl \CTEXnumberline {#1} #2 } \cs_new_protected:Npn \__nju_make_toc:nn #1#2 { \group_begin: \keys_set:nn { ctex } { chapter/format = \c__nju_fmt_toctitle_tl } - \bool_if:NTF \g__nju_toc_in_toc_bool - { \__nju_chapter:n { #1 } } - { - \chapter * { #1 } - \pdfbookmark [0] { #1 } { #2 } - \__nju_chapter_header:n { #1 } - } + \__nju_chapter:cnn { g__nju_ #2 _showentry_bool } {#1} {#2} \group_end: \@starttoc { #2 } } -\cs_generate_variant:Nn \__nju_make_toc:nn { Vn } -\RenewDocumentCommand \tableofcontents { } - { \__nju_make_toc:Vn \contentsname { toc } } -\RenewDocumentCommand \listoffigures { } - { \__nju_make_toc:Vn \listfigurename { lof } } -\RenewDocumentCommand \listoftables { } - { \__nju_make_toc:Vn \listtablename { lot } } -\clist_new:N \g__nju_biblatex_option_clist -\clist_new:N \g__nju_bib_resource_clist +\cs_generate_variant:Nn \__nju_make_toc:nn { vn } +\cs_new_protected:Npn \__nju_define_toc_cmd:nnn #1#2#3 + { + \keys_define:nn { nju / #1 } + { + toc-entry .bool_set:c = { g__nju_ #3 _showentry_bool }, + toc-entry .initial:n = true + } + \exp_args:Nc \RenewDocumentCommand { #1 } { } + { \__nju_make_toc:vn { #2 name } { #3 } } + } +\clist_map_inline:nn + { + { tableofcontents } { contents } { toc }, + { listoffigures } { listfigure } { lof }, + { listoftables } { listtable } { lot } + } + { \__nju_define_toc_cmd:nnn #1 } +\ctex_at_end_preamble:n + { + \bool_if:NF \g__nju_toc_showentry_bool + { + \bool_set_false:N \g__nju_lof_showentry_bool + \bool_set_false:N \g__nju_lot_showentry_bool + } + } +\keys_define:nn { nju / tableofcontents } + { + dotline .choice:, + dotline / chapter .code:n = + { + \cs_set_protected_nopar:Npn \l@chapter + { + \skip_vertical:N 1.0 em \@plus \p@ \scan_stop: + \@dottedtocline { \z@ } { \z@ } { 1.5 em } + } + }, + dotline / section .code:n = { } + } +\clist_new:N \g__nju_blx_option_clist +\clist_new:N \g__nju_blx_resource_clist \msg_new:nnn { njuthesis } { extra-bib-style } { Wrongly-placed~ bib~ style.\\ @@ -1069,66 +1292,69 @@ style .choice:, style / numeric .code:n = { - \clist_gput_right:Nn \g__nju_biblatex_option_clist + \clist_gput_right:Nn \g__nju_blx_option_clist { style = gb7714-2015 } }, style / author-year .code:n = { - \clist_gput_right:Nn \g__nju_biblatex_option_clist + \clist_gput_right:Nn \g__nju_blx_option_clist { style = gb7714-2015ay } }, style / unknown .code:n = - { - \clist_gput_right:Nx \g__nju_biblatex_option_clist - { style = \l_keys_value_tl } - }, + { \clist_gput_right:Nn \g__nju_blx_option_clist { style = #1 } }, style .initial:n = numeric, option .code:n = { \tl_if_in:VnTF \l_keys_value_tl { style = } { \msg_error:nn { njuthesis } { extra-bib-style } } { - \clist_gput_right:NV \g__nju_biblatex_option_clist + \clist_gput_right:NV \g__nju_blx_option_clist \l_keys_value_tl } }, resource .code:n = { - \clist_gput_right:NV \g__nju_bib_resource_clist + \clist_gput_right:NV \g__nju_blx_resource_clist \l_keys_value_tl }, } -\NewDocumentCommand \addbibresource { m } - { \clist_gput_right:Nn \g__nju_bib_resource_clist { #1 } } -\cs_new_protected:Npn \__nju_biblatex_pre_setup: +\bool_if:NT \g__nju_opt_load_blx_bool + { + \NewDocumentCommand \addbibresource { m } + { \clist_gput_right:Nn \g__nju_blx_resource_clist { #1 } } + } +\cs_new_protected:Npn \__nju_blx_pre_setup: { \cs_undefine:N \addbibresource - \clist_gput_right:Nn \g__nju_biblatex_option_clist { backend = biber } + \clist_gput_right:Nn \g__nju_blx_option_clist { backend = biber } \exp_args:NV \PassOptionsToPackage - \g__nju_biblatex_option_clist { biblatex } + \g__nju_blx_option_clist { biblatex } } -\cs_new_protected:Npn \__nju_biblatex_post_setup: +\cs_new_protected:Npn \__nju_blx_post_setup: { \defbibheading { njubibintoc } [ \bibname ] { \__nju_chapter:n { ##1 } } \tl_if_eq:NnTF \blx@refsecreset@level { 2 } { \DeclarePrintbibliographyDefaults { heading = subbibintoc } } { \DeclarePrintbibliographyDefaults { heading = njubibintoc } } - \clist_map_inline:Nn \g__nju_bib_resource_clist + \clist_map_inline:Nn \g__nju_blx_resource_clist { \addbibresource { ##1 } } } \BeforeBeginEnvironment { document } { - \__nju_biblatex_pre_setup: - \RequirePackage { biblatex } - \__nju_biblatex_post_setup: + \bool_if:NT \g__nju_opt_load_blx_bool + { + \__nju_blx_pre_setup: + \RequirePackage { biblatex } + \__nju_blx_post_setup: + } } \ctex_at_end_preamble:n { \pdfstringdefDisableCommands { - \cs_set_eq:NN \\ \prg_do_nothing: - \cs_set_eq:NN \quad \prg_do_nothing: - \cs_set_eq:NN \qquad \prg_do_nothing: + \clist_map_inline:nn + { \\, \quad, \qquad, \bigger } + { \__nju_cs_clear:N #1 } } \hypersetup { @@ -1143,28 +1369,24 @@ } } \cs_new_protected:Npn \__nju_cref_name:n #1 - { - \clist_map_inline:nn { #1 } + { \crefname {#1} { \__nju_name:n {#1} } { \__nju_name:n {#1} } } +\bool_if:NT \g__nju_opt_load_cref_bool + { + \crefdefaultlabelformat { #2#1#3\, } + \crefformat { equation } { 公式~#2#1#3~ } + \crefformat { chapter } { 第#2#1#3章 } + \crefformat { section } { 第~#2#1#3~节 } + \crefformat { subsection } { 第~#2#1#3~小节 } + \crefformat { subsubsection } { 第~#2#1#3~小节 } + \clist_map_inline:nn { figure, table, appendix, proof } + { \__nju_cref_name:n { #1 } } + } +\tl_new:N \g__nju_fn_style_tl +\keys_define:nn { nju / footnote } + { + style .choices:nn = { plain, pifont } { - \crefname { ##1 } - { \__nju_name:n { ##1 } } { \__nju_name:n { ##1 _en } } - } - } -\cs_generate_variant:Nn \__nju_cref_name:n { V } -\crefdefaultlabelformat { #2#1#3\, } -\crefformat { equation } { 公式~#2#1#3~ } -\crefformat { chapter } { 第#2#1#3章 } -\crefformat { section } { 第~#2#1#3~节 } -\crefformat { subsection } { 第~#2#1#3~小节 } -\crefformat { subsubsection } { 第~#2#1#3~小节 } -\__nju_cref_name:n { figure, table, appendix, proof } -\__nju_cref_name:V \g__nju_theorem_type_clist -\tl_new:N \l__nju_fn_style_tl -\keys_define:nn { nju / style } - { - footnote-style .choices:nn = { plain, pifont } - { - \tl_gset_eq:NN \l__nju_fn_style_tl \l_keys_choice_tl + \tl_gset_eq:NN \g__nju_fn_style_tl \l_keys_choice_tl \int_compare:nT { \l_keys_choice_int = 2 } { \RequirePackage { pifont } } } @@ -1175,7 +1397,7 @@ \tl_const:Nn \c__nju_fn_style_pifont_tl { pifont } \cs_new:Npn \__nju_footnote_number:N #1 { - \tl_case:NnF \l__nju_fn_style_tl + \tl_case:NnF \g__nju_fn_style_tl { \c__nju_fn_style_plain_tl { \int_use:N #1 } @@ -1184,15 +1406,39 @@ } { \int_use:N #1 } } -\cs_set:Npn \thefootnote { \__nju_footnote_number:N \c@footnote } -\cs_set:Npn \@makefntext #1 +\bool_if:NT \g__nju_opt_load_fm_bool { - \mode_leave_vertical: - \hbox_to_wd:nn { 1.5 em } { \@thefnmark \hfil } - #1 + \cs_set:Npn \thefootnote { \__nju_footnote_number:N \c@footnote } + \cs_set:Npn \@makefntext #1 + { + \mode_leave_vertical: + \hbox_to_wd:nn { 1.5 em } { \@thefnmark \tex_hfil:D } + #1 + } } +\keys_define:nn { nju / image } { path .code:n = { \graphicspath {#1} } } \DeclareGraphicsExtensions { .pdf, .eps, .jpg, .png } \BeforeBeginEnvironment { tabular } { \centering \zihao {5} } +\ctex_at_end_package:nn { tabularray } + { + \__tblr_use_lib_booktabs: + \tl_set:Nn \l__nju_tmpb_tl + { , abovesep = 4 pt, stretch = 0.8, cells = { font = \small } } + \tl_put_right:NV \l__tblr_default_tblr_inner_tl \l__nju_tmpb_tl + \tl_put_right:NV \l__tblr_default_talltblr_inner_tl \l__nju_tmpb_tl + \tl_put_right:Nn \l__tblr_default_talltblr_outer_tl { , headsep = -4 pt } + \DefTblrTemplate { caption-tag } { default } + { \c__nju_name_table_tl \hspace { 0.25em } \thetable } + \DefTblrTemplate { caption-sep } { default } { \quad } + \DefTblrTemplate { firsthead } { caption } + { + \makebox [ \tablewidth ] + { \parbox { \columnwidth } { \UseTblrTemplate {caption} {normal} } } + } + \SetTblrTemplate { firsthead } { caption } + \SetTblrStyle { caption } { font = \normalfont \bfseries \small } + \SetTblrStyle { note } { font = \normalfont \footnotesize } + } \DeclareCaptionStyle{njucap} { font = small, @@ -1202,62 +1448,214 @@ } \captionsetup [ figure ] { style = njucap } \captionsetup [ table ] { style = njucap } -\setlist { noitemsep } +\cs_generate_variant:Nn \ctex_patch_cmd:Nnn { cnv } +\clist_map_inline:nn { figure, table, equation } + { + \keys_define:nn { nju / label-sep } + { + #1 .tl_set:c = { g__nju_sep_ #1 _tl }, + #1 .initial:n = { - } + } + \__nju_at_begin_document:n + { \ctex_patch_cmd:cnv { the #1 } {.} { g__nju_sep_ #1 _tl } } + } +\bool_if:NT \g__nju_opt_load_enit_bool { \setlist { noitemsep } } +\bool_if:NTF \g__nju_opt_load_um_bool + { \tl_const:Nn \c__nju_name_qed_tl { \ensuremath { \mdlgwhtsquare } } } + { \tl_const:Nn \c__nju_name_qed_tl { \ensuremath { \rule {1ex} {1ex} } } } \keys_define:nn { nju / theorem } { - predefine .bool_set:N = \g__nju_thm_predefine_bool, - style .tl_set:N = \l__nju_thm_style_tl, - header-font .tl_set:N = \l__nju_thm_header_font_tl, - body-font .tl_set:N = \l__nju_thm_body_font_tl, - qed-symbol .tl_set:N = \l__nju_thm_qed_symbol_tl, - counter .tl_set:N = \l__nju_thm_counter_tl, - predefine .initial:n = true, - style .initial:n = plain, - header-font .initial:n = \normalfont \bfseries, - body-font .initial:n = \itshape, - qed-symbol .initial:n = \ensuremath { \mdwhtsquare }, - counter .initial:n = chapter + style .tl_set:N = \l__nju_thm_style_tl, + header-font .tl_set:N = \l__nju_thm_header_font_tl, + body-font .tl_set:N = \l__nju_thm_body_font_tl, + qed-symbol .tl_set:N = \l__nju_thm_qed_symbol_tl, + counter .tl_set:N = \l__nju_thm_counter_tl, + style .initial:n = plain, + header-font .initial:n = \normalfont \bfseries, + body-font .initial:n = \itshape, + qed-symbol .initial:V = \c__nju_name_qed_tl, + counter .initial:n = chapter, + type .clist_set:N = \g__nju_thm_type_clist, + define .value_forbidden:n = true, + define .code:n = + { + \clist_if_empty:NT \g__nju_thm_type_clist + { \msg_error:nn { njuthesis } { empty-theorem-type } } + \clist_map_inline:Nn \g__nju_thm_type_clist + { \__nju_thm_define:nn ##1 } + } + } +\msg_new:nnn { njuthesis } { empty-theorem-type } + { + Empty~ theorem~ list~ to~ define.\\ + The~ key~ "theorem/type"~ should~ not~ be~ set~ empty. } -\cs_new_protected:Npn \__nju_new_theorem:Nn #1#2 +\msg_new:nnn { njuthesis } { missing-ntheorem } { - \clist_map_inline:Nn #1 - { \newtheorem { ##1 } { \__nju_name:n { ##1 } } [#2] } + "ntheorem"~ package~ not~ detected.\\ + The~ functionality~ of~ built-in~ theorem~ settings~ require~ + loading~ the~ class~ with~ "ntheorem"~ option~ set~ to~ "true". } -\cs_generate_variant:Nn \__nju_new_theorem:Nn { NV } -\cs_new_protected:Npn \__nju_ntheorem_post_setup: +\cs_new_protected:Npn \__nju_thm_define:nn #1#2 { + \bool_if:NF \g__nju_opt_load_nthm_bool + { \msg_error:nn { njuthesis } { missing-ntheorem } } \exp_args:NV \theoremstyle \l__nju_thm_style_tl \exp_args:NV \theoremheaderfont \l__nju_thm_header_font_tl \exp_args:NV \theorembodyfont \l__nju_thm_body_font_tl - \exp_args:NV \theoremsymbol \l__nju_thm_qed_symbol_tl - \newtheorem* { proof } { \c__nju_name_proof_tl } + \clist_set:Nn \l__nju_tmp_clist { #1 } + \clist_pop:NN \l__nju_tmp_clist \l__nju_tmpa_tl + \clist_pop:NN \l__nju_tmp_clist \l__nju_tmpb_tl + \tl_if_in:NnT \l__nju_tmpb_tl { + } + { \exp_args:NV \theoremsymbol \l__nju_thm_qed_symbol_tl } + \tl_if_in:NnTF \l__nju_tmpb_tl { * } + { \__nju_thm_new:VVn \l__nju_tmpa_tl \c_novalue_tl {#2} } + { \__nju_thm_new:VVn \l__nju_tmpa_tl \l__nju_thm_counter_tl {#2} } + \bool_if:NT \g__nju_opt_load_cref_bool + { \crefname { \l__nju_tmpa_tl } {#2} {#2} } \theoremsymbol { } + } +\cs_new_protected:Npn \__nju_thm_new:nnn #1#2#3 + { \group_begin: - \clist_remove_all:Nn \g__nju_theorem_type_clist { proof } - \__nju_new_theorem:NV \g__nju_theorem_type_clist \l__nju_thm_counter_tl + \cs_if_exist:cT { end #1 } + { \cs_set_eq:NN \newtheorem \renewtheorem } + \tl_if_novalue:nTF {#2} + { \newtheorem * {#1} {#3} } + { \newtheorem {#1} {#3} [#2] } \group_end: } -\ctex_at_end_preamble:n +\cs_generate_variant:Nn \__nju_thm_new:nnn { VVn } +\bool_new:N \g__nju_opt_math_re_bool +\bool_new:N \g__nju_opt_math_int_bool +\bool_new:N \g__nju_opt_math_leq_bool +\bool_new:N \g__nju_opt_math_vec_bool +\bool_if:NTF \g__nju_opt_load_um_bool + { \tl_set_eq:NN \c__nju_name_integral_tl \l__um_nolimits_tl } + { \tl_set_eq:NN \c__nju_name_integral_tl \c_empty_tl } +\bool_if:NTF \g__nju_opt_load_um_bool + { \cs_new:Npn \__nju_um_setup:n #1 { \keys_set:nn { unicode-math } {#1} } } + { \cs_new:Npn \__nju_um_setup:n #1 { } } +\keys_define:nn { nju / math } + { + integral .choice:, + integral / upright .code:n = + { \bool_set_true:N \g__nju_opt_math_int_bool }, + integral / slanted .code:n = + { \bool_set_false:N \g__nju_opt_math_int_bool }, + integral-limits .choice:, + integral-limits / true .code:n = + { \tl_clear:N \l__um_nolimits_tl }, + integral-limits / false .code:n = + { \tl_set_eq:NN \l__um_nolimits_tl \c__nju_name_integral_tl }, + less-than-or-equal .choice:, + less-than-or-equal / slanted .code:n = + { \bool_set_true:N \g__nju_opt_math_leq_bool }, + less-than-or-equal / horizontal .code:n = + { \bool_set_false:N \g__nju_opt_math_leq_bool }, + math-ellipsis .choice:, + math-ellipsis / centered .code:n = + { + \DeclareRobustCommand \mathellipsis + { \mathinner { \unicodecdots } } + }, + math-ellipsis / lower .code:n = + { + \DeclareRobustCommand \mathellipsis + { \mathinner { \unicodeellipsis } } + }, + partial .choices:nn = + { upright, italic } { \__nju_um_setup:n { partial = #1 } }, + real-part .choice:, + real-part / roman .code:n = + { \bool_set_true:N \g__nju_opt_math_re_bool }, + real-part / fraktur .code:n = + { \bool_set_false:N \g__nju_opt_math_re_bool }, + vector .choice:, + vector / boldfont .code:n = + { \bool_set_true:N \g__nju_opt_math_vec_bool }, + vector / arrow .code:n = + { \bool_set_false:N \g__nju_opt_math_vec_bool }, + uppercase-greek .choice:, + uppercase-greek / upright .code:n = + { \__nju_um_setup:n { math-style = ISO } }, + uppercase-greek / italic .code:n = + { \__nju_um_setup:n { math-style = TeX } }, + style .choice:, + style / TeX .code:n = + { + \keys_set:nn { nju / math } + { + integral = slanted, + integral-limits = false, + less-than-or-equal = horizontal, + math-ellipsis = centered, + partial = italic, + real-part = fraktur, + vector = arrow, + uppercase-greek = upright + } + \__nju_um_setup:n { bold-style = TeX } + }, + style / ISO .code:n = + { + \keys_set:nn { nju / math } + { + integral = upright, + integral-limits = true, + less-than-or-equal = horizontal, + math-ellipsis = lower, + partial = upright, + real-part = roman, + vector = arrow, + uppercase-greek = italic + } + \__nju_um_setup:n { bold-style = ISO } + }, + style / GB .code:n = + { + \keys_set:nn { nju / math } + { + integral = upright, + integral-limits = false, + less-than-or-equal = slanted, + math-ellipsis = centered, + partial = upright, + real-part = roman, + vector = boldfont, + uppercase-greek = italic + } + \__nju_um_setup:n { bold-style = ISO } + }, + style .initial:n = GB + } +\__nju_at_begin_document:n { - \bool_if:NT \g__nju_thm_predefine_bool + \use:c { __nju_loadfont_math_ \g__nju_font_math_tl : } + \bool_if:NT \g__nju_opt_math_leq_bool + { + \cs_set_eq:NN \le \leslant + \cs_set_eq:NN \ge \geslant + \cs_set_eq:NN \leq \leqslant + \cs_set_eq:NN \geq \geqslant + } + \bool_if:NT \g__nju_opt_math_re_bool { - \PassOptionsToPackage { amsmath, thmmarks } { ntheorem } - \RequirePackage { ntheorem } - \__nju_ntheorem_post_setup: + \cs_set:Npn \Re { \operatorname { Re } } + \cs_set:Npn \Im { \operatorname { Im } } } + \bool_if:NT \g__nju_opt_math_vec_bool + { \cs_set_eq:NN \vec \symbf } } \cs_new_protected:Npn \__nju_new_img_cmd:nn #1#2 { - \exp_args:Nc \NewDocumentCommand { #1 } { o m m } + \exp_args:Nc \NewDocumentCommand { nju #1 } { o m m } { \includegraphics [ width = ##2, height = ##3 ] { #2 } } } -\cs_generate_variant:Nn \__nju_new_img_cmd:nn { nV } -\keys_define:nn { nju / style } +\keys_define:nn { nju / image } { - emblem-img .code:n = - { \__nju_new_img_cmd:nV { njuemblem } \l_keys_value_tl }, - name-img .code:n = - { \__nju_new_img_cmd:nV { njuname } \l_keys_value_tl } + nju-emblem .code:n = { \__nju_new_img_cmd:nn { emblem } {#1} }, + nju-name .code:n = { \__nju_new_img_cmd:nn { name } {#1} } } \msg_new:nnn { njuthesis } { missing-image } { @@ -1278,33 +1676,28 @@ \msg_warning:nn { njuthesis } { missing-image } \RequirePackage { njuvisual } } - \bool_if:NT \g__nju_blind_bool + \bool_if:NT \g__nju_opt_anon_bool { - \RenewDocumentCommand \njuemblem { o m m } { \prg_do_nothing: } - \RenewDocumentCommand \njuname { o m m } { \prg_do_nothing: } + \RenewDocumentCommand \njuemblem { o m m } { } + \RenewDocumentCommand \njuname { o m m } { } } } \RenewDocumentCommand \maketitle { } { - \bool_if:NF \g__nju_draft_bool + \bool_if:NF \g__nju_opt_draft_bool { \pagenumbering { gobble } - \bool_if:NTF \g__nju_nlcover_bool + \bool_if:NTF \g__nju_opt_nlcover_bool { \__nju_make_cover_nl: } { \__nju_make_cover: } } \tl_remove_all:Nn \g__nju_info_title_tl { \\ } - \bool_if:NF \g__nju_draft_bool + \bool_if:NF \g__nju_opt_draft_bool { - \bool_if:NT \g__nju_decl_bool + \bool_if:NT \g__nju_opt_decl_bool { - \__nju_make_origdecl: - \AtEndEnvironment { document } - { - \cleardoublepage - \__nju_make_authdecl: - \cleardoublepage - } + \__nju_make_decl_i: + \__nju_make_decl_ii: } } \cleardoublepage @@ -1314,9 +1707,11 @@ \cs_new_protected:Npn \__nju_print_keywords:nn #1#2 { \tl_set:Nv \l__nju_tmpa_tl { c__nju_name_keywords #1 _tl } - \__nju_get_text_width:NV \l__nju_tmpa_dim \l__nju_tmpa_tl - \dim_add:Nn \l__nju_tmpa_dim { 1 em } - \exp_args:NNv \tl_put_right:Nn \l__nju_tmpa_tl { c__nju_name_comma #1 _tl } + \exp_args:NNv \tl_put_left:Nn + \l__nju_tmpa_tl { c__nju_fmt_abslabel #1 _tl } + \exp_args:NNv \tl_put_right:Nn + \l__nju_tmpa_tl { c__nju_name_colon #1 _tl } + \__nju_get_width:NV \l__nju_tmpa_dim \l__nju_tmpa_tl \list { \l__nju_tmpa_tl } { \labelwidth \l__nju_tmpa_dim @@ -1324,39 +1719,39 @@ \leftmargin \c_zero_dim \rightmargin \c_zero_dim \advance \leftmargin \l__nju_tmpa_dim - \cs_set_eq:NN \makelabel \textbf + \__nju_cs_clear:N \makelabel } \item \clist_use:cn { g__nju_info_keywords #1 _clist } { #2 } \endlist } \skip_new:N \g__nju_abs_title_left_skip -\keys_define:nn { nju / style } +\keys_define:nn { nju / abstract } { - abstract-in-toc .bool_gset:N = \g__nju_abs_in_toc_bool, - abstract-in-toc .initial:n = true, - abstract-title .choice:, - abstract-title / strict .code:n = + toc-entry .bool_set:N = \g__nju_abs_showentry_bool, + toc-entry .initial:n = true, + title-style .choice:, + title-style / strict .code:n = { - \bool_gset_true:N \g__nju_strict_abs_title_bool - \skip_gset:Nn \g__nju_abs_title_left_skip { 1 em } + \bool_set_true:N \g__nju_abs_title_strict_bool + \skip_set:Nn \g__nju_abs_title_left_skip { .5 em } }, - abstract-title / centered .code:n = + title-style / centered .code:n = { - \bool_gset_true:N \g__nju_strict_abs_title_bool - \skip_gset:Nn \g__nju_abs_title_left_skip { 0 pt plus 1 fill } + \bool_set_true:N \g__nju_abs_title_strict_bool + \skip_set:Nn \g__nju_abs_title_left_skip { .5 em plus 1 fill } }, - abstract-title / natural .code:n = + title-style / natural .code:n = { - \bool_gset_false:N \g__nju_strict_abs_title_bool - \skip_gset:Nn \g__nju_abs_title_left_skip { 0 pt plus 1 fill } + \bool_set_false:N \g__nju_abs_title_strict_bool + \skip_set:Nn \g__nju_abs_title_left_skip { .5 em plus 1 fill } }, - abstract-title .initial:n = strict + title-style .initial:n = strict } \NewDocumentEnvironment { abstract } { +b } { \cleardoublepage \thispagestyle { plain } - \__nju_abs_bookmark:Vn \c__nju_name_abstract_a_tl { abstract } + \__nju_abs_bookmark:Vn \c__nju_name_abstracta_tl { abstract } \__nju_make_abstract: \group_begin: \kaishu \zihao { -4 } #1 } @@ -1365,7 +1760,7 @@ { \cleardoublepage \thispagestyle { plain } - \__nju_abs_bookmark:Vn \c__nju_name_abstract_a_en_tl { abstract-en } + \__nju_abs_bookmark:Vn \c__nju_name_abstracta_en_tl { abstract-en } \__nju_make_abstract_en: \group_begin: \zihao { -4 } #1 } @@ -1401,7 +1796,7 @@ } \group_end: } -\cs_new_protected:Npn \__nju_notation_label:n #1 { #1 \hfil } +\cs_new_protected:Npn \__nju_notation_label:n #1 { #1 \tex_hfil:D } \cs_new_protected:Npn \__nju_make_notation:nn #1#2 { \dim_set:Nn \l__nju_tmpa_dim { \textwidth - #1 - #2 } @@ -1411,7 +1806,7 @@ \labelsep \c_zero_dim \itemsep \c_zero_dim \parsep \c_zero_dim - \leftmargin .5\l__nju_tmpa_dim + \leftmargin .5\l__nju_tmpa_dim \rightmargin \leftmargin \advance \leftmargin #2 \cs_set_eq:NN \makelabel \__nju_notation_label:n @@ -1428,7 +1823,7 @@ \chapter * { \c__nju_name_notation_tl } \__nju_make_notation:nn { #1 } { #2 } } - { \endlist } + { \endlist \cleardoublepage } \endinput %% %% End of file `njuthesis.cls'. |