\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{diumthesis}[2003/07/11 v0.04 Basic class for thesis at DIUM]
\RequirePackage{ifthen,fancyhdr,graphicx}


%
%  \usepackage[english]{diumthesis} ---> usar inglês
%
\newboolean{english}
\setboolean{english}{false}
\DeclareOption{english}{\setboolean{english}{true}}


%
% \usepackage[book]{diumthesis} ---> tamanho book
% \usepackage{diumthesis} ---> tamanho A4
%
\newboolean{wantbook}
\setboolean{wantbook}{false}
\DeclareOption{book}{\setboolean{wantbook}{true}}

%
% \usepackage[markit]{diumthesis} ---> Marca na capa para corte...
% \usepackage{diumthesis} ---> não marca nada
%
\newboolean{markit}
\setboolean{markit}{false}
\DeclareOption{markit}{\setboolean{markit}{true}}

%
% \usepackage[book,center]{diumthesis} ---> tamanho book centrado
%
\newboolean{centered}
\setboolean{centered}{false}
\DeclareOption{center}{\setboolean{centered}{true}}

%
% \usepackage[mestrado]{diumthesis} ---> texto de mestrado
% \usepackage{diumthesis} ---> texto de doutoramento
%
\newboolean{mestrado}
\setboolean{mestrado}{false}
\DeclareOption{mestrado}{\setboolean{mestrado}{true}}

%
% \usepackage[cmpctlists]{diumthesis} ---> listas compactas (a la jj)
%
\newboolean{cmpctlists}
\setboolean{cmpctlists}{false}
\DeclareOption{cmpctlists}{\setboolean{cmpctlists}{true}}

\newboolean{logo}
\setboolean{logo}{false}
\DeclareOption{logo}{\setboolean{logo}{true}}

\ProcessOptions

%%%------------ End of Header


%
% Tratar do tamanho da página (A4 vs book)
%
\ifthenelse{\boolean{wantbook}}{% BOOK
  \ifthenelse{\boolean{centered}}{% BOOK centered
      \usepackage[compat2,a4paper,twosideshift=0mm,left=41mm,right=41mm,bottom=41mm,top=41mm]{geometry}}{% BOOK encostado
      \usepackage[compat2,a4paper,twosideshift=-17mm,left=41mm,right=41mm,bottom=14mm,top=68mm]{geometry}}}{% A4
  \usepackage[compat2,a4paper,twosideshift=0mm,left=30mm,right=30mm,bottom=30mm,top=30mm]{geometry}}

 
\def\basedir{}%BASEDIR



\newcommand{\mestrado}[1]{\small
  \ifthenelse{\boolean{english}}{ % English

  }{ % Portuguese
   Dissertação submetida à Universidade do Minho para obtenção do
   grau de Mestre em Informática, elaborada sob a orientação de #1
  }
}

\newcommand{\doutoramento}[1]{\small
  \ifthenelse{\boolean{english}}{ % English
    Dissertation submitted in partial fulfillment of the requirements
    for the degree of Philosophi\ae\ Doctor at the University of
    Minho, under the supervision of #1
  }{ % Portuguese
   Dissertação submetida à Universidade do Minho para obtenção do
   grau de Doutor em Informática, elaborada sob a orientação de #1
  }
}


%
% Cria página de título. Passar como argumento o nome do/s orientador/es
%
\newcommand{\diumtitlepage}[1]{
 \thispagestyle{empty}
 \ifthenelse{\boolean{markit}}{\makebox[0mm][l]{\hspace{\textwidth}\hspace{15mm}\raisebox{30mm}[0pt][0pt]{\makebox[0pt][c]{+}}}\makebox[0mm][l]{\hspace{-30mm}\raisebox{30mm}[0pt][0pt]{\makebox[0pt][c]{+}}}}{}
 \begin{center}
   \vfill~\vfill
   \huge \@title\\[5mm]
   \large \textbf{\@author}\\
   \vfill
   \ifthenelse{\boolean{logo}}{\includegraphics[width=.45\textwidth]{\basedir logoum}}{~}
   \vfill
   {\small\it\ifthenelse{\boolean{mestrado}}{\mestrado{#1}}{\doutoramento{#1}}}
   \vfill
   Departamento de Informática\\
   Escola de Engenharia\\
   Universidade do Minho\\[2mm]
   \@date
 \end{center}
 \newpage
 \thispagestyle{empty}
 \cleardoublepage
 \thispagestyle{empty}
}


%
% Abstract code
%
\newcommand\diumabstractname{Abstract}
\newenvironment{diumabstract}{%
  \section*{\diumabstractname}}
{\cleardoublepage \thispagestyle{empty}}
%
% Resumo
%
\newcommand\diumresumoname{Resumo}
\newenvironment{diumresumo}{%
  \section*{\diumresumoname}}
{\cleardoublepage \thispagestyle{empty}}



%
% Definição de Cabeçalhos
%
\pagestyle{fancy}
\fancyhead[LE,RO]{\small\thepage}
\fancyfoot[R,L]{}
\fancyfoot[C]{}
\renewcommand{\chaptermark}[1]{\markboth{ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{ \thesection.\ #1}}
\fancyhead[LO]{\nouppercase{\small\rightmark}}
\fancyhead[RE]{\nouppercase{\small\leftmark}}
%\fancyhead[RE,LO]{}      



%
% listas compactas
%
\ifthenelse{\boolean{cmpctlists}}{% alteracoes `as listas do latex
\def\@listI{\leftmargin\leftmargini  
            \parsep 0\p@ \@plus1\p@ \@minus\p@ 
            \topsep 0\p@ \@plus2\p@ \@minus4\p@ \itemsep0\p@}
\let\@listi\@listI
\@listi
\def\@listii {\leftmargin\leftmarginii
              \labelwidth\leftmarginii
              \advance\labelwidth-\labelsep
              \topsep    0\p@ \@plus2\p@ \@minus\p@}
\def\@listiii{\leftmargin\leftmarginiii
              \labelwidth\leftmarginiii
              \advance\labelwidth-\labelsep
              \topsep    0\p@ \@plus\p@\@minus\p@
              \parsep    \z@
             \partopsep \p@ \@plus\z@ \@minus\p@}
\renewcommand\labelitemi{\normalfont\bfseries --}
\renewcommand\labelitemii{$\m@th\bullet$}     
\def\subitem{\par\setbox0=\hbox{--\enspace}% second order
                \noindent\hangindent\wd0\box0}% index entry
\def\subsubitem{\par\setbox0=\hbox{--\,--\enspace}% third
                \noindent\hangindent\wd0\box0}% order index entry
}{}









%\newcounter{exam}[chapter]
%\raggedbottom
%\newenvironment{com}{\begin{footnotesize} Notas:\begin{description}}{\end{description}\end{footnotesize}}
%\def\linha#1{\item[linha #1] -}
%%\newenvironment{exemplo}[1]{\addtocounter{exam}{1}\begin{list}{}{
%\newenvironment{exemplo}[1]{~\\*[-1ex]
%\protect{
  %\makebox[0mm][l]{\hspace{1mm}\raisebox{-3ex}[0pt][0pt]{\rule{.2pt}{4mm}}}\refstepcounter{exam}\textbf{Exemplo \theexam:} #1} %% \\*[-1ex]
%\begin{list}{}{
 %\itemindent  1.2em
 %\leftmargin  1em
 %\rightmargin 1em
 %\listparindent 0.5em
 %\parsep 2pt %%%
%}\item 
%
%}{\end{list} %% ~\\*[-1ex] 
%\mbox{}\hspace{1mm}\raisebox{1ex}[0pt][1ex]{\rule{.2pt}{4mm}\rule{4cm}{.2pt}}
%
%\smallskip }
%
%\parskip 6pt
%\parindent 1em
%
%%\setcounter{secnumdepth}{2}
%%\setcounter{tocdepth}{3}
%


\newenvironment{diumquote}[1]
{\begin{flushright}\begin{minipage}{0.72\textwidth}\small\it
      \def\xpto{#1}}
    {\begin{flushright}\textit{\textsf{\xpto}}\end{flushright}\end{minipage}\end{flushright}
~\\
}


