% Author: Samuele Giraudo
% Creation: mar. 2021
% Modifications: mar. 2021, apr. 2021, jun. 2021, jul. 2021, oct. 2021, jan. 2022,
% mar. 2022, apr. 2022, may 2022, aug. 2022, jan. 2023, mar. 2023, apr. 2023, may 2023

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{Article2023}[Article style 2023]

% Base class.
\LoadClass[12pt,reqno]{amsart}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Colors.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Colors need to be defined early because some package options use these.
\RequirePackage{xcolor}
\definecolor{ColA}{HTML}{0061b7} % Dark blue.
\definecolor{ColB}{HTML}{b75600} % Dark orange.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Misc.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Trick to fix the error "Too many alphabets".
\newcommand\hmmax{0}
\newcommand\bmmax{0}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Package inclusions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Main packages.
\RequirePackage[utf8]{inputenc}
\RequirePackage[french,english]{babel}
%\RequirePackage[T1]{fontenc}
\RequirePackage[math]{anttor}
\RequirePackage{microtype}

% Layout.
\RequirePackage[
    top=2.9cm,
    bottom=2.9cm,
    left=3.1cm,
    right=3.1cm,
    footskip=32pt,
    headsep=24pt
]{geometry}

% Links.
\RequirePackage[
    colorlinks=true,
    hyperindex=true,
    frenchlinks=true,
    citecolor=ColA!75,
    linkcolor=ColA!80!ColB,
    urlcolor=ColA!75!ColB,
    linktocpage
]{hyperref}

% Misc.
\RequirePackage{amsmath,amsfonts,amssymb,amsthm}
\RequirePackage{bm}
\RequirePackage{shuffle}
\RequirePackage{mathtools}
\RequirePackage{dsfont}
\RequirePackage{wasysym}
\RequirePackage{stmaryrd}
\RequirePackage{mleftright}
\RequirePackage{caption}
\RequirePackage{subfig}
\RequirePackage{multirow}
\RequirePackage{enumitem}
\RequirePackage{multicol}
\RequirePackage{amsaddr}
\RequirePackage{cancel}
\RequirePackage[color=ColB!40]{todonotes}
\RequirePackage{ifthen}
\RequirePackage{nameref}
\RequirePackage{datetime}
\RequirePackage[indent=2em,tocskip=0.15ex,skip=0.5ex]{parskip}
\RequirePackage{lastpage}

% Tikz.
\RequirePackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{fit}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{arrows.meta}

% References (bibliography).
\RequirePackage[
    maxbibnames=16,
    citestyle=alphabetic,
    style=alphabetic,
    backref=true
]{biblatex}
\addbibresource{Bibliography.bib}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Page headers.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\makeatletter
\newcommand*{\currentname}{§ \@currentlabelname}
\makeatother

\newcommand{\CornerAngleNW}{
    \begin{tikzpicture}[scale=0.3]
        \draw[line width=1pt](0,0)--(1,0);
        \draw[line width=1pt](0,0)--(0,-1);
    \end{tikzpicture}}
\newcommand{\CornerAngleNE}{
    \begin{tikzpicture}[scale=0.3]
        \draw[line width=1pt](0,0)--(-1,0);
        \draw[line width=1pt](0,0)--(0,-1);
    \end{tikzpicture}}
\newcommand{\CornerAngleSW}{
    \begin{tikzpicture}[scale=0.3]
        \draw[line width=1pt](0,0)--(1,0);
        \draw[line width=1pt](0,0)--(0,1);
    \end{tikzpicture}}
\newcommand{\CornerAngleSE}{
    \begin{tikzpicture}[scale=0.3]
        \draw[line width=1pt](0,0)--(-1,0);
        \draw[line width=1pt](0,0)--(0,1);
    \end{tikzpicture}}

% On top of the pages.
\renewcommand{\headrulewidth}{1pt}
\fancyhead[L]{\CornerAngleNW \enspace \scriptsize \it \currentname}
\fancyhead[C]{\footnotesize \bf \NoUppercase{\shorttitle}}
\fancyhead[R]{\scriptsize \NoUppercase{\shortauthors} \enspace \CornerAngleNE}

% On bottom of the pages.
\renewcommand{\footrulewidth}{1pt}
\newcommand{\BottomPages}{
    \fancyfoot[L]{\CornerAngleSW \enspace \footnotesize \thepage/\pageref{LastPage}}
    \fancyfoot[C]{}
%    \fancyfoot[R]{\scriptsize \ColMix{90}{\tt \today \quad \currenttime}
    \fancyfoot[R]{\scriptsize \ColMix{90}{\tt }
        \enspace \CornerAngleSE}
}
\BottomPages

% To have the same bottom page also on the first.
\fancypagestyle{HeaderFirstPage}{
    \fancyhf{}
    \BottomPages
}

\setlength{\headheight}{13.15pt}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Style settings.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Set the separator for the dates generated by \currenttime.
\renewcommand{\dateseparator}{-}

% Right introduction for the date on the first page.
\renewcommand{\datename}{{\it Date}:}

% Modifications of the style of the numbers of the sections.
\RequirePackage{titlesec}
\titleformat{\section}
    %{\centering\Large\scshape\color{ColA}}
    {\centering\LARGE\scshape\color{ColA}}
    {\colorbox{ColA!40}{\parbox{2.5em}{\centering\thesection}}}
    {0.25em}
    {}

\titleformat{\subsection}
    {\Large\scshape\color{ColA}}
    {\colorbox{ColA!40}{\parbox{2.5em}{\centering \thesubsection}}}
    {0.25em}
    {}

\titleformat{\subsubsection}[runin]
    {\scshape\color{ColA}}
    {\colorbox{ColA!40}{\parbox{2.5em}{\centering\thesubsubsection}}}
    {0.25em}
    {}
    [.]

% Line space.
\linespread{1.15}
\renewcommand{\arraystretch}{1.4}

% Vertical space for equations.
\setlength{\abovedisplayskip}{5pt}
\setlength{\belowdisplayskip}{5pt}

% Alphabetic footnote marks.
\renewcommand{\thefootnote}{\alph{footnote}}

% To allow cutting equations in several pages.
\allowdisplaybreaks

% Reduce first vertical spacing of multicols.
\setlength{\multicolsep}{6pt plus 2pt minus 1.5pt}

% Numbering of equations.
\numberwithin{equation}{subsection}

% Font size for captions.
\captionsetup[figure]{font=footnotesize}

% Depth of the table of contents.
\setcounter{tocdepth}{2}

\makeatletter
\def\l@section{\@tocline{1}{0em}{1em}{1em}{}}
\def\l@subsection{\@tocline{2}{0em}{4em}{2em}{}}
\def\l@ssububsection{\@tocline{3}{0em}{0em}{0em}{}}
\makeatother

% Theorem environments style.
\newtheoremstyle{TheoremEnvironmentStyle}
    {6pt plus 2pt minus 2pt}                            % Space above.
    {6pt plus 2pt minus 2pt}                            % Space below.
    {\itshape}                                          % Body font.
    {0pt}                                               % Indent space.
    {\color{ColA}\bfseries}                             % Theorem head font and color.
    { ---}                                              % Punctuation after theorem head.
    {5pt plus 1pt minus 1pt}                            % Space after theorem head.
    {$\blacktriangleright$ \thmname{#1} \thmnumber{#2}} % Theorem head specification.

% Environments definitions.
\theoremstyle{TheoremEnvironmentStyle}
\newtheorem{Theorem}{Theorem}[subsection]
\newtheorem{Proposition}[Theorem]{Proposition}
\newtheorem{Lemma}[Theorem]{Lemma}

% Redefinition of the proof environment.
\renewcommand{\qedsymbol}{\ColB{$\blacksquare$}}
\renewenvironment{proof}[1][\proofname]{%
    \noindent \ColB{$\blacktriangleleft$ {\bf #1 ---}}
    }{%
    \qed
    \smallbreak
}

% Better comparison symbols.
\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}
\renewcommand{\nleq}{\nleqslant}
\renewcommand{\ngeq}{\ngeqslant}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Option management.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Booleans for the options.
\newboolean{Draft}
\DeclareOption{Draft}{\setboolean{Draft}{true}}

\newboolean{Final}
\DeclareOption{Final}{\setboolean{Final}{true}}

\ProcessOptions\relax

% Draft option.
\ifthenelse{\boolean{Draft}}{
    \RequirePackage[inline]{showlabels}
    \RequirePackage{refcheck}
    \geometry{showframe,showcrop}}
{}

% Final option.
\ifthenelse{\boolean{Final}}{
    \PassOptionsToPackage{disable}{todonotes}}
{}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Macro definitions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Color macros.
\newcommand{\ColA}[1]{\textcolor{ColA}{#1}}
\newcommand{\ColB}[1]{\textcolor{ColB}{#1}}
\newcommand{\ColMix}[2]{\textcolor{ColA!#1!ColB}{#2}}

% Tools macros.
\newcommand{\Hide}[1]{\ColA{\tt HIDEN}}
\newcommand{\Def}[1]{\ColMix{20}{\em #1}}
\newcommand{\Par}[1]{\mleft(#1\mright)}
\newcommand{\Bra}[1]{\mleft\{#1\mright\}}
\newcommand{\Han}[1]{\mleft[#1\mright]}
\newcommand{\HanL}[1]{\mleft\llbracket#1\mright]}
\newcommand{\Brr}[1]{\mleft|#1\mright|}
\newcommand{\Angle}[1]{\mleft\langle#1\mright\rangle}
\newcommand{\AAngle}[1]{\Angle{\Angle{#1}}}
\newcommand{\BPar}[1]{\boldsymbol{\mleft(\mright.}#1\boldsymbol{\mleft.\mright)}}
\newcommand{\BBrack}[1]{%
    \pmb{\mleft[\vphantom{#1}\mright.}%
    #1%
    \pmb{\mleft.\vphantom{#1}\mright]}}
\newcommand{\Iverson}[1]{\BBrack{#1}}
\newcommand{\BBar}[1]{\overline{#1}}
\newcommand{\OEIS}[1]{\href{http://oeis.org/#1}{{\bf #1}}}
\newcommand{\Arxiv}[1]{\href{https://arxiv.org/abs/#1}{\tt arXiv:#1}}

\newenvironment{Page}[1]{%
    \begin{minipage}{#1\textwidth}
    }{%
    \end{minipage}}

% Code highlighting.
\newcommand{\Code}[1]{%
    \setlength{\fboxsep}{1pt}%
    \colorbox{ColB!10}{%
    \renewcommand{\arraystretch}{1.0}%
    \textcolor{ColA!40}{%
    \begin{tt}%
    \begin{scriptsize}%
    \begin{tabular}{@{}l@{}}%
        #1%
    \end{tabular}%
    \end{scriptsize}%
    \end{tt}}%
}}

\newenvironment{NoUppercase}{%
    \let\uppercase\relax%
    \renewcommand{\uppercasenonmath}[1]{}%
}{}

% Usual symbols.
\newcommand{\N}{\mathbb{N}}
\newcommand{\PP}{\mathbb{P}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\K}{\mathbb{K}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Macro for the beginning and the end of the document.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Prints the title page.
\newcommand{\MakeFirstPage}{
    \yyyymmdddate
    \begin{NoUppercase}
        \maketitle
    \end{NoUppercase}
    \vspace{-0.25cm}
{
\thispagestyle{myheadings}
\font\rms=cmr8 
\font\its=cmti8 
\font\bfs=cmbx8

\markright{\its S\'eminaire Lotharingien de
Combinatoire \bfs 79 \rms (2023), Article~B79h\hfill}
\def\thepage{}
    \begin{small}
        \tableofcontents
    \end{small}
}
%    \thispagestyle{HeaderFirstPage}
%    \newpage
}

% Prints the bibliography.
\newcommand{\MakeReferences}{
    \addcontentsline{toc}{section}{References}
    \printbibliography
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tikz definitions.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Tikz tools.
\tikzstyle{Centering}=[{baseline={([yshift=-0.5ex]current bounding box.center)}}]
\tikzstyle{MarkA}=[draw=ColA!80,fill=ColA!8]
\tikzstyle{MarkB}=[draw=ColB!80,fill=ColB!8]

% Tikz styles for tree drawings.
\tikzstyle{Node}=[circle,draw=ColB!90,fill=ColB!10,inner sep=1pt,minimum size=2mm,thick,
font=\scriptsize]
\tikzstyle{Leaf}=[rectangle,draw=ColA!60,fill=ColA!10,inner sep=0pt,minimum size=1mm,thick]
\tikzstyle{NodeST}=[font=\scriptsize]
\tikzstyle{LeafST}=[font=\scriptsize,node distance=2mm]
\tikzstyle{Edge}=[draw=ColB!95,cap=round,rounded corners=2.5pt,thick]
\tikzstyle{EdgeLabel}=[rectangle,rounded corners=0pt,inner sep=0.125pt,minimum size=3mm,
fill=ColA!15,draw=ColA!90,font=\tiny,midway,line width=0.5pt]
\tikzstyle{Subtree}=[regular polygon,regular polygon sides=3,MarkA,thick,minimum size=5mm,
font=\scriptsize]

% Tikz styles for graphs.
\tikzstyle{GraphVertex}=[circle,MarkA,inner sep=1pt,minimum size=1.5mm,thick]
\tikzstyle{GraphLabeledVertex}=[font=\footnotesize,node distance=3mm]
\tikzstyle{GraphEdge}=[ColB,cap=round,very thick]
\tikzstyle{GraphArc}=[GraphEdge,->]
\tikzstyle{GraphEdgeLabel}=[midway,inner sep=1pt,fill=ColA!0,font=\scriptsize]

% Tikz styles for paths drawings.
\tikzstyle{PathGrid}=[very thin,draw=ColB!60]
\tikzstyle{PathNode}=[circle,draw=ColB!90,fill=ColB!20,thick,inner sep=0pt,minimum size=2mm]
\tikzstyle{PathStep}=[color=ColB,thick]

% Tikz styles for morphism diagrams.
\tikzstyle{Injection}=[draw,{>[scale=1.5,length=3,width=2.5]}-{>[scale=1.5,length=3,
width=2.5]}]
\tikzstyle{Surjection}=[draw,-{>[scale=1.5,length=3,width=2.5]>[scale=1.5,length=3,
width=2.5]}]
\tikzstyle{Bijection}=[draw,double,{<[scale=1.5,length=4,width=5]}-{>[scale=1.5,length=4,
width=5]}]
\tikzstyle{Map}=[draw,-{>[scale=1.5,length=3,width=2.5]}]

