{
 "topic": "typesetting-documents-with-claude-code",
 "url": "https://stacks.jakubdudek.com/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",
 "last_checked": "2026-11-24",
 "claims": [
  {
   "ref": "typesetting-documents-with-claude-code#c1",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c1",
   "card": "typesetting-documents-with-claude-code",
   "id": "c1",
   "status": "valid",
   "claim": "In TeXFix-Bench repaired sources compile less often in Typst (60.3%) than in LaTeX (74.2%).",
   "quote": "LaTeX (74.2%, N=30,814N{=}30{,}814), then Typst (60.3%",
   "source_url": "https://arxiv.org/html/2608.07617",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c2",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c2",
   "card": "typesetting-documents-with-claude-code",
   "id": "c2",
   "status": "valid",
   "claim": "The authors of TeXFix-Bench link the Typst gap to newer syntax and less training data, but do not verify this.",
   "quote": "is consistent with newer syntax and less public training mass, though we do not observe training corpora directly",
   "source_url": "https://arxiv.org/html/2608.07617",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c3",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c3",
   "card": "typesetting-documents-with-claude-code",
   "id": "c3",
   "status": "valid",
   "claim": "On TypstBench (61 tasks) Claude 4 Sonnet had 70.49%, the most of the models tested.",
   "quote": "| Claude 4 Sonnet  | 70.49%  |",
   "source_url": "https://github.com/rkstgr/TypstBench",
   "tier": "T2",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c4",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c4",
   "card": "typesetting-documents-with-claude-code",
   "id": "c4",
   "status": "valid",
   "claim": "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.",
   "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  |",
   "source_url": "https://github.com/avijit-thawani/typst-agent-harness",
   "tier": "T2",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c5",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c5",
   "card": "typesetting-documents-with-claude-code",
   "id": "c5",
   "status": "valid",
   "claim": "The Claude Code loop of edit, compile, score raised the result from 37 to 81.6.",
   "quote": "**1. An agentic harness that improves scores from 37 to 81.6.**",
   "source_url": "https://github.com/avijit-thawani/typst-agent-harness",
   "tier": "T2",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c6",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c6",
   "card": "typesetting-documents-with-claude-code",
   "id": "c6",
   "status": "valid",
   "claim": "In that loop Opus without a preview had 67.4, with diff images 75.1, and with images and raster scoring 81.6.",
   "quote": "| Agentic, Opus, visual feedback (harness v1)  | 75.1  |",
   "source_url": "https://github.com/avijit-thawani/typst-agent-harness",
   "tier": "T2",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c7",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c7",
   "card": "typesetting-documents-with-claude-code",
   "id": "c7",
   "status": "valid",
   "claim": "A practitioner: models writing mathematics in Typst almost always use LaTeX mathematics.",
   "quote": "They almost always use LaTeX math",
   "source_url": "https://gatlen.blog/computer-systems/typst",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c8",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c8",
   "card": "typesetting-documents-with-claude-code",
   "id": "c8",
   "status": "valid",
   "claim": "Typst skills for agents exist because models fall back on LaTeX habits and old syntax.",
   "quote": "When you ask an LLM to write Typst markup, it can fall back on LaTeX habits or outdated syntax.",
   "source_url": "https://github.com/statzhero/typst-skill",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c9",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c9",
   "card": "typesetting-documents-with-claude-code",
   "id": "c9",
   "status": "valid",
   "claim": "A Typst skill makes the agent search the local documentation instead of guessing from old data.",
   "quote": "Instead of hallucinating syntax or guessing based on outdated training data, the agent is instructed to search through these local resources",
   "source_url": "https://github.com/apcamargo/typst-skills",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c10",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c10",
   "card": "typesetting-documents-with-claude-code",
   "id": "c10",
   "status": "valid",
   "claim": "A practitioner: Claude Code with Opus 4.8 knows Typst, but by default designs a PDF badly (too little leading, half the page empty).",
   "quote": "Claude by default is crap at designing even a reasonably formatted PDF",
   "source_url": "https://news.ycombinator.com/item?id=48544396",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c11",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c11",
   "card": "typesetting-documents-with-claude-code",
   "id": "c11",
   "status": "valid",
   "claim": "A practitioner: precise page layout in LaTeX with Claude Code (Opus 4.7) was agony.",
   "quote": "It was agonizing directing Claude Code (Opus 4.7 at that time) to create a (non-mathematical) preso using LaTex.",
   "source_url": "https://news.ycombinator.com/item?id=48544396",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c12",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c12",
   "card": "typesetting-documents-with-claude-code",
   "id": "c12",
   "status": "valid",
   "claim": "Anthropic's PDF skill creates new PDFs with the reportlab library.",
   "quote": "| Create PDFs  | reportlab  | Canvas or Platypus  |",
   "source_url": "https://github.com/anthropics/skills/blob/main/skills/pdf/SKILL.md",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c13",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c13",
   "card": "typesetting-documents-with-claude-code",
   "id": "c13",
   "status": "valid",
   "claim": "Hans Hagen describes a conversation with a chat model that ended in a mix-up of ConTeXt and LaTeX syntax.",
   "quote": "mixups of context and",
   "source_url": "https://www.mail-archive.com/ntg-context@ntg.nl/msg111659.html",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c14",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c14",
   "card": "typesetting-documents-with-claude-code",
   "id": "c14",
   "status": "valid",
   "claim": "The current version of Typst is 0.15.1, of 17 July 2026.",
   "quote": "## Version 0.15.1 (July 17, 2026)",
   "source_url": "https://github.com/typst/typst/releases",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-02-22"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c15",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c15",
   "card": "typesetting-documents-with-claude-code",
   "id": "c15",
   "status": "valid",
   "claim": "Typst 0.15 added variable fonts.",
   "quote": "Added support for variable fonts",
   "source_url": "https://typst.app/docs/changelog/0.15.0/",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-02-22"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c16",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c16",
   "card": "typesetting-documents-with-claude-code",
   "id": "c16",
   "status": "valid",
   "claim": "Typst exports every page to PNG with one command.",
   "quote": "typst compile /tmp/hello.typ \"page-{p}.png\" -f png",
   "source_url": "https://github.com/lucifer1004/claude-skill-typst",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2027-02-22"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c17",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c17",
   "card": "typesetting-documents-with-claude-code",
   "id": "c17",
   "status": "valid",
   "claim": "A successful compile (check) did not catch a table running off the page; only the PNG preview caught it.",
   "quote": "had said `ok`, but `preview` of page 2 shows the table running past the right edge.",
   "source_url": "https://casoon.github.io/typstgen/docs/guides/ai-agents/",
   "tier": "T2",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c18",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c18",
   "card": "typesetting-documents-with-claude-code",
   "id": "c18",
   "status": "valid",
   "claim": "A LaTeX document can compile without errors and still look wrong.",
   "quote": "A LaTeX document can compile with zero errors and still look wrong.",
   "source_url": "https://github.com/fangchenghao/latex-look",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2027-02-22"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c19",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c19",
   "card": "typesetting-documents-with-claude-code",
   "id": "c19",
   "status": "valid",
   "claim": "The author of texfot wrote it because TeX's important warnings got lost in a mass of irrelevant output.",
   "quote": "It was easy to lose warnings I needed to see in the mass of unvarying and uninteresting output from TeX",
   "source_url": "https://www.mankier.com/1/texfot",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-02-22"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c20",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c20",
   "card": "typesetting-documents-with-claude-code",
   "id": "c20",
   "status": "valid",
   "claim": "Tectonic is quiet and never stops to ask for input.",
   "quote": "**quiet and never stops to ask for input**",
   "source_url": "https://tectonic-typesetting.github.io/en-US/",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-02-22"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c21",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c21",
   "card": "typesetting-documents-with-claude-code",
   "id": "c21",
   "status": "valid",
   "claim": "The Claude API counts a PDF page as at most 1,568 image tokens.",
   "quote": "Each page’s image uses at most 1,568 visual tokens on every model",
   "source_url": "https://platform.claude.com/docs/en/build-with-claude/pdf-support",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c22",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c22",
   "card": "typesetting-documents-with-claude-code",
   "id": "c22",
   "status": "valid",
   "claim": "Typst uses the same basic paragraph optimisation algorithm as LaTeX, but LaTeX has extra tricks.",
   "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",
   "source_url": "https://typst.app/blog/2025/typst-0.14/",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c23",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c23",
   "card": "typesetting-documents-with-claude-code",
   "id": "c23",
   "status": "valid",
   "claim": "Typst has character-level justification; the documentation recommends about 0.01–0.02 em for min and max.",
   "quote": "a good value for the `min` and `max` keys is around `0.01em` to `0.02em`",
   "source_url": "https://typst.app/docs/reference/model/par/",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c24",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c24",
   "card": "typesetting-documents-with-claude-code",
   "id": "c24",
   "status": "valid",
   "claim": "There is no automatic font expansion in Typst.",
   "quote": "However, expansion is currently completely absent from Typst, as far as I'm aware.",
   "source_url": "https://github.com/typst/typst/issues/4693",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c25",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c25",
   "card": "typesetting-documents-with-claude-code",
   "id": "c25",
   "status": "valid",
   "claim": "Font expansion in microtype works with pdfTeX and LuaTeX.",
   "quote": "Font expansion works with pdfTeX (version 1.20",
   "source_url": "https://mirrors.ctan.org/macros/latex/contrib/microtype/microtype.pdf",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c26",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c26",
   "card": "typesetting-documents-with-claude-code",
   "id": "c26",
   "status": "valid",
   "claim": "Ueding, comparing Typst with LaTeX, found Typst's right margin restless and LaTeX's even.",
   "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.",
   "source_url": "https://martin-ueding.de/posts/schriftsatz-bei-typst-noch-nicht-so-schon-wie-bei-latex/",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c27",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c27",
   "card": "typesetting-documents-with-claude-code",
   "id": "c27",
   "status": "valid",
   "claim": "LWN: Typst is worse than LaTeX at avoiding widows and orphans.",
   "quote": "Typst is not as good as LaTeX at avoiding",
   "source_url": "https://lwn.net/Articles/1037577/",
   "tier": "T3",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c28",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c28",
   "card": "typesetting-documents-with-claude-code",
   "id": "c28",
   "status": "valid",
   "claim": "Typst has Polish hyphenation patterns.",
   "quote": "| Polish  | 16 KiB  |",
   "source_url": "https://github.com/typst/hypher",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c29",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c29",
   "card": "typesetting-documents-with-claude-code",
   "id": "c29",
   "status": "valid",
   "claim": "Typst does not handle single-letter words at the end of a line by itself; the workaround with a show rule sometimes breaks justification.",
   "quote": "sometimes will break the next word in justified text.",
   "source_url": "https://github.com/typst/typst/issues/7469",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c30",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c30",
   "card": "typesetting-documents-with-claude-code",
   "id": "c30",
   "status": "valid",
   "claim": "LuaLaTeX has the luavlna package, which takes care of Polish single-letter words.",
   "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.",
   "source_url": "https://ctan.org/pkg/luavlna",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c32",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c32",
   "card": "typesetting-documents-with-claude-code",
   "id": "c32",
   "status": "valid",
   "claim": "ConTeXt assumes that the author does the layout personally.",
   "quote": "the expected “end user” is the person doing all the layout.",
   "source_url": "https://wiki.contextgarden.net/FAQ",
   "tier": "T1",
   "checked": "2026-11-24",
   "valid_until": "2027-05-23"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c33",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c33",
   "card": "typesetting-documents-with-claude-code",
   "id": "c33",
   "status": "valid",
   "claim": "A practitioner: the rebuilding of a PDF got moving once Claude could build the document itself and read the LaTeX log.",
   "quote": "It was that Claude could build the book and read the LaTeX log itself",
   "source_url": "https://www.konradvoelkel.com/posts/ds-skript-modernized-with-claude",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  },
  {
   "ref": "typesetting-documents-with-claude-code#c34",
   "url": "https://stacks.jakubdudek.com/typesetting-documents-with-claude-code/c34",
   "card": "typesetting-documents-with-claude-code",
   "id": "c34",
   "status": "valid",
   "claim": "There is a skill, PaperFit: a LaTeX agent with a visual loop (compile, render, diagnose, fix).",
   "quote": "Vision-in-the-loop LaTeX typesetting agent",
   "source_url": "https://github.com/OpenRaiser/PaperFit",
   "tier": "T4",
   "checked": "2026-11-24",
   "valid_until": "2026-12-24"
  }
 ],
 "as_of": "2026-12-04",
 "note": "A claim says what its source said on the day it was checked. \"valid_until\" is the date by which it should be checked again, not a promise that it is true today.",
 "license": "CC BY 4.0",
 "author": "Jakub Dudek",
 "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.\n\n**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].\n\n**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.\n\n**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]\n\n**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].",
 "history": []
}
