ChanMeng666

typst

0
0
# Install this skill:
npx skills add ChanMeng666/typst-claude-skill

Or install specific skill: npx add-skill https://github.com/ChanMeng666/typst-claude-skill

# Description

>

# SKILL.md


name: typst
description: >
Generate professional PDF documents using Typst typesetting system.
Use when user asks to create PDF, write documents, generate reports,
typeset papers, create presentations, or any document generation task.
allowed-tools: Read, Write, Edit, Bash, Glob, Grep


Typst Document Generation Skill

You are an expert Typst typesetter. Use Typst to generate professional PDF, PNG, SVG, or HTML documents.

When to activate

Activate when the user asks to:
- Create or generate a PDF document
- Write a report, paper, thesis, or article
- Create a resume / CV
- Generate a presentation or slides-style document
- Typeset mathematical formulas or equations
- Create any formatted document (letter, invoice, certificate, etc.)

Workflow

1. Verify Typst is available

typst --version

If not available, instruct the user to install:

winget install --id Typst.Typst   # Windows
brew install typst                 # macOS
cargo install typst-cli            # Any platform with Rust

2. Create the .typ source file

  • Choose an appropriate template from references/typst-templates.md
  • Consult references/typst-language-reference.md for syntax details
  • Write the .typ file to the user's desired location

3. Compile to output

typst compile document.typ                          # Default: PDF
typst compile document.typ --format png --ppi 300   # High-res PNG
typst compile document.typ output.svg               # SVG
typst compile document.typ --open                   # Compile and open

See references/typst-cli-reference.md for all CLI options.

4. Iterate

If compilation fails, read the error output, fix the .typ file, and recompile.

Key best practices

Chinese / CJK documents

Always set the text language and use a CJK-capable font:

#set text(lang: "zh", font: ("Source Han Serif SC", "SimSun", "Microsoft YaHei"))
#set page(paper: "a4")

Document structure

Use set rules at the top for global configuration, then write content:

#set page(paper: "a4", margin: 2.5cm)
#set text(font: "Linux Libertine", size: 11pt)
#set heading(numbering: "1.1")
#set par(justify: true, leading: 0.8em)

= Introduction
Content here...

Math equations

$ integral_0^infinity e^(-x^2) dif x = sqrt(pi) / 2 $

Including external data

#let data = json("data.json")
#let records = csv("data.csv")

Using packages

#import "@preview/cetz:0.3.4": canvas, draw
#import "@preview/tablex:0.0.9": tablex

Advanced design patterns

Theme system (cascading defaults)

Use a dictionary-based theme with a fallback helper for customizable templates:

#let default-theme = (
  margin: 26pt,
  font: "Libre Baskerville",
  font-size: 8pt,
  font-secondary: "Roboto",
  font-tertiary: "Montserrat",
  text-color: rgb("#3f454d"),
)

#let my-template(theme: (), body) = {
  let th(key) = if key in theme { theme.at(key) } else { default-theme.at(key) }
  set text(font: th("font"), size: th("font-size"), fill: th("text-color"))
  body
}

Scope-based show rules

Nest show rules inside blocks to apply styling only within a specific scope:

{
  show heading: set text(size: 26pt, weight: "regular")
  show heading: set block(above: 3pt, below: 0pt)
  heading(level: 1, last-name)
}
// The show rules above do NOT affect content outside this block

Visual hierarchy through text color

Use text.fill.lighten() inside context blocks for secondary/tertiary text:

context {
  set text(weight: "light", fill: text.fill.lighten(30%))
  timeframe   // renders lighter than surrounding text
}

Multi-column layout with grid

Use fractional units for responsive sidebar + main layouts:

#grid(
  columns: (3fr, 26pt, 6fr),  // aside, gutter, main
  aside-content,
  [],  // empty gutter
  main-content,
)

Circular profile pictures

{
  set block(radius: 100%, clip: true, above: 1fr, below: 1fr)
  set align(center)
  set image(width: 55%)
  image("photo.jpg")
}

Modular component functions

Build reusable entry components for structured documents (resumes, reports):

#let work-entry(timeframe: "", title: "", organization: "", body) = {
  stack(dir: ltr, spacing: 1fr,
    context { set text(weight: "light", fill: text.fill.lighten(30%)); timeframe },
    context { set text(weight: "light", fill: text.fill.lighten(30%)); location },
  )
  { set text(weight: "bold"); upper(title) } + " – " + organization
  line(stroke: 0.1pt, length: 100%)
  body
}

Custom fonts with --font-path

When using non-system fonts, bundle them and compile with:

typst compile --font-path ./fonts document.typ

PDF output capabilities

Typst's PDF backend (powered by pdf-writer) supports:
- PDF standards: PDF 1.4–2.0, PDF/A-1b through PDF/A-4e, PDF/UA-1
- Tagged PDF: Accessible documents with structure tags (enabled by default)
- Color spaces: RGB, CMYK, grayscale, ICC profiles, Lab color, spot colors
- Fonts: Full Unicode/CJK support via composite fonts (Type0 + CID)
- Advanced graphics: Transparency, blending modes, soft masks, gradients
- Interactive elements: Clickable links, annotations
- Reproducible builds: Use SOURCE_DATE_EPOCH for deterministic output

Reference documentation

For detailed information, consult these reference files (read them when needed):

  • CLI Reference: references/typst-cli-reference.md β€” All CLI commands, options, and environment variables
  • Language Reference: references/typst-language-reference.md β€” Complete language syntax, functions, and features
  • Templates: references/typst-templates.md β€” Ready-to-use document templates (general, Chinese, academic, resume, letter, report, slides, invoice)

Output formats

Format Extension Notes
PDF .pdf Default. Supports PDF/A standards and tagged PDF.
PNG .png One image per page. Use --ppi for resolution.
SVG .svg One file per page. Vector graphics.
HTML .html Experimental. Use --features html.

# README.md

Typst Skill for Claude Code

A Claude Code skill that enables professional document generation using the Typst typesetting system.

When installed, Claude Code can create PDFs, reports, academic papers, resumes, presentations, and more β€” directly from natural language requests.

Features

  • Full Typst language coverage β€” page setup, text formatting, math equations, tables, figures, layout, scripting, show/set rules, introspection, and more
  • Complete CLI reference β€” all commands (compile, watch, init, query, fonts), options, and environment variables for Typst v0.14
  • 8 ready-to-use templates β€” general document, CJK document, academic paper, simple resume, typographic two-column resume, letter, technical report, presentation slides, and invoice
  • Advanced design patterns β€” theme systems with cascading defaults, scope-based show rules, modular component functions, multi-column layouts, circular image clipping, typography hierarchy
  • CJK support β€” font fallback configuration, cjk-latin-spacing, and proper paragraph settings for Chinese/Japanese/Korean documents
  • PDF capabilities β€” PDF/A standards, tagged PDF for accessibility, ICC color profiles, reproducible builds
  • Package publishing β€” typst.toml manifest format, directory structure, and font bundling

Installation

Option 1: Clone to skills directory

# Clone directly into Claude Code skills directory
git clone https://github.com/ChanMeng666/typst-claude-skill.git ~/.claude/skills/typst

Option 2: Manual copy

git clone https://github.com/ChanMeng666/typst-claude-skill.git
cp -r typst-claude-skill/ ~/.claude/skills/typst/

Prerequisites

Typst CLI must be installed on your system:

# Windows
winget install --id Typst.Typst

# macOS
brew install typst

# Any platform with Rust
cargo install typst-cli

File Structure

~/.claude/skills/typst/
β”œβ”€β”€ SKILL.md                          # Main skill file (triggers, workflow, best practices)
└── references/
    β”œβ”€β”€ typst-cli-reference.md        # Complete CLI reference (v0.14.2)
    β”œβ”€β”€ typst-language-reference.md   # Language syntax and features reference
    └── typst-templates.md            # Ready-to-use document templates

Usage

Once installed, the skill activates automatically when you ask Claude Code to generate documents. Examples:

> Create a PDF report about Q1 sales performance
> Write an academic paper template with two-column layout
> Generate a professional resume for a software engineer
> Typeset this math formula as a PDF: E = mc^2
> Create a presentation about our new product launch

You can also invoke it explicitly with /typst.

Templates Included

Template Description
General Document TOC, headers, footers, page numbering
CJK Document Chinese/Japanese/Korean font and paragraph configuration
Academic Paper Two-column, abstract, keywords, bibliography, equation numbering
Simple Resume Single-column with section entries
Typographic Resume Two-column sidebar layout with theme system
Letter Formal letter with sender/recipient blocks
Technical Report Cover page, confidential headers, appendix
Presentation Landscape slides with title/content pattern
Invoice Styled table with totals and payment terms

Contributing

Contributions are welcome! Feel free to:
- Add new templates
- Improve language reference coverage
- Fix errors or outdated information
- Add support for more Typst packages

License

MIT

Acknowledgments

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.