% University of South Carolina Thesis Style.
% Intended to conform with the Graduate School's Thesis Guidelines
%
% http://www.gradschool.sc.edu/GSbasic/text/PrinterFriendly/Thesis_Guidelines-web_2003.pdf
%
% Copyright (C) 2004-2006 by Jose M. Vidal. All Rights Reserved.
%
% Last updated in Tuesday, 27 November 2007, 02:27PM
%
% The author grants permission for anyone to use this macro package and
% to distribute it unchanged without further restriction.  If you choose
% to modify this package, you must indicate that you have modified it
% prior to your distributing it.  I don't want to get bug reports about
% changes that *you* have made!

\ProvidesPackage{uscthesis}
\typeout{Document Style Option `uscthesis'.}

\long\def\comment#1{}
\comment{
  See sample uscthesis.tex
}
\RequirePackage{setspace}
\RequirePackage{geometry}

% Add hyperlinks. You can comment out this line if its giving you
% problems.  float.sty and algorithm.sty have to be loaded *before*
% hyperref.  Note that later in \hypersetup{} we make links invisible
% so the printout will look nice. The links still work.
\RequirePackage[plainpages=false,pdfpagelabels]{hyperref}

% Change from Contents to Table of Contents
\renewcommand{\contentsname}{Table of Contents}


% Fix TOC issues: These issues are not mentioned in the Guidelines but
% apparently Gloria Williams in the Graduate office wants them, so
% they are here in case you get her as your reviewer. I wish they
% would all just stick to the posted Guidelines.
%
%You will need to add a \clearpage before and after your \tableofcontents
%\RequirePackage{tocloft}
%Add the dots ........ to chapter entries in the TOC
%\renewcommand{\cftchapleader}{\cftdotfill{\cftsecdotsep}}
%Put the chapter titles in non-bold font
%\renewcommand{\cftchapfont}{\rm}
% Add a header with the chapter name. This is so the TOC, LOF, etc,
% will have a proper header.
%\RequirePackage{fancyhdr}
%\fancyhead{} % clear all header fields
%\fancyhead[CE,CO]{\textsf{\leftmark}}
% End of Gloria Williams section

% no bold in toc
% \renewcommand*\l@chapter[2]{%
%   \ifnum \c@tocdepth >\m@ne
%     \addpenalty{-\@highpenalty}%
%     \vskip 1.0em \@plus\p@
%     \setlength\@tempdima{1.5em}%
%     \begingroup
%       \parindent \z@ \rightskip \@pnumwidth
%       \parfillskip -\@pnumwidth
%       \leavevmode \normalfont
%       \advance\leftskip\@tempdima
%       \hskip -\leftskip
%       #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
%       \penalty\@highpenalty
%     \endgroup
%   \fi}

%If you would like your urls \url{http...} to appear in normal (roman)
%font then un-comment the next line
%\urlstyle{rm}

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


% Yuck! Why do they want double spacing! It makes the thesis look
% horrible. Double spacing should only be used for drafts that will be
% marked up with a pen.
\doublespacing 

%Set the margins. Set paper size since many systems now default to A4
%paper. The dvips and pdftex commands ensure that the pagesize is
%passed on to dvips and pdflatex, respectively. If you are using some
%other driver then you might need to change this.
\geometry{letterpaper,left=1.5in,top=1in,right=1in,bottom=1in,paperheight=11in,paperwidth=8.5in,dvips,pdftex}

%chapter appears two inches below top of page
\def\@makechapterhead#1{%
  \vspace*{.9in}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}

%chapter* appears two inches below top of page.
\def\@makeschapterhead#1{%
 \vspace*{.9in}
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 40\p@
  }}

%make the footnote line 2in
\renewcommand{\footnoterule}{\vspace*{-3pt}%
  \hrule width 2in height 0.4pt \vspace*{2.6pt}}

%Leave two spaces above and below rule
%\skip\footins 20pt plus4pt minus4pt
\addtolength{\skip\footins}{1.5em plus 4pt minus4pt}
\setlength{\footnotesep}{2em}

% \author, \title are defined in report; here are the rest of the
% front matter defining macros
\def\dept#1{\gdef\@dept{#1}}
\def\directordept#1{\gdef\@directordept{#1}}
\def\secondreaderdept#1{\gdef\@secondreaderdept{#1}}
\def\thirdreaderdept#1{\gdef\@thirdreaderdept{#1}}
\def\abstract#1{\gdef\@abstract{#1}}
\def\director#1{\gdef\@director{#1}}

\def\authordegree#1{\gdef\@authordegree{#1}}
\def\degree#1{\gdef\@degree{#1}}
\def\college#1{\gdef\@college{#1}}

\def\copyrightyear#1{\gdef\@copyrightyear{#1}} % \author, \title in report
\def\@title{}
\def\@author{}
\def\@keywords{}
\def\@abstract{}
\def\@director{}
\def\@degree{Master of Engineering}
\def\@college{College of Engineering and Computing}
\def\@dept{Computer Science and Engineering}
\def\@directordept{Computer Science and Engineering}
\def\@secondreaderdept{Computer Science and Engineering}
\def\@thirdreaderdept{Computer Science and Engineering}

\def\makethesistitle{%
  \@ifundefined{hypersetup}{}{%
    \hypersetup{%
      bookmarksnumbered,
      pdftitle={\@title},
      pdfauthor={\@author},
      pdfsubject={\@dept},
      pdfkeywords={\@keywords},
      pdfview=FitH,
      pdfborder=0 0 0, %Make all links invisible, so it looks good when printed
    }}
  \pagenumbering{roman}%
  \thispagestyle{empty}%
  \begin{center}
    \textsc{\expandafter{\@title}} \\
    by\\ 
    \vspace{2em} \@author\\ 
    \vspace{2em} 
    \begin{singlespace}
      \@authordegree
    \end{singlespace} 
    --------------------------------------------------------------\\
    Submitted in Partial Fulfillment of the \\
    Requirements For the Degree of \@degree \ in \@dept \\
    \@college \\
    University of South Carolina \\
    \@copyrightyear \\
    \vspace{\stretch{1}}
    \begin{singlespace}
      \noindent
      \begin{minipage}[t]{2.5in}
        \hrule \vspace{3pt}
%        Department of \@directordept \\
        Director of Thesis
      \end{minipage}
      \hfill
      \begin{minipage}[t]{2.5in}
        \hrule \vspace{3pt}
%        Department of \@secondreaderdept \\
        2nd Reader
      \end{minipage}
      
      \noindent 
      \begin{minipage}[t]{2.5in}
        \vspace{1in}
        \hrule \vspace{3pt}
%        Department of \@thirdreaderdept \\
        3rd Reader
      \end{minipage}
      \hfill 
      \begin{minipage}[t]{2.5in}
        \vspace{1in}
        \hrule \vspace{3pt}
        Dean of The Graduate School \\
      \end{minipage}
    \end{singlespace}
 \end{center}\newpage}

\def\makedissertationtitle{%
  \@ifundefined{hypersetup}{}{%
    \hypersetup{%
      bookmarksnumbered, 
      pdftitle={\@title},
      pdfauthor={\@author},
      pdfsubject={\@dept},
      pdfkeywords={\@keywords},
      pdfview=FitH,
      pdfborder=0 0 0, %Make all links invisible, so it looks good when printed
    }}
  \pagenumbering{roman}%
  \thispagestyle{empty}%
  \begin{center}
    \textsc{\expandafter{\@title}} \\
    by\\ 
    \vspace{2em} \@author\\ 
    \vspace{2em} 
    \begin{singlespace}
      \@authordegree
    \end{singlespace} 
    --------------------------------------------------------------\\
    Submitted in Partial Fulfillment of the \\
    Requirements For the Degree of \@degree \ in the \\
    Department of \@dept \\
    \@college \\
    University of South Carolina \\
    \@copyrightyear \\
    \vspace{\stretch{1}}    
    \begin{singlespace}
      \noindent\begin{minipage}[t]{2.5in}
        \vspace{1in}
        \hrule \vspace{3pt}
        Major Professor
      \end{minipage}
      \hfill
      \begin{minipage}[t]{2.5in}
        \vspace{1in}
        \hrule \vspace{3pt}
        Chairman, Examining Committee
      \end{minipage}
      
      \noindent\begin{minipage}[t]{2.5in}
        \vspace{1in}
        \hrule \vspace{3pt}
        Committee Member
      \end{minipage}
      \hfill
      \begin{minipage}[t]{2.5in}
        \vspace{1in}
        \hrule \vspace{3pt}
        Committee Member
      \end{minipage}
      
      \noindent
      \begin{minipage}[t]{2.5in}
        \vspace{1in}
        \hrule\vspace{3pt}
        Committee Member
      \end{minipage}
      \hfill
      \begin{minipage}[t]{2.5in}
        \vspace{1in}
        \hrule \vspace{3pt}
        Dean of The Graduate School \\
      \end{minipage}
    \end{singlespace}
 \end{center}\newpage}


\def\makecopyrightpage{%
  \phantom{.}
  \addcontentsline{toc}{chapter}{Copyright}
  \vspace{6in}

  \begin{center}
    \copyright by \@author, \@copyrightyear \\
    All Rights Reserved.
  \end{center}}

%\renewenvironment{abstract}{%
%  \newpage{}
%  \addcontentsline{toc}{chapter}{Abstract}
%  \@beginparpenalty\@lowpenalty
%  \begin{center}%
%    ABSTRACT \\
%    \@title \\
%    \@author \\
%    \vspace{3em}
%    \@endparpenalty\@M 
%  \end{center}}%

\newcommand{\makeumiabstract}{%
  \newpage{}
  \addcontentsline{toc}{chapter}{Abstract}
  \@beginparpenalty\@lowpenalty
  \begin{center}%
    ABSTRACT \\
    \@title \\
    \@author \\
    \vspace{3em}
    \@endparpenalty\@M
  \end{center}
  \@abstract \\[2em]
  \textbf{Dissertation Director:} \@director}%

\def\prefacesection#1{%
	\chapter*{#1}
	\addcontentsline{toc}{chapter}{#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}{Bibliography}
	\@ldthebibliography{#1}}

\newcommand{\makelistoffigures}{
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\newpage
}

\newcommand{\makelistoftables}{
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
\newpage
}

\newcommand{\makeabstract}{
  \prefacesection{Abstract}
  \@abstract}

%Make it easier to place figures
\renewcommand{\textfraction}{0.15}
\renewcommand{\topfraction}{0.85}
\renewcommand{\bottomfraction}{0.65}
\renewcommand{\floatpagefraction}{0.60}


\pagestyle{plain}
