\ProvidesPackage{packages/sleek}[2023/09/18 v1.2.3 Sleek]

%%%%%%%%%%%%
% Settings %
%%%%%%%%%%%%

% Encoding

\RequirePackage[utf8]{inputenc}

% Font

% \RequirePackage{lmodern}
\RequirePackage{mlmodern}
% \RequirePackage{libertinus}
\RequirePackage[T1]{fontenc}
\RequirePackage{microtype}

% Layout

\RequirePackage{geometry}
\RequirePackage{fancyhdr}
\RequirePackage[bottom]{footmisc}
\RequirePackage{lscape}

\geometry{margin=2.5cm}

\pagestyle{fancy}
\fancyhead[L]{}
\fancyhead[R]{}
\fancyfoot[C]{\thepage}
\renewcommand*{\headrulewidth}{0pt}

% Code blocks

\RequirePackage[newfloat]{minted}

% https://tex.stackexchange.com/a/254177
% Non-floating listing environment (w/ page breaks)
\newenvironment{longlisting}{\captionsetup{type=listing}}{}
% Floating listing environment (w/o page breaks)
\SetupFloatingEnvironment{listing}{}

% Text

\RequirePackage{csquotes}
\RequirePackage[inline]{enumitem}
\RequirePackage{eurosym}
\RequirePackage[parfill]{parskip}
\RequirePackage[dvipsnames]{xcolor}

% Links

\RequirePackage[
    pdfusetitle,
    colorlinks=true,
    citecolor=purple,
    filecolor=black,
    linkcolor=blue,
    urlcolor=blue,
    linktoc=page,
]{hyperref}
\RequirePackage{bookmark}
\RequirePackage{qrcode}

% Mathematics

\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{bm}
\RequirePackage{esint}
\RequirePackage{mathtools}

% Units

\RequirePackage{siunitx}

\sisetup{separate-uncertainty}
\sisetup{separate-uncertainty-units=single}

% Markers

\RequirePackage{circledsteps}
\pgfkeys{/csteps/inner color=white}
\pgfkeys{/csteps/fill color=black}

% Figures

\RequirePackage{float}
\RequirePackage[skip=1.5ex]{caption}
\RequirePackage{subcaption}

\captionsetup{labelsep=period} % 'Figure 1.2.' instead of 'Figure 1.2:'

% Tables

\RequirePackage{array}
\RequirePackage{booktabs}
\RequirePackage{tabularx}
\RequirePackage{multirow}

\renewcommand{\arraystretch}{1.1}

\newcolumntype{Z}{>{\centering\arraybackslash}X} % Tabular text-wrapping column
\renewcommand\tabularxcolumn[1]{m{#1}} % Vertical centering of text in X columns

% Algorithms

\RequirePackage[ruled]{algorithm}
\RequirePackage[noend]{algpseudocode}

\makeatletter
\renewcommand\fs@ruled{% https://ctan.org/pkg/float
    \def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@ruled%
    \def\@fs@pre{\hrule height \heavyrulewidth depth 0pt \kern 4pt}%
    \def\@fs@mid{\kern 4pt \hrule height \heavyrulewidth depth 0pt \kern 4pt}%
    \def\@fs@post{\kern 4pt \hrule height \heavyrulewidth depth 0pt \relax}%
    \let\@fs@iftopcapt\iftrue%
}
\makeatother

\algrenewcommand{\algorithmiccomment}[1]{\hfill #1}
\algrenewcommand{\alglinenumber}[1]{\footnotesize{#1}}

\algnewcommand\Input{\item[\textbf{Input:}]}
\algnewcommand\Output{\item[\textbf{Output:}]}

\algnewcommand\Break{\textbf{break}}
\algnewcommand\Continue{\textbf{continue}}

% Glossaries

\RequirePackage[
    automake,
    nonumberlist,
    toc=false
]{glossaries-extra}

\setglossarysection{section}

% Bibliography

\RequirePackage[
    hyperref,
    backend=biber,
    style=numeric,
    % sorting=none,
    % maxcitenames=1,
    % maxbibnames=3,
    % backref=true
]{biblatex}

\setlength\bibitemsep{1ex}

\DeclareFieldFormat*{title}{\enquote{#1}}
\DeclareFieldFormat*{citetitle}{\enquote{#1}}

\DefineBibliographyStrings{english}{
    backrefpage = {page},
    backrefpages = {pages}
}

\DefineBibliographyStrings{french}{
    backrefpage = {page},
    backrefpages = {pages}
}

\DefineBibliographyStrings{german}{
    backrefpage = {Seite},
    backrefpages = {Seiten}
}

% Others

\RequirePackage{comment}

%%%%%%%%%%%
% Options %
%%%%%%%%%%%

\DeclareOption{header}{
    \geometry{top=3.5cm, bottom=2.5cm, right=2.5cm, left=2.5cm}
    \fancyhead[R]{\leftmark}
}

\DeclareOption{french}{
    %% Babel
    \frenchbsetup{StandardLists=true}
    \frenchbsetup{SmallCapsFigTabCaptions=false}

    %% Macros
    \def\cad{c.-à-d.\@}
    \def\Cad{C.-à-d.\@}
}

\ProcessOptions\relax

%%%%%%%%%%%%
% Commands %
%%%%%%%%%%%%

% Abbreviations

\def\cf{\emph{cf.}\@} % confer
\def\eg{\emph{e.g.}\@} % exempli gratia
\def\ie{\emph{i.e.}\@} % id est

% Table of contents

\newcommand*{\romantableofcontents}{ % table of contents with roman (i, ii, ...) numbering of the pages
    \newpage
    \pagenumbering{roman}
    \tableofcontents
    \newpage
    \pagenumbering{arabic}
}

% Mathematics

\DeclarePairedDelimiter\rbk{(}{)} % round brackets (parentheses)
\DeclarePairedDelimiter\cbk{\{}{\}} % curly brackets {braces}
\DeclarePairedDelimiter\sbk{[}{]} % square brackets [brackets]

\DeclarePairedDelimiter\abs{\lvert}{\rvert} % absolute value |x|
\DeclarePairedDelimiter\norm{\lVert}{\rVert} % norm ||x||
\DeclarePairedDelimiter\ceil{\lceil}{\rceil} % ceil ⌈x⌉
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor} % floor ⌊x⌋

\newcommand*{\fact}[1]{#1!} % factorial x!

\renewcommand*{\d}[1]{\operatorname{d}\!{#1}} % upright 'd' for differential

\DeclareMathOperator{\tr}{tr} % trace
\DeclareMathOperator{\diag}{diag} % diagonal

% Figures

\newcommand*{\noskipcaption}[1]{\caption{#1}\vspace{-\intextsep}} % caption without additional vertical space

% Footnotes

\makeatletter
\def\blindfootnote{\gdef\@thefnmark{}\@footnotetext} % footnote without number
\makeatother

\endinput

% In-PDF comments

\newboolean{showcomments}
\setboolean{showcomments}{true}

\ifthenelse{\boolean{showcomments}}
{ \newcommand{\mynote}[3]{
    \fbox{\bfseries\sffamily\scriptsize#1}
    {\small$\blacktriangleright$\textsf{\emph{\color{#3}{#2}}}$\blacktriangleleft$}}}
{ \newcommand{\mynote}[3]{}}
\newcommand{\shrink}[1]{}

\newcommand{\jb}[1]{\mynote{Jalil}{#1}{red}}
\newcommand{\vl}[1]{\mynote{Vincent}{#1}{blue}}
