Documents an agent can write, check and typeset.
texwright turns Markdown, LaTeX or a JSON document tree into PDF or HTML with its own TeX-style engine. Equations, cross-references, citations and footnotes come out the way LaTeX sets them. Mermaid diagrams and TikZ pictures are drawn in place. There is no TeX install and no browser, only one Node.js package with no dependencies.
zip 3.1 MB · Node.js 20+ · Windows and Linux
- lines
- 7
- loose lines
- 2
- worst badness
- 281
- total demerits
- 93,790
Real line breaking on a sample paragraph, without hyphenation
Give it to your agent in one line.
Paste this into any coding agent. The guide it points to is written for models: the syntax, the check, fix and render loop, and what each diagnostic means.
Read https://sophiaxt.com/texwright/AGENTS.md and use texwright to make PDFs from Markdown or LaTeX.
Install from this page
npm installs straight from the tarball here. Nothing to register.
npm install -g https://sophiaxt.com/texwright/texwright-latest.tgz
texwright doc.md -o doc.pdf
Or unzip and run
The zip is the same package. Unzip it anywhere with Node.js 20 or later.
node texwright/dist/cli.mjs doc.md -o doc.pdf
As an MCP server
Nine tools: render, check, fix, repair in one call, outline, preview a page as PNG, the schema, the guide, and new documents from templates.
{
"mcpServers": {
"texwright": { "command": "texwright", "args": ["mcp"] }
}
}Problems come back as data,
with the fix attached.
doc.md:3:5 E REF001 Reference to undefined label "sec:intr" | Did you mean "sec:intro"? | fix "sec:intr" -> "sec:intro" safe
Every stage but page layout, in milliseconds. One line per problem, with a code, a position and a hint.
texwright check doc.md --diagnostics compactMost diagnostics carry their fix as an edit. The unambiguous ones apply in one go.
texwright check doc.md --fixThe result says which page each heading, figure and table landed on.
texwright doc.md -o doc.pdfThe page as a PNG from texwright's own rasterizer, so the agent can see what it made.
texwright preview doc.md --page 2A paper, a homework set
or a report, from plain text.
- Mathematics by TeX's rules. amsmath and amssymb, numbered rows in align and gather, siunitx, mhchem and physics commands without loading anything.
- References that resolve. Sections, figures, tables, equations, theorems and listings numbered, with @fig:x, \ref, \eqref, \cref and exact page references.
- Citations. BibTeX or CSL-JSON, numeric or author-year.
- Pages like LaTeX's. Knuth-Plass line breaking, TeX hyphenation, footnotes at the foot of the page, floating figures, Latin Modern type.
- Three inputs, mixed freely. Markdown with pandoc's extensions, LaTeX as models write it (article, report, book, IEEEtran, revtex, llncs, moderncv, exam, beamer and more), or a JSON document tree.
- Layout and brand from the document. Paper, margins, size, theme, running heads, authors and brand fonts (mainfont, sansfont, monofont; TTF, OTF, WOFF or WOFF2) as pandoc's front-matter keys. No template to edit.


3D plots, circuits, trees
and PSTricks, with no TeX.
These are the drawing packages models reach for when a document needs a figure, and the ones a converter without TeX drops. We wrote 56 documents the way models write them (13 pgfplots 3D, 14 trees and graphs, 14 circuits, 15 PSTricks). texwright draws the figure in all 56. Pandoc's HTML output, without a TeX install, keeps it in none. What is approximated comes back as a warning, and the rest of the picture is still drawn.






Mermaid and TikZ,
drawn by texwright.
A fenced mermaid block becomes a numbered figure. texwright reads Mermaid's syntax with its own parsers and lays the diagram out itself: no browser, a few milliseconds per diagram, labels set in the sans companion of Computer Modern so they match the page. A mistake comes back as DIAG001 at its line, with a hint and usually the fix.
- Flowcharts
- Sequence
- Class
- State
- ER
- Gantt
- Pie
- XY charts
- Quadrant
- Timeline
- Mindmap
- Journey
```{.mermaid #fig:flow caption="Request handling"}
flowchart LR
client([Client]) --> api[API] -->|query| db[(Database)]
```TikZ and pgfplots go through texwright's own interpreter: paths, nodes and shapes, styles, \foreach, positioning and calc, automata, and axes with plots, bars, legends and log scales. Labels use the document's math, so they match the equations around them.




SVG, drawn the way
a browser draws it.
Agents make their figures as SVG: charts, diagrams, Mermaid and draw.io exports. texwright draws gradients, transparency, masks, blend modes, filters, text on paths, HTML labels and full CSS selectors. Each pair is Chrome on the left and texwright's PDF on the right, the PDF drawn by poppler.

Chrome

texwright PDF

Chrome

texwright PDF

Chrome

texwright PDF

Chrome

texwright PDF

Chrome

texwright PDF

Chrome

texwright PDF

Chrome

texwright PDF

Chrome

texwright PDF
Tested on what models actually write.
We asked models for 80 documents (papers, homework, lecture notes, lab reports, CVs, letters, exams) written for pandoc or an ordinary LaTeX installation, then rendered them as they came. All 80 now render with no errors and no warnings; the last one to pass drew its figure in TikZ. A further 30 LaTeX documents in the classes and packages models reach for also check clean. A command starts in about 0.2 seconds, and through the MCP server repeat calls take 15 to 20 ms. The method and the held-out results are in the paper.
What it does not do yet. PSTricks' psmatrix and packages built far beyond TikZ are reported rather than drawn: export those figures as SVG. Beamer comes out as a document, not slides. Hyphenation is English only. Arabic, the Indic scripts and right-to-left text are not supported, the PDF is not tagged for screen readers, and PDF files cannot be used as figures.
Everything, with one address that always works.
texwright-latest.zip and texwright-latest.tgz always hold the newest version, so an agent can keep one address. Only the current version is kept under its own name as well.
| File | What it is | Size | SHA-256 |
|---|---|---|---|
| texwright-0.3.4.zip | The package as a zip. Unzip and run with Node.js. | 3.1 MB | eeea43605e9111f7… |
| texwright-0.3.4.tgz | The same package for npm install. | 2.8 MB | a91a9c923adc5ac5… |
| AGENTS.md | The guide for agents: syntax, the loop, diagnostics. | ||
| CHEATSHEET.md | One page of syntax. | ||
| texwright-paper.pdf | The paper: design, engine, benchmark, security. | 336 KB | |
| release.json | Version, install line, sizes and full SHA-256 hashes. | ||
| llms.txt | This page for language models. |
MIT texwright is written by Thomas Garren at SOPHIA XT. Its text is set in Latin Modern (GUST Font License) and its mathematics in the KaTeX fonts (SIL Open Font License); both ship inside the package.