This repository provides a framework for writing a PhD thesis in Markdown. I used the template for my PhD submission to University College London (UCL), but it should be straightforward to adapt suit other universities too.
If you have used this template in your work, please cite the following publication:
Tom Pollard et al. (2016). Template for writing a PhD thesis in Markdown. Zenodo. http://dx.doi.org/10.5281/zenodo.58490
pandoc
. This repository requires pandoc
3.1+, so if you install pandoc
using a package manager (e.g. apt
), check that it meets the version requirement. Otherwise, install by following the link.pandoc-crossref
, a pandoc
filter for numbering and cross-referencing figures, tables, sections and code blocks.If you're a Mac user and you have conda
and brew
installed, run the following in your terminal to install pandoc
and TeX packages (steps 1 & 3):
# get texlive
brew install --cask mactex
# update tlmgr and packages
sudo tlmgr update --self
# make python venv and install pandoc
conda create -n phd -y python=3.7 pandoc
conda activate phd
# Install required python and texlive packages
make install
There are several ways to install TeXLive. This guide (written for Ubuntu) may be useful. In short, you can:
apt install texlive
to see all available packages), or;tlmgr
) to install required packages. If you go down this route, you can run make install
to install required TeXLive packages.pandoc
User Guide for Markdown syntax for figures, tables, lists, etc., as well as information on flags that can be used when calling pandoc
pandoc-crossref
manual which outlines syntax and customisation options for cross-referencing (e.g. should the figure prefix be "fig,", "Fig." or "Figure")README
for pandoc-crossref
-compatible syntax to have shorter captions for figures in the List of Figures (PDF/LaTeX output only)README
for pandoc-crossref
-compatible syntax to have shorter captions for tables in the List of Tables (PDF/LaTeX output only)Markdown is a super-friendly plain text format that can be easily converted to a bunch of other formats like PDF, Word and LaTeX. You'll enjoy working in Markdown because:
pandoc
.There are some minor annoyances:
pandoc
User Guide) fairly often at first.pandoc
pandoc
to produce the final thesis.make: *** [pdf] Error 43
), consult this article for possible fixes. Most importantly, make sure tlmgr is properly installed, then run `install.sh
The universal document converter pandoc
does all the heavy lifting. For example:
make pdf
(the code under pdf: ...
in Makefile
) runs pandoc
which takes as input
input/*.md
input/metadata.yml
style/template.tex
style/preamble.tex
input/references.bib
style/ref_format.csl
--number-sections
output/thesis.pdf
.tex
which was compiled): pandoc.pdf.log
Put simply, pandoc
uses the latex template provided to create a .tex
file, then compiles it. In detail, pandoc
processes the input files in the following way (the file names in quotes aren't visible to you, but are named for the purpose of understanding):
input/*.md
e.g.:
@fig:my_fig
-> \ref{fig:my_fig}
$$f(x) = ax^3 + bx^2 + cx + d$$ {#eq:my_equation}
-> \begin{equation}f(x) = ax^3 + bx^2 + cx + d\label{eq:my_equation}\end{equation}
[@Cousteau1963]
-> (Cousteau Jacques & Dugan James 1963)
input/*.md
for more examples!body.tex
" by:
*.md
files in the order that they were stated in the pandoc
callmain.tex
" from style/template.tex
by running code wrapped in $
signs. The important things to note are:
style/template.tex
with metadata from input/metadata.yml
and the arguments from the pandoc
callbody.tex
" is pasted in verbatim in place of $body$
references.tex
" by converting ./input/references.bib
thesis.tex
= style/preamble.tex
+ "main.tex
" + "references.tex
"thesis.tex
(you can see the logs for this process, and what "thesis.tex
" would look like in pandoc.pdf.log
)
output/thesis.tex
by running make tex
- this follows all the above steps, bar the final compilationSome useful points, in a random order:
thesis.pdf
you can always fall back on writing LaTeX within the markdown files (but note that thesis.html
and other outputs will not be able to render this)01_chapter_1.md
, 02_chapter_2.md
, etc. This is required because of the way we have written make pdf
. You can change this behaviour by writing a custom pandoc
command instead of using make pdf
.$ npm install
and then $ npm run watch
the PDF and HTML export is done automatically when saving a Markdown file.$ npm run livereload
. The HTML page will automatically reload when saving a Markdown file after the export is done.make *
command fails is a simpler build, e.g. if make pdf
failed, try make tex
to see if that fails too.make tex
works but make pdf
fails), try updating tex live and/or packages. For example, if you get the error make: *** [pdf] Error 43
, have a look in pandoc.pdf.log
for the error. If it is something like
`l3backend-xdvipdfmx.def' not found
then try:
sudo tlmgr update --self
sudo tlmgr l3backend
# Full nuclear option - update *all* the packages! (takes about 10m)
# sudo tlmgr update --all
.travis.yml
)Contributions to the template are encouraged! There are lots of things that could be improved, like:
Please fork and edit the project, then send a pull request.