Skip to content

Commit

Permalink
Merge pull request #7 from jacobneu/main
Browse files Browse the repository at this point in the history
Separate formatting from content, use standard document macros
  • Loading branch information
tomdjong authored Oct 18, 2024
2 parents 4aef153 + 7e7b8f9 commit b1f0a3e
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 119 deletions.
21 changes: 12 additions & 9 deletions frontmatter/titlepage.tex
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
\newgeometry{total={180mm,267mm}} % Make "A thesis submitted...the degree of" fit one line
\makeatletter
\begin{titlepage}
\begin{center}
\vspace*{\stretch{0.5}}

\large % Default size for the title page

{\Huge\textsc{The Title of a PhD Thesis}\par}
{\Huge\textsc{\@title}\par}

\vspace{\stretch{0.2}}

by

\vspace{\stretch{0.2}}

{\huge\textsc{Jane Doe}}
{\huge\textsc{\@author}}


\vspace{\stretch{0.5}}

A thesis submitted to the University of Foo for the degree of\\
\textsc{Doctor of Philosophy}
A thesis submitted to the \@institution{} for the degree of\\
\textsc{\@degree}

\vfill

\flushright
School of Bar \\
College of Baz and Quz \\
University of Foo \\
January 2023
\@ifundefined{@school}{}{\@school \\}
\@ifundefined{@college}{}{\@college \\}
\@institution \\
\@date

\end{center}
\end{titlepage}
\end{titlepage}
\makeatother
111 changes: 9 additions & 102 deletions main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4,107 +4,15 @@
\usepackage{packages}
\usepackage{macros}

% Label tables just like equations, theorems, definitions, etc.
%
% NB: This can be confusing if LaTeX does not place the table at the point of
% writing (e.g. for lack of space)!
\numberwithin{equation}{section}
\numberwithin{table}{section}
\makeatletter
\let\c@equation\c@table
\makeatother

% Setting up the coloured environments
%
\newbool{shade-envs}
% This can be used to toggle the coloured environments on or off.
\setboolean{shade-envs}{true}

%%
\ifthenelse{\boolean{shade-envs}}{%
% Colours are as in Andrej Bauer's notes on realizability:
% https://github.com/andrejbauer/notes-on-realizability
\colorlet{ShadeOfPurple}{blue!5!white}
\colorlet{ShadeOfYellow}{yellow!5!white}
\colorlet{ShadeOfGreen} {green!5!white}
\colorlet{ShadeOfBrown} {brown!10!white}
% But we also shade proofs
\colorlet{ShadeOfGray} {gray!10!white}
}
% If we don't want to have shaded environments, then we use a closing symbol
% \lozenge to mark the end of remarks, definitions and examples.
{%
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt,
bodyfont=\normalfont,
qed=\(\lozenge\)
]{definitionwithbox}
\declaretheoremstyle[
headfont=\itshape,
bodyfont=\normalfont,
qed=\(\lozenge\)
]{remarkwithbox}
}

\ifthenelse{\boolean{shade-envs}}{%
\declaretheorem[sibling=equation]{theorem}
\declaretheorem[sibling=theorem]{lemma,proposition,corollary}
\declaretheorem[sibling=theorem,style=definition]{definition}
\declaretheorem[sibling=theorem,style=definition]{example}
\declaretheorem[sibling=theorem,style=remark]{remark}
% Now we set the shading using the tcolorbox package.
%
% The related thmtools' option "shaded" and the package mdframed seem to have
% issues: the former does not allow for page breaks in shaded environments and
% the latter puts double spacing between two shaded environments.
%
% Since tcolorbox puts stuff inside a minipage or \parbox (according to this
% stackexchange answer: https://tex.stackexchange.com/a/250170), new
% paragraphs aren't indented. We can fix this by grabbing the parindent
% value and passing it to tcbset.
\newlength{\normalparindent}
\AtBeginDocument{\setlength{\normalparindent}{\parindent}}
\tcbset{shadedenv/.style={
colback={#1},
frame hidden,
enhanced,
breakable,
boxsep=0pt,
left=2mm,
right=2mm,
% LaTeX thinks this is too wide (as becomes clear from the many "Overfull
% \hbox" warnings, but optically it looks spot on.
add to width=1.1mm,
enlarge left by=-0.6mm,
before upper={\setlength{\parindent}{\normalparindent}}}
}
\newcommand{\setenvcolor}[2]{%
\tcolorboxenvironment{#1}{shadedenv={#2}}
\addtotheorempreheadhook[#1]{\tikzcdset{background color=#2}}
}
%
\setenvcolor{theorem}{ShadeOfPurple}
\setenvcolor{lemma}{ShadeOfPurple}
\setenvcolor{proposition}{ShadeOfPurple}
\setenvcolor{corollary}{ShadeOfPurple}
\setenvcolor{definition}{ShadeOfYellow}
\setenvcolor{example}{ShadeOfGreen}
\setenvcolor{remark}{ShadeOfBrown}
\setenvcolor{proof}{ShadeOfGray}
}{% Use closing symbols if we don't have colours
\declaretheorem[sibling=equation]{theorem}
\declaretheorem[sibling=theorem]{lemma,proposition,corollary}
\declaretheorem[sibling=theorem,style=definitionwithbox]{definition}
\declaretheorem[sibling=theorem,style=definitionwithbox]{example}
\declaretheorem[sibling=theorem,style=remarkwithbox]{remark}
}
\declaretheorem[sibling=theorem,style=remark,numbered=no]{claim}

% Note that proofs will still have the \qed symbol at the end, even when shaded,
% because we prefer to keep up the tradition.


\title{The Title of a PhD Thesis}
\author{Jane Doe}
\institution{University of Foo}
\degree{Doctor of Philosophy}
%\school{School of Bar} % optional
%\college{College of Baz and Quz} % optional
%\date{January 2023}
%\subject{PhD thesis} % optional
%\keywords{some, descriptive, keywords}

\begin{document}

Expand All @@ -116,7 +24,6 @@
\include{frontmatter/abstract}
\include{frontmatter/acknowledgements}

\setcounter{tocdepth}{2}
\tableofcontents

\mainmatter%
Expand Down
138 changes: 130 additions & 8 deletions packages.sty
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,136 @@ backrefstyle=two]%
, linkcolor=NavyBlue % Colour for internal links
, citecolor=Green % Colour for bibliographical citations
, urlcolor=BrickRed % Colour for (external) urls
%
% Metadata
%
, pdftitle={The Title of a PhD Thesis}%
, pdfauthor={Jane Doe}%
, pdfsubject={PhD thesis}%
, pdfkeywords={some, descriptive, keywords}
]{hyperref}


% Metadata setup (define using \subject, \degree, \institution, etc. in main.tex)
\makeatletter

\newcommand{\subject}[1]{\gdef\@subject{#1}}%
\newcommand{\@subject}{PhD thesis}
\newcommand{\degree}[1]{\gdef\@degree{#1}}%
\newcommand{\@degree}{Doctor of Philosophy}
\newcommand{\institution}[1]{\gdef\@institution{#1}}%
\newcommand{\@institution}{University of Foo}
\newcommand{\school}[1]{\gdef\@school{#1}}%
\newcommand{\college}[1]{\gdef\@college{#1}}%
\newcommand{\keywords}[1]{\gdef\@keywords{#1}}%
\newcommand{\@keywords}{some, descriptive, keywords}

\AtBeginDocument{
\hypersetup{
pdftitle = {\@title},
pdfauthor = {\@author},
pdfsubject = {\@subject},
pdfkeywords = {\@keywords}
}
}
\makeatother

\usepackage[noabbrev,capitalize]{cleveref}
\creflabelformat{equation}{#2\textup{#1}#3} % Write Equation x.y.z instead of Equation (x.y.z)
\creflabelformat{equation}{#2\textup{#1}#3} % Write Equation x.y.z instead of Equation (x.y.z)

% Label tables just like equations, theorems, definitions, etc.
%
% NB: This can be confusing if LaTeX does not place the table at the point of
% writing (e.g. for lack of space)!
\numberwithin{equation}{section}
\numberwithin{table}{section}
\makeatletter
\let\c@equation\c@table
\makeatother

% Setting up the coloured environments
%
\newbool{shade-envs}
% This can be used to toggle the coloured environments on or off.
\setboolean{shade-envs}{true}

%%
\ifthenelse{\boolean{shade-envs}}{%
% Colours are as in Andrej Bauer's notes on realizability:
% https://github.com/andrejbauer/notes-on-realizability
\colorlet{ShadeOfPurple}{blue!5!white}
\colorlet{ShadeOfYellow}{yellow!5!white}
\colorlet{ShadeOfGreen} {green!5!white}
\colorlet{ShadeOfBrown} {brown!10!white}
% But we also shade proofs
\colorlet{ShadeOfGray} {gray!10!white}
}
% If we don't want to have shaded environments, then we use a closing symbol
% \lozenge to mark the end of remarks, definitions and examples.
{%
\declaretheoremstyle[
spaceabove=6pt,
spacebelow=6pt,
bodyfont=\normalfont,
qed=\(\lozenge\)
]{definitionwithbox}
\declaretheoremstyle[
headfont=\itshape,
bodyfont=\normalfont,
qed=\(\lozenge\)
]{remarkwithbox}
}

\ifthenelse{\boolean{shade-envs}}{%
\declaretheorem[sibling=equation]{theorem}
\declaretheorem[sibling=theorem]{lemma,proposition,corollary}
\declaretheorem[sibling=theorem,style=definition]{definition}
\declaretheorem[sibling=theorem,style=definition]{example}
\declaretheorem[sibling=theorem,style=remark]{remark}
% Now we set the shading using the tcolorbox package.
%
% The related thmtools' option "shaded" and the package mdframed seem to have
% issues: the former does not allow for page breaks in shaded environments and
% the latter puts double spacing between two shaded environments.
%
% Since tcolorbox puts stuff inside a minipage or \parbox (according to this
% stackexchange answer: https://tex.stackexchange.com/a/250170), new
% paragraphs aren't indented. We can fix this by grabbing the parindent
% value and passing it to tcbset.
\newlength{\normalparindent}
\AtBeginDocument{\setlength{\normalparindent}{\parindent}}
\tcbset{shadedenv/.style={
colback={#1},
frame hidden,
enhanced,
breakable,
boxsep=0pt,
left=2mm,
right=2mm,
% LaTeX thinks this is too wide (as becomes clear from the many "Overfull
% \hbox" warnings, but optically it looks spot on.
add to width=1.1mm,
enlarge left by=-0.6mm,
before upper={\setlength{\parindent}{\normalparindent}}}
}
\newcommand{\setenvcolor}[2]{%
\tcolorboxenvironment{#1}{shadedenv={#2}}
\addtotheorempreheadhook[#1]{\tikzcdset{background color=#2}}
}
%
\setenvcolor{theorem}{ShadeOfPurple}
\setenvcolor{lemma}{ShadeOfPurple}
\setenvcolor{proposition}{ShadeOfPurple}
\setenvcolor{corollary}{ShadeOfPurple}
\setenvcolor{definition}{ShadeOfYellow}
\setenvcolor{example}{ShadeOfGreen}
\setenvcolor{remark}{ShadeOfBrown}
\setenvcolor{proof}{ShadeOfGray}
}{% Use closing symbols if we don't have colours
\declaretheorem[sibling=equation]{theorem}
\declaretheorem[sibling=theorem]{lemma,proposition,corollary}
\declaretheorem[sibling=theorem,style=definitionwithbox]{definition}
\declaretheorem[sibling=theorem,style=definitionwithbox]{example}
\declaretheorem[sibling=theorem,style=remarkwithbox]{remark}
}
\declaretheorem[sibling=theorem,style=remark,numbered=no]{claim}

% Note that proofs will still have the \qed symbol at the end, even when shaded,
% because we prefer to keep up the tradition.


% Set table of contents depth
\setcounter{tocdepth}{2}

0 comments on commit b1f0a3e

Please sign in to comment.