I write my homework in markdown and my professors usually want pdfs. Here’s what I do

Install dependencies

# Install homebrew from https://brew.sh/
brew install pandoc
brew install basictex

# Add /Library/TeX/texbin to your path (varies by shell, here's how for bash) so pandoc can find pdflatex
export PATH=$PATH:/Library/TeX/texbin

Do it

pandoc -f markdown-implicit_figures -t pdf file.md > file.pdf

Explanation

-f means from

You can also just use markdown but your images will be moved around like in latex which I generally don’t want.

-t means to

> redirect output to file.pdf

homebrew

This is the main macOS package manager. If you do any programming on macOS you’ll need it eventually. Follow the instruction on their homepage to install.

pandoc

“If you need to convert files from one markup format into another, pandoc is your swiss-army knife…”

basictex

basictex provides pdflatex, a lib needed by pandoc to convert markdown -> pdf