\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage[colorlinks,urlcolor=bleu,linkcolor=black]{hyperref}
\usepackage[fancyhdr,minitoc,euclide]{teach}
	\makeatletter
	\renewcommand*\l@section{\color{black}\def\@linkcolor{black}\@dottedtocline{1}{1.5em}{2.5em}}
	\renewcommand*\l@subsection{\color{black}\def\@linkcolor{black}\@dottedtocline{2}{2.5em}{3.5em}}
	\makeatother
\usepackage[upright]{fourier}
\usepackage{eso-pic}
\usepackage{geometry}
\usepackage{eurosym}
\usepackage{tkz-tab,tkz-euclide}
	\usetikzlibrary{calc,%
	shadows,%
	shapes.geometric,%
	decorations.pathmorphing,%
	spy,shapes.symbols}%,decorations.fractals}
\usepackage{cancel}
\usepackage{numprint}
\usepackage{multicol}
\usepackage{mathrsfs}
\usepackage{ulem}
\usepackage{systeme,xlop}
\usepackage{diagbox}
\usepackage{listingsutf8}
	\lstset{%
	inputencoding=utf8,
	frame=single,
	framerule=1pt,
	rulecolor=\color{orange},
	backgroundcolor=\color{orange!20},
	commentstyle=\color{red},
	showstringspaces=false,
	basicstyle=\ttfamily,
	keywordstyle=\color{orange},
	language=python,
  	columns=flexible,
  	keepspaces=true,
  	upquote=true,
	classoffset=0,
	mathescape,
	literate=
    {é}{{\'e}}{1}%
    {è}{{\`e}}{1}%
    {à}{{\`a}}{1}%
    {â}{{\^a}}{1}%%%
    {ç}{{\c{c}}}{1}%
    {œ}{{\oe}}{1}%
    {ù}{{\`u}}{1}%
    {É}{{\'E}}{1}%
    {È}{{\`E}}{1}%
    {À}{{\`A}}{1}%
    {Ç}{{\c{C}}}{1}%
    {Œ}{{\OE}}{1}%
    {Ê}{{\^E}}{1}%
    {ê}{{\^e}}{1}%
    {î}{{\^i}}{1}%
    {ï}{{\"i}}{1}%%%
    {ô}{{\^o}}{1}%
    {û}{{\^u}}{1}%
    ,
  breaklines=true
}
\usepackage{pas-algo}
\usepackage{pas-math}
\usepackage{pas-tableur}
\setlength{\cellspacebottomlimit}{3pt}
\setlength{\cellspacetoplimit}{3pt}
\definecolor{bleu}{cmyk}{0.96,0.07,0,0.4}
\graphicspath{{img/}}

% Listes

\setlist[itemize,1]{%
				labelsep=*,
				label=\textbullet,
				leftmargin=16pt,
				labelindent=0pt}

\setlist[itemize,2]{%
				labelsep=*,
				label=$\blacktriangleright$,
				leftmargin=16pt,
				labelindent=0pt}
				
% Shadow

\def\shadowshift{3pt,-3pt}
\def\shadowradius{5pt}
\colorlet{innercolor}{black!60}
\colorlet{outercolor}{gray!05}
\newcommand\drawshadow[1]{ % \drawshadow{identifiant} avec \node (identifiant) avant
\begin{pgfonlayer}{shadow}
% Effet d'ombre en forme de cercle en bas à gauche
\shade[outercolor, inner color=innercolor, outer color=outercolor] ($(#1.south west)+(\shadowshift)+(\shadowradius/2 , \shadowradius/2)$) circle (\shadowradius);
% Effet d'ombre en forme de cercle en bas à droite
\shade[outercolor, inner color=innercolor, outer color=outercolor] ($(#1.south east)+(\shadowshift)+(-\shadowradius/2 , \shadowradius/2)$) circle (\shadowradius);
% Effet d'ombre en forme de cercle en haut à droite
\shade[outercolor,inner color=innercolor,outer color=outercolor] ($(#1.north east)+(\shadowshift)+(-\shadowradius/2 , -\shadowradius/2)$) circle (\shadowradius);
% Dégradé de haut en bas sur la partie sud du rectangle
\shade[top color=innercolor,bottom color=outercolor] ($(#1.south west)+(\shadowshift)+(\shadowradius/2,-\shadowradius/2)$) rectangle ($(#1.south east)+(\shadowshift)+(-\shadowradius/2,\shadowradius/2)$);
% Dégradé de gauche à droite sur le côté droit du rectangle
\shade[left color=innercolor,right color=outercolor] ($(#1.south east)+(\shadowshift)+(-\shadowradius/2,\shadowradius/2)$) rectangle ($(#1.north east)+(\shadowshift)+(\shadowradius/2,-\shadowradius/2)$);
% On remplit le rectangle créé avec une couleur noire
\filldraw ($(#1.south west)+(\shadowshift)+(\shadowradius/2,\shadowradius/2)$) rectangle ($(#1.north east)+(\shadowshift)-(\shadowradius/2,\shadowradius/2)$);
\end{pgfonlayer}
}
\pgfdeclarelayer{shadow}
\pgfsetlayers{shadow,main}

%% Repère

\newcommand{\rep}[4]{% xmin,ymin,xmax,ymax
\draw[gray,dashed] (#1,#2) grid (#3,#4);
\draw[->,>=stealth'] (#1,0) -- (#3,0);
\draw[->,>=stealth'] (0,#2) -- (0,#4);
\draw[thick,red,->,>=stealth'] (0,0) -- (1,0) node[midway,below] {$\vv{\imath}$};
\draw[thick,red,->,>=stealth'] (0,0) -- (0,1) node[midway,left] {$\vv{\jmath}$};
\node[below left] at (0,0) {O};
\clip (#1,#2) rectangle (#3,#4);
}

%%%%%%%%%%% Peaufinage de la TOC %%%%%%%%%%%%%%%%%%%

\addtocontents{toc}{\vspace*{-2cm}\color{black}}
\newcommand{\numexointoc}{\makeatletter\addtocontents{toc}{\vspace*{-0.5em}\bgroup\color{gray}\itshape\protect\contentsline{chapter}{\numberline{}\arabic{count@corrige} exercices}{}{}\egroup}\makeatother}
%\newcommand{\numexointoc}{}

%%%%%%%%%%%%%%%% Algorithme

\newbox\algobox
\newenvironment{algorithme}{\begin{lrbox}{\algobox}\begin{minipage}{\dimexpr\linewidth-4pt}\ttfamily}{\end{minipage}\end{lrbox}\fcolorbox{green!50!black}{green!10}{\usebox{\algobox}}}

%%%%%%%%%%%%%%% algorithme d'Euclide

\makeatletter
\newcount\@quotient
\newcommand\algoeuclide[2]{%
	Calculons \pgcd{#1}{#2} à l'aide de l'algorithme d'Euclide.\def\varA{#1}\def\varB{#2}\par\begin{quote}
   \ifnum#2>#1
      \def\next{\@lgeuclide{#2}{#1}}%
   \else
      \def\next{\@lgeuclide{#1}{#2}}
   \fi\next}
\newcommand\@lgeuclide[2]{%
   \ifnum#2>\z@
      \@quotient#1
      \divide\@quotient#2
      \edef\next{\number\numexpr#1-\@quotient*#2}%
      $#1=\number\@quotient\times#2+\next$\par 
      \edef\next{\noexpand\@lgeuclide{#2}{\next}}%
      \expandafter\next
   \else
      	\end{quote}\smallbreak \underline{On en déduit que $\pgcd{\varA}{\varB}=#1$.}%
   \fi}
\makeatother