md2pdf

majiayu000's avatarfrom majiayu000

Convert a markdown file to PDF using pandoc

0stars🔀0forks📁View on GitHub🕐Updated Jan 5, 2026

When & Why to Use This Skill

The md2pdf Claude skill automates the conversion of Markdown files into professionally formatted PDF documents using Pandoc. It streamlines the document workflow by handling environment checks, LaTeX engine requirements, and advanced styling options—such as custom margins, table of contents, and syntax highlighting—ensuring high-quality output with minimal manual configuration.

Use Cases

  • Technical Documentation: Transform README.md or project guides into polished, shareable PDF manuals for clients and stakeholders.
  • Professional Reporting: Generate structured business reports from Markdown notes with automatic table of contents and consistent typography.
  • Batch Processing: Efficiently convert multiple Markdown files within a directory into PDFs for archiving or distribution in one command.
  • Academic & Technical Writing: Create high-quality documents featuring LaTeX-based typesetting and syntax-highlighted code blocks for research and development papers.
namemd2pdf
descriptionConvert a markdown file to PDF using pandoc

md2pdf

Convert markdown files to professionally formatted PDF documents using pandoc.

Instructions

When the user asks to convert a markdown file to PDF, follow these steps:

  1. Verify pandoc is installed

    • Run pandoc --version to check if pandoc is available
    • If not installed, provide installation instructions for the user's platform:
  2. Check for PDF engine

    • Pandoc requires a PDF engine (LaTeX). Check if available with pdflatex --version
    • If not installed:
      • macOS: brew install --cask mactex-no-gui (smaller) or brew install --cask mactex (full)
      • Linux: sudo apt-get install texlive-latex-base texlive-fonts-recommended
      • Alternative: Use wkhtmltopdf as PDF engine
  3. Convert the markdown file

    • Basic conversion: pandoc input.md -o output.pdf
    • With options for better formatting:
      pandoc input.md -o output.pdf \
        --pdf-engine=pdflatex \
        -V geometry:margin=1in \
        -V fontsize=11pt \
        --highlight-style=tango
      
  4. Common options

    • --toc: Add table of contents
    • --toc-depth=2: Set TOC depth
    • -V geometry:margin=1in: Set page margins
    • -V fontsize=11pt: Set font size (10pt, 11pt, 12pt)
    • --highlight-style=tango: Syntax highlighting for code blocks
    • -V colorlinks=true: Enable colored links in PDF
    • --metadata title="Document Title": Set PDF title
    • --metadata author="Author Name": Set PDF author
  5. Verify output

    • Confirm the PDF was created successfully
    • Report the output file path to the user

Examples

Example 1: Basic conversion

User: Convert README.md to PDF
Assistant: I'll convert README.md to PDF using pandoc.

[Runs: pandoc README.md -o README.pdf]

Successfully converted README.md to README.pdf

Example 2: Conversion with formatting options

User: Convert CLAUDE.md to PDF with a table of contents
Assistant: I'll convert CLAUDE.md to PDF with a table of contents and formatting.

[Runs: pandoc CLAUDE.md -o CLAUDE.pdf --toc -V geometry:margin=1in -V fontsize=11pt]

Successfully converted CLAUDE.md to CLAUDE.pdf with table of contents

Example 3: Converting with custom output name

User: Convert docs/guide.md to a PDF called user-guide.pdf
Assistant: I'll convert docs/guide.md to user-guide.pdf

[Runs: pandoc docs/guide.md -o user-guide.pdf -V geometry:margin=1in --highlight-style=tango]

Successfully converted docs/guide.md to user-guide.pdf

Example 4: Batch conversion

User: Convert all markdown files in the docs/ folder to PDF
Assistant: I'll convert all markdown files in docs/ to PDF

[Runs: for file in docs/*.md; do pandoc "$file" -o "${file%.md}.pdf"; done]

Successfully converted:
- docs/guide.md → docs/guide.pdf
- docs/api.md → docs/api.pdf
- docs/tutorial.md → docs/tutorial.pdf

Troubleshooting

  • If pandoc is not installed, guide the user to install it first
  • If PDF engine is missing, suggest installing LaTeX or using an alternative engine
  • For large documents, add --pdf-engine-opt=-shell-escape if needed
  • If images are not rendering, ensure image paths are correct and accessible
md2pdf – AI Agent Skills | Claude Skills