%
% LaTeX style file for thesis made at the University of Aveiro
%
% (c) 1999, 2007, 2009 Tomás Oliveira e Silva
%
\ProvidesPackage{uaThesis}[2012/05/20 v0.7 UA thesis]
\usepackage{graphicx}
\usepackage{color}
\usepackage{a4wide}

%
% university logo
%
\DeclareOption{oldLogo}{\def\ua@logo{uaLogoOld}}
\DeclareOption{newLogo}{\def\ua@logo{uaLogoNew}}

%
% Remove "Documento provisório" from the cover page
%
\newif\ifua@final@\ua@final@false
\DeclareOption{final}{\ua@final@true}

%
% color of the cover page top bar
%
\DeclareOption{usecolor}{} % no longer used

\newif\ifua@whitebar@\ua@whitebar@false

\def\ua@arts       {% approximation of the color pantone  264
                    \def\ua@red{0.72}\def\ua@green{0.59}\def\ua@blue{1.00}}

\def\ua@sciences   {% approximation of the color pantone 3105
                    \def\ua@red{0.52}\def\ua@green{1.00}\def\ua@blue{0.89}}

\def\ua@education  {% approximation of the color pantone 1505
                    \def\ua@red{1.00}\def\ua@green{0.43}\def\ua@blue{0.00}}

\def\ua@economy    {% approximation of the color pantone 1787 (the middle bar is white!)
                    \def\ua@red{1.00}\def\ua@green{0.20}\def\ua@blue{0.35}}

\def\ua@engineering{% approximation of the color pantone  484
                    \def\ua@red{0.64}\def\ua@green{0.00}\def\ua@blue{0.00}}

\def\ua@humanities {% approximation of the color pantone  301
                    \def\ua@red{0.00}\def\ua@green{0.25}\def\ua@blue{0.77}}

\def\ua@health     {% approximation of the color pantone  115
                    \def\ua@red{0.95}\def\ua@green{0.88}\def\ua@blue{0.00}}

% Electrical Engineering (old name)
\DeclareOption{ElEng}{\def\ua@red{1.0}\def\ua@green{0.6}\def\ua@blue{0.0}%
  \let\ua@redT=\ua@red\let\ua@greenT=\ua@green\let\ua@blueT=\ua@blue
  \let\ua@redM=\ua@red\let\ua@greenM=\ua@green\let\ua@blueM=\ua@blue
  \let\ua@redB=\ua@red\let\ua@greenB=\ua@green\let\ua@blueB=\ua@blue
  \def\ua@textA{}%
  \def\ua@textB{Departamento de Electr\'onica e Telecomunica\c c\~oes,}%
  \def\ua@textC{}%
  \def\ua@textD{}}

% Electrical Engineering and Informatics
\DeclareOption{DETI}{\ua@engineering
  \let\ua@redT=\ua@red\let\ua@greenT=\ua@green\let\ua@blueT=\ua@blue
  \let\ua@redM=\ua@red\let\ua@greenM=\ua@green\let\ua@blueM=\ua@blue
  \let\ua@redB=\ua@red\let\ua@greenB=\ua@green\let\ua@blueB=\ua@blue
  \def\ua@textA{Departamento de}%
  \def\ua@textB{ET,}%
  \def\ua@textC{}%
  \def\ua@textD{}}
% Mathematics
\DeclareOption{DM}{\ua@sciences
  \let\ua@redT=\ua@red\let\ua@greenT=\ua@green\let\ua@blueT=\ua@blue
  \let\ua@redM=\ua@red\let\ua@greenM=\ua@green\let\ua@blueM=\ua@blue
  \let\ua@redB=\ua@red\let\ua@greenB=\ua@green\let\ua@blueB=\ua@blue
  \def\ua@textA{}%
  \def\ua@textB{Departamento de Matem\'atica,}%
  \def\ua@textC{}%
  \def\ua@textD{}}
% Physics
\DeclareOption{DF}{\ua@sciences
  \let\ua@redT=\ua@red\let\ua@greenT=\ua@green\let\ua@blueT=\ua@blue
  \let\ua@redM=\ua@red\let\ua@greenM=\ua@green\let\ua@blueM=\ua@blue
  \let\ua@redB=\ua@red\let\ua@greenB=\ua@green\let\ua@blueB=\ua@blue
  \def\ua@textA{}%
  \def\ua@textB{Departamento de F\'\i sica,}%
  \def\ua@textC{}%
  \def\ua@textD{}}
% Physics
\DeclareOption{DEC}{\ua@engineering 
  \let\ua@redT=\ua@red\let\ua@greenT=\ua@green\let\ua@blueT=\ua@blue
  \let\ua@redM=\ua@red\let\ua@greenM=\ua@green\let\ua@blueM=\ua@blue
  \let\ua@redB=\ua@red\let\ua@greenB=\ua@green\let\ua@blueB=\ua@blue
  \def\ua@textA{}%
  \def\ua@textB{Departamento de Engenharia Civil}%
  \def\ua@textC{}%
  \def\ua@textD{}}
\DeclareOption{DEM}{\ua@engineering 
  \let\ua@redT=\ua@red\let\ua@greenT=\ua@green\let\ua@blueT=\ua@blue
  \let\ua@redM=\ua@red\let\ua@greenM=\ua@green\let\ua@blueM=\ua@blue
  \let\ua@redB=\ua@red\let\ua@greenB=\ua@green\let\ua@blueB=\ua@blue
  \def\ua@textA{}%
  \def\ua@textB{Departamento de Engenharia Mecânica}%
  \def\ua@textC{}%
  \def\ua@textD{}}


\ExecuteOptions{DETI}    % default!
\ExecuteOptions{oldLogo} % default!
\ProcessOptions

%
% Used to place a tri-colored colored bar in the title page. The \BAR macro must be
% placed inside the first argument of the \HEADER macro.
%
\def\BAR{\smash{\rlap{\textcolor[rgb]{\ua@redT,\ua@greenT,\ua@blueT}{\vrule width 133mm height 12.000mm depth -10.666mm}}}%  top bar
         \smash{\rlap{\textcolor[rgb]{\ua@redM,\ua@greenM,\ua@blueM}{\vrule width 133mm height 10.667mm depth  -9.333mm}}}%  middle bar
         \smash{\rlap{\textcolor[rgb]{\ua@redB,\ua@greenB,\ua@blueB}{\vrule width 133mm height  9.334mm depth  -8.000mm}}}}% bottom bar

%
% Used to include a figure in the title page. The \FIG macro must be placed
% inside the first argument of the \HEADER macro. The text of the macro is
% typeset in the space reversed for a figure, citation, or whatever, and must
% have an height plus depth that does not exceed 60mm
%
\long\def\FIG#1{\smash{\rlap{\setbox0=\hbox{#1}\dimen0=137mm%
  \advance\dimen0 by\ht0\lower\dimen0\box0}}}

%
% fixed font sizes
%
\def\ua@font@size#1{\ifcase#1
      % 11pt \normalsize
    \fontsize{\@xipt}{13.6}\selectfont
  \or % 11pt \Large
    \fontsize{\@xivpt}{18}\selectfont
  \or % 11pt \Huge
    \fontsize{\@xxvpt}{30}\selectfont
  \fi}

%
% Used to put the University logo on the top of a page. Should be the first
% macro inside a \TitlePage environment. Its first argument can be a \BAR
% macro call and/or a \FIG macro call; anything else that does not change the
% horizontal and vertical positions can also be used. Its second argument is
% the year of the thesis.
%
\def\ua@above#1#2{\rlap{\smash{\raise 10pt\hbox{\ua@font@size0\textsf{#1}}}}\hbox{\ua@font@size0\textsf{#2}}}
\def\ua@below#1#2{\rlap{\smash{\lower 10pt\hbox{\ua@font@size0\textsf{#2}}}}\hbox{\ua@font@size0\textsf{#1}}}
\long\def\HEADER#1#2{\vspace*{5mm}\noindent\ua@font@size0\rlap{\parbox{\textwidth}{%
    \ua@font@size0\hspace*{77mm}#1\textsf{\textbf{Universidade de Aveiro}}\space\space
      \ua@above{\ua@textA}{\ua@textB}%
    \iffalse
      %\hrule width \textwidth height .3pt depth 0mm\relax
    \else
      % pdflatex apparently draws the logo before the hrule (why?), so we need to split the hrule in two
      %\hrule width 66mm height 0.3pt depth 0mm\relax
      \vskip -0.3pt
      %\nointerlineskip\moveright 75.2mm\vbox{\hrule width 134.8mm height 0.3pt depth 0mm}\nointerlineskip
    \fi
    \ua@font@size0\hspace*{77mm}\rlap{\ua@font@size0\textsf{\textbf{\strut #2}}}%
      \hphantom{\ua@font@size0\textsf{\textbf{Universidade de Aveiro}}}\space\space
      \ua@below{\ua@textC}{\ua@textD}}}\par
%  \ua@font@size0\vspace*{-8.8mm}\noindent\hspace*{67mm}\includegraphics[height=9mm]{\ua@logo}%
  \ua@font@size0\vspace*{-10.8mm}\noindent\hspace*{66mm}\includegraphics[height=9mm]{\ua@logo}%
    \ifua@final@\else
      \smash{\rlap{\kern 10mm\lower 125mm\hbox{\Huge\textsf{\textbf{DOCUMENTO}}}}}%
      \smash{\rlap{\kern 20mm\lower 137mm\hbox{\Huge\textsf{\textbf{PROVIS\'ORIO}}}}}%
    \fi
  \par\vspace*{40mm}}

%
% Used to put the thesis title in the page. Must be placed immediately after
% the \HEADER macro. The first argument is the author's name and the second
% argument is the thesis title.
%
\long\def\TITLE#1#2{\noindent\hspace*{15mm}\parbox[t]{52mm}{\raggedright
  \ua@font@size1\textsf{\textbf{#1}}}\hspace*{10mm}\parbox[t]{120mm}{\raggedright
  \ua@font@size1\textsf{\textbf{#2}}}\par}

%
% Used to put text in the page. The first argument is the left hand side
% text (may be empty) and the second argument is the right hand side text.
% Use either one \TEXT macro call per paragraph or put all paragraphs in
% one \TEXT macro call.
%
\long\def\TEXT#1#2{\noindent\hspace*{15mm}\parbox[t]{52mm}{\raggedright\sloppy
  \textsf{#1}}\hspace*{10mm}\parbox[t]{120mm}{\textsf{#2}}\par\medskip}

%
% The environment used to build a special page.
%
\def\TitlePage{\newpage\begingroup
  \hoffset=-1in%
  \voffset=-1in%
  \oddsidemargin=0mm%
  \evensidemargin=0mm%
  \topmargin=0mm%
  \headheight=0mm%
  \headsep=0mm%
  \textwidth=210mm%
  %%\textheight=297mm%
  \textheight=297mm%
  \paperwidth=210mm%
  \paperheight=297mm%
  \footskip=0mm%
  \maxdepth=0mm%
  \hsize=210mm%
  \vsize=297mm%
  \titlepage}
\def\EndTitlePage{\endtitlepage\endgroup\newpage}

%
% Used to place a 3mm grid in the page (useful for positioning things). This
% macro works correctly when the PostScript file is generated by dvips. Perfect
% for ghostscript (gv), but very bad when printed. For debugging purposes
%
\iftrue\def\GRID{\special{"gsave initmatrix 72 25.4 div dup scale
  0 setlinewidth 0.8 setgray newpath
  0 3 210 { 0 moveto 0 297 rlineto } for
  0 3 297 { 0 exch moveto 210 0 rlineto } for stroke
  1 0 0 setrgbcolor newpath
  15 0 moveto 15 297 lineto 77 0 moveto 77 297 lineto
  0 293 moveto 210 293 lineto 0 289 moveto 210 289 lineto
  0 239 moveto 210 239 lineto
  0 148 moveto 210 148 lineto 0 88 moveto 210 88 lineto
  77 88 moveto 77 148 lineto 137 88 moveto 137 148 lineto stroke
  grestore}}
\fi

%
% Always indent the first paragraph
%
%JAlex% \let\@afterindentfalse=\@afterindenttrue\@afterindenttrue


%
% mark (or not) all horizontal overfull boxes
%
% \ifua@final@
%   \setlength\overfullrule{0mm}
% \else
%   \setlength\overfullrule{5mm}
% \fi


%
% Add all chapters without numbers (\chapter*) to the table of contents. As a
% consequence, the bibliography, table of contents, list of figures and list
% of tables appear in the table of contents
%
% good for the report and book classes
%
%JAlex%\def\@makeschapterhead#1{%
%JAlex%  \vspace*{50\p@}%
%JAlex%  {\parindent \z@ \raggedright
%JAlex%    \normalfont
%JAlex%    \interlinepenalty\@M
%JAlex%    \Huge \bfseries  #1\par\nobreak
%JAlex%    \vskip 40\p@
%JAlex%    % new stuff
%JAlex%    \refstepcounter{section}% to make the hyperref package do the right thing!!!
%JAlex%    \addcontentsline{toc}{chapter}{#1}%
%JAlex%    \addtocontents{lof}{\protect\addvspace{10\p@}}%
%JAlex%    \addtocontents{lot}{\protect\addvspace{10\p@}}%
%JAlex%    % end of new stuff
%JAlex%  }}
%JAlex%
%JAlex%\endinput
