---
name: md2pdf
description: Convert Markdown files to PDF using Pandoc. Use when the user wants to export, convert, or generate a PDF from a .md file. Triggers: "convert md to pdf", "export pdf", "markdown to pdf", "generate pdf from markdown", "md to pdf", "导出PDF", "转成PDF", "markdown转pdf", "生成PDF".
Convert Markdown files to beautifully typeset PDF using Pandoc + LaTeX.
winget install pandoc or winget install MiKTeX or winget install TeXLive for TeX LiveThe script auto-detects available engines in order: xelatex > lualatex > pdflatex.
Run the bundled script:
python scripts/md2pdf.py <input.md> [output.pdf]
Options:
--toc — Include table of contents--css — Apply custom CSS stylesheet--highlight — Code highlight style (default: tango)The script applies these defaults when using XeLaTeX/LuaLaTeX (the preferred engines):
.md file exists and is readablescripts/md2pdf.py with appropriate optionsFor options not covered by the script, call pandoc directly:
# Custom LaTeX template
pandoc input.md -o output.pdf --pdf-engine=xelatex --template=custom.tex
# Specific page size
pandoc input.md -o output.pdf --pdf-engine=xelatex -V geometry:margin=2cm -V papersize:a4
# Metadata
pandoc input.md -o output.pdf --pdf-engine=xelatex -V title="My Report" -V author="Author"
共 1 个版本