Skip to content

Instantly share code, notes, and snippets.

@dcchambers
Last active September 5, 2024 07:02
Show Gist options
  • Save dcchambers/9761c71880114cc604c902b30b2e06c8 to your computer and use it in GitHub Desktop.
Save dcchambers/9761c71880114cc604c902b30b2e06c8 to your computer and use it in GitHub Desktop.
Generate a PDF from Markdown files with Pandoc

Generate a PDF from a Markdown file with Pandoc

Easy Steps For Mac OS

  1. Have Homebrew installed and a markdown file you want to render to PDF.
  2. Install Pandoc brew install pandoc
  3. Install basictex brew cask install basictex - needed for the pdflatex tool.
  4. Symlink the pdflatex to your /usr/local/bin so pandoc can easily find it. ln -s /Library/TeX/Root/bin/x86_64-darwin/pdflatex /usr/local/bin/pdflatex
  5. Use Pandoc to generate a PDF from a Markdown file. pandoc input.md -o output.pdf
    • By default the margins are pretty large. To optionally change the margins: pandoc input.md -o output.pdf -V geometry:margin=1in
@mxr
Copy link

mxr commented Apr 11, 2023

I ran the above successfully with the following changes

  • Replace brew cask install basictex with brew install basictex --cask because brew cask is no longer a brew command
  • Instead of symlinking, you can open a new terminal window or refresh the path with eval "$(/usr/libexec/path_helper)" (this is what the installer suggests here)

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