%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% STD.TEX
%
% Defines macros and loads packages that are needed for all document types.
%
% This file targets all LaTeX-based documents, including Beamer documents such
% as presentation slides and more regular documents such as tutorials.
%
% Last updated by Thibaut Le Page <lepage_a@yaka.epita.fr> on May, 5th 2013.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[12pt,a4paper]{report}

%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\usepackage[english]{babel}

\usepackage[T1]{fontenc}        % font encoding
\usepackage{euler}              % math font (must be loaded before fontspec)
\usepackage{tabularx}           % arrays with paragraph-like cells
\usepackage[table]{xcolor}      % colors
\usepackage{tikz}               % graphics
\usepackage{float}              % improve floating figures and tables
\usepackage{titlesec}           % must be loaded BEFORE hyperref!
\usepackage{hyperref}           % hyperlinks
\usepackage{graphicx}           % pictures inclusion
\usepackage{listings}           % source code environments and inclusion
\usepackage{fancybox}           % boxes
%\usepackage{fancyhdr}          % En-tête de pages personalisés
\usepackage{fontspec}           % high-level font selection for XeTeX
\usepackage{textcomp}           % more symbols
\usepackage{pifont}             % even more symbols (with \ding)
\usepackage{amsmath,amsfonts}   % math symbols and environments
\usepackage{calc}               % operations on lengths
\usepackage{booktabs}           % better tables
\usepackage{multirow}           % tabular cells spanning multiple rows
\usepackage{ifthen}             % if-then-else construct
\usepackage{enumitem}           % list customization
\usepackage{sectsty}            % section-title customization

%%% STANDARD COLORS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% We can use \rowcolors{3}{OddColor}{EvenColor} to alternatively color the
% lines of a table.

\definecolor{couleur_titre}{rgb}{0.20, 0.45, 0.80}
\definecolor{blue}{rgb}{0.13,0.29,0.46}
\definecolor{red}{rgb}{1,0,0}
\definecolor{lightgray}{RGB}{240,240,240}
\definecolor{pseudo}{rgb}{0.13,0.29,0.46}

\definecolor{vert}{RGB}{0,176,80}
\definecolor{verta}{RGB}{79,97,40}
\definecolor{vertb}{RGB}{195,214,155}
\definecolor{vertc}{RGB}{235,241,221}
\definecolor{bleua}{RGB}{31,73,125}
\definecolor{bleub}{RGB}{239,249,255}
\definecolor{rougea}{RGB}{192,80,77}
\definecolor{rougeb}{RGB}{242,220,219}

\definecolor{brown}{RGB}{128,0,0}
\definecolor{blue}{RGB}{0,0,255}
\definecolor{green}{RGB}{0,128,0}
\definecolor{seagreen}{RGB}{69,158,181}

\definecolor{grey}{RGB}{70,70,75}
\definecolor{lightgrey}{RGB}{220,220,220}
\definecolor{blue}{RGB}{80,80,255}
\definecolor{green}{RGB}{80,180,80}
% YAKA 2014 COLORS
\definecolor{purple}{Hsb}{327,0.94,0.29}
\definecolor{lightpurple}{Hsb}{327,0.09,0.94}
\definecolor{red}{Hsb}{351,0.96,0.32}
\definecolor{lightred}{Hsb}{355,0.20,0.97}
\definecolor{darkblue}{Hsb}{236,0.96,0.21}
\definecolor{lightblue}{Hsb}{236,0.92,0.10}

% This variable is used to pass the chosen main color to other macros.
% Do not delete or modify it, just change its argument.
\def\graphicChartColor{grey}
\def\graphicChartBackgroundColor{lightgrey}


% ***** filigrane *****
%\usepackage{eso-pic,rotating}
%\AddToShipoutPicture{%
%\unitlength 1cm
%\put(11,15){%
%\begin{rotate}{45}
%\makebox(0,0){\color{lightgray}\scalebox{3.5}{\Huge BROUILLON}}
%\end{rotate}}
%}

% ***** commandes personnelles *****

\newcommand\Dual{\textsc{Dual} }

\makeatletter
\renewcommand\chapter{\clearpage\@startsection{chapter}{1}{-1.75em}{\baselineskip}{0.5\baselineskip}{\LARGE\textbf}}
\makeatother
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}

% ***** en-têtes et pieds de pages *****

%\pagestyle{fancyplain}
%        \lhead[\emph{\nouppercase{\leftmark}}]{\emph{\textit{Rapport de stage}}}
%        \chead{}
%        \rhead[\emph{\textit{Rapport de stage}}]{\emph{\nouppercase{\leftmark}}}


%%% LISTINGS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\definecolor{identifiers}{HTML}{000000}
\definecolor{comments}{HTML}{4b9900}
\definecolor{keywords}{HTML}{009ede}
\definecolor{numbers}{HTML}{6b6b6b}
\definecolor{strings}{HTML}{BD0009}
\lstset{%
    frame=none,
    tabsize=4,
    basicstyle=\ttfamily\color{black}\small\NoAutoSpacing,
    identifierstyle=\color{identifiers},
    commentstyle=\color{comments}\itshape,
    stringstyle=\color{strings},
    keywordstyle=\color{keywords}\bfseries,
    numbers=left,
    numberstyle=\tiny\color{numbers},
    numbersep=12pt,
    numberblanklines=true,
    breaklines=true,
    breakatwhitespace=true,
    texcl=true,
}


% Definition of the prompt
\newcommand{\prompt}[0]{{\bfseries{\itshape 42sh}\$}$\quad$}

% Defines an environment that mimic a terminal.
% The prompt (42sh$) is automatically detected and replaced with a more
% readable version. Detected forms are:
%   42sh$
%   42sh>
%   42sh
%   $>
% To be detected, they must be followed by a whitespace (actually this is to
% not emphasize the space between the prompt and the first token).
\lstnewenvironment{console}[0]{%
    \lstset{%
        language=bash,
        frame=single,
        backgroundcolor=\color{lightgrey},
        basicstyle=\ttfamily,
        commentstyle=\color{green}\itshape,
        stringstyle=\color{red},
        keywordstyle={},
        numbers=none,
        breaklines=true,
        breakatwhitespace=true,
        texcl=true,
        showspaces=true,
        literate=*%
            {42sh\$\ }{{\prompt{}}}{6}%
            {42sh\ }{{\prompt{}}}{6}%
            {42sh>\ }{{\prompt{}}}{6}%
            {\$>\ }{{\prompt{}}}{6},
    }
}{}


%%% HYPERLINKS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\hypersetup{%
    colorlinks=true,                % links are colored
    urlcolor=\graphicChartColor,    % URL links
    linkcolor=black,                 % internal links
    citecolor=green,                % bibliography links
    pdfborder= 0 0 0                % links are not framed
}

\newcommand{\refer}[1]{%
    {\small\ref{#1}}~\emph{\nameref{#1} p.~\pageref{#1}}%
}

%%% OTHER MACROS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\file}[1]{\textbf{\texttt{#1}}}
\newcommand{\command}[1]{\textbf{\texttt{#1}}}
\renewcommand{\sc}[1]{\lstinline{#1}} % for 'source code' (\sc should not be used anyway)
\newcommand{\shell}[1]{\lstinline[language=bash,showspaces=true]{#1}}
\newcommand{\expected}[1]{\lstinline[showspaces=true]{"#1"}}
\newcommand{\class}[1]{\textsl{#1}}
\newcommand{\charterColor}[1]{\textcolor{\graphicChartColor}{#1}}
\newcommand{\coloredblock}[2]{\color{#1}#2\color{black}}
\newcommand{\email}[1]{\href{mailto:#1}{\texttt{<#1>}}}

% Don't break paragraphs!
\linepenalty=100

% Set color on *section titles
\allsectionsfont{\color{black}}

% Set proper spacing between list items.
\setlist{itemsep=1pt,topsep=2pt,partopsep=0pt,parsep=0pt,leftmargin=20pt}

\newcommand{\asterisk}[1]{\footnote{#1}\setcounter{footnote}{0}}
%% possibly buggy when multiple called:
\newcommand{\asterisktext}[1]{\footnotetext{#1}\setcounter{footnote}{0}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PREAMBLE_NOBEAMER.TEX
%
% Loads definitions that are not already loaded by STD.TEX - NON-BEAMER
% specific.
%
% This file targets standard documents, that is non-Beamer documents, such as
% tutorials and subjects.
%
% Last updated by Thibaut Le Page <lepage_a@yaka.epita.fr> on May, 5th 2013.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% PACKAGES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{setspace}           % set space amount between lines
\usepackage[cm]{fullpage}       % don't waste space around pages
\usepackage{longtable}

%%% FONTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setmainfont[Ligatures={Common,Rare}]{LinLibertine}
\setsansfont[Ligatures=Common]{LinBiolinum}

%%% ASSISTANT VERSIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\ifdefined\assistantVersion
    \newenvironment{assistant}[0]{%
        \VerbatimEnvironment    % assistant environment can contain verbatim
        \begin{Sbox}
    }{%
        \end{Sbox}
        \vskip\baselineskip\noindent
        \fcolorbox{\graphicChartColor}{\graphicChartBackgroundColor}{%
            \begin{minipage}[t]{\textwidth}
            {\Large\bfseries\underline{Assistant}}\\
            \TheSbox
            \end{minipage}
        }
        \vskip\baselineskip
    }
    \newcommand{\assistantfile}[1]{%
        \lstinputlisting[backgroundcolor=\graphicChartBackgroundColor]{#1}
    }
\else
    \newenvironment{assistant}[0]{%
        \begin{Sbox}
    }{%
        \end{Sbox}
        % We want to not disturb the text, so this line must be blank

        {} % and this one, being the last one, 'skipped' like this.
    }
    \newcommand{\assistantfile}[1]{}
\fi


%%% MISC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\bibliographystyle{apalike}

\newcounter{idRules}
\def\nbRule{\theidRules \stepcounter{idRules}}

\titlespacing{\section}{0pt}{2.5em}{0.66em}
\titlespacing{\subsection}{0pt}{1.5em}{0.5em}
\titlespacing{\subsubsection}{0pt}{1em}{0.4em}
\titlespacing{\paragraph}{0pt}{2ex}{1.2ex}
