
pandoc-pdf-generation
PDF generation from markdown via Pandoc/XeLaTeX. TRIGGERS - markdown for PDF, print document, pandoc
- Installs
- 547
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/terrylica/cc-skills --skill pandoc-pdf-generation- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads pandoc-pdf-generation automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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.
Overview
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.
When to Use This Skill
Use this skill when:
- Converting Markdown to PDF with professional formatting requirements
- Needing automatic section numbering and table of contents
- Managing citations and bibliographies without manual duplication
- Controlling table formatting and page breaks in LaTeX output
- Building automated PDF generation workflows
Quick Start: Universal Build Script
Single Source of Truth Pattern
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 script
From Any Project
/usr/bin/env bash << 'DETECT_EOF'
# Create symlink once per project (git-friendly)
ln -s "$(cc-plugin-root doc-tools)/skills/pandoc-pdf-generation/assets/build-pdf.sh" build-pdf.sh
# Auto-detect single .md file in directory (landscape default)
./build-pdf.sh
# Portrait mode
./build-pdf.sh --portrait document.md
# Monospace font for ASCII diagrams
./build-pdf.sh --monospace diagrams.md
# Explicit input/output
./build-pdf.sh input.md output.pdf
DETECT_EOF
Options:
| 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:
- ✅ Auto-detects input file (if single .md exists)
- ✅ Auto-detects bibliography (
references.bib) and CSL files - ✅ Always uses production-proven LaTeX preamble from skill
- ✅ Pre-flight checks (pandoc, xelatex, files exist)
- ✅ Post-build validation (file size, page count)
- ✅ Code blocks stay on same page (no splitting across pages)
- ✅ Lua filter to hide
<details>blocks from PDF output
Landscape PDF (Quick Command)
For landscape PDFs with blue hyperlinks (no build-pdf.sh dependency):
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
Use landscape for: Wide data tables, comparison matrices, technical docs with code blocks.
Manual Command (With LaTeX Preamble)
/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
ASCII Diagrams
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.
Hiding Content for PDF Output
Use --hide-details to remove <details> blocks from PDF output. This is useful when:
- Diagram source blocks: Keep source in markdown for diagram regeneration, but hide from printed PDFs
- Technical implementation notes: Show in web/markdown view, hide from printed handouts
- Collapsible sections: HTML
<details>tags don't render as collapsible in PDF
Usage:
./build-pdf.sh --hide-details document.md
Markdown pattern:
## My Section
```diagram
┌─────┐ ┌─────┐
│ Box │ ──> │ Box │
└─────┘ └─────┘
```
[Box] -> [Box]
With --hide-details, the entire <details> block is stripped from PDF output while remaining visible in markdown/HTML.
Verification Checklist
Before considering a PDF "done", verify:
Pre-Generation:
- No manual section numbering in markdown (use
--number-sections) - Annotations are outside code blocks, not inside
Post-Generation:
- Open PDF and visually inspect each page
- Verify diagrams don't break across pages
- Check section numbering is correct (no "1. 1. Title" duplication)
- Confirm bullet lists render as bullets, not inline dashes
Pre-Print:
- Get user approval before printing
- Confirm orientation preference (landscape/portrait)
- Confirm duplex preference (one-sided/two-sided)
Printing Workflow
Always let the user review the PDF before printing.
Open for review:
open output.pdf
Print one-sided (simplex):
lpr -P "PRINTER_NAME" -o Duplex=None output.pdf
Print two-sided (duplex):
lpr -P "PRINTER_NAME" -o Duplex=DuplexNoTumble output.pdf # Long-edge binding
lpr -P "PRINTER_NAME" -o Duplex=DuplexTumble output.pdf # Short-edge binding
Find printer name:
lpstat -p -d
Never print without user approval - this wastes paper if issues exist.
Reference Documentation
For detailed information, see:
- Core Development Principles - START HERE - Universal principles learned from production failures
- Markdown for PDF - Markdown structure patterns for clean landscape PDFs
- YAML Front Matter Structure - YAML metadata patterns
- LaTeX Customization - Preamble and table formatting
- Bibliography & Citations - BibTeX and CSL styles
- Document Patterns - Document type templates
- Troubleshooting - Common issues and fixes
Troubleshooting
| 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 |
Post-Execution Reflection
After this skill completes, check before closing:
- Did the command succeed? — If not, fix the instruction or error table that caused the failure.
- Did parameters or output change? — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
- Was a workaround needed? — If you had to improvise (different flags, extra steps), update this SKILL.md so the next invocation doesn't need the same workaround.
Only update if the issue is real and reproducible — not speculative.
FAQ
What does the pandoc-pdf-generation skill do?
PDF generation from markdown via Pandoc/XeLaTeX. TRIGGERS - markdown for PDF, print document, pandoc
How do I install pandoc-pdf-generation?
Run npx skills add https://github.com/terrylica/cc-skills --skill pandoc-pdf-generation in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/pandoc-pdf-generation/ (personal) or .claude/skills/pandoc-pdf-generation/ (project).
Which AI agents can use pandoc-pdf-generation?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is pandoc-pdf-generation safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains pandoc-pdf-generation?
It is published by terrylica in terrylica/cc-skills. It has 547 recorded installs.
More from terrylica/cc-skills
mise-tasks
terrylica/cc-skills
Orchestrate multi-step project workflows using mise task definitions with dependency management and argument handling. Use whenever the user.
mql5-indicator-patterns
terrylica/cc-skills
MQL5 indicator development patterns. TRIGGERS - MQL5 indicator, OnCalculate, indicator buffers, MetaTrader 5.
python-logging-best-practices
terrylica/cc-skills
Python logging with loguru, structlog, and orjson. TRIGGERS - loguru, structlog, structured logging
gdrive-access
terrylica/cc-skills
Access Google Drive via CLI with 1Password OAuth: list files, download, and sync folders. TRIGGERS - google drive, gdrive, drive folder, download drive, sync drive.
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.
writing-fragments
mattpocock/skills
Writing, explore: mine raw fragments, no structure yet.
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.