%% UNAMThesis.sty  14/feb/2017
%% Copyright (c) 2008-2017 Julio A. Freyre-Gonzalez
% Style for Universidad Nacional Aut\'{o}noma de M\'{e}xico theses (grad and undergrad)
% UNAMThesis {Thesis: Universidad Nacional Aut\'{o}noma de M\'{e}xico}{11pt}{report}
\typeout{Thesis: Universidad Nacional Aut\'{o}noma de M\'{e}xico `UNAMThesis' <14 feb 2017>.}
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Julio A. Freyre-Gonzalez.
%
% THIS WORK IS PROVIDED ON AN "AS IS" BASIS.  THE AUTHOR PROVIDES NO
% WARRANTY WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THE WORK,
% INCLUDING WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR FITNESS
% FOR ANY PARTICULAR PURPOSE.
%
% If you make any improvement, found any bug or have a suggestion for a new feature, I'd like to hear about it:
%
% Julio A. Freyre-Gonzalez, PhD
% Professor in Regulatory Systems Biology
% Head of the Regulatory Systems Biology Group
% Center for Genomic Sciences, UNAM
% Av. Universidad S/N, Col. Chamilpa, 62210
% Cuernavaca, Morelos, Mexico
% jfreyre@ccg.unam.mx
% jfreyreg@gmail.com
% http://orcid.org/0000-0001-7061-7637
% http://unam.academia.edu/jfreyre
% https://www.researchgate.net/profile/Julio_Augusto_Freyre-Gonzalez/
%%
%%
% ChangeLog
% 14/feb/2017 jfreyre v2.1 add academictitle command and cosmetic updates
% 05/apr/2013 jfreyre v2.02 minor update
% 16/may/2011 jfreyre v2.01 fix minor typos
% 12/may/2011 jfreyre v2.0  proved in LaTeX standard enviroment (first public release)
% 11/may/2011 jfreyre v1.9  fix bugs under LaTeX standard enviroment
% 27/ago/2008 jfreyre v1.8  add foreword environment and its command version (internal release)
%  4/ago/2008 jfreyre v1.7  add quotenat environment (internal release)
% 17/jul/2008 jfreyre v1.6  minor cosmetic fixes (internal release)
% 17/jun/2008 jfreyre v1.5  add cover page with logos and customization options (internal release)
% 12/feb/2008 jfreyre v1.0  original version (internal release)
%%
% This style is designed to work with the report document style of LaTeX2e.
% Usage:
%   \usepackage{UNAMThesis}
%
% "Preferably, the text should appear on only one side of the paper."
% Hence no doubleside option.
%

\ProvidesPackage{UNAMThesis}[2017/02/14 v2.1 (J.A. Freyre-Gonzalez)]

\RequirePackage{graphicx}
\RequirePackage{setspace}

\oddsidemargin 0.25in
\evensidemargin 0in

\topmargin 0in
\headheight 0in			% no header
\headsep \headheight

\textwidth 6.25in
\textheight 8.5in

\footskip .4in

\doublespacing
%\def\baselinestretch{1.5}

% If using the report style, use - instead of . in the figure, table and equation numbers.
\@ifundefined{thechapter}{}{\def\thefigure{\thechapter-\arabic{figure}}}
\@ifundefined{thechapter}{}{\def\thetable{\thechapter-\arabic{table}}}
\@ifundefined{theequation}{}{\def\theequation{\thechapter-\arabic{equation}}}

%% End of formatting parameters %%

%% Define all the pieces that go on the title page and the abstract.

% \title and \author already exist

\def\logounam#1{\gdef\@logounam{#1}}
\def\@logounam{Escudo-UNAM}

\def\logoinstitute#1{\gdef\@logoinstitute{#1}}
\def\@logoinstitute{Escudo-IBT}

\def\Unam{Universidad Nacional Aut\'{o}noma de M\'{e}xico}
\def\UNAM{\uppercase\expandafter{\Unam}}
\def\university#1{\gdef\Unam{#1}\gdef\UNAM{\uppercase\expandafter{\Unam}}}

\def\institute#1{\institutem{#1}}
\def\rcenter#1{\institutem{#1}}
\def\faculty#1{\institutef{#1}}
\def\school#1{\institutef{#1}}
\def\institutem#1{\@instituteartm\gdef\@institute{#1}}
\def\institutef#1{\@instituteartf\gdef\@institute{#1}}
\def\@instituteartm{\gdef\@instituteart{el}}
\def\@instituteartf{\gdef\@instituteart{la}}
\def\@instituteart{la}  % For side effect of excluding an institution

\def\department#1{\gdef\@department{#1}}
\def\@department{}

\def\academictitle{\gdef\@degreetitle{t\'{i}tulo}}
\def\@degreetitle{grado}

\def\supervisor#1{\gdef\@supervisor{#1}}

\def\prevdegrees#1{\gdef\@prevdegrees{#1}}
\def\@prevdegrees{}

% If you are getting two degrees, use \and between the names.
\def\degree#1{\setbox0\hbox{#1}	 %for side effect of setting \@degreeart
  \gdef\@degree{#1}}
% \and is used inside the \degree argument to separate two degrees
\def\and{\xdef\@degreeart{los \@degreetitle s} \par y \par}
\edef\@degreeart{el \@degreetitle}

% Use \date as \thesisdate
\let\@thesisdate=\@date
\def\date#1{\gdef\@date{#1}\gdef\@thesisdate{#1}}

% typically just a month and year
\def\degreemonth#1{\gdef\@degreemonth{#1}}
\def\degreeyear#1{\gdef\@degreeyear{#1}}

\def\city#1{\gdef\@city{#1}}

\supervisor{supervisor undefined}
\degree{degree undefined}
\degreeyear{degreeyear undefined}

%% Define all the environments needed for the frontmatter
%% The make* are command versions of every environment,
%% useful to interface with Scientific Workplace

\newenvironment{dedication}
{\newpage\thispagestyle{empty}\setlength{\topskip}{0in}\begin{singlespace}\@normalsize
\begin{flushright}\vspace*{-1ex}\vspace*{\fill}\vspace*{\fill}\vspace*{\fill}\vspace*{\fill}\slshape}
{\vfill\vfill\vfill\vfill\vfill\end{flushright}\end{singlespace}\newpage}

\newcommand{\makededication}[1]{\begin{dedication}#1\end{dedication}}

\newenvironment{acknowledgements}
{\newpage\chapter*{Agradecimientos}\begin{singlespace}\@normalsize}
{\end{singlespace}\par\newpage}

\newcommand{\makeacknowledgements}[1]{\begin{acknowledgements}#1\end{acknowledgements}}

\newenvironment{foreword}
{\newpage\chapter*{Pr\'{o}logo}\begin{singlespace}\@normalsize}
{\end{singlespace}\par\newpage}

\newcommand{\makeforeword}[1]{\begin{foreword}#1\end{foreword}}

\newenvironment{resumen}
{\newpage
\begin{center}{\large{\bfseries\@title}\\
por\\
\@author\\[\baselineskip]}
\par
\end{center}
\par
\subsection*{Resumen}\small\begin{singlespace}\@normalsize}
{\end{singlespace}\newpage}

\newcommand{\makeresumen}[1]{\begin{resumen}#1\end{resumen}}

% The abstract enviroment doesn't need a makeabstract command because we
% redefine the original abstract environment
\renewenvironment{abstract}
{\newpage
\begin{center}{\large{\bfseries\@title}\\
by\\
\@author\\[\baselineskip]}
\par
\end{center}
\par
\subsection*{Abstract}\small\begin{singlespace}\@normalsize}
{\end{singlespace}\newpage}

\def\maketitle{
\begin{titlepage}
% Left layout - Logos
\begin{minipage}[c][9in][s]{1in}
\centering
\includegraphics[width=1in]{\@logounam}\\[10pt]
\hskip 2pt\vrule width 2pt height 6.7in
\hskip 1mm\vrule width 1pt height 6.7in\\[10pt]
\includegraphics[width=0.8in]{\@logoinstitute}
\end{minipage}\hskip 10pt
% Right layout - Titles
\begin{minipage}[c][\textheight][s]{5.125in}
\centering
% University, institute, department and title
{\Large\scshape\Unam}
\vspace{3mm}\hrule height2pt
\vspace{1mm}\hrule height1pt
\vspace{3mm}
\@ifundefined{@institute}{\relax}{{\large\scshape\@institute}\\[3pt]}
{\scshape\@department}\par
% Title
\vfill\vfill
{\begin{singlespace}\Large\scshape\@title\par\end{singlespace}}
\vfill\vfill
% Degree, author, supervisor and date
\makebox[8cm][s]{\Huge T E S I S}\\[8pt]
QUE PARA OBTENER \uppercase\expandafter{\@degreeart} DE:\\[3pt]
{\scshape\@degree}\\[16pt]
PRESENTA:\\[3pt]
{\scshape\@author}\par
\vfill
{\small DIRECTOR DE TESIS:\\{\scshape\@supervisor}}\par
\vfill
{\scshape\@ifundefined{@city}{\relax}{\@city\hfill}\@ifundefined{@degreemonth}{\@degreeyear}{\@degreemonth, \@degreeyear}}
\end{minipage}
\end{titlepage}
\begin{titlepage}
\centering\large
{\setstretch{1.2}\Large\bfseries\@title\par}
por\par
{\Large\@author}
\par
\@prevdegrees
\par
Tesis presentada para obtener \@degreeart\ de
\par
\@degree
\par
en \@instituteart
\par
\@ifundefined{@institute}{\relax}{{\scshape\@institute}\par}
{\Large\scshape\Unam}
\par
\@ifundefined{@city}{\@ifundefined{@degreemonth}{\@degreeyear}{\@degreemonth, \@degreeyear}}{\@city. \@degreemonth, \@degreeyear}
\end{titlepage}}

% You can use the titlepage environment to do it all yourself if you
% don't want to use \maketitle.  In the titlepage environment, the
% paragraph skip is infinitely stretchable, so if you leave a blank line
% between lines that you want space between, the space will stretch so
% that the title page fills up the entire page.
\renewenvironment{titlepage}
{\newpage\thispagestyle{empty}
\parindent 0pt \parskip 10pt plus 1fil minus 1fil
\begin{singlespace}\@normalsize\vbox to \vsize\bgroup\vbox to 8.9in\bgroup}
% The \kern0pt pushes any depth into the height.  Thanks to Richard Stone.
{\par\kern 0pt\egroup\vss\egroup\end{singlespace}\newpage}

% The quotenat environment implements the quotation style commonly used at
% beginning of a chapter, just like in D. Knuth's Art of Computer Programming
\newenvironment{quotenat}
{\begin{flushright}\begin{minipage}[b]{5.25 in}\raggedleft
\begin{singlespace}\small}
{\end{singlespace}\end{minipage}\end{flushright}}