Skip to content
pandoc-pdf-generation logo

Pandoc PDF Generation

pandoc-pdf-generation

PDF generation from markdown via Pandoc/XeLaTeX. TRIGGERS - markdown for PDF, print document, pandoc

terrylica/cc-skills0installs75stars

SKILL.md

Full skill instructions

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 ${CLAUDE_PLUGIN_ROOT}/​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 ${CLAUDE_PLUGIN_ROOT}/​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:

FlagDescription
--landscapeLandscape orientation (default)
--portraitPortrait orientation
--monospaceUse DejaVu Sans Mono - ideal for ASCII diagrams
--hide-detailsHide <details> blocks (e.g., graph-easy source) from PDF
-h, --helpShow 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 ${CLAUDE_PLUGIN_ROOT}/​skills/​pandoc-pdf-generation/​assets/​table-spacing-template.tex
SKILL_SCRIPT_EOF

ASCII Diagrams: Always Use graph-easy

CRITICAL: Never manually type ASCII diagrams. Always use the itp:graph-easy skill.

Manual ASCII art causes alignment issues in PDFs. The graph-easy skill ensures:

  • Proper boxart character alignment
  • Consistent spacing
  • Reproducible output
# Invoke the skill for general diagrams
Skill(itp:graph-easy)

# For ADR architecture diagrams
Skill(itp:adr-graph-easy-architect)

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:

  • graph-easy 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 │
└─────┘     └─────┘
```
<details> <summary>graph-easy source</​summary>
[Box] -> [Box]

</​details>


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`)
- [ ] All ASCII diagrams generated via `itp:graph-easy` skill
- [ ] 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:**

```bash
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:


Troubleshooting

IssueCauseSolution
Font not foundDejaVu Sans not installedbrew install font-dejavu
xelatex not foundMacTeX not installedbrew install --cask mactex
Table breaks across pagesMissing longtable packageInclude table-spacing-template.tex preamble
Double section numbersManual numbering in markdownRemove manual numbers, use --number-sections only
ASCII diagram misalignedManual ASCII artUse graph-easy skill for all diagrams
Bullet list renders as dashesMarkdown formatting issueCheck for proper blank lines before lists
Bibliography not renderingMissing references.bibCreate .bib file or remove --bibliography flag
PDF file size too largeEmbedded fontsUse --pdf-engine-opt=-dEmbedAllFonts=false

Post-Execution Reflection

After this skill completes, check before closing:

  1. Did the command succeed? — If not, fix the instruction or error table that caused the failure.
  2. Did parameters or output change? — If the underlying tool's interface drifted, update Usage examples and Parameters table to match.
  3. 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.

More skills from terrylica

code-hardcode-audit logo
terrylica/cc-skills

code-hardcode-audit

Detect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.

75 152
View
calcom-access logo
terrylica/cc-skills

calcom-access

Access Cal.com API via CLI with 1Password API key. Use when user wants to list bookings, create event types, manage schedules, or.

75 0
View
schema-e2e-validation logo
terrylica/cc-skills

schema-e2e-validation

Earthly E2E validation for YAML schema contracts. TRIGGERS - schema validation, YAML schema, schema contracts, regenerate types.

75 0
View
glossary-management logo
terrylica/cc-skills

glossary-management

Manage terminology glossary with Vale. TRIGGERS - sync terms, glossary validation, add terms, Vale vocabulary.

75 0
View
log-reader logo
terrylica/cc-skills

log-reader

Read MetaTrader 5 log files. TRIGGERS - MT5 logs, Experts pane, indicator errors, compilation errors.

75 0
View
daemon-start logo
terrylica/cc-skills

daemon-start

Start the asciinema chunker daemon. TRIGGERS - start daemon, resume chunker, enable backup.

75 0
View
sred-commit logo
terrylica/cc-skills

sred-commit

Create a git commit with SR&ED (CRA tax credit) trailers. TRIGGERS - sred commit, sred, cra commit, tax credit commit, scientific research commit.

75 0
View
doppler-workflows logo
terrylica/cc-skills

doppler-workflows

Manage credentials and secrets through Doppler for publishing and deployment workflows. Use whenever the user needs to publish Python packages.

75 0
View
distributed-job-safety logo
terrylica/cc-skills

distributed-job-safety

Concurrency safety patterns for distributed pueue + mise + systemd-run job pipelines.

75 0
View
diagnose logo
terrylica/cc-skills

diagnose

Diagnose Kokoro TTS issues. TRIGGERS - kokoro not working, tts diagnose, kokoro error, tts troubleshoot.

75 0
View
bootstrap-monorepo logo
terrylica/cc-skills

bootstrap-monorepo

Autonomous polyglot monorepo bootstrap meta-prompt on the moon + proto + Bun stack (Nx-convergent). TRIGGERS - new monorepo, new repository, polyglot setup, scaffold repo, moon proto bootstrap, monorepo from scratch.

75 0
View
fork-intelligence logo
terrylica/cc-skills

fork-intelligence

Discover valuable GitHub fork divergence beyond stars. TRIGGERS - fork analysis, fork intelligence, find forks

75 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View