% This document is designed to conform to the style and layout guidelines stipulated in the document "School of Engineering and Materials Science"
% 
% --- Angadh Nanjangud
% First we define the point size of the text as a variable because 
% we want some other variables to depend upon it.
%
\newcommand{\pointsize}{12pt}
\documentclass[oneside, \pointsize, reqno]{amsbook}
\usepackage{titlesec}
% Set the margins with the geometry package.  For the top margin,
% we have a half-inch to the header containing the page number.
% The remaining half-inch to the text will be introduced by our
% definitions of \headwidth and \headsep.
%
\usepackage[
   %includehead,
   includefoot,
     left = 1in, 
      top = 1in, 
    right = 1in,
   bottom = 1in
]{geometry}
\usepackage{fancyhdr}
\usepackage{setspace}
\usepackage{calc}
% Set \headheight and \headsep so that \headheight + \headsep =
% 0.5in.  Thus, the top of the text will be one inch from the top
% of the page.
%
\setlength{\headheight}{\pointsize + 2pt}
\setlength{\headsep}{0.5in - \headheight} 
% Protrude page number half-inch into right margin so that it is a
% half-inch from the page's edge.
%
\fancyheadoffset[R]{0.5in} 
% The Preliminary Pages are to be numbered with small Roman
% Numerals that are centered at the bottom of the page.
%
\fancypagestyle{prelim}{%    
   \renewcommand{\headrulewidth}{0pt} 
   \fancyhf{}           
   \pagenumbering{roman}    
   \cfoot{-\thepage-}       
}
% Pages of the main text are to be numbered with arabic numerals
% that are in the upper right corner of the page.
%
% There are a couple additions to the header here that are not 
% stipulated in the dissertation guidelines.
%
%   (1) A headrule is added by setting the command \headrulewidth 
%   to be 0.4pt.
%
%   (2) The command \fancyhead[L]{\rightmark} causes the current
%   section to be indicated in the upper left of the page.  See 
%   documentation for the fancyhdr to control this display.
%
\fancypagestyle{maintext}{%
   %\renewcommand{\headrulewidth}{0.4pt}
   \pagenumbering{arabic}
   %\fancyhf{}
   %\fancyhead[L]{\rightmark}
   %\chead{\thepage}
 
% Code I, Angadh, added to the file to sort the opening pages of each chapter   
   \newcommand{\chapfnt}{\fontsize{21}{21}}
   \newcommand{\secfnt}{\fontsize{17}{19}}
   \newcommand{\ssecfnt}{\fontsize{14}{17}}
   \newcommand{\sssecfnt}{\fontsize{10}{14}}
   \titleformat{\chapter}[display]
   {\normalfont\chapfnt\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\chapfnt}
   \titleformat{\section}
   {\normalfont\secfnt\bfseries}{\thesection}{1em}{}
   \titleformat{\subsection}
   {\normalfont\ssecfnt\bfseries}{\thesubsection}{1em}{}
   \titleformat{\subsubsection}
   {\normalfont\sssecfnt\bfseries}{\thesubsubsection}{1em}{}
   \titlespacing*{\chapter} {0pt}{50pt}{40pt}
   \titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
   \titlespacing*{\subsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
   \titlespacing*{\subsubsection} {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
}
% Number figures, tables, and equations so that the chapter is
% included in the number.  E.g., use Figure 2.3 for the third
% figure in Chapter 2.
%
\numberwithin{figure}{chapter} 
\numberwithin{table}{chapter}
\numberwithin{equation}{chapter}
\numberwithin{section}{chapter}
\usepackage{graphicx, float, listings, hyperref}
\usepackage{overcite}
\usepackage{amsmath, amssymb, bm}
\begin{document}
\makeatletter    
   \def\l@section{\@tocline{1}{0,2pt}{2pc}{8mm}{\ \ }} 
%% used 0,1 to add vertical space b/w "subsec" and "subsubsec"
%% Used \ (and a space) to add offset for the subsections. Here I added 2 spaces
%% Used 2pc for the nr. of subsubsections in the subsections
%% Used 8mm to add "horizontal space" b/w the "number" and "subsection"
   \frontmatter
   \pagenumbering{gobble}
   \input{TitlePage.tex}
   \newpage
   \input{Declaration.tex}
   
   \pagestyle{prelim}
   % Redefine plain page style so that the first pages of chapters
   % have desired page style.
   %
   \fancypagestyle{plain}{%
      \fancyhf{}
      \cfoot{-\thepage-}
   }%
   % Begin Double Spacing
   \doublespacing
   \newpage
   \input{Abstract.tex}
   \tableofcontents
   \newpage
   
   \mainmatter
   
   \pagestyle{maintext}
   
   % Redefine plain page style so that the first pages of 
   % chapters have desired page style.
   %
   \fancypagestyle{plain}{%
      \renewcommand{\headrulewidth}{0pt}
      %\fancyhf{}
      %\rhead{\thepage}
   }%
   
   \chapter{Rationale}
   \label{ch:IntroductionLabel}
   \input{Chapters/1_Rationale/Rationale.tex}
   \chapter{Objectives}
   \label{ch:2ndChapter}
   \input{Chapters/2_Aims/Aims_and_Objectives.tex}
 
   \chapter{Conclusion}
   \label{ch:4thChapter}
   \input{Chapters/Conclusions.tex}
   
   \chapter{Test Chapter}
   \label{ch: testlabel}
   \input{Chapters/testchapter.tex}
 
   \appendix
%   \chapter[%
%      Short Title of Appendix A
%   ]{%
%      Long Title of Appendix A
%   }%
%   \label{ch:AppendixALabel}
%   \input{AppendixAFileName.tex}
%       
%   \backmatter
   
   \bibliographystyle{IEEEtran}
   \bibliography{Bibliography}
 \end{document}