\documentclass[12pt,a4paper,twoside]{report}
%====En-tête====
% Ajout des packages
\usepackage[french,english]{babel} % pour dire que le texte est en francais
\usepackage{csquotes}
\usepackage{a4} % pour la taille
\usepackage[T1]{fontenc} % pour les font postscript
\usepackage[cyr]{aeguill} % Police vectorielle TrueType, guillemets francais
\usepackage{epsfig} % pour gérer les images
\usepackage{amsmath,amsthm, mathtools} % très bon mode mathématique
\usepackage{amsfonts,amssymb,bm}% permet la definition des ensembles
\DeclareMathAlphabet{\mathbbb}{U}{bbold}{m}{n} % Pour l'indicatrice

\usepackage{algorithm2e} % pour les algorithmes
% \usepackage{algpseudocode} % pour les algorithmes
\RestyleAlgo{ruled}

\usepackage{url} % pour une gestion efficace des url
\usepackage[citecolor=blueind,urlcolor=blueps,bookmarks=false,hypertexnames=true]{hyperref}  % pour les hyperliens dans le document
\usepackage{tocbibind} % Pour avoir des index pour table des matières, biblio
\usepackage{geometry}
\geometry{bmargin=25mm}

\usepackage{tikz} % For graph plots
\usepackage[outline]{contour}
\usepackage[super]{nth}

\usepackage{adjustbox}

\usepackage{pdflscape}

\usepackage{float} % pour le placement des figure
\usepackage{caption} % Figures
\usepackage{subcaption} % And Subfigures


\usepackage{longtable}
\usepackage{colortbl}

\usepackage{titling}

\usepackage{rotating} % For allowing to rotate figures

\usepackage{float} % To allow Pandoc to control figure placement
\floatplacement{figure}{H}
\floatplacement{table}{H}

\usepackage{booktabs} % For good tables
\usepackage{multirow}

% FancyHDR
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\chaptermark}[1]{\markboth{#1}{#1}}
\fancyhead[lo]{\slshape\nouppercase{\rightmark}}
\fancyhead[re]{\slshape\nouppercase{\leftmark}}
\fancyhead[ro,le]{\thepage}

\fancypagestyle{intro}{%
    \fancyhf{}
    \fancyfoot[C]{\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}

\fancypagestyle{noheader}{
  \fancyhf{}% Clear header/footer
  \renewcommand{\headrulewidth}{0pt}% No header rule
}

% Images
\graphicspath{{../img/}{../figure/}}

%% Tikz Related
\usetikzlibrary{calc,shapes,backgrounds,arrows,automata,shadows,positioning,
arrows,shapes,positioning,shadows,trees,calc,backgrounds,
automata,positioning}


\tikzset{
    basic/.style  = {draw, text width=3cm, font=\sffamily, rectangle},
    root/.style   = {basic, rounded corners=2pt, thin, align=center,
            fill=green!30},
    level 2/.style = {basic, rounded corners=6pt, thin,align=center, fill=green!60,
            text width=8em},
    level 3/.style = {basic, thin, align=left, fill=pink!60, text width=3.5cm}
}


% Couleurs
% pour tikz multilevel
\input{../shared/colors}
% Bibliographie
\input{../shared/biblio}

% Modification titre
\usepackage{titlesec}
\titlespacing*% the star= don't indent first paragraph after
    {\subsection}% which command you want to set the spacing for
    {0pt}% spacing to the left of heading
    {1ex}% spacing before the heading
    {1ex}% spacing after the heading
\titlespacing*%
    {\section}% 
    {0pt}% 
    {1ex}% 
    {1ex}%

\newcounter{customchapter}
\newcounter{maincontentend}
% Important : modifie ici le nombre de chapitres que tu as.
% A savoir que cela correspond aux nombres de labels du bandeau sur le côté.
% Le bandeau est automatiquement mis à jour pour correspondre à la valeur de la 
% variable customchapter, avec 0 = pas de label.
\newcommand\ChapNum{5}

%%%%%% Debut code onglets

\usepackage{background}
\usepackage{changepage}
\usepackage{sectsty}
\newcommand\DeactivateBG{\backgroundsetup{contents={}}}
\newcommand\ActivateBG{\backgroundsetup{
		scale=1,
		angle=0,
		opacity=0.5,
		contents={
            \ifnum\value{maincontentend}=0
			\ifnum\value{customchapter}>0
			\checkoddpage
			\ifoddpage
			\begin{tikzpicture}[remember picture,overlay]
			\node[rotate=90,minimum width=\paperheight,minimum height=0.5cm,fill=gray!40,font=\large\bfseries,text=white,anchor=south west] at ($(current page.south east)$) {};
			\node[rotate=90,minimum width=1/\ChapNum*\paperheight,minimum height=0.5cm,fill=\BoxColor,font=\large\bfseries,text=white,anchor=south west] at ([yshift=(\ChapNum-\thecustomchapter)/\ChapNum*\paperheight]$(current page.south east)$) {\chaptername~\thechapter}; 
			\end{tikzpicture}
			\else
			\begin{tikzpicture}[remember picture,overlay]
			\node[rotate=90,minimum width=\paperheight,minimum height=0.5cm,fill=gray!40,font=\large\bfseries,text=white,anchor=south west] at ([xshift=-\paperwidth+0.5cm]$(current page.south east)$) {};
			\node[rotate=270,minimum width=1/\ChapNum*\paperheight,minimum height=0.5cm,fill=\BoxColor,font=\large\bfseries,text=white,anchor=south west] at ([yshift=(\ChapNum-\thecustomchapter+1)/\ChapNum*\paperheight,xshift=-\paperwidth]$(current page.south east)$) {\chaptername~\thechapter};
			\end{tikzpicture}
			\fi
            \fi
			\fi
}
}
}

\definecolor{bleuvert}{RGB}{102, 255, 204}
\definecolor{greenAgro}{HTML}{028887}
\newcommand\BoxColor{%
	\ifcase\thecustomchapter greenAgro!40!black\or green!40!black\or blue!40!black\or  orange!70!black\or violet!60!black\or teal!60!black\or red!40!black\or blue!40!black\else greenAgro!40!black
    \fi}
% \newcommand\ChapterTitle{%
% 	\ifcase\thecustomchapter {\thechapter} \else {}
%     \fi
%     }

\sectionfont{\color{\BoxColor}}
\subsectionfont{\color{\BoxColor}}
\subsubsectionfont{\color{\BoxColor}}

%%%% End onglets

%%%%%%%%%%%%%% En-tête de chapitre %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
	\vspace*{-30\p@}%
	{
		\parindent \z@ \raggedleft \reset@font
		\scshape 
		\color{\BoxColor}{\@chapapp{} {\fontsize{100pt}{12pt}\selectfont{\textbf{\thechapter}}}}
		\par\nobreak
		\interlinepenalty\@M
		\Huge \bfseries {\color{\BoxColor}{#1}}\par\nobreak
		\vspace*{-20\p@}%
		{\color{\BoxColor}\hrulefill}
		\par\nobreak
		\vskip 10\p@
}}
\def\@makeschapterhead#1{%
	\vspace*{-30\p@}%
	{
		\parindent \z@ \raggedleft \reset@font
		\scshape \vphantom{\@chapapp{} \thechapter}
		\par\nobreak
		\interlinepenalty\@M
		\Huge \bfseries {\color{\BoxColor}{#1}}\par\nobreak
		\vspace*{-20\p@}%
		\hrulefill
		\par\nobreak
		\vskip 10\p@
}}
\makeatother

% Nouvelles commandes
\newcommand{\Tau}{\mathcal{T}}
\newcommand{\eps}[1][]{\ensuremath{\epsilon_{#1}}}


% titre et auteur
\title{Détection et comparaison de structures de réseaux écologiques}
\author{Louis Lacoste}
\begin{document}

% Pour désactiver le fond (background)
\DeactivateBG
\include{page-garde}
% Pour activer les onglets
\ActivateBG
\begin{selectlanguage}{french}
	% \maketitle
	\pagenumbering{roman}
	\tableofcontents
	\include{remerciements}
	% \include{chapter1-presentation_UMR}
\end{selectlanguage}

\begin{selectlanguage}{english}
	\pagenumbering{arabic}
	\include{chapter2-context}
	\include{chapter3-structure-detection}
	\include{chapter4-simulation-studies}

	% \chapter{Applications}
	% \include{Rcodes/real_data/application_dore}
	% \include{Rcodes/real_data/CoOPLBM_completion_analyze}

	\include{conclusions}

	\addtocounter{maincontentend}{1}
	\addtocounter{customchapter}{1}
	\printbibliography
	\input{appendices.tex}
	% \listoffigures
	% \listoftables
\end{selectlanguage}

\end{document}
