%%
%% This is file `colorist/colorist.sty',
%% generated with the docstrip utility.

%% Copyright (C) 2021 by Jinwen XU
%% 
%% This is part of the colorist 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}[2020-10-01]
\ProvidesPackage{colorist}
    [2021/05/24 A colorful style for articles and books]
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
\SetupKeyvalOptions{%
    family = @colorist,
    prefix = @colorist@
}
\DeclareBoolOption[false]{draft}
\DeclareBoolOption[false]{fast}
\DeclareBoolOption[false]{allowbf}
\ProcessKeyvalOptions*\relax

\if@colorist@draft
  \@colorist@fasttrue
\fi

\if@colorist@allowbf
    \newcommand{\conditionalbfseries}{\bfseries\colorlet{PJLtempcolor}{.}\color{PJLtempcolor!90!paper}}
\else
    \newcommand{\conditionalbfseries}{}
\fi

\newif\ifIsBook
\ifdefined\chapter\IsBooktrue\else\IsBookfalse\fi

%%================================
%% Title fonts
%%================================
\RequirePackage{anyfontsize}
\newcommand{\partfont}{\conditionalbfseries\sffamily}
\newcommand{\chapfont}{\conditionalbfseries\sffamily}
\newcommand{\secfont}{\conditionalbfseries\sffamily}
\newcommand{\subsecfont}{\conditionalbfseries\sffamily}
\newcommand{\subsubsecfont}{\conditionalbfseries\sffamily}

%%================================
%% Paper configuration
%%================================
\RequirePackage{PJLpaper}

%%================================
%% Color
%%================================
\definecolor{maintheme}{RGB}{70,130,180}
\definecolor{forestgreen}{RGB}{21,122,81}
\definecolor{lightorange}{RGB}{255,185,88}

%%================================
%% Footer
%%================================
\RequirePackage{geometry}
\RequirePackage{fancyhdr}
\RequirePackage{extramarks}
\AtEndPreamble{\fancyhfoffset{0pt}}
\fancypagestyle{fancy}{
    \fancyhf{}
    \if@twoside
        \fancyfoot[RO]{\small\textcolor{black!30!paper}{\lastrightmark}%
            ~~\rlap{\textcolor{gray!55!paper}{$|$}~~\thepage}}
        \fancyfoot[LE]{\small\leavevmode\llap{\thepage%
            ~~\textcolor{gray!55!paper}{$|$}}%
            ~~\textcolor{black!30!paper}{\lastleftmark}}
    \else
        \fancyfoot[R]{\small\textcolor{black!30!paper}{\lastrightmark}%
            ~~\rlap{\textcolor{gray!55!paper}{$|$}~~\thepage}}
    \fi
    \renewcommand{\headrulewidth}{0pt}
}
\pagestyle{fancy}
\fancypagestyle{plain}{
    \fancyhf{}
    \if@twoside
        \fancyfoot[RO]{\small%
            ~\rlap{\textcolor{gray!55!paper}{$|$}~~\thepage}}
        \fancyfoot[LE]{\small\leavevmode\llap{\thepage%
            ~~\textcolor{gray!55!paper}{$|$}}}
    \else
        \fancyfoot[R]{\small%
            ~\rlap{\textcolor{gray!55!paper}{$|$}~~\thepage}}
    \fi
    \renewcommand{\headrulewidth}{0pt}
}
\ifbool{IsBook}{
    \if@twoside
        \renewcommand{\chaptermark}[1]{\markboth{\textsc{#1}}{}}
    \else
        \renewcommand{\chaptermark}[1]{\markboth{\textsc{#1}}{\textsc{#1}}}
    \fi
    \renewcommand*{\sectionmark}[1]{%
        \markright{\thesection~~#1}}
}{
    \if@twoside
        \renewcommand*{\sectionmark}[1]{\markboth{\textsc{#1}}{}}
    \else
        \renewcommand*{\sectionmark}[1]{\markboth{\textsc{#1}}{\textsc{#1}}}
    \fi
}
%%================================
%% Line spacing
%%================================
\RequirePackage{PJLlang}
\PJLsetlinespacing{\setstretch{1.07}}
\PJLsetCJKlinespacing{\onehalfspacing}
\raggedbottom

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

\newcommand{\partstring}{\MakeUppercase{{\partname~\protect\thepart}}}
\gappto{\PJLlang@langconfig@common}{%
\renewcommand{\partstring}{\MakeUppercase{{\partname~\protect\thepart}}}%
}
\gappto{\PJLlang@langconfig@chinese}{%
\renewcommand{\partstring}{第~\thepart~部分}%
}
\gappto{\PJLlang@langconfig@tchinese}{%
\renewcommand{\partstring}{第~\thepart~部分}%
}
\gappto{\PJLlang@langconfig@japanese}{%
\renewcommand{\partstring}{第~\thepart~部}%
}

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

    %% Chapter
    \newlength{\colorist@chapboxwidth}

    \newcommand{\MakeChapBox}[2]{%
        \settowidth{\colorist@chapboxwidth}{#1}
        \begin{tcolorbox}[
            enhanced,
            skin = bicolor,
            frame engine = path,
            sharp corners = all,
            width = 0.9\textwidth,
            top = 4mm, bottom = 4mm,
            sidebyside,
            frame hidden,
            boxrule = 0mm,
            lefthand width = 1.5\colorist@chapboxwidth,
            colupper = white,
            colback = maintheme!80!paper,
            colbacklower = maintheme!20!paper,
            sidebyside align=center,
            halign=center]
            \Huge #1%
            \tcblower%
            #2%
        \end{tcolorbox}%
    }

    \newcommand{\MakeChapBoxSingle}[1]{%
        \begin{tcolorbox}[
            enhanced,
            width = 0.7\textwidth,
            sharp corners = all,
            top = 4mm, bottom = 4mm,
            frame hidden,
            boxrule = 0mm,
            colback = maintheme!20!paper,
            halign=center]
            #1
        \end{tcolorbox}
    }

    \titleformat{name=\chapter}
        {\filright\chapfont\huge} % Format
        {} % Label
        {0mm} % Sep
        {\MakeChapBox{\thechapter}{#1}} % Before-code
    \titlespacing*{name=\chapter}
        {0em}{*2}{0em} % {left}{before-sep}{after-sep}

    \titleformat{name=\chapter, numberless}
        {\filcenter\chapfont\huge} % Format
        {} % Label
        {0mm} % Sep
        {\MakeChapBoxSingle{#1}} % Before-code
    \titlespacing*{name=\chapter, numberless}
        {0em}{*2}{0em} % {left}{before-sep}{after-sep}

    %% Section
    \titleformat{\section}
    {\color{maintheme}\secfont\large}
    {\thesection}{.75em}{#1}
    % [{\titlerule[.75pt]}]

    %% Subsection
    \titleformat{\subsection}
    {\subsecfont}{\thesubsection}{.75em}
    {#1}
}{
    %% Part
    \titleformat{\part}[display]
        {%
        \partfont\filleft}
        {\partstring}
        {.3em}
        {\fontsize{16}{0}\selectfont\MakeUppercase{#1}}
    \titleformat{name=\part,numberless}[display]
        {% \phantomsection\addcontentsline{toc}{part}{#1}%
        \partfont\filleft}
        {\phantom{\MakeUppercase{\partname}}}
        {.3em}
        {\fontsize{16}{0}\selectfont\MakeUppercase{#1}}
    %% Text after part
    \newcommand{\parttext}[1]{%
        \begin{flushright}%
            \begin{minipage}{0.833\textwidth}%
                \color{black!80!paper}\raggedleft#1%
            \end{minipage}%
        \end{flushright}%
    }

    %% Section
    \titleformat{\section}
    {\color{maintheme}\secfont\large}
    {\thesection}{.75em}{\scshape #1}
    % [{\titlerule[.75pt]}]

    %% Subsection
    \titleformat{\subsection}
    {\subsecfont}{\thesubsection}{.75em}
    {\scshape #1}
}

%% Subsubsection
\titleformat{\subsubsection}
    {\color{paper!30!-paper}\subsubsecfont}{\thesubsubsection}{.5em}
    {#1}

\titlespacing{\section}{0pt}{\baselineskip}{.6\baselineskip}
\titlespacing{\subsection}{0pt}{.75\baselineskip}{.4\baselineskip}
\titlespacing{\subsubsection}{0pt}{.5\baselineskip}{.2\baselineskip}

%%================================
%% TOC format
%%================================
\RequirePackage{titletoc}
\titlecontents{part}
    [0em]
    {\addvspace{1.5pc}\filcenter\sffamily}
    {\thecontentslabel\\\uppercase}
    {}
    {} % without page number
    [\addvspace{.5pc}]
\ifbool{IsBook}{
    \titlecontents{chapter}
        [2em] % i.e., 0em (part) + 2em
        {\addvspace{1pc}\normalfont\color{maintheme}\sffamily\conditionalbfseries}
        {\contentslabel{2em}}
        {\hspace*{-2em}}
        {\titlerule*[1em]{\textcolor{gray!30!paper}{.}}\color{maintheme}\contentspage}
    \titlecontents{section}
        [4em] % i.e., 2em (chapter) + 2em
        {\addvspace{.3pc}\normalfont\color{maintheme}\sffamily}
        {\contentslabel{1.75em}}
        {\hspace*{-1.75em}}
        {\titlerule*[1em]{\textcolor{gray!30!paper}{.}}\color{maintheme}\contentspage}
    \titlecontents{subsection}
        [7em] % i.e., 4em (section) + 3em
        {\addvspace{.15pc}\normalfont\sffamily}
        {\contentslabel{2.75em}}
        {\hspace*{-2.75em}}
        {\titlerule*[1em]{\textcolor{gray!30!paper}{.}}\color{paper!55!-paper}\contentspage}
}{
    \titlecontents{section}
        [2em] % i.e., 0em (part) + 2em
        {\addvspace{.3pc}\normalfont\color{maintheme}\sffamily}
        {\contentslabel{1.75em}}
        {\hspace*{-1.75em}}
        {\titlerule*[1em]{\textcolor{gray!30!paper}{.}}\color{maintheme}\contentspage}
    \titlecontents{subsection}
        [5em] % i.e., 2em (section) + 3em
        {\addvspace{.15pc}\normalfont\sffamily}
        {\contentslabel{2.75em}}
        {\hspace*{-2.75em}}
        {\titlerule*[1em]{\textcolor{gray!30!paper}{.}}\color{paper!55!-paper}\contentspage}
}

%%================================
%% Lists
%%================================
\RequirePackage{enumitem}
\setlist{noitemsep,leftmargin=2em}
\renewcommand\labelitemi{\color{gray!50}$\bullet$}
\renewcommand\labelitemii{\color{gray!55}--}
\renewcommand\labelitemiii{\color{gray!55}\texttt{*}}

%%================================
%% Blank page
%%================================
\newcommand{\blinkpagetext}{This page is intentionally left blank}
\renewcommand{\cleardoublepage}{\relax
    \clearpage
    \if@twoside\ifodd\c@page\relax\else
    \thispagestyle{empty}
    \AddToHookNext{shipout/background}
      {%
       \put(0.5\paperwidth,-0.5\paperheight){%
       \makebox[0pt]{\large\color{gray!20!paper}\blinkpagetext}}}
    \null\newpage\fi\fi}

%%================================
%% Draft mark
%%================================
\RequirePackage{PJLdraft}

%%================================
%% Icons
%%================================
\RequirePackage{tikz}
\newcommand{\ideabulb}[2][0.15]{%
    \scalebox{#1}{%
    \begin{tikzpicture}
        \filldraw[draw=#2,fill=#2] (0,0) circle [radius=1cm];
        \filldraw[draw=paper,fill=paper,rounded corners=0.8pt]
            [rotate=20] (-0.26,-0.66) rectangle (-0.06,-0.6)
            [xshift=-0.4mm,yshift=1mm] (-0.26,-0.66) rectangle (0.02,-0.6)
            [xshift=0.4mm,yshift=1mm] (-0.26,-0.66) rectangle (-0.06,-0.6);
        \draw[draw=paper,line width=0.7mm] (-0.18,-0.46)
            .. controls (-0.18,-0.28) and (-0.28,-0.12) ..(-0.4,0.1)
            .. controls (-0.55,0.4) and (-0.3,0.64) ..(0,0.64)
            .. controls (0.3,0.64) and (0.55,0.4) ..(0.4,0.1)
            .. controls (0.28,-0.12) and (0.18,-0.28) ..(0.18,-0.46);
    \end{tikzpicture}}}

\newcommand{\questionmark}[2][0.15]{%
    \scalebox{#1}{%
    \begin{tikzpicture}
        \filldraw[draw=#2,fill=#2] (0,0) circle [radius=1cm];
        \filldraw[paper,yshift=0.5mm,scale=0.9] (-0.4,0.1) circle [radius=0.77mm];
        \draw[draw=paper,line width=1.5mm,yshift=0.5mm,scale=0.9] (-0.4,0.1)
            .. controls (-0.55,0.4) and (-0.3,0.64) ..(0,0.64)
            .. controls (0.3,0.64) and (0.55,0.4) ..(0.4,0.1)
            .. controls (0.28,-0.12) and (0.05,-0.28) ..(0.05,-0.3)
            .. controls (0,-0.36) and (0.0,-0.45) ..(0.0,-0.5);
        \fill[fill=paper,rounded corners=0.6mm]
            (-0.09,-0.75) rectangle (0.09,-0.53);
    \end{tikzpicture}}}

%%================================
%% Theorems
%%================================
\RequirePackage{mathtools}
\RequirePackage{amsthm}
\newtheoremstyle{simple}%
    {}{}%
    {\normalfont}{}%
    {\normalfont}{}%
    {0pt}%
    {\conditionalbfseries\thmname{#1}\thmnumber{ #2}\hspace{.4em}%
        \textcolor{gray!55!paper}{$|$}\hspace{.4em}%
        \color{gray}\thmnote{\ensuremath{(\text{#3})}~~}\pushQED{\qed}}
\def\@endtheorem{\popQED\endtrivlist\@endpefalse }

\renewcommand{\qedsymbol}{%
    \makebox[1em]{\color{gray!55!paper}\rule[-0.1em]{.95em}{.95em}}}

\newtheoremstyle{basic}
    {0pt}{0pt}{\normalfont}{0pt}
    {}{\;}{0.25em}
    {{\thmname{#1}~\thmnumber{\textup{#2}}}
    \thmnote{\normalfont\sffamily\color{black}~(#3)}}

\newtheoremstyle{emphasis}
    {0pt}{0pt}{\itshape}{0pt}{}{}{0pt}
    {\thmnote{\normalfont\sffamily\color{black}#3\hspace*{0.5em}}}

\if@colorist@fast
    \providecommand{\phantomsection}{}
    \RequirePackage{url}
    \newcommand{\href}[2]{#2}
\else
    \PassOptionsToPackage{hidelinks,linktoc=all}{hyperref}
    \RequirePackage{bookmark}
    \RequirePackage{hyperref}
\fi

\RequirePackage[nothms]{PJLthm}

%% Redefine English theorems names
\def\theoremnameEN{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Theorem}}
\def\lemmanameEN{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Lemma}}
\def\propositionnameEN{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Proposition}}
\def\corollarynameEN{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Corollary}}
\def\propertynameEN{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Property}}
\def\factnameEN{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Fact}}
\def\conjecturenameEN{\normalfont\sffamily\color{purple}\conditionalbfseries\textsc{Conjecture}}
\def\definitionnameEN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Definition}}
\def\axiomnameEN{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Axiom}}
\def\assumptionnameEN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Assumption}}
\def\conventionnameEN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Convention}}
\def\hypothesisnameEN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Hypothesis}}
\def\notationnameEN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Notation}}
\def\examplenameEN{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Example}}
\def\problemnameEN{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Problem}}
\def\questionnameEN{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Question}}
\def\exercisenameEN{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Exercise}}
\def\remarknameEN{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Remark}}
\expandafter\def\csname definition-propositionnameEN\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Definition}-\propositionnameEN}
\expandafter\def\csname definition-theoremnameEN\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Definition}-\theoremnameEN}

%% Redefine French theorems names
\def\theoremnameFR{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Théorème}}
\def\lemmanameFR{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Lemme}}
\def\propositionnameFR{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Proposition}}
\def\corollarynameFR{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Corollaire}}
\def\propertynameFR{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Propriété}}
\def\factnameFR{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Fait}}
\def\conjecturenameFR{\normalfont\sffamily\color{purple}\conditionalbfseries\textsc{Conjecture}}
\def\definitionnameFR{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Définition}}
\def\axiomnameFR{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Axiome}}
\def\assumptionnameFR{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Supposition}}
\def\conventionnameFR{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Convention}}
\def\hypothesisnameFR{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Hypothèse}}
\def\notationnameFR{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Notation}}
\def\examplenameFR{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Exemple}}
\def\problemnameFR{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Problème}}
\def\questionnameFR{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Question}}
\def\exercisenameFR{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Exercice}}
\def\remarknameFR{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Remarque}}
\expandafter\def\csname definition-propositionnameFR\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Définition}-\propositionnameFR}
\expandafter\def\csname definition-theoremnameFR\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Définition}-\theoremnameFR}

%% Redefine German theorems names
\def\theoremnameDE{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Satz}}
\def\lemmanameDE{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Lemma}}
\def\propositionnameDE{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Proposition}}
\def\corollarynameDE{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Korollar}}
\def\propertynameDE{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Eigenschaft}}
\def\factnameDE{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Fakt}}
\def\conjecturenameDE{\normalfont\sffamily\color{purple}\conditionalbfseries\textsc{Vermutung}}
\def\definitionnameDE{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Definition}}
\def\axiomnameDE{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Axiom}}
\def\assumptionnameDE{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Annahme}}
\def\conventionnameDE{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Konvention}}
\def\hypothesisnameDE{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Hypothese}}
\def\notationnameDE{\normalfont\sffamily\color{forestgreen}\conditionalbfseries\textsc{Notation}}
\def\examplenameDE{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Beispiel}}
\def\problemnameDE{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Problem}}
\def\questionnameDE{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Frage}}
\def\exercisenameDE{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Übung}}
\def\remarknameDE{\normalfont\sffamily\color{black}\conditionalbfseries\textsc{Bemerkung}}
\expandafter\def\csname definition-propositionnameDE\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Definition}-\propositionnameDE}
\expandafter\def\csname definition-theoremnameDE\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries\textsc{Definition}-\theoremnameDE}

%% Redefine Chinese theorems names
\def\theoremnameCN{\normalfont\sffamily\color{orange}\conditionalbfseries 定理}
\def\lemmanameCN{\normalfont\sffamily\color{orange}\conditionalbfseries 引理}
\def\propositionnameCN{\normalfont\sffamily\color{orange}\conditionalbfseries 命题}
\def\corollarynameCN{\normalfont\sffamily\color{orange}\conditionalbfseries 推论}
\def\propertynameCN{\normalfont\sffamily\color{orange}\conditionalbfseries 性质}
\def\factnameCN{\normalfont\sffamily\color{black}\conditionalbfseries 事实}
\def\conjecturenameCN{\normalfont\sffamily\color{purple}\conditionalbfseries 猜想}
\def\definitionnameCN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 定义}
\def\axiomnameCN{\normalfont\sffamily\color{orange}\conditionalbfseries 公理}
\def\assumptionnameCN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 假设}
\def\conventionnameCN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 约定}
\def\hypothesisnameCN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 假设}
\def\notationnameCN{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 记号}
\def\examplenameCN{\normalfont\sffamily\color{black}\conditionalbfseries 例}
\def\problemnameCN{\normalfont\sffamily\color{black}\conditionalbfseries 问题}
\def\questionnameCN{\normalfont\sffamily\color{black}\conditionalbfseries 问题}
\def\exercisenameCN{\normalfont\sffamily\color{black}\conditionalbfseries 练习}
\def\remarknameCN{\normalfont\sffamily\color{black}\conditionalbfseries 备注}
\expandafter\def\csname definition-propositionnameCN\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries 定义-\propositionnameCN}
\expandafter\def\csname definition-theoremnameCN\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries 定义-\theoremnameCN}

\def\theoremnameTC{\normalfont\sffamily\color{orange}\conditionalbfseries 定理}
\def\lemmanameTC{\normalfont\sffamily\color{orange}\conditionalbfseries 引理}
\def\propositionnameTC{\normalfont\sffamily\color{orange}\conditionalbfseries 命題}
\def\corollarynameTC{\normalfont\sffamily\color{orange}\conditionalbfseries 推論}
\def\propertynameTC{\normalfont\sffamily\color{orange}\conditionalbfseries 性質}
\def\factnameTC{\normalfont\sffamily\color{black}\conditionalbfseries 事實}
\def\conjecturenameTC{\normalfont\sffamily\color{purple}\conditionalbfseries 猜想}
\def\definitionnameTC{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 定義}
\def\axiomnameTC{\normalfont\sffamily\color{orange}\conditionalbfseries 公理}
\def\assumptionnameTC{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 假設}
\def\conventionnameTC{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 約定}
\def\hypothesisnameTC{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 假設}
\def\notationnameTC{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 記號}
\def\examplenameTC{\normalfont\sffamily\color{black}\conditionalbfseries 例}
\def\problemnameTC{\normalfont\sffamily\color{black}\conditionalbfseries 問題}
\def\questionnameTC{\normalfont\sffamily\color{black}\conditionalbfseries 問題}
\def\exercisenameTC{\normalfont\sffamily\color{black}\conditionalbfseries 練習}
\def\remarknameTC{\normalfont\sffamily\color{black}\conditionalbfseries 備註}
\expandafter\def\csname definition-propositionnameTC\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries 定義-\propositionnameTC}
\expandafter\def\csname definition-theoremnameTC\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries 定義-\theoremnameTC}

%% Redefine Japanese theorems names
\def\theoremnameJP{\normalfont\sffamily\color{orange}\conditionalbfseries 定理}
\def\lemmanameJP{\normalfont\sffamily\color{orange}\conditionalbfseries 補題}
\def\propositionnameJP{\normalfont\sffamily\color{orange}\conditionalbfseries 命題}
\def\corollarynameJP{\normalfont\sffamily\color{orange}\conditionalbfseries 系}
\def\propertynameJP{\normalfont\sffamily\color{orange}\conditionalbfseries 性質}
\def\factnameJP{\normalfont\sffamily\color{black}\conditionalbfseries 事実}
\def\conjecturenameJP{\normalfont\sffamily\color{purple}\conditionalbfseries 予想}
\def\definitionnameJP{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 定義}
\def\axiomnameJP{\normalfont\sffamily\color{orange}\conditionalbfseries 公理}
\def\assumptionnameJP{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 仮定}
\def\conventionnameJP{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 慣例}
\def\hypothesisnameJP{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 仮設}
\def\notationnameJP{\normalfont\sffamily\color{forestgreen}\conditionalbfseries 記法}
\def\examplenameJP{\normalfont\sffamily\color{black}\conditionalbfseries 例}
\def\problemnameJP{\normalfont\sffamily\color{black}\conditionalbfseries 問題}
\def\questionnameJP{\normalfont\sffamily\color{black}\conditionalbfseries 問題}
\def\exercisenameJP{\normalfont\sffamily\color{black}\conditionalbfseries 練習}
\def\remarknameJP{\normalfont\sffamily\color{black}\conditionalbfseries 注釈}
\expandafter\def\csname definition-propositionnameJP\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries 定義-\propositionnameJP}
\expandafter\def\csname definition-theoremnameJP\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries 定義-\theoremnameJP}

%% Redefine Russian theorems names
\def\theoremnameRU{\normalfont\sffamily\color{orange}\conditionalbfseries Теорема}
\def\lemmanameRU{\normalfont\sffamily\color{orange}\conditionalbfseries Лемма}
\def\propositionnameRU{\normalfont\sffamily\color{orange}\conditionalbfseries Предложение}
\def\corollarynameRU{\normalfont\sffamily\color{orange}\conditionalbfseries Следствие}
\def\propertynameRU{\normalfont\sffamily\color{orange}\conditionalbfseries Имущество}
\def\factnameRU{\normalfont\sffamily\color{black}\conditionalbfseries Факт}
\def\conjecturenameRU{\normalfont\sffamily\color{purple}\conditionalbfseries Гипотеза}
\def\definitionnameRU{\normalfont\sffamily\color{forestgreen}\conditionalbfseries Определение}
\def\axiomnameRU{\normalfont\sffamily\color{orange}\conditionalbfseries Аксиома}
\def\assumptionnameRU{\normalfont\sffamily\color{forestgreen}\conditionalbfseries Предположение}
\def\conventionnameRU{\normalfont\sffamily\color{forestgreen}\conditionalbfseries Конвенция}
\def\hypothesisnameRU{\normalfont\sffamily\color{forestgreen}\conditionalbfseries Гипотеза}
\def\notationnameRU{\normalfont\sffamily\color{forestgreen}\conditionalbfseries Нотация}
\def\examplenameRU{\normalfont\sffamily\color{black}\conditionalbfseries Пример}
\def\problemnameRU{\normalfont\sffamily\color{black}\conditionalbfseries Проблема}
\def\questionnameRU{\normalfont\sffamily\color{black}\conditionalbfseries Вопрос}
\def\exercisenameRU{\normalfont\sffamily\color{black}\conditionalbfseries Упражнение}
\def\remarknameRU{\normalfont\sffamily\color{black}\conditionalbfseries Замечание}
\expandafter\def\csname definition-propositionnameRU\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries Определение-\propositionnameRU}
\expandafter\def\csname definition-theoremnameRU\endcsname{\normalfont\sffamily\color{orange}\conditionalbfseries Определение-\theoremnameRU}

%% Theorem environments
\theoremstyle{basic}
\ifbool{IsBook}{
    \newaliascnt{highest}{chapter}
}{
    \newaliascnt{highest}{section}
}
\CreateTheorem{theorem}<highest>
\CreateTheorem{lemma}[theorem]
\CreateTheorem{proposition}[theorem]
\CreateTheorem{corollary}[theorem]
\CreateTheorem{definition-proposition}[theorem]
\CreateTheorem{definition-theorem}[theorem]
\CreateTheorem{property}[theorem]
\CreateTheorem{fact}[theorem]
\CreateTheorem{conjecture}[theorem]
\CreateTheorem*{theorem*}
\CreateTheorem*{lemma*}
\CreateTheorem*{proposition*}
\CreateTheorem*{corollary*}
\CreateTheorem*{definition-proposition*}
\CreateTheorem*{definition-theorem*}
\CreateTheorem*{property*}
\CreateTheorem*{fact*}
\CreateTheorem*{conjecture*}
\CreateTheorem{definition}[theorem]
\CreateTheorem{axiom}[theorem]
\CreateTheorem{assumption}[theorem]
\CreateTheorem{convention}[theorem]
\CreateTheorem{hypothesis}[theorem]
\CreateTheorem{notation}[theorem]
\CreateTheorem{example}[theorem]
\CreateTheorem{problem}[theorem]
\CreateTheorem{question}[theorem]
\CreateTheorem{exercise}[theorem]
\CreateTheorem*{definition*}
\CreateTheorem*{axiom*}
\CreateTheorem*{assumption*}
\CreateTheorem*{convention*}
\CreateTheorem*{hypothesis*}
\CreateTheorem*{notation*}
\CreateTheorem*{example*}
\CreateTheorem*{problem*}
\CreateTheorem*{question*}
\CreateTheorem*{exercise*}

\theoremstyle{emphasis}
\CreateTheorem{remark}<highest>
\CreateTheorem*{remark*}

\numberwithin{equation}{highest}

%% Cref label format
\creflabelformat{theoremEN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{lemmaEN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propositionEN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{corollaryEN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propertyEN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{factEN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{conjectureEN}{#2{\normalfont\sffamily\color{purple}\conditionalbfseries#1}#3}
\creflabelformat{definitionEN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{axiomEN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{assumptionEN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{conventionEN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{hypothesisEN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{notationEN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{exampleEN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{problemEN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{questionEN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{exerciseEN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{definition-theoremEN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{definition-propositionEN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}

\creflabelformat{theoremFR}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{lemmaFR}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propositionFR}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{corollaryFR}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propertyFR}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{factFR}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{conjectureFR}{#2{\normalfont\sffamily\color{purple}\conditionalbfseries#1}#3}
\creflabelformat{definitionFR}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{axiomFR}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{assumptionFR}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{conventionFR}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{hypothesisFR}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{notationFR}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{exampleFR}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{problemFR}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{questionFR}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{exerciseFR}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{definition-theoremFR}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{definition-propositionFR}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}

\creflabelformat{theoremDE}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{lemmaDE}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propositionDE}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{corollaryDE}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propertyDE}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{factDE}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{conjectureDE}{#2{\normalfont\sffamily\color{purple}\conditionalbfseries#1}#3}
\creflabelformat{definitionDE}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{axiomDE}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{assumptionDE}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{conventionDE}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{hypothesisDE}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{notationDE}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{exampleDE}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{problemDE}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{questionDE}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{exerciseDE}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{definition-theoremDE}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{definition-propositionDE}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}

\creflabelformat{theoremCN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{lemmaCN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propositionCN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{corollaryCN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propertyCN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{factCN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{conjectureCN}{#2{\normalfont\sffamily\color{purple}\conditionalbfseries#1}#3}
\creflabelformat{definitionCN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{axiomCN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{assumptionCN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{conventionCN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{hypothesisCN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{notationCN}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{exampleCN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{problemCN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{questionCN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{exerciseCN}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{definition-theoremCN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{definition-propositionCN}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}

\creflabelformat{theoremTC}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{lemmaTC}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propositionTC}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{corollaryTC}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propertyTC}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{factTC}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{conjectureTC}{#2{\normalfont\sffamily\color{purple}\conditionalbfseries#1}#3}
\creflabelformat{definitionTC}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{axiomTC}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{assumptionTC}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{conventionTC}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{hypothesisTC}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{notationTC}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{exampleTC}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{problemTC}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{questionTC}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{exerciseTC}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{definition-theoremTC}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{definition-propositionTC}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}

\creflabelformat{theoremJP}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{lemmaJP}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propositionJP}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{corollaryJP}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propertyJP}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{factJP}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{conjectureJP}{#2{\normalfont\sffamily\color{purple}\conditionalbfseries#1}#3}
\creflabelformat{definitionJP}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{axiomJP}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{assumptionJP}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{conventionJP}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{hypothesisJP}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{notationJP}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{exampleJP}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{problemJP}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{questionJP}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{exerciseJP}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{definition-theoremJP}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{definition-propositionJP}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}

\creflabelformat{theoremRU}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{lemmaRU}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propositionRU}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{corollaryRU}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{propertyRU}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{factRU}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{conjectureRU}{#2{\normalfont\sffamily\color{purple}\conditionalbfseries#1}#3}
\creflabelformat{definitionRU}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{axiomRU}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{assumptionRU}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{conventionRU}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{hypothesisRU}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{notationRU}{#2{\normalfont\sffamily\color{forestgreen}\conditionalbfseries#1}#3}
\creflabelformat{exampleRU}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{problemRU}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{questionRU}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{exerciseRU}{#2{\normalfont\sffamily\color{black}\conditionalbfseries#1}#3}
\creflabelformat{definition-theoremRU}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}
\creflabelformat{definition-propositionRU}{#2{\normalfont\sffamily\color{orange}\conditionalbfseries#1}#3}

%% Icons on the margin
\RequirePackage{marginnote}
\RequirePackage{ifoddpage}
\newcommand{\mparadjust}[1]{\renewcommand*{\marginnotevadjust}{#1}}
\pretocmd{\remark}{%
    \if@twoside\checkoddpage%
        \ifoddpage\reversemarginpar\fi%
    \else%
        \reversemarginpar%
    \fi%
    \mparadjust{-.25em}%
    \marginnote{\ideabulb[0.3]{orange}%
        \ifIsBook%
            \hspace*{-.2em}%
        \else%
            \hspace*{-.5em}%
        \fi%
    }\normalmarginpar%
}{}{\FAIL}
\pretocmd{\conjecture}{%
    \if@twoside\checkoddpage%
        \ifoddpage\reversemarginpar\fi%
    \else%
        \reversemarginpar%
    \fi%
    \mparadjust{-.25em}%
    \marginnote{\questionmark[0.3]{purple}%
        \ifIsBook%
            \hspace*{-.2em}%
        \else%
            \hspace*{-.5em}%
        \fi%
    }\normalmarginpar%
}{}{\FAIL}

\RequirePackage{iftex}
\ifXeTeX
\def\pgfsys@hboxsynced#1{%
{%
    \pgfsys@beginscope%
    \setbox\pgf@hbox=\hbox{%
    \hskip\pgf@pt@x%
    \raise\pgf@pt@y\hbox{%
        \pgf@pt@x=0pt%
        \pgf@pt@y=0pt%
        \special{pdf: content q}%
        \pgflowlevelsynccm%
        \pgfsys@invoke{q -1 0 0 -1 0 0 cm}%
        \special{pdf: content -1 0 0 -1 0 0 cm q}
        % translate to original coordinate system
        \pgfsys@invoke{0 J [] 0 d}% reset line cap and dash
        \wd#1=0pt%
        \ht#1=0pt%
        \dp#1=0pt%
        \box#1%
        \pgfsys@invoke{n Q Q Q}%
    }%
    \hss%
    }%
    \wd\pgf@hbox=0pt%
    \ht\pgf@hbox=0pt%
    \dp\pgf@hbox=0pt%
    \pgfsys@hbox\pgf@hbox%
    \pgfsys@endscope%
}}
\fi

\theoremstyle{simple}% as the default style for user-defined environments

\renewenvironment{proof}[1][\proofname]{\par
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \itshape
    #1\hspace{.4em}%
    \textcolor{gray!55!paper}{$|$}]\ignorespaces
}{%
  \popQED\endtrivlist\@endpefalse
}

\RequirePackage[many]{tcolorbox}
\if@colorist@fast
    \tcbstartdraftmode
\fi
\tcolorboxenvironment{theorem}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{theorem*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{lemma}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{lemma*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{proposition}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{proposition*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{corollary}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{corollary*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{property}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{property*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{axiom}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{axiom*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{definition-proposition}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{definition-proposition*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{definition-theorem}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}
\tcolorboxenvironment{definition-theorem*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.9,colframe=orange,arc=.7mm}

\tcolorboxenvironment{fact}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=gray!10!paper,
    boxrule=0pt,frame hidden,arc=.7mm}
\tcolorboxenvironment{fact*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=gray!10!paper,
    boxrule=0pt,frame hidden,arc=.7mm}

\tcolorboxenvironment{conjecture}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.7,colframe=purple,arc=.7mm}
\tcolorboxenvironment{conjecture*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=black!3!paper,
    left=3.5mm,right=3.5mm,
    opacityframe=0.7,colframe=purple,arc=.7mm}

\tcolorboxenvironment{definition}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{definition*}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{assumption}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{assumption*}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{convention}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{convention*}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{hypothesis}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{hypothesis*}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{notation}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}
\tcolorboxenvironment{notation*}
    {enhanced jigsaw,pad at break*=1mm,breakable,
    left=4mm,right=4mm,top=1mm,bottom=1mm,
    colback=lightorange!10!paper,boxrule=0pt,frame hidden,
    borderline west={1.5mm}{-1mm}{forestgreen},arc=.7mm}

\tcolorboxenvironment{example}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=gray!10!paper,
    boxrule=0pt,frame hidden,arc=.7mm,lines before break=3}
\tcolorboxenvironment{example*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=gray!10!paper,
    boxrule=0pt,frame hidden,arc=.7mm,lines before break=3}

\tcolorboxenvironment{problem}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=yellow!25!paper,
    boxrule=0pt,frame hidden,arc=.7mm}
\tcolorboxenvironment{problem*}
    {enhanced jigsaw,pad at break*=1mm,breakable,colback=yellow!25!paper,
    boxrule=0pt,frame hidden,arc=.7mm}

\tcolorboxenvironment{remark}
    {enhanced jigsaw,pad at break*=1mm,breakable,oversize,
    opacityframe=0,opacityback=0,lines before break=3}
\tcolorboxenvironment{remark*}
    {enhanced jigsaw,pad at break*=1mm,breakable,oversize,
    opacityframe=0,opacityback=0,lines before break=3}

\ExplSyntaxOn
\NewDocumentCommand \AfterEnvEnd { +m }
  { \colorist_after_env_end:nw {#1} }
\cs_new_protected:Npn \colorist_after_env_end:nw #1 #2
       \if@ignore\@ignorefalse\ignorespaces\fi
  { #2 \if@ignore\@ignorefalse\ignorespaces\fi #1 }
  \NewDocumentCommand \ScanEnv { s m +m+m }
  {
    \IfBooleanTF {#1}
      { \jinwen_scan_env_ignore_par:nTF }
      { \jinwen_scan_env:nTF }
          {#2} {#3} {#4}
  }
\cs_new_protected:Npn \jinwen_scan_env:nTF
  { \__jinwen_scan_env:NnTF \c_false_bool }
\cs_new_protected:Npn \jinwen_scan_env_ignore_par:nTF
  { \__jinwen_scan_env:NnTF \c_true_bool }
\tl_new:N \l__jinwen_collected_tl
\cs_new_protected:Npn \__jinwen_scan_env:NnTF #1 #2 #3 #4
  {
    \tl_clear:N \l__jinwen_collected_tl
    \peek_analysis_map_inline:n
      {
        \tl_put_right:Nn \l__jinwen_collected_tl {##1}
        \int_compare:nNnTF { "##3 } = { 0 }
          {
            \exp_args:No \token_if_eq_meaning:NNTF {##1} \begin
              { \peek_analysis_map_break:n { \__jinwen_chk_env:nTFn {#2} {#3} {#4} } }
              {
                \bool_lazy_and:nnF {#1}
                    { \exp_args:No \token_if_eq_meaning_p:NN {##1} \par }
                  { \__jinwen_scan_env_end:n {#4} }
              }
          }
          { \int_compare:nNnF { "##3 } = { 10 } { \__jinwen_scan_env_end:n {#4} } }
      }
  }
\cs_new_protected:Npn \__jinwen_scan_env_end:n #1
  { \peek_analysis_map_break:n { \__jinwen_reinsert_tokens:nn {#1} { } } }
\cs_new_protected:Npn \__jinwen_reinsert_tokens:nn #1 #2
  {
    \use:x
      {
        \tl_clear:N \exp_not:N \l__jinwen_collected_tl
        \exp_not:n {#1} \l__jinwen_collected_tl #2
      }
  }
\cs_new_protected:Npn \__jinwen_chk_env:nTFn #1 #2 #3 #4
  {
    \exp_args:Nx \__jinwen_reinsert_tokens:nn
      { \str_if_eq:nnTF {#1} {#4} { \exp_not:n {#2} } { \exp_not:n {#3} } } { {#4} }
  }
\ExplSyntaxOff

\def\scandefinitionenv{%
  \AfterEnvEnd{%
    \ScanEnv*{definition}%
      {\vspace{-1.05\baselineskip}}%
      {\ScanEnv*{definition*}%
        {\vspace{-1.05\baselineskip}}%
        {}}}}
\AddToHook{env/definition/end}{\scandefinitionenv}%
\AddToHook{env/definition*/end}{\scandefinitionenv}%

\def\scanassumptionenv{%
  \AfterEnvEnd{%
    \ScanEnv*{assumption}%
      {\vspace{-1.05\baselineskip}}%
      {\ScanEnv*{assumption*}%
        {\vspace{-1.05\baselineskip}}%
        {}}}}
\AddToHook{env/assumption/end}{\scanassumptionenv}%
\AddToHook{env/assumption*/end}{\scanassumptionenv}%

\def\scanconventionenv{%
  \AfterEnvEnd{%
    \ScanEnv*{convention}%
      {\vspace{-1.05\baselineskip}}%
      {\ScanEnv*{convention*}%
        {\vspace{-1.05\baselineskip}}%
        {}}}}
\AddToHook{env/convention/end}{\scanconventionenv}%
\AddToHook{env/convention*/end}{\scanconventionenv}%

\def\scanhypothesisenv{%
  \AfterEnvEnd{%
    \ScanEnv*{hypothesis}%
      {\vspace{-1.05\baselineskip}}%
      {\ScanEnv*{hypothesis*}%
        {\vspace{-1.05\baselineskip}}%
        {}}}}
\AddToHook{env/hypothesis/end}{\scanhypothesisenv}%
\AddToHook{env/hypothesis*/end}{\scanhypothesisenv}%

\def\scannotationenv{%
  \AfterEnvEnd{%
    \ScanEnv*{notation}%
      {\vspace{-1.05\baselineskip}}%
      {\ScanEnv*{notation*}%
        {\vspace{-1.05\baselineskip}}%
        {}}}}
\AddToHook{env/notation/end}{\scannotationenv}%
\AddToHook{env/notation*/end}{\scannotationenv}%

\ifbool{IsBook}{}{%

%%================================
%% Title block style
%%================================
\renewcommand{\@maketitle}{%
\begin{center}%
    \color{maintheme}%
    {\Large\sffamily\scshape\conditionalbfseries\@title}\\\bigskip%
    \color{black!80!paper}%
    {\scshape\@author}\\\smallskip%
    {\@date}%
\end{center}%
\medskip%
}
\apptocmd{\maketitle}{\thispagestyle{fancy}}{}{\FAIL}

%%================================
%% Abstract style
%%================================
\renewenvironment{abstract}
{\small{\centerline{\textsc{\conditionalbfseries\abstractname}}\vspace{-0.3\baselineskip}}
    \color{black!80!paper}\begin{quotation}}
{\end{quotation}\medskip}

%%================================
%% Keyword
%%================================
\def\keywordnameEN{\textsc{Keywords}}
\def\keywordnameFR{\textsc{Mots clés}}
\def\keywordnameDE{\textsc{Schlüsselwörter}}
\def\keywordnameCN{关键词}
\def\keywordnameTC{關鍵詞}
\def\keywordnameJP{キーワード}
\def\keywordnameRU{Ключевые слова}

\newenvironment{keyword}
{\small{\centerline{{\conditionalbfseries\csname keywordname\csname\languagename ABBR\endcsname\endcsname}}\vspace{-0.3\baselineskip}}
    \color{black!80!paper}\begin{center}}
{\end{center}\medskip}

%%================================
%% Simulate features of amsart
%%================================
\RequirePackage{PJLamssim}

}

\endinput
%%
%% End of file `colorist/colorist.sty'.
