Skip to content

About

A skill to transcribe old textbooks into modern LaTeX

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retypeset

Turn document references into polished, editable LaTeX.

An AI-agent skill for recreating mathematical scans, photos, and PDFs as visually faithful LaTeX projects.

Agent Skills Output Works with License: MIT

Quick start · How it works · Example prompt · Compatibility


Why Retypeset?

Retypeset turns scanned mathematics into clean, publication-ready LaTeX—capturing the equations, theorem structure, cross-references, and typographic rhythm that ordinary text extraction leaves behind.

It tells an agent to:

  • preserve source wording unless an edit is requested;
  • build real LaTeX structure instead of using a page image as a shortcut;
  • return editable .tex source, not only a PDF; and
  • compile and compare the result with the reference whenever the environment allows it.

Before & after

Each example pairs the visual source with its editable LaTeX reconstruction.

01 · Genus zero

Reference scanLaTeX reconstruction
Source scan for a theorem on genus zero LaTeX reconstruction of a theorem on genus zero

02 · ℓ-adic representations

Reference scanLaTeX reconstruction
Source scan defining an ell-adic representation LaTeX reconstruction defining an ell-adic representation

03 · Dualizing complexes and local duality

Reference scanLaTeX reconstruction
Source scan on dualizing complexes and local duality LaTeX reconstruction on dualizing complexes and local duality

Quick start

Clone the skill repository:

git clone git@github.com:yunhaixiang/retypeset-skill.git

Then use the integration your agent supports:

Agent setup Use it this way
Codex Register the repository as a SKILL.md skill.
Claude Code Install the repository as a custom SKILL.md skill.
Cursor Keep the repository in the project so Cursor reads the root AGENTS.md.
Other project-instruction agents Copy SKILL.md into the agent's instruction file.
Chat based Attach or paste SKILL.md together with the reference document.

Codex and Claude Code use the canonical SKILL.md; Cursor reads AGENTS.md, which points back to the same instructions.

How it works

Stage 1: Preprocess the source
       │
       ▼
Render pages, index the book, and create the LaTeX scaffold
       │
       ▼
Stage 2: Transcribe one user-requested chunk
       │
       ▼
Compile, compare, and audit that chunk
       │
       ▼
Stage 3: Audit one user-requested completed chunk

The agent does not advance to the next chapter or stage unless the user requests it. It selects the LaTeX engine based on the document's actual needs, keeps dependencies practical, and records any nonstandard build requirement.

Example prompt

Use the Retypeset skill to recreate the attached document as a LaTeX project. Preserve the text and page layout. Use main.tex as the entry point, compile it, and include the compiled PDF for comparison. Flag any text that cannot be read reliably.

For the most faithful result, supply every page of the source and specify any required document class, TeX engine, fonts, and bibliography format. Retypeset uses direct visual inspection and never uses OCR.

Expected output

For a multi-file document, a typical result looks like this:

document-name/
├── main.tex        # Editable LaTeX entry point
├── figures/        # Original artwork that cannot be recreated natively
├── main.pdf        # Compiled preview, when compilation is available
└── README.md       # Build instructions, only when nonstandard steps are needed

The .tex source is the primary deliverable. The PDF is a verification artifact, not a substitute for editable source.

Compatibility

Retypeset is intentionally tool-neutral. Any capable AI agent that can read Markdown instructions and work with the supplied files can use it.

Visual verification requires both a LaTeX compiler and a way to render PDFs. If either is unavailable, the agent should still produce the source and clearly disclose that it could not verify the compiled visual result.

Repository layout

.
├── SKILL.md            # Canonical skill instructions
├── AGENTS.md           # Project-instruction discovery entry
├── assets/              # README example images
├── references/
│   ├── style.md         # Mandatory mathematical typesetting conventions
│   └── book-workflow.md # Staged preprocessing, transcription, and audit workflow
└── agents/openai.yaml  # Optional Codex/OpenAI UI metadata

Contributing

The skill's behavior lives in SKILL.md. Keep changes focused on guidance that improves document-to-LaTeX fidelity or makes the workflow more reliable across agent environments.

License

Distributed under the MIT License.

About

A skill to transcribe old textbooks into modern LaTeX

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors