Installation
- Install Pandoc
brew install pandoc- Install BasicTex for PDF generation
BasicTex (2GB) is smaller than MacText (110MB) and it’s enough for this task.
brew cask install basictexln -s /Library/TeX/Distributions/.DefaultTeX/Contents/Programs/x86_64/pdflatex /usr/local/binUsage
Generating a PDF file from multiple markdown files is very simple.
pandoc *.md -o docs.pdfCode blocks
By default, code blocks are not wrapped. If you have a code block with very long lines (longer than PDF document width), they will be cut off.
![]()
To fix this issue, you need fvextra extension. You can download it from GitHub.
wget https://raw.githubusercontent.com/gpoore/fvextra/master/fvextra/fvextra.styStore the file in the directory where you want to execute the pandoc command.
Modify the markdown file where you have code blocks and add YAML header options at the top of the file:
---header-includes: - \usepackage{fvextra} - \DefineVerbatimEnvironment{Highlighting}{Verbatim}{breaklines,commandchars=\\\{\}}---
...You can generate a PDF file once again with wrapped code blocks.
pandoc *.md -o docs.pdf