{:title "Setting up LaTeX on a Mac" :date "2017-07-04" :tags ["tutorial", "bash", "LaTeX"]}

Setting up LaTeX on a Mac

First published: 2018-07-04 Tue
Last updated: 2018-09-08 Sat

Setup

Quick setup for LaTeX using homebrew on Mac OSX. I used BasicTex because MacTeX is a massive file and I can manually manage any additional packages I need using the TeX package manager tlmgr. If you are just getting started with LaTeX and want to use a GUI and some of the other helpful tools then I would still recommend MacTex.

Step 1: Install BasicTex

for this step, I used homebrew, the "missing package manager for macOS". Get homebrew here.
once homebrew is installed and setup, the following commands will install BasicTeX.

brew install caskroom/cask/brew-cask
brew cask install basictex --verbose # verbose flag so I can see what is happening. 

You will have to enter your password at some point. homebrew wont allow you to brew install with sudo.
This should install the basictex files under /Library/TeX/texbin. At this point, quit your terminal session and re-open it. Type the following:

Step 2: Verify the install

which pdflatex

if you get the path to pdflatex, /Library/TeX/texbin/pdflatex then you are all set! However, I had to manually add this to my path. Open you favorite terminal editor and add the following to the bottom of your .bash_profile

Step 3: Add BasicTex to your PATH.

# for basictex
export PATH=$PATH:/Library/TeX/texbin

This assigns the variable PATH to $PATH which is whatever else you already have on your PATH, and then appends the path to basictex.
Now restart your terminal (or run source .bash_profile) and try which pdflatex again, you should now get the path and you have a working version of \LaTeX on your computer. I did this so I could use pandoc and the org-mode exporter.

tlmgr TeX package manager

I love package managers. tlmgr is the package manager for TeX. It seems like most tlmgr commands have to be run as sudo. For example, here is how you install minted, for source code highlighting in LaTeX.

sudo tlmgr install minted

Make sure you pip install pygments as well!