Skip to content

Instantly share code, notes, and snippets.

@owans
Last active April 16, 2020 13:20
Show Gist options
  • Save owans/a0813680fd2e7e062042dc24b197d09c to your computer and use it in GitHub Desktop.
Save owans/a0813680fd2e7e062042dc24b197d09c to your computer and use it in GitHub Desktop.
This is a tutorial on how to install Pandoc and LaTex on Mac Mojave, and solve some common installation errors

How To Install Pandoc and LaTex on MacOS Mojave

I recently had an opportunity to use the Pandoc Universal Document Converter in a project, I needed to run a PDF shell script to output the PDF version of a document, the codebase was already set up with Pandoc using LaTex to convert to a PDF file, this means I had to set up Pandoc and LaTex on my Mac, I faced some errors while trying to run the shell script, so after I solved this errors and outputted the PDF file, I thought to share my experience, and here we go;

System Requirements

  • MacOS Mojave version 10.14.5

Package Requirements

  • Homebrew
  • Python
  • librsvg

Install Pandoc

The easiest way to install Pandoc is via the package installer for Mac

For this tutorial, we would focus on installing Pandoc using Homebrew via the command line, but first, we need to check If Homebrew is installed;

NB: Input the command below into the command line to check if you already have Homebrew installed.

brew help

If Homebrew is installed you get an output, else if the result is a command not found or no output. Then go-ahead to install homebrew here

Enter the command below to Install Pandoc

brew install pandoc

To include Pandoc's citation parser:

brew install pandoc-citeproc

Install LaTex

Homebrew can also install other software that integrates with Pandoc, For example, to install librsvg (its rsvg-convert covers formats without SVG support), python (to use Pandoc filters), and BasicTeX (to typeset PDFs with LaTeX): 

brew install librsvg python

And;

brew cask install basictex

As mentioned earlier, I wanted to generate a pdf file using the pandoc script but I faced the following errors, one of these errors was: xelatex not found

To fix this error, I used the command below:

brew cask install xelatex

You also need the tlmgr tool, to install additional packages as needed.

To check if this tool is already available in your Mac, enter the command below;

cd /usr/local/texlive/

The aim of the above command is to look for a bin folder in texlive, in my case I had a folder called 2020basic inside the texlive folder, so I cd into the 2020basic folder, then cd into the bin folder. 

Here is the command I used:

cd /usr/local/texlive/2020basic/bin

The output was: x86_64-darwin , so I cd into x86_64-darwin.

Here is the command I used:

cd /usr/local/texlive/2020basic/bin/x86_64-darwin

To confirm if the tlmgr tool is available in your Mac, list the content in the current folder by inputting ls in to the command line, you will see a list of tools including the tlmgr tool.

If present, update the tlmgr tool, using the command below;

sudo /usr/local/texlive/2020basic/bin/x86_64-darwin/tlmgr update --self

If the above command was successful, enter the command below;

sudo /usr/local/texlive/2020basic/bin/x86_64-darwin/tlmgr install texliveonfly

I tried to run the script again, but got another error: enumitem.sty not found

To solve this error, I used this command:

sudo /usr/local/texlive/2020basic/bin/x86_64-darwin/tlmgr install enumitem

I tried to run the script again, I met with another error: fnbreak.sty not found.

This is the command I used to solve the above error below:

sudo /usr/local/texlive/2020basic/bin/x86_64-darwin/tlmgr install fnbreak

I tried to run the PDF shell script again and hooray! The pdf file outputted.

Hint

These errors were specific from my command line, but if you encounter an error that is not the same as the above errors, try running the commands above unique to the error in your command line.

I hope this was helpful?

Huge thanks to @bguiz for the helpful guide.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment