updates
[phd-thesis.git] / preamble.tex
index a120487..0301489 100644 (file)
@@ -16,6 +16,7 @@
 \usepackage{siunitx}        % typeset units
 \usepackage{xcolor}         % colors
 \usepackage{fnpct}          % footnotekerning
+\usepackage[all]{nowidow}   % Kill widows and orphans
 \DeclareSIUnit\noop{\relax}
 \DeclareSIUnit\celcius{{}^{\circ}\kern-\scriptspace\mathsf{C}}
 \everymath{\it\/}
        chapterlistsgaps=on,
        ]{equ}
 \usepackage{fancyhdr} % Custom headers and footers
+\usepackage[fit]{truncate}
 %\pagestyle{headings}
 \pagestyle{fancy}
 \fancyhead{}
 \fancyfoot{}
 \setlength{\unitlength}{18mm}
 \newcommand{\blob}{{\color{gray}\rule[-.2\unitlength]{2\unitlength}{.5\unitlength}}}
-\fancyhead[RE]{\rightmark}
-\fancyhead[LO]{\leftmark}
+\fancyhead[RE]{\truncate{.95\headwidth}{\rightmark}}
+\fancyhead[LO]{\truncate{.95\headwidth}{\leftmark}}
 \newcommand{\frontmatterfancy}[0]{
        \fancyhead[RO]{\thepage}
        \fancyhead[LE]{\thepage}
 \def\part@nostar@nopt#1{\NR@gettitle{#1}\titlesec@part{#1}}
 \def\part@nostar@opt[#1]#2{\NR@gettitle{#1}\titlesec@part[#1]{#2}}
 \makeatother
-\newenvironment{chapterabstract}{\begin{quotation}\em}{\end{quotation}} %chktex 6
+
+\usepackage{framed}
+\definecolor{lstbg}{gray}{.95}
+\definecolor{shadecolor}{named}{lstbg}
+\newenvironment{chapterabstract}{\begin{shaded}\begin{quotation}}{\end{quotation}\end{shaded}} %chktex 6
 
 % Increase the depth for the table of contents
 \setcounter{secnumdepth}{3}
 \usepackage{appendix}                      % subappendices, appendices per chapter
 
 % Bibliography
-\usepackage{natbib} % Cite bib entry completely
+\usepackage[square]{natbib} % Cite bib entry completely
 \setlength{\bibsep}{0.0pt}
-\def\bibfont{\small}
+%\def\bibfont{\small}
 %\bibliographystyle{alpha}
 \bibliographystyle{abbrvnat}
-\apptocmd{\thebibliography}{\raggedright}{}{}
+%\apptocmd{\thebibliography}{\raggedright}{}{}
 \usepackage{bibentry} % Cite bib entry completely
 \nobibliography*
 \newcommand{\citeentry}[1]{\begin{NoHyper}\bibentry{#1}\end{NoHyper}. \citep{#1}}
+\newcommand{\refurl}[2]{\url{#1}, accessed on: #2}
 
 \makeatletter
 \newcommand{\citepage}[1]{p.~#1}
 %\newcommand{\citesections}[1]{\S\S.~#1}
 \newcommand{\citeparagraph}[1]{\P.~#1}
 \newcommand{\citeparagraphs}[1]{\P\P.~#1}
+\newcommand{\citelisting}[1]{\cref@listing@name~#1}
 \makeatother
 
-% Graphics
-\usepackage{graphicx} % Images
-\graphicspath{{img/},{intro/img},{top/img},{tvt/img}}
-\usepackage{caption}  % subfigures/captionof
-\usepackage{subcaption}
-\usepackage{rotating}
-\newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\hspace{1mm}\includegraphics[width=1em]{orcid}\hspace{2mm} https://orcid.org/#1}}
-\usepackage{tikz}
-
 % Tables
 \usepackage{booktabs}  % Nicer tables
 \usepackage{multirow}  % Multirow cells
 \usepackage{longtable} % Tables spanning pages
 \usepackage{threeparttable} % Tables with footnotes
 
-% Code
 % Pseudocode
 \usepackage[algochapter,linesnumbered,lined,boxed]{algorithm2e}
 % Fix the algorithm font
 \renewcommand\AlCapFnt{\normalfont}
-\usepackage{listings}
-% https://tex.stackexchange.com/questions/149056/how-can-i-define-additional-literate-replacements-without-deleting-existing-ones
-\makeatletter
-\def\addToLiterate#1{\edef\lst@literate{\unexpanded\expandafter{\lst@literate}\unexpanded{#1}}}
-\lst@Key{moreliterate}{}{\addToLiterate{#1}}
-\makeatother
-% General listings settings
-\lstset{%
-       basewidth=0.5em,
-       basicstyle=\tt\small,
-       breakatwhitespace=false,
-       breaklines=true,
-       captionpos=b,
-       columns=[c]fixed,
-       commentstyle=\sl,
-       escapeinside={[+}{+]},  % chktex 9
-       frame=L,
-       keepspaces=true,
-       keywordstyle=\bf,
-       postbreak=\mbox{\textcolor{gray}{$\hookrightarrow$}\space},
-       showspaces=false,
-       showstringspaces=false,
-       showtabs=false,
-       stringstyle=\it,
-       tabsize=4,
-       upquote=true,
-       numberstyle=\tiny,
-}
-\usepackage{lstlangclean}
-\usepackage{lstlanghaskell}
-\usepackage{lstlangarduino}
-\lstloadlanguages{%
-       {[Arduino]C++},%
-       {c},%
-       {Python},%
-       {Clean},%
-       {[Regular]Haskell},
-       {[Lhs2Tex]Haskell}}
-\newcommand{\cinline}[1]{\lstinline[language=c,postbreak=]|#1|}
-\newcommand{\arduinoinline}[1]{\lstinline[language={[Arduino]C++},postbreak=]|#1|}
-\newcommand{\pythoninline}[1]{\lstinline[language=Python,postbreak=]|#1|}
-\newcommand{\cleaninline}[1]{\lstinline[language=Clean,postbreak=]|#1|}
-\newcommand{\cleaninputlisting}[2][]{\renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}\lstinputlisting[language=Clean,#1]{\subfix{#2}}}
-\newcommand{\haskellinline}[1]{\lstinline[language={[Regular]Haskell},postbreak=]|#1|}
-\newcommand{\haskellinputlisting}[2][]{\renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}\lstinputlisting[language={[Regular]Haskell},#1]{\subfix{#2}}}
-\newcommand{\haskelllhstexinline}[1]{\lstinline[language={[Lhs2Tex]Haskell},postbreak=]|#1|}
-%For storing listings in footnotes
-\newsavebox{\LstBox}
-% Fix list of listings title
-\renewcommand{\lstlistlistingname}{List of Listings}
-% Fix list of listings chapter separator
-\makeatletter
-\let\my@chapter\@chapter%
-\renewcommand*{\@chapter}{%
-  \addtocontents{lol}{\protect\addvspace{10pt}}%
-  \my@chapter}
-\makeatother
 
-\lstnewenvironment{lstPython}[1][]
-       {% 
-               \lstset{language=Python, #1}
-               \renewcommand*{\lstlistingname}{Listing (\gls{PYTHON})}
-       }
-       {}
-\lstnewenvironment{lstClean}[1][]
-       {% 
-               \lstset{language=Clean, #1}
-               \renewcommand*{\lstlistingname}{Listing (\gls{CLEAN})}
-       }
-       {}
-\lstnewenvironment{lstArduino}[1][]
-       {% 
-               \lstset{language={[Arduino]C++}, #1}
-               \renewcommand*{\lstlistingname}{Listing (\gls{CPP})}
-       }
-       {}
-\lstnewenvironment{lstHaskell}[1][]
-       {%
-               \lstset{language={[Regular]Haskell},#1}%
-               \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
-       }
-       {}
-\lstnewenvironment{lstHaskellLhstex}[1][]
-       {%
-               \lstset{language={[Lhs2Tex]Haskell},#1}%
-               \renewcommand*{\lstlistingname}{Listing (\gls{HASKELL})}
-       }
-       {}
+% Listings
+\input{preamble/listings}
+
+% Graphics
+\usepackage{graphicx} % Images
+\graphicspath{{img/},{intro/img},{top/img},{tvt/img}}
+\usepackage{dpfloat}
+\usepackage{caption}  % subfigures/captionof
+\usepackage{subcaption}
+\usepackage{rotating}
+\usepackage{adjustbox} % Make table fit page
+\newcommand{\orcid}[1]{\href{https://orcid.org/#1}{\hspace{1mm}\includegraphics[width=1em]{orcid}\hspace{2mm} https://orcid.org/#1}}
+\usepackage{tikz}
+
+% Index
+%\usepackage{makeidx}
+%\makeindex% Enable the index
+
+% Custom enumerations
+\usepackage[inline,shortlabels]{enumitem}
+\setlist{noitemsep}
+\setlist[description]{leftmargin=\parindent}
 
 % Hyperlinks and metadata
-       \usepackage[hyphens]{url}
+\usepackage[hyphens]{url}
 \usepackage[pdflang={en-GB},pagebackref,breaklinks]{hyperref} % hyperlinks
 \usepackage{xr} % hyperlinks
 \renewcommand*{\backref}[1]{}
        \def\MakeUppercase#1{}%
 }
 
-% Index
-%\usepackage{makeidx}
-%\makeindex% Enable the index
-
-% Custom enumerations
-\usepackage[inline,shortlabels]{enumitem}
-\setlist{noitemsep}
-\setlist[description]{leftmargin=\parindent}
-
 % Initialize the glossaries
 \makeglossaries%
 \input{glossaries}
 \newcommand{\pkoopman}{Koopman, dr.\ P.\ (Radboud University)}
 \newcommand{\ptrinder}{Trinder, prof.~dr.\ P.\ (University of Glasgow)}
 \newcommand{\rdmentry}[5]{#1 (#2): #3. #4.\ \doifmt{#5}}
-\newcommand{\rewriterate}[2]{\langle{}#1, #2\rangle{}}
+\newcommand{\rewriterate}[2]{\langle{}\mathit{#1}, \mathit{#2}\rangle{}}
 \newcommand{\requiresGHCmod}[2][]{\footnote{Requires \GHCmod{#2} to be enabled. #1}}
 \newcommand{\rplasmeijer}{Plasmeijer, prof.\ dr.\ ir.\ R.\ (Radboud University)}
 \newcommand{\erasmusplus}{ERASMUS\raisebox{.25ex}{+}}
 \newcommand{\imtask}{\gls{ITASK}\slash\gls{MTASK}}
-\newcommand{\Imtask}{\Gls{ITASK}\slash\gls{MTASK}}
 \newcommand{\citask}{\gls{CLEAN}\slash\gls{ITASK}}
 \newcommand{\Citask}{\Gls{CLEAN}\slash\gls{ITASK}}
+\newcommand{\cmtask}{\gls{CLEAN}\slash\gls{MTASK}}
+\newcommand{\Cmtask}{\Gls{CLEAN}\slash\gls{MTASK}}
 \newcommand{\cimtask}{\gls{CLEAN}\slash\gls{ITASK}\slash\gls{MTASK}}
 \newcommand{\Cimtask}{\Gls{CLEAN}\slash\gls{ITASK}\slash\gls{MTASK}}
-\newcommand{\ccpp}{\gls{C}\slash\gls{CPP}}
-\newcommand{\Ccpp}{\Gls{C}\slash\gls{CPP}}
+\newcommand{\ccpp}{\texorpdfstring{\gls{C}\slash\gls{CPP}}{C\slash{}C\texttt{++}}}
+\newcommand{\Ccpp}{\texorpdfstring{\Gls{C}\slash\gls{CPP}}{C\slash{}C\texttt{++}}}
 \newcommand{\stacksize}[1]{\parallel#1\parallel}
 
 \makeatletter