typst

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.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "typst" with this command: npx skills add clearsmog/claude-skills/clearsmog-claude-skills-typst

Typst Skill

Current version: Typst 0.14.2 (Dec 2025)

Smart Defaults

If you know nothing else, follow these rules:

  1. Always import @local/qk:2.1.0#import "@local/qk:2.1.0": *
  2. Always use qk-doc or qk-report preset (unless user specifies custom)
  3. Always use touying for presentations (not raw page dimensions) — see references/touying-guide.md
  4. Always #set figure(placement: auto) — prevents blank half-pages
  5. Always add alt: to images — image("path.png", alt: "description")
  6. Always escape $ in content — scan for bare $ before compiling
  7. Default fonts: Libertinus Serif (body), Inter (headings), New Computer Modern Math (math), Fira Code (code)
  8. Default compile: typst compile --root .. Source/<file>.typ
  9. When in doubt about template: Study Guide
  10. When in doubt about visual tool: diagrams → fletcher; charts → see decision tree (simple → cetz-plot, statistical → matplotlib+seaborn, grammar → plotnine, complex → matplotlib)
  11. 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:

  1. Auto-detect template from keywords above
  2. Import @local/qk:2.1.0 at top
  3. Use qk-doc or qk-report preset when applicable
  4. Auto-select template. State choice in Phase 3 summary. User can re-invoke with explicit type override if wrong.
  5. Build from references/templates.md
  6. Custom styles are fine — templates are starting points, not constraints

Visual Tool Routing (compact)

Diagrams (always native Typst — NEVER Python):

NeedTool
Flowcharts, trees, ER, state diagramsfletcher
Sequence diagramschronos
Gantt chartstimeliney
Linear timelinesherodot

Charts (generate SVG, embed with #figure(image(...))):

NeedTool
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 plotsplotnine (theme_qk(), SVG)
Complex charts (4+ series, annotations)matplotlib (full API, SVG)

Images & layout:

NeedTool
Tables, boxes, gridsTypst native
Mind maps/mindmap (auto-invoke)
Conceptual illustrationsgemini-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 patternVisual to addTool
Comparison grids, attribute tablesStyled tableTypst native
Callout boxes, styled layoutsrect() / block()Typst native
Sequential steps, decision logicFlowchart / decision treefletcher
Process with inputs/outputsWorkflow diagramfletcher
System architecture, ER diagramsBlock / entity diagramfletcher
Hierarchy or taxonomyTree diagramfletcher or /mindmap
Topic overview, concept mapMind map/mindmap
Request-response, API flowsSequence diagramchronos
Project schedule, phasesGantt charttimeliney
Historical events, evolutionTimelineherodot or timeliney
Simple data chart (< 3 series, < 20 pts)Line/bar/scatter chartcetz-plot (Typst native)
Statistical/complex chartViolin/kde/heatmap/faceted chartmatplotlib+seaborn or plotnine
Company logo, brand markLogo image/image-search --logo
Real-world photographPhoto/image-search
Concept with analogy, metaphorAI illustrationgemini-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 patternUse instead
Warning paragraphwarning[...]
Key point / takeawaykeypoint[...]
Tip or best practicetip[...]
Common mistake / traptrap[...]
Step-by-step procedurestep-box("Title", [...])
Key equation / formulaformula-box("Title", [...])
KPI or metric highlightstat-card("value", "label")
Frequency indicatorfreq-badge("HIGH") / freq-badge("MEDIUM") / freq-badge("LOW")
MCQ answer explanationanswerbox("A", "why", "trap", "concept")
Analogy / intuitionanalogy[...]
"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 MCPPlaceholder #rect(width: 100%, height: 4cm, fill: luma(240))[Image placeholder]
/image-searchgemini-generate-image MCP with descriptive prompt
/mindmapfletcher tree diagram
matplotlibCheck .venvuv venv .venv.nosync && ln -s .venv.nosync .venv
typst compileIsolate with /* ... */, compile incrementally

Reference File Index

When you need...Read...
Syntax, errors, special charsreferences/quick-ref.md
@local/qk:2.1.0 APIreferences/component-library.md
Visual tool details, examples, fallbacksreferences/tool-routing.md
Document preamblesreferences/templates.md
Table patterns, show rules, large docsreferences/common-patterns.md
Page layout, spacing, figures, curvesreferences/layout-patterns.md
Math mode trapsreferences/math-pitfalls.md
Package importsreferences/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 tablereferences/quality-gates.md
Data-driven generation (JSON, CSV, batch, variants)references/data-driven.md
sym.* symbolsreferences/symbols.md

Version Notes (0.13–0.14)

FeatureVerDescription
Tagged PDFs, PDF/UA-10.14Accessible PDFs by default
figure.alt / image(alt:)0.14Alt text for screen readers
pdf.attach0.14Attach files (replaces pdf.embed)
PDF as image format0.14image("file.pdf")
Multiple table headers0.14Hierarchical headers repeat across pages
curve function0.13Bezier drawing (replaces path)

Deprecated: pathcurve · pdf.embedpdf.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

FontStyleNotes
New Computer ModernAcademic serifDefault; bundled with Typst
GeorgiaReadable serifSafe on macOS
Helvetica NeueClean sans-serifmacOS 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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

golang-pro

No summary provided by upstream source.

Repository SourceNeeds Review
General

flutter-expert

No summary provided by upstream source.

Repository SourceNeeds Review
General

laravel-specialist

No summary provided by upstream source.

Repository SourceNeeds Review
General

kubernetes-specialist

No summary provided by upstream source.

Repository SourceNeeds Review