Wrap a Typst Template
A Typst template is already most of a quill. Typst does all the typesetting in Quillmark’s Typst backend, so the template runs as its author wrote it. Wrapping it adds the two things a template does not carry: a schema of its arguments, and a plate that passes a document’s fields to it.
The result is for the people who will never write Typst. They get a form beside a live page, checked fields, and a document that is Markdown and a few named values.
When to wrap, and when not to
Section titled “When to wrap, and when not to”Wrap a template whose documents are data and prose: a letter, an invoice, a memo, a certificate, a CV, a short report.
Stay in Typst when the people writing the documents write Typst in the body. A quill’s body is Markdown, so it has no form for the template’s own functions, figures with labels and @references, #cite or #bibliography. A thesis, a paper or a slide deck stays a Typst project.
If you are comfortable in Typst and fill your own documents, a template that reads yaml("data.yml") is a fine setup, and you do not need this. A quill is for when the person filling in the data is not you.
The template
Section titled “The template”This page wraps a small invoice template written for it. It takes named arguments and a body, as most Typst Universe templates do, and its example file calls it with a show rule:
#import "@preview/crisp-invoice:1.2.0": invoice
#show: invoice.with( number: "2026-014", date: datetime(year: 2026, month: 3, day: 2), seller: (name: "Okafor Studio", address: [12 Canal Street \ Leeds LS1 4AB]), client: (name: "Brightwater Ltd", address: [Unit 5, Mill Yard \ York YO1 7PR]), items: ( (description: "Brand guidelines", quantity: 1, price: 1800), (description: "Icon set", quantity: 24, price: 35.5), ), tax-rate: 0.2, notes: [Payment by bank transfer. Thank you.],)
Thank you for your business. This invoice covers the work agreed in *February*.1. Vendor the template
Section titled “1. Vendor the template”Make a quill directory, invoice/, as Creating Quills does, and run the commands below from inside it. Copy the template into it as a package, with every package it imports beside it:
invoice/├── Quill.yaml├── plate.typ└── packages/ ├── crisp-invoice/ the template: typst.toml, lib.typ, LICENSE └── rule-kit/ a package the template importsQuillmark never downloads a package, so each one the template reaches is vendored. Add namespace = "preview" to each typst.toml, and every #import "@preview/…" resolves as the author wrote it (Typst Packages). Nothing else in the template changes.
A render reads no installed font. Put the fonts the template names under assets/fonts/, where their licence lets you (Fonts).
Keep the template’s licence file where it is, and carry its licence, author and home into the quill:
quill: name: invoice version: 0.0.1 backend: typst description: A clean one-page invoice author: Mira Okafor license: MIT homepage: https://example.com/crisp-invoice2. Render the template as it is
Section titled “2. Render the template as it is”Before declaring any field, save the template’s example file as plate.typ, under a schema with no fields:
schema: main: description: Nothing to fill yet.npx quillmark render --blank -o ../reference.pdfThis is the template’s own page, drawn by the engine your quill will use. If it fails, the cause is the vendoring: a package, a font or an asset path. Keep the PDF, outside the quill so packing never carries it. It is what the finished quill must print.
3. Declare the arguments as fields
Section titled “3. Declare the arguments as fields”Each argument the example file sets becomes a field in Quill.yaml. One it never sets keeps the template’s default and stays out of the schema.
| In the template | In Quill.yaml |
|---|---|
| a string | text, or enum where it takes one of a few values |
content, [..] |
richtext, or text with shape: lines for an address |
a datetime |
date, with default: today for datetime.today() |
| a number, a boolean | integer, number, boolean |
| an array of dictionaries | array of object, a table of rows in the form |
| a dictionary | object, a group in the form |
| the trailing body | the Markdown body, never a field |
schema: main: description: Write a covering note as plain paragraphs, or leave it out. body: example: | Thank you for your business. This invoice covers the work agreed in **February**. fields: number: type: text example: 2026-014 description: The invoice number. date: type: date default: today example: 2026-03-02 description: Leave as today to date the invoice when it prints. items: type: array items: type: object properties: description: { type: text } quantity: { type: number } price: { type: number } example: - { description: Brand guidelines, quantity: 1, price: 1800 } - { description: Icon set, quantity: 24, price: 35.5 } description: One row for each thing billed. tax_rate: type: number example: 0.2 description: "Tax as a fraction: 0.2 is 20%." notes: type: richtext example: Payment by bank transfer. Thank you. description: Small print at the foot of the page. Leave blank for none. seller: type: object title: From properties: name: { type: text, example: Okafor Studio, description: Your trading name. } address: type: text shape: lines example: |- 12 Canal Street Leeds LS1 4AB description: Your address, one line each. client: type: object title: Bill to properties: name: { type: text, example: Brightwater Ltd, description: Who is billed. } address: type: text shape: lines example: |- Unit 5, Mill Yard York YO1 7PR description: Their address, one line each.The examples are the example file’s own values. Its body moves over as Markdown, so Typst’s *bold* is written **bold**. Describe each field for someone who has never seen the template.
4. Call the template from the plate
Section titled “4. Call the template from the plate”The plate is the example file again, with each literal replaced by a field:
#import "@local/quillmark-helper:0.2.0" as qm#import "@preview/crisp-invoice:1.2.0": invoice
#let d = qm.data
#show: invoice.with( number: qm.str(d.number), date: d.date, seller: (name: qm.str(d.seller.name), address: qm.ink(d.seller, "address")), client: (name: qm.ink(d.client, "name"), address: qm.ink(d.client, "address")), items: d.items, tax-rate: d.tax_rate, notes: if d.notes != "" { qm.ink(d, "notes") },)
#d.at("$body", default: "")Three things in it are worth knowing:
- A value the template only prints goes through
qm.ink. It keeps its click target through the call, so a click on the client’s name in an editor preview opens that field. A table row’s text keeps its target too. - A value the template computes with goes through
qm.str. Atextfield arrives as content, and a template that callsstr(..)or.len()on an argument, or hands it toset document(author: ..), needs a string (Text as a str). That text prints without a click target. - A blank is not always what the template tests for. This template leaves the notes out when they are
none, and a blankrichtextis"", so the plate turns one into the other (Blank values).
5. Check it against the template
Section titled “5. Check it against the template”Render the quill’s example and put it beside the reference from step 2:
npx quillmark render -o ../compare.pdfnpx quillmark check --strictBoth pages come from the same template and the same engine, so they match line for line. A difference is a field wired wrong.
Then open the quill in studio, clear the form and look at the blank page:
npx quillmark studio --openThe template decides what a blank page prints, a label with nothing under it included. Where that matters, guard the label in your vendored copy, and keep a note of the edit beside it.
With Claude Code
Section titled “With Claude Code”The quillmark plugin for Claude Code follows this page (install it). Hand it the template’s sources and example file, or run /quillmark:wrap-typst. It vendors the template, renders the reference, writes the schema and the plate, and compares the two renders. It reports which fields are not click-to-edit, what the blank page prints, and any edit it made to the vendored copy.