%%
%% This is file `nwafuthesis.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% nwafuthesis.dtx  (with options: `class')
%% 
%%     Copyright (C) 2019--2022 by Nan Geng <nangeng@nwafu.edu.cn>
%% 
%%     This work may be distributed and/or modified under the
%%     conditions of the LaTeX Project Public License, either
%%     version 1.3c of this license or (at your option) any later
%%     version. The latest version of this license is in:
%% 
%%       http://www.latex-project.org/lppl.txt
%% 
%%     and version 1.3 or later is part of all distributions of
%%     LaTeX version 2005/12/01 or later.
%% 
%%     This work has the LPPL maintenance status `maintained'.
%% 
%%     The Current Maintainer of this work is Nan Geng.
%% 
%%     This work consists of the files nwafuthesis.dtx,
%%                                     nwafuthesis-doc.dtx,
%%               and the derived files nwafuthesis.ins,
%%                                     nwafuthesis.cls,
%%                                     nwafudoc.cls,
%% 
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\GetIdInfo $Id: nwafuthesis.dtx 1.01 2021-08-07 Nan Geng <nangeng@nwafu.edu.cn> $
  {Thesis template for Northwest A\&F University}
\ProvidesExplClass{\ExplFileName}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\RequirePackage { xparse, xtemplate, l3keys2e }
\clist_map_inline:nn { expl3, xparse, xtemplate, l3keys2e }
  {
    \@ifpackagelater {#1} { 2018/05/12 }
      { } { \msg_error:nnn { nwafuthesis } { l3-too-old } {#1} }
  }
\msg_new:nnn { nwafuthesis } { l3-too-old }
  {
    Package~ "#1"~ is~ too~ old. \\\\
    Please~ update~ an~ up-to-date~ version~ of~ the~ bundles \\
    "l3kernel"~ and~ "l3packages"~ using~ your~ TeX~ package \\
    manager~ or~ from~ CTAN.
  }
\sys_if_engine_xetex:F
  {
    \sys_if_engine_luatex:F
      {
        \msg_fatal:nnx { nwafuthesis } { unsupported-engine }
          { \c_sys_engine_str }
      }
  }
\msg_new:nnn { nwafuthesis } { unsupported-engine }
  {
    The~ nwafuthesis~ class~ requires~ either~ XeTeX~ or~ LuaTeX. \\\\
    "#1"~ is~ not~ supported~ at~ present.~ You~ must~ change \\
    your~ typesetting~ engine~ to~ "xelatex"~ or~ "lualatex".
  }
\hook_gset_rule:nnnn { begindocument/before } { nwafuthesis } { < } { xeCJK }
\box_new:N   \l__nwafu_tmpa_box
\clist_new:N \l__nwafu_tmpa_clist
\clist_new:N \l__nwafu_tmpb_clist
\clist_new:N \l__nwafu_tmpc_clist
\clist_new:N \l__nwafu_tmpd_clist
\clist_new:N \l__nwafu_tmpt_clist
\dim_new:N   \l__nwafu_tmpa_dim
\dim_new:N   \l__nwafu_tmpb_dim
\dim_new:N   \l__nwafu_tmpc_dim
\dim_new:N   \l__nwafu_tmpd_dim
\dim_new:N   \l__nwafu_tmpt_dim
\skip_new:N  \l__nwafu_tmpa_skip
\tl_new:N    \l__nwafu_tmpa_tl
\tl_new:N    \l__nwafu_tmpb_tl
\tl_new:N    \l__nwafu_tmpc_tl
\tl_new:N    \l__nwafu_tmpd_tl
\tl_new:N    \l__nwafu_tmpt_tl
\int_new:N \g__nwafu_thesis_type_int
\clist_new:N \g__nwafu_to_ctexbook_clist
\clist_new:N \g__nwafu_to_hyperref_clist
\bool_new:N \l__nwafu_withchap_bool
\bool_new:N \g__nwafu_twoside_bool
\bool_set_true:N \g__nwafu_twoside_bool
\bool_new:N \g__nwafu_draft_bool
\cs_generate_variant:Nn \cs_generate_variant:Nn { cn }
\cs_generate_variant:Nn \file_input:n           { V  }
\cs_generate_variant:Nn \int_to_arabic:n        { v  }
\cs_generate_variant:Nn \keys_define:nn         { nx }
\cs_generate_variant:Nn \tl_map_inline:nn       { xn }
\prg_generate_conditional_variant:Nnn \tl_if_eq:nn { Vn } { T, TF }
\cs_new:Npn \__nwafu_quad:  { \skip_horizontal:n { 1 em } }
\cs_new:Npn \__nwafu_qquad: { \skip_horizontal:n { 2 em } }
\cs_new_protected:Npn \__nwafu_vspace:N #1
  {
    \dim_set_eq:NN \l__nwafu_tmpa_dim \prevdepth
    \hrule height \c_zero_dim
    \nobreak
    \skip_vertical:N #1
    \skip_vertical:N \c_zero_skip
    \dim_set_eq:NN \prevdepth \l__nwafu_tmpa_dim
  }
\cs_new_protected:Npn \__nwafu_vspace:n #1
  {
    \skip_set:Nn \l__nwafu_tmpa_skip {#1}
    \__nwafu_vspace:N \l__nwafu_tmpa_skip
  }
\cs_generate_variant:Nn \__nwafu_vspace:N { c }
\cs_new:Npn \__nwafu_symbol:n #1 { \tex_char:D #1 \scan_stop: }
\cs_new:Npn \__nwafu_arabic:n #1
  { \int_to_arabic:v { c@ #1 } }
\cs_new_protected:Npn \__nwafu_patch_cmd:Nnn #1#2#3
  {
    \ctex_patch_cmd_once:NnnnTF #1 { } {#2} {#3}
      { } { \ctex_patch_failure:N #1 }
  }
\cs_new_protected:Npn \__nwafu_preto_cmd:Nn #1#2
  {
    \ctex_preto_cmd:NnnTF #1 { } {#2}
      { } { \ctex_patch_failure:N #1 }
  }
\cs_new_protected:Npn \__nwafu_appto_cmd:Nn #1#2
  {
    \ctex_appto_cmd:NnnTF #1 { } {#2}
      { } { \ctex_patch_failure:N #1 }
  }
\cs_new_protected:Npn \__nwafu_at_begin_environment:nn #1#2
  {
    \seq_set_from_clist:Nn \l__nwafu_env_hook_name_seq {#1}
    \seq_map_inline:Nn \l__nwafu_env_hook_name_seq
      { \AtBeginEnvironment{##1}{#2} }
  }
\cs_new_protected:Npn \__nwafu_at_end_preamble:n
  {
    \ctex_gadd_ltxhook:nn { env/document/before }
  }
\cs_new_protected:Npn \__nwafu_define_fn_style:nn #1#2
  { \tl_const:cn { c__nwafu_fn_style_ #1 _tl } {#2} }
\cs_new_protected:Npn \__nwafu_define_punct:nn #1#2
  { \tl_const:cn { c__nwafu_ #1 _tl } { \__nwafu_symbol:n {#2} } }
\cs_new_protected:Npn \__nwafu_define_name:nn #1#2
  { \tl_const:cn { c__nwafu_name_ #1 _tl } {#2} }
\cs_new_protected:Npn \__nwafu_define_name:nnn #1#2#3
  {
    \tl_const:cn { c__nwafu_name_ #1    _tl } {#2}
    \tl_const:cn { c__nwafu_name_ #1 _en_tl } {#3}
  }
\cs_new:Npn \__nwafu_msg_new:nn  { \msg_new:nnn      { nwafuthesis } }
\cs_new:Npn \__nwafu_error:n     { \msg_error:nn     { nwafuthesis } }
\cs_new:Npn \__nwafu_error:nn    { \msg_error:nnn    { nwafuthesis } }
\cs_new:Npn \__nwafu_error:nx    { \msg_error:nnx    { nwafuthesis } }
\cs_new:Npn \__nwafu_error:nnn   { \msg_error:nnnn   { nwafuthesis } }
\cs_new:Npn \__nwafu_warning:n   { \msg_warning:nn   { nwafuthesis } }
\cs_new:Npn \__nwafu_warning:nn  { \msg_warning:nnn  { nwafuthesis } }
\cs_new:Npn \__nwafu_warning:nxx { \msg_warning:nnxx { nwafuthesis } }
\cs_new:Npn \__nwafu_info:nx     { \msg_info:nnx     { nwafuthesis } }
\keys_define:nn { nwafu / option }
  {
    type .choice:,
    type .value_required:n = true,
    type .choices:nn =
      { doctor, master, bachelor }
      { \int_set_eq:NN \g__nwafu_thesis_type_int \l_keys_choice_int },
    type .initial:n = bachelor,
    oneside .value_forbidden:n = true,
    twoside .value_forbidden:n = true,
    oneside .code:n =
      {
        \clist_gput_right:Nn \g__nwafu_to_ctexbook_clist { oneside }
        \bool_set_false:N    \g__nwafu_twoside_bool
      },
    twoside .code:n =
      {
        \clist_gput_right:Nn \g__nwafu_to_ctexbook_clist { twoside, openany }
        \bool_set_true:N     \g__nwafu_twoside_bool
      },
    draft .choice:,
    draft / true  .code:n =
      {
        \bool_set_true:N     \g__nwafu_draft_bool
        \clist_gput_right:Nn \g__nwafu_to_ctexbook_clist { draft }
      },
    draft / false .code:n =
      { \bool_set_false:N    \g__nwafu_draft_bool },
    draft .default:n = true,
    draft .initial:n = false,
    unknown .code:n = { \__nwafu_error:n { unknown-option } }
  }
\__nwafu_msg_new:nn { unknown-option }
  { Class~ option~ "\l_keys_key_tl"~ is~ unknown. }
\ProcessKeysOptions { nwafu / option }
\NewDocumentCommand \nwafuthesis { }
  {%
    \makebox{\rmfamily%
      N\hspace{-0.2ex}\raisebox{-0.5ex}{W}\raisebox{0.5ex}{\hspace{-0.2ex}\textsc{AFU}}\hspace{0.3ex}%
      \textsc{Thesis}
    }
  }
\NewDocumentCommand \datezh { }
  {
    \int_use:N \c_sys_year_int 年
    \int_use:N \c_sys_month_int 月
  }
\prop_new:N \l__nwafu_dateen_prop
\prop_set_from_keyval:Nn \l__nwafu_dateen_prop
  {
    1  = Jan.,
    2  = Feb.,
    3  = Mar.,
    4  = Apr.,
    5  = May.,
    6  = Jun.,
    7  = Jul.,
    8  = Aug.,
    9  = Sept.,
    10 = Oct.,
    11 = Nov.,
    12 = Dec.,
  }
\NewDocumentCommand \dateen { }
  {
    \prop_get:NVN \l__nwafu_dateen_prop \c_sys_month_int \l__nwafu_tmpa_tl
    \l__nwafu_tmpa_tl ,~ \int_use:N \c_sys_year_int
  }
\tl_const:Nn \c__nwafu_name_simp_tl { 西北农林科技大学            }
\tl_const:Nn \c__nwafu_name_trad_tl { 西北農林科技大學            }
\tl_const:Nn \c__nwafu_name_en_tl   { Northwest~ A\&F~ University }
\clist_map_inline:nn
  {
    { ideo_comma       } { "3001 },
    { ideo_full_stop   } { "3002 },
    { fwid_comma       } { "FF0C },
    { fwid_full_stop   } { "FF0E },
    { fwid_colon       } { "FF1A },
    { fwid_semicolon   } { "FF1B },
    { fwid_left_paren  } { "FF08 },
    { fwid_right_paren } { "FF09 }
  }
  { \__nwafu_define_punct:nn #1 }
\fp_const:Nn \c__nwafu_line_spread_fp
  { \dim_ratio:nn { 20 pt } { 12 bp } / 1.2 }
\int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
  {
    \tl_const:Nn \c__nwafu_orig_decl_text_tl
      {
        本人声明:所呈交的学位论文是我个人在导师指导下独立进行的研究工作及取
        得的研究结果;论文中的研究数据及结果的获得完全符合学校《关于规范西北
        农林科技大学研究生学术道德的暂行规定》,如果违反此规定,一切后果与法
        律责任均由本人承担。\par
        尽我所知,除了文中特别加以标注和致谢的地方外,论文中不包含其他人已经
        发表或撰写过的研究结果,也不包含其他人和自己本人已获得西北农林科技大
        学或其它教育机构的学位或证书而使用过的材料。与我一同工作的同事对本
        研究所做的任何贡献均已在论文的致谢中作了明确的说明并表示了谢意。
      }
  }
  {
    \tl_const:Nn \c__nwafu_orig_decl_text_tl
      {
        本人声明：所呈交的毕业
        \clist_item:Nn \c__nwafu_bachelor_type_clist { \l__nwafu_info_bachelor_type_int }
        是我个人在导师指导下
        独立进行的研究工作及取得的研究结果。尽我所知，除了文中特别加
        以标注和致谢的地方外，论文中不包含其他人已经发表或撰写过的研究结果，
        也不包含其他人和自己本人已获得\c__nwafu_name_simp_tl{}或其它教育
        机构的学位或证书而使用过的材料。与我一同工作的同事对本研究所做
        的任何贡献均已在论文的致谢中作了明确的说明并表示了谢意。
        如违反此声明，一切后果与法律责任均由本人承担。
      }
  }
\tl_const:Nn \c__nwafu_super_decl_text_tl
  {
    本人承诺：我的研究生{\__nwafu_text_uline:V \l__nwafu_info_author_tl}所呈交的
    学位论文是在我指导下独立开展研究工作及取得的研究结果,属于我现
    岗职务工作的结果,并严格按照学校《关于规范西北农林科技大学研究生学术
    道德的暂行规定》而获得的研究结果。如果违反学校《关于规范西北农林科
    技大学研究生学术道德的暂行规定》,我愿接受按学校有关规定的处罚处理并
    承担相应导师连带责任。
  }
\int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
  {
    \tl_const:Nn \c__nwafu_auth_decl_text_tl
      {
        本学位论文的知识产权归属西北农林科技大学。本人同意西北农林科技大学
        保存或向国家有关部门或机构送交论文的纸质版和电子版,允许论文被查阅和
        借阅;同意西北农林科技大学将本学位论文的全部或部分内容授权汇编录入
        中国博士/硕士学位论文全文数据库》和《中国学位论文全文数据库》进行
        出版,并享受相关权益。\par

        本人保证,在毕业离开(或者工作调离)西北农林科技大学后,发表或者使用本
        学位论文及其相关的工作成果时,将以西北农林科技大学为第一署名单位,否
        则,愿意按《中华人民共和国著作权法》等有关规定接受处理并承担法律责任。\par

        任何收存和保管本论文各种版本的其他单位和个人(包括研究生本人)未经本
        论文作者的导师同意,不得有对本论文进行复制、修改、发行、出租、改编等
        侵犯著作权的行为,否则,按违背《中华人民共和国著作权法》等有关规定处
        理并追究法律责任。\par

        {\sffamily (保密的学位论文在保密期限内，不得以任何方式发表、借阅、复印、
            缩印或扫描复制手段保存、汇编论文)}
      }
  }
  {
    \tl_const:Nn \c__nwafu_auth_decl_text_tl
      {
        本毕业
        \clist_item:Nn \c__nwafu_bachelor_type_clist { \l__nwafu_info_bachelor_type_int }
        的知识产权归属\c__nwafu_name_simp_tl{}。
        本人同意\c__nwafu_name_simp_tl{}保存或向国家有关部门或机构
        送交论文的纸质版和电子版，允许论文被查阅和借阅。\par

        本人保证，在毕业离开\c__nwafu_name_simp_tl{}后，发表或者使用本毕业
        \clist_item:Nn \c__nwafu_bachelor_type_clist { \l__nwafu_info_bachelor_type_int }
        及其相关的工作成果时，将以\c__nwafu_name_simp_tl{}
        为第一署名单位，否则，愿意按《中华人民共和国著作权法》等
        有关规定接受处理并承担法律责任。\par

        任何收存和保管本论文各种版本的其他单位和个人(包括作者本人)未经
        本论文作者的导师同意，不得有对本论文进行复制、修改、发行、出租、
        改编等侵犯著作权的行为，否则，按违背《中华人民共和国著作权法》
        等有关规定处理并追究法律责任。
      }
  }
\int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
  {
    \tl_const:Nn \c__nwafu_orig_decl_sign_tl
      { 研究生签名 }
    \tl_const:Nn \c__nwafu_super_decl_sign_tl
      { 导师签名 }
  }
  {
    \tl_const:Nn \c__nwafu_orig_decl_sign_tl
      { 本科生签名 }
    \tl_const:Nn \c__nwafu_super_decl_sign_tl
      { 指导教师签名 }
  }
\clist_const:Nn \c__nwafu_auth_decl_sign_clist
  { 作者签名, 导师签名, 日期 }
\clist_const:Nn \c__nwafu_thesis_type_clist
  { 博士学位论文, 硕士学位论文, 本科毕业 }
\clist_const:Nn \c__nwafu_degree_type_clist
  { 学术学位, 专业学位 }
\clist_const:Nn \c__nwafu_bachelor_type_clist
  { 论文, 设计 }
\clist_const:Nn \c__nwafu_secret_clist { 限制, 秘密, 机密, 绝密 }
\clist_map_inline:nn
 {
   { secret_level      } { 密级                          },
   { udc               } { UDC                           },
   { school_id         } { 学校代码                      },
   { department        } { 学院                          },
   { enroll            } { 年级                          },
   { class_id          } { 班级                          },
   { instructors       } { 指导小组                      },
   { author_sign       } { 作者签名                      },
   { supervisor_sign   } { 导师签名                      },
   { sign_date         } { 日期                          },
   { toc               } { 目 \quad 录                   },
   { lof               } { 插图目录                      },
   { lot               } { 表格目录                      },
   { bib_en            } { Bibliography                  },
   { ack               } { 致 \quad 谢                   },
   { resume            } { 个人简历                      },
   { pdf_creator       } { LaTeX~ with~ nwafuthesis~ class },
 }
 { \__nwafu_define_name:nn #1 }
\int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
  {
    \clist_map_inline:nn
      {
        { student_id      } { 研究生学号                       },
        { orig_decl       } { 研究生学位论文的独创性声明       },
        { super_decl      } { 导师指导研究生学位论文的承诺     },
        { auth_decl       } { 关于研究生学位论文使用授权的说明 }
      }
      { \__nwafu_define_name:nn #1 }
   }{
    \clist_map_inline:nn
      {
        { major           } { 专业                           },
        { student_id      } { 学号                           },
        { author          } { 学生姓名                       },
        { cosupervisor    } { 协助指导教师                   },
        { date            } { 完成日期                       },
        { orig_decl       } { 本科生毕业\clist_item:Nn
                              \c__nwafu_bachelor_type_clist {
                              \l__nwafu_info_bachelor_type_int
                              }的独创性声明                  },
        { auth_decl       } { 关于本科生毕业\clist_item:Nn
                              \c__nwafu_bachelor_type_clist {
                              \l__nwafu_info_bachelor_type_int
                              }知识产权的说明                }
      }
      { \__nwafu_define_name:nn #1 }
  }
\clist_map_inline:nn
  {
    { supervisor } { 指导教师 } { Supervisor },
  }
  { \__nwafu_define_name:nnn #1 }
\int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
  {
    \clist_map_inline:nn
      {
        { major             } { 学科专业       } { Major                },
        { researchfield     } { 研究方向       } { Research~ Field      },
        { professionaltype  } { 专业学位类型   } { Degree~ Type         },
        { professionalfield } { 领域名称       } { Field                },
        { author            } { 论文作者       } { Candidate            },
        { cosupervisor      } { 联合指导教师   } { Co-Supervisor        },
        { date              } { 论文提交时间   } { Date~ of~ Submission },
        { abstract          } { 摘 \quad 要    } { ABSTRACT             },
        { keywords          } { 关键字         } { KEYWORDS             },
        { clc               } { 分类号         } { CLC~ number:         },
        { notation          } { 主要符号对照表 } { List~ of~ Symbols    }
      }
      { \__nwafu_define_name:nnn #1 }
  }{
    \clist_map_inline:nn
      {
        { abstract } { 摘要        } { Abstract          },
        { keywords } { 关键字      } { Keywords          },
        { clc      } { 分类号      } { CLC~ number       },
      }
      { \__nwafu_define_name:nnn #1 }
  }
\clist_map_inline:nn
  {
    { proof      } { 证明 } { Proof      },
    { axiom      } { 公理 } { Axiom      },
    { corollary  } { 推论 } { Corollary  },
    { definition } { 定义 } { Definition },
    { example    } { 例   } { Example    },
    { lemma      } { 引理 } { Lemma      },
    { theorem    } { 定理 } { Theorem    }
  }
  { \__nwafu_define_name:nnn #1 }
\PassOptionsToClass
  {
    UTF8,
    heading    = true,
    fontset    = none,
    zihao      = -4,
    linespread = \c__nwafu_line_spread_fp,
    \g__nwafu_to_ctexbook_clist
  }
  { ctexbook }
\clist_map_inline:nn
  {
    { shortlabels       } { enumitem },
    { no-math           } { fontspec },
    { perpage           } { footmisc },
    { amsmath, thmmarks } { ntheorem }
  }
  { \PassOptionsToPackage #1 }
\RequirePackage { etoolbox }
\LoadClass { ctexbook }
\RequirePackage
  {
    amsmath,
    unicode-math,
    geometry,
    fancyhdr,
    titletoc,
    footmisc,
    ntheorem,
    enumitem,
    graphicx,
    longtable,
    booktabs,
    caption,
    xcolor,
  }
\cs_new_protected:Npn \__nwafu_check_package:nnn #1#2#3
  {
    \@ifpackagelater {#1} {#2}
      { } { \__nwafu_error:nnn { package-too-old } {#1} {#3} }
  }
\__nwafu_msg_new:nn { package-too-old }
  {
    Package~ "#1"~ is~ too~ old. \\
    The~ nwafuthesis~ class~ only~ supports~ "#1"~ with~ a~ version \\
    higher~ than~ v#2. \\\\
    Please~ update~ an~ up-to-date~ version~ of~ it~ using~ your \\
    TeX~ package~ manager~ or~ from~ CTAN.
  }
\__nwafu_check_package:nnn { fontspec     } { 2017/09/22 } { 2.6e   }
\__nwafu_check_package:nnn { unicode-math } { 2017/11/18 } { 0.8i   }
\sys_if_engine_xetex:T
  { \__nwafu_check_package:nnn { xeCJK          } { 2017/08/07 } { 3.5.0 } }
\sys_if_engine_luatex:T
  { \__nwafu_check_package:nnn { xunicode-addon } { 2018/04/30 } { 3.7.1 } }
\int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
  {
    \geometry
      {
        paper=a4paper,
        top=3.1cm,
        bottom=3.3cm,
        left=2.6cm,
        right=2.6cm,
        headheight=0.8cm,
        headsep=0.7cm,
        footskip=1.4cm,
        %includehead,
        %includefoot,
      }
  }{
    \geometry
      {
        paper=a4paper,
        top=3.14cm,
        bottom=3.8cm,
        left=2.45cm,
        right=2.45cm,
        headheight=0.8cm,
        headsep=0.63cm,
        footskip=2.3cm,
      }
  }
\bool_if:NT \g__nwafu_draft_bool { \geometry { showframe } }
\tl_new:N \g__nwafu_fontset_tl
\tl_new:N \g__nwafu_cjk_fontset_tl
\keys_define:nn { nwafu / style }
  {
    font .choices:nn =
      { garamond, libertinus, lm, palatino, times, times*, none }
      { \tl_set_eq:NN \g__nwafu_fontset_tl \l_keys_choice_tl }
  }
\keys_define:nn { nwafu / style }
  {
    cjk-font .choices:nn =
      { adobe, fandol, founder, mac, sinotype, sourcehan, windows, none }
      { \tl_set_eq:NN \g__nwafu_cjk_fontset_tl \l_keys_choice_tl }
  }
\keys_define:nn { nwafu / style }
  {
    withchapter .bool_set:N = \l__nwafu_withchap_bool,
    withchapter .default:n  = true,
    withchapter .initial:n  = true,
  }
\cs_new_protected:Npn \__nwafu_setmainfont:nn #1#2
  { \__fontspec_main_setmainfont:nn {#2} {#1} }
\cs_new_protected:Npn \__nwafu_setsansfont:nn #1#2
  { \__fontspec_main_setsansfont:nn {#2} {#1} }
\cs_new_protected:Npn \__nwafu_setmonofont:nn #1#2
  { \__fontspec_main_setmonofont:nn {#2} {#1} }
\cs_new_protected:Npn \__nwafu_setmathfont:nn #1#2
  { \__um_setmathfont:nn {#2} {#1} }
\cs_new_protected:Npn \__nwafu_setCJKmainfont:nn #1#2
  { \__nwafu_set_family:nnn { \CJKrmdefault } {#2} {#1} }
\cs_new_protected:Npn \__nwafu_setCJKsansfont:nn #1#2
  { \__nwafu_set_family:nnn { \CJKsfdefault } {#2} {#1} }
\cs_new_protected:Npn \__nwafu_setCJKmonofont:nn #1#2
  { \__nwafu_set_family:nnn { \CJKttdefault } {#2} {#1} }
\cs_new_protected:Npn \__nwafu_set_cjk_font_hei:nn #1#2
  { \__nwafu_set_family:nnn { nwafu@hei } {#2} {#1} }
\cs_new_protected:Npn \nwafu@hei
  { \__nwafu_switch_family:n { nwafu@hei } }
\cs_new_protected:Npn \__nwafu_set_cjk_font_kai:nn #1#2
  { \__nwafu_set_family:nnn { nwafu@kai } {#2} {#1} }
\cs_new_protected:Npn \nwafu@kai
  { \__nwafu_switch_family:n { nwafu@kai } }
\tl_const:Nn \__nwafu_cjk_font_options:
 { UprightFont = *, ItalicFont = *, AutoFakeBold = true }
\tl_const:Nn \__nwafu_cjk_font_hei_options:
 { UprightFont = *, ItalicFont = *, AutoFakeBold = false }
\cs_new_protected:Npx \__nwafu_setCJKmainfont:n   #1
  { \__nwafu_setCJKmainfont:nn   {#1} { \__nwafu_cjk_font_options: } }
\cs_new_protected:Npx \__nwafu_setCJKsansfont:n   #1
  { \__nwafu_setCJKsansfont:nn   {#1} { \__nwafu_cjk_font_hei_options: } }
\cs_new_protected:Npx \__nwafu_setCJKmonofont:n   #1
  { \__nwafu_setCJKmonofont:nn   {#1} { \__nwafu_cjk_font_options: } }
\cs_new_protected:Npx \__nwafu_set_cjk_font_hei:n #1
  { \__nwafu_set_cjk_font_hei:nn {#1} { \__nwafu_cjk_font_hei_options: } }
\cs_new_protected:Npx \__nwafu_set_cjk_font_kai:n #1
  { \__nwafu_set_cjk_font_kai:nn {#1} { \__nwafu_cjk_font_options: } }
\sys_if_engine_xetex:TF
  {
    \cs_new_eq:NN \__nwafu_set_family:nnn  \xeCJK_set_family:nnn
    \cs_new_eq:NN \__nwafu_switch_family:n \xeCJK_switch_family:n
  }
  {
    \cs_new_eq:NN \__nwafu_set_family:nnn  \ctex_ltj_set_family:nnn
    \cs_new_eq:NN \__nwafu_switch_family:n \ctex_ltj_switch_family:n
  }
\cs_new_protected:Npn \__nwafu_set_font_helper:n #1
  {
    \exp_args:Nc \RenewDocumentCommand { set #1 font } { O { } m O { } }
      {
        \ctex_at_end_preamble:n
          { \use:c { __nwafu_set #1 font:nn } {##2} { ##1, ##3 } }
      }
  }
\clist_map_inline:nn { main, sans, mono, math    } { \__nwafu_set_font_helper:n {#1} }
\clist_map_inline:nn { CJKmain, CJKsans, CJKmono } { \__nwafu_set_font_helper:n {#1} }
\tl_new:N \g__nwafu_font_family_libertinus_serif_tl
\tl_new:N \g__nwafu_font_family_libertinus_sans_tl
\tl_new:N \g__nwafu_font_style_libertinus_rm_tl
\tl_new:N \g__nwafu_font_style_libertinus_bf_tl
\tl_new:N \g__nwafu_font_style_libertinus_it_tl
\tl_new:N \g__nwafu_font_style_libertinus_bfit_tl
\tl_new:N \g__nwafu_font_style_libertinus_bfsl_tl
\tl_new:N \g__nwafu_font_family_xits_tl
\tl_new:N \g__nwafu_font_style_xits_rm_tl
\tl_new:N \g__nwafu_font_style_xits_bf_tl
\tl_new:N \g__nwafu_font_style_xits_it_tl
\tl_new:N \g__nwafu_font_style_xits_bfit_tl
\tl_new:N \g__nwafu_font_name_libertinus_serif_tl
\tl_new:N \g__nwafu_font_name_libertinus_sans_tl
\tl_new:N \g__nwafu_font_name_libertinus_math_tl
\tl_new:N \g__nwafu_font_name_xits_tl
\tl_new:N \g__nwafu_font_name_xits_math_rm_tl
\tl_new:N \g__nwafu_font_name_xits_math_bf_tl
\fontspec_font_if_exist:nTF { LibertinusSerif-Regular.otf }
  {
    \tl_set:Nn \g__nwafu_font_family_libertinus_serif_tl { LibertinusSerif }
    \tl_set:Nn \g__nwafu_font_family_libertinus_sans_tl  { LibertinusSans  }
    \tl_set:Nn \g__nwafu_font_family_libertinus_math_tl  { LibertinusMath  }
    \tl_set:Nn \g__nwafu_font_style_libertinus_rm_tl     { Regular         }
    \tl_set:Nn \g__nwafu_font_style_libertinus_bf_tl     { Bold            }
    \tl_set:Nn \g__nwafu_font_style_libertinus_it_tl     { Italic          }
    \tl_set:Nn \g__nwafu_font_style_libertinus_bfit_tl   { BoldItalic      }
    \tl_set:Nn \g__nwafu_font_style_libertinus_bfsl_tl   { BoldOblique     }
  }
  {
    \tl_set:Nn \g__nwafu_font_family_libertinus_serif_tl { libertinusserif }
    \tl_set:Nn \g__nwafu_font_family_libertinus_sans_tl  { libertinussans  }
    \tl_set:Nn \g__nwafu_font_family_libertinus_math_tl  { libertinusmath  }
    \tl_set:Nn \g__nwafu_font_style_libertinus_rm_tl     { regular         }
    \tl_set:Nn \g__nwafu_font_style_libertinus_bf_tl     { bold            }
    \tl_set:Nn \g__nwafu_font_style_libertinus_it_tl     { italic          }
    \tl_set:Nn \g__nwafu_font_style_libertinus_bfit_tl   { bolditalic      }
    \tl_set:Nn \g__nwafu_font_style_libertinus_bfsl_tl   { bolditalic      }
  }
\fontspec_font_if_exist:nTF { XITS-Regular.otf }
  {
    \tl_set:Nn \g__nwafu_font_family_xits_tl        { XITS             }
    \tl_set:Nn \g__nwafu_font_style_xits_rm_tl      { Regular          }
    \tl_set:Nn \g__nwafu_font_style_xits_bf_tl      { Bold             }
    \tl_set:Nn \g__nwafu_font_style_xits_it_tl      { Italic           }
    \tl_set:Nn \g__nwafu_font_style_xits_bfit_tl    { BoldItalic       }
    \tl_set:Nn \g__nwafu_font_name_xits_math_rm_tl  { XITSMath-Regular }
    \tl_set:Nn \g__nwafu_font_name_xits_math_bf_tl  { XITSMath-Bold    }
  }
  {
    \tl_set:Nn \g__nwafu_font_family_xits_tl        { xits          }
    \tl_set:Nn \g__nwafu_font_style_xits_rm_tl      { regular       }
    \tl_set:Nn \g__nwafu_font_style_xits_bf_tl      { bold          }
    \tl_set:Nn \g__nwafu_font_style_xits_it_tl      { italic        }
    \tl_set:Nn \g__nwafu_font_style_xits_bfit_tl    { bolditalic    }
    \tl_set:Nn \g__nwafu_font_name_xits_math_rm_tl  { xits-math     }
    \tl_set:Nn \g__nwafu_font_name_xits_math_bf_tl  { xits-mathbold }
  }
\tl_set:Nx \g__nwafu_font_name_libertinus_serif_tl
  { \g__nwafu_font_family_libertinus_serif_tl - \g__nwafu_font_style_libertinus_rm_tl }
\tl_set:Nx \g__nwafu_font_name_libertinus_sans_tl
  { \g__nwafu_font_family_libertinus_sans_tl  - \g__nwafu_font_style_libertinus_rm_tl }
\tl_set:Nx \g__nwafu_font_name_libertinus_math_tl
  { \g__nwafu_font_family_libertinus_math_tl  - \g__nwafu_font_style_libertinus_rm_tl }
\tl_set:Nx \g__nwafu_font_name_xits_tl
  { \g__nwafu_font_family_xits_tl - \g__nwafu_font_style_xits_rm_tl }
\cs_new_protected:Npn \__nwafu_load_font_garamond:
  {
    \__nwafu_setmainfont:nn { EBGaramond }
      {
        Extension      = .otf,
        UprightFont    = *-Regular,
        BoldFont       = *-Bold,
        ItalicFont     = *-Italic,
        BoldItalicFont = *-BoldItalic
      }
    \__nwafu_setsansfont:nn { \g__nwafu_font_family_libertinus_sans_tl }
      {
        Extension      = .otf,
        UprightFont    = *-\g__nwafu_font_style_libertinus_rm_tl,
        BoldFont       = *-\g__nwafu_font_style_libertinus_bf_tl,
        ItalicFont     = *-\g__nwafu_font_style_libertinus_it_tl,
        BoldItalicFont = *-\g__nwafu_font_style_libertinus_bfsl_tl
      }
    \__nwafu_setmonofont:nn { lmmonolt10 }
      {
        Extension      = .otf,
        UprightFont    = *-regular,
        BoldFont       = *-bold,
        ItalicFont     = *-oblique,
        BoldItalicFont = *-boldoblique
      }
    \__nwafu_setmathfont:nn { Garamond-Math.otf } { }
  }
\cs_new_protected:Npn \__nwafu_load_font_libertinus:
  {
    \__nwafu_setmainfont:nn { \g__nwafu_font_family_libertinus_serif_tl }
      {
        Extension      = .otf,
        UprightFont    = *-\g__nwafu_font_style_libertinus_rm_tl,
        BoldFont       = *-\g__nwafu_font_style_libertinus_bf_tl,
        ItalicFont     = *-\g__nwafu_font_style_libertinus_it_tl,
        BoldItalicFont = *-\g__nwafu_font_style_libertinus_bfit_tl
      }
    \__nwafu_setsansfont:nn { \g__nwafu_font_family_libertinus_sans_tl }
      {
        Extension      = .otf,
        UprightFont    = *-\g__nwafu_font_style_libertinus_rm_tl,
        BoldFont       = *-\g__nwafu_font_style_libertinus_bf_tl,
        ItalicFont     = *-\g__nwafu_font_style_libertinus_it_tl,
        BoldItalicFont = *-\g__nwafu_font_style_libertinus_bfsl_tl
      }
    \__nwafu_setmonofont:nn { lmmonolt10 }
      {
        Extension      = .otf,
        UprightFont    = *-regular,
        BoldFont       = *-bold,
        ItalicFont     = *-oblique,
        BoldItalicFont = *-boldoblique
      }
    \__nwafu_setmathfont:nn { \g__nwafu_font_name_libertinus_math_tl .otf } { }
  }
\cs_new_protected:Npn \__nwafu_load_font_lm:
  { \__nwafu_setmathfont:nn { latinmodern-math.otf } { } }
\cs_new_protected:Npn \__nwafu_load_font_palatino:
  {
    \__nwafu_setmainfont:nn { texgyrepagella }
      {
        Extension      = .otf,
        UprightFont    = *-regular,
        BoldFont       = *-bold,
        ItalicFont     = *-italic,
        BoldItalicFont = *-bolditalic
      }
    \__nwafu_setsansfont:nn { \g__nwafu_font_family_libertinus_sans_tl }
      {
        Extension      = .otf,
        UprightFont    = *-\g__nwafu_font_style_libertinus_rm_tl,
        BoldFont       = *-\g__nwafu_font_style_libertinus_bf_tl,
        ItalicFont     = *-\g__nwafu_font_style_libertinus_it_tl,
        BoldItalicFont = *-\g__nwafu_font_style_libertinus_bfsl_tl,
        Scale          = MatchUppercase
      }
    \__nwafu_setmonofont:nn { lmmonolt10 }
      {
        Extension      = .otf,
        UprightFont    = *-regular,
        BoldFont       = *-bold,
        ItalicFont     = *-oblique,
        BoldItalicFont = *-boldoblique
      }
    \__nwafu_setmathfont:nn { texgyrepagella-math.otf } { }
  }
\cs_new_protected:Npn \__nwafu_load_font_times:
  {
    \__nwafu_setmainfont:nn { \g__nwafu_font_family_xits_tl }
      {
        Extension          = .otf,
        UprightFont        = *-\g__nwafu_font_style_xits_rm_tl,
        BoldFont           = *-\g__nwafu_font_style_xits_bf_tl,
        ItalicFont         = *-\g__nwafu_font_style_xits_it_tl,
        BoldItalicFont     = *-\g__nwafu_font_style_xits_bfit_tl
      }
    \__nwafu_setsansfont:nn { texgyreheros }
      {
        Extension      = .otf,
        UprightFont    = *-regular,
        BoldFont       = *-bold,
        ItalicFont     = *-italic,
        BoldItalicFont = *-bolditalic
      }
    \__nwafu_setmonofont:nn { texgyrecursor }
      {
        Extension      = .otf,
        UprightFont    = *-regular,
        BoldFont       = *-bold,
        ItalicFont     = *-italic,
        BoldItalicFont = *-bolditalic,
        Ligatures      = CommonOff
      }
    \__nwafu_setmathfont:nn { \g__nwafu_font_name_xits_math_rm_tl .otf }
      { BoldFont = \g__nwafu_font_name_xits_math_bf_tl .otf }
  }
\cs_new_protected:cpn { __nwafu_load_font_ times* : }
  {
    \__nwafu_setmainfont:nn { Times~ New~ Roman    } { }
    \__nwafu_setsansfont:nn { Arial                } { }
    \__nwafu_setmonofont:nn { Courier~ New         } { }
    \__nwafu_setmathfont:nn { \g__nwafu_font_name_xits_math_rm_tl .otf }
      { BoldFont = \g__nwafu_font_name_xits_math_bf_tl .otf }
  }
\cs_new_protected:Npn \__nwafu_load_cjk_font_adobe:
  {
    \__nwafu_setCJKmainfont:n   { AdobeSongStd-Light       }
    \__nwafu_setCJKsansfont:n   { AdobeHeitiStd-Regular    }
    \__nwafu_setCJKmonofont:n   { AdobeFangsongStd-Regular }
    \__nwafu_set_cjk_font_hei:n { AdobeHeitiStd-Regular    }
    \__nwafu_set_cjk_font_kai:n { AdobeKaitiStd-Regular    }
  }
\cs_new_protected:Npn \__nwafu_load_cjk_font_fandol:
  {
    \__nwafu_setCJKmainfont:nn   { FandolSong }
      {
        Extension      = .otf,
        UprightFont    = *-Regular,
        BoldFont       = *-Bold,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Bold
      }
    \__nwafu_setCJKsansfont:nn   { FandolHei  }
      {
        Extension      = .otf,
        UprightFont    = *-Regular,
        BoldFont       = *-Bold,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Bold
      }
    \__nwafu_setCJKmonofont:nn   { FandolFang }
      {
        Extension      = .otf,
        UprightFont    = *-Regular,
        BoldFont       = *-Regular,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Regular
      }
    \__nwafu_set_cjk_font_hei:nn { FandolHei  }
      {
        Extension      = .otf,
        UprightFont    = *-Regular,
        BoldFont       = *-Bold,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Bold
      }
    \__nwafu_set_cjk_font_kai:nn { FandolKai  }
      {
        Extension      = .otf,
        UprightFont    = *-Regular,
        BoldFont       = *-Regular,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Regular
      }
  }
\cs_new_protected:Npn \__nwafu_load_cjk_font_founder:
  {
    \__nwafu_setCJKmainfont:nn   { FZShuSong-Z01 }
      {
        UprightFont    = *,
        BoldFont       = FZHei-B01,
        ItalicFont     = FZKai-Z03,
      }
    \__nwafu_setCJKsansfont:n   { FZHei-B01      }
    \__nwafu_setCJKmonofont:n   { FZFangSong-Z02 }
    \__nwafu_set_cjk_font_hei:n { FZHei-B01      }
    \__nwafu_set_cjk_font_kai:n { FZKai-Z03      }
  }
\cs_new_protected:Npn \__nwafu_load_cjk_font_mac:
  {
    \__nwafu_setCJKmainfont:nn   { STSongti-SC }
      {
        UprightFont    = *-Light,
        BoldFont       = *-Bold,
        ItalicFont     = *-Light,
        BoldItalicFont = *-Bold
      }
    \__nwafu_setCJKsansfont:nn   { STHeitiSC   }
      {
        UprightFont    = *-Medium,
        BoldFont       = *-Medium,
        ItalicFont     = *-Medium,
        BoldItalicFont = *-Medium
      }
    \__nwafu_setCJKmonofont:n    { STFangsong  }
    \__nwafu_set_cjk_font_hei:nn { STHeitiSC   }
      {
        UprightFont    = *-Medium,
        BoldFont       = *-Medium,
        ItalicFont     = *-Medium,
        BoldItalicFont = *-Medium
      }
    \__nwafu_set_cjk_font_kai:nn { STKaitiSC   }
      {
        UprightFont    = *-Regular,
        BoldFont       = *-Bold,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Bold
      }
  }
\cs_new_protected:Npn \__nwafu_load_cjk_font_sinotype:
  {
    \__nwafu_setCJKmainfont:n   { STSong     }
    \__nwafu_setCJKsansfont:n   { STHeiti    }
    \__nwafu_setCJKmonofont:n   { STFangsong }
    \__nwafu_set_cjk_font_hei:n { STHeiti    }
    \__nwafu_set_cjk_font_kai:n { STKaiti    }
  }
\cs_new_protected:Npn \__nwafu_load_cjk_font_sourcehan:
  {
    \__nwafu_setCJKmainfont:nn { SourceHanSerifSC }
      {
        UprightFont    = *-Regular,
        BoldFont       = *-Bold,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Bold
      }
    \__nwafu_setCJKsansfont:nn { SourceHanSansSC  }
      {
        UprightFont    = *-Regular,
        BoldFont       = *-Bold,
        ItalicFont     = *-Regular,
        BoldItalicFont = *-Bold
      }
    \__nwafu_warning:n { source-han }
  }
\__nwafu_msg_new:nn { source-han }
  { Font~ set~ `sourcehan'~ does~ not~ contain~ kaiti~ and~ fangsong. }
\cs_new_protected:Npn \__nwafu_load_cjk_font_windows:
  {
    \__nwafu_setCJKmainfont:n   { SimSun   }
    \__nwafu_setCJKsansfont:n   { SimHei   }
    \__nwafu_setCJKmonofont:n   { FangSong }
    \__nwafu_set_cjk_font_hei:n { SimHei   }
    \__nwafu_set_cjk_font_kai:n { KaiTi    }
  }
\tl_new:N \l__nwafu_cjkfont_tl
\tl_new:N \l__nwafu_font_tl
\cs_new_protected:Npn \__nwafu_detect_platform:
  {
    \sys_if_platform_windows:TF
      {
        \tl_set:Nn \l__nwafu_cjkfont_tl { windows }
        \tl_set:Nn \l__nwafu_font_tl { times* }
      }
      {
        \__nwafu_if_platform_macos:TF
          {
            \tl_set:Nn \l__nwafu_cjkfont_tl { mac }
            \tl_set:Nn \l__nwafu_font_tl { times* }
          }{
            \tl_set:Nn \l__nwafu_cjkfont_tl { fandol }
            \tl_set:Nn \l__nwafu_font_tl { times }
          }
      }
  }
\cs_new_protected:Npn \__nwafu_if_platform_macos:TF
  { \file_if_exist:nTF { /System/Library/Fonts/Menlo.ttc } }
\cs_new_protected:Npn \__nwafu_load_font:
  {
    \tl_if_empty:NTF \g__nwafu_fontset_tl
      {
        \__nwafu_detect_platform:
        \tl_gset_eq:NN \g__nwafu_fontset_tl \l__nwafu_font_tl
      }{
      }
    \tl_if_empty:NTF \g__nwafu_cjk_fontset_tl
      {
        \__nwafu_detect_platform:
        \tl_gset_eq:NN \g__nwafu_cjk_fontset_tl \l__nwafu_cjkfont_tl
      }{
      }
    \use:c { __nwafu_load_font_     \g__nwafu_fontset_tl     : }
    \use:c { __nwafu_load_cjk_font_ \g__nwafu_cjk_fontset_tl : }
  }
\ctex_at_end_preamble:n { \__nwafu_load_font: }
\keys_set:nn { unicode-math }
  {
    math-style = ISO,
    bold-style = ISO,
  }
\keys_define:nn { nwafu / style }
  {
    font-size .choice:,
    font-size .value_required:n = true,
    font-size / -4 .code:n = { },
    font-size /  5 .code:n =
      {
        \RenewDocumentCommand \tiny         { } { \zihao {  7 } }
        \RenewDocumentCommand \scriptsize   { } { \zihao { -6 } }
        \RenewDocumentCommand \footnotesize { } { \zihao {  6 } }
        \RenewDocumentCommand \small        { } { \zihao { -5 } }
        \RenewDocumentCommand \normalsize   { } { \zihao {  5 } }
        \RenewDocumentCommand \large        { } { \zihao { -4 } }
        \RenewDocumentCommand \Large        { } { \zihao { -3 } }
        \RenewDocumentCommand \LARGE        { } { \zihao { -2 } }
        \RenewDocumentCommand \huge         { } { \zihao {  2 } }
        \RenewDocumentCommand \Huge         { } { \zihao {  1 } }
      },
    fullwidth-stop .choice:,
    fullwidth-stop .value_required:n = true,
    fullwidth-stop / catcode .code:n =
      { \__nwafu_set_fullwidth_stop_catcode: },
    fullwidth-stop / mapping .code:n =
      {
        \sys_if_engine_xetex:TF
          {
            \clist_gset:Nn \g__xeCJK_default_features_clist
              { Mapping = fullwidth-stop }
          }
          {
            \sys_if_engine_luatex:T
              {
                \__nwafu_warning:n { mapping-not-available }
                \__nwafu_set_fullwidth_stop_catcode:
              }
          }
      },
    fullwidth-stop / false .code:n = { }
  }
\__nwafu_msg_new:nn { mapping-not-available }
  {
    Option~ "fullwidth-stop = mapping"~ is~ not~ available~ in~ LuaTeX. \\
    "fullwidth-stop = catcode"~ will~ be~ set~ instead.
  }
\cs_new:Npn \__nwafu_set_fullwidth_stop_catcode:
  {
    \char_set_active_eq:nN { "3002 } \c__nwafu_fwid_full_stop_tl
    \char_set_catcode_active:n { "3002 }
  }
\fancyhf { }
\tl_new:N \l__nwafu_header_center_mark_tl
\RenewDocumentCommand \cleardoublepage { }
  {
    \clearpage
    \bool_if:NT \g__nwafu_twoside_bool
      {
        \int_if_odd:nF \c@page
          { \hbox:n { } \thispagestyle { empty } \newpage }
      }
    \tl_gset:Nn \l__nwafu_header_center_mark_tl { }
  }
\pagestyle { fancy }
\cs_gset_eq:NN \nwafuhead\fancyhead
\cs_gset_eq:NN \nwafufoot\fancyfoot
\RenewDocumentCommand{\frontmatter}{sO{Roman}}
  {
    \IfBooleanTF{#1}{\clearpage}{\cleardoublepage}
    \@mainmatterfalse
    \pagenumbering{#2}
    \bool_if:NTF \g__nwafu_twoside_bool
      {
        \nwafuhead[OC]{\small \nouppercase{ \leftmark } }
        \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
          {
            \nwafuhead[EC]{\small \nouppercase{
                \c__nwafu_name_simp_tl \clist_item:Nn
                \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
              }
          }{
            \nwafuhead[EC]{\small \nouppercase{ \leftmark } }
          }
      }{
        \nwafuhead [ C ]
          {
            \small \nouppercase { \l__nwafu_header_center_mark_tl }
          }
      }
    \nwafufoot[C]{\small\thepage}
  }
\RenewDocumentCommand{\mainmatter}{s}
  {
    \IfBooleanTF{#1}{\clearpage}{\cleardoublepage}
    \@mainmattertrue
    \pagenumbering{arabic}
    \bool_if:NTF \g__nwafu_twoside_bool
      {
        \nwafuhead[OC]{\small \nouppercase{ \leftmark } }
        \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
          {
            \nwafuhead[EC]{\small \nouppercase{
                \c__nwafu_name_simp_tl \clist_item:Nn
                \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
              }
          }{
            \nwafuhead[EC]{\small \nouppercase{ \l__nwafu_info_title_tl } }
          }
      }{
        \nwafuhead [ C ]
          {
            \int_if_odd:nTF \c@page
              {
                \small \nouppercase{ \leftmark }
              }{
                \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
                  {
                    \small \nouppercase{
                        \c__nwafu_name_simp_tl \clist_item:Nn
                        \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
                  }{
                    \small \nouppercase{ \l__nwafu_info_title_tl }
                  }
              }
          }
      }
    \int_compare:nNnTF{ \g__nwafu_thesis_type_int } < { 3 }
      {
        \nwafufoot[C]{\small\thepage}
      }{
        \nwafufoot[C]{\small-\ \thepage\ -}
      }
  }
\NewDocumentCommand{\bibmatter}{s}
  {
    \IfBooleanTF{#1}{\clearpage}{\cleardoublepage}
    \@mainmattertrue
    \bool_if:NTF \g__nwafu_twoside_bool
      {
        \nwafuhead[OC]{\small \nouppercase{ \leftmark } }
        \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
          {
            \nwafuhead[EC]{\small \nouppercase{
                \c__nwafu_name_simp_tl \clist_item:Nn
                \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
              }
          }{
            \nwafuhead[EC]{\small \nouppercase{ \leftmark } }
          }
      }{
        \nwafuhead [ C ]
          {
            \int_if_odd:nTF \c@page
              {
                \small \nouppercase{ \leftmark }
              }{
                \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
                  {
                    \small \nouppercase{
                        \c__nwafu_name_simp_tl \clist_item:Nn
                        \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
                  }{
                    \small \nouppercase{ \leftmark }
                  }
              }
          }
      }
  }

\__nwafu_appto_cmd:Nn \appendix
  {
    \clearpage
    \bool_if:NTF \g__nwafu_twoside_bool
      {
        \nwafuhead[OC]{\small \nouppercase{ \@chapapp } }
        \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
          {
            \nwafuhead[EC]{\small \nouppercase{
                \c__nwafu_name_simp_tl \clist_item:Nn
                \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
              }
          }{
            \nwafuhead[EC]{\small \nouppercase{ \@chapapp } }
          }
      }{
        \nwafuhead [ C ]
          {
            \int_if_odd:nTF \c@page
              {
                \small \nouppercase{ \@chapapp }
              }{
                \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
                  {
                    \small \nouppercase{
                        \c__nwafu_name_simp_tl \clist_item:Nn
                        \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
                  }{
                    \small \nouppercase{ \@chapapp }
                  }
              }
          }
      }
  }

\__nwafu_appto_cmd:Nn \backmatter
  {
    \clearpage
    \bool_if:NTF \g__nwafu_twoside_bool
      {
        \nwafuhead[OC]{\small \nouppercase{ \leftmark } }
        \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
          {
            \nwafuhead[EC]{\small \nouppercase{
                \c__nwafu_name_simp_tl \clist_item:Nn
                \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
              }
          }{
            \nwafuhead[EC]{\small \nouppercase{ \leftmark } }
          }
      }{
        \nwafuhead [ C ]
          {
            \int_if_odd:nTF \c@page
              {
                \small \nouppercase{ \leftmark }
              }{
                \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
                  {
                    \small \nouppercase{
                        \c__nwafu_name_simp_tl \clist_item:Nn
                        \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int } }
                  }{
                    \small \nouppercase{ \leftmark }
                  }
              }
          }
      }
  }
\int_compare:nNnTF{ \g__nwafu_thesis_type_int } < { 3 }
  {
    \keys_set:nn { ctex }
      {
        secnumdepth = 3,
        chapter =
          {
            pagestyle   = fancy,
            aftername   = \hspace*{1.0\ccwd},
            format      = \zihao{3} \normalfont \nwafu@hei \bfseries \centering,
            beforeskip  = 1.47\baselineskip,
            afterskip   = 1.24\baselineskip,
            number      = \__nwafu_arabic:n { chapter },
            fixskip     = true
          },
        section =
          {
            format      = \zihao{-3} \normalfont \nwafu@hei \bfseries \raggedright,
            beforeskip  = 1.09\baselineskip,
            afterskip   = 0.80\baselineskip,
            fixskip     = true
          },
        subsection =
          {
            format      = \zihao{4} \normalfont \nwafu@hei \bfseries \raggedright,
            beforeskip  = 0.80\baselineskip,
            fixskip     = true
          },
        subsubsection =
          {
            format      = \zihao{-4} \normalfont \nwafu@hei \bfseries \raggedright,
            beforeskip  = 0.40\baselineskip,
            afterskip   = 0.40\baselineskip,
            fixskip     = true
          }
      }
  }{
    \keys_set:nn { ctex }
      {
        secnumdepth = 3,
        chapter =
          {
            pagestyle   = fancy,
            name = { \bool_if:NT \l__nwafu_withchap_bool {第},
                     \bool_if:NT \l__nwafu_withchap_bool {章} },
            number      = \__nwafu_arabic:n { chapter },
            aftername   = \hspace*{\ccwd},
            format      = \zihao{3} \normalfont \nwafu@hei \bfseries \centering,
            beforeskip  = 0.25\baselineskip,
            afterskip   = 0.65\baselineskip,
            fixskip     = true
          },
        section =
          {
            aftername   = \hspace*{0.5\ccwd},
            format      = \zihao{4} \normalfont \nwafu@hei \bfseries \raggedright,
            beforeskip  = 0.60\baselineskip,
            afterskip   = 0.65\baselineskip,
            fixskip     = true,
            afterindent = true,
          },
        subsection =
          {
            aftername   = \hspace*{0.5\ccwd},
            format      = \zihao{-4} \normalfont \nwafu@hei \bfseries,
            beforeskip  = 0.60\baselineskip,
            afterskip   = 0.65\baselineskip,
            fixskip     = true,
            afterindent = true,
            % indent      = 2\ccwd,
          },
        subsubsection =
          {
            name        = {(,)},
            aftername   = \hspace*{0.5\ccwd},
            number      = \__nwafu_arabic:n { subsubsection },
            format      = \zihao{-4} \normalfont,
            beforeskip  = 0.60\baselineskip,
            afterskip   = 0.65\baselineskip,
            fixskip     = true,
            % afterindent = true,
            indent      = 2\ccwd,
          }
      }
  }
\cs_new_protected:Npn \__nwafu_chapter:n #1
  {
    \group_begin:
      \ctexset { chapter / numbering = false }
      \chapter {#1}
      \__nwafu_chapter_header:n {#1}
    \group_end:
  }
\cs_generate_variant:Nn \__nwafu_chapter:n { V }
\cs_new_protected:Npn \__nwafu_chapter_no_toc:n #1
  {
    \chapter *           {#1}
    \__nwafu_chapter_header:n {#1}
    \pdfbookmark [0] {#1} { toc }
  }
\cs_generate_variant:Nn \__nwafu_chapter_no_toc:n { V }
\cs_new_protected:Npn \__nwafu_chapter_header:n #1
  {
    \bool_if:NTF \g__nwafu_twoside_bool
      { \markboth {#1} {#1} }
      {
        \markboth { } { }
        \tl_gset:Nn \l__nwafu_header_center_mark_tl {#1}
      }
  }
\clist_map_inline:nn
  {
    { plain           } { plain           },
    { libertinus      } { libertinus      },
    { libertinus_neg  } { libertinus*     },
    { libertinus_sans } { libertinus-sans },
    { pifont          } { pifont          },
    { pifont_neg      } { pifont*         },
    { pifont_sans     } { pifont-sans     },
    { pifont_sans_neg } { pifont-sans*    },
    { xits            } { xits            },
    { xits_sans       } { xits-sans       },
    { xits_sans_neg   } { xits-sans*      }
  }
  { \__nwafu_define_fn_style:nn #1 }
\tl_new:N \l__nwafu_fn_style_tl
\keys_define:nn { nwafu / style }
  {
    footnote-style .choices:nn =
      {
        plain,
        libertinus, libertinus*, libertinus-sans,
        pifont,     pifont*,     pifont-sans,     pifont-sans*,
        xits,                    xits-sans,       xits-sans*
      }
      {
        \tl_gset_eq:NN \l__nwafu_fn_style_tl \l_keys_choice_tl
        \int_compare:nT { 5 <= \l_keys_choice_int <= 8 }
          { \RequirePackage { pifont } }
      },
    footnote-style .value_required:n = true
  }
\cs_new:Npn \__nwafu_fn_symbol_libertinus:n #1
  {
    \int_compare:nTF { #1 >= 21 }
      {
        \int_compare:nTF { #1 >= 47 }
          { \__nwafu_symbol:n { \int_eval:n { "24B6 - 47 + #1 } } }
          { \__nwafu_symbol:n { \int_eval:n { "24D0 - 21 + #1 } } }
      }
      { \__nwafu_symbol:n { \int_eval:n { "2460 - 1 + #1 } } }
  }
\cs_new:Npn \__nwafu_fn_symbol_libertinus_neg:n #1
  {
    \int_compare:nTF { #1 >= 11 }
      { \__nwafu_symbol:n { \int_eval:n { "24EB - 11 + #1 } } }
      { \__nwafu_symbol:n { \int_eval:n { "2776 -  1 + #1 } } }
  }
\cs_new_eq:NN \__nwafu_fn_symbol_libertinus_sans:n \__nwafu_fn_symbol_libertinus:n
\cs_new:Npn \__nwafu_fn_symbol_pifont:n #1
  { \ding { \int_eval:n { 171 + #1 } } }
\cs_new:Npn \__nwafu_fn_symbol_pifont_neg:n #1
  { \ding { \int_eval:n { 181 + #1 } } }
\cs_new:Npn \__nwafu_fn_symbol_pifont_sans:n #1
  { \ding { \int_eval:n { 191 + #1 } } }
\cs_new:Npn \__nwafu_fn_symbol_pifont_sans_neg:n #1
  { \ding { \int_eval:n { 201 + #1 } } }
\cs_new:Npn \__nwafu_fn_symbol_xits:n #1
  {
    \int_compare:nTF { #1 >= 10 }
      {
        \int_compare:nTF { #1 >= 36 }
          { \__nwafu_symbol:n { \int_eval:n { "24B6 - 36 + #1 } } }
          { \__nwafu_symbol:n { \int_eval:n { "24D0 - 10 + #1 } } }
      }
      { \__nwafu_symbol:n { \int_eval:n { "2460 - 1 + #1 } } }
  }
\cs_new:Npn \__nwafu_fn_symbol_xits_sans:n #1
  { \__nwafu_symbol:n { \int_eval:n { "2780 - 1 + #1 } } }
\cs_new:Npn \__nwafu_fn_symbol_xits_sans_neg:n #1
  { \__nwafu_symbol:n { \int_eval:n { "278A - 1 + #1 } } }
\cs_set:Npn \thefootnote { \nwafu_footnote_number:N \c@footnote }
\cs_new:Npn \nwafu_footnote_number:N #1
  {
    \tl_case:NnF \l__nwafu_fn_style_tl
      {
        \c__nwafu_fn_style_plain_tl
          { \int_use:N #1 }
        \c__nwafu_fn_style_libertinus_tl
          {
            \fontspec { \g__nwafu_font_name_libertinus_serif_tl .otf }
            \__nwafu_fn_symbol_libertinus:n {#1}
          }
        \c__nwafu_fn_style_libertinus_neg_tl
          {
            \fontspec { \g__nwafu_font_name_libertinus_serif_tl .otf }
            \__nwafu_fn_symbol_libertinus_neg:n {#1}
          }
        \c__nwafu_fn_style_libertinus_sans_tl
          {
            \fontspec { \g__nwafu_font_name_libertinus_sans_tl .otf }
            \__nwafu_fn_symbol_libertinus_sans:n {#1}
          }
        \c__nwafu_fn_style_pifont_tl
          { \__nwafu_fn_symbol_pifont:n {#1} }
        \c__nwafu_fn_style_pifont_neg_tl
          { \__nwafu_fn_symbol_pifont_neg:n {#1} }
        \c__nwafu_fn_style_pifont_sans_tl
          { \__nwafu_fn_symbol_pifont_sans:n {#1} }
        \c__nwafu_fn_style_pifont_sans_neg_tl
          { \__nwafu_fn_symbol_pifont_sans_neg:n {#1} }
        \c__nwafu_fn_style_xits_tl
          {
            \fontspec { \g__nwafu_font_name_xits_tl .otf }
            \__nwafu_fn_symbol_xits:n {#1}
          }
        \c__nwafu_fn_style_xits_sans_tl
          {
            \fontspec { \g__nwafu_font_name_xits_tl .otf }
            \__nwafu_fn_symbol_xits_sans:n {#1}
          }
        \c__nwafu_fn_style_xits_sans_neg_tl
          {
            \fontspec { \g__nwafu_font_name_xits_tl .otf }
            \__nwafu_fn_symbol_xits_sans_neg:n {#1}
          }
      }
      { \int_use:N #1 }
  }
\cs_set:Npn \@makefntext #1
  {
    \mode_leave_vertical:
    \hbox_to_wd:nn { 1.5 em } { \@thefnmark \hfil }
    #1
  }
\clist_const:Nn \c__nwafu_thm_style_plain_clist
  { plain, margin, change }
\clist_const:Nn \c__nwafu_thm_style_break_clist
  { break, marginbreak, changebreak }
\tl_new:N \l__nwafu_thm_style_tl
\tl_new:N \l__nwafu_thm_header_font_tl
\tl_new:N \l__nwafu_thm_body_font_tl
\tl_new:N \l__nwafu_thm_qed_tl
\tl_new:N \l__nwafu_thm_counter_tl
\keys_define:nn { nwafu / theorem }
  {
    style       .tl_set:N  = \l__nwafu_thm_style_tl,
    header-font .tl_set:N  = \l__nwafu_thm_header_font_tl,
    body-font   .tl_set:N  = \l__nwafu_thm_body_font_tl,
    qed         .tl_set:N  = \l__nwafu_thm_qed_tl,
    counter     .tl_set:N  = \l__nwafu_thm_counter_tl
  }
\cs_new_eq:NN \__nwafu_thm_ntheorem_style:n \theoremstyle
\cs_new_eq:NN \__nwafu_thm_ntheorem_new:w   \newtheorem
\RenewDocumentCommand \newtheorem { s o m m }
  {
    \IfBooleanTF {#1}
      { \tl_set:Nn \l__nwafu_thm_qed_tl { \ensuremath { \QED } } }
      { \tl_set:Nn \l__nwafu_thm_qed_tl { } }
    \tl_set:Nn \l__nwafu_thm_style_tl { plain }
    \IfValueT {#2} { \keys_set:nn { nwafu / theorem } {#2} }
    \nwafu_thm_set_header_font:V \l__nwafu_thm_header_font_tl
    \nwafu_thm_set_body_font:V   \l__nwafu_thm_body_font_tl
    \nwafu_thm_set_qed:V         \l__nwafu_thm_qed_tl
    \IfBooleanTF {#1}
      {
        \clist_if_in:nVF { plain, break } \l__nwafu_thm_style_tl
          {
            \clist_if_in:NVTF
              \c__nwafu_thm_style_plain_clist \l__nwafu_thm_style_tl
              { \__nwafu_thm_redefine_style:n { plain } }
              {
                \clist_if_in:NVTF
                  \c__nwafu_thm_style_break_clist \l__nwafu_thm_style_tl
                  { \__nwafu_thm_redefine_style:n { break } }
                  {
                    \__nwafu_error:nx { unknown-theorem-style }
                      { \l__nwafu_thm_style_tl }
                  }
              }
          }
        \tl_put_left:Nn \l__nwafu_thm_style_tl { nonumber }
        \nwafu_thm_new_no_number:Vxx \l__nwafu_thm_style_tl {#3} {#4}
      }
      {
        \clist_clear:N \l__nwafu_tmpa_clist
        \clist_concat:NNN \l__nwafu_tmpa_clist
          \c__nwafu_thm_style_plain_clist \c__nwafu_thm_style_break_clist
        \clist_if_in:NVF \l__nwafu_tmpa_clist \l__nwafu_thm_style_tl
          {
            \__nwafu_error:nx { unknown-theorem-style }
              { \l__nwafu_thm_style_tl }
          }
        \nwafu_thm_new:VVxx \l__nwafu_thm_style_tl \l__nwafu_thm_counter_tl
          {#3} {#4}
      }
  }
\cs_new:Npn \__nwafu_thm_redefine_style:n #1
  {
    \__nwafu_warning:nxx { redefine-theorem-style }
      {#1} { \l__nwafu_thm_style_tl }
    \tl_set:Nn \l__nwafu_thm_style_tl {#1}
  }
\__nwafu_msg_new:nn { redefine-theorem-style }
  { Theorem~ style~ "#2"~ will~ be~ redefined~ as~ "#1". }
\__nwafu_msg_new:nn { unknown-theorem-style }
  { Theorem~ style~ "#1"~ is~ unknown. }
\cs_new:Npn \nwafu_thm_new:nnnn #1#2#3#4
  {
    \__nwafu_thm_ntheorem_style:n {#1}
    \__nwafu_thm_ntheorem_new:w   {#3} {#4} [#2]
  }
\cs_generate_variant:Nn \nwafu_thm_new:nnnn { VVxx }
\cs_new:Npn \nwafu_thm_new_no_number:nnn #1#2#3
  {
    \__nwafu_thm_ntheorem_style:n {#1}
    \__nwafu_thm_ntheorem_new:w   {#2} {#3}
  }
\cs_generate_variant:Nn \nwafu_thm_new_no_number:nnn { Vxx }
\cs_new:Npn \nwafu_thm_set_qed:n         #1 { \theoremsymbol     {#1} }
\cs_new:Npn \nwafu_thm_set_header_font:n #1 { \theoremheaderfont {#1} }
\cs_new:Npn \nwafu_thm_set_body_font:n   #1 { \theorembodyfont   {#1} }
\cs_generate_variant:Nn \nwafu_thm_set_qed:n         { V }
\cs_generate_variant:Nn \nwafu_thm_set_header_font:n { V }
\cs_generate_variant:Nn \nwafu_thm_set_body_font:n   { V }
\DeclareCaptionLabelSeparator{ccwd}{\hspace{0.5\ccwd}}
\DeclareCaptionLabelFormat{parens}{\bothIfFirst{#1}{~}(#2)}
\DeclareCaptionFont{nwafu@table@font}{\sffamily\small}
\DeclareCaptionFont{nwafu@figure@font}{\sffamily\small}
\DeclareCaptionFont{nwafu@subtable@font}{\small}
\DeclareCaptionFont{nwafu@subfigure@font}{\small}
\captionsetup
  {
    format          = hang,
    font            = {stretch = 1},
    labelsep        = ccwd,
    singlelinecheck = true,
    skip=4bp,
  }
\captionsetup[table]{font += nwafu@table@font}
\captionsetup[longtable]{font += nwafu@table@font}
\captionsetup[figure]{font += nwafu@figure@font}
\captionsetup[subfigure]
  {
    labelformat = parens,
    font       = nwafu@subfigure@font,
    belowskip   = 2pt,
    aboveskip   = 6pt
  }
\DeclareCaptionOption{bi-first}[format=hang,hangindent=-0.5em]{
    \def\tablename{表}
    \def\figurename{图}
  }
\DeclareCaptionOption{bi-second}[format=hang,hangindent=-2em]{
    \def\tablename{Tab.}
    \def\figurename{Fig.}
  }
\captionsetup[bi-first]{bi-first}
\captionsetup[bi-second]{bi-second}
\AddToHook
  { env/figure/end }
  {
    \centering
  }
\AddToHook
  { env/table/end }
  {
    \centering
  }
\__nwafu_at_begin_environment:nn { tabular,tabularx,longtable,tblr }
  {
    \exp_args:Nx \linespread { 1.05 }
    \small\selectfont\ignorespaces
  }
\cs_set:Npn \thefigure
  { \thechapter - \__nwafu_arabic:n { figure } }
\cs_set:Npn \thetable
  { \thechapter - \__nwafu_arabic:n { table  } }
\clist_map_inline:nn
  {
    title, date, grade, enroll, author, supervisor, cosupervisor
    department, major, researchfield, professionaltype, professionalfield,
    class_id, student_id, school_id, clc, defensedate, udc
  }
  { \tl_new:c { l__nwafu_info_ #1 _tl } }
\clist_new:N \l__nwafu_info_instructors_clist
\clist_new:N \l__nwafu_info_defensecommittees_clist
\clist_new:N \l__nwafu_info_foundation_clist
\clist_map_inline:nn
  { title, author, supervisor, cosupervisor, department,
    major, mastertype, researchfield, professionaltype, professionalfield,date }
  { \tl_new:c { l__nwafu_info_ #1 _en_tl } }
\int_new:N \l__nwafu_info_degree_type_int
\int_new:N \l__nwafu_info_bachelor_type_int
\keys_define:nn { nwafu / info }
  {
    degree      .choices:nn  =
      { academic, professional }
      { \int_set_eq:NN \l__nwafu_info_degree_type_int \l_keys_choice_int },
    btype      .choice:,
    btype      .value_required:n = true,
    btype      .choices:nn  =
      { paper, design }
      { \int_set_eq:NN \l__nwafu_info_bachelor_type_int \l_keys_choice_int },
    btype      .initial:n = paper,
    title       .tl_set:N    = \l__nwafu_info_title_tl,
    title*      .tl_set:N    = \l__nwafu_info_title_en_tl,
    date        .tl_set:N    = \l__nwafu_info_date_tl,
    date*       .tl_set:N    = \l__nwafu_info_date_en_tl,
    grade        .tl_set:N    = \l__nwafu_info_grade_tl,
    enroll        .tl_set:N    = \l__nwafu_info_enroll_tl,
    author      .tl_set:N    = \l__nwafu_info_author_tl,
    author*     .tl_set:N    = \l__nwafu_info_author_en_tl,
    supervisor  .tl_set:N    = \l__nwafu_info_supervisor_tl,
    supervisor* .tl_set:N    = \l__nwafu_info_supervisor_en_tl,
    cosupervisor        .tl_set:N    = \l__nwafu_info_cosupervisor_tl,
    cosupervisor*       .tl_set:N    = \l__nwafu_info_cosupervisor_en_tl,
    instructors .clist_set:N = \l__nwafu_info_instructors_clist,
    defensecommittees .clist_set:N = \l__nwafu_info_defensecommittees_clist,
    defensedate        .tl_set:N    = \l__nwafu_info_defensedate_tl,
    foundation .clist_set:N = \l__nwafu_info_foundation_clist,
    department  .tl_set:N    = \l__nwafu_info_department_tl,
    department* .tl_set:N    = \l__nwafu_info_department_en_tl,
    major       .tl_set:N    = \l__nwafu_info_major_tl,
    major*      .tl_set:N    = \l__nwafu_info_major_en_tl,
    mastertype .tl_set:N    = \l__nwafu_info_mastertype_en_tl,
    researchfield  .tl_set:N    = \l__nwafu_info_researchfield_tl,
    researchfield* .tl_set:N    = \l__nwafu_info_researchfield_en_tl,
    professionaltype  .tl_set:N    = \l__nwafu_info_professionaltype_tl,
    professionaltype* .tl_set:N    = \l__nwafu_info_professionaltype_en_tl,
    professionalfield  .tl_set:N    = \l__nwafu_info_professionalfield_tl,
    professionalfield* .tl_set:N    = \l__nwafu_info_professionalfield_en_tl,
    class-id  .tl_set:N    = \l__nwafu_info_class_id_tl,
    student-id  .tl_set:N    = \l__nwafu_info_student_id_tl,
    school-id   .tl_set:N    = \l__nwafu_info_school_id_tl,
    clc         .tl_set:N    = \l__nwafu_info_clc_tl,
    udc         .tl_set:N    = \l__nwafu_info_udc_tl,
  }
\tl_new:N    \l__nwafu_cover_logo_tl
\clist_new:N \l__nwafu_cover_logo_size_clist
\keys_define:nn { nwafu / style }
  {
    logo      .tl_set:N    = \l__nwafu_cover_logo_tl,
    logo-size .clist_set:N = \l__nwafu_cover_logo_size_clist
  }
\bool_new:N \l__nwafu_secret_bool
\tl_new:N \l__nwafu_info_secret_level_tl
\keys_define:nn { nwafu / info }
  {
  % 密级。\opt{none} 表示公开，\opt{i}、\opt{ii}、\opt{iii}、\opt{iv} 分别为
    secret-level .choices:nn  =
      { none, i, ii, iii, iv }
      {
        \int_compare:nNnTF { \l_keys_choice_int } > { 1 }
          {
            \bool_set_true:N \l__nwafu_secret_bool
            \tl_set:Nn \l__nwafu_info_secret_level_tl
              {
                \clist_item:Nn \c__nwafu_secret_clist
                  { \l_keys_choice_int - 1 }
              }
          }
          {
            \bool_set_false:N \l__nwafu_secret_bool
            \tl_set:Nn \l__nwafu_info_secret_level_tl { 公开 }
          }
      },
    secret-level .value_required:n = true,
  }
\cs_new_protected:Npn \__nwafu_spread_box:nn #1#2
  {
    \mode_leave_vertical:
    \hbox_to_wd:nn {#1}
      { \tl_map_inline:xn {#2} { ##1 \hfil } \unskip }
  }
\cs_generate_variant:Nn \__nwafu_spread_box:nn  { Vn }
\cs_generate_variant:Nn \__nwafu_spread_box:nn  { nV }
\cs_new_protected:Npn \__nwafu_center_box:nn #1#2
  {
    \mode_leave_vertical:
    \dim_set:Nn \l__nwafu_tmpt_dim {#1}
    \dim_add:Nn \l__nwafu_tmpt_dim {0.6em}
    \makebox[0cm][l]{\rule[-0.5ex]{\l__nwafu_tmpt_dim}{0.4 pt}}
      {\hbox_to_wd:nn {\l__nwafu_tmpt_dim} { \hfil #2 \hfil }}
    % \fbox[b]{\parbox {#1} { \centering #2 }}
  }
\cs_generate_variant:Nn \__nwafu_center_box:nn  { Vn }
\cs_new:Npn \__nwafu_fixed_width_box:nn #1#2
  { \parbox {#1} {#2} }
\cs_generate_variant:Nn \__nwafu_fixed_width_box:nn  { Vn }
\cs_new:Npn \__nwafu_fixed_width_center_box:nn #1#2
  { \parbox {#1} { \centering #2 } }
\cs_new:Npn \__nwafu_get_text_width:Nn #1#2
  {
    \hbox_set:Nn \l__nwafu_tmpa_box {#2}
    \dim_set:Nn #1 { \box_wd:N \l__nwafu_tmpa_box }
  }
\cs_generate_variant:Nn \__nwafu_get_text_width:Nn { NV }
\cs_new:Npn \__nwafu_get_max_text_width:NN #1#2
  {
    \group_begin:
      \dim_set:Nn #1 {-999pt}
      \clist_set_eq:NN \l__nwafu_tmpt_clist #2
      \bool_until_do:nn { \clist_if_empty_p:N \l__nwafu_tmpt_clist }
        {
          \clist_pop:NN \l__nwafu_tmpt_clist \l__nwafu_tmpt_tl
          \__nwafu_get_text_width:NV \l__nwafu_tmpt_dim \l__nwafu_tmpt_tl
          \dim_gset:Nn #1 { \dim_max:nn {#1} { \l__nwafu_tmpt_dim } }
        }
    \group_end:
  }
\cs_new:Npn \__nwafu_blank_underline:n #1
  { \rule [ -0.5 ex ] {#1} { 0.4 pt } }
\cs_new:Npn \__nwafu_text_uline:n #1
  {
    \__nwafu_get_text_width:Nn \l__nwafu_tmpt_dim {#1}
    \dim_add:Nn \l__nwafu_tmpt_dim {0.6em}
    \makebox[0cm][l]{\rule[-0.5ex]{\l__nwafu_tmpt_dim}{0.4 pt}}
      \rule{.3em}{0cm}#1\rule{.3em}{0cm}
  }
\cs_generate_variant:Nn \__nwafu_text_uline:n { V }
\cs_new:Npn \__nwafu_line_spread:N #1
  { \linespread { \fp_use:N #1 } \selectfont }
\cs_new:Npn \__nwafu_line_spread:n #1
  { \linespread {#1} \selectfont }
\cs_new_protected:Npn \__nwafu_cover_id:
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
        \group_begin:
        \clist_clear:N \l__nwafu_tmpa_clist
        \clist_set:Nx \l__nwafu_tmpa_clist
          {
            { \c__nwafu_name_clc_tl          },
            { \c__nwafu_name_udc_tl          },
            { \c__nwafu_name_secret_level_tl }
          }
        \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
        \clist_set:Nx \l__nwafu_tmpb_clist
          {
            { \l__nwafu_info_clc_tl              },
            { \l__nwafu_info_udc_tl              },
            { \l__nwafu_info_secret_level_tl     }
          }
        \__nwafu_get_max_text_width:NN \l__nwafu_tmpb_dim \l__nwafu_tmpb_clist
        \clist_set:Nx \l__nwafu_tmpc_clist
          {
            { \c__nwafu_name_school_id_tl         },
            {                                 },
            { \c__nwafu_name_student_id_tl        }
          }
        \__nwafu_get_max_text_width:NN \l__nwafu_tmpc_dim \l__nwafu_tmpc_clist
        \clist_set:Nx \l__nwafu_tmpd_clist
          {
            { \l__nwafu_info_school_id_tl              },
            {                                      },
            { \l__nwafu_info_student_id_tl             }
          }
        \__nwafu_get_max_text_width:NN \l__nwafu_tmpd_dim \l__nwafu_tmpd_clist
        \begin{minipage} [ c ] { \textwidth }
        \bool_until_do:nn { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
          {
            \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
            \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
            \clist_pop:NN \l__nwafu_tmpc_clist \l__nwafu_tmpc_tl
            \clist_pop:NN \l__nwafu_tmpd_clist \l__nwafu_tmpd_tl
            \tl_if_eq:NNTF \l__nwafu_tmpa_tl \c__nwafu_name_udc_tl
              {
                \__nwafu_fixed_width_box:Vn \l__nwafu_tmpa_dim { \l__nwafu_tmpa_tl }
              }{
                \__nwafu_spread_box:Vn \l__nwafu_tmpa_dim { \l__nwafu_tmpa_tl }
              }
            \c__nwafu_fwid_colon_tl
            \__nwafu_center_box:Vn \l__nwafu_tmpb_dim { \l__nwafu_tmpb_tl }
            \hfill
            \tl_if_empty:NTF \l__nwafu_tmpc_tl
              {
              }{
                \__nwafu_spread_box:Vn \l__nwafu_tmpc_dim { \l__nwafu_tmpc_tl }
                \c__nwafu_fwid_colon_tl
                \__nwafu_center_box:Vn \l__nwafu_tmpd_dim { \l__nwafu_tmpd_tl }
              }
            \par
          }
        \end{minipage}
        \group_end:
      }
      {
        \__nwafu_fixed_width_box:nn { 120 pt }
          {
            \__nwafu_cover_id_aux:n { student_id }
          }
      }
  }
\cs_new:Npn \__nwafu_cover_id_aux:n #1
  {
    \tl_use:c { c__nwafu_name_ #1 _tl }
    \c__nwafu_fwid_colon_tl
    \__nwafu_text_uline:n {\tl_use:c { l__nwafu_info_ #1 _tl }}
  }
\cs_new_protected:Npn \__nwafu_cover_logo:
  {
    \clist_pop:NN   \l__nwafu_cover_logo_size_clist \l__nwafu_tmpa_tl
    \clist_pop:NNTF \l__nwafu_cover_logo_size_clist \l__nwafu_tmpb_tl
      {
        \tl_if_empty:NTF \l__nwafu_tmpa_tl
          { \includegraphics [ height = \l__nwafu_tmpb_tl ] }
          {
            \includegraphics
              [ width  = \l__nwafu_tmpa_tl, height = \l__nwafu_tmpb_tl ]
          }
      }
      { \includegraphics [ width = \l__nwafu_tmpa_tl ] }
    { \l__nwafu_cover_logo_tl }
  }
\cs_new_protected:Npn \__nwafu_cover_type:
  {
    \tl_set:Nx \l__nwafu_tmpa_tl
      {
        \clist_item:Nn \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int }
      }
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
        \__nwafu_spread_box:nn { 0.75 \textwidth } { \l__nwafu_tmpa_tl }
      }{
        \__nwafu_get_text_width:NV \l__nwafu_tmpa_dim \l__nwafu_info_grade_tl
        \__nwafu_center_box:Vn \l__nwafu_tmpa_dim { \l__nwafu_info_grade_tl }
        \__nwafu_spread_box:nn { 0.50 \textwidth }{
            届
            \l__nwafu_tmpa_tl
            \clist_item:Nn \c__nwafu_bachelor_type_clist { \l__nwafu_info_bachelor_type_int }
          }
      }
  }
\cs_new_protected:Npn \__nwafu_cover_info:
  {
    \begin{minipage} [ c ] { \textwidth }
      \centering
      \int_case:nn {\g__nwafu_thesis_type_int}
        {
          {1}{
            \clist_set:Nx \l__nwafu_tmpa_clist
              {
                \c__nwafu_name_major_tl,
                \c__nwafu_name_researchfield_tl,
                \c__nwafu_name_author_tl,
                \c__nwafu_name_supervisor_tl,
                \c__nwafu_name_cosupervisor_tl,
                \c__nwafu_name_date_tl,
              }
            \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
            \clist_set:Nx \l__nwafu_tmpb_clist
              {
                { \l__nwafu_info_major_tl              },
                { \l__nwafu_info_researchfield_tl      },
                { \l__nwafu_info_author_tl             },
                { \l__nwafu_info_supervisor_tl         },
                { \l__nwafu_info_cosupervisor_tl       },
                { \l__nwafu_info_date_tl               }
              }
            \__nwafu_get_max_text_width:NN \l__nwafu_tmpb_dim \l__nwafu_tmpb_clist
          }
          {2}{
            \int_case:nn {\l__nwafu_info_degree_type_int}
            {
              {1}{
                \clist_set:Nx \l__nwafu_tmpa_clist
                  {
                    \c__nwafu_name_major_tl,
                    \c__nwafu_name_researchfield_tl,
                    \c__nwafu_name_author_tl,
                    \c__nwafu_name_supervisor_tl,
                    \c__nwafu_name_cosupervisor_tl,
                    \c__nwafu_name_date_tl,
                  }
                \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
                \clist_set:Nx \l__nwafu_tmpb_clist
                  {
                    { \l__nwafu_info_major_tl              },
                    { \l__nwafu_info_researchfield_tl      },
                    { \l__nwafu_info_author_tl             },
                    { \l__nwafu_info_supervisor_tl         },
                    { \l__nwafu_info_cosupervisor_tl       },
                    { \l__nwafu_info_date_tl               }
                  }
                \__nwafu_get_max_text_width:NN \l__nwafu_tmpb_dim \l__nwafu_tmpb_clist
              }
              {2}{
                \clist_set:Nx \l__nwafu_tmpa_clist
                  {
                    \c__nwafu_name_professionaltype_tl,
                    \c__nwafu_name_professionalfield_tl,
                    \c__nwafu_name_author_tl,
                    \c__nwafu_name_supervisor_tl,
                    \c__nwafu_name_cosupervisor_tl,
                    \c__nwafu_name_date_tl,
                  }
                \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
                \clist_set:Nx \l__nwafu_tmpb_clist
                  {
                    { \l__nwafu_info_professionaltype_tl   },
                    { \l__nwafu_info_professionalfield_tl  },
                    { \l__nwafu_info_author_tl             },
                    { \l__nwafu_info_supervisor_tl         },
                    { \l__nwafu_info_cosupervisor_tl       },
                    { \l__nwafu_info_date_tl               }
                  }
                \__nwafu_get_max_text_width:NN \l__nwafu_tmpb_dim \l__nwafu_tmpb_clist
              }
            }
          }
          {3}{
            \clist_set:Nx \l__nwafu_tmpa_clist
              {
                \c__nwafu_name_department_tl,
                \c__nwafu_name_major_tl,
                \c__nwafu_name_enroll_tl\c__nwafu_name_class_id_tl,
                \c__nwafu_name_author_tl,
                \c__nwafu_name_supervisor_tl,
                \c__nwafu_name_cosupervisor_tl,
                \c__nwafu_name_date_tl,
              }
            \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
            \clist_set:Nx \l__nwafu_tmpb_clist
              {
                { \l__nwafu_info_department_tl                          },
                { \l__nwafu_info_major_tl                               },
                { \l__nwafu_info_enroll_tl 级 \l__nwafu_info_class_id_tl 班 },
                { \l__nwafu_info_author_tl                              },
                { \l__nwafu_info_supervisor_tl                          },
                { \l__nwafu_info_cosupervisor_tl                        },
                { \l__nwafu_info_date_tl                                }
              }
            \__nwafu_get_max_text_width:NN \l__nwafu_tmpb_dim \l__nwafu_tmpb_clist
          }
      }
      \bool_until_do:nn
        { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
        {
          \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
          \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
          \__nwafu_spread_box:Vn \l__nwafu_tmpa_dim { \l__nwafu_tmpa_tl }
          \c__nwafu_fwid_colon_tl
          \__nwafu_center_box:Vn \l__nwafu_tmpb_dim { \l__nwafu_tmpb_tl }
          \skip_vertical:n { 1 ex }
        }
    \end{minipage}
  }
\cs_new_protected:Npn \__nwafu_cover_info_en:
  {
    \int_case:nn {\g__nwafu_thesis_type_int}
      {
        {1}{
          \clist_set:Nx \l__nwafu_tmpa_clist
            {
              {\c__nwafu_name_major_en_tl{\l__nwafu_info_major_en_tl}},
              {\c__nwafu_name_researchfield_en_tl{\l__nwafu_info_researchfield_en_tl}},
              {\c__nwafu_name_author_en_tl{\l__nwafu_info_author_en_tl}},
              {\c__nwafu_name_supervisor_en_tl{\l__nwafu_info_supervisor_en_tl}},
              {\c__nwafu_name_cosupervisor_en_tl{\l__nwafu_info_cosupervisor_en_tl}},
              {\c__nwafu_name_date_en_tl{\l__nwafu_info_date_en_tl}},
            }
          \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
          \dim_add:Nn \l__nwafu_tmpa_dim {2.5em}
          \begin{minipage} [ c ] { \l__nwafu_tmpa_dim }
            \flushleft
            \clist_set:Nx \l__nwafu_tmpa_clist
              {
                \c__nwafu_name_major_en_tl,
                \c__nwafu_name_researchfield_en_tl,
                \c__nwafu_name_author_en_tl,
                \c__nwafu_name_supervisor_en_tl,
                \c__nwafu_name_cosupervisor_en_tl,
                \c__nwafu_name_date_en_tl,
              }
            \clist_set:Nx \l__nwafu_tmpb_clist
              {
                { \l__nwafu_info_major_en_tl              },
                { \l__nwafu_info_researchfield_en_tl      },
                { \l__nwafu_info_author_en_tl             },
                { \l__nwafu_info_supervisor_en_tl         },
                { \l__nwafu_info_cosupervisor_en_tl       },
                { \l__nwafu_info_date_en_tl               }
              }
            \bool_until_do:nn
              { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
              {
                \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
                \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
                \l__nwafu_tmpa_tl
                \c__nwafu_fwid_colon_tl
                \l__nwafu_tmpb_tl
                \skip_vertical:n { 1 ex }
              }
          \end{minipage}
        }
        {2}{
          \int_case:nn {\l__nwafu_info_degree_type_int}
            {
              {1}{
                \clist_set:Nx \l__nwafu_tmpa_clist
                  {
                    {\c__nwafu_name_major_en_tl{\l__nwafu_info_major_en_tl}},
                    {\c__nwafu_name_researchfield_en_tl{\l__nwafu_info_researchfield_en_tl}},
                    {\c__nwafu_name_author_en_tl{\l__nwafu_info_author_en_tl}},
                    {\c__nwafu_name_supervisor_en_tl{\l__nwafu_info_supervisor_en_tl}},
                    {\c__nwafu_name_cosupervisor_en_tl{\l__nwafu_info_cosupervisor_en_tl}},
                    {\c__nwafu_name_date_en_tl{\l__nwafu_info_date_en_tl}},
                  }
                \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
                \dim_add:Nn \l__nwafu_tmpa_dim {2.5em}
                \begin{minipage} [ c ] { \l__nwafu_tmpa_dim }
                  \flushleft
                  \clist_set:Nx \l__nwafu_tmpa_clist
                     {
                       \c__nwafu_name_major_en_tl,
                       \c__nwafu_name_researchfield_en_tl,
                       \c__nwafu_name_author_en_tl,
                       \c__nwafu_name_supervisor_en_tl,
                       \c__nwafu_name_cosupervisor_en_tl,
                       \c__nwafu_name_date_en_tl,
                     }
                  \clist_set:Nx \l__nwafu_tmpb_clist
                    {
                      { \l__nwafu_info_major_en_tl              },
                      { \l__nwafu_info_researchfield_en_tl      },
                      { \l__nwafu_info_author_en_tl             },
                      { \l__nwafu_info_supervisor_en_tl         },
                      { \l__nwafu_info_cosupervisor_en_tl       },
                      { \l__nwafu_info_date_en_tl               }
                    }
                  \bool_until_do:nn
                    { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
                    {
                      \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
                      \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
                      \l__nwafu_tmpa_tl
                      \c__nwafu_fwid_colon_tl
                      \l__nwafu_tmpb_tl
                      \skip_vertical:n { 1 ex }
                    }
                \end{minipage}
              }
              {2}{
                \clist_set:Nx \l__nwafu_tmpa_clist
                  {
                    {\c__nwafu_name_professionaltype_en_tl{Master~of~\l__nwafu_info_professionaltype_en_tl}},
                    {\c__nwafu_name_professionalfield_en_tl{\l__nwafu_info_professionalfield_en_tl}},
                    {\c__nwafu_name_author_en_tl{\l__nwafu_info_author_en_tl}},
                    {\c__nwafu_name_supervisor_en_tl{\l__nwafu_info_supervisor_en_tl}},
                    {\c__nwafu_name_cosupervisor_en_tl{\l__nwafu_info_cosupervisor_en_tl}},
                    {\c__nwafu_name_date_en_tl{\l__nwafu_info_date_en_tl}},
                  }
                \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
                \dim_add:Nn \l__nwafu_tmpa_dim {2.5em}
                \begin{minipage} [ c ] { \l__nwafu_tmpa_dim }
                  \flushleft
                  \clist_set:Nx \l__nwafu_tmpa_clist
                     {
                       \c__nwafu_name_professionaltype_en_tl,
                       \c__nwafu_name_professionalfield_en_tl,
                       \c__nwafu_name_author_en_tl,
                       \c__nwafu_name_supervisor_en_tl,
                       \c__nwafu_name_cosupervisor_en_tl,
                       \c__nwafu_name_date_en_tl,
                     }
                  \clist_set:Nx \l__nwafu_tmpb_clist
                    {
                      { Master ~ of ~ \l__nwafu_info_professionaltype_en_tl },
                      { \l__nwafu_info_professionalfield_en_tl              },
                      { \l__nwafu_info_author_en_tl                         },
                      { \l__nwafu_info_supervisor_en_tl                     },
                      { \l__nwafu_info_cosupervisor_en_tl                   },
                      { \l__nwafu_info_date_en_tl                           }
                    }
                  \bool_until_do:nn
                    { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
                    {
                      \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
                      \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
                      \l__nwafu_tmpa_tl
                      \c__nwafu_fwid_colon_tl
                      \l__nwafu_tmpb_tl
                      \skip_vertical:n { 1 ex }
                    }
                \end{minipage}
              }
            }
          }
      }
  }
\cs_new_protected:Npn \__nwafu_cover_instructors:
  {
    \int_case:nn {\g__nwafu_thesis_type_int}
      {
        {1}{
          \clist_set:Nx \l__nwafu_tmpa_clist
            {
              {\c__nwafu_name_author_tl      },
              {\c__nwafu_name_supervisor_tl  },
              {\c__nwafu_name_instructors_tl },
            }
          \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
          \tl_set:Nn \l__nwafu_tmpa_tl {\clist_use:Nn \l__nwafu_info_instructors_clist {\__nwafu_quad: }}
          \clist_set:Nx \l__nwafu_tmpb_clist
            {
              {\l__nwafu_info_author_tl     },
              {\l__nwafu_info_supervisor_tl },
              {\l__nwafu_tmpa_tl            },
            }
          \__nwafu_get_max_text_width:NN \l__nwafu_tmpb_dim \l__nwafu_tmpb_clist
          \dim_set_eq:NN \l__nwafu_tmpt_dim \l__nwafu_tmpa_dim
          \dim_add:Nn \l__nwafu_tmpt_dim { \l__nwafu_tmpb_dim }
          \dim_add:Nn \l__nwafu_tmpt_dim {2.5em}
          \begin{minipage} [ c ] { \l__nwafu_tmpt_dim }
            \centering
            \bool_until_do:nn
              { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
              {
                \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
                \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
                \l__nwafu_tmpa_tl
                \c__nwafu_fwid_colon_tl
                \__nwafu_center_box:Vn \l__nwafu_tmpb_dim { \l__nwafu_tmpb_tl }
                \skip_vertical:n { 1 ex }
              }
            % \c__nwafu_name_author_tl
            % \c__nwafu_fwid_colon_tl
            % \__nwafu_blank_underline:n{ 12em }
            % \skip_vertical:n { 1 ex }
            % \c__nwafu_name_supervisor_tl
            % \c__nwafu_fwid_colon_tl
            % \__nwafu_blank_underline:n{ 12em }
            % \skip_vertical:n { 1 ex }
            % \c__nwafu_name_instructors_tl
            % \c__nwafu_fwid_colon_tl
            % \__nwafu_blank_underline:n{ 12em }
            % \skip_vertical:n { 1 ex }
          \end{minipage}
        }
        {2}{
          \clist_set:Nx \l__nwafu_tmpa_clist
            {
              {\c__nwafu_name_author_tl      },
              {\c__nwafu_name_supervisor_tl  },
            }
          \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
          \clist_set:Nx \l__nwafu_tmpb_clist
            {
              {\l__nwafu_info_author_tl     },
              {\l__nwafu_info_supervisor_tl },
            }
          \__nwafu_get_max_text_width:NN \l__nwafu_tmpb_dim \l__nwafu_tmpb_clist
          \dim_add:Nn \l__nwafu_tmpb_dim { \l__nwafu_tmpb_dim }
          \dim_set_eq:NN \l__nwafu_tmpt_dim \l__nwafu_tmpa_dim
          \dim_add:Nn \l__nwafu_tmpt_dim { \l__nwafu_tmpb_dim }
          \dim_add:Nn \l__nwafu_tmpt_dim {2.5em}
          \begin{minipage} [ c ] { \l__nwafu_tmpt_dim }
            \centering
            \bool_until_do:nn
              { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
              {
                \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
                \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
                \l__nwafu_tmpa_tl
                \c__nwafu_fwid_colon_tl
                \__nwafu_center_box:Vn \l__nwafu_tmpb_dim { \l__nwafu_tmpb_tl }
                \skip_vertical:n { 1 ex }
              }
          % \begin{minipage} [ c ] { 17em }
          %   \flushleft
          %   \c__nwafu_name_author_tl
          %   \c__nwafu_fwid_colon_tl
          %   \__nwafu_blank_underline:n{ 12em }
          %   \skip_vertical:n { 1 ex }
          %   \c__nwafu_name_supervisor_tl
          %   \c__nwafu_fwid_colon_tl
          %   \__nwafu_blank_underline:n{ 12em }
          %   \skip_vertical:n { 1 ex }
          \end{minipage}
        }
      }
  }
\cs_new_protected:Npn \__nwafu_cover_defensecommittees:
  {
    \clist_set:Nn \l__nwafu_tmpa_clist {}
    \clist_set:Nn \l__nwafu_tmpb_clist {}
    \clist_set:Nn \l__nwafu_tmpc_clist {}
    \bool_until_do:nn { \clist_if_empty_p:N \l__nwafu_info_defensecommittees_clist }
      {
        \clist_set:Nn \l__nwafu_tmpt_clist {}
        \clist_pop:NN \l__nwafu_info_defensecommittees_clist \l__nwafu_tmpa_tl
        \clist_set:NV \l__nwafu_tmpt_clist \l__nwafu_tmpa_tl
        \clist_put_right:Nx \l__nwafu_tmpa_clist {
            \clist_item:Nn \l__nwafu_tmpt_clist {1}
        }
        \clist_put_right:Nx \l__nwafu_tmpb_clist {
            \clist_item:Nn \l__nwafu_tmpt_clist {2}
        }
        \clist_put_right:Nx \l__nwafu_tmpc_clist {
            \clist_item:Nn \l__nwafu_tmpt_clist {3}
        }
      }
    \__nwafu_get_max_text_width:NN \l__nwafu_tmpa_dim \l__nwafu_tmpa_clist
    \__nwafu_get_max_text_width:NN \l__nwafu_tmpb_dim \l__nwafu_tmpb_clist
    \__nwafu_get_max_text_width:NN \l__nwafu_tmpc_dim \l__nwafu_tmpc_clist
    \begin{minipage} [ c ] { \textwidth }
      \centering
      \bool_until_do:nn { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
        {
          \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
          \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
          \clist_pop:NN \l__nwafu_tmpc_clist \l__nwafu_tmpc_tl
          \__nwafu_spread_box:Vn \l__nwafu_tmpa_dim { \l__nwafu_tmpa_tl }
          \__nwafu_center_box:Vn \l__nwafu_tmpb_dim { \l__nwafu_tmpb_tl }
          \__nwafu_spread_box:Vn \l__nwafu_tmpc_dim { \l__nwafu_tmpc_tl }
          \skip_vertical:n { 0.5 ex }
        }
    \end{minipage}
  }
\cs_new_protected:Npn \__nwafu_cover_foundation:
  {
    \clist_set:Nn \l__nwafu_tmpa_clist {}
    \clist_set:Nn \l__nwafu_tmpb_clist {}
    \clist_set:Nn \l__nwafu_tmpc_clist {}
    \bool_until_do:nn { \clist_if_empty_p:N \l__nwafu_info_foundation_clist }
      {
        \clist_set:Nn \l__nwafu_tmpt_clist {}
        \clist_pop:NN \l__nwafu_info_foundation_clist \l__nwafu_tmpa_tl
        \clist_set:NV \l__nwafu_tmpt_clist \l__nwafu_tmpa_tl
        \clist_put_right:Nx \l__nwafu_tmpa_clist {
            \clist_item:Nn \l__nwafu_tmpt_clist {1}
        }
        \clist_put_right:Nx \l__nwafu_tmpb_clist {
            \clist_item:Nn \l__nwafu_tmpt_clist {2}
        }
        \clist_put_right:Nx \l__nwafu_tmpc_clist {
            \clist_item:Nn \l__nwafu_tmpt_clist {3}
        }
      }
    \begin{minipage} [ c ] { \textwidth }
    \bool_until_do:nn { \clist_if_empty_p:N \l__nwafu_tmpa_clist }
      {
        \clist_pop:NN \l__nwafu_tmpa_clist \l__nwafu_tmpa_tl
        \clist_pop:NN \l__nwafu_tmpb_clist \l__nwafu_tmpb_tl
        \clist_pop:NN \l__nwafu_tmpc_clist \l__nwafu_tmpc_tl
        \indent
        \__nwafu_qquad:
        本研究得到
        \l__nwafu_tmpa_tl
        \c__nwafu_fwid_colon_tl
        \l__nwafu_tmpb_tl
        (编号\c__nwafu_fwid_colon_tl
        \l__nwafu_tmpc_tl
        )资助
        \par
      }
    \end{minipage}
  }
\cs_new_protected:Npn \__nwafu_cover_signature:N #1
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
        \__nwafu_qquad:
        \__nwafu_spread_box:nV { 5 em } #1
        \c__nwafu_fwid_colon_tl
        \hspace*{\fill}
      }{
        \__nwafu_spread_box:nV { 6 em } #1
        \c__nwafu_fwid_colon_tl
        % \__nwafu_blank_underline:n { 6 em }
        \hspace*{\fill}
      }
    时间\c__nwafu_fwid_colon_tl
    \__nwafu_qquad:\__nwafu_qquad: 年
    \__nwafu_qquad: 月
    \__nwafu_qquad: 日
    \hspace*{\fill}
    % \__nwafu_qquad:
  }
\DeclareObjectType { nwafu / cover } { \c_zero_int }
\NewDocumentCommand \DeclareCoverTemplate { m m }
  { \nwafu_cover_declare_template:nn {#1} {#2} }
\cs_new_protected:Npn \nwafu_cover_declare_template:nn #1#2
  {
    \tl_set:Nn \l__nwafu_cover_template_tl {#1}
    \__nwafu_cover_declare_template_interface:nx {#1}
      {
        format      : tokenlist,
        top-skip    : skip,
        bottom-skip : skip,
        \clist_map_function:nN {#2} \__nwafu_cover_key_type:n
      }
    \tl_new:c   { l__nwafu_cover / #1 / format_tl   }
    \skip_new:c { l__nwafu_cover / #1 / top_skip    }
    \skip_new:c { l__nwafu_cover / #1 / bottom_skip }
    \clist_map_inline:nn {#2}
      {
        \tl_new:c   { l__nwafu_cover / #1 / ##1 / content_tl  }
        \tl_new:c   { l__nwafu_cover / #1 / ##1 / format_tl   }
        \skip_new:c { l__nwafu_cover / #1 / ##1 / bottom_skip }
      }
    \__nwafu_cover_declare_template_code:nxn {#1}
      {
        format      = \exp_not:c { l__nwafu_cover / #1 / format_tl   },
        top-skip    = \use:c     { l__nwafu_cover / #1 / top_skip    },
        bottom-skip = \use:c     { l__nwafu_cover / #1 / bottom_skip },
        \clist_map_function:nN {#2} \__nwafu_cover_key_binding:n
      }
      {
        \AssignTemplateKeys
        \tl_use:c       { l__nwafu_cover / #1 / format_tl }
        \__nwafu_vspace:c { l__nwafu_cover / #1 / top_skip  }
        \clist_map_inline:nn {#2}
          {
            \use:c { __nwafu_cover / #1 / ####1 / align:n }
              {
                \tl_use:c { l__nwafu_cover / #1 / ####1 / format_tl  }
                \tl_use:c { l__nwafu_cover / #1 / ####1 / content_tl }
                \par
              }
            \__nwafu_vspace:c { l__nwafu_cover / #1 / ####1 / bottom_skip }
          }
        \__nwafu_vspace:c { l__nwafu_cover / #1 / bottom_skip }
      }
  }
\tl_new:N \l__nwafu_cover_template_tl
\cs_new_protected:Npn \__nwafu_cover_declare_template_interface:nn #1#2
  { \DeclareTemplateInterface { nwafu / cover } {#1} { \c_zero_int } {#2} }
\cs_new_protected:Npn \__nwafu_cover_declare_template_code:nnn #1#2#3
  { \DeclareTemplateCode { nwafu / cover } {#1} { \c_zero_int } {#2} {#3} }
\cs_generate_variant:Nn \__nwafu_cover_declare_template_interface:nn { nx  }
\cs_generate_variant:Nn \__nwafu_cover_declare_template_code:nnn     { nxn }
\cs_new:Npn \__nwafu_cover_key_type:n #1
  {
    #1 / content     : tokenlist,
    #1 / format      : tokenlist,
    #1 / bottom-skip : skip,
    #1 / align       : choice { left, right, center, normal } = normal,
  }
\cs_new:Npn \__nwafu_cover_key_binding:n #1
  {
    #1 / content     =
      \exp_not:c
        { l__nwafu_cover / \l__nwafu_cover_template_tl / #1 / content_tl  },
    #1 / format      =
      \exp_not:c
        { l__nwafu_cover / \l__nwafu_cover_template_tl / #1 / format_tl   },
    #1 / bottom-skip =
      \exp_not:c
        { l__nwafu_cover / \l__nwafu_cover_template_tl / #1 / bottom_skip },
    #1 / align       =
      {
        left   =
          \exp_not:N \cs_set_protected:cpn
            { __nwafu_cover / \l__nwafu_cover_template_tl / #1 / align:n }
            \exp_not:n {##1}
            {
              \exp_not:n
                {
                  \group_begin:
                    \flushleft ##1 \endflushleft
                  \group_end:
                }
            },
        right  =
          \exp_not:N \cs_set_protected:cpn
            { __nwafu_cover / \l__nwafu_cover_template_tl / #1 / align:n }
            \exp_not:n {##1}
            {
              \exp_not:n
                {
                  \group_begin:
                    \flushright ##1 \endflushright
                  \group_end:
                }
            },
        center =
          \exp_not:N \cs_set_protected:cpn
            { __nwafu_cover / \l__nwafu_cover_template_tl / #1 / align:n }
            \exp_not:n {##1}
            {
              \exp_not:n
                {
                  \group_begin:
                    \center ##1 \endcenter
                  \group_end:
                }
            },
        normal =
          \exp_not:N \cs_set_protected:cpn
            { __nwafu_cover / \l__nwafu_cover_template_tl / #1 / align:n }
            \exp_not:n {##1}
            { \exp_not:n { \group_begin: ##1 \group_end: } }
      },
  }
\NewDocumentCommand \makecoveri { }
  {
    \thispagestyle { empty }
    \newgeometry{top=1.0in, bottom=1.0in, left=1.25in, right=1.25in}
    \UseInstance { nwafu / cover } { cover-i-default }
    \restoregeometry
  }
\NewDocumentCommand \makecoverii { }
  {
    \thispagestyle { empty }
    \newgeometry{top=1.0in, bottom=1.0in, left=1.25in, right=1.25in}
    \UseInstance { nwafu / cover } { cover-ii-default }
    \restoregeometry
  }
\NewDocumentCommand \makecoveriii { }
  {
    % \cleardoublepage
    \newgeometry{top=1.0in, bottom=1.0in, left=1.25in, right=1.25in}
    \thispagestyle { empty }
    \UseInstance { nwafu / cover } { cover-iii-default }
    \restoregeometry
  }
\NewDocumentCommand \makecoveriv { }
  {
    % \cleardoublepage
    \newgeometry{top=1.0in, bottom=1.0in, left=1.25in, right=1.25in}
    \thispagestyle { empty }
    \UseInstance { nwafu / cover } { cover-iv-default }
    \restoregeometry
  }
\NewDocumentCommand \makecoverv { }
  {
    % \cleardoublepage
    \newgeometry{top=1.0in, bottom=1.0in, left=1.25in, right=1.25in}
    \thispagestyle { empty }
    \UseInstance { nwafu / cover } { cover-v-default }
    \restoregeometry
  }
\NewDocumentCommand \makecovervi { }
  {
    % \cleardoublepage
    \newgeometry{top=1.0in, bottom=1.0in, left=1.25in, right=1.25in}
    \thispagestyle { empty }
    \UseInstance { nwafu / cover } { cover-vi-default }
    \restoregeometry
  }
\NewDocumentCommand \makecovervii { }
  {
    % \cleardoublepage
    \newgeometry{top=1.0in, bottom=1.0in, left=1.25in, right=1.25in}
    \thispagestyle { empty }
    \UseInstance { nwafu / cover } { cover-vii-default }
    \restoregeometry
  }
\int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
  {
    \DeclareCoverTemplate { cover-i   }
      { logo, type, title, info }
  }{
    \DeclareCoverTemplate { cover-i   }
      { id, logo, type, title, info }
  }
\DeclareCoverTemplate { cover-ii  } {
  type, title, info, department, nwafu
  }
\DeclareCoverTemplate { cover-iii } { id, name, title, instructors,
    ctitle, committees, dtitle, date
  }
\DeclareCoverTemplate { cover-iv  } { name-list }
\DeclareCoverTemplate { cover-v }
  {
    originality-decl-name,
    originality-decl-text,
    originality-decl-sig,
    supervisor-decl-name,
    supervisor-decl-text,
    supervisor-decl-sig
  }
\DeclareCoverTemplate { cover-vi }
  {
    authorization-decl-name,
    authorization-decl-text,
    authorization-decl-sig,
    supervisor-decl-sig
  }
\DeclareCoverTemplate { cover-vii }
  {
    originality-decl-name,
    originality-decl-text,
    originality-decl-sig,
    authorization-decl-name,
    authorization-decl-text,
    authorization-decl-sig,
    supervisor-decl-sig
  }
\int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
  {
    \DeclareInstance { nwafu / cover } { cover-i-default } { cover-i }
      {
        bottom-skip            = 0 pt plus 1.5 fill,
        logo     / content     = \__nwafu_cover_logo:,
        logo     / bottom-skip = -45 pt plus 0.3 fill,
        logo     / align       = center,
        type     / content     = \__nwafu_cover_type:,
        type     / format      = \sffamily \zihao {  0 },% \bfseries,
        type     / bottom-skip = -20 pt plus 0.3 fill,
        type     / align       = center,
        title    / content     =
          \__nwafu_fixed_width_center_box:nn
            { 0.9 \textwidth } { \l__nwafu_info_title_tl },
        title    / format      = \nwafu@hei \bfseries \zihao { 2 },
        title    / bottom-skip = 80 pt plus 0.3 fill,
        title    / align       = center,
        info     / content     = \__nwafu_cover_info:,
        info     / format      = \__nwafu_line_spread:n {1.05}\nwafu@hei \zihao { -3 },
        info     / align       = center,
      }
  }{
    \DeclareInstance { nwafu / cover } { cover-i-default } { cover-i }
      {
        bottom-skip            = 0 pt plus 0.5 fill,
        id       / content     = \__nwafu_cover_id:,
        id       / format      = \bfseries\zihao { 4 },
        id       / bottom-skip = 0 pt plus 0.3 fill,
        id       / align       = right,
        logo     / content     = \__nwafu_cover_logo:,
        logo     / bottom-skip = -30 pt,% plus 0.3 fill,
        logo     / align       = center,
        type     / content     = \__nwafu_cover_type:,
        type     / format      = \bfseries\nwafu@kai\zihao {  1 },
        type     / bottom-skip = -20 pt plus 0.3 fill,
        type     / align       = center,
        title    / content     =
          \__nwafu_fixed_width_center_box:nn
            { 0.9 \textwidth } { \l__nwafu_info_title_tl },
        title    / format      = \nwafu@hei \bfseries\zihao { 2 },
        title    / bottom-skip = 80 pt plus 0.3 fill,
        title    / align       = center,
        info     / content     = \__nwafu_cover_info:,
        info     / format      = \rmfamily\zihao { 3 },
        info     / align       = center,
      }
  }
\int_case:nn {\g__nwafu_thesis_type_int}
  {
    {1}{
         \DeclareInstance { nwafu / cover } { cover-ii-default } { cover-ii }
           {
             bottom-skip            = 0 pt plus 0.5 fill,
             type     / content =
               \__nwafu_fixed_width_center_box:nn { 0.7\textwidth } {
                  Thesis~Submitted~to~\c__nwafu_name_en_tl\\
                  in~Partial~Fulfillment~of~the~Requirements\\
                  for~Degree~of\\
                  Doctor~of~Philosophy
              },
             type     / format  = \__nwafu_line_spread:n {1.22} \zihao { -3 },
             type     / bottom-skip = 42 pt,% plus 0.3 fill,
             type     / align   = center,
             title     / content = \l__nwafu_info_title_en_tl,
             title     / format  = \__nwafu_line_spread:n {0.90}
                                   \zihao { 1 } \bfseries,
             title     / bottom-skip = 35 pt,% plus 0.3 fill,
             title     / align   = center,
             info     / content     = \__nwafu_cover_info_en:,
             info     / format      = \__nwafu_line_spread:n {1.12} \zihao { -3 },
             info    / bottom-skip = 72 pt,% plus 0.3 fill,
             info     / align       = center,
             department     / content     = \l__nwafu_info_department_en_tl,
             department     / format      = \zihao { -3 },
             department     / bottom-skip = -32 pt,% plus 0.3 fill,
             department     / align       = center,
             nwafu     / content     = \c__nwafu_name_en_tl,
             nwafu     / format      = \zihao { -3 },
             nwafu     / align       = center,
           }
    }
    {2}{
         \DeclareInstance { nwafu / cover } { cover-ii-default } { cover-ii }
           {
             bottom-skip            = 0 pt plus 0.5 fill,
             type     / content =
               \__nwafu_fixed_width_center_box:nn { 0.7\textwidth } {
                  Thesis~Submitted~to~\c__nwafu_name_en_tl\\
                  in~Partial~Fulfillment~of~the~Requirements\\
                  for~Degree~of\\
                  Master~of
                 \int_case:nn {\l__nwafu_info_degree_type_int}
                  {
                    {1}{
                      \__nwafu_text_uline:V \l__nwafu_info_mastertype_en_tl
                    }
                    {2}{
                      \__nwafu_text_uline:V \l__nwafu_info_professionaltype_en_tl
                    }
                  }
               },
             type     / format  = \__nwafu_line_spread:n {1.22} \zihao { -3 },
             type     / bottom-skip = 42 pt,% plus 0.3 fill,
             type     / align   = center,
             title     / content = \l__nwafu_info_title_en_tl,
             title     / format  = \__nwafu_line_spread:n {0.90} \zihao { 1 } \bfseries,
             title     / bottom-skip = 35 pt,% plus 0.3 fill,
             title     / align   = center,
             info     / content     = \__nwafu_cover_info_en:,
             info     / format      = \__nwafu_line_spread:n {1.12} \zihao { -3 },
             info    / bottom-skip = 72 pt,% plus 0.3 fill,
             info     / align       = center,
             department     / content     = \l__nwafu_info_department_en_tl,
             department     / format      = \zihao { -3 },
             department     / bottom-skip = -32 pt,% plus 0.3 fill,
             department     / align       = center,
             nwafu     / content     = \c__nwafu_name_en_tl,
             nwafu     / format      = \zihao { -3 },
             nwafu     / align       = center,
           }
    }
  }
\DeclareInstance { nwafu / cover } { cover-iii-default } { cover-iii }
  {
    top-skip            = -55 pt plus 0.1 fill,
    bottom-skip            = 0 pt plus 0.5 fill,
    id     / content = \__nwafu_cover_id:,
    id     / format  =  \__nwafu_line_spread:n {1.12}\zihao { -4 },
    id     / bottom-skip = 35 pt plus 0.3 fill,
    id     / align   = center,
    name     / content = \c__nwafu_name_simp_tl
                         \clist_item:Nn \c__nwafu_thesis_type_clist { \g__nwafu_thesis_type_int },
    name     / format  = \zihao { -2 }\bfseries,
    name     / bottom-skip = 0 pt plus 0.3 fill,
    name     / align   = center,
    title     / content = \l__nwafu_info_title_tl,
    title     / format  = \zihao { 2 } \sffamily,
    title     / bottom-skip = 65 pt plus 0.3 fill,
    title     / align   = center,
    instructors     / content     = \__nwafu_cover_instructors:,
    instructors     / format      = \__nwafu_line_spread:n {0.88}\zihao { 3 }\bfseries,
    instructors     / bottom-skip = 75 pt plus 0.3 fill,
    instructors     / align       = center,
    ctitle     / content = 答辩委员会\c__nwafu_fwid_colon_tl,
    ctitle     / format  = \zihao { -3 }\bfseries,
    ctitle     / bottom-skip = -20 pt plus 0.3 fill,
    ctitle     / align   = left,
    committees     / content     = \__nwafu_cover_defensecommittees:,
    committees     / format      = \__nwafu_line_spread:n {1.12}\zihao { -3 },
    committees     / bottom-skip = 60 pt plus 0.3 fill,
    committees     / align       = center,
    date     / content     = {\bfseries{}答辩日期}\c__nwafu_fwid_colon_tl\l__nwafu_info_defensedate_tl,
    date     / format      = \zihao { -3 },
    date     / bottom-skip = 0 pt plus 0.3 fill,
    date     / align       = left,
  }
\DeclareInstance { nwafu / cover } { cover-iv-default } { cover-iv }
  {
    name-list / content = \__nwafu_cover_foundation:,
    name-list / format = \sffamily\zihao{3},
    name-list / align = center,
  }
\DeclareInstance { nwafu / cover } { cover-v-default } { cover-v }
  {
    format                                =
      \__nwafu_line_spread:n { 1.25 },
    top-skip                              = 0 pt plus 0.2 fill,
    bottom-skip                           = 0 pt plus 2.5 fill,
    originality-decl-name   / content     = \c__nwafu_name_orig_decl_tl,
    originality-decl-text   / content     = \c__nwafu_orig_decl_text_tl,
    originality-decl-sig    / content     =
      \__nwafu_cover_signature:N \c__nwafu_orig_decl_sign_tl,
    supervisor-decl-name / content     = \c__nwafu_name_super_decl_tl,
    supervisor-decl-text / content     = \c__nwafu_super_decl_text_tl,
    supervisor-decl-sig  / content     =
      \__nwafu_cover_signature:N \c__nwafu_super_decl_sign_tl,
    originality-decl-name   / format      =
      \__nwafu_line_spread:n { 1.2 } \zihao { 3 } \sffamily,
    supervisor-decl-name / format      =
      \__nwafu_line_spread:n { 1.2 } \zihao { 3 } \sffamily,
    originality-decl-text   / format      = \zihao { -4 },
    supervisor-decl-text / format      = \zihao { -4 },
    originality-decl-name   / bottom-skip = 0.25 cm,
    originality-decl-text   / bottom-skip = 0.4 cm,
    originality-decl-sig    / bottom-skip = 0.4 cm,
    supervisor-decl-name / bottom-skip = 0.25 cm,
    supervisor-decl-text / bottom-skip = 0.4 cm,
    originality-decl-name   / align       = center,
    originality-decl-sig    / align       = left,
    supervisor-decl-name / align       = center,
    supervisor-decl-sig  / align       = left,
  }
\DeclareInstance { nwafu / cover } { cover-vi-default } { cover-vi }
  {
    format                                =
      \__nwafu_line_spread:n { 1.25 },
    top-skip                              = 0 pt plus 0.2 fill,
    bottom-skip                           = 0 pt plus 2.5 fill,
    authorization-decl-name   / content     = \c__nwafu_name_auth_decl_tl,
    authorization-decl-text   / content     = \c__nwafu_auth_decl_text_tl,
    authorization-decl-sig    / content     =
      \__nwafu_cover_signature:N \c__nwafu_orig_decl_sign_tl,
    supervisor-decl-sig  / content     =
      \__nwafu_cover_signature:N \c__nwafu_super_decl_sign_tl,
    authorization-decl-name   / format      =
      \__nwafu_line_spread:n { 1.2 } \zihao { 3 } \sffamily,
    authorization-decl-text   / format      = \zihao { -4 },
    authorization-decl-name   / bottom-skip = 0.25 cm,
    authorization-decl-text   / bottom-skip = 0.8 cm,
    authorization-decl-sig    / bottom-skip = -0.50 cm,
    authorization-decl-name   / align       = center,
    authorization-decl-sig    / align       = left,
    supervisor-decl-sig  / align       = left,
  }
\DeclareInstance { nwafu / cover } { cover-vii-default } { cover-vii }
  {
    format                                =
      \__nwafu_line_spread:n { 1.25 },
    top-skip                              = 0 pt plus 0.2 fill,
    bottom-skip                           = 0 pt plus 2.5 fill,
    originality-decl-name   / content     = \c__nwafu_name_orig_decl_tl,
    originality-decl-text   / content     = \c__nwafu_orig_decl_text_tl,
    originality-decl-sig    / content     =
      \__nwafu_cover_signature:N \c__nwafu_orig_decl_sign_tl,
    authorization-decl-name / content     = \c__nwafu_name_auth_decl_tl,
    authorization-decl-text / content     = \c__nwafu_auth_decl_text_tl,
    authorization-decl-sig  / content     =
      \__nwafu_cover_signature:N \c__nwafu_orig_decl_sign_tl,
    supervisor-decl-sig  / content     =
      \__nwafu_cover_signature:N \c__nwafu_super_decl_sign_tl,
    originality-decl-name   / format      =
      \__nwafu_line_spread:n { 1.2 } \zihao { 3 } \sffamily,
    authorization-decl-name / format      =
      \__nwafu_line_spread:n { 1.2 } \zihao { 3 } \sffamily,
    originality-decl-text   / format      = \zihao { -4 } \nwafu@kai,
    authorization-decl-text / format      = \zihao { -4 } \nwafu@kai,
    originality-decl-sig   / format      = \zihao { -4 } \nwafu@kai,
    authorization-decl-sig / format      = \zihao { -4 } \nwafu@kai,
    supervisor-decl-sig / format      = \zihao { -4 } \nwafu@kai,
    originality-decl-name   / bottom-skip = 0.25 cm,
    originality-decl-text   / bottom-skip = 0.4 cm,
    originality-decl-sig    / bottom-skip = 0.4 cm,
    authorization-decl-name / bottom-skip = 0.25 cm,
    authorization-decl-text / bottom-skip = 0.4 cm,
    authorization-decl-sig    / bottom-skip = -0.5 cm,
    originality-decl-name   / align       = center,
    originality-decl-sig    / align       = left,
    authorization-decl-name / align       = center,
    authorization-decl-sig  / align       = left,
    supervisor-decl-sig  / align       = left,
  }
\bool_new:N \l__nwafu_auto_make_cover_bool
\keys_define:nn { nwafu / style }
  {
    auto-make-cover .bool_set:N = \l__nwafu_auto_make_cover_bool,
    auto-make-cover .default:n  = true
  }
\NewDocumentCommand \makecovers { }
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
        \begin{titlepage}
          \makecoveri
          \newpage
          \makecoverii
          \newpage
          \makecoveriii
          \newpage
          \makecoveriv
          \newpage
          \makecoverv
          \newpage
          \makecovervi
        \end{titlepage}
      }{
        \begin{titlepage}
          \makecoveri
          \cleardoublepage
          \makecovervii
        \end{titlepage}
      }
  }
\tl_new:c { l__nwafu_abstract_file_tl }
\tl_new:c { l__nwafu_abstract_file_en_tl }
\clist_new:N \l__nwafu_abstract_keywords_clist
\clist_new:N \l__nwafu_abstract_keywords_en_clist
\tl_new:c { l__nwafu_notation_file_tl }
\keys_define:nn { nwafu / abstract }
  {
    abstractfile  .tl_set:N = \l__nwafu_abstract_file_tl,
    abstractfile* .tl_set:N = \l__nwafu_abstract_file_en_tl,
    keywords  .clist_set:N = \l__nwafu_abstract_keywords_clist,
    keywords* .clist_set:N = \l__nwafu_abstract_keywords_en_clist,
    notationfile  .tl_set:N  = \l__nwafu_notation_file_tl,
    notationfile  .default:n = {},
  }
\NewDocumentCommand \makefront { }
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
        \frontmatter
        \tl_if_empty:NF \l__nwafu_abstract_file_tl
          {
            \begin{abstract}
              \file_input:V \l__nwafu_abstract_file_tl
            \end{abstract}
          }
        \tl_if_empty:NF \l__nwafu_abstract_file_en_tl
          {
            \begin{abstract*}
              \file_input:V \l__nwafu_abstract_file_en_tl
            \end{abstract*}
          }
        \cleardoublepage
        \pagenumbering{Roman}
        \tableofcontents
        % \frontmatter
        \tl_if_empty:NF \l__nwafu_notation_file_tl
          {
            \cleardoublepage
            \pagenumbering{Roman}
            \file_input:V \l__nwafu_notation_file_tl
          }
      }{
        \cleardoublepage
        \thispagestyle { empty }
        \tl_if_empty:NF \l__nwafu_abstract_file_tl
          {
            \begin{abstract}
              \__nwafu_get_text_width:Nn \l__nwafu_tmpa_dim {\c__nwafu_name_keywords_tl}
              \group_begin:
                \par \indent
                {\sffamily\zihao{-4}
                \__nwafu_spread_box:Vn \l__nwafu_tmpa_dim {\c__nwafu_name_abstract_tl}
                \c__nwafu_fwid_colon_tl}
                \normalfont
                \file_input:V \l__nwafu_abstract_file_tl
              \group_end:
            \end{abstract}
          }
        \clearpage
        \thispagestyle { empty }
        \tl_if_empty:NF \l__nwafu_abstract_file_en_tl
          {
            \begin{abstract*}
              \group_begin:
                \par \indent
                {\bfseries\zihao{-4}
                \c__nwafu_name_abstract_en_tl : ~}
                \normalfont
                \file_input:V \l__nwafu_abstract_file_en_tl
              \group_end:
            \end{abstract*}
          }
        \frontmatter
        \tableofcontents
      }
  }
\AfterEndPreamble
  {
    \bool_if:NT \l__nwafu_auto_make_cover_bool
      {
        \makecovers
        \makefront
      }
  }
\keys_set:nn { ctex }
  {
    contentsname   = \c__nwafu_name_toc_tl,
    listfigurename = \c__nwafu_name_lof_tl,
    listtablename  = \c__nwafu_name_lot_tl,
  }
\clist_map_inline:nn
  {
      chapter, section, subsection, figure, table
  }
  {
    \clist_map_inline:nn
      {
        format, indent, rule, numsep
      }
      {
        \tl_new:c {__nwafu_toc_ #1 _ ##1 _ tl}
      }
  }
\clist_map_inline:nn
  {
      chapter, section, subsection, figure, table
  }
  { \dim_new:c { __nwafu_toc_ #1 _offset_dim } }
\bool_new:N \__nwafu_toc_line_align_bool
\bool_new:N \__nwafu_titletoc_hang_fix_bool
\tl_set:Nn \__nwafu_toc_chapter_format_tl { \addvspace{1pt}\nwafu@hei \bfseries }
\tl_set:Nn \__nwafu_toc_chapter_indent_tl {0pc}
\tl_set:Nn \__nwafu_toc_chapter_rule_tl {\tocrule{$\cdot$}}
\tl_set:Nn \__nwafu_toc_chapter_numsep_tl {0.5\ccwd}
\dim_set:Nn \__nwafu_toc_chapter_offset_dim
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          0pc
      }{
          1pt
      }
  }
\tl_set:Nn \__nwafu_toc_section_format_tl
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          \addvspace{0pt}
      }{
          \addvspace{1pt}\small
      }
  }
\tl_set:Nn \__nwafu_toc_section_indent_tl { \ccwd }
\tl_set:Nn \__nwafu_toc_section_rule_tl {\tocrule{$\cdot$}}
\tl_set:Nn \__nwafu_toc_section_numsep_tl {0.5\ccwd}
\dim_set:Nn \__nwafu_toc_section_offset_dim
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          0pc
      }{
          1pt
      }
  }
\tl_set:Nn \__nwafu_toc_subsection_format_tl
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          \addvspace{0pt}
      }{
          \addvspace{1pt}\small
      }
  }
\tl_set:Nn \__nwafu_toc_subsection_indent_tl {2.0\ccwd}
\tl_set:Nn \__nwafu_toc_subsection_rule_tl {\tocrule{$\cdot$}}
\tl_set:Nn \__nwafu_toc_subsection_numsep_tl {0.5\ccwd}
\dim_set:Nn \__nwafu_toc_subsection_offset_dim
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          0pc
      }{
          1pt
      }
  }
\tl_set:Nn \__nwafu_toc_figure_format_tl
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          \addvspace{0pt}
      }{
          \addvspace{1pt}
      }
  }
\tl_set:Nn \__nwafu_toc_figure_indent_tl {0pc}
\tl_set:Nn \__nwafu_toc_figure_rule_tl {\tocrule{$\cdot$}}
\tl_set:Nn \__nwafu_toc_figure_numsep_tl {0.5\ccwd}
\dim_set:Nn \__nwafu_toc_figure_offset_dim
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          0pc
      }{
          1pt
      }
  }
\tl_set:Nn \__nwafu_toc_table_format_tl
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          \addvspace{0pt}
      }{
          \addvspace{1pt}
      }
  }
\tl_set:Nn \__nwafu_toc_table_indent_tl {0pc}
\tl_set:Nn \__nwafu_toc_table_rule_tl {\tocrule{$\cdot$}}
\tl_set:Nn \__nwafu_toc_table_numsep_tl {0.5\ccwd}
\dim_set:Nn \__nwafu_toc_table_offset_dim
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
          0pc
      }{
          1pt
      }
  }
\bool_set_false:N \__nwafu_toc_line_align_bool
\bool_set_false:N \__nwafu_titletoc_hang_fix_bool
\clist_map_inline:nn
  {
      chapter, section, subsection, figure, table
  }
  {
    \titlecontents{#1}
      [ \use:c { __nwafu_toc_#1_indent_tl } ]
      { \use:c { __nwafu_toc_#1_format_tl } }
      {
        \bool_if:NT \__nwafu_titletoc_hang_fix_bool
          {
            \contentspush
              {
                \thecontentslabel
                \hspace{\use:c { __nwafu_toc_#1_numsep_tl }}
              }
          }
      }
      {}
      {\use:c { __nwafu_toc_#1_rule_tl }}
      [\addvspace{\use:c{ __nwafu_toc_ #1 _offset_dim }}]
  }

\cs_new:Npn \NWAFUNumberLine #1
  {
    \CTEXifname
      {
        \use:c { CTEXthe#1 }
        \hspace{\use:c { __nwafu_toc_#1_numsep_tl }}
      }{}
  }

\bool_if:NTF \__nwafu_titletoc_hang_fix_bool
  {
    \keys_set:nn { ctex }
      {
        chapter/tocline     = \CTEXnumberline{#1}#2,
        section/tocline     = \CTEXnumberline{#1}#2,
        subsection/tocline  = \CTEXnumberline{#1}#2
      }
  }{
    \keys_set:nn { ctex }
      {
        chapter/tocline     = \NWAFUNumberLine{#1}#2,
        section/tocline     = \NWAFUNumberLine{#1}#2,
        subsection/tocline  = \NWAFUNumberLine{#1}#2
      }
 }
\NewDocumentCommand{\tocrule}{sO{0.3pc}D(){1.2}mO{}}
  {
    \small\normalfont
    \titlerule*[#2]{\scalebox{#3}{#4}}#5
    \IfBooleanTF{#1}
      {\thecontentspage}
      {
        \bool_if:NTF \__nwafu_toc_line_align_bool
          {\contentspage}{\thecontentspage}
      }
  }
\__nwafu_patch_cmd:Nnn \tableofcontents
  {
    \chapter*{\contentsname
      \@mkboth{\MakeUppercase\contentsname}
              {\MakeUppercase\contentsname}}
  }
  { \__nwafu_chapter_no_toc:V \contentsname }
\__nwafu_patch_cmd:Nnn \listoffigures
  {
    \chapter*{\listfigurename}
    \@mkboth{\MakeUppercase\listfigurename}
            {\MakeUppercase\listfigurename}
  }
  { \__nwafu_chapter:V \listfigurename }
\__nwafu_patch_cmd:Nnn \listoftables
  {
    \chapter*{\listtablename}
    \@mkboth{\MakeUppercase\listtablename}
            {\MakeUppercase\listtablename}
  }
  { \__nwafu_chapter:V \listtablename }
\NewDocumentEnvironment { abstract  } { }
  { \__nwafu_abstract_begin:    } { \__nwafu_abstract_end:      }
\NewDocumentEnvironment { abstract* } { }
  { \__nwafu_abstract_en_begin: } { \__nwafu_abstract_en_end:   }
\cs_new_protected:Npn \__nwafu_abstract_begin:
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
        \__nwafu_chapter:V \c__nwafu_name_abstract_tl
      }{
        \par \mode_leave_vertical: \par
        \begin{center}\nwafu@hei\bfseries\zihao{3}\l__nwafu_info_title_tl\end{center}
      }
  }
\cs_new_protected:Npn \__nwafu_abstract_en_begin:
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
        \__nwafu_chapter:n \c__nwafu_name_abstract_en_tl
      }{
        \par \mode_leave_vertical: \par
        \begin{center}\bfseries\zihao{3}\l__nwafu_info_title_en_tl\end{center}
      }
  }
\cs_new_protected:Npn \__nwafu_abstract_end:
  {
    \__nwafu_keywords:nNn
      { \sffamily \zihao{-4} \c__nwafu_name_keywords_tl \c__nwafu_fwid_colon_tl  }
      \l__nwafu_abstract_keywords_clist { ; ~}
  }
\cs_new_protected:Npn \__nwafu_abstract_en_end:
  {
    \__nwafu_keywords:nNn
      { \bfseries \c__nwafu_name_keywords_en_tl : ~ }
      \l__nwafu_abstract_keywords_en_clist { ; ~ }
  }
\cs_new_protected:Npn \__nwafu_keywords:nNn #1#2#3
  {
    \int_compare:nNnTF { \g__nwafu_thesis_type_int } < { 3 }
      {
        \par \mode_leave_vertical: \par \noindent
        \__nwafu_get_text_width:Nn \l__nwafu_tmpa_dim {#1}
        \group_begin: \MakeUppercase{#1} \group_end:
        \parbox [t] { \dim_eval:n { \textwidth - \l__nwafu_tmpa_dim } }
          {
            \clist_use:Nn #2 {#3} \par
            \cs_gset:Npx \__nwafu_keywords_prevdepth: { \dim_use:N \tex_prevdepth:D }
          }
      }{
        \par \mode_leave_vertical: \par
        \__nwafu_get_text_width:Nn \l__nwafu_tmpa_dim {#1}
        \group_begin: #1 \group_end:
        \clist_use:Nn #2 {#3} \par
        \cs_gset:Npx \__nwafu_keywords_prevdepth: { \dim_use:N \tex_prevdepth:D }
      }
  }
\NewDocumentEnvironment { notation } { O { l p { 7.5 cm } } }
  {
    \__nwafu_notation_begin:
    \group_begin:
      \__nwafu_notation_long_table_setup:
      \longtable {#1}
  }
  {
      \endlongtable
    \group_end:
  }
\cs_new_protected:Npn \__nwafu_notation_begin:
  {
    \__nwafu_chapter_no_toc:V \c__nwafu_name_notation_tl
  }
\cs_new_protected:Npn \__nwafu_notation_long_table_setup:
  {
    \dim_set_eq:NN \LTpre  \c_zero_dim
    \dim_set_eq:NN \LTpost \c_zero_dim
  }
\NewDocumentEnvironment { acknowledgement } { }
  {
    \group_begin:
    \__nwafu_chapter:V \c__nwafu_name_ack_tl
  }
  {
    \group_end:
  }
\NewDocumentEnvironment { resume } { }
  {
    \group_begin:
    \__nwafu_chapter:V \c__nwafu_name_resume_tl
  }
  {
    \group_end:
  }
\NewDocumentCommand{ \resumitem }{ O{ 学习经历 } }
  {%
    \vspace{24bp}{\zihao{-4}\nwafu@hei\bfseries\centerline{#1}}\par\vspace{6bp}
  }
\NewDocumentCommand{ \researchitem }{ O{ 发表的学术论文 } }
  {%
    \vspace{32bp}{\zihao{-4}\nwafu@hei\bfseries\centerline{#1}}\par\vspace{14bp}
  }
\newlist{publications}{enumerate}{1}
\setlist[publications]{label=[\arabic*],align=left,nosep,itemsep=6bp,
  leftmargin=10mm,before=\zihao{-4},resume}
\newlist{achievements}{enumerate}{1}
\setlist[achievements]{label=[\arabic*],align=left,nosep,itemsep=6bp,
  leftmargin=10mm,before=\zihao{-4}}
\def\publicationskip{\bigskip\bigskip}
\clist_new:N \l__nwafu_bib_resource_clist
\keys_define:nn { nwafu / style }
  {
    bib-resource .clist_set:N = \l__nwafu_bib_resource_clist
  }
\__nwafu_at_end_preamble:n
  {
    \__nwafu_biblatex_pre_setup:
    \RequirePackage { biblatex }
    \__nwafu_biblatex_post_setup:
  }
\cs_new_protected:Npn \__nwafu_biblatex_pre_setup:
  {
    \__nwafu_pass_options_to_biblatex:n { style = gb7714-2015ay }
    \__nwafu_pass_options_to_biblatex:n { backend = biber, sortlocale=zh__pinyin,
        gbtype=false, maxbibnames=99, maxcitenames=2, mincitenames=1,
        gbpub=false, uniquename=false, uniquelist=false, gbnamefmt=lowercase,
        doi=false, isbn=false, gbfieldtype=true, gbpunctin=false,
      }
  }
\cs_new_protected:Npn \__nwafu_biblatex_post_setup:
  {
    \__nwafu_biblatex_misc:
    \clist_map_function:NN \l__nwafu_bib_resource_clist \addbibresource
    \__nwafu_biblatex_allow_url_break:
    \defbibheading { bibliography } [ \bibname ] { \__nwafu_chapter:n {##1} }
  }
\cs_new_protected:Npn \__nwafu_pass_options_to_biblatex:n #1
  { \PassOptionsToPackage {#1} { biblatex } }
\cs_new:Npn \__nwafu_biblatex_misc:
  {
    \DefineBibliographyExtras{english}{\renewcommand*{\bibrangedash}{$\sim$}}
    \newcommand\nwafu@font@bib{\__nwafu_line_spread:n {1.3}\zihao{5}}
    \renewcommand{\bibfont}{\nwafu@font@bib}
    \DeclareFieldFormat[article]{journaltitle}{\iffieldequalstr{userd}{chinese}{##1}{\textit{##1}}\isdot}
    \renewcommand{\postnotedelim}{\addcolon\space}
    \DeclareFieldFormat{postnote}{##1}
    \DeclareDelimFormat[cite,parencite,pagescite]{nameyeardelim}{\space}
    \DeclareDelimFormat[textcite]{nameyeardelim}{\space}
    \DeclareDelimFormat[bib,biblist]{nameyeardelim}{\addperiod\space}
    \renewcommand*{\finentrypunct}{}
    \DefineBibliographyStrings{english}{
        andincitecn = {和},
        andincite   = {and},
        mathesiscn={[硕士学位论文]},
        phdthesiscn={[博士学位论文]},
        in={In:\addspace},
        incn={见:\addspace},
      }
    \DeclareDelimFormat{finalnamedelim}{%
        \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
        \edef\userfieldabcde{userd}%
        \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
        \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
        \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
        \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
        \ifcase\value{gbcitelocalcase}%
          \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}%
          \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
          \iffieldequalstr{\userfieldabcde}{japnese}{\bibstring{andjp}}{}%
          \iffieldequalstr{\userfieldabcde}{english}{\addspace\bibstring{andincite}\addspace}{}%
          \iffieldequalstr{\userfieldabcde}{french}{\addspace\bibstring{and}\addspace}{}%
          \iffieldequalstr{\userfieldabcde}{russian}{\addspace\bibstring{and}\addspace}{}%
        \or%
        \bibstring{andincitecn}%
        \or%
        \addspace\bibstring{andincite}\addspace%
        \fi
      }
    \DeclareDelimFormat{strandothersdelim}{%
        \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
        %\addspace%
        \edef\userfieldabcde{userd}%
        \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
        \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
        \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
        \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
        \ifcase\value{gbcitelocalcase}%
          \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andothersincitecn}}{}%
          \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andotherskr}}{}%
          \iffieldequalstr{\userfieldabcde}{japnese}{\bibstring{andothersjp}}{}%
          \iffieldequalstr{\userfieldabcde}{english}{\bibstring{andothersincite}}{}%
          \iffieldequalstr{\userfieldabcde}{french}{\bibstring{andothers}}{}%
          \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{andothers}}{}%
        \or%
        \bibstring{andothersincitecn}%
        \or%
        \bibstring{andothersincite}%
        \fi
      }
    \AtEveryCitekey{%
        \iffieldequalstr{userf}{chinese}{\renewcommand*{\andothersdelim}{}}%\addthinspace
        {\renewcommand*{\andothersdelim}{\addspace}}%
      }
    \renewbibmacro*{cite:extradate}{%
        \iffieldundef{extradate} {}
        {\printtext[bibhyperref]{\printlabeldateextra}}%\printfield{extradate}
      }
    \renewbibmacro*{date+extradate}{%
        \iffieldundef{labelyear}{}%
        {\ifboolexpr{%
           test {\ifentrytype{patent}}
           or
           (test {\ifentrytype{newspaper}} )%
         }%
         {\printtext{\blx@isodate{}{}}}%
         {\printtext{%
             \iflabeldateisdate
             {\printdateextra}
             {\printlabeldateextra}
          }
         }%
        }%
      }
    \newbibmacro*{origdate+extradate}{%
        \printtext{\printorigdate}%
      }
    \renewbibmacro*{bytranslator+others}{%
        \ifnameundef{translator}
          {}
          {\printnames[bytranslator]{translator}%
           \usebibmacro{bytranslator+othersstrg}%“译”的位置换到下面来，即放到译者后面。
           \newunit
          }%
        \usebibmacro{withothers}%
        \ifboolexpr{%
          test {\iffieldundef{origyear}} or test {\ifnameundef{translator}}%%
        }{}{\printtext{\printdate}}%
      }
    \renewbibmacro*{url+urldate}{%
        \usebibmacro{url}%
        \iffieldundef{urlyear}%
        {}
        {\usebibmacro{urldate}
        }
      }
    \DeclareFieldFormat{addnumflag}{%
        \ifentrytype{newspaper}
        {\setunit{\addcomma\addspace}\printtext{##1}}
        {\nobreak\printtext{(}\nobreak ##1\nobreak\printtext{)}}
      }
    \renewbibmacro*{patenttitle}{%原输出来自biblatex.def文件
        \ifboolexpr{%
          test{\iffieldundef{title}}%
          and%
          test{\iffieldundef{subtitle}}%
        }%
        {}%
        {
          \printtext[title]{\bibtitlefont%
          \printfield[titlecase]{title}%
          \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断，解决不判断多一个点的问题
          {}
          {
            \setunit{\subtitlepunct}%
            \printfield[titlecase]{subtitle}}%
            \iffieldundef{titleaddon}{}%判断一下titleaddon，否则直接加可能多一个空格
            {\setunit{\subtitlepunct}\printfield{titleaddon}}%
            \setunit{\adddot\addspace}\printfield{number}%写专利号
            \iftoggle{bbx:gbtype}{\printfield[gbtypeflag]{usera}}{}%
          }%
        }%
      }
    \renewbibmacro*{name:andothers}{%
        \ifboolexpr{
          test {\ifnumequal{\value{listcount}}{\value{liststop}}}
          and
          test \ifmorenames
        }{\ifnumgreater{\value{liststop}}{1}%
            {\finalandcomma}%
            {}%
            \printdelim{andothersdelim}\printdelim{strandothersdelim}%
        }{%当是译者的时候需要特殊处理
          \ifcurrentname{translator}{\addcomma}{}%
        }
      }
    \DeclareFieldFormat{edition}{%
        \testCJKfirst{userd}%
        \iftoggle{ifCJKforgbt}%
        {\ifinteger{##1}%
          {\printtext{\bibstring{serialcn}\zhnumber{##1}\str@edition}}%
          {##1\isdot}
        }%
        {\ifinteger{##1}%
          {\mkbibordedition{##1}~\bibstring{edition}}%
          {##1\isdot}
        }
      }
    \renewbibmacro*{author}{%
        \ifboolexpr{
          test \ifuseauthor
          and
          not test {\ifnameundef{author}}
        }{\usebibmacro{bbx:dashcheck}
           {\printnames{author}\setunit{\printdelim{nameyeardelim}}%把标点也带上
           }{\usebibmacro{bbx:savehash}%
             \printnames{author}%
             \iffieldundef{authortype}
               {\setunit{\printdelim{nameyeardelim}}}
               {\setunit{\printdelim{authortypedelim}}}
           }%
           \iffieldundef{authortype}
             {}
             {\usebibmacro{authorstrg}%
              \setunit{\printdelim{nameyeardelim}}
             }
        }%
        {\global\undef\bbx@lasthash
         \usebibmacro{labeltitle}%
         \setunit*{\printdelim{nonameyeardelim}}
        }%
        \ifboolexpr{%
          test {\iffieldundef{origyear}} or test {\ifnameundef{translator}}%
        }{\usebibmacro{date+extradate}}%
        {\usebibmacro{origdate+extradate}}%
      }
    \DeclareBibliographyDriver{book}{%源来自standard.bbx文件
        \usebibmacro{bibindex}%
        \usebibmacro{begentry}%
        \usebibmacro{author/editor+others/translator+others}%
        \ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
        \usebibmacro{maintitle+title}%
        \iftoggle{bbx:gbstrict}{}{%
          \newunit%
          \printlist{language}%
          \newunit\newblock%
          \usebibmacro{byauthor}%
          \newunit\newblock%
        }%
        \newunit%
        \printfield{edition}%
        \newunit%
        \usebibmacro{byeditor+others}%
        \newunit\newblock%
        \iftoggle{bbx:gbstrict}{}{%
          \iffieldundef{maintitle}%
          {%
            \printfield{volume}%
            \printfield{part}%
          }%
          {}%
          \newunit%
          \printfield{volumes}%
          \newunit\newblock%
          \usebibmacro{series+number}%
        }%
        \newunit\newblock%
        \usebibmacro{publisher+location+date}%
        \usebibmacro{chapter+pages}%
        \iffieldundef{url}{}{%当没有网址时也不输出
          \usebibmacro{modifydate}%带括号的修改或更新日期，
        }%
        \usebibmacro{doi+eprint+url}%从下面移动到上面来，因为gbt2015的url需直接放在页码后面。
        \newunit\newblock%
        \printfield{pagetotal}%
        \newunit\newblock%
        \iftoggle{bbx:isbn}%
          {\printfield{isbn}}
          {}%
        \newunit\newblock%
        \usebibmacro{addendum+pubstate}%
        \setunit{\bibpagerefpunct}\newblock
        \usebibmacro{pageref}%
        \newunit\newblock%
        \iftoggle{bbx:related}%
          {\usebibmacro{related:init}%
           \usebibmacro{related}%
          }{}%
        \usebibmacro{finentry}
      }
    \DeclareBibliographyDriver{online}{%源来自standard.BBX
        \usebibmacro{bibindex}%
        \usebibmacro{begentry}%
        \usebibmacro{author/editor+others/translator+others}%
        \ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
        \usebibmacro{title}%
        \iftoggle{bbx:gbstrict}{}{%
          \newunit%
          \printlist{language}%
          \newunit\newblock
          \usebibmacro{byauthor}%
          \newunit\newblock
          \usebibmacro{byeditor+others}%
          \newunit\newblock
          \printfield{note}
        }%
        \newunit
        \printfield{version}%
        \newunit\newblock
        \printlist{institution}%
        \newunit\newblock
        \ifboolexpr{%
          test{\iffieldundef{day}} and test{\iffieldundef{endday}} and test{\iffieldundef{eventday}}%
        }{\usebibmacro{date}}%
        \usebibmacro{url+urldate}%从下面移上来
        \newunit\newblock
        \iftoggle{bbx:eprint}
          {\usebibmacro{eprint}}
          {}%
        \newunit\newblock
        \usebibmacro{addendum+pubstate}%
        \setunit{\bibpagerefpunct}\newblock
        \usebibmacro{pageref}%
        \newunit\newblock
        \iftoggle{bbx:related}
          {\usebibmacro{related:init}%
           \usebibmacro{related}}
          {}%
        \usebibmacro{finentry}
      }
    \DeclareBibliographyDriver{patent}{%源来自standard.BBX
        \usebibmacro{bibindex}%
        \usebibmacro{begentry}%
        \usebibmacro{author}%
        \ifnameundef{author}{}{\setunit{\labelnamepunct}\newblock}%这一段用于去除作者不存在时多出的标点
        \usebibmacro{patenttitle}%给出专利专用的标题输出
        \iftoggle{bbx:gbstrict}{}{%
          \newunit%
          \printlist{language}%
          \newunit\newblock
          \usebibmacro{byauthor}
        }%
        \newunit\newblock
        \printfield{type}%
        \setunit*{\addspace}%
        \iflistundef{location}
          {}
          {\setunit*{\addspace}%
           \printtext{%[parens]
           \printlist[][-\value{listtotal}]{location}}
          }%
        \newunit\newblock
        \usebibmacro{byholder}%
        \newunit\newblock
        \printfield{note}%
        \newunit\newblock
        \usebibmacro{doi+eprint+url}%
        \newunit\newblock
        \usebibmacro{addendum+pubstate}%
        \setunit{\bibpagerefpunct}\newblock
        \usebibmacro{pageref}%
        \newunit\newblock
        \iftoggle{bbx:related}
          {\usebibmacro{related:init}%
           \usebibmacro{related}
          }
          {}%
        \usebibmacro{finentry}
      }
    \setlength{\bibitemsep}{2pt}
    \setlength{\bibnamesep}{0ex}
    \setlength{\bibinitsep}{0ex}
    \setlength{\bibitemindent}{-2\ccwd}% bibitemindent表示一条文献中第一行相对后面各行的缩进
    \setlength{\bibhang}{2\ccwd} % 表示的各行起始位置到页边的距离
  }
\cs_new:Npn \__nwafu_biblatex_allow_url_break:
  {
    \int_set_eq:NN \c@biburlucpenalty  \c_one_int
    \int_set_eq:NN \c@biburlnumpenalty \c_one_int
    \int_set_eq:NN \c@biburllcpenalty  \c_one_int
  }
\cs_new:Npn \__nwafu_set_cite_style_author_year:
  {
    \NAT@numbersfalse
    \cs_set_eq:NN \NAT@open  \c__nwafu_fwid_left_paren_tl
    \cs_set_eq:NN \NAT@close \c__nwafu_fwid_right_paren_tl
    \cs_set_eq:NN \NAT@sep   \c__nwafu_fwid_semicolon_tl
    \cs_set_eq:NN \NAT@aysep \c__nwafu_fwid_comma_tl
    \cs_set_eq:NN \NAT@yrsep \c__nwafu_ideo_comma_tl
  }
\skip_set:Nn \parskip { 0pt plus 2pt minus 1pt }
\skip_set:Nn \intextsep { 14pt plus 2pt minus 2pt }
\skip_set:Nn \textfloatsep { 16pt plus 2pt minus 4pt }
\allowdisplaybreaks[4]
\ctex_after_end_preamble:n
  {
    \skip_set:Nn \abovedisplayskip { 5pt plus 1pt minus 1pt }
    \skip_set:Nn \belowdisplayskip { 5pt plus 1pt minus 1pt }
    \skip_set:Nn \abovedisplayshortskip { 0pt }
    \skip_set:Nn \belowdisplayshortskip { 5pt plus 1pt minus 1pt }
  }
\cs_new_protected:Npn \__nwafu_enumitem_label_set:nn #1#2
  { \SetEnumitemValue{label}{#1}{#2} }
\clist_map_inline:nn
  {
    { bullet   } { \textbullet                      },
    { endash   } { \normalfont\bfseries\textendash  },
    { asterisk } { \textasteriskcentered            },
    { arabic   } { \bool_if:NTF \l__nwafu_withchap_bool
                      { \arabic*. }{ (\arabic*) }   },
    { alph     } { \bool_if:NTF \l__nwafu_withchap_bool
                      { \alph*. }{ (\alph*) }       },
    { roman    } { \bool_if:NTF \l__nwafu_withchap_bool
                      { \roman*. }{ (\roman*) }     },
    { alph     } { (\alph*)                         },
    { roman    } { \roman*.                         },
    { outline  } { \upshape\ding{111}               }
  }
  { \__nwafu_enumitem_label_set:nn #1 }
\SetEnumitemValue{font}{sf}{\normalfont\sffamily}
\SetEnumitemValue{ref}{enumii}{\arabic{enumi}.\alph*}
\SetEnumitemValue{ref}{enumiii}{\arabic{enumi}.\alph{enumii}.\roman*}
\setlist
  {
    nosep,
    leftmargin = *,
    labelindent = \dimexpr\parindent+0pt\relax,
    wide=\parindent,
  }
\setlist[itemize,1]{label = bullet}
\setlist[itemize,2]{label = endash}
\setlist[itemize,3]{label = asterisk}
\setlist[enumerate,1]{label = arabic,ref = \arabic*}
\setlist[enumerate,2]{label = alph,ref = enumii}
\setlist[enumerate,3]{label = roman,ref = enumiii,labelwidth = *}
\setlist[description]{font = sf,labelwidth = *,leftmargin = 2\ccwd}
\NewDocumentCommand \hypersetup { m }
  { \nwafu_hyperref_setup:n {#1} }
\cs_new_protected:Npn \nwafu_hyperref_setup:n #1
  { \clist_gput_right:Nn \g__nwafu_to_hyperref_clist {#1} }
\cs_new:Npn \__nwafu_set_hyperlink_color_key:n #1
  {
    hyperlink-color / \clist_item:nn {#1} {1} .code:n =
      {
        \__nwafu_define_hyperlink_color:nnn
          { \clist_item:nn {#1} {2} }
          { \clist_item:nn {#1} {3} }
          { \clist_item:nn {#1} {4} }
        \nwafu_hyperref_setup:n
          {
            linkcolor = nwafu@link, linkbordercolor = nwafu@link,
            urlcolor  = nwafu@url,  urlbordercolor  = nwafu@url,
            citecolor = nwafu@cite, citebordercolor = nwafu@cite
          }
      },
  }
\cs_new_protected:Npn \__nwafu_define_hyperlink_color:nnn #1#2#3
  {
    \definecolorset { HTML } { nwafu@ } { }
      { link, #1; url, #2; cite, #3 }
  }
\keys_define:nx { nwafu / style }
  {
    hyperlink .choice:,
    hyperlink .value_required:n = true,
    hyperlink / border .code:n = { },
    hyperlink / color  .code:n =
      { \nwafu_hyperref_setup:n { colorlinks = true } },
    hyperlink / none   .code:n =
      { \nwafu_hyperref_setup:n { hidelinks  = true } },
    hyperlink-color .choice:,
    hyperlink-color .value_required:n = true,
    \clist_map_function:nN
      {
        { autumn,    D70000, D75F00, AF8700 },
        { business,  D14542, 295497, 1F6E43 },
        { classic,   FF0000, 0000FF, 00FF00 },
        { default,   990000, 0000B2, 007F00 },
        { elegant,   961212, C31818, 9B764F },
        { fantasy,   FF4A19, FF3F94, 934BA1 },
        { material,  E91E63, 009688, 4CAF50 },
        { science,   CA0619, 389F9D, FF8920 },
        { summer,    00AFAF, 5F5FAF, 5F8700 },
        { graylevel, 616161, 616161, 616161 },
        { prl,       2D3092, 2D3092, 2D3092 }
      }
      \__nwafu_set_hyperlink_color_key:n
  }
\cs_new:Npn \nwafu_allow_url_break:
  {
    \cs_new:Npn \__nwafu_add_url_break_points:
      { \tl_map_function:NN \c__nwafu_url_break_points_tl \do }
    \__nwafu_appto_cmd:Nn \UrlBreaks
      { \UrlOrds \__nwafu_add_url_break_points: }
  }
\tl_const:Nn \c__nwafu_url_break_points_tl
  {
    abcdefghijklmnopqrstuvwxyz
    ABCDEFGHIJKLMNOPQRSTUVWXYZ
    0123456789
  }
\ctex_at_end_preamble:n
  {
    \RequirePackage { hyperref }
    \hypersetup
      {
        bookmarksnumbered = true,
        psdextra          = true,
        unicode           = true,
        pdftitle    = \l__nwafu_info_title_tl,
        pdfauthor   = \l__nwafu_info_author_tl,
        pdfkeywords = \l__nwafu_abstract_keywords_clist,
        pdfcreator  = \c__nwafu_name_pdf_creator_tl
      }
    \exp_args:NV \hypersetup \g__nwafu_to_hyperref_clist
    \nwafu_allow_url_break:
    \BiblatexManualHyperrefOn
  }
\ctex_at_end_package:nn { hyperref }
  {
    \pdfstringdefDisableCommands
      {
        \cs_set_eq:NN \nwafu@kai \prg_do_nothing:
        \cs_set_eq:NN \quad    \c_space_tl
        \cs_set_eq:NN \qquad   \c_space_tl
      }
  }
\labelformat{part}{\CTEXthepart}
\labelformat{chapter}{\CTEXthechapter}
\labelformat{figure}{\figurename~#1}
\labelformat{table}{\tablename~#1}
\def\figureautorefname{图}
\def\tableautorefname{表}
\keys_set_known:nn { ctex }
  {
    figurename          = 图,
    tablename           = 表,
  }
\labelformat{equation}{式（#1）}
\labelformat{section}{节 #1}
\labelformat{subsection}{小节 #1}
\keys_define:nn { nwafu }
  {
    abstract  .meta:nn = { nwafu / abstract } {#1},
    info      .meta:nn = { nwafu / info     } {#1},
    style     .meta:nn = { nwafu / style    } {#1}
  }
\keys_set:nn { nwafu }
  {
    style   / font-size       = -4,
    style   / fullwidth-stop  = false,
    style   / auto-make-cover = true,
    style   / logo            = { logo/nwafu-bar.pdf },
    style   / logo-size       = { 0.65 \textwidth },
    style   / hyperlink       = none,
    style   / hyperlink-color = default,
    info    / degree          = academic,
    info    / secret-level    = none,
    info    / school-id       = { 10712 },
    info    / date            = { \zhtoday },
    theorem / header-font     = { \sffamily },
    theorem / body-font       = { \nwafu@kai },
    theorem / counter         = { chapter }
  }
\NewDocumentCommand \nwafuset { m }
  { \keys_set:nn { nwafu } {#1} }
\newtheorem* { proof       } { \c__nwafu_name_proof_tl      }
\newtheorem  { axiom       } { \c__nwafu_name_axiom_tl      }
\newtheorem  { corollary   } { \c__nwafu_name_corollary_tl  }
\newtheorem  { definition  } { \c__nwafu_name_definition_tl }
\newtheorem  { example     } { \c__nwafu_name_example_tl    }
\newtheorem  { lemma       } { \c__nwafu_name_lemma_tl      }
\newtheorem  { theorem     } { \c__nwafu_name_theorem_tl    }
\endinput
%%
%% End of file `nwafuthesis.cls'.
