%%% File: PhDThesisED182.cls
%%% Brief: Document class template for ED182 thesis manuscript
%%% Use: \documentclass[showNotes, showLineNumbers, showWatermark]{PhDThesisED182}
%%% Author: Alexandre BIGOT, alexandre.bigot@iphc.cnrs.fr
%%% Tweaks: Thibault BARNOUIN, thibault.barnouin@astro.unistra.fr

%% Identification
%% The class identifies itself and the LaTeX version needed
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{PhDThesisED182}[2024-02-28 Minimal class for PhD thesis manuscript in ED182]

%% Load the article class file
\LoadClass[a4paper,twoside,12pt]{report}

%%%%%%%%%%%%%%%% Commands and default values for Covers %%%%%%%%%%%%%%%%
% Author name
\newcommand{\Firstname}[1]{\gdef\@Firstname{#1}}
\Firstname{Firstname}
\newcommand{\Lastname}[1]{\gdef\@Lastname{#1}}
\Lastname{Lastname}
% University name and logo
\newcommand{\UniversityName}[1]{\gdef\@UniversityName{#1}}
\UniversityName{Universit\'e de Strasbourg}
\newcommand{\UniversityLogo}[1]{\gdef\@UniversityLogo{#1}}
\UniversityLogo{Images/Covers/Logo\_StrasbourgUni.pdf}
% Labo name and logo
\newcommand{\LaboName}[1]{\gdef\@LaboName{#1}}
\LaboName{My Laboratory}
\newcommand*{\LaboLogo}[1]{\gdef\@LaboLogo{#1}}
\LaboLogo{}
% Doctoral school name and logo
\newcommand{\DoctoralSchoolName}[1]{\gdef\@DoctoralSchoolName{#1}}
\DoctoralSchoolName{\'Ecole Doctorale de physique et chimie-physique}
\newcommand{\DoctoralSchoolLogo}[1]{\gdef\@DoctoralSchoolLogo{#1}}
\DoctoralSchoolLogo{Images/Covers/logo\_ED182}
% Thesis title and subtitle in French and English
\newcommand{\TitreThese}[1]{\gdef\@TitreThese{#1}}
\TitreThese{Le titre de la thèse en français.}
\newcommand*{\SousTitreThese}[1]{\gdef\@SousTitreThese{#1}}
\SousTitreThese{}
\newcommand{\resume}[1]{\gdef\@resume{#1}}
\resume{1000 caract\`eres maximum}
\newcommand{\motscles}[1]{\gdef\@motscles{#1}}
\motscles{...}
\newcommand{\ThesisTitle}[1]{\gdef\@ThesisTitle{#1}}
\ThesisTitle{Title of the thesis in english.}
\newcommand*{\ThesisSubTitle}[1]{\gdef\@ThesisSubTitle{#1}}
\ThesisSubTitle{}
\renewcommand{\abstract}[1]{\gdef\@abstract{#1}}
\abstract{1000 letters max}
\newcommand{\keywords}[1]{\gdef\@keywords{#1}}
\keywords{...}
\newcommand{\ThesisDate}[1]{\gdef\@ThesisDate{#1}}
\ThesisDate{XX mois 20XX}
% Discipline
\newcommand{\Discipline}[1]{\gdef\@Discipline{#1}}
\Discipline{Physique}
\newcommand*{\Speciality}[1]{\gdef\@Speciality{#1}}
\Speciality{}
%%% Members of the jury title, name, position and affiliation
\newcommand{\person}[5]{\hspace{2mm}\bfseries{#1\, \MakeUppercase{#2}\, #3} & {#4, #5}\\}
% Directeurs
\newcommand{\directeurs}[1]{\gdef\@directeurs{#1}}
\directeurs{
    \person{Civ.}{Lastname}{Firstname}{Pos.}{Affiliation}
    \person{Civ.}{Lastname}{Firstname}{Pos.}{Affiliation}
}
% Rapporteurs
\newcommand{\rapporteurs}[1]{\gdef\@rapporteurs{#1}}
\rapporteurs{
    \person{Civ.}{Lastname}{Firstname}{Pos.}{Affiliation}
    \person{Civ.}{Lastname}{Firstname}{Pos.}{Affiliation}
}
% Jury
\newcommand{\jury}[1]{\gdef\@jury{#1}}
\jury{
    \person{Civ.}{Lastname}{Firstname}{Pos.}{Affiliation}
    \person{Civ.}{Lastname}{Firstname}{Pos.}{Affiliation}
    \person{Civ.}{Lastname}{Firstname}{Pos.}{Affiliation}
}

%% Load packages
\PassOptionsToPackage{pdftitle={\@ThesisTitle}, pdfauthor={\@Firstname \@Lastname}, pdfcreator={PdfLaTeX}, pdfkeywords={\@keywords}, pdfsubject={Thesis Manuscript}}{hyperref}\RequirePackage{hyperref} % Extensive support for hypertext
\makeatother
\PassOptionsToPackage{a4paper,inner=25mm,outer=15mm,top=25mm,bottom=20mm}{geometry}\RequirePackage{geometry} % Flexible and complete interface to document dimensions
\PassOptionsToPackage{T1}{fontenc}\RequirePackage{fontenc} % Standard package for selecting font encodings
%\PassOptionsToPackage{comma,square,numbers,sort&compress}{natbib}\RequirePackage{natbib} % Flexible bibliography support
\PassOptionsToPackage{main=english,french}{babel}\RequirePackage{babel} % Multilingual support
\RequirePackage{lmodern} % Make sure thesis is ready for printing
\RequirePackage{graphicx} % Enhanced support for graphics
\RequirePackage{amsmath} % AMS mathematical facilities
\RequirePackage{amsfonts} % TeX fonts from the American Mathematical Society
\RequirePackage{xcolor} % Driver-independent color extensions
\RequirePackage{fancyhdr} % Extensive control of page headers and footers
\RequirePackage{etoolbox} % Extended conditional commands
\PassOptionsToPackage{most}{tcolorbox}\RequirePackage{tcolorbox} % Coloured boxes
\PassOptionsToPackage{nottoc}{tocbibind}\RequirePackage{tocbibind}  % Add bibliography/index/contents to Table of Contents
\RequirePackage{minitoc} % Produce a table of contents for each chapter, part or section
\PassOptionsToPackage{title}{appendix}\RequirePackage{appendix} % Extra control of appendices
\PassOptionsToPackage{modulo}{lineno}\RequirePackage{lineno} % Line numbers on paragraphs
\RequirePackage{macros} % Personal macros for bibliography

\addbibresource[glob]{*.bib}

%% Define my colours
\definecolor{DarkBlue}{rgb}{0.0, 0.0, 0.55}
\definecolor{DarkRed}{rgb}{0.55, 0.0, 0.0}
\definecolor{DarkGreen}{rgb}{0.0, 0.2, 0.13}
\definecolor{DodgerBlue}{rgb}{0.12, 0.56, 1.0}
\colorlet{DodgerBlue2}{DodgerBlue!80}

%% Color commands
\newcommand{\mycolor}[2]{\color{#1}#2\color{black}\xspace}
\newcommand{\red}[1]{\color{red}#1\color{black}\xspace}

%% Change hyperlinks style
\hypersetup
{
    colorlinks=true,
    linkcolor=black,
    linktocpage=false, % to have the link on the page number in toc
    filecolor=magenta,
    urlcolor=DodgerBlue,
    citecolor=DodgerBlue,
}

%% Fonts substitutions for non existing bold small caps in lmodern
\rmfamily
\DeclareFontShape{T1}{lmr}{b}{sc}{<->ssub*cmr/b/sc}{}
\DeclareFontShape{T1}{lmr}{bx}{sc}{<->ssub*cmr/bx/sc}{}

\sffamily
\DeclareFontShape{T1}{lmss}{m}{sc} { <-> ssub * phv/m/sc }{}
\DeclareFontShape{T1}{lmss}{bx}{sc} { <-> ssub * phv/bx/sc }{}

%% Table of contents configuration
\setcounter{minitocdepth}{3}
\setlength{\mtcindent}{24pt}
\renewcommand{\mtcfont}{\small}
\renewcommand{\mtifont}{\large\bf}
\renewcommand{\mtcSfont}{\small\bf}
\renewcommand{\mtcSSfont}{\small}
%\renewcommand{\mtctitle}{Contents}

%% Section configuration | Change the numerotations of sections
    % \renewcommand{\thesection}{\Roman{section})}
    % \renewcommand{\thesubsection}{\Roman{section}.\arabic{subsection})}
    % \renewcommand{\thesubsubsection}{\Roman{section}.\arabic{subsection}.\alph{subsubsection})}

%% A simple box
\newenvironment{mybox}[0]{%
    \tcolorbox[opacityback=0., standard jigsaw,breakable]}%
    {\endtcolorbox}

%% Change left and right margins (used in front and back covers)
\newenvironment{changemargin}[2]{%
    \begin{list}{}{%
        \setlength{\topsep}{0pt}%
        \setlength{\leftmargin}{#1}%
        \setlength{\rightmargin}{#2}%
        \setlength{\listparindent}{\parindent}%
        \setlength{\itemindent}{\parindent}%
        \setlength{\itemsep}{\parskip}%
        \setlength{\parsep}{\parskip}%
    }%
    \item[]
}{\end{list}}

%% Save deault margin lengths
\newlength{\defaultOddsidemargin}
\setlength{\defaultOddsidemargin}{\oddsidemargin}
\newlength{\defaultEvensidemargin}
\setlength{\defaultEvensidemargin}{\evensidemargin}

%% Switches
\newif\ifshowNotes
    \newenvironment{notes}[1]{\ifshowNotes #1\fi}

\newif\ifshowLineNumbers
%
%% Class options
\DeclareOption{showNotes}{\showNotestrue}
\DeclareOption{showLineNumbers}{\showLineNumberstrue}
\ProcessOptions\relax % to process options
