Typst Skill
Current version: Typst 0.14.2 (Dec 2025)
Smart Defaults
If you know nothing else, follow these rules:
- Always import
@local/qk:2.1.0 — #import "@local/qk:2.1.0": *
- Always use
qk-doc or qk-report preset (unless user specifies custom)
- Always use touying for presentations (not raw page dimensions) — see
references/touying-guide.md
- Always
#set figure(placement: auto) — prevents blank half-pages
- Always add
alt: to images — image("path.png", alt: "description")
- Always escape
$ in content — scan for bare $ before compiling
- Default fonts: Libertinus Serif (body), Inter (headings), New Computer Modern Math (math), Fira Code (code)
- Default compile:
typst compile --root .. Source/<file>.typ
- When in doubt about template: Study Guide
- When in doubt about visual tool: diagrams → fletcher; charts → see decision tree (simple → cetz-plot, statistical → matplotlib+seaborn, grammar → plotnine, complex → matplotlib)
- Always scan project for existing
.typ files and match their style (fonts, colors, qk preset) unless user specifies otherwise
New Document Decision Tree
User request → scan for keywords:
"resume/CV/job" → CV / Résumé template
"slides/presentation" → Presentation (touying — metropolis default)
"lecture/class/academic" → Academic Lecture (touying — university theme)
"essay/thesis/paper" → Essay
"report/brief/client" → Business Report
"research/analysis" → Research Report
"study guide/revision" → Study Guide
"reference/glossary" → Annotated Reference
"cheatsheet/reference card/formula sheet" → Cheatsheet template
"exam/problem set/homework" → Exam template
"flashcard/Q&A/quiz" → Flashcard template
ambiguous? → ask purpose + audience → pick template
Steps:
- Auto-detect template from keywords above
- Import
@local/qk:2.1.0 at top
- Use
qk-doc or qk-report preset when applicable
- Auto-select template. State choice in Phase 3 summary. User can re-invoke with explicit type override if wrong.
- Build from
references/templates.md
- Custom styles are fine — templates are starting points, not constraints
Visual Tool Routing (compact)
Diagrams (always native Typst — NEVER Python):
| Need |
Tool |
| Flowcharts, trees, ER, state diagrams |
fletcher |
| Sequence diagrams |
chronos |
| Gantt charts |
timeliney |
| Linear timelines |
herodot |
Charts (generate SVG, embed with #figure(image(...))):
| Need |
Tool |
| Simple charts (< 3 series, < 20 pts) |
cetz-plot (Typst native, qk-cycle colors) |
| Statistical plots (violin, kde, pair, heatmap) |
matplotlib + seaborn (use(), SVG) |
| Grammar-of-graphics / faceted plots |
plotnine (theme_qk(), SVG) |
| Complex charts (4+ series, annotations) |
matplotlib (full API, SVG) |
Images & layout:
| Need |
Tool |
| Tables, boxes, grids |
Typst native |
| Mind maps |
/mindmap (auto-invoke) |
| Conceptual illustrations |
gemini-generate-image MCP (auto-invoke) |
| Real photos, logos |
/image-search (auto-invoke) |
Detail and examples in references/tool-routing.md.
Proactive Behaviors
Visual Auto-detection
When writing Typst documents, automatically identify content that benefits from visuals. Do NOT wait for the user to request them. Route by content type: diagrams → native Typst (fletcher/chronos/timeliney/herodot); charts → cetz-plot (simple) / matplotlib or plotnine (complex) — generate SVG, embed; images → /image-search / /mindmap / gemini-generate-image MCP.
| Content pattern |
Visual to add |
Tool |
| Comparison grids, attribute tables |
Styled table |
Typst native |
| Callout boxes, styled layouts |
rect() / block() |
Typst native |
| Sequential steps, decision logic |
Flowchart / decision tree |
fletcher |
| Process with inputs/outputs |
Workflow diagram |
fletcher |
| System architecture, ER diagrams |
Block / entity diagram |
fletcher |
| Hierarchy or taxonomy |
Tree diagram |
fletcher or /mindmap |
| Topic overview, concept map |
Mind map |
/mindmap |
| Request-response, API flows |
Sequence diagram |
chronos |
| Project schedule, phases |
Gantt chart |
timeliney |
| Historical events, evolution |
Timeline |
herodot or timeliney |
| Simple data chart (< 3 series, < 20 pts) |
Line/bar/scatter chart |
cetz-plot (Typst native) |
| Statistical/complex chart |
Violin/kde/heatmap/faceted chart |
matplotlib+seaborn or plotnine |
| Company logo, brand mark |
Logo image |
/image-search --logo |
| Real-world photograph |
Photo |
/image-search |
| Concept with analogy, metaphor |
AI illustration |
gemini-generate-image MCP |
See references/tool-routing.md for full examples, fallback chains, and auto-invoke rules.
Content Structure
- Suggest TOC (
#outline()) at 4+ sections
- Suggest file split at 40+ pages — see
references/common-patterns.md "Large Documents"
- Convert prose lists to tables when 3+ items with attributes
Component Library Auto-use
When writing content, automatically convert matching patterns to @local/qk:2.1.0 components:
| Content pattern |
Use instead |
| Warning paragraph |
warning[...] |
| Key point / takeaway |
keypoint[...] |
| Tip or best practice |
tip[...] |
| Common mistake / trap |
trap[...] |
| Step-by-step procedure |
step-box("Title", [...]) |
| Key equation / formula |
formula-box("Title", [...]) |
| KPI or metric highlight |
stat-card("value", "label") |
| Frequency indicator |
freq-badge("HIGH") / freq-badge("MEDIUM") / freq-badge("LOW") |
| MCQ answer explanation |
answerbox("A", "why", "trap", "concept") |
| Analogy / intuition |
analogy[...] |
| "Why this matters" |
whycare[...] |
Cross-referencing
Add <label> + @ref for recurring concepts across sections.
Accessibility (Typst 0.14+)
alt: on all figures — image("path.png", alt: "description")
- Semantic heading hierarchy — don't skip levels
table.header() for repeating headers — improves PDF/UA accessibility
Fallback Chains
| If this fails... |
Try... |
gemini-generate-image MCP |
Placeholder #rect(width: 100%, height: 4cm, fill: luma(240))[Image placeholder] |
/image-search |
gemini-generate-image MCP with descriptive prompt |
/mindmap |
fletcher tree diagram |
| matplotlib |
Check .venv → uv venv .venv.nosync && ln -s .venv.nosync .venv |
typst compile |
Isolate with /* ... */, compile incrementally |
Reference File Index
| When you need... |
Read... |
| Syntax, errors, special chars |
references/quick-ref.md |
@local/qk:2.1.0 API |
references/component-library.md |
| Visual tool details, examples, fallbacks |
references/tool-routing.md |
| Document preambles |
references/templates.md |
| Table patterns, show rules, large docs |
references/common-patterns.md |
| Page layout, spacing, figures, curves |
references/layout-patterns.md |
| Math mode traps |
references/math-pitfalls.md |
| Package imports |
references/packages.md |
| Touying presentations (themes, slides, speaker notes) |
references/touying-guide.md |
| Visual verification (PNG rendering, spot-checks) |
references/visual-verification.md |
| Quality gates, rubrics, dispatch table |
references/quality-gates.md |
| Data-driven generation (JSON, CSV, batch, variants) |
references/data-driven.md |
sym.* symbols |
references/symbols.md |
Version Notes (0.13–0.14)
| Feature |
Ver |
Description |
| Tagged PDFs, PDF/UA-1 |
0.14 |
Accessible PDFs by default |
figure.alt / image(alt:) |
0.14 |
Alt text for screen readers |
pdf.attach |
0.14 |
Attach files (replaces pdf.embed) |
| PDF as image format |
0.14 |
image("file.pdf") |
| Multiple table headers |
0.14 |
Hierarchical headers repeat across pages |
curve function |
0.13 |
Bezier drawing (replaces path) |
Deprecated: path → curve · pdf.embed → pdf.attach · image.decode → pass bytes directly · polylux:0.3.1 → polylux:0.4.0 or touying
| touying 0.6.1 | 0.6 | Presentation framework — #show: theme.with(...) API (NOT the old register() pattern) |
CLI Commands
typst compile document.typ # Compile to PDF
typst compile document.typ --root .. # Set project root
typst compile document.typ out.pdf --pages 1-5 # Specific pages
typst watch document.typ # Watch and recompile
typst fonts # List available fonts
typst query doc.typ "heading.where(level: 1)" # Query document structure
--root flag: When a .typ file uses #import or #image() with paths outside its directory, set --root to the project root.
Batch compile: for f in *.typ; do typst compile "$f"; done
Conventions
- Source files in
Source/, compiled PDFs in PDFs/
- Compile with
--root .. when .typ references parent directory assets
- For multi-file projects:
main.typ + #include sections + shared lib.typ
- File naming: lowercase-kebab-case (e.g.,
portfolio-theory-guide.typ)
Fonts
| Font |
Style |
Notes |
| New Computer Modern |
Academic serif |
Default; bundled with Typst |
| Georgia |
Readable serif |
Safe on macOS |
| Helvetica Neue |
Clean sans-serif |
macOS only |
Variable font warning: Apple system fonts (New York, SF Pro) are variable → "variable fonts are not currently supported." Install static .otf/.ttf versions or use alternatives.
CJK fallback: #set text(font: ("New Computer Modern", "Songti SC"))
Documentation
1---2name: typst3description: Syntax guide and ecosystem reference for writing Typst (.typ) files. Use this skill when writing, editing, or debugging Typst documents. Covers core syntax, common errors, packages, and best practices.4license: MIT5---67# Typst Skill89**Current version**: Typst 0.14.2 (Dec 2025)1011## Smart Defaults1213If you know nothing else, follow these rules:14151. **Always** import `@local/qk:2.1.0` — `#import "@local/qk:2.1.0": *`162. **Always** use `qk-doc` or `qk-report` preset (unless user specifies custom)173. **Always** use touying for presentations (not raw page dimensions) — see `references/touying-guide.md`184. **Always** `#set figure(placement: auto)` — prevents blank half-pages195. **Always** add `alt:` to images — `image("path.png", alt: "description")`206. **Always** escape `$` in content — scan for bare `$` before compiling217. **Default fonts**: Libertinus Serif (body), Inter (headings), New Computer Modern Math (math), Fira Code (code)228. **Default compile**: `typst compile --root .. Source/<file>.typ`239. **When in doubt** about template: Study Guide2410. **When in doubt** about visual tool: diagrams → fletcher; charts → see decision tree (simple → cetz-plot, statistical → matplotlib+seaborn, grammar → plotnine, complex → matplotlib)2511. **Always** scan project for existing `.typ` files and match their style (fonts, colors, qk preset) unless user specifies otherwise2627## New Document Decision Tree2829```30User request → scan for keywords:31 "resume/CV/job" → CV / Résumé template32 "slides/presentation" → Presentation (touying — metropolis default)33 "lecture/class/academic" → Academic Lecture (touying — university theme)34 "essay/thesis/paper" → Essay35 "report/brief/client" → Business Report36 "research/analysis" → Research Report37 "study guide/revision" → Study Guide38 "reference/glossary" → Annotated Reference39 "cheatsheet/reference card/formula sheet" → Cheatsheet template40 "exam/problem set/homework" → Exam template41 "flashcard/Q&A/quiz" → Flashcard template42 ambiguous? → ask purpose + audience → pick template43```4445**Steps:**461. Auto-detect template from keywords above472. Import `@local/qk:2.1.0` at top483. Use `qk-doc` or `qk-report` preset when applicable494. Auto-select template. State choice in Phase 3 summary. User can re-invoke with explicit type override if wrong.505. Build from `references/templates.md`516. Custom styles are fine — templates are starting points, not constraints5253## Visual Tool Routing (compact)5455**Diagrams** (always native Typst — NEVER Python):5657| Need | Tool |58|------|------|59| Flowcharts, trees, ER, state diagrams | `fletcher` |60| Sequence diagrams | `chronos` |61| Gantt charts | `timeliney` |62| Linear timelines | `herodot` |6364**Charts** (generate SVG, embed with `#figure(image(...))`):6566| Need | Tool |67|------|------|68| Simple charts (< 3 series, < 20 pts) | **cetz-plot** (Typst native, `qk-cycle` colors) |69| Statistical plots (violin, kde, pair, heatmap) | **matplotlib + seaborn** (`use()`, SVG) |70| Grammar-of-graphics / faceted plots | **plotnine** (`theme_qk()`, SVG) |71| Complex charts (4+ series, annotations) | **matplotlib** (full API, SVG) |7273**Images & layout:**7475| Need | Tool |76|------|------|77| Tables, boxes, grids | Typst native |78| Mind maps | `/mindmap` (auto-invoke) |79| Conceptual illustrations | `gemini-generate-image` MCP (auto-invoke) |80| Real photos, logos | `/image-search` (auto-invoke) |8182Detail and examples in `references/tool-routing.md`.8384## Proactive Behaviors8586### Visual Auto-detection8788When writing Typst documents, automatically identify content that benefits from visuals. Do NOT wait for the user to request them. Route by content type: diagrams → native Typst (fletcher/chronos/timeliney/herodot); charts → cetz-plot (simple) / matplotlib or plotnine (complex) — generate SVG, embed; images → `/image-search` / `/mindmap` / `gemini-generate-image` MCP.8990| Content pattern | Visual to add | Tool |91|-----------------|---------------|------|92| Comparison grids, attribute tables | Styled table | Typst native |93| Callout boxes, styled layouts | `rect()` / `block()` | Typst native |94| Sequential steps, decision logic | Flowchart / decision tree | `fletcher` |95| Process with inputs/outputs | Workflow diagram | `fletcher` |96| System architecture, ER diagrams | Block / entity diagram | `fletcher` |97| Hierarchy or taxonomy | Tree diagram | `fletcher` or `/mindmap` |98| Topic overview, concept map | Mind map | `/mindmap` |99| Request-response, API flows | Sequence diagram | `chronos` |100| Project schedule, phases | Gantt chart | `timeliney` |101| Historical events, evolution | Timeline | `herodot` or `timeliney` |102| Simple data chart (< 3 series, < 20 pts) | Line/bar/scatter chart | cetz-plot (Typst native) |103| Statistical/complex chart | Violin/kde/heatmap/faceted chart | matplotlib+seaborn or plotnine |104| Company logo, brand mark | Logo image | `/image-search --logo` |105| Real-world photograph | Photo | `/image-search` |106| Concept with analogy, metaphor | AI illustration | `gemini-generate-image` MCP |107108See `references/tool-routing.md` for full examples, fallback chains, and auto-invoke rules.109110### Content Structure111112- Suggest TOC (`#outline()`) at 4+ sections113- Suggest file split at 40+ pages — see `references/common-patterns.md` "Large Documents"114- Convert prose lists to tables when 3+ items with attributes115116### Component Library Auto-use117118When writing content, automatically convert matching patterns to `@local/qk:2.1.0` components:119120| Content pattern | Use instead |121|-----------------|-------------|122| Warning paragraph | `warning[...]` |123| Key point / takeaway | `keypoint[...]` |124| Tip or best practice | `tip[...]` |125| Common mistake / trap | `trap[...]` |126| Step-by-step procedure | `step-box("Title", [...])` |127| Key equation / formula | `formula-box("Title", [...])` |128| KPI or metric highlight | `stat-card("value", "label")` |129| Frequency indicator | `freq-badge("HIGH")` / `freq-badge("MEDIUM")` / `freq-badge("LOW")` |130| MCQ answer explanation | `answerbox("A", "why", "trap", "concept")` |131| Analogy / intuition | `analogy[...]` |132| "Why this matters" | `whycare[...]` |133134### Cross-referencing135136Add `<label>` + `@ref` for recurring concepts across sections.137138### Accessibility (Typst 0.14+)139140- `alt:` on all figures — `image("path.png", alt: "description")`141- Semantic heading hierarchy — don't skip levels142- `table.header()` for repeating headers — improves PDF/UA accessibility143144## Fallback Chains145146| If this fails... | Try... |147|------------------|--------|148| `gemini-generate-image` MCP | Placeholder `#rect(width: 100%, height: 4cm, fill: luma(240))[Image placeholder]` |149| `/image-search` | `gemini-generate-image` MCP with descriptive prompt |150| `/mindmap` | `fletcher` tree diagram |151| matplotlib | Check `.venv` → `uv venv .venv.nosync && ln -s .venv.nosync .venv` |152| `typst compile` | Isolate with `/* ... */`, compile incrementally |153154## Reference File Index155156| When you need... | Read... |157|------------------|---------|158| Syntax, errors, special chars | `references/quick-ref.md` |159| `@local/qk:2.1.0` API | `references/component-library.md` |160| Visual tool details, examples, fallbacks | `references/tool-routing.md` |161| Document preambles | `references/templates.md` |162| Table patterns, show rules, large docs | `references/common-patterns.md` |163| Page layout, spacing, figures, curves | `references/layout-patterns.md` |164| Math mode traps | `references/math-pitfalls.md` |165| Package imports | `references/packages.md` |166| Touying presentations (themes, slides, speaker notes) | `references/touying-guide.md` |167| Visual verification (PNG rendering, spot-checks) | `references/visual-verification.md` |168| Quality gates, rubrics, dispatch table | `references/quality-gates.md` |169| Data-driven generation (JSON, CSV, batch, variants) | `references/data-driven.md` |170| `sym.*` symbols | `references/symbols.md` |171172## Version Notes (0.13–0.14)173174| Feature | Ver | Description |175|---------|-----|-------------|176| Tagged PDFs, PDF/UA-1 | 0.14 | Accessible PDFs by default |177| `figure.alt` / `image(alt:)` | 0.14 | Alt text for screen readers |178| `pdf.attach` | 0.14 | Attach files (replaces `pdf.embed`) |179| PDF as image format | 0.14 | `image("file.pdf")` |180| Multiple table headers | 0.14 | Hierarchical headers repeat across pages |181| `curve` function | 0.13 | Bezier drawing (replaces `path`) |182183**Deprecated**: `path` → `curve` · `pdf.embed` → `pdf.attach` · `image.decode` → pass bytes directly · polylux:0.3.1 → `polylux:0.4.0` or `touying`184185| touying 0.6.1 | 0.6 | Presentation framework — `#show: theme.with(...)` API (NOT the old `register()` pattern) |186187## CLI Commands188189```bash190typst compile document.typ # Compile to PDF191typst compile document.typ --root .. # Set project root192typst compile document.typ out.pdf --pages 1-5 # Specific pages193typst watch document.typ # Watch and recompile194typst fonts # List available fonts195typst query doc.typ "heading.where(level: 1)" # Query document structure196```197198**`--root` flag:** When a `.typ` file uses `#import` or `#image()` with paths outside its directory, set `--root` to the project root.199200**Batch compile:** `for f in *.typ; do typst compile "$f"; done`201202## Conventions203204- Source files in `Source/`, compiled PDFs in `PDFs/`205- Compile with `--root ..` when `.typ` references parent directory assets206- For multi-file projects: `main.typ` + `#include` sections + shared `lib.typ`207- File naming: lowercase-kebab-case (e.g., `portfolio-theory-guide.typ`)208209## Fonts210211| Font | Style | Notes |212|------|-------|-------|213| New Computer Modern | Academic serif | Default; bundled with Typst |214| Georgia | Readable serif | Safe on macOS |215| Helvetica Neue | Clean sans-serif | macOS only |216217**Variable font warning:** Apple system fonts (New York, SF Pro) are variable → "variable fonts are not currently supported." Install static `.otf`/`.ttf` versions or use alternatives.218219**CJK fallback:** `#set text(font: ("New Computer Modern", "Songti SC"))`220221## Documentation222223- [Official Reference](https://typst.app/docs/reference/)224- [Package Registry](https://typst.app/universe/)225- [Tutorial](https://typst.app/docs/tutorial/)226- [Changelog](https://typst.app/docs/changelog/)