---
topic: typesetting-documents-with-claude-code
title: How to get Claude Code to typeset beautiful documents: Typst, LaTeX or ConTeXt, and with what working method
description: Which typesetting system (Typst, LaTeX, ConTeXt) fits Claude Code best, how well models write each of them, what a loop with a PNG preview gives and where each system wins typographically, also in Polish typesetting (November 2026).
aliases: [typesetting, typography, documents, PDF, report, Typst, LaTeX, LuaLaTeX, XeLaTeX, pdfLaTeX, ConTeXt, LMTX, Tectonic, microtype, KOMA-Script, luavlna, vlna, orphans, single-letter words, hyphenation, justification, Knuth-Plass, font expansion, protrusion, tinymist, typst-mcp, skill, Claude Code, render loop, visual loop, PNG, TeXFix-Bench, TypstBench, TeXpert, StructEval, reportlab, react-pdf, Quarto, Pandoc, document generation]
domain: ai
created: 2026-11-24
license: CC BY 4.0, Jakub Dudek
address: https://stacks.jakubdudek.com/typesetting-documents-with-claude-code
---

## Conclusions

**Typst 0.15 by default, and beauty is decided by the working method.** Models write LaTeX more surely than Typst: in source repair 74.2% against 60.3% of compilations, in a benchmark without Claude [c1], and the authors put this down to newer syntax and less data, which they do not verify themselves [c2]. On the small TypstBench Claude 4 Sonnet was the best of those tested [c3]. Errors in Typst are predictable: mathematics in LaTeX syntax [c7] and old syntax habits, which is why Typst skills make the agent read the local documentation before writing [c8, c9]. The strongest evidence concerns method: one shot by frontier models gives 37–43/100 [c4], the Claude Code loop of edit, compile, score gives 81.6 [c5], and the image preview alone adds a few points [c6]. That harness measures fidelity to a pdfLaTeX reference, not beauty.

**A compile without errors says nothing about the look, so the loop has to have PNGs.** The preview caught a table running off the page that `check` did not see [c17]; the same holds for LaTeX [c18]. Typst gives a PNG of every page with one command [c16], has more readable messages than TeX's noisy log [c19], and since 0.15 supports variable fonts [c14, c15]. It is better to render the pages to PNG oneself, because the API counts a PDF page as at most 1,568 image tokens [c21]. By default Claude designs poorly (tight leading, half the page empty) [c10], and precise layout in LaTeX with it can be agony [c11], hence a house template tuned once by a human. In its own PDF skill Anthropic uses reportlab, not a typesetting system [c12].

**LaTeX (LuaLaTeX + microtype) still sets a paragraph better.** Typst has the same basic paragraph algorithm, but LaTeX has extra tricks [c22]. Typst has no font expansion [c24], which microtype gives in pdfTeX and LuaTeX [c25]; it does have character-level justification [c23]. In Ueding's comparison Typst's right margin was restless [c26], and LWN sees weaker control of widows and orphans [c27]. Tectonic is convenient for an agent [c20], but it stands on XeTeX, so it has no expansion (our inference from [c25]). For long, dense texts where microtypography counts, LuaLaTeX; for reports and company documents with one's own template, Typst.

**Polish typesetting: in Typst the care for single-letter words has to be added.** Typst has Polish hyphenation patterns [c28], but it does not keep single-letter words off the end of a line, and the workaround with a show rule sometimes breaks justification [c29]; LuaLaTeX has the ready-made luavlna [c30]. [omitted]

**ConTeXt is out for an agent.** There are no measurements of how models write it; Hagen describes a mix-up of its syntax with LaTeX [c13], and ConTeXt itself assumes that the author does the layout [c32]. Practitioners of LaTeX with Claude say the breakthrough comes only when the agent builds the document itself and reads the log [c33]; for LaTeX there is a ready-made skill with a visual loop (PaperFit) [c34].

## Claims

### c1. In TeXFix-Bench repaired sources compile less often in Typst (60.3%) than in LaTeX (74.2%).
- source: https://arxiv.org/html/2608.07617 · T1
- quote: LaTeX (74.2%, N=30,814N{=}30{,}814), then Typst (60.3%
- checked: 2026-11-24
- valid until: 2026-12-24

### c2. The authors of TeXFix-Bench link the Typst gap to newer syntax and less training data, but do not verify this.
- source: https://arxiv.org/html/2608.07617 · T1
- quote: is consistent with newer syntax and less public training mass, though we do not observe training corpora directly
- checked: 2026-11-24
- valid until: 2026-12-24

### c3. On TypstBench (61 tasks) Claude 4 Sonnet had 70.49%, the most of the models tested.
- source: https://github.com/rkstgr/TypstBench · T2
- quote: | Claude 4 Sonnet  | 70.49%  |
- checked: 2026-11-24
- valid until: 2026-12-24

### c4. One-shot conversion of hard LaTeX documents to Typst by frontier models (Opus 4.7 among them) gave 37–43/100 and 0 of 6 quality gates.
- source: https://github.com/avijit-thawani/typst-agent-harness · T2
- quote: | Frontier LLM, one shot (Gemini 3.1 Flash-Lite / Sonnet 4.6 / Opus 4.7)  | 37–43/100 overall, 0 of 6 pass the quality gates  |
- checked: 2026-11-24
- valid until: 2026-12-24

### c5. The Claude Code loop of edit, compile, score raised the result from 37 to 81.6.
- source: https://github.com/avijit-thawani/typst-agent-harness · T2
- quote: **1. An agentic harness that improves scores from 37 to 81.6.**
- checked: 2026-11-24
- valid until: 2026-12-24

### c6. In that loop Opus without a preview had 67.4, with diff images 75.1, and with images and raster scoring 81.6.
- source: https://github.com/avijit-thawani/typst-agent-harness · T2
- quote: | Agentic, Opus, visual feedback (harness v1)  | 75.1  |
- checked: 2026-11-24
- valid until: 2026-12-24

### c7. A practitioner: models writing mathematics in Typst almost always use LaTeX mathematics.
- source: https://gatlen.blog/computer-systems/typst · T4
- quote: They almost always use LaTeX math
- checked: 2026-11-24
- valid until: 2026-12-24

### c8. Typst skills for agents exist because models fall back on LaTeX habits and old syntax.
- source: https://github.com/statzhero/typst-skill · T4
- quote: When you ask an LLM to write Typst markup, it can fall back on LaTeX habits or outdated syntax.
- checked: 2026-11-24
- valid until: 2026-12-24

### c9. A Typst skill makes the agent search the local documentation instead of guessing from old data.
- source: https://github.com/apcamargo/typst-skills · T4
- quote: Instead of hallucinating syntax or guessing based on outdated training data, the agent is instructed to search through these local resources
- checked: 2026-11-24
- valid until: 2026-12-24

### c10. A practitioner: Claude Code with Opus 4.8 knows Typst, but by default designs a PDF badly (too little leading, half the page empty).
- source: https://news.ycombinator.com/item?id=48544396 · T4
- quote: Claude by default is crap at designing even a reasonably formatted PDF
- checked: 2026-11-24
- valid until: 2026-12-24

### c11. A practitioner: precise page layout in LaTeX with Claude Code (Opus 4.7) was agony.
- source: https://news.ycombinator.com/item?id=48544396 · T4
- quote: It was agonizing directing Claude Code (Opus 4.7 at that time) to create a (non-mathematical) preso using LaTex.
- checked: 2026-11-24
- valid until: 2026-12-24

### c12. Anthropic's PDF skill creates new PDFs with the reportlab library.
- source: https://github.com/anthropics/skills/blob/main/skills/pdf/SKILL.md · T1
- quote: | Create PDFs  | reportlab  | Canvas or Platypus  |
- checked: 2026-11-24
- valid until: 2026-12-24

### c13. Hans Hagen describes a conversation with a chat model that ended in a mix-up of ConTeXt and LaTeX syntax.
- source: https://www.mail-archive.com/ntg-context@ntg.nl/msg111659.html · T4
- quote: mixups of context and
- checked: 2026-11-24
- valid until: 2026-12-24

### c14. The current version of Typst is 0.15.1, of 17 July 2026.
- source: https://github.com/typst/typst/releases · T1
- quote: ## Version 0.15.1 (July 17, 2026)
- checked: 2026-11-24
- valid until: 2027-02-22

### c15. Typst 0.15 added variable fonts.
- source: https://typst.app/docs/changelog/0.15.0/ · T1
- quote: Added support for variable fonts
- checked: 2026-11-24
- valid until: 2027-02-22

### c16. Typst exports every page to PNG with one command.
- source: https://github.com/lucifer1004/claude-skill-typst · T4
- quote: typst compile /tmp/hello.typ "page-{p}.png" -f png
- checked: 2026-11-24
- valid until: 2027-02-22

### c17. A successful compile (check) did not catch a table running off the page; only the PNG preview caught it.
- source: https://casoon.github.io/typstgen/docs/guides/ai-agents/ · T2
- quote: had said `ok`, but `preview` of page 2 shows the table running past the right edge.
- checked: 2026-11-24
- valid until: 2026-12-24

### c18. A LaTeX document can compile without errors and still look wrong.
- source: https://github.com/fangchenghao/latex-look · T4
- quote: A LaTeX document can compile with zero errors and still look wrong.
- checked: 2026-11-24
- valid until: 2027-02-22

### c19. The author of texfot wrote it because TeX's important warnings got lost in a mass of irrelevant output.
- source: https://www.mankier.com/1/texfot · T1
- quote: It was easy to lose warnings I needed to see in the mass of unvarying and uninteresting output from TeX
- checked: 2026-11-24
- valid until: 2027-02-22

### c20. Tectonic is quiet and never stops to ask for input.
- source: https://tectonic-typesetting.github.io/en-US/ · T1
- quote: **quiet and never stops to ask for input**
- checked: 2026-11-24
- valid until: 2027-02-22

### c21. The Claude API counts a PDF page as at most 1,568 image tokens.
- source: https://platform.claude.com/docs/en/build-with-claude/pdf-support · T1
- quote: Each page’s image uses at most 1,568 visual tokens on every model
- checked: 2026-11-24
- valid until: 2026-12-24

### c22. Typst uses the same basic paragraph optimisation algorithm as LaTeX, but LaTeX has extra tricks.
- source: https://typst.app/blog/2025/typst-0.14/ · T1
- quote: even though Typst uses the same fundamental algorithm as LaTeX does to optimize paragraphs, it's true that LaTeX has some extra tricks up its sleeve
- checked: 2026-11-24
- valid until: 2027-05-23

### c23. Typst has character-level justification; the documentation recommends about 0.01–0.02 em for min and max.
- source: https://typst.app/docs/reference/model/par/ · T1
- quote: a good value for the `min` and `max` keys is around `0.01em` to `0.02em`
- checked: 2026-11-24
- valid until: 2027-05-23

### c24. There is no automatic font expansion in Typst.
- source: https://github.com/typst/typst/issues/4693 · T4
- quote: However, expansion is currently completely absent from Typst, as far as I'm aware.
- checked: 2026-11-24
- valid until: 2027-05-23

### c25. Font expansion in microtype works with pdfTeX and LuaTeX.
- source: https://mirrors.ctan.org/macros/latex/contrib/microtype/microtype.pdf · T1
- quote: Font expansion works with pdfTeX (version 1.20
- checked: 2026-11-24
- valid until: 2027-05-23

### c26. Ueding, comparing Typst with LaTeX, found Typst's right margin restless and LaTeX's even.
- source: https://martin-ueding.de/posts/schriftsatz-bei-typst-noch-nicht-so-schon-wie-bei-latex/ · T4
- quote: Allerdings finde ich den rechten Rand unruhig, das ist bei LaTeX nicht der Fall.
- quote language: de
- paraphrase: However, I find the right margin restless; that is not the case with LaTeX.
- checked: 2026-11-24
- valid until: 2027-05-23

### c27. LWN: Typst is worse than LaTeX at avoiding widows and orphans.
- source: https://lwn.net/Articles/1037577/ · T3
- quote: Typst is not as good as LaTeX at avoiding
- checked: 2026-11-24
- valid until: 2027-05-23

### c28. Typst has Polish hyphenation patterns.
- source: https://github.com/typst/hypher · T1
- quote: | Polish  | 16 KiB  |
- checked: 2026-11-24
- valid until: 2027-05-23

### c29. Typst does not handle single-letter words at the end of a line by itself; the workaround with a show rule sometimes breaks justification.
- source: https://github.com/typst/typst/issues/7469 · T4
- quote: sometimes will break the next word in justified text.
- checked: 2026-11-24
- valid until: 2027-05-23

### c30. LuaLaTeX has the luavlna package, which takes care of Polish single-letter words.
- source: https://ctan.org/pkg/luavlna · T1
- quote: In some languages, like Czech or Polish, there should be no single letter words at the end of a line, according to typographical norms.
- checked: 2026-11-24
- valid until: 2027-05-23

### c32. ConTeXt assumes that the author does the layout personally.
- source: https://wiki.contextgarden.net/FAQ · T1
- quote: the expected “end user” is the person doing all the layout.
- checked: 2026-11-24
- valid until: 2027-05-23

### c33. A practitioner: the rebuilding of a PDF got moving once Claude could build the document itself and read the LaTeX log.
- source: https://www.konradvoelkel.com/posts/ds-skript-modernized-with-claude · T4
- quote: It was that Claude could build the book and read the LaTeX log itself
- checked: 2026-11-24
- valid until: 2026-12-24

### c34. There is a skill, PaperFit: a LaTeX agent with a visual loop (compile, render, diagnose, fix).
- source: https://github.com/OpenRaiser/PaperFit · T4
- quote: Vision-in-the-loop LaTeX typesetting agent
- checked: 2026-11-24
- valid until: 2026-12-24

## History
