ENOSUCHBLOG

Programming, philosophy, pedaling.


How I Write

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.

Typesetting: Pandoc

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:

  1. Markdown makes it easier to focus on the content, instead of getting caught up in the formatting.
  2. When I do need to do manual formatting, Pandoc's syntax makes inlined LaTeX straightforward and painless.

For papers, I have a template file and that I copy over. The template looks something like this:

---
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:

Blank PDF

The LaTeX abstract section can also be added, although Pandoc's Markdown doesn't work within it:

---
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:

Blank PDF with abstract

Composition: Sublime Text

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):

Sublime Text Paper Composition. (More on the Makefile in a bit.)

Workflow: Makefiles, entr, and mupdf

To actually see my rendered work in (near) real-time, I rely on a few different tools:

Thus, my workflow looks like this:

  1. I save Paper.md. The entr trigger for Paper.md runs, calling pandoc to produce Paper.pdf.
  2. The entr trigger for Paper.pdf runs, calling killall -HUP mupdf-x11 to refresh my PDF viewer.
  3. A second 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:

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:

My writing workspace (The left terminal is running make entr, and the right terminal is running my wordcounter.)

...and in action:

Click to play on YouTube.

Wrapup

Here are some working examples, in the wild:


Reddit discussion