Skip to content
Skillpedia
PDF, Word & slides7.8k · #12907

pandoc-unicode-workaround

What it does

This skill describes a workflow for converting Markdown to PDF when pandoc fails on special characters. It is for people whose documents contain checkmarks, arrows, dashes or similar symbols.

When to use it

  • ✓When pandoc fails to make a PDF with a Unicode or LaTeX error.
  • ✓When the error names a special character such as a checkmark, arrow or em dash.
  • ✓When I need a PDF and can accept plain text versions of the symbols.

Skill link

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-unicode-workaround/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-unicode-workaround/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“My PDF export fails on the checkmarks and arrows in my notes. Replace them with plain text and make the PDF again.”

5 new skills a week. 1 minute to read.

How it works

The AI tries the normal conversion first. If it fails, it replaces special characters with ASCII equivalents from a table and converts again.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Pandoc Unicode Workaround

This skill provides a workflow for generating PDFs from Markdown using pandoc when LaTeX compilation fails due to Unicode character errors.

When to Use

Use this skill when:

  • pandoc document.md -o document.pdf fails with LaTeX/Unicode errors
  • Error messages mention "Unicode character", "LaTeX Error", or specific characters like ✓, →, —, etc.
  • You need to produce PDF output but pandoc's default LaTeX engine cannot handle special characters

Step-by-Step Procedure

Step 1: Attempt Initial PDF Generation

pandoc input.md -o output.pdf

If this succeeds, you're done. If it fails with Unicode/LaTeX errors, proceed to Step 2.

Step 2: Normalize Unicode Characters

Replace problematic Unicode characters with ASCII equivalents. Common replacements:

Unicode Character ASCII Replacement Alternative
✓ (checkmark) [Y] or [X] OK, ✓ removed
✗ or ✘ (cross) [N] FAIL
→ (arrow right) -> =>
← (arrow left) <-
— (em dash) -- or - ---
– (en dash) -
• (bullet) - *
© (copyright) (c) Copyright
® (registered) (R)
™ (trademark) (TM)
… (ellipsis) ...
" (smart quotes) " or '

Step 3: Apply Replacements

Option A - Manual edit: Open the Markdown file and manually replace the characters using find/replace.

Option B - Automated with sed (Linux/Mac):

sed -i 's/✓/[Y]/g' input.md
sed -i 's/✗/[N]/g' input.md
sed -i 's/→/->/g' input.md
sed -i 's/—/--/g' input.md

Option C - Automated with Python:

replacements = {
    '✓': '[Y]',
    '✗': '[N]',
    '→': '->',
    '—': '--',
    '–': '-',
    '…': '...',
    '"': '"',
    '"': '"',
}

with open('input.md', 'r', encoding='utf-8') as f:
    content = f.read()

for orig, repl in replacements.items():
    content = content.replace(orig, repl)

with open('input.md', 'w', encoding='utf-8') as f:
    f.write(content)

Step 4: Regenerate PDF

pandoc input.md -o output.pdf

Step 5: Verify Output

Check that the PDF was generated successfully and review the content to ensure character replacements are acceptable for your use case.

Alternative Approaches

If Unicode normalization is not acceptable:

  1. Use a different PDF engine:

    pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf
    
  2. Use XeLaTeX (better Unicode support):

    pandoc input.md -o output.pdf --pdf-engine=xelatex
    
  3. Add LaTeX packages for Unicode:

    pandoc input.md -o output.pdf -H header.tex
    

    Where header.tex contains:

    \usepackage{fontspec}
    \usepackage{xunicode}
    

Tips

  • Keep the original Markdown file before normalization if you need to preserve characters
  • Document which characters were replaced for future reference
  • Test with a small sample first if working with large documents
  • For Word documents (.docx), Unicode issues are less common; this pattern is primarily for PDF generation

Error Indicators

Common LaTeX Unicode errors to watch for:

  • ! LaTeX Error: Unicode character ... not set up for use with LaTeX
  • Package inputenc Error: Unicode character ... not set up
  • ! Missing character: There is no ... in font ...
FAQ

Does it try the normal conversion first?

Yes, the guide starts with the plain pandoc command and only cleans the text if it fails.

What replaces a checkmark?

The guide suggests a plain marker such as a bracketed Y or X.

Are the replacements listed?

Yes, the guide includes a table that maps each symbol to a plain alternative.

Details

Original description by the author

Handle LaTeX Unicode errors in pandoc PDF generation by normalizing special characters to ASCII

repo: HKUDS/AgentPilot

Popularity

GitHub stars
7.8k
Ranking position
#12907
License
MIT
Updated
11/1/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills