%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                  Copyleft Trullemans Gregory                                    %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                                                 %
%                                                                                                 %
%                                                                                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Package definition
\ProvidesPackage{ffgTemplate}[2015/01/30 v1.00 Template FfG by G. Trullemans]


% Required Package
\RequirePackage[a4paper, top=2cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}  % Gestion des marges
\RequirePackage[utf8]{inputenc}                                 % Gestion des accents (source)
\RequirePackage[frenchb]{babel}                                 % Gestion du français
\RequirePackage{graphicx}                                       % Gestion des images
\RequirePackage{xcolor}                                         % Gestion des couleurs
\RequirePackage{hyperref}                                       % Gestion des hyperliens
\RequirePackage{fancyhdr}                                       % Gestion des en-têtes et pieds de pages.
\RequirePackage{pifont}                                         % Gestion des symbols (\ding{55} dans le footer)
\RequirePackage{array}                                          % Gestion (améliorée) des tableaux
\RequirePackage{ulem}                                           % Gestion (avancée) des soulignements
\RequirePackage{textcomp}                                       % Caractères additionnels
\RequirePackage{mathtools, amsmath, amstext, amssymb, amsthm}   % Package de l'AMS + mathtools
\RequirePackage{nicefrac}                                       % Gestion des fractions
\RequirePackage{xspace}                                         % Gestion intelligente de l'espace après une commande
\RequirePackage{lmodern}                                        % Police de caractère
\RequirePackage{calc}                                           % Syntaxe naturelle pour les calculs


% Layout Page de garde
\RequirePackage{eso-pic}                                % Gestion du background de la page de garde.
\RequirePackage[absolute]{textpos}                      % Gestion des positions du texte (option de config : showboxes)
\RequirePackage{fontspec}                               % Gestion de "arial" ET "arial narrow" comme font.
\RequirePackage{anyfontsize}                            % Gestion des tailles de police hors dictionnaire
\RequirePackage{shadowtext}                             % Gestion des ombres


% Layout Document 
\RequirePackage{titlesec}                               % Gestion des sections
\RequirePackage{titletoc}                               % Gestion de la table des matière
\RequirePackage{titling}                                % Gestion des titres
\RequirePackage{enumitem}                               % Gestion des listes


% Tools kit
\RequirePackage{fancybox}                               % pour dessiner des boites ;-)
\RequirePackage{etoolbox}                               % Renew command & robust command


% other package
\RequirePackage{bm}                                     % Notation mathématique en gras
\RequirePackage{lscape}                                 % Gestion du mode "paysage"

\frenchbsetup{StandardItemLabels=true}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define global variable for document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\federationName{Fédération francophone de Gymnastique et de fitness}
\def\federationAcronym{FfG}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% (Re)Define parametres for document
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setmainfont{Arial}
\addto\captionsfrench{\def\tablename{Tableau}}                  % Définition du mot pour les tableaux
\addto\captionsfrench{\def\figurename{Figure}}                  % Définition du mot pour les Figures

% Color definition
\definecolor{ffgorange}{RGB}{239, 125, 55}
\definecolor{ffggris}{RGB}{128, 128, 128}

\patchcmd{\footrule}{\hrule}{\color{orange}\hrule}{}{}

% Parametres for TextPos
\setlength{\TPHorizModule}{1mm}
%\setlength{\TPVertModule}{\TPHorizModule}
\textblockorigin{5mm}{5mm}                                      % start everything near the top-left corner
\setlength{\parindent}{0pt}                                     % Pas d'indentation au placement du texte

% \renewcommand{\labelitemii}{$\circ$}
% \AtBeginDocument{\renewcommand{\labelitemii}{\textcirc}}

% Image's first page definition
\newcommand\BackgroundPic{%
    \put(0,0){%
        \parbox[b][\paperheight]{\paperwidth}{%
            \vfill
            \centering
            \includegraphics[scale=1]{firstpage.png}%
            \vfill
        }
    }
}

\shadowoffset{3pt}
\shadowrgb{0.8, 0.8, 0.8}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% First Page's definition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\maketitle{%
    \null
    \thispagestyle{empty}%

    % Titre du document
    \begin{textblock}{100}(15,4.7)
        {\fontsize{32}{42}\selectfont {\bfseries \textcolor{ffggris}{FORMATION\\ \formationType\\\discipline\\~\\Module :\\\moduleTitle}\par}}
    \end{textblock}

    % Type de document
    \begin{textblock}{100}(8,11.5)
        \begin{center}
            {\fontsize{28}{42}\selectfont {\bfseries \textcolor{ffggris}{\shadowtext{Formation des}\\\vspace{-0.3cm}\shadowtext{Cadres}}\par}}%
        \end{center}
    \end{textblock}

    % Années
    \begin{textblock}{82}(116,11.6)
        \begin{center}
            {\fontsize{70}{84}\selectfont {\bfseries \textcolor{ffggris}{\the\year}\par}}%
        \end{center}
    \end{textblock}

    % Adresses et informations de la Fédération
    \begin{textblock}{185}(7,13.5)
        \begin{flushright}{\fontsize{12}{13}\selectfont{
            \textcolor{ffggris}{\federationName ~asbl\hfill Tél : +32 (0)2 234 38 38\\
            Avenue de Roodebeek, 44\hfill Fax : +32 (0)2 230 06 69\\
            1030 Bruxelles\hfill E-mail : info@FfGym.be\\
            ~ \hfill Site : www.FfGym.be}
        }}\end{flushright}
    \end{textblock}

    \null
    \cleardoublepage
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Other page definition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setlength{\headheight}{30pt}
\fancypagestyle{followingpage}{%
    \fancyhf{}

    %% Header
    \fancyhead[CE,CO]{\includegraphics[scale=0.11]{logoFfgHeader.png}}
    \renewcommand{\headrulewidth}{0pt}

    %% Footer
    \fancyfootoffset{3cm}
    \fancyfoot[C]{\hspace{2.5cm} {\fontsize{9}{10}\selectfont \textit{{\bfseries\textcolor{ffggris}{FfG \ding{55} \formationType~\disciplineAcronym \hfill Page \thepage \hfill Edition \the\year}}}} \hspace{2.5cm}}
    \renewcommand{\footrulewidth}{1pt}
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title layout redefinition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter

% Chapter Title redefinition
\renewcommand{\chapter}{\if@openright\cleardoublepage\else\clearpage\fi
                    \thispagestyle{plain}%
                    %\global\@topnum\z@
                    \@startsection{chapter}{0}{\z@}%
                    {-3.5ex \@plus -1ex \@minus -.2ex}%
                    {2.3ex \@plus.2ex}%
                    %\global\@topnum\z@
                    %\@afterindentfalse
                    %\secdef\@chapter\@schapter
                    {\noindent\fontsize{18}{20}\fontspec{Arial Narrow}\selectfont\bfseries\color{ffgorange}}}


% Section Title redefinition
\renewcommand{\section}{\@startsection{section}{1}{\z@}%
                        {-3.5ex \@plus -1ex \@minus -.2ex}%
                        {2.3ex \@plus.2ex}%
                        {\noindent\fontsize{10}{12}\normalfont\bfseries\color{ffgorange}\underline}}


% SubSection Title redefinition
\renewcommand{\subsection}{\@startsection{subsection}{2}{\z@}%
                        {-3.25ex\@plus -1ex \@minus -.2ex}%
                        {1.5ex \@plus .2ex}%
                        {\normalfont\fontsize{10}{12}\underline}}

\makeatother

\pagestyle{followingpage}
\AtBeginDocument{
    \setcounter{secnumdepth}{3}
    \setcounter{tocdepth}{3}
    \AddToShipoutPicture*{\BackgroundPic}
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% References
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% http://www.liv.ac.uk/~maryrees/posterproduction/textpos.pdf
% http://latex-community.org/forum/viewtopic.php?f=4&t=23421
% http://www.grappa.univ-lille3.fr/FAQ-LaTeX/6.3.html
% https://www.overleaf.com/2177757tknnqv#/5555417/
% http://tutex.tug.org/pracjourn/2005-4/hefferon/hefferon.pdf
% http://tex.stackexchange.com/questions/528/style-class-tutorials