%
% \LaTeX\ style file for thesis made at the University of Aveiro
%
% (c) 1999, 2007 Tomás Oliveira e Silva
%
% WORKS WELL ONLY FOR 11pt DOCUMENTS
%
\ProvidesPackage{uaThesis}[2007/03/27 v0.5 UA thesis front pages]
\usepackage{epsfig}

\ifcase\@ptsize % 10pt
  \message{^^JThe uaThesis style does NOT work well with 10pt documents^^J^^J}
\or             % 11pt
\or             % 12pt
  \message{^^JThe uaThesis style does NOT work well with 12pt documents^^J^^J}
\fi

\newif\ifua@color@\ua@color@false
\DeclareOption{usecolor}{\ua@color@true}

\newif\ifua@whitebar@\ua@whitebar@false
\def\ua@arts       {\ua@whitebar@false\def\ua@red{0.72}\def\ua@green{0.59}\def\ua@blue{1.00}} % approximation of the color pantone  264
\def\ua@sciences   {\ua@whitebar@false\def\ua@red{0.52}\def\ua@green{1.00}\def\ua@blue{0.89}} % approximation of the color pantone 3105
\def\ua@education  {\ua@whitebar@false\def\ua@red{1.00}\def\ua@green{0.43}\def\ua@blue{0.00}} % approximation of the color pantone 1505
\def\ua@economy    {\ua@whitebar@true \def\ua@red{1.00}\def\ua@green{0.20}\def\ua@blue{0.35}} % approximation of the color pantone 1787
\def\ua@engineering{\ua@whitebar@false\def\ua@red{0.64}\def\ua@green{0.00}\def\ua@blue{0.00}} % approximation of the color pantone  484
\def\ua@humanities {\ua@whitebar@false\def\ua@red{0.00}\def\ua@green{0.25}\def\ua@blue{0.77}} % approximation of the color pantone  301
\def\ua@health     {\ua@whitebar@false\def\ua@red{0.95}\def\ua@green{0.88}\def\ua@blue{0.00}} % approximation of the color pantone  115

% Electrical Engineering (old name)
\DeclareOption{ElEng}{\def\ua@red{1.0}\def\ua@green{0.6}\def\ua@blue{0.0}%
  \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
  \def\ua@textA{Departamento de}%
  \def\ua@textB{Electr\'onica, Telecomunica\c c\~oes e Inform\'atica,}%
  \def\ua@textC{}%
  \def\ua@textD{}}
% Mathematics
\DeclareOption{DM}{\ua@sciences
  \def\ua@textA{}%
  \def\ua@textB{Departamento de Matem\'atica,}%
  \def\ua@textC{}%
  \def\ua@textD{}}
% Physics
\DeclareOption{DF}{\ua@sciences
  \def\ua@textA{}%
  \def\ua@textB{Departamento de F\'\i sica,}%
  \def\ua@textC{}%
  \def\ua@textD{}}
% Mechanics
\DeclareOption{DEM}{\ua@engineering
  \def\ua@textA{}%
  \def\ua@textB{Departamento de Engenharia Mec\^anica}%
  \def\ua@textC{}%
  \def\ua@textD{}}

\ExecuteOptions{DETI} % default!
\ProcessOptions

%
% Used to place a colored bar in the title page. The \BAR macro must be
% placed inside the first argument of the \HEADER macro.
%
\ifua@color@
  \usepackage[dvips]{color}
  \def\BAR{\smash{\rlap{\textcolor[rgb]{\ua@red,\ua@green,\ua@blue}{\vrule width 133mm height 12mm depth -8mm}}}%
           \ifua@whitebar@\smash{\rlap{\textcolor[rgb]{1,1,1}{\vrule width 133mm height 10.67mm depth -9.33mm}}}\fi}
\else
  \def\BAR{\smash{\rlap{\special{ps:gsave \ua@red \ua@green \ua@blue setrgbcolor}%
    \vrule width 133mm height 12mm depth -8mm%
    \ifua@whitebar@\special{ps:1 1 1 setrgbcolor}\vrule width 133mm height 10.67mm depth -9.33mm\fi
  \special{ps:grestore}}}}
\fi

%
% 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}}}
  
%%
%% Used to define the \textsubscript command macro
%%
%\newcommand\textsubscript[1]{\@textsubscript{\selectfont#1}}
%\def\@textsubscript#1{{\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
%\newcommand\textbothscript[2]{%
%  \@textbothscript{\selectfont#1}{\selectfont#2}}
%\def\@textbothscript#1#2{%
%  {\m@th\ensuremath{%
%    ^{\mbox{\fontsize\sf@size\z@#1}}%
%    _{\mbox{\fontsize\sf@size\z@#2}}}}}
%\def\@super{^}\def\@sub{_}
%
%\catcode`^\active\catcode`_\active
%\def\@super@sub#1_#2{\textbothscript{#1}{#2}}
%\def\@sub@super#1^#2{\textbothscript{#2}{#1}}
%\def\@@super#1{\@ifnextchar_{\@super@sub{#1}}{\textsuperscript{#1}}}
%\def\@@sub#1{\@ifnextchar^{\@sub@super{#1}}{\textsubscript{#1}}}
%\def^{\let\@next\relax\ifmmode\@super\else\let\@next\@@super\fi\@next}
%\def_{\let\@next\relax\ifmmode\@sub\else\let\@next\@@sub\fi\@next}

%
% Used to put the University logo on the top of a page. Should be the first
% macro inside a \TitlePage environment. (The \GRID and \DRAFT macros may be
% safely placed before the \HEADER macro.) 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{\textsf{#1}}}}\hbox{\textsf{#2}}}
\def\ua@below#1#2{\rlap{\smash{\lower 10pt\hbox{\textsf{#2}}}}\hbox{\textsf{#1}}}
\long\def\HEADER#1#2{\vspace*{5mm}\noindent\rlap{\parbox{\textwidth}{%
    \hspace*{77mm}#1\textsf{\textbf{Universidade de Aveiro}} %
      \ua@above{\ua@textA}{\ua@textB}%
    \hrule width \textwidth height .3pt depth 0mm\relax
    \hspace*{77mm}\rlap{\textsf{\textbf{\strut #2}}}%
      \hphantom{\textsf{\textbf{Universidade de Aveiro}}} %
      \ua@below{\ua@textC}{\ua@textD}}}\par
  \vspace*{-8.8mm}\noindent\hspace*{67mm}\epsfig{file=packages/uaLogoNew.eps,height=9mm}%
  \par\vspace*{40mm}}


%
% Used to put the thesis title in the page. Must be 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
  \Large\textsf{\textbf{#1}}}\hspace*{10mm}\parbox[t]{120mm}{\raggedright
  \Large\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%
  \paperwidth=210mm%
  \paperheight=297mm%
  \footskip=0mm%
  \maxdepth=0mm%
  \hsize=210mm%
  \vsize=297mm%
  \titlepage}
\def\EndTitlePage{\endtitlepage\endgroup\newpage}

%
% Used to place the text "Documento Provisório" across a page. This macro
% works correctly when the PostScript file is generated by dvips.
%
\def\DRAFT{\special{"gsave initmatrix newpath 297.64 500.94 translate
  30 rotate /Arial-BoldItalic findfont dup length dict begin
    { 1 index /FID ne { def } { pop pop } ifelse } forall
    /Encoding ISOLatin1Encoding def currentdict
  end /ISO exch definefont 50 scalefont setfont
  (Documento Provisório) dup stringwidth exch -2 div exch
  -2 div 0.26 50 mul sub moveto dup gsave 0.9 setgray show grestore
  true charpath 0 setlinewidth stroke grestore}}

%
% 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.
%
\def\GRID{\special{"gsave initmatrix 72 25.4 div dup scale
  newpath 0 setlinewidth 0.8 setgray
  0 3 210 { 0 moveto 0 297 rlineto } for
  0 3 297 { 0 exch moveto 210 0 rlineto } for stroke grestore}}

%
% 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. Too
% dark for ghostscript (gv), but acceptable when printed.
%
\def\PGRID{\special{"gsave initmatrix 72 25.4 div dup scale
  newpath 0 setlinewidth 0 setgray
  0 3 210 { 0 moveto 0 297 rlineto } for
  0 3 297 { 0 exch moveto 210 0 rlineto } for stroke grestore}}

\endinput
