Skip to content
Snippets Groups Projects
njuthesis.dtx 151 KiB
Newer Older
% \end{macro}
%
%    \begin{macrocode}
\ctexset
  {
    chapter/beforeskip   = 10 pt,
    chapter/afterskip    = 60 pt,
    chapter/format       = \centering \c_@@_sec_format_tl,
    section/format       = \c_@@_sec_format_tl,
    subsection/format    = \c_@@_sec_format_tl,
    subsubsection/format = \c_@@_sec_format_tl
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
% \subsection{目录格式}
Yu Xiong's avatar
Yu Xiong committed
% \changes{v0.13}{2021/12/09}{删除 \pkg{tocloft},改用 \pkg{ctex} 内置的目录设置。}
Yu Xiong's avatar
Yu Xiong committed
% \begin{macro}{\@@_chapter_in_toc:n}
% 将无编号章插入目录。
Yu Xiong's avatar
Yu Xiong committed
\cs_new_protected:Npn \@@_chapter_in_toc:n #1
  { \addcontentsline { toc } { chapter } { \c_@@_sec_format_tl #1 } }
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
% 设置目录标题默认名称。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
    contentsname   = { 目\hspace{2em}录 },
    listfigurename = { 插图目录         }, 
    listtablename  = { 表格目录         },
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
% 设置目录中章标题的样式。
    chapter / tocline = \c_@@_sec_format_tl \CTEXnumberline {#1} #2
Yu Xiong's avatar
Yu Xiong committed
% \begin{macro}{\c_@@_toc_title_tl}
% 目录页标题格式,单独设置为三号粗宋体。
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
\tl_const:Nn \c_@@_toc_title_tl { \centering \zihao{3} \bf }
%    \end{macrocode}
% \end{macro}
%
Yu Xiong's avatar
Yu Xiong committed
% \begin{macro}{\@@_modify_toc_title:nn}
% 通过 group 内修改标题设置,改变标题页字体。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
\cs_new_protected:Npn \@@_modify_toc_title:nn #1#2
{
  \group_begin:
    \ctexset { chapter/format = \c_@@_toc_title_tl }
Yu Xiong's avatar
Yu Xiong committed
    \njuchapter { #1 }
Yu Xiong's avatar
Yu Xiong committed
  \group_end:
  \@starttoc{#2}
}
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{macro}{\tableofcontents,\listoffigures,\listoftables}
% 重定义目录命令,修改标题格式并插入书签。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
\RenewDocumentCommand \tableofcontents { }
  { \@@_modify_toc_title:nn { \contentsname   } { toc } }
\RenewDocumentCommand \listoffigures   { }
  { \@@_modify_toc_title:nn { \listfigurename } { lof } }
\RenewDocumentCommand \listoftables    { }
  { \@@_modify_toc_title:nn { \listtablename  } { lot } }
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
% \subsection{参考文献}
%
%    \begin{macrocode}
\keys_define:nn { nju / bib }
  {
%    \end{macrocode}
% \begin{macro}{bib/style}
% \changes{v0.14}{2021/12/19}{提供选择参考文献样式的接口。}
% 参考文献样式。分为顺序编码制 \opt{numeric}(gb7714-2015)和著者-出版年制 \opt{author-year}(gb7714-2015ay)。
%    \begin{macrocode}
    style             .choice:,
    style / numeric     .code:n =
      { \clist_set:Nn \l_@@_tmp_clist { style = gb7714-2015   } },
    style / author-year .code:n =
      { \clist_set:Nn \l_@@_tmp_clist { style = gb7714-2015ay } },
    style            .initial:n = numeric,
%    \end{macrocode}
% \end{macro}
% \begin{macro}{bib/resource}
  % \changes{v0.14}{2021/12/19}{提供批量导入参考文献数据源的接口。}
% 参考文献数据源。
%    \begin{macrocode}
    resource       .clist_set:N = \l_@@_bib_resource_clist
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\addbibresource}
% 由于在导言区尚未载入 \pkg{biblatex} 宏包,为了兼容用于添加参考文献数据源的 \cs{addbibresource} 命令,需要单独对其进行定义。
%    \begin{macrocode}
\NewDocumentCommand \addbibresource { m }
  { \clist_gput_right:Nn \l_@@_bib_resource_clist {#1} }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@@_biblatex_pre_setup:}
% 载入 \pkg{biblatex} 宏包前,需要禁用自行定义的 \cs{addbibresource} 命令,并传入用户设置的选项。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_biblatex_pre_setup:
  {
    \cs_undefine:N \addbibresource
    \clist_put_right:Nn \l_@@_tmp_clist { backend = biber }
    \exp_args:NV \PassOptionsToPackage \l_@@_tmp_clist { biblatex }
    \clist_clear:N \l_@@_tmp_clist
  }
%    \end{macrocode}
% \begin{macro}{\@@_biblatex_post_setup:}
% \pkg{biblatex} 宏包载入后的设置,此时可正常使用 \cs{addbibresource} 命令。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_biblatex_post_setup:
  {
%    \end{macrocode}
% \changes{v0.12}{2021/12/06}{设置输出参考文献的默认选项。}
% 修改参考文献的头部样式,自动添加目录条目。
%    \begin{macrocode}
    \defbibheading { njubib } [ \bibname ] { \njuchapter { ##1 } }
    \DeclarePrintbibliographyDefaults { heading = njubib }
%    \end{macrocode}
% 传入参考文献源文件。
%    \begin{macrocode}
    \clist_map_inline:Nn \l_@@_bib_resource_clist
      { \addbibresource { ##1 } }
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
% 忽略不需要的文献信息。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
    \AtEveryBibitem
      {
        \clist_map_inline:nn
          { abstract, issn, isbn, archivePrefix, arxivId, pmid, eprint }
          { \clearfield { ##1 } }
        % \ifentrytype{online} { }
          % {
            % \ifentrytype{misc} { }
            %   \clearfield{urldate} { \clearfield{url} }
          % }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% 使用 \pkg{etoolbox} 提供的 \tn{BeforeBeginEnvironment},在 \env{document} 环境开始的钩子前载入 \pkg{biblatex} 并进行相关设置。
%    \begin{macrocode}
%\hook_gset_rule:nnnn { begindocument/before } { . } { < } { xeCJK }
%\hook_gput_code:nnn { env/document/begin } { . }
\BeforeBeginEnvironment { document }
    \@@_biblatex_pre_setup:
    \RequirePackage { biblatex }
    \@@_biblatex_post_setup:
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
% \subsection{引用}
Yu Xiong's avatar
Yu Xiong committed
%
% \pkg{hyperref} 设置。
Yu Xiong's avatar
Yu Xiong committed
% \changes{v0.11}{2021/10/01}{写入PDF元数据。}
%    \begin{macrocode}
\ctex_at_end_preamble:n
%    \end{macrocode}
% 清除标题中用于手动换行的 |!| 控制符。
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
    \tl_set_eq:NN \l_@@_tmp_tl \l_@@_info_title_tl
    \tl_remove_all:Nn \l_@@_tmp_tl { ! }
Yu Xiong's avatar
Yu Xiong committed
    \hypersetup
      {
        bookmarksnumbered = true,
        psdextra          = true,
        unicode           = true,
        hidelinks,
%    \end{macrocode}
% 填写 PDF 元信息。
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
        pdftitle    = \l_@@_tmp_tl,
Yu Xiong's avatar
Yu Xiong committed
        pdfauthor   = \l_@@_info_author_tl,
        pdfkeywords = \l_@@_info_keywords_clist,
        pdfcreator  = \c_@@_name_pdf_creator_tl
      }
  }
%    \end{macrocode}
%
% \begin{macro}{\@@_cref_name:n,\@@_cref_name:N }
% 用于修改 \pkg{cleverref} 的标签名称的辅助函数。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_cref_name:n #1
  {
    \clist_map_inline:nn { #1 }
      { 
        \crefname { ##1 }
          { \@@_name:n { ##1 } } { \@@_name:n { ##1 _en } }
      }
  }
\cs_new_protected:Npn \@@_cref_name:N #1
  {
    \clist_map_inline:Nn #1
      { 
        \crefname { ##1 }
          { \@@_name:n { ##1 } } { \@@_name:n { ##1 _en } }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% 修改 \pkg{cleverref} 的标签格式。
% 默认在名称后面添加空格,删除公式编号的括号。
%    \begin{macrocode}
\crefdefaultlabelformat{#2#1#3\,}
\crefformat { equation      } { 公式~#2#1#3~   }
\crefformat { chapter       } { 第#2#1#3章     }
\crefformat { section       } { 第~#2#1#3~节   }
\crefformat { subsection    } { 第~#2#1#3~小节 }
\crefformat { subsubsection } { 第~#2#1#3~小节 }
%    \end{macrocode}
%
% 修改 \pkg{cleverref} 的标签名称。
%    \begin{macrocode}
\@@_cref_name:n { figure, table, appendix, proof }
\@@_cref_name:N \c_@@_theorem_type_clist
%    \end{macrocode}
% \subsection{图片表格}
%
% 设置默认图片扩展名,允许在不键入扩展名时自动进行补全。
%    \begin{macrocode}
\DeclareGraphicsExtensions{.pdf,.eps,.jpg,.png}
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
% 
% \changes{v0.12}{2021/12/06}{删除了可能导致冲突的 \pkg{floatrow}。}
% 图表标题样式。文字设置为五号宋体,标签设置为粗体,间隔一个全角空格。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\DeclareCaptionStyle{njucap}
  {
    font          = small,
    labelfont     = bf,
    labelsep      = quad,
    justification = centering
  }
\captionsetup [ figure ] { style = njucap }
\captionsetup [ table  ] { style = njucap }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% \subsection{列表环境}
% \changes{v0.12}{2021/12/07}{删除了 \pkg{enumitem} 的部分列表环境设置。}
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\setlist { noitemsep }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
% \subsection{定理环境}
% \begin{macro}{\@@_new_theorem:N}
% 用于定义普通定理环境的辅助函数。
% \begin{arguments}
%   \item 定理名称列表,|clist| 型变量
% \end{arguments}
% 除证明以外的环境都不需要证毕符号,在此清空其设置。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_new_theorem:N #1
  { 
    \theoremsymbol { }
    \clist_map_inline:Nn #1
      { \newtheorem { ##1 } { \@@_name:n { ##1 } } }
  }
%    \end{macrocode}
% \end{macro}
%
Yu Xiong's avatar
Yu Xiong committed
% 定义证明环境。证毕符号使用 \tn{mdlgwhtsquare}绘制,对应于 |U+25A1| 字符\footnote{\url{https://tex.stackexchange.com/questions/567135/how-get-box-like-symbol-with-xelatex}}。
%    \begin{macrocode}
\theoremsymbol { \ensuremath { \mdwhtsquare } }
\newtheorem* { proof } { \c_@@_name_proof_tl }
%    \end{macrocode}
%
% 定义普通定理环境。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\@@_new_theorem:N \c_@@_theorem_type_clist
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
Yu Xiong's avatar
Yu Xiong committed
% \subsection{封面}
%
Yu Xiong's avatar
Yu Xiong committed
% \subsubsection{内部命令}
% \begin{macro}{\@@_split_title:n}
% 分割标题。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_split_title:n #1
    \tl_if_in:VnTF { #1 } { ! }
      {
%    \end{macrocode}
% 从英文感叹号进行分割,存入 |clist|。
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
        \seq_set_split:NnV \l_@@_tmp_seq { ! } { #1 }
        \clist_set_from_seq:NN \l_@@_tmp_clist \l_@@_tmp_seq
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
% 如果没找到感叹号,则手动进行分割固定宽度的字符。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
        \@@_put_inempty_seg:nnn { #1 } { 1  } { 15 }
        \@@_put_inempty_seg:nnn { #1 } { 16 } { 15 }
        \@@_put_inempty_seg:nnn { #1 } { 31 } { 15 }
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{macro}{\@@_multiline_title:nnn}
% 生成多行标题。
% \begin{arguments}
%   \item 内容格式
%   \item 名称盒子宽度,|dim| 型变量
%   \item 内容盒子宽度,|dim| 型变量
% \end{arguments}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_multiline_title:nnn #1#2#3
    \@@_split_title:n { \l_@@_info_title_tl }
    \@@_spread_box:nnn { #2 } { \kaishu } { \c_@@_name_title_tl }
    \@@_hskip:
Yu Xiong's avatar
Yu Xiong committed
    \clist_map_inline:Nn \l_@@_tmp_clist
      { \@@_ulined_center_box:nn { #3 } { #1 ##1 } \@@_vskip: }
%    \end{macrocode}
% \end{macro}
%
Yu Xiong's avatar
Yu Xiong committed
% \begin{macro}{\@@_cover_entry:nnn}
% 生成单项信息条目。
% \begin{arguments}
%   \item 条目
%   \item 名称盒子宽度,|dim| 型变量
%   \item 内容盒子宽度,|dim| 型变量
% \end{arguments}
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
\cs_new_protected:Npn \@@_cover_entry:nnn #1#2#3
    \@@_spread_box:nnn { #2 } { \kaishu } { \@@_name:n { #1 } }
    \@@_ulined_center_box:nn  { #3 }      { \@@_info:n { #1 } }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
Yu Xiong's avatar
Yu Xiong committed
% \begin{macro}{\@@_cover_bientry:nnnn}
% 生成两项信息条目,仅用于本科生封面。
% \begin{arguments}
%   \item 左侧条目
%   \item 右侧条目
%   \item 名称盒子宽度,|dim| 型变量
%   \item 内容盒子宽度,|dim| 型变量
% \end{arguments}
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
\cs_new_protected:Npn \@@_cover_bientry:nnnn #1#2#3#4
    \@@_spread_box:nnn { #3 } { \kaishu } { \@@_name:n { #1 } }
    \@@_ulined_center_box:nn  { #4 }      { \@@_info:n { #1 } }
    \skip_horizontal:n { 0.5 em }
    \@@_spread_box:nnn { #3 } { \kaishu } { \@@_name:n { #2 } }
    \@@_ulined_center_box:nn  { #4 }      { \@@_info:n { #2 } }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
%
% \subsubsection{绘制部件}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{macro}{\@@_cover_title_ug:}
% 本科生封面标题。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_cover_title_ug:
  { \@@_spread_box:nnn { 9em } { \bf } { \l_@@_info_type_tl } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_cover_info_ug:nnn}
% 本科生封面信息栏。
Yu Xiong's avatar
Yu Xiong committed
% \begin{arguments}
%   \item 名称盒子宽度,|dim| 型变量
%   \item 长内容盒子宽度,|dim| 型变量
%   \item 短内容盒子宽度,|dim| 型变量
Yu Xiong's avatar
Yu Xiong committed
% \end{arguments}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_cover_info_ug:nnn #1#2#3
Yu Xiong's avatar
Yu Xiong committed
  {
    \begin{minipage} [ c ] { #1 + #2 + 0.3 em }
Yu Xiong's avatar
Yu Xiong committed
      \@@_cover_entry:nnn { dept            } { #1 } { #2 }
      \@@_cover_entry:nnn { major           } { #1 } { #2 }
      \@@_multiline_title:nnn   { \bf } { #1 } { #2 }
Yu Xiong's avatar
Yu Xiong committed
      \@@_cover_bientry:nnnn { grade } { id } { #1 } { #3 }
      \@@_cover_entry:nnn { author          } { #1 } { #2 }
      \@@_cover_bientry:nnnn { supv } { supv_ttl } { #1 } { #3 }
      \tl_if_blank:VF { \l_@@_info_supv_ii_tl }
Yu Xiong's avatar
Yu Xiong committed
        { \@@_cover_bientry:nnnn { supv_ii } { supv_ttl } { #1 } { #3 } }
      \@@_cover_entry:nnn { sm_date     } { #1 } { #2 }
Yu Xiong's avatar
Yu Xiong committed
  }
%    \end{macrocode}
% \end{macro}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{macro}{\@@_cover_title_g:}
% 研究生封面标题。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_cover_title_g:
    \@@_spread_box:nnn { 9em } { } { \l_@@_info_type_tl } \@@_vskip:
    \c_@@_name_degree_l_tl \l_@@_info_degree_tl \c_@@_name_degree_r_tl
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_cover_info_g:nn}
% 研究生封面信息栏。
% \begin{arguments}
%   \item 名称盒子宽度,|dim| 型变量
%   \item 内容盒子宽度,|dim| 型变量
% \end{arguments}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_cover_info_g:nn #1#2
    \begin{minipage} [ c ] { #1 + #2 + 0.3 em }
      \raggedleft
      \@@_multiline_title:nnn { } { #1 } { #2 }
Yu Xiong's avatar
Yu Xiong committed
      \clist_map_inline:nn { author, major, field, supv_full }
Yu Xiong's avatar
Yu Xiong committed
        { \@@_cover_entry:nnn { ##1 } { #1 } { #2 } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_cover_back_g:}
% 研究生封面背面信息。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_cover_back_g:
    \@@_spread_box:nnn { 6.2 em } { \kaishu } { \c_@@_name_id_tl }
    { : \@@_quad: } \l_@@_info_id_tl
    \@@_vskip:
    \@@_spread_box:nnn { 6.2 em } { \kaishu } { \c_@@_name_df_date_tl }
    { : \@@_quad: } \l_@@_info_df_date_tl
    \@@_vskip:
    \@@_spread_box:nnn { 6.2 em } { \kaishu } { \c_@@_name_supv_full_tl }
    { : \@@_quad: } \skip_horizontal:n { 8 em } \c_@@_name_sign_tl
% \begin{macro}{\@@_cover_en_g:}
% 研究生英文封面。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_cover_en_g:
%    \end{macrocode}
% 标题。
%    \begin{macrocode}
      \parbox { \textwidth }
        { \centering \bf \sffamily \zihao { 2 } \l_@@_info_title_en_tl }
      \skip_vertical:n { 1 cm }
%    \end{macrocode}
% 作者。
%    \begin{macrocode}
      \group_begin: \zihao { 4 } { by } \group_end: \@@_vskip:
      \group_begin: 
        \bf \sffamily \zihao { 4 } \l_@@_info_author_en_tl
      \group_end: \skip_vertical:n { 1 cm }
%    \end{macrocode}
% 导师。
%    \begin{macrocode}
      \group_begin: \zihao { 4 } { Supervised~ by } \group_end: \@@_vskip:
      \group_begin:
        \sffamily \zihao { 4 } \l_@@_info_supv_full_en_tl
      \group_end: \vfill
%    \end{macrocode}
% 学位信息。
%    \begin{macrocode}
      \c_@@_cover_en_text_tl \@@_vskip:
      \textsc { \clist_item:Nn \c_@@_name_degree_en_clist
Yu Xiong's avatar
Yu Xiong committed
                  { \l_@@_info_degree_int } }
      \@@_vskip: { in } \@@_vskip: 
      \l_@@_info_major_en_tl \skip_vertical:n { 1 cm }
%    \end{macrocode}
% 校徽。
%    \begin{macrocode}
      \njuemblem [ black ] { ! } { 2.5 cm } \@@_vskip:
      \l_@@_info_dept_en_tl \\ \c_@@_name_nju_en_tl
      \skip_vertical:n { 1 cm }
%    \end{macrocode}
% 提交日期。
%    \begin{macrocode}
      \l_@@_info_sm_date_en_tl
% \begin{macro}{\@@_cover_top_nl:}
% 国家图书馆封面顶部信息。
\cs_new_protected:Npn \@@_cover_top_nl:
    \@@_spread_box:nnn { 3.2 em } { } { \c_@@_name_clc_tl   } \@@_hskip:
    \@@_ulined_center_box:nn { 9 em } { \l_@@_info_clc_tl   } \hfill
    \@@_spread_box:nnn { 3.2 em } { } { \c_@@_name_seclv_tl } \@@_hskip:
    \@@_ulined_center_box:nn { 9 em } { \l_@@_info_seclv_tl } \\
    \@@_spread_box:nnn { 3.2 em } { } { \c_@@_name_udc_tl   } \@@_hskip:
    \@@_ulined_center_box:nn { 9 em } { \l_@@_info_udc_tl   } \hfill \null
Yu Xiong's avatar
Yu Xiong committed
% \end{macro}
% \begin{macro}{\@@_cover_title_nl:}
% 国家图书馆封面标题。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_cover_title_nl:
  {
    \noindent \kaishu \zihao { -0 } \skip_vertical:n { -1 cm }
    \@@_spread_box:nnn { 6 em } { } { \c_@@_name_title_tl }
    \@@_vskip: \zihao { 1 }
Yu Xiong's avatar
Yu Xiong committed
    \@@_split_title:n { \l_@@_info_title_tl }
    \@@_multiline_box:nnnn { \l_@@_tmp_int } \l_@@_tmp_clist { 3 } { 15 em }
    \@@_vskip: \zihao{4} \c_@@_name_title_nl_tl
    \@@_vskip: \zihao{1} 
    \@@_ulined_center_box:nn { 4.5 em } { \l__nju_info_author_tl }
    \@@_vskip: \zihao{4} { ( } \c_@@_name_author_tl { ) }
  }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@@_cover_info_nl:}
% 国家图书馆封面信息栏。
\cs_new_protected:Npn \@@_cover_info_nl:
Yu Xiong's avatar
Yu Xiong committed
    \@@_uline_entry:nnnn   \l_@@_tmp_dim { supv_info } { supv   } { } \\
    \@@_ulined_center_box:nn { \textwidth } { \@@_info:n { supv_ttl }
    \@@_quad: \@@_info:n  { supv_cont } }                             \\
    \@@_uline_bientry:nnnn \l_@@_tmp_dim { degree   } { degree  } { }
    \@@_uline_bientry:nnnn \l_@@_tmp_dim { major_nl } { major   } { } \\ 
    \@@_uline_bientry:nnnn \l_@@_tmp_dim { sm_date  } { sm_date } { }
    \@@_uline_bientry:nnnn \l_@@_tmp_dim { df_date  } { df_date } { } \\
    \@@_full_uline:Nn \l_@@_tmp_dim { \c_@@_name_confer_tl }
    \@@_uline:n { \l_@@_tmp_dim }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{macro}{\@@_cover_bottom_nl:}
% 国家图书馆封面底部信息。
\cs_new_protected:Npn \@@_cover_bottom_nl:
    \@@_name:n { chairman } \@@_hskip:
    \@@_ulined_center_box:nn { 9 em } { \@@_info:n { chairman } } \\
    \@@_name:n { reviewer } \@@_hskip:
Yu Xiong's avatar
Yu Xiong committed
    \@@_multiline_box:nnnn { \l_@@_tmp_int }
      { \l_@@_info_reviewer_clist } { 4 } { 9 em }
  }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
Yu Xiong's avatar
Yu Xiong committed
% \subsubsection{绘制封面}
%
% \begin{macro}{\@@_make_cover_ug:}
% \changes{v0.13}{2021/12/10}{使用 \hologo{LaTeX3} 语法重构本科生封面。}
% 生成本科生封面。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_make_cover_ug:
%    \end{macrocode}
% 校徽、校名。
%    \begin{macrocode}
    \null \skip_horizontal:n { -1 cm }
    \njuemblem [ black] { ! } { 3.35 cm }
    \begin{center}      
      \njuname[black]{!}{3cm} \@@_vskip:
%    \end{macrocode}
% 学位信息。
%    \begin{macrocode}
      \group_begin: \zihao { -1 } \@@_cover_title_ug: \group_end:
      \skip_vertical:n { 1.5 cm } \vfil
%    \end{macrocode}
% 信息栏。
%    \begin{macrocode}
      \zihao{3} \@@_cover_info_ug:nnn { 4.2 em } { 16 em } { 5.5 em } \vfil 
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{macro}{\@@_make_cover_g:}
% \changes{v0.13}{2021/12/11}{使用 \hologo{LaTeX3} 语法重构研究生封面。}
% 生成研究生封面。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_make_cover_g:
  {    
    \newpage
    \begin{center}
%    \end{macrocode}
% 校徽、校名。
%    \begin{macrocode}
      \null \skip_vertical:n { 1 cm }
      \njuemblem [ black ] { ! } { 1.9 cm } \skip_vertical:n { 0.5 cm }
      \njuname   [ black ] { 4.4 cm } { ! } \@@_vskip:
%    \end{macrocode}
% 学位信息。
%    \begin{macrocode}
        \zihao { -1 } \bf \kaishu \@@_cover_title_g:
      \group_end:
      \skip_vertical:n { 3 cm } \vfil 
%    \end{macrocode}
% 信息栏。
%    \begin{macrocode}
      \group_begin:
        \zihao { 3 } \kaishu
        \@@_cover_info_g:nn { 6.2 em } { 18 em } \vfil
        \skip_vertical:n { 2 cm } \l_@@_info_sm_date_tl
      \group_end:
    \end{center}
%    \end{macrocode}
% 背面。格式存在变化,没有使用循环来简化。
%    \begin{macrocode}
    \newpage
    \noindent \null \skip_vertical:n { 18 cm }
      \zihao { 3 } \kaishu \@@_cover_back_g:
%    \end{macrocode}
% 英文封面。
%    \begin{macrocode}
    \newpage
    \noindent \null \skip_vertical:n { 2 cm }
    \begin{center}
      \@@_cover_en_g:
    \end{center}
  }
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
% \end{macro}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{macro}{\@@_make_cover_nl:}
% \changes{v0.13}{2021/12/12}{使用 \hologo{LaTeX3} 语法重构国家图书馆封面。}
% 生成研究生的国家图书馆封面。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_make_cover_nl:
    \pdfbookmark [ 0 ] { 国家图书馆封面 } { nlcover }
    \noindent \null
%    \end{macrocode}
% 顶部,包括密级、分类号、UDC。
%    \begin{macrocode}
    \begin{center}
      \zihao{ -4 } \skip_vertical:n { -2 cm }
      \@@_cover_top_nl:
    \end{center}
%    \end{macrocode}
% 标题。
%    \begin{macrocode}
    \begin{center}
      \skip_vertical:n { -2 cm }
      \@@_cover_title_nl:
    \end{center}
%    \end{macrocode}
% 中部信息栏。
%    \begin{macrocode}
    \group_begin: 
      \kaishu \zihao { 4 } \noindent \@@_cover_info_nl:
    \group_end:
%    \end{macrocode}
% 底部答辩信息。
%    \begin{macrocode}
    \begin{flushright}
      \@@_cover_bottom_nl:
    \end{flushright}
    \begin{center}
      \kaishu \zihao{3} \@@_qquad: 年 \@@_quad: 月 \@@_quad: 日
    \end{center}
    \skip_vertical:n { -1 cm }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
% \begin{macro}{\@@_make_orig_decl: }
% \changes{v0.13}{2021/12/15}{加入本科生的诚信承诺书。}
% 生成学位论文原创性声明。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_make_orig_decl: 
  {
    \normalfont \normalsize
    \chapter* { \c_@@_name_nju_tl \c_@@_name_orig_decl_tl }
    \thispagestyle { empty }
    \c_@@_orig_decl_text_tl
    \vfil
    \begin{flushright}
      \clist_set:Nn \l_@@_tmp_clist { orig_sign, id, orig_date }
      \int_compare:nF { \l_@@_info_degree_int == 1 }
        { \clist_remove_all:Nn \l_@@_tmp_clist { id } }
      \clist_map_inline:Nn \l_@@_tmp_clist
        { \@@_vskip: \@@_name:n { ##1 } : \@@_uline:n { 7 em } }
    \end{flushright}
    \vfil
  }
Yu Xiong's avatar
Yu Xiong committed
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
%
%
% \subsubsection{用户接口}
%
Yu Xiong's avatar
Yu Xiong committed
% \begin{macro}{\maketitle}
Yu Xiong's avatar
Yu Xiong committed
% \changes{v0.12}{2021/12/01}{仅会生成国家图书馆封面或者普通封面之一。}
% \changes{v0.13}{2021/12/12}{重新绘制封面。}
Yu Xiong's avatar
Yu Xiong committed
% \changes{v0.13}{2021/12/15}{草稿模式下不绘制封面。}
% 重定义 \cs{maketitle} 以生成封面。
Yu Xiong's avatar
Yu Xiong committed
% 在草稿模式下,封面绘制将被禁用,有助于提升编译速度。
%    \begin{macrocode}
\RenewDocumentCommand \maketitle { }
  {
Yu Xiong's avatar
Yu Xiong committed
    \bool_if:NF \g_@@_draft_bool
      {
        \pagestyle { empty }
%    \end{macrocode}
% 如果在研究生模板中选择了 |nlcover|,就生成用于申请学位的国家图书馆封面和原创性声明,反之生成普通封面。
%    \begin{macrocode}
Yu Xiong's avatar
Yu Xiong committed
        \bool_if:NTF \g_@@_nlcover_bool 
          { \@@_make_cover_nl: }
Yu Xiong's avatar
Yu Xiong committed
          { \use:c { @@_make_cover_ \l_@@_info_diploma_tl : } }
%    \end{macrocode}
% 如果在选择了 |orig-decl|,就生成本科生的诚信承诺书或研究生的原创性声明。
%    \begin{macrocode}
        \bool_if:NT \g_@@_orig_decl_bool { \@@_make_orig_decl: }
Yu Xiong's avatar
Yu Xiong committed
      }
%    \end{macrocode}
% 生成封面后清除标题中的换行控制符。
%    \begin{macrocode}
    \tl_remove_all:Nn \l_@@_info_title_tl { ! }
%    \end{macrocode}
% 在标题页后使用大写罗马字母页码,恢复正常字体设置。
%    \begin{macrocode}
    \cleardoublepage
Yu Xiong's avatar
Yu Xiong committed
    \pagestyle     { plain }
    \pagenumbering { Roman }
    \normalfont \normalsize      
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
%
% \subsection{摘要页}
Yu Xiong's avatar
Yu Xiong committed
%
% \subsubsection{内部命令}
%
% \begin{macro}{\@@_abs_title_uuline:n}
% 摘要标题双层下划线格式。
% \begin{arguments}
%   \item 宽度,|dim| 型变量
% \end{arguments}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_abs_title_uuline:n #1 
  { \bf \kaishu \zihao { -2 } \@@_uuline:n { #1 } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_abs_info_style:n,\@@_abs_info_style_en:n}
% 摘要信息栏通用格式,设置为无缩进、四号或者小四号、楷书。
% \begin{arguments}
%   \item 字号
% \end{arguments}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_abs_info_style:n #1 
  { \noindent \zihao{ #1 } \kaishu }
\cs_new_protected:Npn \@@_abs_info_style_en: #1
  { \zihao{ #1 } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_abs_bookmark:,\@@_abs_bookmark_en:}
% \changes{v0.14}{2021/12/21}{将摘要插入目录。}
% 生成摘要的目录条目。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_abs_bookmark:
  {
    \phantomsection
    \addcontentsline { toc } { chapter }
      { \c_@@_sec_format_tl \c_@@_name_lang_tl \c_@@_name_abstract_tl }
  }
\cs_new_protected:Npn \@@_abs_bookmark_en:
    \phantomsection
    \addcontentsline { toc } { chapter }
      { \c_@@_sec_format_tl \c_@@_name_abstract_en_tl }
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
% \end{macro}
%
%
% \subsubsection{绘制部件}
%
% \begin{macro}{\@@_abs_title_ug:n}
% 绘制本科生摘要标题。
% \begin{arguments}
%   \item 语言,空置为中文,|_en| 为英文
% \end{arguments}
%    \begin{macrocode}
\cs_generate_variant:Nn \clist_map_inline:nn { Vn }
\cs_new_protected:Npn \@@_abs_title_ug:n #1
  { 
    \@@_name:n { nju     } \@@_name:n { type     }
    \@@_name:n { lang #1 } \@@_name:n { abstract }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_abs_info_ug:nn}
% 绘制本科生摘要信息栏。
% \begin{arguments}
%   \item 语言,空置为中文,|_en| 为英文
%   \item 分隔符
% \end{arguments}
% 本科生摘要页面不含下划线,因而不用确定文本宽度,绘制命令较为简单。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_abs_info_ug:nn #1#2
%    \end{macrocode}
% 确定标题类型。
%    \begin{macrocode}
    \tl_if_blank:eTF { #1 }
      { \c_@@_name_title_tl }
      { \clist_item:Nn \c_@@_name_type_en_clist { \l_@@_info_type_int } }
    #2 \tl_use:c { l_@@_info_title #1 _tl } \\
%    \end{macrocode}
% 由于作者姓名使用的字样发生了变动,这里进行替换以便嵌入循环。
%    \begin{macrocode}
    \tl_set_eq:NN \c_@@_name_author_tl \c_@@_name_author_full_tl
%    \end{macrocode}
% 使用循环输出院系、专业、作者、导师信息。
%    \begin{macrocode}
    \clist_map_inline:nn { dept, major, author, supv_full }
      { \@@_name:n { ##1 #1 } #2 \@@_info:n { ##1 #1 } \\ }
    \@@_name:n { abstract #1 } #2
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_abs_title_g:n}
% 绘制研究生摘要标题。
% \begin{arguments}
%   \item 语言,空置为中文,|_en| 为英文
% \end{arguments}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_abs_title_g:n #1
  { 
Yu Xiong's avatar
Yu Xiong committed
    \@@_name:n { nju     } \@@_info:n { type       }
    \@@_name:n { lang #1 } \@@_name:n { abstract_r }
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{macro}{\@@_abs_info_g:nn}
Yu Xiong's avatar
Yu Xiong committed
% 绘制研究生摘要信息栏。
% \begin{arguments}
%   \item 语言,空置为中文,|_en| 为英文
%   \item 分隔符
% 研究生摘要页包括下划线以及若干特殊的对齐方式,实现方式较为繁琐。
% \end{arguments}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_abs_info_g:nn #1#2
    \tl_if_blank:eTF { #1 }
      {
%    \end{macrocode}
% 中文摘要环境,使用 \cs{@@_full_uline:NV} 确定内容宽度后,调用 \cs{@@_uline:n} 或 \cs{@@_ulined_center_box:nn} 命令以绘制横穿页面的下划线。前两行为标题。
%    \begin{macrocode}
        \@@_full_uline:NV \l_@@_tmp_dim
          {
            \clist_item:Nn \c_@@_name_type_clist { \l_@@_info_type_int }
            \c_@@_name_title_s_tl #2
          }
        \@@_ulined_center_box:nn { \l_@@_tmp_dim }
          { \tl_range:Nnn \l_@@_info_title_tl { 1 } { 20 } } \\
        \@@_uline:n { \textwidth } \@@_qquad:
        \tl_range:Nnn \l_@@_info_title_tl { 21 } { -1 } \\
%    \end{macrocode}
% 专业、年级、姓名。
%    \begin{macrocode}
        \@@_full_uline:NV \l_@@_tmp_dim
          {
            \@@_ulined_center_box:nn { 11 em } { \l_@@_info_major_tl }
            \c_@@_name_major_s_tl
            \@@_ulined_center_box:nn { 4 em } { \l_@@_info_grade_tl }
            \c_@@_name_grade_tl
Yu Xiong's avatar
Yu Xiong committed
            \tl_item:nn { \l_@@_info_degree_tl } { 1 }
            \c_@@_name_author_r_tl #2 
          }
        \@@_ulined_center_box:nn { \l_@@_tmp_dim }
          { \l_@@_info_author_tl } \\
%    \end{macrocode}
% 导师姓名、职称。
%    \begin{macrocode}
        \@@_full_uline:NV \l_@@_tmp_dim
          { \c_@@_name_supv_full_tl \c_@@_name_supv_r_tl #2 }
        \@@_ulined_center_box:nn { \l_@@_tmp_dim }
          { \l_@@_info_supv_full_tl }
      }
%    \end{macrocode}
% 英文摘要环境。前两行为标题。
%    \begin{macrocode}
      { 
        \@@_full_uline:NV \l_@@_tmp_dim
          { \clist_item:cn { c_@@_name_type #1 _clist }
              { \l_@@_info_type_int } # 2 }
        \@@_ulined_center_box:nn { \l_@@_tmp_dim }
          { \tl_range:Nnn \l_@@_info_title_en_tl { 1 } { 40 } } \\
        \@@_uline:n { \textwidth } \@@_qquad:
        \tl_range:Nnn \l_@@_info_title_en_tl { 41 } { -1 }
%    \end{macrocode}
% 使用循环输出专业、姓名、导师。注意这里将 |\\| 放置在前部,以避免末尾生成多余的换行符产生 |Underfull \vbox| 信息。
%    \begin{macrocode}
        \clist_map_inline:nn { major, author, supv_full }
          { \\ 
            \@@_uline_entry:nnnn \l_@@_tmp_dim { ##1 _en } { ##1 _en } { #2 }
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_print_keywords:nn}
% 生成中英文关键词列表。
% \begin{arguments}
%   \item 语言,空置为中文,|_en| 为英文
%   \item 关键词分隔符
% \end{arguments}
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_print_keywords:nn #1#2
  {
    \skip_vertical:n { 2 ex }
    \group_begin:
%    \end{macrocode}
% “关键词”字样使用加粗黑体。
%    \begin{macrocode}
      \noindent \bf \heiti
      \use:c { c_@@_name_keywords #1 _tl }
    \group_end: 
    \clist_use:cn { l_@@_info_keywords #1 _clist } { #2 } 
%    \end{macrocode}
Yu Xiong's avatar
Yu Xiong committed
% \end{macro}
% \subsubsection{绘制摘要}
%
% \begin{macro}{\@@_make_abs_ug:nn}
% \changes{v0.13}{2021/12/12}{使用 \hologo{LaTeX3} 语法重构本科生摘要。}
% \begin{arguments}
%   \item 语言,空置为中文,|_en| 为英文
%   \item 关键词分隔符
% \end{arguments}
% 生成本科生摘要。
Yu Xiong's avatar
Yu Xiong committed
%    \begin{macrocode}
\cs_new_protected:Npn \@@_make_abs_ug:nn #1#2
  {
    \begin{center}
      \@@_abs_title_uuline:n { 22 em }
      \@@_abs_title_ug:n { #1 }
    \end{center}
    \group_begin:
      \@@_abs_info_style:n { -4 }
      \@@_abs_info_ug:nn { #1 } { #2 }
    \group_end: \@@_vskip:
  }
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{macro}{\@@_make_abs_g:nn}
% \changes{v0.13}{2021/12/12}{使用 \hologo{LaTeX3} 语法重构研究生摘要。}