\ProvidesPackage{crealp-report}

% Use utf-8 encoding for foreign characters
\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}
%\usepackage[francais]{babel}
\usepackage{graphicx}
\usepackage{url}
\usepackage{hyperref} 
\DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png} 


%%%% debut macro %%%%
\newenvironment{changemargin}[2]{\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{0pt}%
\setlength{\rightmargin}{0pt}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{0pt plus 1pt}%
\addtolength{\leftmargin}{#1}%
\addtolength{\rightmargin}{#2}%
}\item }{\end{list}}
%%%% fin macro %%%%

\usepackage{listings}
\usepackage{color}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

%% nouvelle commande pour les listings %%
\newcommand{\crealplisting} [1]{
  \lstset{ %
    backgroundcolor=\color{white},  % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
    basicstyle=\footnotesize,       % the size of the fonts that are used for the code
    breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
    breaklines=true,                % sets automatic line breaking
    captionpos=b,                   % sets the caption-position to bottom
    commentstyle=\color{dkgreen},   % comment style
    deletekeywords={...},           % if you want to delete keywords from the given language
    %escapeinside={\%*}{*)},         % if you want to add LaTeX within your code
    %extendedchar=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
    frame=single,                   % adds a frame around the code
    keywordstyle=\color{blue},      % keyword style
    language=#1,                % the language of the code
    morekeywords={*,...},           % if you want to add more keywords to the set
    numbers=left,                   % where to put the line-numbers; possible values are (none, left, right)
    numbersep=5pt,                  % how far the line-numbers are from the code
    numberstyle=\tiny\color{gray},  % the style that is used for the line-numbers
    rulecolor=\color{black},        % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
    showspaces=false,               % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
    showstringspaces=false,         % underline spaces within strings only
    showtabs=false,                 % show tabs within strings adding particular underscores
    stepnumber=1,                   % the step between two line-numbers. If it's 1, each line will be numbered
    stringstyle=\color{mauve},      % string literal style
    tabsize=2,                      % sets default tabsize to 2 spaces
    %title=\lstname                  % show the filename of files included with \lstinputlisting; also try caption instead of title
  }
}


%% nouvelle commande pour créer le titre
\newcommand {\crealptitle} [4] {
	\begin{titlepage}
	\begin{changemargin}{-1.5cm}{-1.5cm}
		%%%%%% EN TETE %%%%%
		\begin{center}
		\begin{tabular}{|p{2.3cm}|p{13cm}|}
		\hline
		% colonne 1
		\begin{center}
		\includegraphics [width=65 pt]{img/logo_crealp_seul.png}
		\end{center}
		& 
		% colonne 2
		\begin{center}
		\textsc{Research center on alpine environment}\\
		\textsc{\small Centre de Recherche sur l'Environnement Alpin }\\
		\scriptsize Industrie 45 - CH 1951 SION +4127 324 03 80 crealp@crealp.vs.ch
		\end{center}
		\\ \hline
		\end{tabular}
		\end{center}
		%%%%%% FIN DE L EN TETE %%%%%%

		\vspace{4cm}

		%%%%%%%%%%%%%%%%%%%% TITRE %%%%%%%%%%%%%%%%%%
		\begin{center}
		\begin{tabular}{|p{13cm}|}	
		\hline
		\begin{center}
			\bfseries {\Huge {\sffamily #1}}
		\end{center}
		\\ \hline
		\end {tabular}
		\end{center}
		%%%%%%%%%%%%%%%%%%%% FIN TITRE %%%%%%%%%%%%%

		\vspace{2cm}

		%%%%%%%%%%%%%%%%%%%  DESCRIPTION %%%%%%%%%%%%%
		\begin{center}
		\begin{tabular}{p{14cm}}	
		\hline
		\begin{center}
			\bfseries {\LARGE {\sffamily #2}}
		\end{center}
		\\ \hline
		\end {tabular}
		\end{center}
		%%%%%%%%%%%%%%%%%  FIN DESCRIPTION %%%%%%%%%%%%

		\vspace{6cm}

		%%%%%%%%%%%%%%%%%%%  BAS DE PAGE - DATE %%%%%%%%%%%%%
		\begin{center}
    Revised: \today 

			#3 

			\href{mailto:#4}{\url{#4}}
		\end{center}
		%%%%%%%%%%%%%%%%%%%  FIN DE BAS DE PAGE %%%%%%%%%%%%%
	\end{changemargin}		
	\end{titlepage}
}
