# Typst

> Use this skill whenever the user wants to create, compile, or work with Typst documents (.typ files). Triggers include: any mention of 'Typst', '.typ', or requests to create beautifully typeset documents, academic papers, reports, letters, resumes, or slide decks using Typst. Also use when the user wants a LaTeX alternative, mentions typesetting with markup, asks to generate PDFs from Typst source, or needs help with Typst syntax (set rules, show rules, math mode, tables, figures, bibliography). Use this skill for converting LaTeX to Typst, creating Typst templates, or any document generation where Typst is explicitly requested or would be the best tool. If the user says "make me a PDF" and the content is academic, mathematical, or involves complex typesetting, consider suggesting Typst. Do NOT use for general Word docs (.docx), PowerPoint, or simple markdown files.

- Skill: `mineru98/typst` (Agent Skill)
- Install (CLI): `npx skillmds@latest add mineru98/typst`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mineru98/typst/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Docs & Writing
- Author: Mineru98 (https://skillmd.com/u/mineru98)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/mineru98/typst

---


# Typst Document Creation Skill

Typst is a modern markup-based typesetting system — a powerful, fast alternative to LaTeX that produces
high-quality PDFs. This skill helps Claude create, compile, and deliver Typst documents.

## Setup

Typst must be installed before use. Run this installation step first:

```bash
cd /tmp && curl -sL "https://github.com/typst/typst/releases/download/v0.14.2/typst-x86_64-unknown-linux-musl.tar.xz" -o typst.tar.xz && tar -xf typst.tar.xz && cp typst-x86_64-unknown-linux-musl/typst /usr/local/bin/ && typst --version
```

If typst is already installed (`which typst` succeeds), skip this step.

## Workflow

1. **Write the `.typ` source file** in `/home/claude/`
2. **Compile** with `typst compile document.typ document.pdf`
3. **Copy the PDF** to `/mnt/user-data/outputs/`
4. **Present** both the `.typ` source and `.pdf` to the user

Always compile and verify that Typst exits without errors before delivering. If there are warnings
(like unknown fonts), fix them — use fonts from the available set (check with `typst fonts`).

## Typst Syntax Quick Reference

Typst has three modes: **markup**, **math**, and **code**. In markup, `#` enters code mode.
In math (`$ ... $`), function calls don't need `#`.

### Document Setup (Page, Font, Paragraph)

```typst
#set page(paper: "a4", margin: (top: 2.5cm, bottom: 2.5cm, left: 2cm, right: 2cm))
#set text(font: "Libertinus Serif", size: 11pt, lang: "en")
#set par(justify: true, leading: 0.65em, first-line-indent: 1.2em)
#set heading(numbering: "1.1")
```

For Korean documents, use `"Noto Sans CJK KR"` as the font. For Japanese, `"Noto Sans CJK JP"`.
Always check available fonts with `typst fonts` before specifying.

### Headings

```typst
= Top Level Heading
== Second Level
=== Third Level
```

### Text Formatting

```typst
*bold text*
_emphasized text_
`inline code`
#underline[underlined]
#strike[strikethrough]
#highlight[highlighted]
#text(fill: blue)[colored text]
#smallcaps[Small Caps]
```

### Lists

```typst
- Unordered item
  - Nested item

+ Ordered item
+ Another item

/ Term: Definition
/ Another: Its definition
```

### Links and References

```typst
#link("https://typst.app")[Typst Website]

= Introduction <intro>
See @intro for details.
```

### Images and Figures

```typst
#figure(
  image("photo.jpg", width: 80%),
  caption: [A descriptive caption.],
) <fig-label>
```

### Tables

```typst
#table(
  columns: (1fr, 2fr, 1fr),
  align: (left, center, right),
  table.header([*Name*], [*Description*], [*Value*]),
  [Alpha], [First item], [100],
  [Beta],  [Second item], [200],
)
```

For complex tables with merged cells, use `table.cell(colspan: 2)[...]` or `table.cell(rowspan: 2)[...]`.

### Math Mode

Inline math: `$x^2 + y^2 = z^2$`

Block math (add spaces inside `$`):
```typst
$ integral_0^oo e^(-x^2) dif x = sqrt(pi) / 2 $
```

Key math syntax:
- Subscript: `x_i`  Superscript: `x^2`
- Fractions: `a / b` or `frac(a, b)`
- Square root: `sqrt(x)` or `root(n, x)`
- Summation: `sum_(i=0)^n`
- Greek letters: `alpha`, `beta`, `gamma`, `pi`, `theta`, etc.
- Operators: `dot`, `times`, `plus.minus`, `approx`, `!=`
- Angle brackets: `chevron.l ... chevron.r` (NOT `angle.l`/`angle.r` — deprecated)
- Partial derivative: `partial` (NOT `diff` — deprecated in 0.14+)
- Differential: `dif` for $dx$ in integrals
- Matrices: `mat(1, 2; 3, 4)`
- Vectors: `vec(x, y, z)`
- Cases: `cases(x &"if" x > 0, -x &"otherwise")`
- Alignment in multi-line: use `&` and `\`

```typst
$ sum_(k=0)^n k &= 1 + 2 + dots + n \
               &= (n(n+1)) / 2 $
```

### Set Rules and Show Rules

Set rules change default properties:
```typst
#set text(size: 12pt)
#set page(numbering: "1")
#set enum(numbering: "a)")
```

Show rules transform how elements appear:
```typst
#show heading.where(level: 1): it => {
  set text(size: 16pt, weight: "bold")
  block(above: 1.5em, below: 0.8em)[#it.body]
}

// Make all links blue and underlined
#show link: set text(fill: blue)
#show link: underline
```

### Code Blocks

````typst
```python
def hello():
    print("Hello, Typst!")
```
````

### Page Breaks and Columns

```typst
#pagebreak()

#columns(2)[
  Content in two columns.
  #colbreak()
  Second column.
]
```

### Bibliography

```typst
#bibliography("refs.bib", style: "ieee")

// Citation in text:
As shown by @authorkey.
```

### Custom Functions

```typst
#let alert(body, title: "Note") = {
  block(
    fill: luma(230),
    inset: 12pt,
    radius: 4pt,
    width: 100%,
  )[
    *#title:* #body
  ]
}

#alert[This is a note.]
#alert(title: "Warning")[Be careful!]
```

### Importing and Modules

```typst
#import "template.typ": conf
#show: conf.with(title: "My Paper", authors: ("Author",))

// Import from Typst Universe packages:
#import "@preview/cetz:0.3.4": canvas, draw
```

## Common Document Templates

For common document types, read the reference file at `references/templates.md` for
ready-to-use templates covering: academic papers, letters, resumes, slide presentations, and reports.

## Available Fonts (Common)

These fonts are typically available in the Claude environment:
- Serif: `Libertinus Serif`, `DejaVu Serif`, `Liberation Serif`, `Latin Modern Roman`, `FreeSerif`
- Sans: `DejaVu Sans`, `Liberation Sans`, `Latin Modern Sans`, `FreeSans`
- Mono: `DejaVu Sans Mono`, `Liberation Mono`, `Latin Modern Mono`, `FreeMono`
- CJK: `Noto Sans CJK KR`, `Noto Sans CJK JP`, `Noto Sans CJK SC`, `Noto Sans CJK TC`
- Math: `DejaVu Math TeX Gyre`, `Latin Modern Math`
- Emoji: `Noto Color Emoji`

Always verify with `typst fonts | grep -i "font-name"` before using a font.

## Compilation Options

```bash
# Basic PDF
typst compile doc.typ

# Explicit output path
typst compile doc.typ output.pdf

# Specify format
typst compile doc.typ output.svg --format svg
typst compile doc.typ output.png --format png

# Custom font path
typst compile --font-path ./fonts doc.typ

# Pass input variables
typst compile --input name="Alice" doc.typ
```

## Troubleshooting

- **Unknown font family**: Check `typst fonts` for available names. Names are case-sensitive.
- **File not found**: Typst resolves paths relative to the `.typ` file's directory. Use `--root` to change.
- **Package download fails**: Typst auto-downloads from its Universe registry. Ensure network access.
- **Korean/CJK text not rendering**: Set the font to a CJK-capable font like `Noto Sans CJK KR`.

## Tips for High-Quality Output

1. Use `#set par(justify: true)` for professional-looking paragraphs
2. Use `#set text(lang: "ko")` (or appropriate language) for correct hyphenation
3. Use `#show math.equation: set text(font: "Latin Modern Math")` for consistent math fonts
4. For academic papers, set up `#set heading(numbering: "1.1")` and `#set math.equation(numbering: "(1)")`
5. Use `#set page(numbering: "1", number-align: center + bottom)` for page numbers
6. Use figures with captions and labels for cross-referencing: `@fig-label`

