%%
%% This is file `carte.sty',
%% it is intended to generate the LaTeX2e style for a book at the Dunod
%%
%% It should be put as last package in the declaration if you want
%% to avoid problems.
%%
%% It has been realized by Henri de la Vallée Poussin.
%%
%%
%% --------------------------------------------
%%
%% It may be distributed under the terms of the LaTeX Project Public
%% License, as described in lppl.txt in the base LaTeX distribution.
%% Either version 1.0 or, at your option, any later version.
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{carte}
              [2001/03/16 v1.9
 Standard LaTeX document style]

%\setlength{\parindent}{0cm} % Fara indent la inceput de paragraf
\setlength{\textheight}{20cm} % Inaltimea paginii %19
\setlength{\textwidth}{17.75cm} % Latimea paginii %17
\setcounter{secnumdepth}{3} % Pentru nemerotarea subsubcapitolelor
% \setcounter{tocdepth}{3} % Cuprinsul contine subsubcapitolele
\setcounter{tocdepth}{2}

\tolerance 9999 % Pentru ca sa nu se depaseasca marginile

\newcommand{\expotextrm}[1]{\textrm{\scriptsize{#1}}} % Pentru exponenti in formulele
                                                                                          % matematice

\newcommand\cfigurename{Figura}
\def\fnum@figure{\cfigurename~\thefigure}
\newcommand\ctablename{Tabel}
\def\fnum@table{\ctablename~\thetable}

\def\CaptionSeparator{\string:\space}
\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{\footnotesize #1\CaptionSeparator #2}%
  \ifdim \wd\@tempboxa >\hsize
   {\footnotesize #1\CaptionSeparator #2}\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}

\newenvironment{theappendixes}[2][]%
    {\def\cfirst{#1}
    \def\csec{#2}
    \def\cnull{}
    \ifx \cfirst\cnull \def\ctitle{\csec} \else \def\ctitle{\cfirst} \fi %
%    \@latex@warning{#1 - #2 * \ctitle +} %
    \setcounter{equation}{0}%\@addtoreset {equation}{section}%
    \setcounter{figure}{0}%
    \setcounter{subsection}{0}%
%    \section*{\thechapter{}A Annexes~:~{\csec}}%
%    \addcontentsline{toc}{section}{\thechapter{}A Annexes~:~{\ctitle}}%
    \section*{Annexes~:~{\csec}}%
    \addcontentsline{toc}{section}{Annexes~:~{\ctitle}}%
    \sectionmark{\thechapter{}A Annexes~:~{\ctitle}}
    \renewcommand \thesubsection{\thechapter{}A.\@arabic\c@subsection}%
    \renewcommand\thesubsubsection{\thesubsection .\@arabic\c@subsubsection}
    \renewcommand\theequation%
      {\ifnum \c@chapter>\z@ \thechapter{}A.\fi \@arabic\c@equation}%
    \renewcommand \thefigure%
         {\ifnum \c@chapter>\z@ \thechapter{}A.\fi \@arabic\c@figure}%
%    \renewcommand\normalsize{%
%       \@setfontsize\normalsize\@ixpt{10.8}%
%       \abovedisplayskip 8\p@ \@plus2\p@ \@minus4\p@ %
%       \abovedisplayshortskip \z@ \@plus3\p@ %
%       \belowdisplayshortskip 5\p@ \@plus3\p@ \@minus3\p@ %
%       \belowdisplayskip \abovedisplayskip %
%       \let\@listi\@listI}%
%    \normalsize%
    }{%
%    \renewcommand\normalsize{%
%       \@setfontsize\normalsize\@xpt\@xiipt %
%       \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ %
%       \abovedisplayshortskip \z@ \@plus3\p@ %
%       \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ %
%       \belowdisplayskip \abovedisplayskip %
%       \let\@listi\@listI}%
%    \normalsize%
    }

\newenvironment{theappendix}[2][]%
    {\def\cfirst{#1}
    \def\csec{#2}
    \def\cnull{}
    \ifx \cfirst\cnull \def\ctitle{\csec} \else \def\ctitle{\cfirst} \fi %
    \setcounter{equation}{0}%\@addtoreset {equation}{section}%
    \setcounter{figure}{0}%
    \setcounter{subsection}{0}%
%    \section*{\thechapter{}A Annexe~:~{\csec}}%
%    \addcontentsline{toc}{section}{\thechapter{}A Annexe~:~{\ctitle}}%
    \section*{Annexes~:~{\csec}}%
    \addcontentsline{toc}{section}{Annexes~:~{\ctitle}}%
    \sectionmark{\thechapter{}A Annexe~:~{\ctitle}}
    \renewcommand \thesubsection{\thechapter{}A.\@arabic\c@subsection}%
    \renewcommand\thesubsubsection{\thesubsection .\@arabic\c@subsubsection}
    \renewcommand\theequation%
      {\ifnum \c@chapter>\z@ \thechapter{}A.\fi \@arabic\c@equation}%
    \renewcommand \thefigure%
         {\ifnum \c@chapter>\z@ \thechapter{}A.\fi \@arabic\c@figure}%
%    \renewcommand\normalsize{%
%       \@setfontsize\normalsize\@ixpt{10.8}%
%       \abovedisplayskip 8\p@ \@plus2\p@ \@minus4\p@ %
%       \abovedisplayshortskip \z@ \@plus3\p@ %
%       \belowdisplayshortskip 5\p@ \@plus3\p@ \@minus3\p@ %
%       \belowdisplayskip \abovedisplayskip %
%       \let\@listi\@listI}%
%    \normalsize%
    }{%
%    \renewcommand\normalsize{%
%       \@setfontsize\normalsize\@xpt\@xiipt %
%       \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@ %
%       \abovedisplayshortskip \z@ \@plus3\p@ %
%       \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ %
%       \belowdisplayskip \abovedisplayskip %
%       \let\@listi\@listI}%
%    \normalsize%
    }

\renewenvironment{thebibliography}[1]
     {\chapter*{Bibliografie}%section
      \addcontentsline{toc}{section}{Bibliografie}%
      \refstepcounter{chapter}%
      \chaptermark{Bibliografie}
      \sectionmark{Bibliografie}
      \list{\@biblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@biblabel{#1}}%
           \leftmargin\labelwidth
	   \def\leftmark{Bibliografie}
	   \def\rightmark{Bibliografie}
           \advance\leftmargin\labelsep
           \@openbib@code
           \usecounter{enumiv}%
           \let\p@enumiv\@empty
           \renewcommand\theenumiv{\@arabic\c@enumiv}}%
     \sloppy
     \clubpenalty4000
     \@clubpenalty \clubpenalty
     \widowpenalty4000%
     \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `thebibliography' environment}}%
      \endlist}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Modificare antete
%%
\if@twoside
  \def\ps@cheadings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty % Subsol gol
      \def\@evenhead{\thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markboth {%
        \ifnum \c@secnumdepth >\m@ne
          \if@mainmatter
            %\thechapter. \ %
          \fi
        \fi
        ##1}{}}%
    \def\sectionmark##1{%
      \markright {%
        \ifnum \c@secnumdepth >\z@
          %\thesection. \ %
        \fi
        ##1}}}
\else
  \def\ps@cheadings{%
    \let\@oddfoot\@empty
    \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
    \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markright {%
        \ifnum \c@secnumdepth >\m@ne
          \if@mainmatter
%            \@chapapp\ \thechapter. \ %
          \fi
        \fi
        ##1}}}
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Codul comenzii  \chapter luat din stilul book
%% Dar modificat pentru ca titlul lung sa fie preluat
%% in Cuprins.

\renewcommand\chapter{\clearpage%
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#2}%
                       \else
                         \addcontentsline{toc}{chapter}{#2}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#2}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\def\@schapter#1{\if@twocolumn
                   \@topnewpage[\@makeschapterhead{#1}]%
                 \else
                   \@makeschapterhead{#1}%
                   \@afterheading
                 \fi}
\def\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}

% Pentru a putea avea un capitl nenumerotat care sa apara insa
% in Cuprins

\newcommand\nnchapter[1]{\chapter*{#1}%
        \addcontentsline{toc}{chapter}{\numberline{}#1}
        \chaptermark{#1}
        \sectionmark{#1}
        }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Am recopiat stilul de capitol pentru ca totul
%% sa fie aliniat la stanga.

\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\Large\bfseries\raggedright}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries\raggedright}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries\raggedright}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\bfseries\raggedright}}
\pagestyle{cheadings}
