Inspiration

University students arrive with the hard part already done: the argument, the data, the reading. What stops them is the typesetting. LaTeX is the expected format for theses, lab reports, and research papers, but its syntax and compile step turn a writing task into a debugging task.

Simpleton closes that gap. Describe the document, attach your data and reading, and get a properly structured PDF, while seeing how the work was organised, cited, and critiqued along the way.

Why LaTeX is the obstacle

One small mistake stops the whole document from building:

  • Missing \begin{document}
  • Undefined control sequences
  • Package conflicts
  • Unescaped %, $, &, #
  • Environments nested wrongly
  • Fonts that are not installed

The errors do not explain themselves: ! LaTeX Error: Missing \begin{document}. ! Undefined control sequence. ! LaTeX Error: File `example.sty' not found.

What it does

1. Plan You describe the document in plain English, for example "a research paper with an abstract, introduction, and methodology". You can attach files alongside the prompt: a CSV of data, images for figures, or PDFs of papers you are working from.

2. Research The agent decides the document class, selects packages known to compile, and reads any attached PDFs so the draft draws on their real definitions and findings, citing them where they belong.

3. Generate LaTeX streams in character by character, using a vetted package set.

4. Compile pdflatex runs automatically. No manual step.

5. Self-correct On failure the agent reads the compiler log, identifies the cause, edits the source, and recompiles. Up to three attempts.

6. Review On demand, the agent reads the whole draft like a supervisor and returns severity-ranked notes: missing citations, stub sections, equations outside math mode, unsupported claims, structural gaps. With papers attached, it points to exactly where they should be cited and flags claims that do not match what those papers say. Each note has an Apply with agent button that sends it back as a targeted edit.

7. Deliver A finished PDF, with no error logs to decipher.

Why this problem

The errors are the barrier, not the syntax. Package conflicts, encoding issues, bibliography failures, figures that will not sit still. Experienced users lose hours to these. Beginners give up and open Word.

Nothing solves it end to end.

  • Overleaf surfaces errors but leaves you to fix them
  • General chatbots write LaTeX but cannot compile or repair it
  • Templates break when edited
  • Stack Overflow answers someone else's error, not yours

No tool plans, writes, compiles, and fixes without a human in the loop.

It is a problem I hit myself. A CV lost to font package conflicts. A paper lost to bibliography errors. A thesis lost to formatting rules. Most of that time went to fighting the toolchain rather than writing.

How we built it

Stack

  • FastAPI (Python 3.13) with LangGraph for agent orchestration
  • Qwen 3.7 via Alibaba Cloud Model Studio
  • Next.js, Monaco, and react-pdf on the front end
  • Supabase for Postgres and PDF storage
  • Upstash Redis for sessions and rate limiting
  • TeX Live's pdflatex as the compiler

The central decision was to treat compilation as the agent's feedback loop. A build counts as successful only on a clean process exit. A partial PDF is a failure, so genuine errors always reach the agent instead of being papered over. Cheap deterministic repairs run first (missing packages, TikZ libraries, bare underscores). Whatever survives goes to the model with the compiler log attached, for up to three retries.

The review agent is a second pass over the full draft plus any attached papers, returning strict JSON with severity-ranked suggestions. Each one routes back through the same edit path as a normal refinement, so critique and correction share a single loop.

Deployment A Docker image with TeX Live baked in, running on Alibaba Cloud ECS. It needs a real container rather than a serverless function because it spawns pdflatex and holds long streaming connections.

Challenges we ran into

LaTeX fails deceptively. The compiler can produce a broken PDF and still look like it half worked. That shaped the strictness rule above.

Generation quality was a grind. Every defect found in testing became a permanent rule in the agent's prompt:

  • Theses rendered as flat articles until the prompt required report with real chapters
  • Wave plots had wrong periods until pgfplots' degree-based trig was spelled out
  • 3D vector fields rendered flat until the working recipe was written in

Deployment produced a second wave. The container was OOM-killed mid-generation when the compiler outgrew the host's memory. Sessions broke silently because browsers reject cookies across domains. Dead database connections surfaced as misleading CORS errors and sent us debugging in the wrong place entirely. Each one was found by reproducing the failure directly, and each left the system more robust.

Accomplishments that we're proud of

Verified end to end, prompt to compiled PDF:

  • Eleven document types: reports, papers, theses with real chapters, beamer decks, lecture notes, specifications, proposals, CVs, letters, invoices, books
  • A self-correction loop that converges: most documents compile first try, the rest recover within one automatic fix
  • Publication-grade figures: 3D surfaces, vector fields, statistical box plots with quartiles and outliers, quantum circuits, Gantt charts, all from a sentence
  • A review agent that finds real problems: in testing it caught a % TODO left in a draft, an equation written outside math mode, and a contradiction between a thesis's problem statement and its dataset
  • Running in production: deployed, with cross-domain sessions, a memory-guarded compiler

What we learned

Conversation memory is what separates a tool from a workspace. "Make the intro shorter" only works if the agent sees the whole previous document and edits it in place. We learned this the hard way. An early bug truncated the history, so the agent silently regenerated instead of editing, quietly discarding the user's earlier changes.

Streaming buys trust, not just speed. Watching the LaTeX appear and the compile attempt run, including the fixing step, makes the agent feel considered. A polished PDF with a hidden repair loop would feel impressive but opaque.

A self-correction loop is only as good as its error signal. The fix step works because pdflatex either exits cleanly or does not, and its log is specific. Given the actual error text rather than "compilation failed", the model repairs the right thing. Reliability came from visibility, not from trying harder.

Errors lie about their cause. Browser "CORS errors" were dead HTTP/2 connections. "Invalid email or password" was a cookie policy problem. Reproducing each failure before fixing it saved us from chasing ghosts.

What's next for Simpleton

Near term

  • Real citation lookup, so the agent fetches actual references and emits BibTeX rather than only telling you where a citation is needed
  • Collaborative editing
  • Journal-specific templates

Longer term LaTeX stops being something you learn and becomes something you use. Describe the document, get the document, keep your attention on the ideas.

Built With

  • alibaba
  • langgraph
  • monaco
  • nextjs
  • postgress
  • qwen3.7
  • redis
  • supabase
  • upstash
Share this project:

Updates