Jesse Whitehouse Developer | Analyst

Upgrading BasicTeX with Recommended Fonts


The other day I needed a way to convert a markdown document to PDF for my company. All signs pointed to Pandoc as the fastest and highest quality option. So I downloaded it and ran:

$whitehouse: pandoc -o training.pdf

But immediately received an error:

pandoc: pdflatex not found. pdflatex is needed for pdf output.
Error: pandoc document conversion failed

Pandoc requires a LaTeX installation to generate PDF’s. For macOS, this usually means the enormous MacTex package. As of May 2017 it’s a 3GB download 1. The entire Microsoft Office Suite download is only 2.7GB, by comparison. MacTeX includes every major package needed to generate even the most complicated typsettings and page layouts. So it’s really overkill for my simple needs.

I found an alternative Mac installation called BasicTeX that’s only 72mb. It includes all the basic packages but nothing else. It includes tlmgr (the LaTeX package manager) though, so you can add components later.

brew cask install basictex

During installation BasicTeX adds /usr/local/texlive/current_version to your $PATH variable and conveniently stores all of its resources there. Close and reopen and Pandoc should generate a beautiful PDF with aplomb.

The default settings look beautiful. It uses Latin Modern font with suitable line spacing. The margins are a touch bloated. But the whole setup will do in a pinch.

Add Fonts

Still, I don’t want my training documentation at work to look like the Journal of the American Medical Association. So I needed a different font. If I had installed MacTeX this wouldn’t be a problem because the mac daddy of downloads includes every font under the sun. But BasicTeX includes just two: Latin Modern and Times.

According to the Pandoc Documentation, the fastest way to add some useful fonts is with tlmgr. First, make sure it’s updated.

tlmgr update --self

Then have tlmgr install the collection-fontsrecommended package:

sudo tlmgr install collection-fontsrecommended

This package includes the thirty five base PostScript 2 fonts (more info here), the TeX Gyre font families, and encoding support for Computer Modern families. Detailed information about this package can be found at netbsd.

To use a different font, add YAML front matter to the top of your .md file before running Pandoc.

title: Your Title
author: Your Name
fontfamily: Your Font Choice

I chose Palatino.2

  1. And it’s getting bigger. In my search for solutions to this problem I found references to MacTeX from 2012 and earlier when “large” was 1.5GB. When you read this it will probably have grown some more. 

  2. You can see a Pandoc rendered version of this blog post here