\hduthesis_provide_module:n {unv.layout}

\RequirePackage{geometry, array, setspace}

\newcommand\frontmatter
  {
    \clearpage
    \pagenumbering{Roman}
    \cfoot{}
  }
\newcommand\mainmatter
  {
    \clearpage
    \pagenumbering{arabic}
    \cfoot \thepage
  }

\cs_new_protected:Npn \l_spread_box:nn #1#2
  {
    \mode_leave_vertical:
    \hbox_to_wd:nn {#1}
    { \tl_map_inline:Nn {#2} { ##1 \hfil } \unskip }
  }
\cs_new_protected:Npn \l_center_box:nn #1#2
  {
    \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-3.8pt \hrule height .8pt
              \vskip9.6pt \unvbox1
            }
          \unskip\unpenalty
        \repeat
      }
    \group_end:
    \box1
  }

\RequirePackage[skip = 1.75ex, labelsep = quad, font = small]{caption}
\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}

\RequirePackage{enumitem, cleveref}
\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}
\graphicspath
  {
    {./figure/}{./figures/}{./image/}{./images/}
    {./graphics/}{./graphic/}{./pictures/}{./picture/}
  }

\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_clist,
    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_clist,
    supervisor .clist_set:N = \l__docinfo_supervisor_clist,
    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:
  {
    \exp_args:NNne \seq_set_split:Nnn
      \l__title_tmp_seq {/} {\l__docinfo_title_clist}
    \exp_args:NNe \tl_set:Nn
      \l__docinfo_cntitle_tl { \seq_item:Nn \l__title_tmp_seq {1} }
    \exp_args:NNe \tl_set:Nn
      \l__docinfo_entitle_tl { \seq_item:Nn \l__title_tmp_seq {2} }
    \exp_args:NNne \seq_set_split:Nnn
      \l__author_tmp_seq {/} {\l__docinfo_author_clist}
    \exp_args:NNe \tl_set:Nn
      \l__docinfo_cnauthor_tl { \seq_item:Nn \l__author_tmp_seq {1} }
    \exp_args:NNe \tl_set:Nn
      \l__docinfo_enauthor_tl { \seq_item:Nn \l__author_tmp_seq {2} }
    \exp_args:NNne \seq_set_split:Nnn
      \l__supervisor_tmp_seq {/} {\l__docinfo_supervisor_clist}
    \exp_args:NNe \tl_set:Nn
      \l__docinfo_cnsupervisor_tl { \seq_item:Nn \l__supervisor_tmp_seq {1} }
    \exp_args:NNe \tl_set:Nn
      \l__docinfo_ensupervisor_tl { \seq_item:Nn \l__supervisor_tmp_seq {2} }
    \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}{参考文献}
          }
      }
  }

\endinput
