Pandoc + Latex Template

Date: 2019-04-22
Last Updated: 2023-04-18
#LaTeX #Pandoc

Sigh this one was a real piece of work. So as you may know I document my caving adventures in a log (see below), each month has a log entry. Until recently I used the app Ulysses to export my logs using a template I got from their website. When I upgraded my MacBook to an SSD, I looked for something new, since I don’t quite agree with the subscription model that they have adopted.

I proceeded to attempt to recreate the Ulysses template with CSS and use Pandoc to create a PDF using the CSS as a template. This proved to be a right pain, so I looked back to my old faithful LaTeX. It really can be an even bigger pain but you know that with enough fiddling the desired results are obtainable.

In truth I was able to put together a LaTex template for my caving logs. It was quite close to the original Ulysses template, but given a few minor discrepancies I decided to rerender all my old logs using this new template too. They are what you see up to and including the log of December 2018.

But this is where things become interesting and the reason for this post arises. I when to render the March 2019 log (Yeah I know I’m behind in them), I found that Pandoc was erroring and failing to complete the job. It was in troubleshooting this that I found out that the Pandoc in my path, was not the one installed by HomeBrew but rather the one installed by Anaconda. This is interesting because I finally made the jump form Python 2 to 3 when I installed my SSD, and of course now I’m using a far newer version of Pandoc, but still not current.

So I started to play with my template, I noticed that when I changed the font from Helvetica to Courier (Courier is a “standard” font in LaTeX) the document would compile. This lead me to a decision to rewrite my template again. In reality I just moved from Helvetica to Courier and gave the document the look of a real log / field report that had been typed up on a typewriter.


This was the error message that I saw. Now yes this is related to the hyperref package but somehow refraining from using fontspec cured the error.

The anchor of a bookmark and its parent's must not be the same...

Both my new and old templates are linked to below.

Here’s the code that I use to render the PDFs, I keep it in a script in my local logs dir.

pandoc $1 -s --template cave-log.tex \
  -o ${1%.*}.pdf --latex-engine=xelatex

Caving Logs

New Template

Old Template