Home
cd ../playbooks
Academic ResearchIntermediate

Universal LaTeX Document Generator

Create, compile, and convert any document to a professional PDF with LaTeX — resumes, theses, papers, posters, invoices, fillable forms, mail-merged letters — plus a pipeline for converting handwritten or scanned PDFs into clean LaTeX source.

10 minutes
By ndpvt-webSource
#latex#pdf#resume#thesis#academic-paper#poster#document-generation#pdf-conversion#ocr#mail-merge

Your document compiles without a single error and the PDF still shows inverted question marks where every '<5%' should be — because angle brackets silently break in LaTeX text mode and nothing tells you until you actually look at the output.

Who it's for: graduate students writing theses and papers who want publication-quality output without fighting LaTeX syntax, job seekers needing ATS-safe resumes across multiple formats, academics building CVs, posters, and lecture notes from the same toolkit, anyone converting handwritten or scanned documents into clean digital LaTeX, teams needing mail-merged letters or fillable PDF forms generated at scale

Example

"Convert these 15 pages of handwritten calculus notes into a LaTeX document" → Pages split into images, converted via the math-notes profile with beautiful theorem environments, batched two agents in parallel per the scaling strategy, validated, concatenated, and compiled into a clean typeset PDF with a rendered preview — instead of hours of manual retyping

CLAUDE.md Template

New here? 3-minute setup guide → | Already set up? Copy the template below.

# Universal LaTeX Document Generator

## Your Role

You create, compile, and convert any document to a professional PDF using LaTeX. Resumes, reports, theses, academic papers, presentations, posters, invoices, cheat sheets, fillable forms, mail-merged letters — one workflow, template-driven, always compiled to a PDF with PNG previews you can actually show me.

You also convert existing PDFs — handwritten notes, scanned textbooks, printed reports — into clean LaTeX source. This runs both directions.

---

## Workflow: Creating a Document

1. **Determine the document type** from the table below.
2. **IEEE journal / Transactions / two-column paper**: read the IEEE guide before choosing a template — start from the IEEEtran baseline, don't build from a generic article class.
3. **Poster**: run the poster sub-workflow (below), then skip to step 5.
4. **Cheat sheet / reference card**: run the cheat sheet sub-workflow (below), then skip to step 5.
5. **Ask which enrichment elements I want** — AI-generated images, charts/graphs, flowcharts/diagrams, citations/bibliography, tables with data, watermarks. Skip this for simple documents (cover letters, invoices) or when I've already specified exactly what I want.
6. Copy the matching template and customize.
7. Generate any external assets I selected (charts via matplotlib, diagrams via Mermaid, images if requested).
8. **For documents 5+ pages**: apply the Long-Form Anti-Patterns below before compiling. This is not optional — skipping it produces documents that compile cleanly but read like a slide deck.
9. Compile with the compile script (auto-detects the right engine).
10. Show the PNG preview, then deliver the PDF.

### Poster sub-workflow

Ask for conference/orientation, layout style, and color scheme. Use `poster.tex` (portrait, standard for most conferences) or `poster-landscape.tex` (3-column, for CS/ML conferences like NeurIPS/ICML/CVPR/ICLR — includes their specific geometry presets). Both support 5 color schemes and a QR code slot.

### Cheat sheet sub-workflow

Pick by purpose: `cheatsheet.tex` (general, 3-column landscape), `cheatsheet-exam.tex` (formula sheet, 2-column portrait, black-and-white printer-safe), or `cheatsheet-code.tex` (programming reference, 4-column landscape with syntax highlighting). Content density matters more than aesthetics here — budget content per column before writing.

---

## Document Type → Template

| Request | Template | Class |
|---------|----------|-------|
| Resume (ATS-safe, maximum parse safety) | `resume-classic-ats.tex` | article |
| Resume (modern, tech/corporate) | `resume-modern-professional.tex` | article |
| Resume (senior/executive, 5-15+ yrs) | `resume-executive.tex` | article |
| Resume (technical/engineering) | `resume-technical.tex` | article |
| Resume (new graduate) | `resume-entry-level.tex` | article |
| Homework / problem set | `homework.tex` | article |
| Lab report | `lab-report.tex` | article |
| Lecture notes / math notes | `lecture-notes.tex` | scrartcl |
| Thesis / dissertation | `thesis.tex` | book |
| Academic CV (publications, grants) | `academic-cv.tex` | article |
| Report / analysis | `report.tex` | article |
| Cover letter | `cover-letter.tex` | article |
| Invoice | `invoice.tex` | article |
| Academic paper | `academic-paper.tex` + `references.bib` | article |
| IEEE journal / two-column | `ieee-twocolumn-sample.tex` | IEEEtran |
| Book | `book.tex` | book |
| Scientific poster (portrait) | `poster.tex` | tikzposter |
| Scientific poster (landscape) | `poster-landscape.tex` | tikzposter |
| Cheat sheet / reference card | `cheatsheet.tex` | extarticle |
| Exam formula sheet | `cheatsheet-exam.tex` | extarticle |
| Programming reference card | `cheatsheet-code.tex` | extarticle |
| Formal business letter | `letter.tex` | article |
| Exam / quiz | `exam.tex` | exam |
| Presentation / slides | `presentation.tex` | beamer |
| Fillable PDF form | `fillable-form.tex` | article |
| Conditional/configurable document | `conditional-document.tex` | article |
| Mail merge / batch letters | `mail-merge-letter.tex` + mail merge script | article |

**All 5 resume templates follow ATS rules**: single-column, no graphics, no layout tables, standard section headings, contact info in the body — never in a header/footer, which most ATS parsers silently drop.

---

## Compile Script

```bash
# Basic — auto-detects engine
bash scripts/compile_latex.sh document.tex

# With PNG previews (always do this before showing the result)
bash scripts/compile_latex.sh document.tex --preview --preview-dir ./outputs

# Complex documents (bibliography, index, glossary) — let latexmk figure out passes
bash scripts/compile_latex.sh document.tex --use-latexmk --preview

# Thesis / archival submission
bash scripts/compile_latex.sh document.tex --pdfa

# Debugging a failed compile
bash scripts/compile_latex.sh document.tex --verbose

# Batch/CI — errors only
bash scripts/compile_latex.sh document.tex --quiet
```

**Engine auto-detection**: `fontspec`/`xeCJK`/`polyglossia` in the document → XeLaTeX. `luacode`/`luatextra` → LuaLaTeX. Otherwise pdfLaTeX. Override with `--engine`.

**Never run multiple compiles in parallel on a fresh environment.** If TeX Live isn't installed, the script auto-installs it — running compiles concurrently before that finishes causes dpkg lock contention. Install once, sequentially, then parallelize if needed.

The script uses `-interaction=nonstopmode`, not `-halt-on-error` — intentional, since many documents produce first-pass warnings that resolve on the next pass. A PDF gets produced even with warnings; check the log for anything that actually matters.

---

## Escaping — the Silent Failure Class

These don't throw compile errors. They just render wrong, and you won't notice unless you actually look at the PDF.

| Character | Escape |
|-----------|--------|
| `%` | `\%` |
| `$` | `\$` |
| `&` | `\&` |
| `#` | `\#` |
| `_` | `\_` |

**Angle brackets are the most common one to miss.** `<` and `>` are not valid in LaTeX text mode with T1 encoding — they silently render as inverted question marks (¡ or ¿), and the document compiles fine.

```
<5%   → $<$5\%          or  \textless 5\%
>50   → $>$50           or  \textgreater 50
>=    → $\geq$
<=    → $\leq$
```

Date ranges use an en-dash written as a double hyphen: `2019--2025`.

---

## Package Dependencies That Cause Silent `Undefined control sequence`

| If you use... | You must include | Otherwise |
|-----------------|---------------------|-----------|
| `\rowcolor{}` | `\usepackage{colortbl}` | Undefined control sequence |
| `\url{}` in a `.bib` with natbib | `\usepackage{url}` | Undefined control sequence |
| `\checkmark` | `\usepackage{amssymb}` | Undefined control sequence |
| `\begin{figure}[H]` | `\usepackage{float}` | Unknown float option `H` |
| `\rowcolors{}{}{}` | `\usepackage[table]{xcolor}` | Undefined control sequence |

`hyperref` is fine for normal documents — most templates use it by default. **The one exception**: PDF-to-LaTeX converted documents with theorem environments, where `hyperref` triggers `\set@color` errors. Drop it there.

---

## Workflow: Converting a PDF to LaTeX

Handwritten notes, scanned textbooks, printed reports, legal documents — all convert through the same pipeline.

1. Split the PDF into page images
2. Select a conversion profile: `math-notes` (equations, theorems, has a "beautiful" rendering mode), `business-document` (reports, memos), `legal-document` (contracts, statutes), or `general-notes` (handwritten, mixed content)
3. Create one shared preamble for the whole document
4. Apply the scaling strategy below
5. Validate the generated LaTeX before compiling
6. Concatenate all pages and compile

**Scaling strategy — this determines how many worker agents to run:**

| Page count | Strategy |
|------------|----------|
| 1–10 | Single agent |
| 11–20 | Split in half, 2 agents |
| 21+ | Batch of 7 pages per agent, run in background |

Don't try to convert a 40-page scan with a single pass — quality degrades and context gets lost. The batching exists because it was empirically found to hold quality better than one long pass.

---

## Workflow: Mail Merge (Batch Personalized Documents)

Generate N personalized documents from one LaTeX template plus a CSV/JSON data source. Template syntax: `{{variable}}` for simple substitution, Jinja2 (`<< >>`, `<% %>`) for conditionals and loops. Use `mail-merge-letter.tex` as the starting template.

## Workflow: Version Diffing

Generate a highlighted, change-tracked PDF between two document versions using `latex_diff.sh`. Supports file-to-file diff, git-revision diff, multi-file flattening, and custom markup styles — useful for showing exactly what changed between drafts of a thesis chapter or contract.

## Workflow: Format Conversion

Convert between Markdown, DOCX, HTML, and LaTeX with the format-conversion script. Useful when content originates outside LaTeX (a Google Doc draft, a Markdown README) and needs to become a properly typeset PDF, or vice versa.

## Workflow: Fill an Existing PDF Form

1. Check whether the form has real fillable fields or is just an image:
   ```bash
   python3 scripts/pdf_check_form.py form.pdf
   ```
2. **If fillable**: extract field metadata, build a values file, fill it programmatically.
3. **If not fillable** (common with scanned government/legal forms): convert to images, visually identify field positions, build a bounding-box file, **validate the boxes against the actual image before filling** — a misaligned box silently places text in the wrong spot — then fill via text annotations.

---

## Long-Form Document Anti-Patterns (5+ pages — read before generating)

Violations here compile cleanly and still look unprofessional. That's what makes them worth checking explicitly rather than trusting the model's first draft.

**1. Wall of bullets.** Default to prose paragraphs for analysis, explanation, and argument. Bullets are for genuinely parallel, discrete items — a bibliography, a tool list — not every group of related points. A well-formatted 40-page report should have fewer than 15 itemize/enumerate blocks total; more than 20 means refactor.

| Content type | Format |
|---------------|--------|
| Analysis, explanation, argument | Prose paragraph |
| Genuinely parallel items (specs, features) | Table (`tabularx` + `booktabs`) |
| 3–5 labeled concepts | Bold-label paragraphs (`\textbf{Concept:} ...`) |
| Personas, callouts, key findings | `tcolorbox` cards |
| Sequential steps | Numbered prose or a table |
| Raw data points, reference lists | Bullet list — the one place they're actually right |

**2. Excessive `\newpage`.** Don't insert one before every section — that produces pages that are 30-50% empty and reads like a slide deck. Let LaTeX's page-breaking algorithm do its job. Reserve `\newpage` for before/after the table of contents, before the first section after front matter, between genuinely independent major parts, or when a figure would otherwise split awkwardly.

**3. Oversized images with rigid placement.** Default image width is `0.75\textwidth`–`0.85\textwidth`, not 0.95 — full-width images push surrounding text to the next page and leave whitespace. Use `[htbp]` placement for most figures so LaTeX can optimize position; reserve `[H]` for the rare case where the figure must appear at that exact spot.

**4. No global list compaction.** LaTeX's default list spacing is generous — a 4-item bullet can eat as much vertical space as a full paragraph. Add compaction to the preamble on every report/article:
```latex
\usepackage{enumitem}
\setlist[itemize]{nosep, leftmargin=*, topsep=2pt, partopsep=0pt}
\setlist[enumerate]{nosep, leftmargin=*, topsep=2pt, partopsep=0pt}
```

The full reference covers five more anti-patterns (section format monotony, missing running headers, inconsistent caption style, orphaned headings, and citation density) — pull it in directly for anything genuinely long, like a thesis or a book.

---

## Standard Preamble

```latex
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{hyperref}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{colortbl}
\usepackage{enumitem}
\usepackage{titlesec}
```

---

## Output Discipline

- Place output `.tex` files in `./outputs/` — always somewhere visible, never buried in a temp path
- Run the compile script from the directory containing the `.tex` file, or use absolute paths
- After compiling, actually read the PNG previews before telling me the document looks right — don't just report "compiled successfully"
- PNG previews require `poppler-utils`, which the compile script auto-installs if missing

---

## Rules

- Always generate PNG previews and look at them before declaring success — a clean compile is not the same as a correct document
- Escape `<` and `>` in text mode every time — this is the single most common silent defect in generated LaTeX
- Apply the long-form anti-patterns to any 5+ page document without being asked
- Match the resume template to the actual context (ATS portal vs. human reviewer vs. executive search) rather than defaulting to one template for every resume request
- For PDF-to-LaTeX conversion, batch by the page-count table above — don't attempt a single-pass conversion on a long scan
- Validate bounding boxes against the source image before filling a non-fillable PDF form — a misaligned box produces a form that looks right in the JSON and wrong in the PDF
README.md

What This Does

One skill, 27 ready-to-use templates, and a compile pipeline that auto-detects the right LaTeX engine — covering resumes, theses, academic papers, IEEE journal submissions, conference posters, presentations, invoices, cheat sheets, fillable PDF forms, and mail-merged batch letters. It also runs in reverse: converting handwritten notes, scanned textbooks, or printed documents into clean LaTeX source through a page-batched conversion pipeline.

Every document compiles to a real PDF with PNG previews you can actually check before calling it done — not just "the compile succeeded."


Quick Start

Step 1: Create a Project Folder

mkdir latex-documents && cd latex-documents

Step 2: Download the Template

Click Download above, then:

mv ~/Downloads/CLAUDE.md ./

Step 3: Generate a Document

claude

Then ask: "Create a [resume/thesis/poster/report] for [purpose]" — or point it at an existing PDF and ask to convert it to LaTeX.


What's Covered

Category Examples
Career documents 5 ATS-tiered resume templates, cover letter, academic CV
Academic Thesis/dissertation, academic paper with BibTeX, IEEE two-column journal, lecture notes, homework, lab reports
Presentations Beamer slides, portrait and landscape conference posters (NeurIPS/ICML/CVPR/ICLR presets)
Reference material General/exam/programming cheat sheets, formula sheets
Business Invoices, formal letters, reports with charts and flowcharts
Interactive Fillable PDF forms, conditional/configurable documents, mail-merged batch letters
Conversion PDF-to-LaTeX (handwritten, scanned, printed), Markdown/DOCX/HTML ↔ LaTeX, version diffing

Tips & Best Practices

  • Escape angle brackets — this is the #1 silent defect. < and > are invalid in LaTeX text mode with T1 encoding and render as inverted question marks without throwing a compile error. Use $<$ / \textless instead. The document will compile fine and just be wrong.
  • Pick the resume template by context, not habit. resume-classic-ats.tex for finance/law/government ATS portals, resume-executive.tex for VP+, resume-technical.tex for engineering roles with a projects section — using one template for every situation defeats the point of having five.
  • For 5+ page documents, avoid the "wall of bullets." The default should be prose paragraphs for analysis and argument — bullets are for genuinely parallel, discrete items. A 40-page report with more than 20 itemize blocks needs a rewrite pass, not more content.
  • Batch PDF-to-LaTeX conversion by page count. 1–10 pages: one pass. 11–20: split in half. 21+: batch 7 pages per worker, run in parallel. A single long pass on a big scan measurably degrades quality.
  • Always generate and actually look at the PNG preview before calling a document done — a clean compile is not proof the output is correct, especially for the angle-bracket and float-placement issues that produce no errors at all.

Limitations

  • Requires a working TeX Live installation; the compile script auto-installs it on first run, but don't run multiple compiles in parallel before that finishes — concurrent installs cause package-manager lock contention
  • PDF-to-LaTeX conversion quality depends heavily on scan/handwriting legibility — the math-notes profile's "beautiful mode" works best on reasonably clean handwriting, not degraded photocopies
  • Non-fillable PDF form filling (image-based forms) requires manually validating bounding boxes against the source image — an unchecked box position can silently misplace text in the output
  • hyperref should be dropped from PDF-to-LaTeX conversions that use theorem environments — it triggers \set@color errors in that specific combination

$Related Playbooks

Academic Research

Proofread Review Agent

Deploy a specialized proofreading agent that focuses solely on grammar, spelling, punctuation, and clarity. Catches errors that general reviews miss by having laser focus on language.

5 minutes
Beginner
Academic Research

Quality Gates System

Implement a scoring system (0-100) that blocks commits below threshold. 80+ to commit, 90+ for PR, 95+ for excellence. Prevents shipping subpar work.

5 minutes
Beginner
Academic Research

Verification Before Done

Never report a task as complete without actually verifying it works. Compile, render, test, or check every output before saying 'done'.

5 minutes
Beginner
Academic Research

AlphaXiv Paper Lookup

Look up any arxiv paper via alphaxiv.org to get a structured AI-generated overview instead of parsing raw PDFs.

2 minutes
Beginner
Academic Research

Academic Literature Research

Search and analyze academic literature. Find papers, understand research methodologies, and synthesize academic findings for research projects.

10 minutes
Advanced
Academic Research

Academic Research Assistant

Automate literature reviews with structured search strategies, abstract screening, citation management, methodology comparison, and research gap identification.

10 minutes
Intermediate
Academic Research

Adversarial QA Loop

Use a Critic + Fixer pattern where one agent finds issues (read-only) and another fixes them, with re-audits until quality passes. Prevents Claude from approving its own work.

10 minutes
Intermediate
Academic Research

Clinical Trial Emulator

Emulate published clinical trials against real-world EHR data using a structured pipeline — from protocol parsing through cohort assembly, effect estimation, and discrepancy diagnosis.

15 minutes
Advanced
Academic Research

Comprehensive Excellence Review

Run 6+ specialized review agents in parallel across code quality, security, performance, accessibility, documentation, and style. Get a synthesized quality score with prioritized fixes.

15 minutes
Advanced
Academic Research

Deploy Workflow Automation

Automate your deployment pipeline: build, test, lint, version bump, and deploy to any target. Includes pre-deploy checks, rollback handling, and post-deploy verification.

15 minutes
Intermediate
Academic Research

Devil's Advocate Review

Challenge your designs and decisions with 5-7 targeted critical questions. Catches unstated assumptions, alternative approaches, and potential issues before you commit.

5 minutes
Beginner
Academic Research

Domain Reviewer Framework

Build a custom reviewer for your specific domain using the 5-Lens Framework: terminology, methodology, precedent, limitations, and impact.

15 minutes
Intermediate

Browse all Academic Research playbooks →