%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                    |  \               %
%   ______  __     __  ______  _______      _______ _| ▓▓_   __    __   %
%  /      \|  \   /  \|      \|       \    /       \   ▓▓ \ |  \  |  \  %
% |  ▓▓▓▓▓▓\\▓▓\ /  ▓▓ \▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\  |  ▓▓▓▓▓▓▓\▓▓▓▓▓▓ | ▓▓  | ▓▓  %
% | ▓▓    ▓▓ \▓▓\  ▓▓ /      ▓▓ ▓▓  | ▓▓   \▓▓    \  | ▓▓ __| ▓▓  | ▓▓  %
% | ▓▓▓▓▓▓▓▓  \▓▓ ▓▓ |  ▓▓▓▓▓▓▓ ▓▓  | ▓▓__ _\▓▓▓▓▓▓\ | ▓▓|  \ ▓▓__/ ▓▓  %
%  \▓▓     \   \▓▓▓   \▓▓    ▓▓ ▓▓  | ▓▓  \       ▓▓  \▓▓  ▓▓\▓▓    ▓▓  %
%   \▓▓▓▓▓▓▓    \▓     \▓▓▓▓▓▓▓\▓▓   \▓▓\▓▓\▓▓▓▓▓▓▓    \▓▓▓▓ _\▓▓▓▓▓▓▓  %
%                                                           |  \__| ▓▓  %
%                                                            \▓▓    ▓▓  %
%                                                             \▓▓▓▓▓▓   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% https://github.com/vEnhance/dotfiles/blob/main/texmf/tex/latex/evan/evan.sty

% ░█▄█░▄▀▄░█░░▒█░░░▀█▀░▄▀▄░░░█▒█░▄▀▀▒██▀
% ▒█▒█░▀▄▀░▀▄▀▄▀▒░░▒█▒░▀▄▀▒░░▀▄█▒▄██░█▄▄
%
% If you don't know how to use this file, read:
% +--------------------------------------------+
% | https://web.evanchen.cc/faq-latex.html#L-4 |
% +--------------------------------------------+
%
% TL;DR of the Boost license conditions are as follows:
%
% 1. Any SOURCE VERSIONS must cite evan.sty and the Boost license below.
% 2. For COMPILED PDF OUTPUT, attribution of evan.sty is OPTIONAL (but nice).
% 3. NO OTHER REQUIREMENTS; you may modify, redistribute, sell freely.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% BOOST SOFTWARE LICENSE - VERSION 1.0 - 17 AUGUST 2003
%
% Copyright (c) 2022 Evan Chen [evan at evanchen.cc]
% https://web.evanchen.cc/ || github.com/vEnhance
%
% Available for download at:
% https://github.com/vEnhance/dotfiles/blob/main/texmf/tex/latex/evan/evan.sty
%
% Permission is hereby granted, free of charge, to any person or organization
% obtaining a copy of the software and accompanying documentation covered by
% this license (the "Software") to use, reproduce, display, distribute,
% execute, and transmit the Software, and to prepare derivative works of the
% Software, and to permit third-parties to whom the Software is furnished to
% do so, all subject to the following:
%
% The copyright notices in the Software and this entire statement, including
% the above license grant, this restriction and the following disclaimer,
% must be included in all copies of the Software, in whole or in part, and
% all derivative works of the Software, unless such copies or derivative
% works are solely in the form of machine-executable object code generated by
% a source language processor.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
% SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
% FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
% ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
% DEALINGS IN THE SOFTWARE.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ProvidesPackage{evan}
%%fakesection Argument processing
% Default Arguments
% We include "Evan" in all of these to make sure
% that they don't collide with anything in external packages
\newif\ifevanfancy\evanfancytrue
\newif\ifevanhdr\evanhdrtrue
\newif\ifevanhref\evanhreftrue
\newif\ifevansetup\evansetuptrue
\newif\ifevanthm\evanthmtrue
\newif\ifevansecthm\evansecthmfalse
\newif\ifevanht\evanhtfalse
\newif\ifevanpkg\evanpkgtrue
\newif\ifevanpdf\evanpdftrue
\newif\ifevanauthor\evanauthortrue
\newif\ifevanchinese\evanchinesefalse
\newif\ifevanmdthm\evanmdthmfalse
\newif\ifevandiagrams\evandiagramsfalse
\newif\ifevanpatchasy\evanpatchasyfalse
\newif\ifevanhints\evanhintsfalse
\newif\ifevanasy\evanasytrue
\newif\ifevancolorsec\evancolorsecfalse
\newif\ifevantitlemark\evantitlemarktrue
\newif\ifevanvonenabled\evanvonenabledfalse
\newif\ifevanbritish\evanbritishtrue

%Receive Arguments
\DeclareOption{chinese}{\evanhreffalse\evanchinesetrue} % Chinese support
% allow href to override this one

\DeclareOption{sexy}{\evansecthmtrue\evanmdthmtrue\evancolorsectrue} % long docs

\DeclareOption{fancy}{\evanfancytrue}
\DeclareOption{nofancy}{\evanfancyfalse}
\DeclareOption{hdr}{\evanhdrtrue}
\DeclareOption{nohdr}{\evanhdrfalse}
\DeclareOption{href}{\evanhreftrue}
\DeclareOption{nohref}{\evanhreffalse}

\DeclareOption{nosetup}{\evansetupfalse}
\DeclareOption{thm}{\evanthmtrue}
\DeclareOption{nothm}{\evanthmfalse}
\DeclareOption{secthm}{\evansecthmtrue}
\DeclareOption{nosecthm}{\evansecthmfalse}

\DeclareOption{ht}{\evanhttrue}
\DeclareOption{nopdf}{\evanpdffalse}
\DeclareOption{nopkg}{\evanpkgfalse}
\DeclareOption{noauthor}{\evanauthorfalse}
\DeclareOption{titlemark}{\evantitlemarktrue} % Sets title in ohead, not \rightmark
\DeclareOption{sectionmark}{\evantitlemarkfalse} % Uses \rightmark not title in ohead

\DeclareOption{mdthm}{\evanmdthmtrue}
\DeclareOption{nomdthm}{\evanmdthmfalse}
\DeclareOption{diagrams}{\evandiagramstrue}
\DeclareOption{nodiagrams}{\evandiagramsfalse}
\DeclareOption{colorsec}{\evancolorsectrue}
\DeclareOption{nocolorsec}{\evancolorsecfalse}

\DeclareOption{patchasy}{\evanpatchasytrue}
\DeclareOption{noasy}{\evanasyfalse}

\DeclareOption{hints}{\evanhintstrue}
\DeclareOption{von}{\evanvonenabledtrue}

\DeclareOption{british}{\evanbritishtrue}
\DeclareOption{american}{\evanbritishfalse}

\ProcessOptions\relax

% if packages not loaded, turn off mdthm and asy
\ifevanpkg\else\evanmdthmfalse\fi
\ifevanpkg\else\evanasyfalse\fi

% If no setup, turn off theorems
\ifevansetup\else\evanthmfalse\fi

%%fakesection Some macros
%Small commands
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifevanpkg
  \usepackage[minimal]{yhmath}
\fi
\newcommand{\cbrt}[1]{\sqrt[3]{#1}}
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\ceiling}[1]{\left\lceil #1 \right\rceil}
\newcommand{\mailto}[1]{\href{mailto:#1}{\texttt{#1}}}
\newcommand{\ol}{\overline}
\newcommand{\ul}{\underline}
\newcommand{\wt}{\widetilde}
\newcommand{\wh}{\widehat}
\newcommand{\eps}{\varepsilon}
%\renewcommand{\iff}{\Leftrightarrow}
%\renewcommand{\implies}{\Rightarrow}
\newcommand{\vocab}[1]{\textbf{\color{blue}\sffamily #1}}
\providecommand{\alert}{\vocab}
\providecommand{\half}{\frac{1}{2}}
\newcommand{\catname}{\mathsf}
\newcommand{\hrulebar}{
  \par\hspace{\fill}\rule{0.95\linewidth}{.7pt}\hspace{\fill}
  \par\nointerlineskip \vspace{\baselineskip}
}
\providecommand{\arc}[1]{\wideparen{#1}}

%For use in author command
\newcommand{\plusemail}[1]{\\ \normalfont \texttt{\mailto{#1}}}

%More commands and math operators
\DeclareMathOperator{\cis}{cis}
\DeclareMathOperator*{\lcm}{lcm}
\DeclareMathOperator*{\argmin}{arg min}
\DeclareMathOperator*{\argmax}{arg max}

%Convenient Environments
\newenvironment{soln}{\begin{proof}[Solution]}{\end{proof}}
\newenvironment{parlist}{\begin{inparaenum}[(i)]}{\end{inparaenum}}
\newenvironment{gobble}{\setbox\z@\vbox\bgroup}{\egroup}

%Inequalities
\newcommand{\cycsum}{\sum_{\mathrm{cyc}}}
\newcommand{\symsum}{\sum_{\mathrm{sym}}}
\newcommand{\cycprod}{\prod_{\mathrm{cyc}}}
\newcommand{\symprod}{\prod_{\mathrm{sym}}}

%From H113 "Introduction to Abstract Algebra" at UC Berkeley
\newcommand{\CC}{\mathbb C}
\newcommand{\FF}{\mathbb F}
\newcommand{\NN}{\mathbb N}
\newcommand{\QQ}{\mathbb Q}
\newcommand{\RR}{\mathbb R}
\newcommand{\ZZ}{\mathbb Z}
\newcommand{\charin}{\text{ char }}
\DeclareMathOperator{\sign}{sign}
\DeclareMathOperator{\Aut}{Aut}
\DeclareMathOperator{\Inn}{Inn}
\DeclareMathOperator{\Syl}{Syl}
\DeclareMathOperator{\Gal}{Gal}
\DeclareMathOperator{\GL}{GL} % General linear group
\DeclareMathOperator{\SL}{SL} % Special linear group

%From Kiran Kedlaya's "Geometry Unbound"
\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}
\newcommand{\norm}[1]{\left\lVert #1 \right\rVert}
\newcommand{\dang}{\measuredangle} %% Directed angle
\newcommand{\ray}[1]{\overrightarrow{#1}}
\newcommand{\seg}[1]{\overline{#1}}

%From M275 "Topology" at SJSU
\newcommand{\id}{\mathrm{id}}
\newcommand{\taking}[1]{\xrightarrow{#1}}
\newcommand{\inv}{^{-1}}

%From M170 "Introduction to Graph Theory" at SJSU
\DeclareMathOperator{\diam}{diam}
\DeclareMathOperator{\ord}{ord}
\newcommand{\defeq}{\overset{\mathrm{def}}{=}}

%From the USAMO .tex files
\newcommand{\ts}{\textsuperscript}
\newcommand{\dg}{^\circ}
\newcommand{\ii}{\item}

% From Math 55 and Math 145 at Harvard
\newenvironment{subproof}[1][Proof]{%
\begin{proof}[#1] \renewcommand{\qedsymbol}{$\blacksquare$}}%
{\end{proof}}

\newcommand{\liff}{\leftrightarrow}
\newcommand{\lthen}{\rightarrow}
\newcommand{\opname}{\operatorname}
\newcommand{\surjto}{\twoheadrightarrow}
\newcommand{\injto}{\hookrightarrow}
\newcommand{\On}{\mathrm{On}} % ordinals
\DeclareMathOperator{\img}{im} % Image
\DeclareMathOperator{\Img}{Im} % Image
\DeclareMathOperator{\coker}{coker} % Cokernel
\DeclareMathOperator{\Coker}{Coker} % Cokernel
\DeclareMathOperator{\Ker}{Ker} % Kernel
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\Spec}{Spec} % spectrum
\DeclareMathOperator{\Tr}{Tr} % trace
\DeclareMathOperator{\pr}{pr} % projection
\DeclareMathOperator{\ext}{ext} % extension
\DeclareMathOperator{\pred}{pred} % predecessor
\DeclareMathOperator{\dom}{dom} % domain
\DeclareMathOperator{\ran}{ran} % range
\DeclareMathOperator{\Hom}{Hom} % homomorphism
\DeclareMathOperator{\Mor}{Mor} % morphisms
\DeclareMathOperator{\End}{End} % endomorphism

% Things Lie
\newcommand{\kb}{\mathfrak b}
\newcommand{\kg}{\mathfrak g}
\newcommand{\kh}{\mathfrak h}
\newcommand{\kn}{\mathfrak n}
\newcommand{\ku}{\mathfrak u}
\newcommand{\kz}{\mathfrak z}
\DeclareMathOperator{\Ext}{Ext} % Ext functor
\DeclareMathOperator{\Tor}{Tor} % Tor functor
\newcommand{\gl}{\opname{\mathfrak{gl}}} % frak gl group
% \renewcommand{\sl}{\opname{\mathfrak{sl}}} % frak sl group chktex 6

% More script letters etc.
\newcommand{\SA}{\mathcal A}
\newcommand{\SB}{\mathcal B}
\newcommand{\SC}{\mathcal C}
\newcommand{\SF}{\mathcal F}
\newcommand{\SG}{\mathcal G}
\newcommand{\SH}{\mathcal H}
\newcommand{\OO}{\mathcal O}

\newcommand{\SCA}{\mathscr A}
\newcommand{\SCB}{\mathscr B}
\newcommand{\SCC}{\mathscr C}
\newcommand{\SCD}{\mathscr D}
\newcommand{\SCE}{\mathscr E}
\newcommand{\SCF}{\mathscr F}
\newcommand{\SCG}{\mathscr G}
\newcommand{\SCH}{\mathscr H}

% Mathfrak primes
\newcommand{\km}{\mathfrak m}
\newcommand{\kp}{\mathfrak p}
\newcommand{\kq}{\mathfrak q}

%% Napkin commands
\newcommand{\prototype}[1]{
  \emph{{\color{red} Prototypical example for this section:} #1} \par\medskip
}
\newenvironment{moral}{%
  \begin{mdframed}[linecolor=green!70!black]%
  \bfseries\color{green!70!black}}%
  {\end{mdframed}}

%%fakesection Asymptote setup
\ifevanasy
  \ifevanpatchasy
    \usepackage{patch-asy}
  \else
    \usepackage{asymptote}
  \fi
  \begin{asydef}
    defaultpen(fontsize(10pt));
    size(8cm); // set a reasonable default
    usepackage("amsmath");
    usepackage("amssymb");
    settings.tex="pdflatex";
    settings.outformat="pdf";
    // Replacement for olympiad+cse5 which is not standard
    import geometry;
    // recalibrate fill and filldraw for conics
    void filldraw(picture pic = currentpicture, conic g, pen fillpen=defaultpen, pen drawpen=defaultpen)
      { filldraw(pic, (path) g, fillpen, drawpen); }
    void fill(picture pic = currentpicture, conic g, pen p=defaultpen)
      { filldraw(pic, (path) g, p); }
    // some geometry
    pair foot(pair P, pair A, pair B) { return foot(triangle(A,B,P).VC); }
    pair orthocenter(pair A, pair B, pair C) { return orthocentercenter(A,B,C); }
    pair centroid(pair A, pair B, pair C) { return (A+B+C)/3; }
    // cse5 abbreviations
    path CP(pair P, pair A) { return circle(P, abs(A-P)); }
    path CR(pair P, real r) { return circle(P, r); }
    pair IP(path p, path q) { return intersectionpoints(p,q)[0]; }
    pair OP(path p, path q) { return intersectionpoints(p,q)[1]; }
    path Line(pair A, pair B, real a=0.6, real b=a) { return (a*(A-B)+A)--(b*(B-A)+B); }
    // cse5 more useful functions
    picture CC() {
      picture p=rotate(0)*currentpicture;
      currentpicture.erase();
      return p;
    }
    pair MP(Label s, pair A, pair B = plain.S, pen p = defaultpen) {
      Label L = s;
      L.s = "$"+s.s+"$";
      label(L, A, B, p);
      return A;
    }
    pair Drawing(Label s = "", pair A, pair B = plain.S, pen p = defaultpen) {
      dot(MP(s, A, B, p), p);
      return A;
    }
    path Drawing(path g, pen p = defaultpen, arrowbar ar = None) {
      draw(g, p, ar);
      return g;
    }
  \end{asydef}
\fi

%%fakesection BEGIN MAIN SETUP
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ifevansetup
  %%fakesection Set up author and date
  \ifevanauthor
    \title{} % empty title to avoid crashes
    \ifluatex
      \author{Evan Chen《陳誼廷》}
    \else
      \author{Evan Chen}
    \fi
    \date{\today}
  \fi
  %%fakesection Hyperref
  \ifevanpkg
    \PassOptionsToPackage{usenames,svgnames,dvipsnames,table}{xcolor}
    \usepackage{xcolor}
    \ifevanhref
      \usepackage[colorlinks=false]{hyperref}
      \hypersetup{urlcolor=RubineRed,linkcolor=RoyalBlue,citecolor=ForestGreen}
    \fi
    \usepackage[nameinlink]{cleveref}
  \fi

  %%fakesection New Theorem Styles
  \ifevanthm
    \usepackage{amsthm}
    \usepackage{thmtools}
  \fi
  \ifevanmdthm
    \ifevanthm
      %% theorem packages loaded already
    \else
      \usepackage{amsthm}
      \usepackage{thmtools}
    \fi
    \usepackage[framemethod=TikZ]{mdframed}

    \mdfdefinestyle{mdbluebox}{%
      roundcorner=10pt,
      linewidth=1pt,
      skipabove=12pt,
      innerbottommargin=9pt,
      skipbelow=2pt,
      linecolor=blue,
      nobreak=true,
      backgroundcolor=TealBlue!5,
    }
    \declaretheoremstyle[
      headfont=\sffamily\bfseries\color{MidnightBlue},
      mdframed={style=mdbluebox},
      headpunct={\\[3pt]},
      postheadspace={0pt}
    ]{thmbluebox}

    \mdfdefinestyle{mdredbox}{%
      linewidth=0.5pt,
      skipabove=12pt,
      frametitleaboveskip=5pt,
      frametitlebelowskip=0pt,
      skipbelow=2pt,
      frametitlefont=\bfseries,
      innertopmargin=4pt,
      innerbottommargin=8pt,
      nobreak=true,
      backgroundcolor=Salmon!5,
      linecolor=RawSienna,
    }
    \declaretheoremstyle[
      headfont=\bfseries\color{RawSienna},
      mdframed={style=mdredbox},
      headpunct={\\[3pt]},
      postheadspace={0pt},
    ]{thmredbox}

    \mdfdefinestyle{mdgreenbox}{%
      skipabove=8pt,
      linewidth=2pt,
      rightline=false,
      leftline=true,
      topline=false,
      bottomline=false,
      linecolor=ForestGreen,
      backgroundcolor=ForestGreen!5,
    }
    \declaretheoremstyle[
      headfont=\bfseries\sffamily\color{ForestGreen!70!black},
      bodyfont=\normalfont,
      spaceabove=2pt,
      spacebelow=1pt,
      mdframed={style=mdgreenbox},
      headpunct={ --- },
    ]{thmgreenbox}

    \mdfdefinestyle{mdblackbox}{%
      skipabove=8pt,
      linewidth=3pt,
      rightline=false,
      leftline=true,
      topline=false,
      bottomline=false,
      linecolor=black,
      backgroundcolor=RedViolet!5!gray!5,
    }
    \declaretheoremstyle[
      headfont=\bfseries,
      bodyfont=\normalfont\small,
      spaceabove=0pt,
      spacebelow=0pt,
      mdframed={style=mdblackbox}
    ]{thmblackbox}

    \newcommand{\listhack}{$\empty$\vspace{-2em}}
  \fi

  %%fakesection Theorem setup
  \ifevanthm
    \theoremstyle{definition}
    %Branching here: the option secthm changes theorems to be labelled by section
    \ifevanmdthm
      \ifevansecthm
        \declaretheorem[%
        style=thmbluebox,name=Teorema,numberwithin=section]{theorem}
      \else
        \declaretheorem[%
        style=thmbluebox,name=Teorema]{theorem}
      \fi
      \declaretheorem[style=thmbluebox,name=Lemma,sibling=theorem]{lemma}
      \declaretheorem[style=thmbluebox,name=Proposizione,sibling=theorem]{proposition}
      \declaretheorem[style=thmbluebox,name=Corollario,sibling=theorem]{corollary}
      \declaretheorem[style=thmbluebox,name=Teorema,numbered=no]{theorem*}
      \declaretheorem[style=thmbluebox,name=Lemma,numbered=no]{lemma*}
      \declaretheorem[style=thmbluebox,name=Proposizione,numbered=no]{proposition*}
      \declaretheorem[style=thmbluebox,name=Corollario,numbered=no]{corollary*}
    \else
      \ifevansecthm
        \declaretheorem[name=Theorem,numberwithin=section]{theorem}
      \else
        \declaretheorem[name=Theorem]{theorem}
      \fi
      \declaretheorem[name=Lemma,sibling=theorem]{lemma}
      \declaretheorem[name=Proposizione,sibling=theorem]{proposition}
      \declaretheorem[name=Corollario,sibling=theorem]{corollary}
      \declaretheorem[name=Teorema,numbered=no]{theorem*}
      \declaretheorem[name=Lemma,numbered=no]{lemma*}
      \declaretheorem[name=Proposizione,numbered=no]{proposition*}
      \declaretheorem[name=Corollario,numbered=no]{corollary*}
    \fi

    \ifevanmdthm
      \declaretheorem[style=thmgreenbox,name=Algoritmo,sibling=theorem]{algorithm}
      \declaretheorem[style=thmgreenbox,name=Algoritmo,numbered=no]{algorithm*}
      \declaretheorem[style=thmgreenbox,name=Claim,sibling=theorem]{claim}
      \declaretheorem[style=thmgreenbox,name=Claim,numbered=no]{claim*}
    \else
      \declaretheorem[name=Algoritmo,sibling=theorem]{algorithm}
      \declaretheorem[name=Algoritmo,numbered=no]{algorithm*}
      \declaretheorem[name=Claim,sibling=theorem]{claim}
      \declaretheorem[name=Claim,numbered=no]{claim*}
    \fi

    \ifevanmdthm
      \declaretheorem[style=thmredbox,name=Esempio,sibling=theorem]{example}
      \declaretheorem[style=thmredbox,name=Esempio,numbered=no]{example*}
    \else
      \declaretheorem[name=Esempio,sibling=theorem]{example}
      \declaretheorem[name=Esempio,numbered=no]{example*}
    \fi

    % Remark-style theorems
    %\theoremstyle{remark}
    \ifevanmdthm
      \declaretheorem[style=thmgreenbox,name=Osservazione,sibling=theorem]{remark}
      \declaretheorem[style=thmgreenbox,name=Osservazione,numbered=no]{remark*}
    \else
      \declaretheorem[name=Osservazione,sibling=theorem]{remark}
      \declaretheorem[name=Osservazione,numbered=no]{remark*}
    \fi

    \declaretheorem[name=Congettura,sibling=theorem]{conjecture}
    \declaretheorem[name=Congettura,numbered=no]{conjecture*}
    \declaretheorem[name=Definizione,sibling=theorem]{definition}
    \declaretheorem[name=Definizione,numbered=no]{definition*}
    \declaretheorem[name=Esercizio,sibling=theorem]{exercise}
    \declaretheorem[name=Esercizio,numbered=no]{exercise*}
    \declaretheorem[name=Fatto noto,sibling=theorem]{fact}
    \declaretheorem[name=Fatto noto,numbered=no]{fact*}
    \declaretheorem[name=Problema,sibling=theorem]{problem}
    \declaretheorem[name=Problema,numbered=no]{problem*}
    \declaretheorem[name=Domanda,sibling=theorem]{ques}
    \declaretheorem[name=Domanda,numbered=no]{ques*}

    \ifevanpkg
      \Crefname{claim}{Claim}{Claims}
      \Crefname{conjecture}{Congettura}{Congetture}
      \Crefname{exercise}{Esercizio}{Esercizio}
      \Crefname{fact}{Fatto noto}{Fatti noti}
      \Crefname{problem}{Problema}{Problemi}
      \Crefname{ques}{Domanda}{Domande}
    \fi
  \fi

  %%fakesection Fancy section and chapter heads
  \ifevancolorsec
    \@ifundefined{KOMAClassName}{}{
      \@ifundefined{chapter}{}{
        \addtokomafont{partprefix}{\rmfamily}
        \renewcommand*{\partformat}{\color{purple}
          \scalebox{2.5}{\thepart}\enlargethispage{2em}}
        \addtokomafont{chapterprefix}{\raggedleft}
        \RedeclareSectionCommand[beforeskip=0.5em]{chapter}
        \renewcommand*{\chapterformat}{\mbox{%
          \scalebox{1.5}{\chapappifchapterprefix{\nobreakspace}}%
          \scalebox{2.718}{\color{purple}\thechapter}\enskip}}
      }
      \renewcommand*{\sectionformat}%
        {\color{purple}\S\thesection\enskip}
      \renewcommand*{\subsectionformat}%
        {\color{purple}\S\thesubsection\enskip}
      \renewcommand*{\subsubsectionformat}%
        {\color{purple}\S\thesubsubsection\enskip}
      \KOMAoptions{numbers=noenddot}
      %\usetocstyle{KOMAlike}
    }
  \fi


  %%fakesection Loads a bunch of useful packages (but allow disabling)
  \ifevanpkg
    \ifevanvonenabled
      \IfFileExists{von.sty}{\usepackage{von}}{}
    \fi
    \usepackage{listings}
    \usepackage{mathrsfs}
    \usepackage{textcomp}
    \lstset{basicstyle=\ttfamily\scriptsize,
      backgroundcolor=\color{green!2!white},
      breakatwhitespace=true,
      breaklines=true,
      commentstyle=\color{green!70!black},
      frame=shadowbox,
      frame=single,
      identifierstyle=\color{green!20!black},
      keywordstyle=\bfseries,
      keywordstyle=\bfseries\color{blue},
      numbers=left,
      numbersep=5pt,
      numberstyle=\tiny\sffamily\itshape\color{black!60},
      rulecolor=\color{blue!70!black},
      rulesepcolor=\color{blue!30!black},
      showstringspaces=false,
      stringstyle=\color{orange},
      tabsize=4,
    } % chktex 6
    \lstdefinelanguage{gitcommit}{
      alsoletter={:},
      morecomment=[l]{|},
      morekeywords={commit,Author:,Date:,chore,doc,edit,feat,fix,polish,style,tests,},
      sensitive=true,
    }
    \lstdefinelanguage{gitlog}{
      morekeywords={chore,doc,edit,feat,fix,polish,style,tests,},
      morecomment=[s]{[}{]}, % chktex 9
      sensitive=true,
    }

    \usepackage[shortlabels]{enumitem}
    \usepackage[obeyFinal,textsize=scriptsize,shadow]{todonotes}
    \usepackage{textcomp}
    \usepackage{multirow}
    % Tiny optimizations:
    \usepackage{mathtools}
    \usepackage{microtype}
    \usepackage{xstring}
    \usepackage{wrapfig}
    \ifevanbritish
      % Use day-first date format
      \usepackage[cleanlook,british]{isodate}
    \fi

    % a list I like for walkthrough's --- Drew-style parts
    \newlist{walk}{enumerate}{3}
    \setlist[walk]{label=\bfseries (\alph*)}
    % list item for MO style rubrics
    \newcommand{\worth}[1]{\def\hfill{\hskip 20pt plus 1fill}\dotfill%
      \IfEq{#1}{0}{\textbf{0~points}}%
      {\textbf{\color{blue}#1~point\IfEndWith{#1}{1}{}{s}}}%
      \par}
    \newcommand{\subworth}[1]{\def\hfill{\hskip 20pt plus 1fill}\dotfill%
      \IfEq{#1}{0}{{\footnotesize0~points}}%
      {\textbf{\footnotesize#1~point\IfEndWith{#1}{1}{}{s}}}%
      \par}
    \newlist{rubric}{enumerate}{2}
    \setlist[rubric,1]{label=\Roman*.}
    \setlist[rubric,2]{label=(\Roman{rubrici}.\alph*)}
  \fi

  %%fakesection \maketitle configuration
  \@ifundefined{KOMAClassName}%
    {} % do nothing outside KOMA class
    {% If KOMA exists. . .
    \addtokomafont{subtitle}{\Large}
    \setkomafont{author}{\Large\scshape}
    \setkomafont{date}{\Large\normalsize}
    }
  \providecommand{\thetitle}{\@title}
  \providecommand{\theauthor}{\@author}
  \providecommand{\thedate}{\@date}

  %%fakesection Commutative diagrams support
  \ifevandiagrams
    \usepackage{tikz-cd}
    \usetikzlibrary{decorations.pathmorphing}
  \fi

  %%fakesection Page Setup
  \ifevanfancy
    \@ifundefined{KOMAClassName}
    {
      \usepackage{fancyhdr}
      \setlength{\headheight}{0.75in}
      \setlength{\oddsidemargin}{0in}
      \setlength{\evensidemargin}{0in}
      \setlength{\voffset}{-1.0in}
      \setlength{\headsep}{10pt}
      \setlength{\textwidth}{6.5in}
      \setlength{\headwidth}{6.5in}
      \setlength{\textheight}{8.75in}
      \setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
      \setlength{\footskip}{0.3in}
      \ifevanhdr
        \renewcommand{\headrulewidth}{0.5pt}
        \renewcommand{\footrulewidth}{0.0pt}
        \pagestyle{fancy}
        \lhead{Evan Chen}
        \chead{}
        \rhead{\nouppercase{\leftmark}}
        \lfoot{}
        \cfoot{\thepage}
        \rfoot{}
      \fi
    }
    {
      \usepackage[headsepline]{scrlayer-scrpage}
      \renewcommand{\headfont}{}
      \addtolength{\textheight}{3.14cm}
      \setlength{\footskip}{0.5in}
      \setlength{\headsep}{10pt}
      \ihead{\footnotesize\textbf{\theauthor} --- \thedate}
      \automark{section}
      \chead{}
      \ohead{\footnotesize\textbf{\thetitle}}
      \cfoot{\pagemark}
    }
  \fi

  %%fakesection Unicode
  \ifevanpkg
    \ifluatex
      \usepackage{fontspec}
      % https://tex.stackexchange.com/a/572220/76888
      \directlua{luaotfload.add_fallback
        ("evans_fallbacks",
          {
            "NotoColorEmoji:mode=harf;",
            "Source Han Sans TW:style=Regular;",
            "Noto Serif CJK SC:style=Regular;",
          }
        )}
      \setmainfont{lmroman10-regular}[
        BoldFont=lmroman10-bold,
        ItalicFont=lmroman10-italic,
        BoldItalicFont=lmroman10-bolditalic,
        SlantedFont=lmromanslant10-regular,
        BoldSlantedFont=lmromanslant10-bold,
        SmallCapsFont=lmromancaps10-regular,
        RawFeature={fallback=evans_fallbacks}
      ]
      \setsansfont{lmsans10-regular}[
        BoldFont=lmsans10-bold,
        ItalicFont=lmsans10-oblique,
        BoldItalicFont=lmsans10-boldoblique,
        RawFeature={fallback=evans_fallbacks}
      ]
    \else
      \ifevanchinese
        \usepackage{babel}
        \usepackage[encapsulated]{CJK}
        \usepackage{ucs}
        \usepackage[utf8x]{inputenc}
        \newenvironment{bsmi}{\begin{CJK}{UTF8}{bsmi}}{\end{CJK}}
        \newcommand{\cn}[1]{\begin{bsmi}#1\end{bsmi}}
        \AtBeginDocument{\begin{CJK}{UTF8}{bsmi}}
        \AtEndDocument{\end{CJK}}
      \fi
    \fi
  \fi

  %%fakesection Hints
  \ifevanhints
    \usepackage{answers}
    \Newassociation{hint}{hintitem}{hints}
    \renewcommand{\solutionextension}{out}
    \Opensolutionfile{hints}
    \newcommand{\makehints}{\Closesolutionfile{hints}\input{hints.out}} % chktex 27
  \fi
%%fakesection END MAIN SETUP
\fi