%%
%% This is file `hdu-exam.code.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hduthesis.dtx  (with options: `exam')
%% -----------------------------------------------------------------------
%%   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 {exam}
\keys_define:nn { hduthesis / exam }
  {
    watermark .tl_set:N = \l__hdu_exam_watermark_tl,
  }
\NewDocumentCommand \hdutexset {m} { \keys_set:nn { hduthesis / exam } {#1} }
\DeclareHookRule { shipout / background }
  { hduthesis / exam } { before } { pgfrcs }
\AddToHook { shipout / background } [ hduthesis / exam ]
  {
    \tl_if_empty:NF \l__hdu_exam_watermark_tl
      {
        \tikz [ remember~picture, overlay ]
          \node [ opacity = .2 ] at (current~page)
            {
              \includegraphics [ width = \linewidth ]
                { \l__hdu_exam_watermark_tl }
            };
      }
  }
\RequirePackage
  {
    geometry, mathtools, array, bm, esint, keytheorems,
    siunitx, fixdif, derivative, physics2, tasks, anyfontsize
  }
\RequirePackage[inline]{enumitem}
\RequirePackage{fontawesome5, fancyqr, circuitikz}
\hook_gput_code:nnn { cmd/faIcon/before } { . }
  {
    \group_begin:
    \fontsize { \fp_eval:n { .9 * \f@size } } { 0 } \selectfont
  }
\hook_gput_code:nnn { cmd/faIcon/after } { . } { \group_end: }
\geometry{margin = 1in}
\RequirePackage[svgnames]{xcolor}
\newkeytheorem{note}
  [ style = remark, numbered = false,
    name = \color{DarkRed}\sffamily \faIcon{info-circle}~Tip. ]
\newkeytheorem{problem}
  [ style = definition,
    name = \color{DarkGreen}\sffamily \faIcon{pen-square}~Problem ]
\newkeytheorem{solution}
  [ style = definition, numbered = false,
    name = \color{MidnightBlue}\sffamily \faIcon{check-square}~Solution ]
\usephysicsmodule{ab, op.legacy}
\settasks { label = \sffamily\Alph*., item-indent = 2.5em, label-offset = .5pt }
\newcommand \true {\addtocounter{task}{1}\faIcon{check-circle}}
\def \@result#1 {\underline{~#1~}}
\def \s@result {\textsf{【\qquad 】}}
\DeclareRobustCommand \result {\@ifstar\s@result\@result}
\keys_define:nn { textfig }
  {
    ratio      .tl_set:N    = \l__hdu_textfig_ratio_tl,
      ratio    .initial:n   = 7 \c_colon_str 2,
    position   .tl_set:N    = \l__hdu_textfig_position_tl,
      position .initial:n   = c,
    unknown    .code:n      = \tl_if_novalue:nF {#1}
      { \tl_set_eq:NN \l__hdu_textfig_position_tl \l_keys_key_tl }
  }
\NewDocumentEnvironment{textfig}{ O{} }
  {
    \group_begin:
    \keys_set:nn { textfig } {#1}
    \seq_set_split:Nee \l__hdu_textfig_ratio_seq { \c_colon_str }
      { \l__hdu_textfig_ratio_tl }
    \noindent
    \minipage [ \l__hdu_textfig_position_tl ]
      {
        \fp_eval:n
          {
            .96*\seq_item:Nn \l__hdu_textfig_ratio_seq {1}/
              (
                \seq_item:Nn \l__hdu_textfig_ratio_seq {1} +
                \seq_item:Nn \l__hdu_textfig_ratio_seq {2}
              )
          }\dimexpr \linewidth
      }
  }
  {
    \endminipage
    \vspace{4.5pt plus 1.5pt minus 1.5pt} \par
    \group_end:
  }
\NewDocumentCommand \textfigsplit {}
  {
    \endminipage
    \hspace{.02\linewidth}
    \minipage [ \l__hdu_textfig_position_tl ]
      {
        \fp_eval:n
          {
            .96*\seq_item:Nn \l__hdu_textfig_ratio_seq {2}/
              (
                \seq_item:Nn \l__hdu_textfig_ratio_seq {1} +
                \seq_item:Nn \l__hdu_textfig_ratio_seq {2}
              )
          }\dimexpr \linewidth
      }
  }

\makeatother \ExplSyntaxOff
\usetikzlibrary{ fadings, patterns, arrows, decorations.markings }
\tikzset
  {
    > = stealth',
    every picture/.append style =
      { line join = round, line cap = round, thick }
  }
%% -----------------------------------------------------------------------
%%   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-exam.code.tex'.
