\usepackage[french]{babel}
\usepackage[a4paper, margin=2cm]{geometry}
\usepackage[hidelinks]{hyperref}
\usepackage{amsmath}
\usepackage{bbm}
\usepackage{bm}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{stmaryrd}
\usepackage{xcolor}
\usepackage{mdframed}
\usepackage{etoolbox}
\usepackage{xparse}
\usepackage{parskip}
\usepackage{tikz,tkz-tab}
\usepackage{pgfplots}
\usepackage[bottom,stable]{footmisc}
\usepackage{titleps}
\ifsolo
\else
\usepackage{lastpage}
% \usepackage[nohints,french]{minitoc}
% \usepackage[nohints]{minitoc}
\fi
\usepackage{tocloft}
% \usepackage{lmodern}
\usepackage{enumitem}
\usepackage{needspace}
% \usepackage[noautomatic]{imakeidx}
\usepackage[normalem]{ulem}


% \AtBeginDocument{\def\labelitemi{$\bullet$}}
\setlist[itemize]{leftmargin=.5cm,listparindent=\parindent}
\setlist[enumerate]{leftmargin=.7cm}

\newcommand{\todo}[1]{{\color{red}\textbf{À faire:} #1}}
\newcommand{\reftx}[1]{{\color{gray}[#1]}}
\newcommand{\rem}[0]{\textbf{Remarque: }}
\newcommand{\refannexe}[1]{\hyperref[#1]{\textbf{Texte~\ref{#1}}}}
\theoremstyle{definition}
\newtheorem{annexetexte}{Texte}

\NewDocumentEnvironment{extquote}{m}%
    {\begin{mdframed}%
        [topline=false,%
            rightline=false,%
            bottomline=false,%
            linewidth=2pt,%
            linecolor=black!70,%
            backgroundcolor=black!10]%
            %\itshape
        }%
        {\\[-3ex]\begin{flushright}\normalfont\textbf{#1}\end{flushright}\end{mdframed}}

\newenvironment{texte}[2]{\begin{annexetexte}
        \needspace{.1\textheight}
        \label{#1}
        \addcontentsline{toc}{subsection}{\texorpdfstring{\hyperref[#1]{#2}}{#2}}
        \textbf{#2}\par
}{\end{annexetexte}}

\renewcommand{\thesection}{\Alph{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}
\renewcommand{\thesubsubsection}{(\emph{\alph{subsubsection}\,})}
\renewcommand{\theannexetexte}{\arabic{annexetexte}}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}

\ifsolo
\else
% Séparation entre "Chapitre" et le titre dans la toc
\setlength{\cftchapnumwidth}{2.3cm}
\renewcommand{\cftchappresnum}{\chaptername\ }
\renewcommand{\cftchapaftersnum}{ -- }
\fi

\setlength{\cftsecnumwidth}{0.65cm}
\renewcommand{\cftsecpresnum}{}
\renewcommand{\cftsecaftersnum}{ -- }

\setlength{\cftsubsecnumwidth}{0.6cm}
\renewcommand{\cftsubsecpresnum}{}
\renewcommand{\cftsubsecaftersnum}{ -- }

\setlength{\cftsubsubsecnumwidth}{0.9cm}
\renewcommand{\cftsubsubsecpresnum}{}
\renewcommand{\cftsubsubsecaftersnum}{ -- }

% Change "Chapitre" en "Annexe" après \appendix dans la toc
\makeatletter
\g@addto@macro\appendix{%
  \addtocontents{toc}{%
    \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
  }%
  \protect\renewcommand{\thesection}{\Roman{section}}%
}
\makeatother

\definecolor{light-gray}{gray}{0.7}
\definecolor{dark-gray}{gray}{0.2}
\colorlet{DarkBlue}{blue!20!black!90}
\definecolor{gray}{rgb}{0.5, 0.5, 0.5}

\renewcommand{\cftdot}{{\color{light-gray}.}}

\newcommand{\textquote}[1]{{«~\color{DarkBlue}#1~»}}


\ifsolo
\addto\captionsfrench{
% \addto\captionsenglish{
  \renewcommand{\contentsname}%
    {Chapter content}%
}
\else
% \renewcommand{\thechapter}{\Roman{chapter}}
% \mtcsetoffset{minitoc}{-2em}
% \renewcommand{\cftsecfont}{\small\bfseries}
% \setcounter{tocdepth}{1}
% \setlength{\cftchapnumwidth}{1.4cm}
\fi

\newpagestyle{main}{
  \setheadrule{1pt}
  % \ifsolo\else \setfootrule{1pt}\fi
  \sethead{\thesection ~--~\textsc{\sectiontitle}}{}{Page \thepage\ifsolo\else~/~\pageref{LastPage}\fi}
  % \setfoot{\ifsolo\else\fi}{}{}
}

\tocloftpagestyle{empty}
\pagestyle{main}

\pgfplotsset{compat=1.16}
