npx skills add ...
npx skills add terrylica/cc-skills --skill pandoc-pdf-generation
PDF generation from markdown via Pandoc/XeLaTeX. TRIGGERS - markdown for PDF, print document, pandoc
npx skills add terrylica/cc-skills --skill pandoc-pdf-generation
Self-Evolving Skill: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.
Generate professional PDF documents from Markdown using Pandoc with the XeLaTeX engine. This skill covers automatic section numbering, table of contents, bibliography management, LaTeX customization, and common troubleshooting patterns learned through production use.
Use this skill when:
This skill provides production-proven assets in $(cc-plugin-root doc-tools)/skills/pandoc-pdf-generation/assets/:
table-spacing-template.tex - Production-tuned LaTeX preamble (booktabs, colortbl, ToC fixes)build-pdf.sh - Universal auto-detecting build scriptOptions:
| Flag | Description |
|---|---|
--landscape | Landscape orientation (default) |
--portrait | Portrait orientation |
--monospace | Use DejaVu Sans Mono - ideal for ASCII diagrams |
--hide-details | Hide <details> blocks from PDF |
-h, --help | Show help message |
Features:
references.bib) and CSL files<details> blocks from PDF outputFor landscape PDFs with blue hyperlinks (no build-pdf.sh dependency):
Use landscape for: Wide data tables, comparison matrices, technical docs with code blocks.
ASCII diagrams need consistent character alignment to survive PDF rendering: use box-drawing characters consistently and keep every row the same width.
Also important: Keep annotations OUTSIDE code blocks. Don't add inline comments like # contains: file1, file2 inside diagram code blocks - they break alignment.
Use --hide-details to remove <details> blocks from PDF output. This is useful when:
<details> tags don't render as collapsible in PDFUsage:
Markdown pattern:
With --hide-details, the entire <details> block is stripped from PDF output while remaining visible in markdown/HTML.
Before considering a PDF "done", verify:
Pre-Generation:
--number-sections)Post-Generation:
Pre-Print:
Always let the user review the PDF before printing.
Open for review:
Print one-sided (simplex):
Print two-sided (duplex):
Find printer name:
Never print without user approval - this wastes paper if issues exist.
For detailed information, see:
| Issue | Cause | Solution |
|---|---|---|
| Font not found | DejaVu Sans not installed | brew install font-dejavu |
| xelatex not found | MacTeX not installed | brew install --cask mactex |
| Table breaks across pages | Missing longtable package | Include table-spacing-template.tex preamble |
| Double section numbers | Manual numbering in markdown | Remove manual numbers, use --number-sections only |
| Bullet list renders as dashes | Markdown formatting issue | Check for proper blank lines before lists |
| Bibliography not rendering | Missing references.bib | Create .bib file or remove --bibliography flag |
| PDF file size too large | Embedded fonts | Use --pdf-engine-opt=-dEmbedAllFonts=false |
After this skill completes, check before closing:
Only update if the issue is real and reproducible — not speculative.
pandoc file.md -o file.pdf \
--pdf-engine=xelatex \
-V geometry:a4paper,landscape \
-V geometry:margin=1in \
-V fontsize=11pt \
-V mainfont="DejaVu Sans" \
-V colorlinks=true \
-V linkcolor=blue \
-V urlcolor=blue \
--toc --toc-depth=2 \
--number-sections/usr/bin/env bash << 'SKILL_SCRIPT_EOF'
pandoc document.md \
-o document.pdf \
--pdf-engine=xelatex \
--toc \
--toc-depth=3 \
--number-sections \
-V geometry:margin=1in \
-V mainfont="DejaVu Sans" \
-H "$(cc-plugin-root doc-tools)/skills/pandoc-pdf-generation/assets/table-spacing-template.tex"
SKILL_SCRIPT_EOF./build-pdf.sh --hide-details document.mdopen output.pdflpr -P "PRINTER_NAME" -o Duplex=None output.pdflpr -P "PRINTER_NAME" -o Duplex=DuplexNoTumble output.pdf # Long-edge binding
lpr -P "PRINTER_NAME" -o Duplex=DuplexTumble output.pdf # Short-edge bindinglpstat -p -d