\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{2ndpatchwork}[07/09/2021 Mon second patchwork]

% https://www.overleaf.com/latex/templates/lecture-outline-template/zprvgkrcwhmv
% https://www.overleaf.com/latex/templates/sticky-notes/ftrvjddrmbwx
% https://www.overleaf.com/latex/templates/fun-template-1/drwvdzsrpgzz

\usepackage[dvipsnames]{xcolor}
\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage[italicdiff]{physics}
% Pour les postits
\usepackage{tikz, adjustbox, xcolor, wrapfig}
\usepackage[most]{tcolorbox}
% Pourquoi ils sont là j'en sais rien
\usepackage{calrsfs, wasysym, verbatim, bbm, color, graphics, geometry, graphicx, frcursive, mathtools, array, boldline, cancel, listings, systeme, marvosym,enumitem}


\geometry{tmargin=.75in, bmargin=.75in, lmargin=.75in, rmargin = .75in}
\setlength{\parindent}{0pt}
\let\phi\varphi

% Mémo : matrix, pmatrix, bmatrix, Bmatrix, vmatrix, Vmatrix
% None, parentheses, brackets, curly brackets, vertical, 2x vertical bar


%%%%%%%%%%  INDEX  %%%%%%%%%%


\usepackage{euscript}


\usepackage[style=numeric,citestyle=numeric,sorting=nyt,sortcites=true,autopunct=true,babel=hyphen,hyperref=true,abbreviate=false,backref=true,backend=biber]{biblatex}
\usepackage{calc, makeidx, titletoc, hyperref, bookmark, mathptmx}
\makeindex
\hypersetup{hidelinks,backref=true,pagebackref=true,hyperindex=true,colorlinks=false,breaklinks=true,urlcolor=bleu,bookmarks=true,bookmarksopen=false}
\usepackage{bookmark}
\bookmarksetup{open, numbered, addtohook={\ifnum\bookmarkget{level}=0 \bookmarksetup{bold} \fi \ifnum\bookmarkget{level}=-1 \bookmarksetup{color=bleu,bold} \fi } }





%%%%%%%%% OPTIONS  %%%%%%%%%



\DeclareOption{chapitres}{
    \makeatletter
    % we use \prefix@<level> only if it is defined
    \renewcommand{\@seccntformat}[1]{%
      \ifcsname prefix@#1\endcsname
        \csname prefix@#1\endcsname
      \else
        \csname the#1\endcsname\quad
      \fi}
    % define \prefix@section
    \newcommand\prefix@section{Chapitre \thesection : }
    \makeatother
}
\DeclareOption{sections}{
	\makeatletter
	% we use \prefix@<level> only if it is defined
	\renewcommand{\@seccntformat}[1]{%
		\ifcsname prefix@#1\endcsname
		\csname prefix@#1\endcsname
		\else
		\csname the#1\endcsname\quad
		\fi}
	% define \prefix@section
	\newcommand\prefix@section{Section \thesection : }
	\makeatother
}
\ProcessOptions\relax





%%%%%%%%%  COULEURS  %%%%%%%%%





\definecolor{BgYellow}{HTML}{FFF59C}
\definecolor{FrameYellow}{HTML}{F7A600}

\definecolor{jaune}{RGB}{248, 194, 145}
\definecolor{bleu}{RGB}{34, 166, 179}
\definecolor{rouge}{RGB}{215, 56, 104}
\definecolor{vert}{RGB}{22, 160, 133}
\definecolor{gris}{RGB}{52, 73, 94}




%%%%%%%%%%  POSTIT  %%%%%%%%%%





\newtcolorbox{YStkyNote}[1][]{%
    enhanced,
    before skip=2mm,after skip=2mm,
    width=0.4\textwidth, % width of the sticky note
    boxrule=0.2mm,
    colback=BgYellow, colframe=FrameYellow, % Colors
    attach boxed title to top left={xshift=0cm,yshift*=0mm-\tcboxedtitleheight},
    varwidth boxed title*=-3cm,
    % The titlebox:
    boxed title style={frame code={%
        \path[left color=FrameYellow,right color=FrameYellow,
        middle color=FrameYellow]
        ([xshift=-0mm]frame.north west) -- ([xshift=0mm]frame.north east)
        [rounded corners=0mm]-- ([xshift=0mm,yshift=0mm]frame.north east)
        -- (frame.south east) -- (frame.south west)
        -- ([xshift=0mm,yshift=0mm]frame.north west)
        [sharp corners]-- cycle;
        },interior engine=empty,
    },
    sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
    % The "folded paper" in the bottom right corner:
    underlay={%
        \path[fill=BgYellow!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
        \path[draw=FrameYellow,shorten <=-0.05mm,shorten >=-0.05mm,color=FrameYellow] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
        },
    drop fuzzy shadow, % Shadow
    fonttitle=\bfseries,
    title={#1}
}
% Put the sticky note in a wrapfigure to have text wrap around it.
% R ou L : Coté de la page
\newcommand{\postit}[2]{\begin{wrapfigure}{R}{0.45\textwidth}\begin{YStkyNote}[#1]#2\end{YStkyNote}\end{wrapfigure}}

\newtcolorbox{postit2}[1][]{%
    enhanced,
    before skip=2mm,after skip=2mm,
    width=1\textwidth, % width of the sticky note
    boxrule=0.2mm,
    colback=BgYellow, colframe=FrameYellow, % Colors
    attach boxed title to top left={xshift=0cm,yshift*=0mm-\tcboxedtitleheight},
    varwidth boxed title*=-3cm,
    % The titlebox:
    boxed title style={frame code={%
        \path[left color=FrameYellow,right color=FrameYellow,
        middle color=FrameYellow]
        ([xshift=-0mm]frame.north west) -- ([xshift=0mm]frame.north east)
        [rounded corners=0mm]-- ([xshift=0mm,yshift=0mm]frame.north east)
        -- (frame.south east) -- (frame.south west)
        -- ([xshift=0mm,yshift=0mm]frame.north west)
        [sharp corners]-- cycle;
        },interior engine=empty,
    },
    sharp corners,rounded corners=southeast,arc is angular,arc=3mm,
    % The "folded paper" in the bottom right corner:
    underlay={%
        \path[fill=BgYellow!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
        \path[draw=FrameYellow,shorten <=-0.05mm,shorten >=-0.05mm,color=FrameYellow] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
        },
    drop fuzzy shadow, % Shadow
    fonttitle=\bfseries,
    title={#1}
}



%%%%%%%% STABILO %%%%%%%%%





\usepackage{soul}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}

\makeatletter

\newcommand{\defhighlighter}[3][]{%
  \tikzset{every highlighter/.style={color=#2, fill opacity=#3, #1}}%
}

\defhighlighter{red}{.5}

\newcommand{\stabilo@DoHighlight}{
  \fill [ decoration = {random steps, amplitude=0.5pt, segment length=15pt}
        , outer sep = -15pt, inner sep = 0pt, decorate
        , every highlighter, this highlighter ]
        ($(begin stabilo)+(0,8pt)$) rectangle ($(end stabilo)+(0,-3pt)$) ;
}

\newcommand{\stabilo@BeginHighlight}{
  \coordinate (begin stabilo) at (0,0) ;
}

\newcommand{\stabilo@EndHighlight}{
  \coordinate (end stabilo) at (0,0) ;
}

\newdimen\stabilo@previous
\newdimen\stabilo@current

\DeclareRobustCommand*\stabilo[1][]{%
  \tikzset{this highlighter/.style={#1}}%
  \SOUL@setup
  %
  \def\SOUL@preamble{%
    \begin{tikzpicture}[overlay, remember picture]
      \stabilo@BeginHighlight
      \stabilo@EndHighlight
    \end{tikzpicture}%
  }%
  %
  \def\SOUL@postamble{%
    \begin{tikzpicture}[overlay, remember picture]
      \stabilo@EndHighlight
      \stabilo@DoHighlight
    \end{tikzpicture}%
  }%
  %
  \def\SOUL@everyhyphen{%
    \discretionary{%
      \SOUL@setkern\SOUL@hyphkern
      \SOUL@sethyphenchar
      \tikz[overlay, remember picture] \stabilo@EndHighlight ;%
    }{%
    }{%
      \SOUL@setkern\SOUL@charkern
    }%
  }%
  %
  \def\SOUL@everyexhyphen##1{%
    \SOUL@setkern\SOUL@hyphkern
    \hbox{##1}%
    \discretionary{%
      \tikz[overlay, remember picture] \stabilo@EndHighlight ;%
    }{%
    }{%
      \SOUL@setkern\SOUL@charkern
    }%
  }%
  %
  \def\SOUL@everysyllable{%
    \begin{tikzpicture}[overlay, remember picture]
      \path let \p0 = (begin stabilo), \p1 = (0,0) in \pgfextra
        \global\stabilo@previous=\y0
        \global\stabilo@current =\y1
      \endpgfextra (0,0) ;
      \ifdim\stabilo@current < \stabilo@previous
        \stabilo@DoHighlight
        \stabilo@BeginHighlight
      \fi
    \end{tikzpicture}%
    \the\SOUL@syllable
    \tikz[overlay, remember picture] \stabilo@EndHighlight ;%
  }%
  \SOUL@
}
\makeatother





%%%%%%% BOITES & COULEURS %%%%%%





\newtcolorbox{jaune}[1][]{colback=white,colframe=jaune,fonttitle=\bfseries,title=#1}
\newtcolorbox{bleu}[1][]{colback=white,colframe=bleu,fonttitle=\bfseries,title=#1}
\newtcolorbox{rouge}[1][]{colback=white,colframe=rouge,fonttitle=\bfseries,title=#1}
\newtcolorbox{verte}[1][]{colback=white,colframe=vert,fonttitle=\bfseries,title=#1}
\newtcolorbox{gris}[1][]{colback=white,colframe=gris,fonttitle=\bfseries,title=#1}

\newtcolorbox{exemple}[1][]{boxrule=0pt,boxsep=0pt,blanker,borderline west={2pt}{0pt}{Black},left=12pt,right=8pt,sharp corners,before skip=10pt,after skip=10pt,breakable, title=\color{black}\sffamily\bfseries Exemple #1}
\newtcolorbox{exemples}[1][]{boxrule=0pt,boxsep=0pt,blanker,borderline west={2pt}{0pt}{Black},left=12pt,right=8pt,sharp corners,before skip=10pt,after skip=10pt,breakable, title=\color{black}\sffamily\bfseries Exemples #1}
\newtcolorbox{exercice}[1][]{boxrule=0pt,boxsep=0pt,blanker,borderline west={2pt}{0pt}{Black},left=12pt,right=8pt,sharp corners,before skip=10pt,after skip=10pt,breakable, title=\color{black}\sffamily\bfseries Exercice #1}
\newtcolorbox{demo}[1][]{boxrule=0pt,boxsep=0pt,blanker,borderline west={2pt}{0pt}{Black},left=12pt,right=8pt,sharp corners,before skip=10pt,after skip=10pt,breakable, title=\color{black}\sffamily\bfseries Démonstration #1}

\newtcolorbox{singlelinebox}[1]{boxrule=0pt,boxsep=0pt,blanker,borderline west={2pt}{0pt}{#1},left=8pt,right=8pt,sharp corners,before skip=10pt,after skip=10pt,breakable}

\newcommand{\minithm}[1]{\begin{singlelinebox}{rouge}{\color{rouge}\bfseries Théorème} : #1\end{singlelinebox}}
\newcommand{\minilem}[1]{\begin{singlelinebox}{rouge}{\color{rouge}\bfseries Lemme} : #1\end{singlelinebox}}
\newcommand{\miniprop}[1]{\begin{singlelinebox}{rouge}{\color{rouge}\bfseries Proposition} : #1\end{singlelinebox}}
\newcommand{\minipropr}[1]{\begin{singlelinebox}{rouge}{\color{rouge}\bfseries Propriété} : #1\end{singlelinebox}}
\newcommand{\minicorol}[1]{\begin{singlelinebox}{rouge}{\color{rouge}\bfseries Corollaire} : #1\end{singlelinebox}}
\newcommand{\minidef}[1]{\begin{singlelinebox}{vert}{\color{vert}\bfseries Définition} : #1\end{singlelinebox}}
\newcommand{\miniexo}[1]{\begin{singlelinebox}{Black}{\color{Black}\bfseries Exercice} : #1\end{singlelinebox}}
\newcommand{\miniex}[1]{\begin{singlelinebox}{Black}{\color{Black}\bfseries Exemple} : #1\end{singlelinebox}}
\newcommand{\minirem}[1]{\begin{singlelinebox}{Black}{\color{Black}\bfseries Remarque} : #1\end{singlelinebox}}
\newcommand{\minidemo}[1]{\begin{singlelinebox}{Black}{\color{Black}\bfseries Démonstration} : #1\end{singlelinebox}}
\newcommand{\minirouge}[1]{\begin{singlelinebox}{rouge}#1\end{singlelinebox}}
\newcommand{\minivert}[1]{\begin{singlelinebox}{vert}#1\end{singlelinebox}}
\newcommand{\mininoir}[1]{\begin{singlelinebox}{Black}#1\end{singlelinebox}}
\newcommand{\mininwar}[1]{\begin{singlelinebox}{Black}#1\end{singlelinebox}}

\newtcolorbox{application}[1][]{boxrule=0pt,boxsep=0pt,blanker,borderline west={2pt}{0pt}{Black},left=12pt,right=8pt,sharp corners,before skip=10pt,after skip=10pt,breakable, title=\color{black}\sffamily\bfseries Application #1}
\newtcolorbox{nwar}[1][]{boxrule=0pt,boxsep=0pt,blanker,borderline west={2pt}{0pt}{Black},left=12pt,right=8pt,sharp corners,before skip=10pt,after skip=10pt,breakable, title=\color{black}\sffamily\bfseries #1}
\newtcolorbox{definition}[1][]{colback=white,colframe=vert,fonttitle=\bfseries,title=Définition #1}
\newtcolorbox{deff}[1][]{colback=white,colframe=vert,fonttitle=\bfseries,title=Définition #1}
\newtcolorbox{definitions}[1][]{colback=white,colframe=vert,fonttitle=\bfseries,title=Définitions #1}
\newtcolorbox{theoreme}[1][]{colback=white,colframe=rouge,fonttitle=\bfseries,title=Théorème #1}
\newtcolorbox{propriete}[1][]{colback=white,colframe=rouge,fonttitle=\bfseries,title=Propriété #1}
\newtcolorbox{proprietes}[1][]{colback=white,colframe=rouge,fonttitle=\bfseries,title=Propriétés #1}
\newtcolorbox{proposition}[1][]{colback=white,colframe=rouge,fonttitle=\bfseries,title=Proposition #1}
\newtcolorbox{caracterisation}[1][]{colback=white,colframe=rouge,fonttitle=\bfseries,title=Caractérisation #1}
\newtcolorbox{lemme}[1][]{colback=white,colframe=rouge,fonttitle=\bfseries,title=Lemme #1}
\newtcolorbox{corollaire}[1][]{colback=white,colframe=rouge,fonttitle=\bfseries,title=Corollaire #1}







%%%%%%%%%%  IMAGES & COLONNES %%%%%%%%%%





\newcommand{\img}[2]{\includegraphics[width=#2]{Annexes/#1.png}}
\newcommand{\imgtxt}[2]{\begin{minipage}{.35\textwidth}\includegraphics[width=\textwidth]{Annexes/#1.png}\end{minipage}\hfill\begin{minipage}{.6\textwidth}#2\end{minipage}}
\newcommand{\txtimg}[2]{\begin{minipage}{.6\textwidth}#1\end{minipage}\hfill\begin{minipage}{.35\textwidth}\includegraphics[width=\textwidth]{Annexes/#2.png}\end{minipage}}
\newcommand{\txtimgp}[4]{\begin{minipage}{#3}#1\end{minipage}\hfill\begin{minipage}{#4}\includegraphics[width=\textwidth]{Annexes/#2.png}\end{minipage}}
\newcommand{\txttxt}[2]{\begin{minipage}{.5\textwidth}#1\end{minipage}\hfill\begin{minipage}{.5\textwidth}#2\end{minipage}}
\newcommand{\txttxtp}[4]{\begin{minipage}{#3}#1\end{minipage}\hfill\begin{minipage}{#4}#2\end{minipage}}





%%%%%%%%%% RACCOURCIS  %%%%%%%%%%

%\renewcommand{\epsilon}{\varepsilon}


\newcommand{\lin}{\mathcal{L}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\K}{\mathbb{K}}
\newcommand{\pnt}{\boldsymbol{\cdot}}
\newcommand{\vect}{\overrightarrow}
\newcommand{\circonf}{\mathbin{\char`\^}}
\newcommand{\grandefleche}{\longrightarrow}
\newcommand{\GrandeFleche}[1]{\xrightarrow{\hspace*{#1cm}}}
\newcommand{\fleche}{\rightarrow}
\newcommand{\fleched}{\leftarrow}
\newcommand{\traitfleche}{\longmapsto}
\newcommand{\inclu}{\subset}
\newcolumntype{\Inclu}{\Subset}
\newcommand{\noninclu}{\not\subset}
\newcommand{\appartient}{\in}
\newcommand{\appartientpas}{\not\in}
\newcommand{\different}{\neq}
\newcommand{\inter}{\cap}
\newcommand{\coeur}{ \quad \text{\Heart}}
\newcommand{\union}{\cup}
\newcommand{\infini}{\infty}
\newcommand{\incluegal}{\subseteq}
\newcommand{\inclupasegal}{\subsetneq}
\newcommand{\rond}{\circ}
\newcommand{\doublefleche}{\longleftrightarrow}
\newcommand{\equivalent}{\Leftrightarrow}
\newcommand{\implique}{\implies}
\newcommand{\supeq}{\ge}
\newcommand{\infeq}{\le}
\newcommand{\diff}{\ne}
\newcommand{\pourtout}{\forall}
\newcommand{\ilexiste}{\exists}
\newcommand{\equival}{\Leftrightarrow}
\newcommand{\moins}{\backslash}
\newcommand{\congru}{\equiv}
\newcommand{\environ}{\simeq}
\newcommand{\plusmoins}{\pm}
\newcommand{\perpendiculaire}{\bot}
\newcommand{\perpe}{\bot}
\newcommand{\para}{\|}
\newcommand{\bx}{\barre{x}}
%\newcommand{\tilde}{\sim}
\newcommand{\espace}{\qquad}
\newcommand{\vectoriel}{\wedge}
\newcommand{\prop}{\propto}
\newcommand{\pr}{\oplus}
\newcommand{\pc}{\sur{+}{\wedge}}
\newcommand{\incluenvers}{\supset}
\newcommand{\ssi}{\textit{ssi }}
\newcommand{\drond}{\partial} % USELESS
\newcommand{\gradd}{\vect{grad}~}
\newcommand{\degre}{^\circ}
\newcommand{\fbb}{\sur{F}{=}}
\newcommand{\comma}{, }


\newcommand{\chapeau}[1]{\widehat{#1}}
\newcommand{\gras}[1]{\textbf{#1}}
\newcommand{\italique}[1]{\textit{#1}}
\newcommand{\souligne}[1]{\underline{#1}}
\newcommand{\sous}[2]{\underset{#2}{#1}}
\newcommand{\sur}[2]{\overset{#2}{#1}}
\newcommand{\Sur}[2]{\begin{matrix}#1\\#2\end{matrix}}
\newcommand{\centrer}[1]{$$\text{{#1}}$$}
\newcommand{\barre}[1]{\overline{#1}}
\newcommand{\cpl}[1]{\underline{#1}} % Complexe
\newcommand{\joliOLD}[1]{\textcursive{#1}} % mathcal aussi utilisé
\newcommand{\joli}[1]{\EuScript{#1}}
\newcommand{\ch}[1]{\left[#1\right]}
\newcommand{\chff}[1]{\left[#1\right]}
\newcommand{\chf}[1]{\begin{bmatrix}#1\end{bmatrix}}
\newcommand{\chfo}[1]{\left[#1\right[}
\newcommand{\chof}[1]{\left]#1\right]}
\newcommand{\choo}[1]{\left]#1\right[}
\newcommand{\systemd}[1]{\left|\begin{array}{l}#1\end{array}\right.}
\newcommand{\systemb}[1]{\left\{\begin{array}{l}#1\end{array}\right.}
\newcommand{\parmi}[2]{\left(\begin{array}{rcl}#1\\#2\end{array}\right)}
\newcommand{\vecteurOLD}[1]{\left(\begin{array}{rcl}#1\end{array}\right)}
\newcommand{\vecteur}[1]{~\begin{array}{|lcl}#1\end{array}}
\newcommand{\integrale}[4]{\(\int_{#1}^{#2} #3 \,#4\)}
\newcommand{\matrice}[1]{\begin{pmatrix}#1\end{pmatrix}}
\newcommand{\mtrx}[1]{\begin{matrix}#1\end{matrix}}
\newcommand{\moy}[1]{\langle #1 \rangle}
\newcommand{\gros}[1]{{\displaystyle #1 }} % Big inline formula
