Writing an article in LaTeX produces crisp, quality documents and beautiful equations. However, it’s not very user friendly. Recently I’ve been using another language, Markdown, because I find it more readable and intuitive, but it still has LaTeX equation support. To me that’s the best of both worlds. So how about writing an entire PhD thesis in Markdown? This post shows you how.
This month I’ve started writing up my PhD research into a thesis. One question I often get asked is: will you use LaTeX or Word? Word is simple and is easy for others to review, but people who’ve put a lot of figures, sections and equations into a Word file understand how slow and unstable it gets. Sometimes a whole file freezes or gets corrupted. That’s stress I don’t need right now.
Because of this, a lot of scientists use LaTeX. It uses plain-text files with little overhead and allows version control backup with Git. It also supports writing complex equations, cross-referencing and bibliographies. But I don’t think it’s a language that is intuitive or very easy to read, especially since I’ve learnt Markdown for writing this blog. So let’s compare LaTeX and Markdown.
This is how a LaTeX document looks with headings, citations, links and labelled equations:
This is how the same information looks in Markdown:
I find the Markdown much easier to read and write. So I wondered, is it possible to write my thesis in Markdown?
With the right framework, a series of input Markdown files (say, per chapter) can be combined into a single output file while automatically creating a table of contents, a bibliography, and with dynamic referencing to sections and equations.
So let’s take a look at what the Markdown output above looks like.
The thing I like most about this system is that I can type either:
and in less than a second, I get either a LaTeX pdf, html or a Word docx:
I think that’s beautiful, especially since one of my supervisors prefers to review in Word. If you want more fine tuning for your LaTeX documents, you can also output to .tex, make your changes, then output to pdf. Great!
So, I’ve taken the work of others and adapted it for my needs, including the formatting requirements of UNSW Sydney where I’ll be submitting my thesis. I’ve also added a few extra capabilities like equation numbering and a word count.
One thing I wanted was a way to track the number of words in the input files.
The first file I need is
wordcount.sh, a shell script that interrogates the committed Git files. It’s adapted from on the work of Bastian Rieck.
The second file is
plot_wordcount.py, a simple python script which plots your progress like this:
I find this a really great way to get me motivated to keep on writing, as I want to beat that trend line! I’ll update this wordcount plot as I get closer to my goal. Hopefully that’ll keep me honest.
If you want to use the framework, clone my Github repository here.