复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-pandoc-pdf-error-resolution-5761d4e1ef3a ,按照其中的说明把「pandoc-pdf-error-resolution」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
This skill provides a step-by-step workflow for diagnosing and resolving "unknown error" messages when using pandoc to generate PDFs.
Use this skill when:
First, confirm pandoc is installed and check its version:
pandoc --version
This confirms pandoc is available and shows the version number. Note that pandoc itself doesn't generate PDFs directly—it delegates to external PDF engines.
Identify which PDF engines are installed on the system:
which pdflatex xelatex lualatex wkhtmltopdf pdfroff 2>/dev/null || echo "Checking individual engines..."
which pdflatex
which xelatex
which lualatex
which wkhtmltopdf
Common engines and their characteristics:
Retry the conversion with an explicit --pdf-engine flag:
pandoc input.md -o output.pdf --pdf-engine=xelatex
Try engines in this order:
xelatex (best Unicode support)pdflatex (most widely available)lualatex (if xelatex fails)wkhtmltopdf (for HTML-heavy content)Always capture the complete error output before falling back:
pandoc input.md -o output.pdf --pdf-engine=xelatex 2>&1 | tee pandoc_error.log
This preserves the full error message for analysis. Common error patterns:
tlmgr install <package>)If errors indicate missing LaTeX packages:
# For TeX Live
tlmgr install <package-name>
# For Debian/Ubuntu
apt-get install texlive-latex-extra texlive-fonts-recommended
# For macOS with Homebrew
brew install --cask mactex
If all engines fail, consider:
#!/bin/bash
# pandoc-pdf-debug.sh
INPUT_FILE="$1"
OUTPUT_FILE="${INPUT_FILE%.md}.pdf"
echo "=== Pandoc PDF Conversion Debug ==="
echo "Input: $INPUT_FILE"
echo "Output: $OUTPUT_FILE"
# Step 1: Verify pandoc
echo -e "\n[1] Checking pandoc version..."
pandoc --version | head -1
# Step 2: Check engines
echo -e "\n[2] Checking available PDF engines..."
for engine in pdflatex xelatex lualatex wkhtmltopdf; do
if which "$engine" &>/dev/null; then
echo " ✓ $engine: $(which $engine)"
else
echo " ✗ $engine: not found"
fi
done
# Step 3: Try conversion with xelatex
echo -e "\n[3] Attempting conversion with xelatex..."
pandoc "$INPUT_FILE" -o "$OUTPUT_FILE" --pdf-engine=xelatex 2>&1 | tee /tmp/pandoc_error.log
if [ $? -eq 0 ]; then
echo "✓ Conversion successful!"
else
echo "✗ Conversion failed. Check /tmp/pandoc_error.log for details"
echo "Attempting fallback with pdflatex..."
pandoc "$INPUT_FILE" -o "$OUTPUT_FILE" --pdf-engine=pdflatex 2>&1
fi
| Command | Purpose |
|---|---|
pandoc --version | Verify pandoc installation |
which xelatex | Check if xelatex engine exists |
pandoc file.md -o file.pdf --pdf-engine=xelatex | Convert with explicit engine |
... 2>&1 | tee error.log | Capture full stderr output |
tlmgr install <pkg> | Install missing LaTeX package |