May 5, 2018 Tags: workflow
I’ve had a few people ask me how I compose and typeset my papers and presentations, so I’m writing this post to explain my setup.
For the last two years, I’ve used Pandoc to do pretty much all of my writing (excluding this blog, which is Jekyll based). Prior to Pandoc I used LaTeX for several years, but switched for two main reasons:
For papers, I have a template file and that I copy over. The template looks something like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
---
documentclass: article
geometry: margin=1in
fontsize: 12pt
header-includes:
- \usepackage{setspace}
- \usepackage[hang,multiple]{footmisc}
- \setlength{\footnotemargin}{0mm}
---
William Woodruff \hfill CLASS -- ASSIGNMENT
\today \hfill Dr. NAME
\setlength{\parindent}{2em}
\doublespacing
**Here** is *some text*.
(N.B.: This is my assignment template. You can rearrange and remove the elements that don’t apply to you.)
When compiled (pandoc paper.md -o paper.pdf
), this yields a blank slate:
The LaTeX abstract
section can also be added, although Pandoc’s Markdown doesn’t work within it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
documentclass: article
geometry: margin=1in
fontsize: 12pt
header-includes:
- \usepackage{setspace}
- \usepackage[hang,multiple]{footmisc}
- \setlength{\footnotemargin}{0mm}
---
William Woodruff \hfill CLASS -- ASSIGNMENT
\today \hfill Dr. NAME
\setlength{\parindent}{2em}
\doublespacing
\begin{abstract}
vīvāmus mea Lesbia, atque amēmus,
rūmōrēsque senum sevēriōrum
omnēs ūnius aestimēmus assis!
sōlēs occidere et redīre possunt:
nōbīs cum semel occidit brevis lūx,
nox est perpetua ūna dormienda.
dā mī bāsia mīlle, deinde centum,
dein mīlle altera, dein secunda centum,
deinde ūsque altera mīlle, deinde centum.
dein, cum mīlia multa fēcerīmus,
conturbābimus illa, ne sciāmus,
aut nē quis malus invidēre possit,
cum tantum sciat esse bāsiōrum.
\end{abstract}
**Here** is *some text*.
Which yields:
I do all of my composition in a normal Sublime Text window, with spellchecking enabled.
I don’t use any specialized Pandoc plugins, although I do use AutoWrap to wrap any lines that pass my normal ruler (which is 100 columns).
This is what it ends up looking like (note the spellchecker lines and 100-column ruler):
(More on the
Makefile
in a bit.)
entr
, and mupdf
To actually see my rendered work in (near) real-time, I rely on a few different tools:
entr
, a nice little tool for running a command whenever files
change.mupdf
, a lightweight PDF viewer for X11.pdftotext
, a Poppler (originally Xpdf) tool for converting
PDFs into plain text.Thus, my workflow looks like this:
entr
trigger for Paper.md runs, calling pandoc
to produce
Paper.pdf.entr
trigger for Paper.pdf runs, calling killall -HUP mupdf-x11
to refresh my PDF
viewer.entr
trigger for Paper.pdf runs, calling pdftotext Paper.pdf - | wc -w
to give me
my current word count.I usually simplify this a bit via a Makefile
:
1
2
3
4
5
all:
pandoc "Paper.md" --latex-engine=pdflatex -o "Paper.pdf"
entr:
ls *.md | entr -c bash -c 'make; killall -HUP mupdf-x11'
The end result is a tidy side-by-side view, all within an i3 workspace:
(The left terminal is running
make entr
, and the right terminal is running my wordcounter.)
…and in action:
Here are some working examples, in the wild:
bytefield
diagrams.