%%
%% This is file `minimalist/minimalist-classical.sty',
%% generated with the docstrip utility.
%%
%% Copyright (C) 2021-2023 by Jinwen XU
%% 
%% This is part of the minimalist class series.
%% 
%% This work may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License, either version 1.3c of this license or (at
%% your option) any later version. The latest version of this license is in
%% 
%%     http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3c or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[2022-06-01]
\ProvidesExplPackage
  {minimalist-classical}
  {2023/01/05} {}
  {The "classical" style of minimalist}

\IfPackageLoadedTF { minimalist } {}
  {
    \msg_new:nnn { \@currname }
      { minimalist-not-loaded }
      { "#1"~is~an~internal~style~of~"minimalist".~To~use~it,~you~must~load~the~package~"minimalist"~first. }
    \msg_warning:nnx { \@currname } { minimalist-not-loaded } { \@currname }
    \endinput
  }

%%================================
%%  Title fonts
%%================================
\RequirePackage { relsize }
\RequirePackage { anyfontsize }

\NewCommandCopy \minimalist_original_bfseries: \bfseries
\bool_new:N \l_minimalist_is_under_bfseries_bool
\bool_set_false:N \l_minimalist_is_under_bfseries_bool
\RenewDocumentCommand \bfseries { }
  {
    \bool_if:NF \l_minimalist_is_under_bfseries_bool
      {
        \colorlet{minimalist-temp-color}{.}
        \color{minimalist-temp-color!70!paper}
      }
    \minimalist_original_bfseries:
    \bool_set_true:N \l_minimalist_is_under_bfseries_bool
  }
\bool_if:NTF \l__minimalist_use_boldface_bool
  {
    \cs_new:Nn \minimalist_bfseries: { \bfseries }
  }
  {
    \cs_new:Nn \minimalist_bfseries: {}
  }

\bool_if:NTF \l__minimalist_use_scshape_bool
  {
    \cs_new:Nn \minimalist_scshape: { \scshape }
  }
  {
    \cs_new:Nn \minimalist_scshape: {}
  }

\tl_new:N \g_minimalist_title_font_common_tl

\tl_new:N \g_minimalist_title_font_part_tl
\tl_new:N \g_minimalist_title_font_chapter_tl
\tl_new:N \g_minimalist_title_font_section_tl
\tl_new:N \g_minimalist_title_font_subsection_tl
\tl_new:N \g_minimalist_title_font_subsubsection_tl
\tl_new:N \g_minimalist_title_font_paragraph_tl

\tl_gset:Nn \g_minimalist_title_font_part_tl          { \minimalist_bfseries: \g_minimalist_title_font_common_tl }
\tl_gset:Nn \g_minimalist_title_font_chapter_tl       { \minimalist_bfseries: \g_minimalist_title_font_common_tl \minimalist_scshape: }
\tl_gset:Nn \g_minimalist_title_font_section_tl       { \minimalist_bfseries: }
\tl_gset:Nn \g_minimalist_title_font_subsection_tl    { \minimalist_bfseries: }
\tl_gset:Nn \g_minimalist_title_font_subsubsection_tl { \minimalist_bfseries: \itshape }
\tl_gset:Nn \g_minimalist_title_font_paragraph_tl     { \minimalist_bfseries: \minimalist_scshape: }

\bool_if:NF \l__minimalist_fast_bool
  {
    \RequirePackage { tikz }
    \ExplSyntaxOff
    \usetikzlibrary{calc,shadings}
    \ExplSyntaxOn
    \RequirePackage { tikzpagenodes } % For `current page text area`
  }

\bool_if:NTF \l__minimalist_fast_bool
  {
    \tl_const:Nn \l_minimalist_sep_bar { $|$ }
  }
  {
    \tl_const:Nn \l_minimalist_sep_bar
      {
        \skip_horizontal:n { .1em }
        \tikz[baseline=.125em] \draw[line~width=.9pt] (0,0) -- (0,.9em);
        \skip_horizontal:n { .1em }
      }
  }

%%================================
%%  Footer
%%================================
\RequirePackage { geometry }
\RequirePackage { fancyhdr }
\RequirePackage { extramarks }

\hook_gput_code:nnn { begindocument/before } { minimalist }
  {
    \fancyhfoffset { 0pt }
  }

\tl_new:N \l_minimalist_leftmark_tl
\tl_new:N \l_minimalist_rightmark_tl

\tl_set:Nn \l_minimalist_leftmark_tl
  {
    \begin{minipage}[t]{.833\textwidth}
      \lastleftmark
    \end{minipage}
  }
\tl_set:Nn \l_minimalist_rightmark_tl
  {
    \begin{minipage}[t]{.833\textwidth}
      \filleft
      \lastrightmark
    \end{minipage}
  }

\fancypagestyle { fancy }
  {
    \fancyhf { }
    \if@twoside
      \fancyfoot[RO]
        {
          \small
          \textcolor { main-text!30!paper } { \l_minimalist_rightmark_tl }
          \nobreakspace \nobreakspace
          \rlap
            {
              \textcolor { main-text!27!paper } { \l_minimalist_sep_bar }
              \nobreakspace \nobreakspace
              \thepage
            }
        }
      \fancyfoot[LE]
        {
          \small
          \leavevmode
          \llap
            {
              \thepage
              \nobreakspace \nobreakspace
              \textcolor { main-text!27!paper } { \l_minimalist_sep_bar }
            }
          \nobreakspace \nobreakspace
          \textcolor { main-text!30!paper } { \l_minimalist_leftmark_tl }
        }
    \else
      \fancyfoot[R]
        {
          \small
          \textcolor { main-text!30!paper } { \l_minimalist_rightmark_tl }
          \nobreakspace \nobreakspace
          \rlap
            {
              \textcolor { main-text!27!paper } { \l_minimalist_sep_bar }
              \nobreakspace \nobreakspace
              \thepage
            }
        }
    \fi
    \renewcommand { \headrulewidth } { 0pt }
  }
\pagestyle { fancy }

\fancypagestyle { plain }
  {
    \fancyhf { }
    \if@twoside
      \fancyfoot[RO]
        {
          \small
          \nobreakspace
          \rlap
            {
              \textcolor { main-text!27!paper } { \l_minimalist_sep_bar }
              \nobreakspace \nobreakspace
              \thepage
            }
        }
      \fancyfoot[LE]
        {
          \small
          \leavevmode
          \llap
            {
              \thepage
              \nobreakspace \nobreakspace
              \textcolor { main-text!27!paper } { \l_minimalist_sep_bar }
            }
        }
    \else
      \fancyfoot[R]
        {
          \small
          \nobreakspace
          \rlap
            {
              \textcolor { main-text!27!paper } { \l_minimalist_sep_bar }
              \nobreakspace \nobreakspace
              \thepage
            }
        }
    \fi
    \renewcommand { \headrulewidth } { 0pt }
  }

\bool_if:NTF \l__minimalist_is_book_bool
  {
    \bool_if:NTF \l__minimalist_fast_bool
      {
        \newcommand{ \minimalist_draw_help_line: }{}
      }
      {
        \newcommand{ \minimalist_draw_help_line: }
          {
            \begin{tikzpicture}[remember~picture,overlay]
              \foreach\i in {0,1,...,5}{
                \fill[opacity=0.12-0.02*\i]
                    ($(current~page~text~area.north~east)+(-\i*0.5em-.025em,-10pt+\i*1.1pt)$)
                      rectangle ($(current~page~text~area.south~east)+(-\i*0.5em+.025em,10pt-\i*1.1pt)$);
                \shade[top~color=paper,bottom~color=main-text,opacity=0.12-0.02*\i]
                    ($(current~page~text~area.north~east)+(-\i*0.5em-.025em,2pt)$)
                      rectangle ($(current~page~text~area.north~east)+(-\i*0.5em+.025em,-10pt+\i*1.1pt)$);
                \shade[top~color=main-text,bottom~color=paper,opacity=0.12-0.02*\i]
                    ($(current~page~text~area.south~east)+(-\i*0.5em-.025em,-2pt)$)
                      rectangle ($(current~page~text~area.south~east)+(-\i*0.5em+.025em,10pt-\i*1.1pt)$);
              }
            \end{tikzpicture}
          }
      }
    \fancypagestyle { part }
      {
        \fancyhf { }
        \renewcommand { \headrulewidth } { 0pt }
        \fancyhead[C] { \minimalist_draw_help_line: }
      }
    \addtolength { \headheight } { 20pt }
    \addtolength { \topmargin } { -20pt }
    \if@twoside
        \renewcommand{\chaptermark}[1]{\markboth{\textsc{#1}}{}}
    \else
        \renewcommand{\chaptermark}[1]{\markboth{\textsc{#1}}{\textsc{#1}}}
    \fi
    \renewcommand*{\sectionmark}[1]{
      \markright{\protect\g_minimalist_section_decoration_char_tl\nobreakspace\thesection\nobreakspace\protect\g_minimalist_section_decoration_char_tl\nobreakspace\nobreakspace\nobreakspace#1}}
  }
  {
    \if@twoside
        \renewcommand*{\sectionmark}[1]{\markboth{\textsc{#1}}{}}
    \else
        \renewcommand*{\sectionmark}[1]{\markboth{\textsc{#1}}{\textsc{#1}}}
    \fi
  }

\renewcommand*{\thefootnote}{\textcolor{main-text!45!paper}{\arabic{footnote}}}

\bool_if:NT \l__minimalist_is_book_bool
  {
    \hook_gput_code:nnn { cmd/frontmatter/before } { minimalist }
      {
        \renewcommand*{\thefootnote}{\textcolor{main-text!45!paper}{\fnsymbol{footnote}}}
      }
    \hook_gput_code:nnn { cmd/mainmatter/before } { minimalist }
      {
        \setcounter{footnote}{0}
        \renewcommand*{\thefootnote}{\textcolor{main-text!45!paper}{\arabic{footnote}}}
      }
  }

%%================================
%%  Title format
%%================================
\RequirePackage [ explicit, newparttoc ] { titlesec }
\PassOptionsToPackage { normalem } { ulem }
\RequirePackage { ulem }

\cs_new:Nn \minimalist_title_numbering_apply_font:n { { \usefont{U}{zeur}{b}{n} #1 } }

\cs_new_protected:Nn \minimalist_apply_title_numbering_style_static:n
  {
    #1
  }


\newcommand{\partstring}{\MakeUppercase{{\partname\nobreakspace\protect\thepart}}}

\AddLanguageSetting
  {
    \renewcommand{\partstring}{\MakeUppercase{{\partname\nobreakspace\protect\thepart}}}
  }
\AddLanguageSetting [ schinese ]
  {
    \renewcommand{\partstring}{第 \zhnumber{\arabic{part}} 部分}
  }
\AddLanguageSetting [ tchinese ]
  {
    \renewcommand{\partstring}{第 \zhnumber{\arabic{part}} 部分}
  }
\AddLanguageSetting [ japanese ]
  {
    \renewcommand{\partstring}{第 \nobreakspace\thepart\nobreakspace 部}
  }


\bool_if:NTF \l__minimalist_is_book_bool
  {
    \setcounter{secnumdepth}{3}

    %% Part
    \titleclass{\part}{top} % make part like a chapter
    \titleformat{\part}[display]
      {\thispagestyle{part}
      \LocallyStopLineNumbers
      \g_minimalist_title_font_part_tl\filleft}
      {\partstring}
      {1em}
      {\fontsize{20}{24}\selectfont\MakeUppercase{#1}}
      [\ResumeLineNumbers]
    \titleformat{name=\part,numberless}[display]
      {\thispagestyle{part}
      \LocallyStopLineNumbers
        % \phantomsection\addcontentsline{toc}{part}{#1}
      \g_minimalist_title_font_part_tl\filleft}
      {\phantom{\MakeUppercase{\partname}}}
      {1em}
      {\fontsize{20}{24}\selectfont\MakeUppercase{#1}}
      [\ResumeLineNumbers]
    \titlespacing*{\part}{0pt}{5em}{6em}
    %% Text after part
    \newcommand{\parttext}[1]{
      \vfill
      \LocallyStopLineNumbers
      \begin{flushright}
        \begin{minipage}{0.833\textwidth}
          \color{main-text!80!paper}\raggedleft#1
        \end{minipage}
      \end{flushright}
      \ResumeLineNumbers
      \vfill\vfill
      \cleardoublepage
    }

    %% Chapter
    \titleformat{\chapter}
      {\thispagestyle{fancy}
      \LocallyStopLineNumbers
      \color{main-text!80!paper}\fontsize{16}{0}\selectfont}{}{0em}
      {\rlap{\hspace*{-.5em}{\color{main-text!12!paper}
        \fontsize{80}{0}\selectfont\raisebox{-7pt}{\thechapter}}} \g_minimalist_title_font_chapter_tl #1}
      [\ResumeLineNumbers]
    \titleformat{name=\chapter,numberless}
      {\thispagestyle{fancy}
      \LocallyStopLineNumbers
        % \phantomsection\addcontentsline{toc}{chapter}{#1}
      \color{main-text!80!paper}\fontsize{16}{0}\selectfont}{}{0em}
      {\rlap{\hspace*{-.5em}{\color{main-text!12!paper}
        \fontsize{80}{0}\selectfont\normalfont\raisebox{-7pt}{*}}} \g_minimalist_title_font_chapter_tl #1}
      [\ResumeLineNumbers]
  }
  {
    %% Part
    \titleformat{\part}[display]
      {\LocallyStopLineNumbers
      \g_minimalist_title_font_part_tl\filleft}
      {\partstring}
      {.3em}
      {\fontsize{16}{0}\selectfont\MakeUppercase{#1}}
      [\ResumeLineNumbers]
    \titleformat{name=\part,numberless}[display]
      {\LocallyStopLineNumbers
        % \phantomsection\addcontentsline{toc}{part}{#1}
      \g_minimalist_title_font_part_tl\filleft}
      {\phantom{\MakeUppercase{\partname}}}
      {.3em}
      {\fontsize{16}{0}\selectfont\MakeUppercase{#1}}
      [\ResumeLineNumbers]
    %% Text after part
    \newcommand{\parttext}[1]{
      \LocallyStopLineNumbers
      \begin{flushright}
        \begin{minipage}{0.833\textwidth}
          \color{main-text!80!paper}\raggedleft#1
        \end{minipage}
      \end{flushright}
      \ResumeLineNumbers
    }
  }

%% Section
\renewcommand\thesection{\arabic{section}}
\newcommand\seculine{\bgroup\markoverwith{\color{main-text!27!paper}
    \rule[-0.9ex]{2pt}{.6pt}\hspace{-2pt}\rule[-1.2ex]{2pt}{.6pt}}\ULon}
\bool_if:NTF \l__minimalist_fast_bool
  {
    \tl_gset:Nn \g_minimalist_section_decoration_char_tl { \raisebox{.03em}{\normalfont/} }
  }
  {
    \tl_gset:Nn \g_minimalist_section_decoration_char_tl
      {
        \tikz[baseline=.125em] \draw[line~width=.9pt] (-.12em,0) -- (.12em,.9em);
      }
  }
\titleformat{\section}
  {\LocallyStopLineNumbers
  \g_minimalist_title_font_section_tl\centering}{}{0em}
  {{\small\textcolor{main-text!27!paper}{\footnotesize \g_minimalist_section_decoration_char_tl }
    \,\,\textcolor{main-text!90!paper}{\minimalist_bfseries:\arabic{section}}
    \,\,\textcolor{main-text!27!paper}{\footnotesize \g_minimalist_section_decoration_char_tl }}\\
    \seculine{#1}}
  [\ResumeLineNumbers]
\titleformat{name=\section,numberless}
  {\LocallyStopLineNumbers
    % \phantomsection\addcontentsline{toc}{section}{#1}
  \g_minimalist_title_font_section_tl\centering}{}{0em}
  {\seculine{#1}}
  [\ResumeLineNumbers]

%% Subsection
\renewcommand\thesubsection{
  \ifnum\c@section=0\else\arabic{section}.\fi\arabic{subsection}}
\newcommand\subseculine{\bgroup\markoverwith{\color{main-text!27!paper}
  \rule[-1ex]{2pt}{.75pt}}\ULon}
\titleformat{\subsection}
  {\LocallyStopLineNumbers
  \g_minimalist_title_font_subsection_tl}{}{0em}
  {\subseculine{\thesubsection\nobreakspace\textcolor{main-text!27!paper}{ \l_minimalist_sep_bar }\nobreakspace #1}}
  [\ResumeLineNumbers]
\titleformat{name=\subsection,numberless}
  {\LocallyStopLineNumbers
  \g_minimalist_title_font_subsection_tl}{}{0em}
  {\subseculine{#1}}
  [\ResumeLineNumbers]

%% Subsubsection
\bool_if:NTF \l__minimalist_runin_bool
  {
    \titleformat{\subsubsection}[runin]
      {\color{main-text!70!paper}\g_minimalist_title_font_subsubsection_tl}
      {\scalebox{0.9}{\thesubsubsection}}{.33em}
      {#1.}[\hspace*{.3em}]
  }
  {
    \titleformat{\subsubsection}
      {\LocallyStopLineNumbers
      \color{main-text!70!paper}\g_minimalist_title_font_subsubsection_tl}
      {\scalebox{0.9}{\thesubsubsection}}{.33em}
      {#1}
      [\ResumeLineNumbers]
  }

%% Paragraph
\titleformat{\paragraph}[runin]
  { \g_minimalist_title_font_paragraph_tl }{\theparagraph}{1em}{#1}

\titlespacing{\section}{0pt}{1\baselineskip plus .5\baselineskip minus .2\baselineskip}{.6\baselineskip plus .3\baselineskip minus .2\baselineskip}
\titlespacing{\subsection}{0pt}{.75\baselineskip plus .3\baselineskip minus .2\baselineskip}{.4\baselineskip plus .2\baselineskip minus .1\baselineskip}
\bool_if:NTF \l__minimalist_runin_bool
  {
    \titlespacing{\subsubsection}{0pt}{.5\baselineskip plus .2\baselineskip minus .1\baselineskip}{0pt}
  }
  {
    \titlespacing{\subsubsection}{0pt}{.5\baselineskip plus .2\baselineskip minus .1\baselineskip}{.3\baselineskip plus .2\baselineskip minus .1\baselineskip}
  }


%%================================
%%  ToC format
%%================================
\RequirePackage { titletoc }
\titlecontents{part}
  [0em]
  {\addvspace{1.5pc}\filcenter\normalfont}
  { \minimalist_apply_title_numbering_style_static:n { \thecontentslabel } \nopagebreak\\\nopagebreak\uppercase}
  {}
  {} % without page number
  [\addvspace{.5pc}]

\bool_if:NTF \l__minimalist_is_book_bool
  {
    \titlecontents{chapter}
      [2em] % i.e., 0em (part) + 2em
      {\addvspace{.5pc}\normalfont}
      {\contentslabel[ \minimalist_apply_title_numbering_style_static:n { \thecontentslabel } ]{2em}}
      {\hspace*{-2em}}
      {\titlerule*[1em]{\textcolor{main-text!15!paper}{.}}\contentspage}
    \titlecontents{section}
      [5em] % i.e., 2em (chapter) + 3em
      {\normalfont}
      {\contentslabel[\textcolor{main-text!27!paper}{\small\g_minimalist_section_decoration_char_tl}\,\textcolor{main-text!90!paper}{ \minimalist_apply_title_numbering_style_static:n { \thecontentslabel } }\,\textcolor{main-text!27!paper}{\small\g_minimalist_section_decoration_char_tl}]{2.75em}}
      {\hspace*{-2.75em}}
      {\titlerule*[1em]{\textcolor{main-text!15!paper}{.}}\contentspage}
    \titlecontents{subsection}
      [8em] % i.e., 5em (section) + 3em
      {\normalfont}
      {\contentslabel[ \minimalist_apply_title_numbering_style_static:n { \thecontentslabel } ]{2.75em}}
      {\hspace*{-2.75em}}
      {\titlerule*[1em]{\textcolor{main-text!15!paper}{.}}\contentspage}
    \titlecontents{subsubsection}
      [12em] % i.e., 8em (subsection) + 4em
      {\normalfont}
      {\contentslabel[ \minimalist_apply_title_numbering_style_static:n { \thecontentslabel } ]{3.75em}}
      {\hspace*{-3.75em}}
      {\titlerule*[1em]{\textcolor{main-text!15!paper}{.}}\contentspage}
  }
  {
    \titlecontents{section}
      [2em] % i.e., 0em (part) + 2em
      {\normalfont}
      {\contentslabel[ \minimalist_apply_title_numbering_style_static:n { \thecontentslabel } ]{1.5em}}
      {\hspace*{-1.5em}}
      {\titlerule*[1em]{\textcolor{main-text!15!paper}{.}}\contentspage}
    \titlecontents{subsection}
      [4.75em] % i.e., 2em (section) + 2.75em
      {\normalfont}
      {\contentslabel[ \minimalist_apply_title_numbering_style_static:n { \thecontentslabel } ]{2.50em}}
      {\hspace*{-2.50em}}
      {\titlerule*[1em]{\textcolor{main-text!15!paper}{.}}\contentspage}
    \titlecontents{subsubsection}
      [8.25em] % i.e., 4.75em (subsection) + 3.5em
      {\normalfont}
      {\contentslabel[ \minimalist_apply_title_numbering_style_static:n { \thecontentslabel } ]{3.25em}}
      {\hspace*{-3.25em}}
      {\titlerule*[1em]{\textcolor{main-text!15!paper}{.}}\contentspage}
  }

%%================================
%%  Lists
%%================================
\RequirePackage { enumitem }
\setlistdepth{10}
\setlist{noitemsep, topsep=.33\topsep-.5\parskip}
\setlist[enumerate]{labelsep=*, leftmargin=*}
\setlist[enumerate,1]{label = \normalfont\arabic*$\mskip-.5mu\big)$,
    ref = \normalfont\color{.!45!paper}\arabic*$\mskip-.5mu\big)$}
\setlist[enumerate,2]{label = \normalfont\emph{\roman*}$\mskip-.5mu\big)$,
    ref = \normalfont\color{.!45!paper}\arabic{enumi}.\emph{\roman*}$\mskip-.5mu\big)$}
\setlist[enumerate,3]{label = \normalfont\emph{\alph*}$\mskip-.5mu\big)$,
    ref = \normalfont\color{.!45!paper}\arabic{enumi}.\emph{\roman{enumii}}.\emph{\alph*}$\mskip-.5mu\big)$}
\setlist[description]{font=\normalfont\minimalist_bfseries:}
\newcommand\desculine{\bgroup\markoverwith{\color{.!55!paper}
  \rule[-.45ex]{2pt}{.75pt}}\ULon}
\renewcommand{\descriptionlabel}[1]{
  \hspace{\labelsep}\normalfont\desculine{#1}
}

\renewlist{itemize}{itemize}{10}
\setlist[itemize]{leftmargin=*,label=\textcolor{.!27!paper}{$\cdot$}}
\AddLanguageSetting { \setlist[itemize,1]{label=\textcolor{.!27!paper}{$\bullet$},leftmargin=\maxof{\parindent}{1.5em}} }
\AddLanguageSetting [french] { \setlist[itemize,1]{label=\textcolor{.!39!paper}{\rule[.2\baselineskip]{.8em}{.75pt}},leftmargin=\maxof{\parindent}{1.5em}} }
\setlist[itemize,2]{label=\textcolor{.!27!paper}{\rule[.2\baselineskip]{.55em}{.75pt}}}
\setlist[itemize,3]{label=\textcolor{.!27!paper}{$\circ$}}
\setlist[itemize,4]{label=\textcolor{.!27!paper}{$\ast$}}

%%================================
%%  Blank page
%%================================
\projlib_langauge_define_multilingual_text:Nn \bl@nkpagetext
  {
    , EN = This~page~is~intentionally~left~blank
    , FR = Cette~page~est~intentionnellement~laissée~vide
    , DE = Diese~Seite~wurde~absichtlich~leer~gelassen
    , IT = Questa~pagina~è~stata~lasciata~vuota~intenzionalmente
    , PT = Esta~página~foi~intencionalmente~deixada~em~branco
    , BR = Esta~página~foi~intencionalmente~deixada~em~branco
    , ES = Esta~página~se~ha~dejado~intencionadamente~en~blanco
    , CN = \ziju{0.2} 此页为有意留为空白
    , TC = \ziju{0.2} 此頁為有意留為空白
    , JP = このページは意図的に空白にしてあります
    , RU = Эта~страница~намеренно~оставлена~пустой
  }
\renewcommand{\cleardoublepage}{
  \relax
  \clearpage
  \if@twoside\ifodd\c@page\relax\else
  \thispagestyle{empty}
  \hook_gput_next_code:nn { shipout/background }
    {
      \put(0.5\paperwidth,-0.5\paperheight){
      \makebox[0pt]{\large\color{main-text!10!paper}\g_minimalist_title_font_common_tl\bl@nkpagetext}}
    }
  \null\newpage\fi\fi
}

%%================================
%%  Index
%%================================
\RequirePackage { imakeidx }
\makeindex[intoc]

\RequirePackage { silence }
\ExplSyntaxOff
\WarningFilter{latex}{Writing or overwriting file}
\begin{filecontents*}[overwrite]{\jobname.mst}
delim_0 "\\IndexDotfill " % Filler between section heading and page number
delim_1 "\\IndexDotfill " % Filler between subsection heading and page number
headings_flag 1
heading_prefix "\\IndexHeading{"
heading_suffix "}\n"
\end{filecontents*}
\ExplSyntaxOn

\projlib_langauge_define_multilingual_text:Nn \index_symbols_name
  {
    , EN = Symbols
    , FR = Symboles
    , DE = Symbole
    , IT = Simboli
    , PT = Símbolos
    , BR = Símbolos
    , ES = Símbolos
    , CN = 符号
    , TC = 符號
    , JP = 記号
    , RU = Символы
  }

\newcommand*{\IndexDotfill}
  {
    \null\nobreak
    \leaders \hbox to .67em {\hss \textcolor{main-text!15!paper}{.} \hss} \hskip1em plus1fill
  }
\newcommand*{\IndexLinebreak}
  {
    \nobreakspace\textcolor{main-text!45!paper}{\raisebox{.4ex}{.}\raisebox{.2ex}{.}}
    \item\hspace*{\hangindent}
    \textcolor{main-text!45!paper}{\raisebox{.45ex}{.}\raisebox{.25ex}{.}}\:
    \unskip
  }

\newcommand*{\IndexHeading}[1]
  {
    \str_if_eq:nnTF { #1 } { Symbols }
      { \tl_set:Nn \l_tmpa_tl { \index_symbols_name } }
      { \tl_set:Nn \l_tmpa_tl { #1 } }
    \centerline{ \g_minimalist_title_font_common_tl \minimalist_apply_title_numbering_style_static:n { \l_tmpa_tl } }
    \nopagebreak
    \par
    \vspace{.3\baselineskip}
  }

\renewcommand*{\indexspace}
  {
    \par
    \vspace{2pc plus .5pc minus .3pc}
  }

\bool_new:N \l__minimalist_if_first_subitem_bool
\renewcommand*{\@idxitem}
  {
    \par\hangindent40\p@
    \bool_set_true:N \l__minimalist_if_first_subitem_bool
  }
\renewcommand*{\subitem}
  {
    \par\hangindent40\p@
    \bool_if:NT \l__minimalist_if_first_subitem_bool
      {
        \nobreak
        \bool_set_false:N \l__minimalist_if_first_subitem_bool
      }
    \hspace*{20\p@}
  }

\hook_gput_code:nnn { begindocument/before } { minimalist }
  {
    \bool_if:NF \l__minimalist_fast_bool
      {
        \hook_gput_code:nnn { cmd/printindex/before } { minimalist } { \bookmarksetup{startatroot} }
      }
    \hook_gput_code:nnn { cmd/printindex/before } { minimalist } { \LocallyStopLineNumbers }
    \hook_gput_code:nnn { cmd/printindex/after } { minimalist } { \ResumeLineNumbers }
  }

%%================================
%%  Draft mark
%%================================
\RequirePackage { projlib-draft }

%%================================
%%  Theorems
%%================================
\RequirePackage { mathtools }
\RequirePackage { amsthm }

\def\tagform@#1{\maketag@@@{\textcolor{main-text!39!paper}{(\ignorespaces#1\unskip\@@italiccorr)}}}

\PassOptionsToPackage { nopatch = eqnum } { microtype }

\def\simpleqedsymbol{
  \makebox[1em]{\rlap{\textcolor{main-text!12!paper}{\rule[-0.1em]{.95em}{.95em}}}{\kern.07em\raisebox{.07em}{\textcolor{paper}{\rule[-0.1em]{.81em}{.81em}}}\kern.07em}}}
\bool_if:NTF \l__minimalist_theorem_in_new_line_bool
  {
    \newtheoremstyle{simple}
      {.5\baselineskip}{.5\baselineskip}
      {\normalfont}{}
      {\normalfont}{}
      {\newline}
      { \global\let\qedsymbol\simpleqedsymbol
        \rlap{\vbox{\hbox{\parbox{\linewidth}{
          {\thmname{#1}\thmnumber{\nobreakspace #2}}
          \thmnote{\hspace{.4em}\textcolor{main-text!27!paper}{ \l_minimalist_sep_bar }\hspace{.4em}\color{main-text!50!paper}$($#3$)$}
        }}\hbox{\strut}\vspace{0pt}}}\vspace{-2\parskip}
        \pushQED{\qed}
      }
  }
  {
    \newtheoremstyle{simple}
      {.5\baselineskip}{.5\baselineskip}
      {\normalfont}{}
      {\normalfont}{}
      {0pt}
      { \global\let\qedsymbol\simpleqedsymbol
        {\thmname{#1}\thmnumber{\nobreakspace #2}}\hspace{.4em}
        \textcolor{main-text!27!paper}{ \l_minimalist_sep_bar }\hspace{.4em}
        \color{main-text!50!paper}\thmnote{$($#3$)$\nobreakspace\nobreakspace}
        \pushQED{\qed}
      }
  }
\def\@endtheorem{\global\let\qedsymbol\simpleqedsymbol
  \popQED\endtrivlist\@endpefalse
  \global\let\qedsymbol\qedsymbolOriginal}

\theoremstyle{simple}

\newcommand{\customqedsymbol}{
  \makebox[1em]{\color{.!27!paper}\rule[-0.1em]{.95em}{.95em}}}
\let\qedsymbol\customqedsymbol

\bool_if:NTF \l__minimalist_fast_bool
  {
    \RequirePackage { hyperref }
    \hypersetup { draft }
  }
  {
    \RequirePackage { hyperref }
    \RequirePackage { bookmark }
    \hypersetup{ hidelinks, linktoc = all }
    \bookmarksetup{ numbered }
    \renewcommand\Hy@numberline[1]{#1.~}
    % https://tex.stackexchange.com/a/1821
    % Add the bookmark of ToC
    \hook_gput_code:nnn { cmd/tableofcontents/before } { minimalist }
      {
        \if@openright\cleardoublepage\else\clearpage\fi
        \pdfbookmark[0]{\contentsname}{toc}
      }
  }



\RequirePackage { projlib-theorem }

\SetTheorem { proof, proof* } { qed-symbol = { \customqedsymbol } }



\exp_args:No \SetTheorem { \c_projlib_theorem_supported_clist, theorem-with-name }
  {
    name style = {
      , heading style = {
          , english = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
          , french = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
          , ngerman = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
          , italian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
          , portuguese = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
          , brazilian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
          , spanish = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
          , schinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
          , tchinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
          , japanese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
          , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl
        }
    }
  }

\SetTheorem { remark }
  {
    name style = {
      , heading style = {
          , english = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
          , french = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
          , ngerman = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
          , italian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
          , portuguese = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
          , brazilian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
          , spanish = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
          , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
          , schinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
          , tchinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
          , japanese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
          , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl
        }
    }
  }

\bool_if:NF \l__projlib_theorem_complexname_bool
  {
    \exp_args:No \SetTheorem { \c_projlib_theorem_supported_clist, theorem-with-name }
      {
        name style = {
          , crefname style = {
              , english = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , french = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , ngerman = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , italian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , portuguese = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , brazilian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , spanish = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , schinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , tchinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , japanese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl
            }
          , Crefname style = {
              , english = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , french = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , ngerman = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , italian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , portuguese = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , brazilian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , spanish = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textsc
              , schinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , tchinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , japanese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl
            }
          , numbering style = {
              \minimalist_bfseries:\g_minimalist_title_font_common_tl
            }
        }
      }

    \SetTheorem { remark }
      {
        name style = {
          , crefname style = {
              , english = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , french = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , ngerman = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , italian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , portuguese = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , brazilian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , spanish = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , schinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , tchinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , japanese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl
            }
          , Crefname style = {
              , english = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , french = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , ngerman = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , italian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , portuguese = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , brazilian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , spanish = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl\textit
              , schinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , tchinese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , japanese = \minimalist_bfseries:\g_minimalist_title_font_common_tl
              , russian = \minimalist_bfseries:\g_minimalist_title_font_common_tl
            }
          , numbering style = {
              \minimalist_bfseries:\g_minimalist_title_font_common_tl
            }
        }
      }
  }

\PassOptionsToPackage { many } { tcolorbox }
\RequirePackage { tcolorbox }
\bool_if:NT \l__minimalist_fast_bool { \tcbstartdraftmode }


\NewDocumentEnvironment { emphasis } { }
  {
    \LocallyStopLineNumbers
    \enlargethispage{2mm}
    \begin{tcolorbox}
        [
          enhanced ~ jigsaw, breakable, oversize,
          % nobeforeafter,
          left = .5em, right=0mm, top=0.5mm, bottom=0mm, boxrule=0pt,
          colback = paper, frame ~ hidden,
          borderline ~ west = {.125em} {-.5mm} {main-text!25!paper, double, double ~ distance=.1em},
          arc = 0.2mm,
        ]
  }
  {
    \end{tcolorbox}
    \ResumeLineNumbers
  }


%%================================
%%  Title block style
%%================================
\bool_if:NTF \l__minimalist_is_book_bool
  {
    \hook_gput_code:nnn { package/projlib-author/after } { minimalist }
      {
        \tl_gset:Nn \g__projlib_author_font_author_tl      { \normalfont \minimalist_scshape: }
        \tl_gset:Nn \g__projlib_author_font_institute_tl   { \large \normalfont }
        \tl_gset:Nn \g__projlib_author_font_address_tl     { \large \normalfont \itshape }
        \tl_gset:Nn \g__projlib_author_font_curraddr_tl    { \large \normalfont \itshape }
        \tl_gset:Nn \g__projlib_author_font_email_tl       { \large \normalfont \ttfamily }
      }

    \RequirePackage { projlib-titlepage }
    \renewcommand{\maketitle}{
      \LocallyStopLineNumbers
      \ProjLibTitlePage [ style = simple ]
        {
          , title  = \@title
          , author = \@author
          , date   = \@date
        }
      \ResumeLineNumbers
    }
  }
  {
    \renewcommand{\@maketitle}
      {
        \LocallyStopLineNumbers
        \noindent
        {\textcolor{main-text!27!paper}{\rule{\textwidth}{0.75pt}}}
        % \vspace{-\parskip}
        \vspace{-.5\baselineskip}
        \begin{flushright}
          \let\footnote\thanks
          {\minimalist_bfseries:\@title}\\\medskip
          \color{main-text!80!paper}
          {\small\minimalist_scshape:\@author}
          \par\vspace{-\parskip}\vspace{2pt}
          {\small\@date}
        \end{flushright}
        \vspace{-.5\baselineskip}
        \projlib_author_if_content_empty:nTF { \@date }
          {
            \vspace{-.2\baselineskip}
          }
          {
            \vspace{-.5\baselineskip}
          }
        {\textcolor{main-text!27!paper}{\rule{\textwidth}{0.75pt}}\par}
        \ResumeLineNumbers
      }

    \hook_gput_code:nnn { cmd/maketitle/after } { minimalist } { \thispagestyle{fancy} }

%%================================
%%  Abstract style
%%================================
    \renewenvironment{abstract}
      {
        \LocallyStopLineNumbers
        \begin{flushright}
          { \g_minimalist_title_font_section_tl \minimalist_scshape: \small\abstractname}\par
          \vspace{-\parskip}
          \vspace{-.25\baselineskip}
          \begin{minipage}[t]{.833\textwidth}
            \vspace{0pt}
            \color{main-text!80!paper}
            \footnotesize
            \parindent=2em
      }
      {
          \end{minipage}
        \end{flushright}
        \bigskip
        \ResumeLineNumbers
      }

%%================================
%%  Keyword environment
%%================================
    \DefineMultilingualText { \keywordname }
      {
        EN = Keywords                               ,
        FR = Mots~clés                              ,
        DE = Schlüsselwörter                        ,
        IT = Parole~chiave                          ,
        PT = Palavras~chave                         ,
        BR = Palavras~chave                         ,
        ES = Palabras~clave                         ,
        CN = 关键词                                 ,
        TC = 關鍵詞                                 ,
        JP = キーワード                             ,
        RU = Ключевые~слова                         ,
      }

    \newenvironment{keyword}{
      \LocallyStopLineNumbers
      \vspace{-.5\baselineskip}
      \begin{flushright}
        {\minimalist_bfseries:\minimalist_scshape:\small\keywordname}\par
        \vspace{-\parskip}
        \vspace{-.30\baselineskip}
        \begin{minipage}[t]{.833\textwidth}
          \vspace{0pt}
          \color{main-text!80!paper}
          \footnotesize
          \parindent=2em
          \raggedleft
    }{
        \end{minipage}
      \end{flushright}
      \bigskip
      \ResumeLineNumbers
    }
  } % end of \bool_if:NTF \l__minimalist_is_book_bool

%%================================
%%  Simulate features of amsart
%%================================
\PassOptionsToPackage { amsfashion } { projlib-author }
\RequirePackage { projlib-author }

%%================================
%%  Special adjustment
%%================================
\crefformat { chapter } { \nobreak \crefthemark { \crefthe_retrieve_space: } \nobreak #2 \minimalist_apply_title_numbering_style_static:n {#1} #3 }
\labelcrefformat { chapter } { #2 \minimalist_apply_title_numbering_style_static:n {#1} #3 }
\crefformat { section } { \nobreak \crefthemark { \crefthe_retrieve_space: } \nobreak #2 \minimalist_apply_title_numbering_style_static:n {#1} #3 }
\labelcrefformat { section } { #2 \minimalist_apply_title_numbering_style_static:n {#1} #3 }
\crefformat { subsection } { \nobreak \crefthemark { \crefthe_retrieve_space: } \nobreak #2 \minimalist_apply_title_numbering_style_static:n {#1} #3 }
\labelcrefformat { subsection } { #2 \minimalist_apply_title_numbering_style_static:n {#1} #3 }
\crefformat { subsubsection } { \nobreak \crefthemark { \crefthe_retrieve_space: } \nobreak #2 \minimalist_apply_title_numbering_style_static:n {#1} #3 }
\labelcrefformat { subsubsection } { #2 \minimalist_apply_title_numbering_style_static:n {#1} #3 }

\endinput
%%
%% End of file `minimalist/minimalist-classical.sty'.
