Setting up LaTeX on a Mac

Setup

Quick setup for using homebrew on a mac. 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. 
==> Auto-updated Homebrew!
Updated Homebrew from 56458f03 to 935cf28c.
Updated 3 taps (caskroom/cask, homebrew/core, homebrew/science).
==> New Formulae
asciidoctor
asciidoctorj
csvkit
dps8m
e2tools
[email protected]
git-appraise
glib-openssl
go-jira
gutenberg
heartbeat
htslib
iron-functions
jabba
just
kaitai-struct-compiler
keystone
[email protected]
kontena
[email protected]
lgogdownloader
libbitcoin-database
libxo
[email protected]
massren
ocaml-findlib
ocaml-num
pipenv
[email protected]
rbenv-chefdk
restic
sc-im
simg2img
singular
swift-protobuf
terraform_landscape
traefik
ydcv
zip
==> Updated Formulae
abcm2ps
abcmidi
abyss
aces_container
activemq
adplug
afl-fuzz
akamai
alexjs
allegro
allure
amazon-ecs-cli
ammonite-repl
angband
angular-cli
ansible
ansible-cmdb
ansible-lint
apache-geode
apache-opennlp
apibuilder-cli
app-engine-go-64
app-engine-java
appscale-tools
apr
apr-util
arangodb
archivemount
aria2
armadillo
artifactory
asciidoc
aspcud
aspectj
assh
at-spi2-atk
at-spi2-core
atk
atlassian-cli
ats2-postiats
aws-elasticbeanstalk
aws-sdk-cpp
aws-shell
awscli
axel
azure-cli
[email protected]
b2-tools
babl
bacula-fd
baresip
bash-preexec
bash-snippets
bazel
bchunk
bear
bento4
bibtexconv
binaryen
bindfs
bit
bitcoin
bitrise
bluepill
bmake
boost-mpi
brew-gem
bro
bsponmpi
buku
bzt
caf
cake
calcurse
camlp4
camlp5
cargo-completion
carthage
casperjs
cassandra
ccm
ceres-solver
certigo
cfitsio
chakra
charm-tools
check
checkstyle
chezscheme
chisel
chronograf
cimg
citus
ckan
clac
cli53
clinfo
clojure
clojurescript
closure-compiler
cmake
cmark
cnats
cockroach
cocot
codemod
coffeescript
collectd
commandbox
conan
configen
conjure-up
consul
consul-template
convox
cookiecutter
coq
corebird
couchdb
cppad
cpprestsdk
credstash
crowdin
crystal-icr
crystal-lang
curl
cython
dar
davix
dbhash
dbus
dcm2niix
dcmtk
dcos-cli
debianutils
deja-gnu
dep
dependency-check
derby
dhall-json
diff-pdf
diffoscope
digdag
django-completion
dmd
docfx
docker
docker-completion
docker-compose
docker-compose-completion
docker-machine
docker-machine-completion
docker2aci
doctl
doitlive
dos2unix
dovecot
dscanner
dssim
dub
duck
dvm
e2fsprogs
easyrpg-player
efl
elasticsearch
erlang
etcd
exact-image
exiftool
expat
expect
exploitdb
eye-d3
faac
faad2
faas-cli
fabio
fantom
fd
feedgnuplot
feh
ffmpeg
[email protected]
fibjs
fifechan
file-roller
filebeat
fio
firebase-cli
flake8
flawfinder
flow
fluent-bit
fluid-synth
fn
folly
fon-flash-cli
fonttools
fossil
freetds
frugal
fswatch
fuse-emulator
fwup
fzf
gammu
gauge
gawk
[email protected]
gdcm
geckodriver
gegl
geoipupdate
geoserver
get_iplayer
getdns
geth
getmail
gibo
git
git-annex
git-cinnabar
git-cola
git-ftp
git-lfs
git-quick-stats
git-review
git-town
gitbucket
gitlab-runner
gjs
gjstest
glassfish
glib
glib-networking
glide
gmic
gmime
gmp
gmsh
gmt
[email protected]
gnu-time
gnu-units
gnupg
gnuplot
gnutls
go
[email protected]
goad
godep
goenv
gofabric8
gomplate
goocanvas
goofys
google-benchmark
google-java-format
gopass
govendor
gradle
grafana
grakn
graphicsmagick
gromacs
groonga
groovysdk
grpc
gsmartcontrol
gsoap
gspell
gstreamermm
gtk+3
gtk-gnutella
gucharmap
h2o
hadoop
harfbuzz
hashcat
haxe
hercules
heroku
hevea
highlight
hive
homebrew/science/abinit
homebrew/science/alpscore
homebrew/science/bless
homebrew/science/breseq
homebrew/science/calculix-ccx
homebrew/science/cdo
homebrew/science/cmor
homebrew/science/cp2k
homebrew/science/dealii
homebrew/science/diamond
homebrew/science/dida
homebrew/science/dl_poly_classic
homebrew/science/dssp
homebrew/science/elemental
homebrew/science/etsf_io
homebrew/science/exabayes
homebrew/science/field3d
homebrew/science/flint
homebrew/science/garli
homebrew/science/geant4
homebrew/science/getdp
homebrew/science/gnuastro
homebrew/science/gnudatalanguage
homebrew/science/graph-tool
homebrew/science/igv
homebrew/science/insighttoolkit
homebrew/science/ipopt
homebrew/science/lammps
homebrew/science/libbi
homebrew/science/libminc
homebrew/science/lis
homebrew/science/meme
homebrew/science/mlpack
homebrew/science/moab
homebrew/science/mumps
homebrew/science/nccmp
homebrew/science/nest
homebrew/science/nextflow
homebrew/science/nixio
homebrew/science/ome-common
homebrew/science/ome-files
homebrew/science/ome-xml
homebrew/science/openimageio
homebrew/science/p4est
homebrew/science/parallel-netcdf
homebrew/science/parmetis
homebrew/science/pastix
homebrew/science/petsc
homebrew/science/pulseview
homebrew/science/pykep
homebrew/science/quaff
homebrew/science/quast
homebrew/science/quicktree
homebrew/science/radx
homebrew/science/rapsearch2
homebrew/science/ray
homebrew/science/rstudio-server
homebrew/science/scotch
homebrew/science/scotch5
homebrew/science/scram
homebrew/science/slepc
homebrew/science/superlu_dist
homebrew/science/therion
homebrew/science/trilinos
homebrew/science/unicycler
homebrew/science/xmgredit
homebrew/science/zoltan
html-xml-utils
htmlcleaner
htmldoc
httest
httpd
hugo
hyperscan
hypre
i2p
ibex
ice
icoutils
icu4c
idnits
imagemagick
[email protected]
imapfilter
immortal
infer
influxdb
inspircd
iperf3
ipfs
ironcli
irssi
ispc
itstool
ivykis
jack
jbig2dec
jena
jenkins
jenkins-lts
jfrog-cli-go
jhipster
jmeter
jmxtrans
joe
jruby
json-fortran
juju
kerl
keychain
kibana
knot
knot-resolver
kobalt
kompose
konoha
kops
kotlin
krb5
kubectx
kubernetes-cli
kubernetes-helm
lablgtk
landscaper
languagetool
lapack
lastpass-cli
laszip
latexila
lbdb
ldc
lean-cli
leiningen
lftp
libass
libassuan
libbitcoin-blockchain
libbitcoin-node
libbitcoin-server
libcdr
libcello
libconfig
libcouchbase
libcue
libebur128
libetonyek
libextractor
libfabric
libfaketime
libfixbuf
libfreehand
libgphoto2
libgraphqlparser
libgsf
libhttpseverywhere
libical
liblcf
libmatio
libmaxminddb
libmxml
libogg
libopusenc
libphonenumber
libpng
libpq
libpqxx
librdkafka
libre
libressl
librest
librsync
libsoup
libspectrum
libtensorflow
libtiff
libtorrent-rasterbar
libtrace
libuv
libvirt
libvisio
libwebsockets
libwpd
libwpg
libxml2
libxmlsec1
libxslt
lighttpd
link-grammar
linkerd
liquid-dsp
little-cms2
loc
logrotate
logstalgia
logstash
logtalk
lwtools
lxc
lynis
macvim
mailutils
mairix
mame
mapserver
mariadb
[email protected]
[email protected]
mat
maven
mawk
maxima
mdds
media-info
megacmd
memcached
menhir
mercurial
mesalib-glw
metricbeat
mg
micropython
mighttpd2
mikutter
mingw-w64
minimal-racket
minio-mc
mitie
mkclean
mkdocs
mkvalidator
mkvtoolnix
moc
modd
modules
molecule
monetdb
mongo-c-driver
mongodb
mongoose
monit
mosh
mosquitto
mpd
mpv
multimarkdown
mupdf
mupdf-tools
mvnvm
mypy
mysql
mysql-sandbox
[email protected]
[email protected]
nano
nanomsg
nanomsgxx
nanopb-generator
natalie
nativefier
nats-streaming-server
ncmpc
ncmpcpp
nco
ncrack
ncurses
ncview
neo4j
neovim
netcdf
netpbm
nettle
nfdump
nghttp2
nginx
nickle
node
node-build
[email protected]
[email protected]
nomad
noti
notmuch
nsq
nss
ntl
nuttcp
nvm
ocaml
ocamlbuild
ocamlsdl
octave
ode
offlineimap
omniorb
ompl
opam
open-mpi
open-scene-graph
opencoarrays
opencv
[email protected]
openfortivpn
openjazz
openrtsp
opensaml
openshift-cli
openssl
[email protected]
openvdb
opusfile
ortp
osc
osm2pgrouting
osquery
osrm-backend
pacapt
packer
packetbeat
packetq
paket
pandoc
pandoc-citeproc
pandoc-crossref
pango
paperkey
parallel
passenger
pazpar2
pcb
pcl
pdal
pdfcrack
pdfpc
pdftoedn
pdftoipe
percona-server-mongodb
pgpool-ii
pgroonga
pgrouting
phoronix-test-suite
physfs
pick
pike
pilosa
pioneers
planck
plantuml
pldebugger
pngquant
poco
pony-stable
ponyc
poppler
postgis
postgresql
[email protected]
[email protected]
pqiv
pre-commit
prest
presto
primesieve
proguard
prometheus
protobuf
protobuf-c
protobuf-swift
psftools
psqlodbc
pumba
pure-ftpd
purescript
pushpin
pwntools
py2cairo
py3cairo
pygobject3
pyqt
python-markdown
qcli
qd
qt
qtfaststart
rabbitmq
radare2
rakudo-star
rancid
ratfor
rbenv-bundler
rdfind
re2
re2c
readosm
[email protected]
redex
redpen
regex-opt
reminiscence
resty
ringojs
ripgrep
rom-tools
root
roswell
rpm
rtags
rtv
ruby
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
rust
s-nail
s3cmd
s6
sagittarius-scheme
saltstack
sassc
sbcl
sbt
scala
scalaenv
scalapack
scalastyle
sccache
schismtracker
scipy
scm-manager
scons
screen
sdl2
sdl2_gfx
sdl2_image
sdl2_mixer
sdl_gfx
selenium-server-standalone
shairport-sync
shapelib
shibboleth-sp
shpotify
silk
simgrid
simple-obfs
sip
sjk
skinny
sleuthkit
smali
smartmontools
snakemake
snort
solr
[email protected]
sonarqube
sops
source-to-image
sourcekitten
speedtest-cli
sphinx-doc
sqldiff
sqlite
sqlite-analyzer
sqlmap
src
ssdeep
sslh
sslmate
sslyze
stanford-parser
statik
stoken
streamlink
strongswan
stubby
stunnel
subnetcalc
suil
suite-sparse
sundials
supersonic
suricata
svgo
swfmill
swi-prolog
swiftformat
swiftgen
swiftlint
syncthing
sysbench
taisei
tarantool
task-spooler
tectonic
telegraf
telegram-cli
teleport
temporal_tables
tenyr
terminal-notifier
terraform
terraform-docs
terragrunt
texapp
texmath
tfenv
thefuck
tinc
tintin
tippecanoe
tor
translate-shell
ttyd
txt2tags
typescript
u-boot-tools
uftp
unbound
uncrustify
upscaledb
urh
urlview
userspace-rcu
vagrant-completion
vala
vapoursynth
varnish
[email protected]
vault
vault-cli
vert.x
vim
vips
vpcs
vte3
vtk
watchexec
webpack
wget
when
wildfly-as
wine
winetricks
wireguard-tools
wireshark
wolfssl
wpcli-completion
wtf
wxmaxima
xapian
xclip
xctool
xmake
xmrig
xrootd
xtensor
yadm
yaf
yara
yarn
yash
yaze-ag
ykman
yle-dl
you-get
youtube-dl
yubico-piv-tool
z80dasm
zabbix
zanata-client
zbackup
zenity
zimg
zint
zmqpp
zsh-completions
zstd
zurl
==> Renamed Formulae
findbugs -> spotbugs
newsbeuter -> newsboat
==> Deleted Formulae
homebrew/science/bali-phy
homebrew/science/mbsystem
homebrew/science/pymol
htop-osx
jboss-as
[email protected]
libical-glib
[email protected]

==> brew cask install caskroom/cask/brew-cask 

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
/Library/TeX/texbin/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!