--- name: typst-authoring description: This skill should be used when the user asks to "write Typst", "create a Typst document", "format in Typst", "convert to Typst", "Typst syntax", "Typst template", "Typst math", "Typst table", or works with .typ files. Provides comprehensive Typst markup, scripting, math, layout, and styling reference for authoring documents. Also use proactively when generating .typ output files (e.g., in deep-research reports). --- # Typst Authoring Reference Typst is a modern typesetting language with three syntactic modes: **markup** (default), **code** (`#`), and **math** (`$`). Understanding mode transitions is the core skill for productive authoring. ## Three Modes at a Glance - **Markup mode** (default) — Text, `*bold*`, `_italic_`, `= Heading`, `- list`, `+ ordered`, `/ term: def` - **Code mode** (enter with `#`) — Variables, functions, control flow, imports. End with `;` to return to markup. - **Math mode** (enter with `$`) — `$inline$` (no spaces) or `$ block $` (spaces). Single letters = italic variables; multi-letter = function names. ## Essential Syntax Quick Reference | Element | Syntax | | ------------------ | --------------------------------------- | | Bold / Italic | `*bold*` / `_italic_` | | Heading | `= H1`, `== H2`, `=== H3` | | Lists | `- bullet`, `+ numbered`, `/ Term: def` | | Link | `https://...` or `#link("url")[text]` | | Label / Reference | `` / `@name` | | Code expression | `#expr` | | Line break | `\` | | Comment | `// line` or `/* block */` | | Non-breaking space | `~` | | Dashes | `--` (en), `---` (em) | | Escape | `\#`, `\@`, `\$`, `\*`, etc. | ## Set Rules and Show Rules **Set rules** configure defaults for functions: ```typst #set text(font: "New Computer Modern", size: 11pt) #set par(justify: true) #set heading(numbering: "1.") #set page("a4", margin: (x: 2.5cm, y: 2.5cm)) ``` Set rules are scoped to their enclosing content block `[...]`. **Show rules** transform rendering: ```typst #show heading: set text(navy) // show-set (composable) #show heading: it => emph(it.body) // transformational #show: columns.with(2) // everything rule #show heading.where(level: 1): set align(center) // filtered ``` Selectors: element functions, `.where(field: val)`, `"text"`, `regex(...)`, `