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:
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
- Write the
.typsource file in/home/claude/ - Compile with
typst compile document.typ document.pdf - Copy the PDF to
/mnt/user-data/outputs/ - Present both the
.typsource and.pdfto 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)
#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
= Top Level Heading
== Second Level
=== Third Level
Text Formatting
*bold text*
_emphasized text_
`inline code`
#underline[underlined]
#strike[strikethrough]
#highlight[highlighted]
#text(fill: blue)[colored text]
#smallcaps[Small Caps]
Lists
- Unordered item
- Nested item
+ Ordered item
+ Another item
/ Term: Definition
/ Another: Its definition
Links and References
#link("https://typst.app")[Typst Website]
= Introduction <intro>
See @intro for details.
Images and Figures
#figure(
image("photo.jpg", width: 80%),
caption: [A descriptive caption.],
) <fig-label>
Tables
#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 $):
$ integral_0^oo e^(-x^2) dif x = sqrt(pi) / 2 $
Key math syntax:
- Subscript:
x_iSuperscript:x^2 - Fractions:
a / borfrac(a, b) - Square root:
sqrt(x)orroot(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(NOTangle.l/angle.r— deprecated) - Partial derivative:
partial(NOTdiff— deprecated in 0.14+) - Differential:
diffor $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\
$ sum_(k=0)^n k &= 1 + 2 + dots + n \
&= (n(n+1)) / 2 $
Set Rules and Show Rules
Set rules change default properties:
#set text(size: 12pt)
#set page(numbering: "1")
#set enum(numbering: "a)")
Show rules transform how elements appear:
#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
```python
def hello():
print("Hello, Typst!")
```
Page Breaks and Columns
#pagebreak()
#columns(2)[
Content in two columns.
#colbreak()
Second column.
]
Bibliography
#bibliography("refs.bib", style: "ieee")
// Citation in text:
As shown by @authorkey.
Custom Functions
#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
#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
# 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 fontsfor available names. Names are case-sensitive. - File not found: Typst resolves paths relative to the
.typfile's directory. Use--rootto 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
- Use
#set par(justify: true)for professional-looking paragraphs - Use
#set text(lang: "ko")(or appropriate language) for correct hyphenation - Use
#show math.equation: set text(font: "Latin Modern Math")for consistent math fonts - For academic papers, set up
#set heading(numbering: "1.1")and#set math.equation(numbering: "(1)") - Use
#set page(numbering: "1", number-align: center + bottom)for page numbers - Use figures with captions and labels for cross-referencing:
@fig-label