% Tesi D.S.I. - modello preso da
% Stanford University PhD thesis style -- modifications to the report style
%

% \makeatletter            --not necessary for LaTeX style files
% We need 1" margins except on the binding edge, where it is 1 1/2"
\oddsidemargin 0in \evensidemargin 0in
\marginparwidth 40pt \marginparsep 10pt
\topmargin 0pt \headsep .5in
\textheight 8.1in \textwidth 6in

% Disallow page breaks at hyphens (this will give some underfull vbox's,
% so an alternative is to use \brokenpenalty=100 and manually search
% for and fix such page breaks)
\brokenpenalty=10000

% Use 1.3 times the normal baseline-to-baseline skip
\renewcommand{\baselinestretch}{1.0}		% ERA 1.3

% Figures and tables are to be numbered sequentially throughout the
% thesis, rather than within chapters; for style consistency, do
% equations the same.  The following \def of \cl@chapter is a kludge:
% really there should be a \removefromreset, to stop figure numbers, etc.,
% from being reset at chapter beginnings
\def\cl@chapter{\@elt{section}\@elt{footnote}}
\def\thefigure{\@arabic\c@figure}
\def\thetable{\@arabic\c@table}
\def\theequation{\arabic{equation}}

% 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\dept#1{\gdef\@dept{#1}}
\def\relatore#1{\gdef\@relatore{#1}}
\def\correlatore#1{\gdef\@correlatore{#1}}
\def\anno#1{\gdef\@anno{#1}}
\def\matricola#1{\gdef\@matricola{#1}}

\def\principaladviser#1{\gdef\@principaladviser{#1}}
\def\advis@r{Adviser} % default spelling
\def\principaladvisor#1{\gdef\@principaladviser{#1}\gdef\advis@r{Advisor}}
\def\firstreader#1{\gdef\@firstreader{#1}}
\def\secondreader#1{\gdef\@secondreader{#1}}
\def\submitdate#1{\gdef\@submitdate{#1}}
\def\copyrightyear#1{\gdef\@copyrightyear{#1}} % \author, \title in report
\def\@title{}\def\@author{}\def\@dept{computer science}
\def\@principaladviser{}\def\@firstreader{}\def\@secondreader{}
\def\@relatore{}\def\@correlatore{}\def\@anno{}\def\@matricola{}

\def\@submitdate{\ifcase\the\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space \number\the\year}
% Stanford says that December theses should have the next year as the
% copyright year
\ifnum\month=12
    \@tempcnta=\year \advance\@tempcnta by 1
    \edef\@copyrightyear{\number\the\@tempcnta}
\else
    \def\@copyrightyear{\number\the\year}
\fi
\newif\ifcopyright \newif\iffigurespage \newif\iftablespage
\copyrightfalse
\figurespagefalse
\tablespagefalse

\def\titlep{%
	\thispagestyle{empty}%
	%\null\vskip1in%
        \begin{center}
            %{\sc Universit\`a degli Studi di Milano} \\
            %Facolt\`a di Scienze e Tecnologie \\
            \includegraphics[width=\textwidth]{Logo.jpg} \\
			{\em \@dept}
        \end{center}
        \vskip1in
	\begin{center}
% 		{\Large\uppercase\expandafter{\@title}}
        \begin{doublespace}
		{\Huge\uppercase\expandafter{\@title}}
        \end{doublespace}
	\end{center}
	\vfill
        \begin{description}
        \item[Relatore:] \@relatore
        %\item[Correlatore:] \@correlatore
        \end{description}
	\vskip0.5in
        \null\hfill
        \parbox{1.6in}{
          Tesi di: \\
          \expandafter{\@author}
	  \\ Matricola: \@matricola
          }
        \vfill
	\begin{center}
         \large   Anno Accademico \@anno
        \end{center}
        \newpage}

\def\copyrightpage{%
	\null\vfill
	\begin{center}
		\Large\copyright\ Copyright \@copyrightyear\\
		by\\
		\@author\\
	\end{center}
	\vfill\newpage}

\long\def\signature#1{%
\begin{center}
\begin{minipage}{4in}
\parindent=0pt
I certify that I have read this thesis and that in my opinion
it is fully adequate, in scope and in quality, as a dissertation for the degree
of Doctor of Philosophy.
\par
\vspace{.5in}
\hbox to 4in{\hfil\shortstack{\vrule width 3in height 0.4pt\\#1}}
\end{minipage}
\end{center}}

\def\signaturepage{%
	\signature{\@principaladviser\\(Principal \advis@r)}
	\vfill
	\signature\@firstreader
	\vfill
	\signature\@secondreader
	\vfill
	\begin{center}
	\begin{minipage}{4in}
	Approved for the University Committee on Graduate Studies:\par
	\vspace{.5in}
	\hbox to 4in{\hfil\shortstack{\vrule width 3in height 0.4pt\\
			Dean of Graduate Studies \& Research}}
	\end{minipage}
	\end{center}}

\def\beforepreface{
	\pagenumbering{roman}
	\pagestyle{plain}
	\titlep}
%	\ifcopyright\copyrightpage\fi
%	\signaturepage}

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

\def\prefacesectionnochapter#1{%
	\chapter*{}
	\addcontentsline{toc}{chapter}{#1}}

% The \addvspace business below is to avoid the extra space that gets put
% in the tables of figures and tables between chapters (it makes no sense
% now that the numbering is continuous)
\def\afterpreface{\newpage
	\tableofcontents
	\newpage
	\iftablespage
		{\addvspace{10pt}
		\let\saveaddvspace=\addvspace
		\def\addvspace##1{}
		\listoftables
		\let\addvspace=\saveaddvspace}
		\newpage
	\fi
	\iffigurespage
		{\addvspace{10pt}
		\let\saveaddvspace=\addvspace
		\def\addvspace##1{}
		\listoffigures
		\let\addvspace=\saveaddvspace}
		\newpage
	\fi
	\pagenumbering{arabic}
	\pagestyle{headings}}

\pagestyle{headings}
% \makeatother           --not necessary for LaTeX style files

