Declare a LaTeX document family once, in Python types. texmodel renders it to plain, readable, git-trackable .sty source:
commit it, diff it, compile it with whatever LaTeX setup you already have. The same declarations give you documents as
Python objects, a JSON Schema for their data, checks that committed files are current, and typed compile diagnostics.
Status: alpha. The public API may change before 1.0. What is missing today: known limitations.
pip install texmodel # the library and the texmodel command
pip install 'texmodel[proof-pdf]' # plus the proof-pdf verifierfrom texmodel.components import Command, Value
from texmodel.package import Package
from texmodel.types import Length, Text
pkg = Package("acme-cards", prefix="ac", version="1.4.0", date="2026/10/21")
@pkg.value
class FactGap(Value[Length]):
"""Space under each fact."""
default = Length("2mm")
@pkg.command
class Fact(Command):
"""One short sentence under the title."""
text: Text
body = r"\par\noindent #text\par\vspace{\acFactGap}"
print(pkg.render()) # the .sty
print(pkg.document(Fact(text="50% of $5"))) # \acFact{50\% of \$5}, escapedtexmodel build # writes generated/acme-cards.sty
texmodel check # exit 1 if a committed generated file is stale, missing or orphaned- Deterministic. No timestamps or hashes; the header records the generator version.
- Checked early. A bad declaration is refused when the class is defined, with a stable code (
TM-M0xx) and the class named. A bad document reports everything wrong at once, each with a path. - Typed.
Textis escaped,Rawpasses through;Length, colours, flags, choices and key lists are values, not strings. - No TeX needed to run. The library never starts a process.
texmodel.runis the optionallatexmkdriver.
| Getting started | declare, render, check: a worked first package |
| Guide | components, arguments, values, documents, adopting existing TeX, testing |
| Cookbook | worked examples |
| Known limitations | what it does not do |
| Plan and decisions | the target specification and the decisions log |
pdm run mkdocs serve builds the same pages as a site.
See CONTRIBUTING.md. Public API is the top-level modules of each package; everything under _internal may
change. Report vulnerabilities as described in SECURITY.md.
MIT. The reference images carry their own licences (Ghostscript is AGPL); texmodel run runs them as a
separate process and ships none of their code.