Generate a LaTeX-based PDF from Markdown
Generating a PDF from Markdown requires Pandoc and a LaTeX engine. This guide covers the full process: converting Obsidian or Markdown notes into a clickable, navigable PDF with table of contents, headings, and custom headers/footers.
Unlike a simple “Export to PDF” in Obsidian, this method ensures:
- Clickable table of contents
- PDF bookmarks for headings
- Unicode support
- Custom footers and headers
- Full control over layout and fonts
You can run this pipeline locally on Windows, macOS, or Linux. It works with:
- Markdown files exported from Obsidian
- Any standard Markdown source
- Optional LaTeX customization
You must have a LaTeX distribution installed (MiKTeX, TeX Live, or MacTeX) and your binaries accessible via PATH. Pandoc cannot produce PDFs without a LaTeX engine.
Prerequisites
- Pandoc installed and accessible from the terminal
- LaTeX distribution installed, used MikTeX for Windows here
Check installations
pandoc --version
pdflatex --versionOn Windows, ensure your project path is short to avoid issues during compilation (e.g., C:\GitHub\notes).
Configure Your LaTeX Header (Optional)
For headers, footers, fonts, and page numbering, create a LaTeX header file, e.g., header.tex:
1. Create header.tex
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyfoot[C]{\thepage}
\fancyhead[L]{My Markdown Notes}
\fancyhead[R]{Generated PDF}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}2. Place header.tex in your working directory
This file will be included in the Pandoc build command.
Generate the PDF
1. Basic PDF generation
pandoc "YourNote.md" -o "YourNote.pdf" --toc --pdf-engine=xelatex--tocgenerates a clickable table of contents--pdf-engine=xelatexensures Unicode support and modern font handling
2. PDF generation with custom LaTeX header
pandoc "YourNote.md" -o "YourNote.pdf" --toc --pdf-engine=xelatex -H header.texThis applies your custom headers, footers, and layout.
Notes on File Organization
- Multiple Markdown files: you can combine them in order:
pandoc chapter1.md chapter2.md chapter3.md -o fullbook.pdf --toc --pdf-engine=xelatex -H header.tex-
Unicode symbols: XeLaTeX or LuaLaTeX is required;
pdflatexcannot handle non-ASCII symbols. -
Font customization: set the main font via Pandoc variable:
pandoc "YourNote.md" -o "YourNote.pdf" --toc --pdf-engine=xelatex -V mainfont="Latin Modern Roman" -H header.texVerification
After compilation:
-
Open the PDF
-
Verify that:
-
Table of contents links work
-
Headings are clickable
-
Custom headers and footers appear
-
Unicode symbols render correctly
Keep a consistent workflow directory structure for Obsidian notes, headers, and output PDFs to simplify repeated builds.
Created: 25.01.2026
Last Updated: 25.01.2026