pandoc-pdf-generation by terrylica/cc-skills
npx skills add https://github.com/terrylica/cc-skills --skill pandoc-pdf-generation使用 Pandoc 配合 XeLaTeX 引擎,从 Markdown 生成专业的 PDF 文档。此技能涵盖自动章节编号、目录、参考文献管理、LaTeX 定制以及通过生产使用总结出的常见故障排除模式。
在以下情况使用此技能:
此技能在 ${CLAUDE_PLUGIN_ROOT}/skills/pandoc-pdf-generation/assets/ 目录下提供了经过生产验证的资源:
table-spacing-template.tex - 经过生产调优的 LaTeX 前言(booktabs, colortbl, ToC 修复)build-pdf.sh - 通用自动检测构建脚本/usr/bin/env bash << 'DETECT_EOF'
# 每个项目创建一次符号链接(对 git 友好)
ln -s ${CLAUDE_PLUGIN_ROOT}/skills/pandoc-pdf-generation/assets/build-pdf.sh build-pdf.sh
# 自动检测目录中的单个 .md 文件(默认横向)
./build-pdf.sh
# 纵向模式
./build-pdf.sh --portrait document.md
# 用于 ASCII 图表的等宽字体
./build-pdf.sh --monospace diagrams.md
# 显式指定输入/输出
./build-pdf.sh input.md output.pdf
DETECT_EOF
<details>
<summary>graph-easy 源代码</summary>
</details>
```
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
选项:
| 标志 | 描述 |
|---|---|
--landscape | 横向页面方向(默认) |
--portrait | 纵向页面方向 |
--monospace | 使用 DejaVu Sans Mono 字体 - 适用于 ASCII 图表 |
--hide-details | 从 PDF 中隐藏 <details> 块(例如,graph-easy 源代码) |
-h, --help | 显示帮助信息 |
功能:
references.bib)和 CSL 文件<details> 块用于生成带有蓝色超链接的横向 PDF(不依赖 build-pdf.sh):
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 ${CLAUDE_PLUGIN_ROOT}/skills/pandoc-pdf-generation/assets/table-spacing-template.tex
SKILL_SCRIPT_EOF
关键:切勿手动输入 ASCII 图表。始终使用 itp:graph-easy 技能。
手动 ASCII 艺术会导致 PDF 中对齐问题。graph-easy 技能确保:
# 调用技能生成通用图表
Skill(itp:graph-easy)
# 用于 ADR 架构图
Skill(itp:adr-graph-easy-architect)
同样重要:将注释保持在代码块之外。不要在图表代码块内添加内联注释,如 # contains: file1, file2 - 这会破坏对齐。
使用 --hide-details 从 PDF 输出中移除 <details> 块。这在以下情况下很有用:
<details> 标签在 PDF 中不会渲染为可折叠形式用法:
./build-pdf.sh --hide-details document.md
Markdown 模式:
## 我的章节
```diagram
┌─────┐ ┌─────┐
│ Box │ ──> │ Box │
└─────┘ └─────┘
[Box] -> [Box]
使用 --hide-details 时,整个 <details> 块会从 PDF 输出中剥离,同时在 markdown/HTML 中保持可见。
在认为 PDF"完成"之前,请验证:
生成前:
--number-sections)itp:graph-easy 技能生成生成后:
打印前:
打印前始终让用户审阅 PDF。
打开审阅:
open output.pdf
单面打印(simplex):
lpr -P "PRINTER_NAME" -o Duplex=None output.pdf
双面打印(duplex):
lpr -P "PRINTER_NAME" -o Duplex=DuplexNoTumble output.pdf # 长边装订
lpr -P "PRINTER_NAME" -o Duplex=DuplexTumble output.pdf # 短边装订
查找打印机名称:
lpstat -p -d
切勿未经用户批准就打印 - 如果存在问题,这会浪费纸张。
有关详细信息,请参阅:
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 字体未找到 | 未安装 DejaVu Sans | brew install font-dejavu |
| xelatex 未找到 | 未安装 MacTeX | brew install --cask mactex |
| 表格跨页中断 | 缺少 longtable 包 | 包含 table-spacing-template.tex 前言 |
| 重复的章节编号 | Markdown 中存在手动编号 | 移除手动编号,仅使用 --number-sections |
| ASCII 图表未对齐 | 手动 ASCII 艺术 | 所有图表均使用 graph-easy 技能 |
| 项目符号列表渲染为破折号 | Markdown 格式问题 | 检查列表前是否有适当的空行 |
| 参考文献未渲染 | 缺少 references.bib 文件 | 创建 .bib 文件或移除 --bibliography 标志 |
| PDF 文件大小过大 | 嵌入了字体 | 使用 --pdf-engine-opt=-dEmbedAllFonts=false |
每周安装次数
171
代码仓库
GitHub 星标数
22
首次出现
2026年1月24日
安全审计
安装于
opencode163
gemini-cli158
codex157
github-copilot155
cursor153
amp150
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 ${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/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:
| Flag | Description |
|---|---|
--landscape | Landscape orientation (default) |
--portrait | Portrait orientation |
--monospace | Use DejaVu Sans Mono - ideal for ASCII diagrams |
--hide-details | Hide <details> blocks (e.g., graph-easy source) 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):
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.
/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
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
Skill(itp:graph-easy)
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.
Use --hide-details to remove <details> blocks from PDF output. This is useful when:
<details> tags don't render as collapsible in PDFUsage:
./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.
Before considering a PDF "done", verify:
Pre-Generation:
--number-sections)itp:graph-easy skillPost-Generation:
Pre-Print:
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.
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 |
| ASCII diagram misaligned | Manual ASCII art | Use graph-easy skill for all diagrams |
| Bullet list renders as dashes | Markdown formatting issue | Check for proper blank lines before lists |
| Bibliography not rendering | Missing references.bib |
Weekly Installs
171
Repository
GitHub Stars
22
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode163
gemini-cli158
codex157
github-copilot155
cursor153
amp150
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
33,600 周安装
| Create .bib file or remove --bibliography flag |
| PDF file size too large | Embedded fonts | Use --pdf-engine-opt=-dEmbedAllFonts=false |