% !TeX program = lualatex
%\documentclass[xcolor=dvipsnames,notes=show,handout]{beamer} % pour mes notes de présentateur
\documentclass[xcolor=table,xcolor=dvipsnames]{beamer} % pour impression
%\documentclass[xcolor=dvipsnames]{beamer} % pour présentation
\usetheme{Berlin}
\graphicspath{{Figures/}}

\setbeamertemplate{mini frames}{} %FRED : enleve les points de progression
\renewcommand*{\slideentry}[6]{} %FRED  :enleve l'espace reserve pour les points de progression
%\makeatother
%\usepackage{fontspec}
%\newfontfamily\Georgia{Georgia}
%\newfontfamily\FuturaBold{FuturaBold}
%\newfontfamily\futur{futur}
%\setmainfont[Ligatures=TeX]{Georgia}
%\setsansfont[Ligatures=TeX]{FuturaBold}

\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{array}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{frcursive}
\usepackage{epstopdf}
\usepackage{tikz} 
\usepackage{xspace}
\newcommand{\TikZ}{Ti\textit{k}Z\xspace}


\usepackage{textcase,regexpatch}
\usepackage[font=footnotesize]{caption}
%%\usepackage[french,english]{babel} %Enleve car conflit avec pgfplot...
\usepackage{float}
\usepackage{xcolor} %% http://www.ctan.org/pkg/xcolor

\definecolor{BGERAD}{RGB}{0,82,155}%BleuGERAD
\definecolor{OGERAD}{RGB}{178,92,18}%OrangeGERAD
\definecolor{BEGERAD}{RGB}{247,238,212}%BeigeGERAD
\usecolortheme[named=BGERAD]{structure}
%\mode{presentation}

\setbeamercovered{transparent}

\setbeamercolor{frametitle}{fg=BEGERAD}
\setbeamercolor{alerted text}{fg=OGERAD}
\setbeamercolor{normal text}{fg=BGERAD}
\setbeamercolor{part title}{fg=BEGERAD}
\setbeamercolor{section title}{fg=BEGERAD}
\setbeamercolor{subtitle}{fg=BEGERAD}
\setbeamercolor{subsection title}{fg=BEGERAD}
\setbeamercolor{section in head/foot}{fg=BEGERAD}
\setbeamercolor{subsection in head/foot}{fg=BEGERAD}
% 1- Block title (background and text)
\setbeamercolor{block title}{bg=BGERAD, fg=BEGERAD}
% 2- Block body (background)
\setbeamercolor{block body}{bg=BGERAD!10}
% 1- Exampleblock title (background and text)
\setbeamercolor{block title example}{bg=OGERAD, fg=BEGERAD}
% 2- Exampleblock body (background)
\setbeamercolor{block body example}{bg=OGERAD!10, fg=OGERAD}

\setbeamertemplate{caption}[numbered]
\setbeamertemplate{footline}{%
	~~~{\small\strut}
	{\includegraphics[height=0.3cm]{GERAD_Logo}\hfill \tiny \textcolor{BGERAD}{\insertframenumber\,/\,\inserttotalframenumber}}\hspace{1cm}
}
\setbeamerfont{alerted text}{series=\bfseries} 
%\setbeamerfont{frametitle}{series=\bfseries, family=\FuturaBold}
%\setbeamerfont{normal text}{family=\Georgia}
%\setbeamerfont{title}{series=\bfseries, family=\FuturaBold}
\setbeamerfont{caption}{series=\bfseries}

\AtBeginDocument{\usebeamerfont{normal text}}

\parindent=0pt % indentation du paragraphe
%\parskip=15pt  % espacement entre les paragraphes
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%Préambule spécifique Tikz%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{adjustbox} %ajout Karine
\usepackage{verbatim} %ajout Lucie
\usepackage{wasysym} %ajout Lucie pour caractère spéciaux

\usepackage{caption} %Ajout par Luciano - mettre les captions des figures au centre
\usepackage{textpos} %Ajout par Luciano  - 
\usepackage{fancyvrb} %Ajout par Luciano  - draw a frame around verbatim
%
\AtBeginSection{\frame{\sectionpage}} %ajout Fred, pages de sections

\newcommand{\red}[1]{\textcolor{red}{#1}}
\newcommand{\green}[1]{\textcolor{green!50!black}{#1}}
%
%%---------------------
%%packages de Fred
%%
\RequirePackage{atbegshi}
\usepackage{listings}
\usepackage{animate}
\usepackage{calc}
\usepackage{fp}
\usetikzlibrary{arrows,automata,shapes,calc}
\usepackage{tkz-graph}

\usetikzlibrary{patterns}
\usetikzlibrary{decorations.pathreplacing}


\usepackage{pgfplots} 
\pgfplotsset{compat=newest}
\usepackage{tikz-3dplot} % pour 3D
\usetikzlibrary{intersections} 
\usepgfplotslibrary{fillbetween}

\newcommand{\framesoustitre}[1]{{\Large\underline{\textbf{#1}}}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Personnalisation du theme par Frédéric Quesnel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%personalise les pages de section
\AtBeginSection{\frame{\sectionpage}}


\defbeamertemplate{section page}{secmine}[1][]{%
	\begin{centering}
		{\usebeamerfont{section name}\usebeamercolor[fg]{section name}#1}
		\vskip1em\par
		\begin{beamercolorbox}[sep=12pt,center]{part title}
			\usebeamerfont{section title}\thesection. \hspace{0.1cm} \insertsection\par
		\end{beamercolorbox}
	\end{centering}
}

%personalise les pages de sous-section
%
\AtBeginSubsection{\frame{\subsectionpage}}

\defbeamertemplate{subsection page}{subsecmine}[1][]{%
	
  \begin{centering}
  	{\usebeamerfont{section name}\usebeamercolor[fg]{section name}#1}
    \vskip1em\par
    \begin{beamercolorbox}[sep=12pt,center]{part title}
      \usebeamerfont{section title}\thesection. \hspace{0.1cm} \insertsection\par
    \end{beamercolorbox}
  
    {\usebeamerfont{subsection name}\usebeamercolor[fg]{subsection name}#1}
    \vskip1em\par
    \begin{beamercolorbox}[sep=2pt,center, rounded=true]{part title}
      \usebeamerfont{subsection title}\insertsubsection\par
    \end{beamercolorbox}
  \end{centering}
}

%===============================

\setbeamertemplate{section page}[secmine]
\setbeamertemplate{subsection page}[subsecmine]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\usetikzlibrary{external}
%\tikzexternalize % activate!


%\newcommand{\TikZ}{Ti\textit{k}{Z}}

\newcounter{cnt}
\setcounter{cnt}{0}
\newcommand{\ANDLER}[4]
{   
	\draw[-latex] (0,0) -- (8.5,0) node[right]{\tiny $b$};
	\draw[-latex] (0,0) -- (0,5.5) node[left]{\tiny $K_G K_L K_B$};
	\pgfmathsetmacro\vkl{#1}
	\pgfmathsetmacro\vkb{#3}
	\pgfmathsetmacro\vP{#2}
	\pgfmathsetmacro\vM{#4}
	\pgfmathsetmacro\bOpt{10* sqrt( (2 * \vkb * \vM) / (\vkl) / ( \vP) )}
	\pgfmathsetmacro\bOpta{ \bOpt /10}
	\pgfmathsetmacro\Kmin{ sqrt( 2 * \vkl * \vP * \vkb)  * sqrt(  \vM * 0.01)}
	\pgfmathsetmacro\Kmina{ \Kmin/20}   
	\FPround{\Kmin}{\Kmin}{2}
	\FPround{\bOpt}{\bOpt}{2}
	
	\draw[dotted] (\bOpta,4.5) -- (\bOpta,-0.5) node[below]
	{\tiny $b_{opt}=\sqrt{\frac{2\cdot #3 \cdot #4 \cdot100}{#1 \cdot #2}} = \bOpt$};
	\draw[dotted]   (-0.5,\Kmina) -- (5.5,\Kmina) node[right]
	{\tiny $K_G(b_{opt})=
		\sqrt{\frac{2\cdot #1 \cdot #2 \cdot #3 \cdot #4}{100}}=\Kmin$};
	\foreach \x  in {1,...,8}{
		\pgfmathsetmacro\xtext{ \x * 10}
		\draw (\x cm,1pt) -- (\x cm,-1pt) node[below] {\tiny $\xtext$};
	}
	\foreach \y  in {1,...,5}{
		\pgfmathsetmacro\ytext{ \y * 20}
		\draw (1pt,\y cm) -- (-1pt,\y cm) node[left]  {\tiny $\ytext$};}%                    
	\foreach \kl/\P/\kb/\M in {#1/#2/#3/#4}{
		\draw[color=black, ultra thick] plot[id=#1#2#3#4a]
		function{(0.5*\kl*0.01*\P*(x*10)+\kb*\M/(x*10))/20};
		\node[color=black, very thick] at (4.5,5)
		{\scriptsize$K_G(b)=\textcolor{red}{\frac{1}{2}\cdot\frac{k_l\cdot P}{100} \cdot b}
			+\textcolor{blue}{\frac{M\cdot k_b}{b}}=
			\textcolor{red}{\frac{1}{2}\cdot\frac{\kl\cdot\P}{100} \cdot b}
			+\textcolor{blue}{\frac{\M\cdot\kb}{b}}$};                           
		\draw[color=red,thick  ] plot[id=#1#2#3#4b] function{(0.5*\kl*0.01*\P*(x*10))/20};                      
		\draw[color=blue,thick  ] plot[id=#1#2#3#4c] function{(\kb*\M/(x*10))/20};
	}
	
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
	
	
	\title{\bfseries\textcolor{BEGERAD}{TUTORIEL \TikZ}}
	\subtitle{\textcolor{BEGERAD}{Introduction \`{a} \TikZ}}
	\date{\textcolor{OGERAD}{2023}}
	\author{\textcolor{OGERAD}{\footnotesize Karine H\'{e}bert}\\
		%\textcolor{OGERAD}{\footnotesize Pr\'{e}nom~Nom}\\
		\textcolor{OGERAD}{\footnotesize Fr\'{e}d\'{e}ric Quesnel}}
	
	%%%%%%%%%%%%%Decommentez votre institution%%
	%%%%%%%%%%%%%Institution=HEC%%%%%%%%%%%%%%%%
	%\institute{\textcolor{OGERAD}{\includegraphics[height=0.5cm]{GERAD_Logo}}~~~{\includegraphics[height=0.5cm]{HEC}}}
	
	%%%%%%%%%%%%%Institution=McGill%%%%%%%%%%%%%
	%\institute{\textcolor{OGERAD}{\includegraphics[height=0.5cm]{GERAD_Logo}}~~~{\includegraphics[height=0.5cm]{McGill}}}
	
	%%%%%%%%%%%%%Institution=Polytechnique%%%%%%
	\institute{\textcolor{OGERAD}{\includegraphics[height=0.5cm]{GERAD_Logo}}~~~{\includegraphics[height=0.5cm]{Figures/UQAM.pdf}}}
	
	%%%%%%%%%%%%%Institution=UQAM%%%%%%%%%%%%%%%
	%\institute{\textcolor{OGERAD}{\includegraphics[height=0.5cm]{GERAD_Logo}}~~~{\includegraphics[height=0.5cm]{UQAM}}}
	
	%%%%%%%%%%%%%%%%%%%%%%%%%%
	%\section{Page titre}
	%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{frame}
		\titlepage
	\end{frame}
	
	
	%%%%%%%%%%%%%%%%%%%%%%%%%%
	%\section{Titres et items}
	%%%%%%%%%%%%%%%%%%%%%%%%%%
	\setbeamercovered{invisible}

	%
	\include{debut}
	\include{base}
	\include{graphes}
	%\setbeamercovered{transparent}
	\include{faciliter_la_vie}
	\include{puissance_TikZ}
	\nocite{Cremer2011}
	\nocite{Tantau2012}
	\nocite{Tisseau2012}
	%%%%%%%%%%%%%%%%%%%%%%%%%%
	%\section{Reference}
	%%%%%%%%%%%%%%%%%%%%%%%%%%
	\begin{frame}{R\'{e}f\'{e}rences}
	\begin{itemize}	\footnotesize
		\item Wikibooks sur \TikZ: \url{https://en.wikibooks.org/wiki/LaTeX/PGF/TikZ}
        \item CTAN sur \TikZ incluant le pdf du livre officiel de Crémer et autre  documentation: \url{https://www.ctan.org/pkg/pgf}
        \item base de données TeXample \TikZ remplie d'exemples et d'inspirations : \url{https://texample.net/tikz/}
    \end{itemize}
		\bibliographystyle{plain}
		\bibliography{Document}
	\end{frame}
	
	%%%%%%%%%%%%%%%%%%%%%%%%%%
	%\section{Remerciements}
	%%%%%%%%%%%%%%%%%%%%%%%%%%
% Local background must be enclosed by curly braces for grouping.
{
	\usebackgroundtemplate{\includegraphics[width=.85\paperwidth]{logo_G}}
	\begin{frame}
		
		\begin{center}
			\huge{Merci pour votre attention!}
			
			\vfill
				
				\footnotesize{\copyright Luciano Costa, Lucie Desfontaines,\break Fr\'{e}d\'{e}ric Quesnel, GERAD}
			\end{center}
		\end{frame}
	}
	
	%\section{\includegraphics[height=1.5cm]{logo}}
	%%%%%%%%%%%%%%%%%%%%%%%%%%
	%\section{Lemme}
	%%%%%%%%%%%%%%%%%%%%%%%%%%
%	\begin{frame}[t,fragile]
%		\frametitle{PREUVE}
%		
%		\begin{proof}
%			\lipsum[10]
%		\end{proof}
%		
%	\end{frame}
	
\end{document}
