\hduthesis_provide_module:n {layout}

\RequirePackage{geometry, array, setspace, fancyhdr, enumitem, cleveref}
\RequirePackage[skip = 1.75ex, labelsep = quad, font = small]{caption}
\fancyhf{}
\pagestyle{fancy}
\renewcommand*\headrulewidth {.8pt}
\renewcommand*\thefigure {\arabic{chapter}-\arabic{figure}}
\renewcommand*\thetable {\arabic{chapter}-\arabic{table}}
\renewcommand*\theequation {\arabic{chapter}-\arabic{equation}}
\AddToHook{env/figure/after}{\vspace*{-2.3ex}}
\AddToHook{env/table/after}{\vskip-1.9ex}
\setlist[enumerate,1]
  {
    label = (\,\arabic*\,), itemindent = 4em, leftmargin = 0em,
    labelsep = 1ex, topsep = 0pt, itemsep = 0pt, partopsep = 0pt,
    parsep = 0em, listparindent = 2\ccwd
  }
\crefformat{figure}{图#2#1#3}
\crefformat{table}{表#2#1#3}

\cs_new_protected:Npn \__hduthesis_cover_spread_box:nn #1#2
  {
    \mode_leave_vertical:
    \hbox_to_wd:nn {#1}
      { \exp_args:Nee \tl_map_inline:nn {#2} { ##1 \hfil } \unskip }
  }
\cs_new_protected:Npn \__hduthesis_cover_center_box:nn #1#2
  { % by @egreg on tex.stackexchange.com
    \mode_leave_vertical:
    \dim_set:Nn \l_tmpa_dim {#1}
    \global\setbox1 = \box\voidb@x
    \group_begin:
    \setbox0 = \vbox
      {
        \dim_set:Nn \hsize {#1}\relax
        \dim_set:Nn \parindent {0pt}
        \skip_set:Nn \leftskip {0pt plus 1fil}
        \skip_set:Nn \rightskip {0pt plus -1fil}
        \skip_set:Nn \parfillskip {0pt plus 2fil}
        #2 \par
        \loop
        \setbox2 = \lastbox
        \unless\ifvoid2
          \global\setbox1 = \vtop
            { \hbox to\hsize{\strut\unhbox2}
              \vskip-4pt \hrule height .5pt
              \vskip9.6pt \unvbox1
            }
          \unskip\unpenalty
        \repeat
      }
    \group_end:
    \box1
  }

\cs_new_protected_nopar:Npn \__hduthesis_process_array:NnnN #1#2#3#4
  {
    \seq_set_split:Nee \l__hduthesis_process_array_seq { / } {#1}
    \seq_set_split:Nee \l__hduthesis_process_array_row_seq { \c_colon_str }
      { \seq_item:Nn \l__hduthesis_process_array_seq {#2} }
    \tl_if_eq:nnTF {#3} {:}
      { \tl_gset:Ne #4 { \seq_use:Nn \l__hduthesis_process_array_row_seq {} } }
      {
        \tl_gset:Ne #4 { \seq_item:Nn \l__hduthesis_process_array_row_seq {#3} }
      }
    \seq_clear:N \l__hduthesis_process_array_seq
    \seq_clear:N \l__hduthesis_process_array_row_seq
  }
\clist_set:Nn \g_system_month_clist
  {
    January, February, March, April, May, June, July,
    August, September, October, November, December
  }
\keys_define:nn { hduthesis / docinfo }
  {
    title .clist_set:N   = \l__docinfo_title_tl,
    department .tl_set:N = \l__docinfo_department_tl,
    major .tl_set:N      = \l__docinfo_major_tl,
    class .tl_set:N      = \l__docinfo_class_tl,
    stdntid .tl_set:N    = \l__docinfo_stdntid_tl,
    author .clist_set:N  = \l__docinfo_author_tl,
    supervisor .tl_set:N = \l__docinfo_supervisor_tl,
    bibsource .tl_set:N  = \l__docinfo_bibsource_tl,
  }
\NewDocumentCommand \DocInfo { m }
  {
    \keys_set:nn { hduthesis / docinfo } {#1}
    \__hduthesis_docinfo_process_aux:  
    \__hduthesis_docinfo_degree_if_aux:  
  }
\cs_set_protected_nopar:Nn \__hduthesis_docinfo_process_aux:
  {
    \__hduthesis_process_array:NnnN \l__docinfo_title_tl {1} {:} \@title
    \__hduthesis_process_array:NnnN \l__docinfo_title_tl {2} {:}
      \l__docinfo_entitle_tl
    \__hduthesis_process_array:NnnN \l__docinfo_author_tl {1} {:} \@author
    \__hduthesis_process_array:NnnN \l__docinfo_author_tl {2} {:}
      \l__docinfo_enauthor_tl
    \__hduthesis_process_array:NnnN \l__docinfo_supervisor_tl {1} {1}
      \l__docinfo_cnrole_tl
    \__hduthesis_process_array:NnnN \l__docinfo_supervisor_tl {1} {2}
      \l__docinfo_cnsupervisor_tl
    \__hduthesis_process_array:NnnN \l__docinfo_supervisor_tl {2} {1}
      \l__docinfo_enrole_tl
    \__hduthesis_process_array:NnnN \l__docinfo_supervisor_tl {2} {2}
      \l__docinfo_ensupervisor_tl
    \bool_if:NF \g__hduthesis_agreement_bool
      { \tl_clear:N \l__docinfo_bibsource_tl }
    \tl_if_empty:NTF \l__docinfo_bibsource_tl
      {
        \newcommand*\printbibliography{\chapter*{参考文献}}
        \renewcommand*\cite[1]{\textsuperscript{[##1]}}
      }
      {
        \RequirePackage[sort&compress]{gbt7714}
        \bibliographystyle{gbt7714-numerical}
        \dim_set:Nn \bibsep {.35ex}
        \newcommand*\printbibliography
          {
            \nocite{*} \bibliography { \l__docinfo_bibsource_tl }
            \addcontentsline{toc}{chapter}{参考文献}
          }
      }
  }

\cs_new_protected_nopar:Npn \__hduthesis_signature_process_aux:nnn #1#2#3
  {
    \clist_set:Nn \l__hduthesis_signature_process_clist {#1}
    \seq_set_split:Nne \l__hduthesis_signature_figure_seq {/}
      { \clist_item:Nn \l__hduthesis_signature_process_clist {#2} }
    \int_compare:nNnTF {#3} = {0}
      {
        \tl_set:Ne \l__hduthesis_signature_figure_tl
          { \seq_item:Nn \l__hduthesis_signature_figure_seq { #3 + 1 } }
        \seq_clear:N \l__hduthesis_signature_figure_seq
      }
      {
        \seq_set_split:Nne \l__hduthesis_signature_date_seq {-}
          { \seq_item:Nn \l__hduthesis_signature_figure_seq {2} }
        \seq_item:Nn \l__hduthesis_signature_date_seq {#3}
        \seq_clear:N \l__hduthesis_signature_date_seq
      }
    \clist_clear:N \l__hduthesis_signature_process_clist
  }

\NewDocumentCommand \signature { m }
  {
    \leavevmode@ifvmode
    \lower \dimexpr \f@size\p@ * 9/16
    \hbox { \includegraphics [ height = { \fp_eval:n {2*\f@size}\p@ } ] {#1} }
  }

\endinput
