跳到正文
Skillpedia
PDF、Word 与幻灯片7.8k · #12904

pandoc-pdf-error-recovery

它能做什么

这项技能是针对 pandoc PDF 转换失败(提示模糊)的分步恢复方案。适合需要生成 PDF 却无法让 pandoc 完成转换的人。

适用场景

  • ✓当 pandoc 生成 PDF 失败、且只给出模糊提示时。
  • ✓当电脑上没有安装 pandoc 或找不到它时。
  • ✓当我想用指定的引擎(例如 xelatex)生成 PDF 时。

技能链接

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-pdf-error-recovery/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-pdf-error-recovery/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我:我的 pandoc PDF 转换失败,只提示模糊的错误。请逐步带我恢复,并得到一个可用的 PDF。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 确认 pandoc 已安装,查找哪些 PDF 引擎可用,记录全部输出的同时用 xelatex 重试,然后根据日志决定下一步修复。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Pandoc PDF Error Recovery

Overview

When pandoc fails to convert documents to PDF with an "unknown error" or similar vague message, follow this systematic diagnostic and recovery workflow.

Step-by-Step Procedure

1. Verify Pandoc Installation

First confirm pandoc is installed and accessible:

pandoc --version

If this fails, install pandoc before proceeding:

2. Check Available PDF Engines

Identify which PDF rendering engines are available on the system:

which pdflatex xelatex lualatex wkhtmltopdf context

Common engines and their typical use cases:

  • pdflatex: Standard LaTeX, fast but limited Unicode support
  • xelatex: Full Unicode support, recommended for most modern documents
  • lualatex: Lua scripting support, good for complex layouts
  • wkhtmltopdf: HTML/CSS rendering, good for web-style documents
  • context: ConTeXt typesetting system

3. Attempt Conversion with Explicit Engine

Try conversion with xelatex first (most versatile for general documents):

pandoc input.md -o output.pdf --pdf-engine=xelatex 2>&1 | tee conversion.log

The 2>&1 | tee pattern captures both stdout and stderr to a log file for analysis.

4. Analyze Error Output

If conversion fails, examine the captured log:

cat conversion.log

Common error patterns and solutions:

  • Missing LaTeX packages: Install with tlmgr install <package> or system package manager
  • Font issues: Specify fonts with -V mainfont="Font Name"
  • Missing engine: Fall back to available engine (go to Step 5)

5. Try Alternative Engines

Systematically try other available engines:

# Fallback to pdflatex
pandoc input.md -o output.pdf --pdf-engine=pdflatex 2>&1 | tee conversion-pdflatex.log

# Or try wkhtmltopdf for HTML-rich content
pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf 2>&1 | tee conversion-wkhtmltopdf.log

# Or try lualatex for complex documents
pandoc input.md -o output.pdf --pdf-engine=lualatex 2>&1 | tee conversion-lualatex.log

6. Install Missing Dependencies

If all engines fail or are missing, install required packages:

# Full TeX Live installation (comprehensive but large)
sudo apt-get install texlive-full

# Or minimal installation with common packages
sudo apt-get install texlive-latex-base texlive-fonts-recommended

# For xelatex font support
sudo apt-get install fonts-noto fonts-dejavu

7. Simplify and Retry

If errors persist, try conversion with minimal options:

pandoc input.md -o output.pdf --pdf-engine=xelatex --standalone

Remove complex formatting, custom headers, or advanced LaTeX features that may be causing issues.

Quick Reference Command

Complete diagnostic one-liner:

pandoc --version && which pdflatex xelatex wkhtmltopdf && pandoc input.md -o output.pdf --pdf-engine=xelatex -v

Tips

  • Always capture stderr (2>&1) to see the actual error message
  • Use -v (verbose) flag for more detailed output during troubleshooting
  • For non-English documents, xelatex or lualatex are usually required
  • HTML/CSS-heavy documents may work better with wkhtmltopdf
  • Check system disk space - PDF generation can require significant temporary space
常见问题

pandoc 怎样安装?

指南列出了 macOS 下使用 brew、Linux 下使用 apt 或 yum 的安装命令,以及 Windows 的下载链接。

指南列出了哪些 PDF 引擎?

指南列出了 pdflatex、xelatex、lualatex、wkhtmltopdf 和 ConTeXt。

日志文件有什么用?

它保存完整的输出,便于找出失败的步骤。

详情

作者的原始描述

Systematic approach to diagnose and recover from pandoc PDF conversion unknown errors

repo: HKUDS/AgentPilot

热度

GitHub 星标
7.8k
排名
#12904
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能