% Estilo para Teses do Instituto de Computacao da UNICAMP
% Traduzido e Adaptado a partir de suthesis.sty
% Welson R. Jacometti - 03.06.1992
%
% Modificacoes e correcoes introduzidas por:
% Pedro J. de Rezende - 14.05.1993
% Pedro J. de Rezende - 23.10.1996
%
% Adaptacao para capa com janela e inclusao de opcao para doutorado:
% Pedro J. de Rezende - 19.11.1996
%
% Revisao de formato para conformidade com novas recomendacoes da DAC:
% Pedro J. de Rezende - 25.04.1997
%
% Revisao de formato para conformidade com composicao de banca de doutorado:
% Pedro J. de Rezende - 13.10.1997
%
% Revisao para constar co-orientador na pagina correta e nao na banca:
% Pedro J. de Rezende - 3.11.1997
%
% Revisao na ordem das paginas e para deixar paginas em branco na contagem
% para substituicao pela ficha catalografica e pela folha com a assinatura da banca:
% Rodolfo Jardim de Azevedo - 18.06.2002
%
% Revisao para numerar *todas* as paginas como requer a Grafica da UNICAMP
% Pedro J. de Rezende - 5.07.2002
%
% Revisao para oferecer a opcao de nao mostrar as paginas de ficha catalografica,
% assinatura da banca e texto mencionando a versao final
% Jeronimo Pellegrini - 24.05.2006
%
% Revisao de formato para conformidade com as novas normas da UNICAMP, conforme
% Informa\c{c}{\~a}o CCPG/002/06
% Jeronimo Pellegrini e Pedro J. de Rezende - 01.12.2006
%
% Revisao de formato para adicao do setimo elemento na banca examinadora
% Andre C. Drummond - 17.08.2010

\typeout{Estilo: TESE IC - UNICAMP <01 de Dezembro de 2006>.}

\long\def\comment#1{}
%
% BEGIN COMMENT
\comment{
  Example of usage:
    \documentclass[12pt,twoside]{report} % Use esta linha para tese com mais de 100 p{\'a}ginas
%    \documentclass[12pt]{report} % Use esta linha para tese com at{\'e} 100 p{\'a}ginas

    \usepackage{ic-tese}
    \usepackage[latin1]{inputenc}
    \usepackage[brazil]{babel}

    \begin{document}
    \title{Como Escrever um T{\'\i}tulo em Duas Linhas\\
           para sua Disserta\c{c}{\~a}o ou Tese}
    \author{Donna S. A. St. Udent}
    \degreesought{Doutorado} % Mestrado
    \titlesought{Doutor}     % Doutora/Mestre
    \principaladvisor{Adam Astor}
    \advisortitle{Orientador} % Orientadora
    \coadvisor{Byron Meter (Co-orientador)} % Pode ser omitido.
    \firstreader{Charlie Brown\\ Departamento de Apicultura Subterr{\^a}nea
                 Computacional}
    \secondreader{Donald Duck}
    \thirdreader{Era Stoteles}
    \fourthreader{Fairy Tail}
    \grants{{\rm Suporte financeiro de: Bolsa do CNPq (processo XYZ) 1990--1992, Projeto Finep (processo UVW)
    1992--1993 e Universidade Federal de Santa Rita do Passa Tr{\^e}s 1994--1996.}} % Pode ser omitido.
%
    \submitdate{Abril de 1997} % Pode ser omitido.
    \date{12 de junho de 1997} % Pode ser omitido.
%
%   Se pretende utilizar \copyrighttrue, consulte antes seu orientador ou a CPG!!!
%   Este ponto envolve quest{\~o}es legais complexas e de graves conseq{\"u}{\^e}ncias.
    \copyrightfalse % Caso nao queira que apareca a pagina de Copyright.
%    \copyrighttrue % Caso queira que apareca a pagina de Copyright.
%
    \finalversiontrue % Caso seja a versao final.
%    \finalversionfalse % Caso nao seja a versao final ainda.
%
    \tablespagetrue % Caso queira que apareca a Lista de Tabelas.
%    \tablespagefalse % Caso nao queira que apareca a Lista de Tabelas.
%
    \figurespagetrue % Caso queira que apareca o Lista de Figuras.
%    \figurespagefalse % Caso nao queira que apareca o Lista de Figuras.
%
    \beforepreface
    \prefacesection{Resumo}
        O resumo deve conter no m{\'a}ximo 500 palavras...
    \prefacesection{Abstract}
        The abstract must contain at most 500 words...
    \prefacesection{Agradecimentos}
        Eu gostaria de agradecer a...
    \afterpreface % Gera: Conteudo, Lista de Tabelas, Lista de Figuras.
%
    \chapter{Introdu\c{c}{\~a}o}
        Foi conjecturado em 1953 que uma M{\'a}quina de Turing...
     ...
     ...
     ...
    \vspace*{5cm}
    \begin{figure}[h]
      \centerline{
        \fbox{Figura que mil palavras valem menos que uma imagem.}}
      \caption{A Lista de Figuras {\'e} opcional.}
    \end{figure}

    \begin{table}
      \centerline{
      \begin{tabular}{|c|c|} \hline
        {\bf Algoritmo} & {\bf Complexidade de Tempo}\\\hline
        Algo 1 & R{\'a}pido\\\hline
        Algo 2 & Veloz \\\hline
      \end{tabular}}
      \caption{A Lista de Tabelas {\'e} opcional.}
    \end{table}


    \chapter{Conclus{\~o}es}
        Atrav{\'e}s dos contra-exemplos apresentados ...


    \appendix
    \chapter{Uma Longa Demonstra\c{c}{\~a}o}
        Utilizando as t{\'e}cnicas vistas nos cap{\'\i}tulos anteriores,
        vamos demonstrar neste ap{\^e}ndice que ${\bf P = NP}$. ...


    \bibliographystyle{plain}
    \bibliography{mybib}
    \end{document}

Documentation:
    This package file modifies the standard  report class to  follow the
    Regulations  passed  by  the  ``Comissao de Pos-Graduacao''  of  the
    Instituto   de Computacao at  UNICAMP,   for Preparing Doctoral  and
    Masters' Thesis".  It sets   the margins and interline   spacing and
    disallows page breaks at hyphens, among other style choices.

    The \beforepreface command creates the title pages, a copyright page
    (optionally); then, the user should insert preface section(s), using
    the  \prefacesection{section   title}  command.   The  \afterpreface
    command  then produces the tables  of  contents, tables and figures,
    and sets things up to start the main body (on arabic page 1).

    These commands control what will be in the "front matter" part:

        \title{thesis title}
        \author{author's name}
        \degreesought{which degree}
        \titleesought{the title that the degree leads to}
        \dept{author's department}
        \principaladvisor{the principal advisor's name}
        \advisortitle{the advisor's title}
        \firstreader{the first reader's name}
        \coadvisor{the coadvisor's name, if any}
        \secondreader{the second reader's name}
        \thirdreader{the third reader's name}
        \fourthreader{the fourth reader's name}
        \fifthreader{the fifth reader's name}
        \sixthreader{the sixth reader's name}
        \seventhreader{the seventh reader's name}
        \grants{Supported in part by AGENCY, under grants X, Y, Z.}
        \submitdate{month year in which submitted to CPG}
                - date LaTeX'd if omitted
        \date{date of defense}
                - date LaTeX'd if ommited
        \copyrightyear{year degree conferred}
                - year LaTeX'd if omitted
        \copyrighttrue or \copyrightfalse
                - produce or don't produce a copyright page
                  (false by default)
        \figurespagetrue or \figurespagefalse
                - produce or don't produce a List of Figures page
                  (true by default)
        \tablespagetrue or \tablespagefalse
                - produce or don't produce a List of Tables page
                  (true by default)

This style uses interline spacing that is 1.1 times normal, except
in the figure and table environments where normal spacing is used.
That can be changed by doing:
    \renewcommand{\baselinestretch}{1.6}\small\normalsize
(or whatever you want instead of 1.6).
}
%
% END COMMENT

% First thing we do is make sure that report has been loaded.  A
% common error is to try to use ic-tese as a documentstyle or class.
\@ifundefined{chapter}{\@latexerr{The `ic-tese' option should be
used with the `report' document style}{You should probably read
the ic-tese documentation.}}{}

% Theses with more than 100 pages must be double-sided, so we have
% to set \evensidemargin, too.
\oddsidemargin 1cm
\evensidemargin -0.4cm
\marginparwidth 40pt \marginparsep 10pt
\topmargin -1.25cm \headsep .5in
\textheight 21.5cm \textwidth 16cm

% Use 1.1 times the normal baseline-to-baseline skip
\renewcommand{\baselinestretch}{1.1}

% Redefine the macro used for floats (including figures and tables)
% so that single spacing is used.
% (Note \def\figure{\@float{figure}set single spacing} doesn't work
% because figure has an optional argument)
\def\@xfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else
   \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner
      \@parmoderr\@floatpenalty\z@
    \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname
       \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n
       \@tfor \@tempa :=#2\do
                        {\if\@tempa h\advance\@tempcnta \@ne\fi
                         \if\@tempa t\advance\@tempcnta \tw@\fi
                         \if\@tempa b\advance\@tempcnta 4\relax\fi
                         \if\@tempa p\advance\@tempcnta 8\relax\fi
         }\global\count\@currbox\@tempcnta}\@fltovf\fi
    \global\setbox\@currbox\vbox\bgroup
    \def\baselinestretch{1}\@normalsize
    \boxmaxdepth\z@
    \hsize\columnwidth \@parboxrestore}

% Redefine the macro used for footnotes to use single spacing
\long\def\@footnotetext#1{\insert\footins{\def\baselinestretch{1}\footnotesize
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\footnotesep
    \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
    \hsize\columnwidth \@parboxrestore
   \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext
    {\rule{\z@}{\footnotesep}\ignorespaces
      #1\strut}}}

% \author, \title are defined in report; here are the rest of the
% front matter defining macros
\def\grants#1{\gdef\@grants{#1}}
\def\dept#1{\gdef\@dept{#1}}
\def\principaladvisor#1{\gdef\@principaladvisor{#1}}
\def\principaladviser#1{\gdef\@principaladvisor{#1}}
\def\advisortitle#1{\gdef\@advisor{#1}}
\def\advisertitle#1{\gdef\@advisor{#1}}
\def\firstreader#1{\gdef\@firstreader{#1}}
\def\coadvisor#1{\gdef\@coadvisor{#1}}
\def\coadviser#1{\gdef\@coadvisor{#1}}
\def\secondreader#1{\gdef\@secondreader{#1}}
\def\thirdreader#1{\gdef\@thirdreader{#1}}
\def\fourthreader#1{\gdef\@fourthreader{#1}}
\def\fifthreader#1{\gdef\@fifthreader{#1}}
\def\sixthreader#1{\gdef\@sixthreader{#1}}
\def\seventhreader#1{\gdef\@seventhreader{#1}}

%
% Force the reference to the document to be:
% - ``Tese'' de Doutorado
% - ``Dissertacao'' de Mestrado
\def\@Mestrado{Mestrado}
\def\degreesought#1{\gdef\@degreesought{#1}\ifx\@Mestrado\@degreesought
\gdef\@tese{Disserta\c{c}{\~a}o}\else\gdef\@tese{Tese}\fi}%
\degreesought{Mestrado} % default
%
\def\titlesought#1{\gdef\@titlesought{#1}}%
\titlesought{Mestre} % default
\def\submitdate#1{\gdef\@submitdate{#1}}
\def\copyrightyear#1{\gdef\@copyrightyear{#1}}
\def\@title{}\def\@author{}\let\@dept\relax\let\@grants\relax
\def\@faculty{Instituto de Computa\c{c}{\~a}o}
\def\@principaladvisor{}\def\@advisor{}\def\@firstreader{}\let\@coadvisor\relax\def\@secondreader{}\def\@thirdreader{}\let\@fourthreader\relax\let\@fifthreader\relax\let\@sixthreader\relax\let\@seventhreader\relax
\def\today{\number\the\day{}\space de\space \ifcase\the\month\or
  janeiro\or fevereiro\or mar\c{c}o\or abril\or maio\or junho\or
  julho\or agosto\or setembro\or outubro\or novembro\or dezembro\fi
  \space de \number\the\year}
\def\@submitdate{\ifcase\the\month\or
  Janeiro\or Fevereiro\or Mar\c{c}o\or Abril\or Maio\or Junho\or
  Julho\or Agosto\or Setembro\or Outubro\or Novembro\or Dezembro\fi
  \space de \number\the\year}
\def\@copyrightyear{\number\the\year}

\newif\ifcopyright \newif\iffigurespage \newif\iftablespage \newif\iffinalversion
\copyrightfalse \figurespagetrue \tablespagetrue

\def\titlep{%
%        \thispagestyle{empty}%
        \begin{center}
                \hrule\vspace{1pt}\hrule\vspace{1ex}
                \ifx\@dept\relax\else\@dept\ \\\fi
                \@faculty\\
                Universidade Estadual de Campinas\\[1ex]
                \hrule\vspace{1pt}\hrule
        \end{center}
        \vfill
        \begin{center}
                \Large\bf\expandafter{\@title}
        \end{center}
        \vspace{.5cm}
        \begin{center}
        {\large\bf\@author\ifx\@grants\relax\else\footnote{\@grants}\fi}\\[2ex]
            {\small\@submitdate}
        \end{center}
        \vfill
        {\bf Banca Examinadora:}
        \begin{itemize}
        \item \@principaladvisor\ (\@advisor)
%       \ifx\@coadvisor\relax\else\item \@coadvisor\fi
        \item \@firstreader
        \item \@secondreader
        \item \@thirdreader
        \ifx\@fourthreader\relax\else\item \@fourthreader\fi
        \ifx\@fifthreader\relax\else\item \@fifthreader\fi
        \ifx\@sixthreader\relax\else\item \@sixthreader\fi
        \ifx\@seventhreader\relax\else\item \@seventhreader\fi
        \end{itemize}
        \vfill
        \null\newpage}

\def\copyrightpage{%
        \null\vfill
        \begin{center}
                \copyright\ \@author, \@copyrightyear. \\
                ~~~Todos os direitos reservados.
        \end{center}
        \vskip.5in\newpage}

\def\notfinalversiontext{Este exemplar corresponde {\`a} reda\c{c}{\~a}o
da \@tese\ apresentada para a Banca Examinadora antes da defesa da \@tese.}

\def\finalversiontext{Este exemplar corresponde {\`a} reda\c{c}{\~a}o
final da \@tese\ devidamente corrigida e defendida por \@author\ e
aprovada pela Banca Examinadora.}

\def\finalversiontitle{
%  \thispagestyle{empty}%
  \begin{center}
    \Large\bf\expandafter{\@title}
  \end{center}
  \vskip 3cm
  \hfill{\parbox[t]{8.35cm}{\iffinalversion\finalversiontext\newpage\else\notfinalversiontext\fi}} \par
  \vskip 3cm
  \hfill{\parbox[t]{8.35cm}{\centerline{Campinas, \@date.}}}\par
  \vskip 2.2cm
  \hfill{\parbox[t]{8.35cm}{\begin{center}{\@principaladvisor\ (\@advisor)\ifx\@coadvisor\relax\else\\[2.5cm]\@coadvisor\fi}\end{center}}}\par
  \vskip 2cm
  \hfill{\parbox[t]{8.35cm}{\@tese\ apresentada ao Instituto de
  Com\-pu\-ta\-\c{c}{\~a}o, {\sc unicamp}, como requisito parcial para a
  obten\c{c}{\~a}o do t{\'\i}tulo de \@titlesought\ em Ci{\^e}ncia da Computa\c{c}{\~a}o.}} \par
}

\def\fichacatalografica{
  \begin{center}
%    \thispagestyle{empty}
    \vspace{10cm}
    {\Large\bf\expandafter{Substitua pela ficha catalogr{\'a}fica}\\
    {\rm (Esta p{\'a}gina deve ser o verso da p{\'a}gina anterior mesmo no\\
    caso em que n{\~a}o se imprime frente e verso, i.{\'e}., at{\'e} 100 p{\'a}ginas.)}}
%    \addtocounter{page}{-1}
  \end{center}
}

\def\assinaturabanca{
  \begin{center}
    \vspace{10cm}
    \Large\bf\expandafter{Substitua pela folha com as assinaturas da banca}
  \end{center}
}

\def\windowtitle{\bgroup\newpage\c@page\z@
%  \thispagestyle{empty}
  \parindent 0pt
  \small\rm             % \xipt
  \null\vskip 12.9cm
\begin{center}
\hskip-1.75cm
\framebox[10.5cm]{
  \vbox to 5.75cm{\vfill
\hsize=3.5575in\textwidth=\hsize\linewidth=\hsize
\begin{center}
\vbox{
   \begin{center}
    \def\thanks##1{}
    \def\@footnotemark{\relax}
    {\bf \@title \par}
    \vskip 1.5ex
    {\it
       \begin{tabular}[t]{c}
       \def\and{
       %%\begin{tabular}
       \end{tabular}\hskip 1em plus .17fil\begin{tabular}[t]{c}
       %% \end{tabular}
       }
       \@author
       \end{tabular}\par
    }
    \vskip 1.5ex
    {\bf \@tese\ de \@degreesought}
   \end{center}
}\end{center}
  \vfill}
}\end{center}
\egroup}

% PATCH: Here, I fix \cleardoublepage so that the skipped pages are really blank! PJR
    \let\origdoublepage\cleardoublepage
    \newcommand{\clearemptydoublepage}{%
      \clearpage
      {\pagestyle{empty}\origdoublepage}%
    }
    \let\cleardoublepage\clearemptydoublepage

\def\beforepreface{
        \pagenumbering{roman}
        \pagestyle{plain}
%        \windowtitle
    \finalversiontitle
    \newpage
    \iffinalversion\fichacatalografica\clearemptydoublepage %\newpage
    \else\null\fi
    \iffinalversion\assinaturabanca\clearemptydoublepage %\newpage
    \else\null\fi
    \titlep
    \ifcopyright\clearemptydoublepage\copyrightpage\fi\clearemptydoublepage}

\def\prefacesection#1{%
    \clearemptydoublepage
    \chapter*{#1}
    \addcontentsline{toc}{chapter}{#1}
    }

\def\afterpreface{\clearemptydoublepage
    \tableofcontents
    \clearemptydoublepage
    \iftablespage
        \listoftables
        \clearemptydoublepage
    \fi
    \iffigurespage
        \listoffigures
        \clearemptydoublepage
    \fi
    \if@twoside\ifodd\c@page\else\null\thispagestyle{empty}\clearpage\fi\fi
    \@openrighttrue
    \pagenumbering{arabic}
    \pagestyle{headings}
    }

\def\ps@headings{\let\@mkboth\markboth
\def\@oddfoot{}\def\@evenfoot{}%
\def\@evenhead{\rm \thepage\hfil \sl \leftmark}%
\def\@oddhead{\hbox{}\sl \rightmark \hfil \rm\thepage}%
\def\chaptermark##1{\markboth {{\ifnum \c@secnumdepth >\m@ne
\@chapapp\ \thechapter. \ \fi ##1}}{}}%
\def\sectionmark##1{\markright {{\ifnum \c@secnumdepth >\z@
\thesection. \ \fi ##1}}}}

% Redefine \thebibliography to go to a new page and put an entry in the
% table of contents
\let\@ldthebibliography\thebibliography
\renewcommand{\thebibliography}[1]{\newpage
        \addcontentsline{toc}{chapter}{Bibliografia}
        \@ldthebibliography{#1}}

% Start out normal
\pagestyle{headings}

