Latex formula extraction

From XuShuwenn/RedAct · View interactive version

Latex formula extraction is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Extract LaTeX formulas from PDF research papers, fixing display syntax errors while preserving original content.

How to use this skill

Skill file

LaTeX Formula Extraction from PDF

When to Use

Execution Priorities

Input

Runtime Checks

Extraction Steps

  1. Review the PDF page by page and identify every standalone display formula candidate, including unnumbered and multi-line formulas.
  2. Extract each formula as raw LaTeX in $$ ... $$.
  3. Preserve the exact displayed content from the PDF only when symbols and structure are clearly supported by readable extraction output or direct page inspection.
  4. Remove equation tags, commas, and periods at the end of formulas only when they are not part of the math content.
  5. Check each extracted formula for syntax/display issues only after the displayed formula has been reliably identified from the PDF.
  6. Append corrected versions only for formulas with clear syntax/display problems.
  7. If output is blank, truncated, garbled, fragmented, or mixes prose into equations, switch methods instead of inferring missing math.
  8. As soon as you have a workable draft, write /root/latex_formula_extraction.md, then verify the file exists and that each formula is in its own $$...$$ block.
  9. Do not declare completion until all pages containing standalone formulas have been inspected.

Evidence and Verification

Output Format

Markdown file /root/latex_formula_extraction.md:

$$original_formula_1$$
$$original_formula_2$$

$$fixed_formula_1$$
$$fixed_formula_2$$
...

Write the final result to exactly /root/latex_formula_extraction.md; do not substitute JSON, reports, or code files for this artifact.

Write one formula per line in $$...$$ markdown display form, with extracted originals first and fixed versions after them only when needed.

Before finishing, verify the file exists, is non-empty, and contains only the extracted display formulas in the required $$...$$ format.

Fix Types

Tips

Completion Checklist

Completion Checklist

Execution Workflow

Execution Workflow

  1. Start with a lightweight, inspectable method first (for example, pdfplumber or PyMuPDF).
  2. Validate on 1-2 sample pages before scaling up: confirm displayed formulas are readable and not corrupted prose, Unicode fragments, or flattened layout.
  3. If direct/full-file reading hits size limits, switch to page-by-page, chunked, or region-level extraction instead of retrying the same full read.
  4. If a tool produces empty output, stalls, times out, or gives unusable formula text after 1-2 attempts, stop retrying it and switch to a materially different method.
  5. If text extraction loses equation structure, use page rendering, OCR, or manual page-level transcription from verified PDF evidence rather than adding more heuristics.
  6. Track which pages have been inspected so completeness claims are evidence-based.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.