A thesis in LaTeX

I wrote my PhD thesis in LaTeX, there are many advantages to this including perfect formatting, PDF links, and rock solid stability. Pretty much everyone I know has had major issues writing a thesis in Microsoft Word. The template below should be of some help in creating a nicely formatted thesis. You can download the template file below as main.tex and my introduction chapter introduction.tex and the title page title.tex as an example.

The percent sign (%) is a commenting mark, so everything after "%" in each line is ignored by LaTeX, this is a good way to quickly try different options by commenting out lines of code.

Thesis template

% Thesis template by Bevan Weir %%%%%%%%%%%%%%%%%%%%%%%% start %%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,12pt,twoside] {book} % title page, draft - warning draft turns off hyperref 
%\usepackage{utopia} % The "Utopia" font
%\usepackage{charter} % The "charter" font
\usepackage{textcomp} % Allows the use of extra characters
\usepackage{verbatim, amsmath, amsfonts, amssymb, amsthm} % For code environment and math support
\usepackage{makeidx} %robustindex % Indexing
\usepackage[british]{babel} % For British English hyphenation patterns
\usepackage[final]{graphicx} %draft % To include graphics
\usepackage{booktabs,longtable,rotating} % long tables are split to other lines %for rotating tables
\usepackage{array,warpcol} % Alignment on decimal point entries in tables
\usepackage{multirow} % muli rows (merge) in tables
\usepackage{fixme} %
\usepackage[section,verbose]{placeins} % Keeps floats `in their place', preventing them from floating past a "\FloatBarrier" command into another section
\usepackage[width=11cm,font=footnotesize,labelfont=bf, % format=default,justification=centerlast]{caption} 
% Captions
\usepackage{fancyhdr} % Change caption style; changes headers and page styles etc.
\usepackage{sectsty} % Changing section headings
\usepackage{setspace} % For changing line spacing
%\usepackage{gensymb,units}
\usepackage{url} % Formatting for URL's i.e. http://www.rhizobia.co.nz
\usepackage{natbib} % The best package for bibliographies
\usepackage{appendix} % Makes appendices
\usepackage{cclicenses} % Creative commons
\usepackage{afterpage} % Makes appendices
\usepackage{microtype} % makes pdf look better
%\usepackage{lineno} % Line numbering [pagewise]
\usepackage[nottoc]{tocbibind} % Table of contents
%\usepackage{texshade} % Fancy DNA sequences
\usepackage[hyperindex=true,pdftitle={Systematics,
Specificity, and Ecology of New Zealand
Rhizobia},pdfauthor={Bevan Weir},colorlinks=false,
pagebackref=false,citecolor=blue,plainpages=false,
pdfpagelabels]{hyperref} % colourlinks=false for printing 
% ---------------------------------------------------------------
% OPTIONS %\citeindextrue % Fuzz
\hfuzz2pt % Don't bother to report over-full boxes if over-edge is < 2pt   
%----------------------------------------------
%Alter page dimensions %\setlength{\textwidth}{16cm}
%\setlength{\oddsidemargin}{0.46cm}
%\setlength{\evensidemargin}{0.46cm}
%\setlength{\textheight}{22.3cm}
%\setlength{\topmargin}{-0.54cm}
%\setlength{\headsep}{1.5cm}
%\setlength{\footnotesep}{0.6cm} 
%-------------------------------------------
\pagestyle{fancy}
% with this we ensure that the chapter and section
% headings are in lowercase.
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{} % delete current setting for header and footer
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt} % make space for the rule
\fancypagestyle{plain}{%
\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}
%--------------------------------------------------------------------- 
% Document settings \setcounter{secnumdepth}{3} %subsubsections are numbered
\setcounter{tocdepth}{3} %subsubsections are added to the TOC 
\renewcommand{\tocbibname}{References} 
\allsectionsfont{\raggedright} % stops headings being split 
% \linenumbers % turns line numbering on %parts to include
%uncomment as necessary
\includeonly{
Title, Abstract, Acknowledgements, Glossary, Introduction, Methods,
Identification, Nitrogen, NodA, Discussion, Appendix}
%\makeindex
\hyphenation{leg-ume Zea-land leg-umes Car-mi-chae-lia
Car-mi-chae-li-eae leg-u-min-o-sa-rum li-po-poly-sac-ch-rides
exo-poly-sac-ch-rides rep-li-cons Brady-rhi-zo-bi-um
Meso-rhi-zo-bi-um nod-u-la-ted So-pho-ra car-mi-chae-li-ana
beta-proteo-bacteria alpha-proteo-bacteria} 
% \parskip 7.2pt %sets spacing between paragraphs
  \begin{document} 
%-------------------- end of preamble ---------------------
%----------------------------------------------------------
\frontmatter %the following is numbered with roman numerals 
\include{Title} 
\singlespacing
%\onehalfspacing
\doublespacing % --> better for proof reading 
\include{Abstract}
\include{Acknowledgements} 
\singlespacing 
\tableofcontents
\listoffigures 
\listoftables 
\singlespacing
%\onehalfspacing
\doublespacing % --> better for proof reading 
\include{Glossary} 
%--------------------------------------------------------------------------------------------------
\mainmatter %start numbering with Arabic numerals 
\include{Introduction}
\include{Methods}
\include{Identification}
\include{NodA}
\include{Nitrogen}
\include{Discussion}
%--------------------------------------------------------------------------------------------------
%\backmatter %still arabic numerals, but sections not numbered in TOC 
\appendix 
\include{Appendix} 
\singlespacing 
\bibliographystyle{bevbib4} %{plainnat}
\bibliography{Rhizobia} 
%\addcontentsline{toc}{chapter}{Index} %leave commented I think
%\printindex 
\end{document} 

%notes
% \textcelsius\ and \textcelsius.
% you can add thin spaces by using: \;
% The symbols * † ‡ § ¶ # should be used for footnotes
% * \dag \ddag \S \P \sharp \diamond %By default, LaTeX doesn't like to fill more than 0.7 of a text page
%with tables and graphics, nor does it like too many figures per
%page. This behaviour can be changed by placing lines like the
%following before \begin{document} %\renewcommand\floatpagefraction{.9}
%\renewcommand\topfraction{.9}
%\renewcommand\bottomfraction{.9}
%\renewcommand\textfraction{.1}
%\setcounter{totalnumber}{50} \setcounter{topnumber}{50}
%\setcounter{bottomnumber}{50}

Tags