%%
%% This is file `hdu-stationery.code.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hduthesis.dtx  (with options: `stationery')
%% -----------------------------------------------------------------------
%%   Copyright (C) 2023-2025 by Mingyu Xia <myhsia@outlook.com>          *
%%                                                                       *
%%   It may be distributed and/or modified under the conditions of the   *
%%   LaTeX Project Public License (LPPL), either version 1.3c of this    *
%%   license or (at your option) any later version. The latest version   *
%%   of this license is in the file                                      *
%%                                                                       *
%%       http://www.latex-project.org/lppl.txt                           *
%%                                                                       *
%%   This work has the LPPL maintenance status `maintained'.             *
%%                                                                       *
%%   The Current Maintainer of this work is Mingyu Xia.                  *
%% -----------------------------------------------------------------------
\__hdu_provide_module:n {stationery}
\keys_define:nn { stationery / hduset }
  {
    watermark   .bool_set:N = \g__hdu_set_watermark_bool,
      watermark .initial:n  = false,
      watermark .default:n  = true,
    title       .tl_set:N   = \l__hdu_set_title_tl,
    author      .tl_set:N   = \l__hdu_set_author_tl,
    mail        .tl_set:N   = \l__hdu_set_mail_tl,
    date        .tl_set:N   = \l__hdu_set_date_tl
  }
\RequirePackage{ hyperref,      geometry, tikz,
                 tikzpagenodes, twemojis, fancyhdr }
\hypersetup{hidelinks}
\urlstyle{same}
\NewDocumentCommand \hduset { m }
  {
    \tl_clear:N \l__hdu_set_author_tl
    \tl_clear:N \l__hdu_set_mail_tl
    \keys_set:nn { stationery / hduset } {#1}
    \hypersetup
      {
        pdftitle = Hangzhou Dianzi University,
        pdfsubject = \l__hdu_set_title_tl,
        pdfauthor = \l__hdu_set_author_tl
      }
  }
\geometry
  { hmargin  = .8in,    top     = 1.95in, bottom   = .75in,
    headheight = 1.2in, headsep = .3in,   footskip = .3in }
\linespread{1.25}
\RequirePackage [ skip = \baselineskip ] { parskip }
\renewcommand* \familydefault { \sfdefault }
\definecolor{hdu}{HTML}{163479}

\renewcommand* \headrulewidth {2pt}
\renewcommand* \footrulewidth {2pt}
\hook_gput_code:nnn { cmd/headrule/before } { . } { \color{hdu!80} }
\hook_gput_code:nnn { cmd/footrule/before } { . } { \color{hdu!80} }
\lhead
  { {}~
    \minipage{.6\linewidth}
      \medskip \leavevmode \lower -.111in
      \hbox { \includegraphics [ height = .75in ] {hdu-badge} }
    \endminipage \medskip \hfill
    \minipage{.36\linewidth}
      \medskip \vbox
        {
          \linespread{1.2}
          \raggedright \small \color{hdu}
          \texttwemoji{1f4cd} ~ 1158 ~ No.2 ~ St., ~ Hangzhou, ~ 310018\\
          \texttwemoji{1f4de} ~ (86) ~ 0571-86915072\\
          \texttwemoji{1f310} ~ \url{www.hdu.edu.cn}
        } \medskip
    \endminipage
  }
\lfoot
  {
    \small{} ~ \texttwemoji{1f4cd} ~
    1158 ~ No.2~Street, ~ Qiantang ~District, ~
    Hangzhou, ~ Zhejiang ~ Province, ~ 310018, ~ P.R.China
  }
\cfoot {}
\rfoot { \small \texttwemoji{1f310} ~ \url{www.hdu.edu.cn} ~ }
\pagestyle{fancy}
\renewcommand* \maketitle
  {
    \group_begin: \small
    \bool_lazy_or:nnT
      { !\tl_if_empty_p:N \l__hdu_set_author_tl }
      { !\tl_if_empty_p:N \l__hdu_set_mail_tl }
      { \makebox [ 4em ] [ l ] { \scshape From } }
    \tl_if_empty:NTF \l__hdu_set_author_tl
      { \@latex@warning@no@line {No \noexpand \author given} }
      { \l__hdu_set_author_tl{} ~ }
    \tl_if_empty:NF \l__hdu_set_mail_tl
      { \texttt { <\l__hdu_set_mail_tl> } }
    \bool_lazy_or:nnT
      { !\tl_if_empty_p:N \l__hdu_set_author_tl }
      { !\tl_if_empty_p:N \l__hdu_set_mail_tl } { \\ }
    \makebox [ 4em ] [ l ] { \scshape Date }
    \tl_if_empty:NTF \l__hdu_set_date_tl \today \l__hdu_set_date_tl \\
    \tl_if_empty:NTF \l__hdu_set_title_tl
      { \@latex@error {No \noexpand \title given}\@ehc }
      {
        \makebox [ 4em ] [ l ] { \scshape Subject }
        \l__hdu_set_title_tl
      }
    \par \vspace{.5\baselineskip}
    \group_end:
  }
\AtBeginDocument { \color_select:n {black!80} }
\DeclareHookRule { shipout / background } { hduthesis / stationery }
  { before } { pgfrcs }
\AddToHook { shipout / background } [ hduthesis / stationery ]
  {
    \bool_if:NT \g__hdu_set_watermark_bool
      {
        \tikz [ remember~picture, overlay ]
          \node [ opacity = .2 ] at (current~page)
            { \includegraphics [ width = .4\linewidth ] {hdu-logo} };
      }
  }
\NewDocumentCommand \notelines {O{20}}
  {
    \tikz [ remember~picture, overlay ]
      {
        \int_step_inline:nn { #1 - 1 }
          {
            \draw [ hdu, very~thick, opacity = .6 ]
              ([
                yshift = -##1 * (\textheight + .6in - 15.87pt ) / #1
                       + .3in
               ]current~page~text~area.north~west
              ) --++ (\linewidth, 0);
          }
      }
  }
%% -----------------------------------------------------------------------
%%   This work consists of the files hduthesis.dtx,                      *
%%                                   hdu-graphics.dtx,                   *
%%                               and hduthesis.ins,                      *
%%             and the derived files hduthesis.cls,                      *
%%                                   hdu-<module>.code.tex,              *
%%                                   beamerthemehdu.sty,                 *
%%                                   hdu-logo.pdf,                       *
%%                                   hdu-title.pdf,                      *
%%                                   hdu-badge.pdf,                      *
%%                                   hdu-motto.pdf,                      *
%%                                   hduthesis.pdf,                      *
%%                                   hdu-graphics.pdf,                   *
%%                               and README.md.                          *
%% -----------------------------------------------------------------------
%%
%% End of file `hdu-stationery.code.tex'.
