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
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: typst-23description: 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. Use when this capability is needed.4---56# Typst Skill78**Current version**: Typst 0.14.2 (Dec 2025)910## Smart Defaults1112If you know nothing else, follow these rules:13141. **Always** import `@local/qk:2.1.0` — `#import "@local/qk:2.1.0": *`152. **Always** use `qk-doc` or `qk-report` preset (unless user specifies custom)163. **Always** use touying for presentations (not raw page dimensions) — see `references/touying-guide.md`174. **Always** `#set figure(placement: auto)` — prevents blank half-pages185. **Always** add `alt:` to images — `image("path.png", alt: "description")`196. **Always** escape `$` in content — scan for bare `$` before compiling207. **Default fonts**: Libertinus Serif (body), Inter (headings), New Computer Modern Math (math), Fira Code (code)218. **Default compile**: `typst compile --root .. Source/<file>.typ`229. **When in doubt** about template: Study Guide2310. **When in doubt** about visual tool: diagrams → fletcher; charts → see decision tree (simple → cetz-plot, statistical → matplotlib+seaborn, grammar → plotnine, complex → matplotlib)2411. **Always** scan project for existing `.typ` files and match their style (fonts, colors, qk preset) unless user specifies otherwise2526## New Document Decision Tree2728```29User request → scan for keywords:30 "resume/CV/job" → CV / Résumé template31 "slides/presentation" → Presentation (touying — metropolis default)32 "lecture/class/academic" → Academic Lecture (touying — university theme)33 "essay/thesis/paper" → Essay34 "report/brief/client" → Business Report35 "research/analysis" → Research Report36 "study guide/revision" → Study Guide37 "reference/glossary" → Annotated Reference38 "cheatsheet/reference card/formula sheet" → Cheatsheet template39 "exam/problem set/homework" → Exam template40 "flashcard/Q&A/quiz" → Flashcard template41 ambiguous? → ask purpose + audience → pick template42```4344**Steps:**451. Auto-detect template from keywords above462. Import `@local/qk:2.1.0` at top473. Use `qk-doc` or `qk-report` preset when applicable484. Auto-select template. State choice in Phase 3 summary. User can re-invoke with explicit type override if wrong.495. Build from `references/templates.md`506. Custom styles are fine — templates are starting points, not constraints5152## Visual Tool Routing (compact)5354**Diagrams** (always native Typst — NEVER Python):5556| Need | Tool |57|------|------|58| Flowcharts, trees, ER, state diagrams | `fletcher` |59| Sequence diagrams | `chronos` |60| Gantt charts | `timeliney` |61| Linear timelines | `herodot` |6263**Charts** (generate SVG, embed with `#figure(image(...))`):6465| Need | Tool |66|------|------|67| Simple charts (< 3 series, < 20 pts) | **cetz-plot** (Typst native, `qk-cycle` colors) |68| Statistical plots (violin, kde, pair, heatmap) | **matplotlib + seaborn** (`use()`, SVG) |69| Grammar-of-graphics / faceted plots | **plotnine** (`theme_qk()`, SVG) |70| Complex charts (4+ series, annotations) | **matplotlib** (full API, SVG) |7172**Images & layout:**7374| Need | Tool |75|------|------|76| Tables, boxes, grids | Typst native |77| Mind maps | `/mindmap` (auto-invoke) |78| Conceptual illustrations | `gemini-generate-image` MCP (auto-invoke) |79| Real photos, logos | `/image-search` (auto-invoke) |8081Detail and examples in `references/tool-routing.md`.8283## Proactive Behaviors8485### Visual Auto-detection8687When 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.8889| Content pattern | Visual to add | Tool |90|-----------------|---------------|------|91| Comparison grids, attribute tables | Styled table | Typst native |92| Callout boxes, styled layouts | `rect()` / `block()` | Typst native |93| Sequential steps, decision logic | Flowchart / decision tree | `fletcher` |94| Process with inputs/outputs | Workflow diagram | `fletcher` |95| System architecture, ER diagrams | Block / entity diagram | `fletcher` |96| Hierarchy or taxonomy | Tree diagram | `fletcher` or `/mindmap` |97| Topic overview, concept map | Mind map | `/mindmap` |98| Request-response, API flows | Sequence diagram | `chronos` |99| Project schedule, phases | Gantt chart | `timeliney` |100| Historical events, evolution | Timeline | `herodot` or `timeliney` |101| Simple data chart (< 3 series, < 20 pts) | Line/bar/scatter chart | cetz-plot (Typst native) |102| Statistical/complex chart | Violin/kde/heatmap/faceted chart | matplotlib+seaborn or plotnine |103| Company logo, brand mark | Logo image | `/image-search --logo` |104| Real-world photograph | Photo | `/image-search` |105| Concept with analogy, metaphor | AI illustration | `gemini-generate-image` MCP |106107See `references/tool-routing.md` for full examples, fallback chains, and auto-invoke rules.108109### Content Structure110111- Suggest TOC (`#outline()`) at 4+ sections112- Suggest file split at 40+ pages — see `references/common-patterns.md` "Large Documents"113- Convert prose lists to tables when 3+ items with attributes114115### Component Library Auto-use116117When writing content, automatically convert matching patterns to `@local/qk:2.1.0` components:118119| Content pattern | Use instead |120|-----------------|-------------|121| Warning paragraph | `warning[...]` |122| Key point / takeaway | `keypoint[...]` |123| Tip or best practice | `tip[...]` |124| Common mistake / trap | `trap[...]` |125| Step-by-step procedure | `step-box("Title", [...])` |126| Key equation / formula | `formula-box("Title", [...])` |127| KPI or metric highlight | `stat-card("value", "label")` |128| Frequency indicator | `freq-badge("HIGH")` / `freq-badge("MEDIUM")` / `freq-badge("LOW")` |129| MCQ answer explanation | `answerbox("A", "why", "trap", "concept")` |130| Analogy / intuition | `analogy[...]` |131| "Why this matters" | `whycare[...]` |132133### Cross-referencing134135Add `<label>` + `@ref` for recurring concepts across sections.136137### Accessibility (Typst 0.14+)138139- `alt:` on all figures — `image("path.png", alt: "description")`140- Semantic heading hierarchy — don't skip levels141- `table.header()` for repeating headers — improves PDF/UA accessibility142143## Fallback Chains144145| If this fails... | Try... |146|------------------|--------|147| `gemini-generate-image` MCP | Placeholder `#rect(width: 100%, height: 4cm, fill: luma(240))[Image placeholder]` |148| `/image-search` | `gemini-generate-image` MCP with descriptive prompt |149| `/mindmap` | `fletcher` tree diagram |150| matplotlib | Check `.venv` → `uv venv .venv.nosync && ln -s .venv.nosync .venv` |151| `typst compile` | Isolate with `/* ... */`, compile incrementally |152153## Reference File Index154155| When you need... | Read... |156|------------------|---------|157| Syntax, errors, special chars | `references/quick-ref.md` |158| `@local/qk:2.1.0` API | `references/component-library.md` |159| Visual tool details, examples, fallbacks | `references/tool-routing.md` |160| Document preambles | `references/templates.md` |161| Table patterns, show rules, large docs | `references/common-patterns.md` |162| Page layout, spacing, figures, curves | `references/layout-patterns.md` |163| Math mode traps | `references/math-pitfalls.md` |164| Package imports | `references/packages.md` |165| Touying presentations (themes, slides, speaker notes) | `references/touying-guide.md` |166| Visual verification (PNG rendering, spot-checks) | `references/visual-verification.md` |167| Quality gates, rubrics, dispatch table | `references/quality-gates.md` |168| Data-driven generation (JSON, CSV, batch, variants) | `references/data-driven.md` |169| `sym.*` symbols | `references/symbols.md` |170171## Version Notes (0.13–0.14)172173| Feature | Ver | Description |174|---------|-----|-------------|175| Tagged PDFs, PDF/UA-1 | 0.14 | Accessible PDFs by default |176| `figure.alt` / `image(alt:)` | 0.14 | Alt text for screen readers |177| `pdf.attach` | 0.14 | Attach files (replaces `pdf.embed`) |178| PDF as image format | 0.14 | `image("file.pdf")` |179| Multiple table headers | 0.14 | Hierarchical headers repeat across pages |180| `curve` function | 0.13 | Bezier drawing (replaces `path`) |181182**Deprecated**: `path` → `curve` · `pdf.embed` → `pdf.attach` · `image.decode` → pass bytes directly · polylux:0.3.1 → `polylux:0.4.0` or `touying`183184| touying 0.6.1 | 0.6 | Presentation framework — `#show: theme.with(...)` API (NOT the old `register()` pattern) |185186## CLI Commands187188```bash189typst compile document.typ # Compile to PDF190typst compile document.typ --root .. # Set project root191typst compile document.typ out.pdf --pages 1-5 # Specific pages192typst watch document.typ # Watch and recompile193typst fonts # List available fonts194typst query doc.typ "heading.where(level: 1)" # Query document structure195```196197**`--root` flag:** When a `.typ` file uses `#import` or `#image()` with paths outside its directory, set `--root` to the project root.198199**Batch compile:** `for f in *.typ; do typst compile "$f"; done`200201## Conventions202203- Source files in `Source/`, compiled PDFs in `PDFs/`204- Compile with `--root ..` when `.typ` references parent directory assets205- For multi-file projects: `main.typ` + `#include` sections + shared `lib.typ`206- File naming: lowercase-kebab-case (e.g., `portfolio-theory-guide.typ`)207208## Fonts209210| Font | Style | Notes |211|------|-------|-------|212| New Computer Modern | Academic serif | Default; bundled with Typst |213| Georgia | Readable serif | Safe on macOS |214| Helvetica Neue | Clean sans-serif | macOS only |215216**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.217218**CJK fallback:** `#set text(font: ("New Computer Modern", "Songti SC"))`219220## Documentation221222- [Official Reference](https://typst.app/docs/reference/)223- [Package Registry](https://typst.app/universe/)224- [Tutorial](https://typst.app/docs/tutorial/)225- [Changelog](https://typst.app/docs/changelog/)226227---228> Converted and distributed by [TomeVault](https://tomevault.io/claim/clearsmog) — claim your Tome and manage your conversions.229<!-- tomevault:4.0:skill_md:2026-04-13 -->