%-------------------------------------------------------------------------------

% This file is part of Code_Saturne, a general-purpose CFD tool.
%
% Copyright (C) 1998-2018 EDF S.A.
%
% This program is free software; you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free Software
% Foundation; either version 2 of the License, or (at your option) any later
% version.
%
% This program is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
% details.
%
% You should have received a copy of the GNU General Public License along with
% this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
% Street, Fifth Floor, Boston, MA 02110-1301, USA.

%-------------------------------------------------------------------------------

\NeedsTeXFormat{LaTeX2e}
\def \filename {csdoc.sty}
\def \filedate {2013/02/07}
\def \fileversion {0.6}
\ProvidesPackage {csdoc}[\filedate\space\fileversion\space
  Code_Saturne documentation format package]
\typeout {Package: `csdoc' \fileversion\space <\filedate>}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load required packages
\RequirePackage{ifpdf}

\ifpdf
  \pdfcompresslevel=9
  \RequirePackage[pdftex]{graphicx}
  \DeclareGraphicsExtensions{.png,.pdf,.jpg}
\else
  \RequirePackage{graphicx}
\fi

\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{setspace}
\RequirePackage{xspace}

\RequirePackage{tabularx}
\RequirePackage{wasysym}
\RequirePackage{fancyhdr}
\RequirePackage{lastpage}
\RequirePackage{ifthen}
\RequirePackage{alltt}
\RequirePackage{nomencl}
\RequirePackage{enumitem}
\RequirePackage{subfigure}
\RequirePackage{listings}
\lstloadlanguages{C,C++,Fortran,Python}

\RequirePackage[latin1]{inputenc}
\RequirePackage[OT1]{fontenc} % \RequirePackage[T1]{fontenc} Caution: symbols list

% Keep the hyperref package at the end of the required packages list
\RequirePackage[pdftex,
                bookmarksopen=true,
                colorlinks=true,
                linkcolor=blue,
                filecolor=blue,
                urlcolor=blue,
                citecolor=blue]{hyperref}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Page layout: macro definitions
\newcommand{\titreCS}[1]{\def\titre{#1}}
\newcommand{\docassociesCS}[1]{\def\docassocies{#1}}
\newcommand{\resumeCS}[1]{\def\resume{#1}}

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Horizontal margins
%-------------------
\setlength{\voffset}{0pt}
\setlength{\topmargin}{0pt}
\addtolength{\topmargin}{-13mm}
\setlength{\headheight}{15mm}
\setlength{\headsep}{6mm}
\setlength{\textheight}{233mm}
\setlength{\footskip}{15mm}

% Vertical margins
%-----------------
\setlength{\hoffset}{0pt}
\setlength{\evensidemargin}{7mm}
\setlength{\oddsidemargin}{7mm}
\setlength{\textwidth}{156mm}
\setlength{\parindent}{0mm}
\setlength{\parskip}{6pt}
\setlength{\tabcolsep}{1mm}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Renew title styles for sections and others
\DeclareFixedFont{\polsec}{OT1}{phv}{b}{n}{16}
\DeclareFixedFont{\polssec}{OT1}{phv}{b}{n}{14}
\DeclareFixedFont{\polsssec}{OT1}{phv}{b}{n}{12}
\renewcommand{\section}{\@startsection {section}{1}{\z@}
                        {12pt plus2pt minus1pt}
                        {6pt}
                        {\bfseries\fontsize{16}{18}\selectfont\polsec}}
\renewcommand{\subsection}{\@startsection {subsection}{2}{\z@}
                           {12pt plus2pt minus1pt}
                           {6pt}
                           {\bfseries\fontsize{14}{16}\polssec}}
\renewcommand{\subsubsection}{\@startsection {subsubsection}{3}{\z@}
                           {12pt plus2pt minus1pt}
                           {6pt}
                           {\bfseries\fontsize{12}{14}\polsssec}}
\newcommand{\subsubsubsection}{\@startsection {paragraph}{3}{\z@}
                             {12pt plus2pt minus1pt}
                             {6pt}
                             {\bfseries\fontsize{10}{12}\polsssec}}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Contents
%
\renewcommand*\l@section{\upshape\bfseries \@dottedtocline{1}{0.5em}{2.5em}}
\renewcommand*\l@subsection{\mdseries\scshape \@dottedtocline{2}{0.5em}{3.4em}}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input Code_Saturne name and version macros
\input{csvers}
%
% Choose Code_Saturne logo version

\newcommand{\logocs}{cs_logo_flux}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bibliography
%-------------
% Remove the references title

\renewenvironment{thebibliography}[1]
     {\list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy\clubpenalty4000\widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Warning: \passepage does not work before a \chapter ('report' class)
\newcommand{\passepage}{%
\ifthenelse{\isodd{\arabic{page}}}
{\newpage\hspace*{6.cm}\newpage}{\newpage}}
\newcommand{\passepart}{%
\hspace*{6.cm}\ifthenelse{\isodd{\value{page}}}
{\newpage}{\hspace*{-6.cm}}}
%
\newcommand{\minititre}[1]{\bigskip\noindent \underline{\sc #1}\\}
%
% Headers and footpages
% =====================
\pagestyle{fancy}
\fancyhead{}
\fancyhead[LE,LO]{\cartouche}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

% CARTOUCHE
% =========
\newcommand{\cartouche}{%
\hspace*{-5mm}
\begin{tabularx}{162mm}
{|>{\small\centering\arraybackslash}p{2.7cm}|>{\small\centering\arraybackslash}X|>
{\small\centering\arraybackslash}p{3.5cm}|}
\hline
\vspace{2mm}\textbf{EDF R\&D}
&
\vspace{2mm}\textbf{\large\titre}
&
\CS \par
documentation \par
Page \thepage/\pageref{LastPage} \\
\hline
\end{tabularx}}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Title page
\newcount\hour \newcount\minute
\hour=\time  \divide \hour by 60
\minute=\time
\loop \ifnum \minute > 59 \advance \minute by -60 \repeat
\newcommand\now{\number\hour\ h
         \ifnum \minute<10 0\fi
         \number\minute}

\input{../../debian/epoch}
\def\monthyear{%
  \ifcase\month\or
  JANUARY\or FEBRUARY\or MARCH\or APRIL\or MAY\or JUNE\or
  JULY\or AUGUST\or SEPTEMBER\or OCTOBER\or NOVEMBER\or
  DECEMBER\fi
  \space \number\year}

\newcommand{\makepdgCS}
{%

\begin{titlepage}

\thispagestyle{empty}

\enlargethispage{4.5cm} % Enlarge the \textheight for the current page
\unitlength=1cm

\begin{center}
\vspace*{-32mm}

\begin{picture}(16,8.5)
  \put(7,5.7){\includegraphics*[width=1.95cm]{logoedf}}
  \put(0,7.1){\textsf{\textbf{EDF R\&D}}}
  \put(0,4.6){\scriptsize\textsc{\textsf{Fluid Dynamics, Power Generation and Environment Department}}}
  \put(0,4.3){\scriptsize\textsc{\textsf{Single Phase Thermal-Hydraulics Group}}}
  \put(0,3.6){\scriptsize\textsc{\textsf{6, quai Watier}}}
  \put(0,3.3){\scriptsize\textsc{\textsf{F-78401 Chatou Cedex}}}
  \put(0,2.5){\scriptsize\textsc{\textsf{Tel: 33 1 30 87 75 40}}}
  \put(0,2.2){\scriptsize\textsc{\textsf{\parbox[t]{16cm}{Fax: 33 1 30 87 79 16 \hfill \monthyear}}}}
\end{picture}
\begin{picture}(16,4.4)
  \put(2.5,0){\framebox(11,4.4){\ }}
  \put(2.75,3.8){\CS\ documentation}
  \put(2.75,2.5){\parbox[t]{10.5cm}{\centering\textbf{{\titre}}}}
  \put(2.75,0.4){contact: saturne-support@edf.fr}
\end{picture}
\begin{picture}(16,13)
\put(3,3){\includegraphics*[width=10cm]{\logocs}}
\end{picture}
\end{center}

{ http://code-saturne.org/\hfill\copyright{} EDF \number\year}

\passepart

\end{titlepage}
\normalsize
}


