Skip to content
Snippets Groups Projects
njuthesis.dtx 80.4 KiB
Newer Older
  SupervisorATitle  .tl_set:N     =   \l_@@_info_supv_a_title_tl,
  SupervisorATitle* .tl_set:N     =   \l_@@_info_supv_a_title_en_tl,
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\keys_define:nn { nju / info }
{
  SupervisorB       .tl_set:N     =   \l_@@_info_supv_b_tl,
  SupervisorB*      .tl_set:N     =   \l_@@_info_supv_b_en_tl,
  SupervisorBTitle  .tl_set:N     =   \l_@@_info_supv_b_title_tl,
  SupervisorBTitle* .tl_set:N     =   \l_@@_info_supv_b_title_en_tl,
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\keys_define:nn { nju / info }
{
  SubmitDate        .tl_set:N     =   \l_@@_submit_date_tl,
  SubmitDate*       .tl_set:N     =   \l_@@_submit_date_en_tl,
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\keys_define:nn { nju / info }
{
  DefendDate        .tl_set:N     =   \l_@@_defend_date_tl,
  ReviewerChairman  .tl_set:N     =   \l_@@_info_chairman_tl,
  ReviewerA         .tl_set:N     =   \l_@@_info_reviewer_a_tl,
  ReviewerB         .tl_set:N     =   \l_@@_info_reviewer_b_tl,
  ReviewerC         .tl_set:N     =   \l_@@_info_reviewer_c_tl,
  ReviewerD         .tl_set:N     =   \l_@@_info_reviewer_d_tl,
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% 国家图书馆封面相关
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\keys_define:nn { nju / info }
{
  Classification    .tl_set:N     =   \l_@@_info_classif_tl,
  SecurityLevel     .tl_set:N     =   \l_@@_info_seclv_tl,
  UDC               .tl_set:N     =   \l_@@_info_udc_tl,
  SupervisorContact .tl_set:N     =   \l_@@_info_supv_cont_tl,
%    \end{macrocode}
% 定义用于设置个人信息的命令
%    \begin{macrocode}
\NewDocumentCommand \njusetup { m }
{ \keys_set:nn { nju } { #1 } }
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
% 使用\pkg{geometry}设置页边距。
%    \begin{macrocode}
\RequirePackage[    
    top=2.5cm,
    bottom=2.5cm,
    left=3.2cm,
    right=3.2cm
]{geometry}
\RequirePackage{xparse}
\RequirePackage[hyphens]{url} % generate better linebreaks in the url
\RequirePackage{dashundergaps}
\RequirePackage{setspace}
\RequirePackage{lastpage}
\RequirePackage{emptypage} % 清除空白页的页码
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\RequirePackage{listings} % 代码环境
\RequirePackage{enumitem} % 用于修改列表环境
\RequirePackage{caption}
\RequirePackage{floatrow} % 用于图表等页面元素的定位
\RequirePackage{booktabs} % 用于绘制三线表
\RequirePackage{multirow} % Cells occupying multiple rows in tables
\RequirePackage{multicol} % Multiple columns in dictionary
\RequirePackage{siunitx} % 用于书写单位符号
%    \end{macrocode}
%
% 用于化学
%    \begin{macrocode}
\RequirePackage[version=4]{mhchem} % 用于绘制分子式
Yu Xiong's avatar
Yu Xiong committed
% 用于生成可以被插入书签的LaTeX logo,TODO: 使用hologo创建|latex{}|命令
%    \begin{macrocode}
\RequirePackage{hologo} 
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% Required to prevent page break right after a sectioning command
% \RequirePackage{needspace} 

% \RequirePackage{xspace} % Better print trailing whitespace
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
% \begin{macro}{\njuline}
% 针对编译引擎,使用不同的宏包构建可以对中文正常换行的下划线命令。\pkg{lua-ul}中需要在结尾使用|\null|保护尾部空白。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\sys_if_engine_xetex:T
{
    \RequirePackage{microtype}
    \RequirePackage{xeCJKfntef}
    \newcommand{\njuline}[1]{\CJKunderline{#1}}
Yu Xiong's avatar
Yu Xiong committed
\sys_if_engine_luatex:T
{
    \RequirePackage{lua-ul}
    \newcommand{\njuline}[1]{\underLine{#1}\null}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
% \end{macro}
Yu Xiong's avatar
Yu Xiong committed
%
% 生成用于测试的大段无意义英文文字
%    \begin{macrocode}
\RequirePackage{blindtext} 
\RequirePackage{zhlipsum} 
%    \end{macrocode}
%
% 加载以后展示内容边界
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% \RequirePackage{showframe} 
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% 数学
%    \begin{macrocode}
\RequirePackage{amsmath} % Must be loaded before unicode-math
\RequirePackage{amsthm} % Mathematical environments
\RequirePackage{mathtools} % Mathematical tools to use with amsmath
\RequirePackage{thmtools} % Theorem styles
\RequirePackage[
    warnings-off={% 消除与mathtools合用产生的警告
        mathtools-colon,
        mathtools-overbracket}
        ]{unicode-math} % Math fonts in xetex or luatex
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
% 配置图片路径
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\RequirePackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.eps,.jpg,.png}
\graphicspath{{figure/}} % 图片路径
\RequirePackage{wrapfig} % Wrap text around figures
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
% 必须以该顺序加载以下包
\RequirePackage[hidelinks,bookmarksnumbered=true]{hyperref}
\RequirePackage[capitalise,nameinlink,noabbrev]{cleveref}
%    \end{macrocode}
%
% \subsection{字体设置}
%
% 加载设置字体所需的包\pkg{fontspec}
%    \begin{macrocode}
\RequirePackage{fontspec}
%    \end{macrocode}
%
% 
%
% \begin{variable}{\g_@@_latin_fontset_tl,\g_@@_cjk_fontset_tl}
% 用于存储所使用字体名称的全局变量
%    \begin{macrocode}
\tl_new:N \g_@@_latin_fontset_tl
\tl_new:N \g_@@_cjk_fontset_tl
%    \end{macrocode}
% \end{variable}
%
% 定义字体选项
%    \begin{macrocode}
\keys_define:nn { nju }
{
  customlatinfont   .choices:nn   =
Yu Xiong's avatar
Yu Xiong committed
  { gyre, macos, windows, none }
  { \tl_set_eq:NN \g_@@_latin_fontset_tl \l_keys_choice_tl },  
  customchinesefont .choices:nn   =
Yu Xiong's avatar
Yu Xiong committed
  { fandol, founder, macos, noto, windows, none }
  { \tl_set_eq:NN \g_@@_cjk_fontset_tl   \l_keys_choice_tl },
}
%    \end{macrocode}
%
% \begin{macro}{\ProcessKeysOptions}
% 在定义完全部设置以后从tex文件导言区输入参数
%    \begin{macrocode}
\ProcessKeysOptions { nju }
%    \end{macrocode}
% \end{macro}
%
% 如果未进行设置则使用系统默认字体覆盖输入参数
%
Yu Xiong's avatar
Yu Xiong committed
% \begin{variable}{\g_@@_load_system_fontset_bool}
% 用于判断是否需要载入系统预装字体的全局变量
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
\bool_new:N \g_@@_load_system_fontset_bool
%    \end{macrocode}
% \end{variable}
%
% 判断用户是否自定义了中英文字体,如果其中任意一种未被定义,
% 则使用系统预装字体覆盖字体选项
%    \begin{macrocode}
\tl_if_empty:NTF \g_@@_latin_fontset_tl
Yu Xiong's avatar
Yu Xiong committed
  { \bool_gset_true:N \g_@@_load_system_fontset_bool }  
{  
  \tl_if_empty:NT \g_@@_cjk_fontset_tl
Yu Xiong's avatar
Yu Xiong committed
    { \bool_gset_true:N \g_@@_load_system_fontset_bool }  
Yu Xiong's avatar
Yu Xiong committed
\bool_if:NT \g_@@_load_system_fontset_bool
{
  % 检测是否是 Windows
  \sys_if_platform_windows:TF
  {
    \tl_set:Nn \g_@@_latin_fontset_tl { windows }
    \tl_set:Nn \g_@@_cjk_fontset_tl   { windows }
  }
  {
    % 检测是否是 macOS
    \ctex_if_platform_macos:TF
    {
      \tl_set:Nn \g_@@_latin_fontset_tl { macos }
      \tl_set:Nn \g_@@_cjk_fontset_tl   { macos }
    }
    % 其余系统一律使用自由字体
    {
      \tl_set:Nn \g_@@_latin_fontset_tl { gyre }
      \tl_set:Nn \g_@@_cjk_fontset_tl { fandol }
    }
  }
}
%    \end{macrocode}
%
% 接下来逐个定义所需要使用的字库
%
% \begin{macro}{\@@_load_latin_font_windows:}
% Windows 西文字体
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_latin_font_windows:
{
  \setmainfont{Times~New~Roman}
  \setsansfont{Arial}
  \setmonofont{Courier~New}[Scale=MatchLowercase]
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
%
% \begin{macro}{\@@_load_latin_font_macos:}
% macOS 西文字体
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_latin_font_macos:
{
\setmainfont{Times~New~Roman}
\setsansfont{Arial}
\setmonofont{Menlo}[Scale=MatchLowercase]
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
%
% \begin{macro}{\@@_load_latin_font_gyre:}
% 开源的 gyre 西文字体
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_latin_font_gyre:
{
\setmainfont{texgyretermes}[
  Extension=.otf,
  UprightFont=*-regular,
  BoldFont=*-bold,
  ItalicFont=*-italic,
  BoldItalicFont=*-bolditalic]
\setsansfont{texgyreheros}[
  Extension=.otf,
  UprightFont=*-regular,
  BoldFont=*-bold,
  ItalicFont=*-italic,
  BoldItalicFont=*-bolditalic]
\setmonofont{texgyrecursor}[
  Extension=.otf,
  UprightFont=*-regular,
  BoldFont=*-bold,
  ItalicFont=*-italic,
  BoldItalicFont=*-bolditalic,
  Scale=MatchLowercase,
  Ligatures=CommonOff]
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{macro}{\@@_load_cjk_font_windows:}
% Windows 中文字体
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_cjk_font_windows:
{
  \setCJKmainfont{SimSun}[
    AutoFakeBold=2.17, 
    ItalicFont=KaiTi]
  \setCJKsansfont{SimHei}
  \setCJKmonofont{FangSong}
  \setCJKfamilyfont{zhsong}{SimSun}[AutoFakeBold=2.17]
  \setCJKfamilyfont{zhhei}{SimHei}
  \setCJKfamilyfont{zhfs}{FangSong}
  \setCJKfamilyfont{zhkai}{KaiTi}[AutoFakeBold=2.17]
  % \setCJKfamilyfont{zhnewhei}{Microsoft~YaHei}[
  %   BoldFont=Microsoft~YaHei~Bold]
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
%
% \begin{macro}{\@@_load_cjk_font_macos:}
% macOS 字体
Yu Xiong's avatar
Yu Xiong committed
% 参考CTeX手册第9节 LuaLATEX 下的中文支持方式解决issue问题
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_cjk_font_macos:
{
  % 移除 does not contain script "CJK" 警告
  \msg_redirect_name:nnn {fontspec} {no-script} {info} 
  \setCJKmainfont{Songti~SC~Light}[
    BoldFont=Songti~SC~Bold,
    ItalicFont=Kaiti~SC,
    BoldItalicFont=Kaiti~SC~Bold]
  \setCJKsansfont{Heiti~SC~Light}[BoldFont=Heiti~SC~Medium]
  \setCJKmonofont{STFangsong}
  \setCJKfamilyfont{zhsong}{Songti~SC~Light}[BoldFont=Songti~SC~Bold]
  \setCJKfamilyfont{zhhei}{Heiti~SC~Light}[BoldFont=Heiti~SC~Medium]
  \setCJKfamilyfont{zhfs}{STFangsong}
  \setCJKfamilyfont{zhkai}{Kaiti~SC}[BoldFont=Kaiti~SC~Bold]
  \setCJKfamilyfont{zhnewhei}{PingFang~SC}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
%
% \begin{macro}{\@@_load_cjk_font_fandol:}
% Fandol 字体
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_cjk_font_fandol:
{
  % 移除 does not contain script "CJK" 警告
  \msg_redirect_name:nnn {fontspec} {no-script} {info} 
  \setCJKmainfont{FandolSong-Regular}[
    Extension=.otf,
    BoldFont=FandolSong-Bold,
    ItalicFont=FandolKai-Regular]
  \setCJKsansfont{FandolHei-Regular}[
    Extension=.otf,
    BoldFont=FandolHei-Bold]
  \setCJKmonofont{FandolFang-Regular}[Extension=.otf]
  \setCJKfamilyfont{zhsong}{FandolSong-Regular}[
    Extension=.otf,
    BoldFont=FandolSong-Bold]
  \setCJKfamilyfont{zhhei}{FandolHei-Regular}[
    Extension=.otf,
    BoldFont=FandolHei-Bold]
  \setCJKfamilyfont{zhfs}{FandolFang-Regular}[Extension=.otf]
  \setCJKfamilyfont{zhkai}{FandolKai-Regular}[
    Extension=.otf,
    AutoFakeBold=2.17]
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
%
% \begin{macro}{\@@_load_cjk_font_founder:}
% 方正字库(简繁扩展)
% FZYouHK_508R \href{http://www.foundertype.com/index.php/FontInfo/index/id/244}{方正悠黑508R} 设计师非商免费,
% FZYouHK_511M \href{http://www.foundertype.com/index.php/FontInfo/index/id/244}{方正悠黑511M} 设计师非商免费
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_cjk_font_founder:
{
  \setCJKmainfont{FZSSK}[% 方正书宋
    Extension=.ttf,
    BoldFont=FZXBSK,% 方正小标宋
    ItalicFont=FZKTK]% 方正楷体
  \setCJKsansfont{FZXH1K}[% 方正细黑一
    Extension=.ttf,
    BoldFont=FZHTK]% FZHTK 方正黑体
  \setCJKmonofont{FZFSK}[Extension=.ttf]% 方正仿宋
  \setCJKfamilyfont{zhsong}
    {FZSSK}[
      Extension=.ttf,
      BoldFont=FZXBSK]
  \setCJKfamilyfont{zhhei}
    {FZHTK}[
      Extension=.ttf,
      AutoFakeBold=2.17]
  \setCJKfamilyfont{zhfs}
    {FZFSK}[Extension=.ttf]
  \setCJKfamilyfont{zhkai}
    {FZKTK}[Extension=.ttf]
  % \setCJKfamilyfont{zhnewhei}
  %   {FZYouHK_508R}[% 方正悠黑508R
  %     Extension=.ttf,
  %     BoldFont=FZYouHK_511M]% 方正悠黑511M
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
%
% \begin{macro}{\@@_load_cjk_font_noto:}
% 思源字体
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_cjk_font_noto:
{
  % 思源宋体
  \setCJKmainfont[
    UprightFont=NotoSerifCJKsc-Regular,
    BoldFont=NotoSerifCJKsc-Bold,
    ItalicFont=NotoSerifCJKsc-Regular,
    BoldItalicFont=NotoSerifCJKsc-Bold,
    ItalicFeatures=FakeSlant,
    BoldItalicFeatures=FakeSlant]{Noto~Serif~CJK~SC}

  % 思源黑体
  \setCJKsansfont[
    UprightFont=NotoSansCJKsc-Regular,
    BoldFont=NotoSansCJKsc-Bold,
    ItalicFont=NotoSansCJKsc-Regular,
    BoldItalicFont=NotoSansCJKsc-Bold,
    ItalicFeatures=FakeSlant,
    BoldItalicFeatures=FakeSlant]{Noto~Sans~CJK~SC}

  % 包含于思源黑体
  \setCJKmonofont[
    UprightFont=NotoSansMonoCJKsc-Regular,
    BoldFont=NotoSansMonoCJKsc-Bold,
    ItalicFont=NotoSansMonoCJKsc-Regular,
    BoldItalicFont=NotoSansMonoCJKsc-Bold,
    ItalicFeatures=FakeSlant,
    BoldItalicFeatures=FakeSlant]{Noto~Sans~Mono~SC}

  \setCJKfamilyfont{zhsong}{Noto~Serif~CJK~SC}
  \setCJKfamilyfont{zhhei}{Noto~Sans~CJK~SC}
  \setCJKfamilyfont{zhfs}
    {FZFSK}[Extension=.ttf]
  \setCJKfamilyfont{zhkai}
    {FZKTK}[Extension=.ttf]
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% 载入设置的字体
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_load_font:
  \use:c { @@_load_latin_font_ \g_@@_latin_fontset_tl : }
  \use:c { @@_load_cjk_font_   \g_@@_cjk_fontset_tl   : }
  
  \NewDocumentCommand\songti{}{\CJKfamily{zhsong}}
  \NewDocumentCommand\heiti{}{\CJKfamily{zhhei}}
  \NewDocumentCommand\fangsong{}{\CJKfamily{zhfs}}
  \NewDocumentCommand\kaishu{}{\CJKfamily{zhkai}}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% 设置数学字体 (XITS, 或者 STIX, 与 Times New Roman 最为相近)
% \setmathfont{STIXTwoMath-Regular}[Extension = .otf]
\setmathfont{XITSMath-Regular}[
  BoldFont = XITSMath-Bold,
  Extension = .otf]
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
%
% \subsection{页面样式}
%
% \subsubsection{页眉页脚}
Yu Xiong's avatar
Yu Xiong committed
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\RequirePackage{fancyhdr} % 调整页眉页脚
% 本科生页眉页脚 
\fancypagestyle{njuplain}{%
   \fancyhead{}               
   \fancyfoot[C]{\zihao{5}\thepage} % 页脚居中 五号新罗马体数字
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% TODO: 研究生页眉页脚 
\fancypagestyle{njuheadings}{%
   \fancyhead{}               
   \fancyfoot[C]{\zihao{5}\thepage}        
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\str_if_eq:NNTF {\l_@@_info_degree_tl} { ug } 
{
  % the header line
  \tl_set:Nn \headrulewidth {0pt}
  % the footer line
  \tl_set:Nn \footrulewidth {0pt}
  \AtBeginDocument{\pagestyle{njuplain}\flushbottom} % 本科无页眉页脚
}
{
  % the header line
  \tl_set:Nn \headrulewidth {1pt}
  % the footer line
  \tl_set:Nn \footrulewidth {0pt}
  \setlength{\headheight}{20pt}
  % \AtBeginDocument{\pagestyle{njuplain}} % 无页眉页脚
  \AtBeginDocument{\pagestyle{fancy}\flushbottom} % 研究生有页眉页脚
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
    chapter/format = \zihao{4}\heiti\centering\selectfont,
    chapter/beforeskip = 10pt,
    chapter/afterskip = 60pt,
    section/format = \zihao{4}\heiti\raggedright\selectfont,
    subsection/format = \zihao{4}\heiti\raggedright\selectfont,
    subsubsection/format = \zihao{4}\heiti\raggedright\selectfont,
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\ctexset{
    contentsname = 目录,
    listfigurename = 插图清单, 
    listtablename = 表格清单,
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% \pkg{tocloft}定制目录文字格式
%    \begin{macrocode}
\RequirePackage[titles]{tocloft}
\cftsetpnumwidth{2em}
\renewcommand{\cftchapleader}{\cftdotfill{\cftchapdotsep}}
\renewcommand{\cftchapdotsep}{\cftdotsep}
\renewcommand{\cftchapfont}{\heiti\zihao{4}}
\setlength{\cftsecindent}{2em}
\setlength{\cftsubsecindent}{52pt}
\setlength{\cftsubsecnumwidth}{2em}
%    \end{macrocode}
%
% 将目录插入书签
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\renewcommand\tableofcontents{%
  \raggedbottom
  \begingroup
    \ctexset{
      contentsname = {目\hspace{2em}录},
      chapter/format = {\centering\songti\bf\zihao{3}\selectfont},
    }%
    \chapter*{\contentsname}%
  \endgroup
  \addcontentsline{toc}{chapter}{\contentsname}
  \vskip 20pt 
  \@starttoc{toc}%
}
\renewcommand\listoffigures{%
  \begingroup
  \ctexset{
    chapter/format = {\centering\songti\bf\zihao{3}\selectfont},
  }%
  \chapter*{\listfigurename}%
  \endgroup
  \addcontentsline{toc}{chapter}{\listfigurename}
  \vskip 20pt 
  \@starttoc{lof}%
}
\renewcommand\listoftables{%
  \begingroup
  \ctexset{
    chapter/format = {\centering\songti\bf\zihao{3}\selectfont},
  }%
  \chapter*{\listtablename}%
  \endgroup
  \addcontentsline{toc}{chapter}{\listtablename}
  \vskip 20pt 
  \@starttoc{lot}%
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% \begin{environment}{preface}
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\NewDocumentEnvironment{preface}{}
{%
  \chapter*{前言}
  \addcontentsline{toc}{chapter}{前言}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{environment}{acknowledgement}
Yu Xiong's avatar
Yu Xiong committed
% 单独制作的致谢页。
%    \begin{macrocode}
\NewDocumentEnvironment{acknowledgement}{}
{%
  \chapter*{致谢}
  \addcontentsline{toc}{chapter}{致谢}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% biblatex设置
\RequirePackage[
    style=gb7714-2015,
    %style=numeric-comp,
    %citestyle=authortitle-icomp,
    % citestyle=numeric-comp,
    %bibstyle=authoryear,
    % bibstyle=numeric,
    sorting=none,
    %sorting=nyt,
    %sortcites=true,
    %autocite=footnote,
    backend=biber, % Compile the bibliography with biber
    hyperref=true,
    backref=false,
    citecounter=true,
    pagetracker=true,
    citetracker=true,
    ibidtracker=context,
    autopunct=true,
    autocite=plain,
    % gbpub=false,         % Uncomment if you do NOT want '[S.l. : s.n.]' 
                           % in reference entries, GitHub Issue (#47)
    % gbnamefmt=lowercase, % Uncomment if you do NOT want uppercase author 
                           % names in reference entries, GitHub Issue (#23)
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% Remove some unwanted entries from the bibliography
\AtEveryBibitem{
	\clearfield{abstract}
	\clearfield{issn}
	\clearfield{isbn}
	\clearfield{archivePrefix}
	\clearfield{arxivId}
	\clearfield{pmid}
	\clearfield{eprint}
	\ifentrytype{online}{}{\ifentrytype{misc}{}{\clearfield{url}}}
	% \ifentrytype{book}{\clearfield{doi}}{}
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% 修改标签名称
\crefdefaultlabelformat{#2#1#3\,} % 默认在名称后面添加空格

\crefname{figure}{图}{图}
\crefname{table}{表}{表}
% \crefname{equation}{公式}{公式}
\crefformat{equation}{公式~#2#1#3~} % 删除公式编号的括号

\crefformat{chapter}{第#2#1#3章}
\crefformat{section}{第~#2#1#3~节}
\crefformat{subsection}{第~#2#1#3~小节}
\crefformat{subsubsection}{第~#2#1#3~小节}
% \crefname{chapter}{§}{§}
% \crefname{section}{§}{§}
% \crefname{subsection}{§}{§}
% \crefname{subsubsection}{§}{§}
\crefname{appendix}{附录}{附录}

% \crefname{definition}{定义}{定义}
% \crefname{axiom}{公理}{公理}
% \crefname{property}{性质}{性质}
% \crefname{proposition}{命题}{命题}
% \crefname{lemma}{引理}{引理}
% \crefname{corollary}{推论}{推论}
% \crefname{remark}{注解}{注解}
% \crefname{condition}{条件}{条件}
% \crefname{conclusion}{结论}{结论}
% \crefname{assumption}{假设}{假设}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% soifjsojfosjfos
%    \begin{macrocode}
% 图表位置调整
\floatsetup[lstlisting]{ % Captions for lstlistings
	capposition=above,%
	margins=centering,%
	floatwidth=\textwidth%
}
\floatsetup[figure]{ % Captions for figures
	capposition=bottom,%
	margins=centering,%
	floatwidth=\textwidth%
}
\floatsetup[table]{ % Captions for tables
	capposition=above,%
	margins=centering,%
	floatwidth=\textwidth%
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% 代码样式
\lstset{
	basicstyle=\ttfamily\linespread{1}\small\selectfont,
    keywordstyle=\bfseries,% use bold style for keywords
    commentstyle=\rmfamily\itshape,% use italic style for comments
    stringstyle=\ttfamily,% 字符串风格
    flexiblecolumns,% ?
    numbers=left,% left-aligned numbering
    showspaces=false,% hide markers for spaces
    showstringspaces=false,
    captionpos=t,% place the caption at the top
	% frame=lrtb,% show all four sides of the frame
	% linewidth=.8\textwidth,
	% breakatwhitespace=true,
	breaklines=true,
	xleftmargin=2em,xrightmargin=2em,% set the width of the code environment
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\lstdefinestyle{LaTeX}{
  language=TeX,
  morekeywords={
    begin, caption, label, mathrm, frac, 
    toprule, midrule, bottomrule, includegraphics}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% 图表标题样式
\DeclareCaptionFont{songticap}{\zihao{5}\bf\songti}
\captionsetup{
    font=small,%
    labelfont=songticap,
	textfont=songticap,
	strut=no,%
	hypcap=true, % Links point to the top of the figure
	% indention=0pt, % Suppress indentation
	% % parindent=0pt, % Suppress space between paragraphs
	aboveskip=6pt, % Increase the space between the figure and the caption
	belowskip=6pt, % Increase the space between the caption and the table
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% list configuration
\renewcommand{\labelitemi}{\tiny$\blacktriangleright$}
\renewcommand{\labelitemii}{\textbullet}

\setlist[itemize]{noitemsep}
\setlist[enumerate]{noitemsep}
\setlist[description]{noitemsep}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
% 数学环境
\declaretheoremstyle[
    	%spaceabove=.5\thm@preskip,
    	%spacebelow=.5\thm@postskip,
    	headfont=\bf\songti,%\scshape,
    	notefont=\songti,% notebraces={ (}{)},
    	bodyfont=\songti,
    	%headformat={\NAME\space\NUMBER\space\NOTE},
    	headpunct={},
    	%postheadspace={.5em plus .1em minus .1em},
    	%prefoothook={\hfill\qedsymbol}
    ]{njuthm}

\theoremstyle{njuthm}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\let\oldproofname=\proofname
\renewcommand*{\proofname}{\rm\bf\songti{\oldproofname}} % 修改证明环境标题
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\declaretheorem[
	name=算法,
	style=njuthm,
	refname={算法,算法},
	Refname={算法,算法},
	% numberwithin=section,
]{algorithm}
\declaretheorem[
	name=假设,
	style=njuthm,
	refname={假设,假设},
	Refname={假设,假设},
	% numberwithin=section,
]{assumption}
\declaretheorem[
	name=公理,
	style=njuthm,
	refname={公理,公理},
	Refname={公理,公理},
	% numberwithin=section,
]{axiom}
\declaretheorem[
	name=结论,
	style=njuthm,
	refname={结论,结论},
	Refname={结论,结论},
	% numberwithin=section,
]{conclusion}
\declaretheorem[
	name=条件,
	style=njuthm,
	refname={条件,条件},
	Refname={条件,条件},
	% numberwithin=section,
]{condition}
\declaretheorem[
	name=推论,
	style=njuthm,
	refname={推论,推论},
	Refname={推论,推论},
	% numberwithin=section,
]{corollary}
\declaretheorem[
	name=定义,
	style=njuthm,
	refname={定义,定义},
	Refname={定义,定义},
	% numberwithin=section,
]{definition}
\declaretheorem[
    	name=例,
    	style=njuthm,
    	refname={例,例},
    	Refname={例,例},
    	% numberwithin=section,
]{example}
\declaretheorem[
	name=引理,
	style=njuthm,
	refname={引理,引理},
	Refname={引理,引理},
	% numberwithin=section,
]{lemma}
\declaretheorem[
	name=性质,
	style=njuthm,
	refname={性质,性质},
	Refname={性质,性质},
	% numberwithin=section,
]{property}
\declaretheorem[
	name=命题,
	style=njuthm,
	refname={命题,命题},
	Refname={命题,命题},
	% numberwithin=section,
]{proposition}
\declaretheorem[
	name=注解,
	style=njuthm,
	refname={注解,注解},
	Refname={注解,注解},
	% numberwithin=section,
]{remark}
\declaretheorem[
	name=定理,
	style=njuthm,
	refname={定理,定理},
	Refname={定理,定理},
	numberwithin=section,
]{theorem}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% \subsection{封面绘制}
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\tl_const:Nn \l_@@_info_title_tl 
{
  \l_@@_info_title_a_tl
  \l_@@_info_title_b_tl
  \l_@@_info_title_c_tl
}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%% \begin{variable}{\l_@@_info_supv_full_tl,\l_@@_info_supv_full_en_tl}
% 用于存储导师姓名加职称的变量,旧版编译器不支持字符串中含有|\hspace{.5em}|这样的空白空间命令
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\tl_new:N \l_@@_info_supv_full_tl
\tl_new:N \l_@@_info_supv_full_en_tl
%    \end{macrocode}
% \end{variable}
%
%    \begin{macrocode}
\tl_set:Nn \l_@@_info_supv_full_tl
  \l_@@_info_supv_a_tl\ 
  \l_@@_info_supv_a_title_tl\ \ 
  \l_@@_info_supv_b_tl\ 
  \l_@@_info_supv_b_title_tl
\tl_set:Nn \l_@@_info_supv_full_en_tl
{
  \l_@@_info_supv_a_en_tl\ 
  \l_@@_info_supv_a_title_en_tl\ \ 
  \l_@@_info_supv_b_en_tl\ 
  \l_@@_info_supv_b_title_en_tl
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
% \begin{variable}{\c_@@_name_degree_tl,\c_@@_name_degree_en_tl}
% 用于存储学位名称的变量
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\tl_new:N \c_@@_name_degree_tl
\tl_new:N \c_@@_name_degree_en_tl
%    \end{macrocode}
% \end{variable}
%
% 判断学位进行命令定义
%    \begin{macrocode}
\str_if_eq:NNTF {\l_@@_info_degree_tl} { ug } 
  \tl_const:Nn \l_@@_name_diploma_tl { 本\hfill 科\hfill }
  \tl_const:Nn \c_@@_name_title_tl { 题\hfill 目 }
  
  \tl_const:Nn \c_@@_cover_uline_len_a_tl { 250pt }
  \tl_const:Nn \c_@@_cover_uline_len_b_tl { 90pt }
  \tl_const:Nn \c_@@_cover_uline_font_tl { \songti }
  \tl_const:Nn \c_@@_cover_uline_style_tl { \bf }
  \tl_const:Nn \c_@@_cover_uline_bskip_tl {}

  \tl_const:Nn \c_@@_cover_box_len_tl { 4.2em }

  % 本科强制不打印国家图书馆封面
Yu Xiong's avatar
Yu Xiong committed
  \bool_set_false:N \g_@@_nlcover_bool
} 
{ 
  % 本科以外都是研究生 
  \tl_const:Nn \l_@@_name_diploma_tl { 研\hfill 究\hfill 生\hfill }
  \tl_const:Nn \c_@@_name_title_tl { 论\hfill 文\hfill 题\hfill 目 }
  \tl_const:Nn \c_@@_cover_uline_len_a_tl { 250pt }
  \tl_const:Nn \c_@@_cover_uline_len_b_tl { 14em }
  \tl_const:Nn \c_@@_cover_uline_font_tl { \kaishu }
  \tl_const:Nn \c_@@_cover_uline_style_tl {}
  \tl_const:Nn \c_@@_cover_uline_bskip_tl { \hspace{1em} }
  \tl_const:Nn \c_@@_cover_box_len_tl { 6em }
  % 研究生学位名称
  \str_if_eq:NNTF { \l_@@_info_degree_tl } { phd }
  {
    \tl_set:Nn \c_@@_name_degree_tl { 博士 }
    \tl_set:Nn \c_@@_name_degree_en_tl { Doctor~of~Philosophy }
    \tl_set:Nn \c_@@_name_degree_en_tl { Master }
    \str_if_eq:NNTF { \l_@@_info_degree_tl } { mg }
    { \tl_set:Nn \c_@@_name_degree_tl { 硕士 } }
    { \tl_set:Nn \c_@@_name_degree_tl { 硕士专业 } }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% \begin{macro}{\@@_cover_uline_a:n}
% 在封面绘制下划线
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new:Npn \@@_cover_uline_a:n #1
{
  \uline{\makebox[\c_@@_cover_uline_len_a_tl]
    {\rm\c_@@_cover_uline_font_tl #1 }}
}
\cs_new:Npn \@@_cover_uline_b:n #1
{
  \uline{\makebox[\c_@@_cover_uline_len_b_tl]
    {\rm\c_@@_cover_uline_font_tl #1 }}
}
\cs_new:Npn \@@_cover_uline_nl:nn #1 #2
{