重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
typst-writer by ypares/agent-skills
npx skills add https://github.com/ypares/agent-skills --skill typst-writer此技能为编写正确的 Typst 代码提供指导,重点在于避免因混淆 Typst 与其他语言而导致的常见语法错误。
关键区别:
(item1, item2) - 圆括号(key: value, key2: value2) - 带冒号的圆括号[markup content] - 方括号关于详细的语法规则和常见模式,请参阅 references/syntax.md。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
Typst Universe(官方包注册中心)没有编程 API,但你可以通过 GitHub 搜索包:
gh search,或 SearXNG 的仓库搜索(参见 searxng-search 技能)GitHub 直接搜索示例:
# 搜索关于某个主题的 typst 仓库
gh search repos --language "typst" --json "url,language,description" diagram arrows ...
# 列出给定仓库中的所有文件
gh search code --repo "Jollywatt/typst-fletcher"
# 在仓库中,搜索某种类型的所有文件
gh search code --repo "Jollywatt/typst-fletcher" --extension "md" arrow node ...
需要 searxng-search 技能
curl "http://localhost:<searxng-port>/search?q=typst+diagram&format=json&categories=repos" | jq '.results[] | select(.engines[] == "github")'
fletcher,用于边注的 drafting,用于高级表格的 tablex)需要时使用 WebFetch 来检索当前文档进行验证。
(),内容用 [])#let name(params) = { ... } 定义函数context 块[] 表示数组(应使用 ())arr[0] 访问数组元素(应使用 arr.at(0))# 前缀[] 和代码块 {}// 为文档元素定义自定义函数
#let important(body) = {
box(
fill: red.lighten(80%),
stroke: red + 1pt,
inset: 8pt,
body
)
}
// 使用状态进行计数
#let example-counter = state("examples", 1)
#let example(body) = context {
let num = example-counter.get()
important[Example #num: #body]
example-counter.update(x => x + 1)
}
// 数据数组
#let factions = (
(name: "Merchants", color: blue),
(name: "Artisans", color: green)
)
// 迭代并渲染
#for faction in factions [
- #text(fill: faction.color, faction.name)
]
除了编译,typst CLI 命令还可以使用 typst query 对 Typst 文件运行查询,使用 Typst 选择器,并将结果以 JSON 格式获取。
例如,typst query the_document.typ "heading.where(level: 1)" | jq ".[].body.text" 将列出文档中所有一级标题的文本。遗憾的是,它不会告诉你它们在文件中的确切位置,但 Typst 文件很容易用 grep 搜索。
更多信息请参阅关于 query 的在线文档。
当需要专门功能时:
#import "@preview/package:version" 导入热门包 :
drafting: 用于进行中文档的注释/评论gentle-clues: 标注、提示、笔记、警告框showybox: 通用、可自定义的文本框,带页眉和页脚。例如用于定义、定理或高亮重要段落itemize: 用于项目列表、枚举、清单、树形列表等的精美布局cetz: 通用图表/绘图,带有显式定位(坐标)- 大多数 Typst 绘图库的基础fletcher: 图表、流程图、自动机、树等 - 自动布局chronos: 序列图timeliney: 甘特图herodot: 线性时间线lilaq: 数据可视化和绘图tablem: 以类似 Markdown 的表格格式编写表格 - 轻松控制边框、合并单元格...cmarker: 将 Markdown(内联或来自单独文件)渲染为 Typst 文档的一部分polylux: 演示文稿、幻灯片suiji: Typst 代码中的随机数生成zebraw: 带行号、高亮行、内联 Typst 注释/解释等的代码清单lovelace: 算法/伪代码conchord: 带有叠加和弦变化、吉他指型和指法图的歌词eqalc: 将数学方程转换为实际可调用的 Typst 函数jlyfish: 将 Typst 作为 Julia 笔记本使用:在 Typst 中嵌入 Julia 代码以生成内容、可视化等pyrunner: 在 Typst 中嵌入并调用_非 I/O_ Python 代码Typst Universe 托管了许多预构建的模板,用于报告、论文、简历、演示文稿等。模板提供完整的文档样式和结构。
#import "@preview/template-name:version": *#show: template-name.with(param: value, ...) 应用它示例:
#import "@preview/bubble:0.2.2": bubble
// 一些模板(如 bubble)不使用 `#set document(...)` 设置的标准元数据(目前?),
// 所以我们将其提取出来:
#let doc-md = (
title: [My report],
author: "Claude",
date: datetime(year: 2025, month: 12, day: 8) // 总是在代码中包含明确的日期(这样我们就不会默认使用 PDF 构建的日期)
)
#set document(..doc-md)
#show: bubble.with(
..doc-md,
date: doc-md.date.display("[day]-[month]-[year]"), // 有些模板这里需要字符串,而不是 `datetime` 对象,所以我们在这里覆盖日期
subtitle: "A detailed analysis",
affiliation: "Your Organization",
main-color: rgb("#FF6B35"),
color-words: ("important", "key", "critical"),
)
// 你的内容紧随其后
= Introduction
...
与包的关键区别:
#show: 通过一个单一的"主"函数将样式应用到整个文档热门模板 : charged-ieee (IEEE 论文), bubble (彩色报告), modern-cv (简历)
Typst 支持使用 BibTeX (.bib) 或 Hayagriva (.yml) 格式文件进行引用和参考文献管理。
务必尽可能在参考文献文件中包含正确的 URL。
务必在文本中任何相关引用处包含 @ref-name 引用。一个好的参考文献如果不被引用就毫无用处。
这里展示了一个学术论文的示例。你将需要编写的大多数报告不需要如此正式,但这算是一个典型示例。
#set document(
title: "Document Title",
author: "Your Name",
date: auto,
)
#set page(
paper: "a4",
margin: (x: 2.5cm, y: 2.5cm),
numbering: "1",
)
#set text(size: 11pt)
#set par(justify: true)
#set heading(numbering: "1.")
// 标题页
#align(center)[
#text(size: 24pt, weight: "bold")[Document Title]
#v(1cm)
#text(size: 14pt)[Your Name]
#v(0.5cm)
#datetime.today().display()
]
#pagebreak()
// 目录
#outline(title: "Table of Contents", indent: auto)
#pagebreak()
// 主要内容
= Introduction
Your introduction text...
= Methods
...
= Results
...
= Conclusion
...
#pagebreak()
// 参考文献
#bibliography("refs.bib", title: "References", style: "ieee")
#import "@preview/charged-ieee:0.1.4": *
#show: ieee.with(
title: "Your Paper Title",
authors: (
(name: "Author One", email: "author1@example.com"),
(name: "Author Two", email: "author2@example.com"),
),
abstract: [
Your abstract text here...
],
index-terms: ("keyword1", "keyword2", "keyword3"),
bibliography: bibliography("refs.bib"), // ieee 模板会自行处理参考文献。并非总是如此
)
// 内容立即开始
= Introduction
Your introduction text...
= Methods
...
= Results
...
= Conclusion
...
如果看到"未知字体族"警告,请移除字体规范以使用系统默认字体
注意 : 字体警告不会阻止编译;文档将使用备用字体
如果导入失败并显示"包未找到":
@preview/package:version 语法中的拼写错误常见修复方法:
#{ } 包裹或使用正确的语法# 前缀(),字典需要 key: value,单元素数组是 (elem,)对于大型文档:
#include "file.typ" 拆分成多个文件typst compile doc.typ output.pdf --pages 1-5typst compile --timings doc.typ每周安装次数
70
仓库
GitHub Stars
24
首次出现
Jan 20, 2026
安全审计
安装于
opencode61
codex58
gemini-cli57
github-copilot54
kimi-cli53
amp53
This skill provides guidance for writing correct Typst code, with emphasis on avoiding common syntax errors from conflating Typst with other languages.
Critical distinctions:
(item1, item2) - parentheses(key: value, key2: value2) - parentheses with colons[markup content] - square bracketsFor detailed syntax rules and common patterns , see references/syntax.md.
Typst Universe (the official package registry) doesn't have a programmatic API, but you can search for packages via GitHub:
gh search, or SearXNG's repos search (see the searxng-search Skill)Direct GitHub search examples:
# Search for typst repos about some topic
gh search repos --language "typst" --json "url,language,description" diagram arrows ...
# List all files in a given repo
gh search code --repo "Jollywatt/typst-fletcher"
# In a repo, search through all files of some type
gh search code --repo "Jollywatt/typst-fletcher" --extension "md" arrow node ...
Requiressearxng-search Skill
curl "http://localhost:<searxng-port>/search?q=typst+diagram&format=json&categories=repos" | jq '.results[] | select(.engines[] == "github")'
fletcher for diagrams, drafting for margin notes, tablex for advanced tables)Use WebFetch when needed to retrieve current documentation for verification.
(), content with [])#let name(params) = { ... }context blocks when accessing state[] for arrays (use () instead)arr[0] (use arr.at(0))# prefix for code in markup context[] with code blocks {}// Define custom functions for document elements
#let important(body) = {
box(
fill: red.lighten(80%),
stroke: red + 1pt,
inset: 8pt,
body
)
}
// Use state for counters
#let example-counter = state("examples", 1)
#let example(body) = context {
let num = example-counter.get()
important[Example #num: #body]
example-counter.update(x => x + 1)
}
// Arrays for data
#let factions = (
(name: "Merchants", color: blue),
(name: "Artisans", color: green)
)
// Iterate and render
#for faction in factions [
- #text(fill: faction.color, faction.name)
]
Besides compiling, the typst CLI command can also run queries against a Typst file with typst query, using Typst selectors, and get the result as JSON.
For instance, typst query the_document.typ "heading.where(level: 1)" | jq ".[].body.text" will list all the level-1 section titles present in the document. Sadly, it will not tell you their exact positions in the file, but Typst file are easy to grep.
See [https://typst.app/docs/reference/introspection/query/#command-line-queries](the online docs about query) for more info.
When needing specialized functionality:
#import "@preview/package:version"Popular packages :
drafting: annotations/comments for work-in-progress docsgentle-clues: callouts, tips, notes, admonitionsshowybox: general-purpose, customizable text boxes, with headers and footers. E.g. for definitions, theorems or highlighting important paragraphsitemize: nice layouts for item lists, enums, checklists, tree lists, etc.cetz: general diagrams/drawings, with explicit placing (coordinates) - basis of most Typst drawing librariesfletcher: graphs, flowcharts, automata, trees, etc. - automatic placingchronos: sequence diagramstimeliney: Gantt chartsherodot: linear timelinesTypst Universe hosts many pre-built templates for reports, papers, CVs, presentations, and more. Templates provide complete document styling and structure.
#import "@preview/template-name:version": *#show: template-name.with(param: value, ...)Example:
#import "@preview/bubble:0.2.2": bubble
// Some templates (like bubble) don't use the standard metadata set by `#set document(...)` (for now?),
// so we factor it out:
#let doc-md = (
title: [My report],
author: "Claude",
date: datetime(year: 2025, month: 12, day: 8) // ALWAYS include explicit date in code (so we don't default to date of PDF build)
)
#set document(..doc-md)
#show: bubble.with(
..doc-md,
date: doc-md.date.display("[day]-[month]-[year]"), // some templates want a string here, not a `datetime` object, so we override date here
subtitle: "A detailed analysis",
affiliation: "Your Organization",
main-color: rgb("#FF6B35"),
color-words: ("important", "key", "critical"),
)
// Your content follows
= Introduction
...
Key differences from packages:
#show: to apply styling to the entire document, via one single "main" functionPopular templates : charged-ieee (IEEE papers), bubble (colorful reports), modern-cv (CVs)
Typst supports citations and bibliographies using BibTeX (.bib) or Hayagriva (.yml) format files.
See references/bibliography.md
ALWAYS include proper URLs in the bibliography file AS MUCH AS POSSIBLE.
ALWAYS include@ref-name citations in text WHEREVER A REF IS RELEVANT. A good bibliography is useless if not cited.
This shows an example for academic papers. Most reports you will have to write won't need to be that formal, but it's sort of the canonical example.
#set document(
title: "Document Title",
author: "Your Name",
date: auto,
)
#set page(
paper: "a4",
margin: (x: 2.5cm, y: 2.5cm),
numbering: "1",
)
#set text(size: 11pt)
#set par(justify: true)
#set heading(numbering: "1.")
// Title page
#align(center)[
#text(size: 24pt, weight: "bold")[Document Title]
#v(1cm)
#text(size: 14pt)[Your Name]
#v(0.5cm)
#datetime.today().display()
]
#pagebreak()
// Table of contents
#outline(title: "Table of Contents", indent: auto)
#pagebreak()
// Main content
= Introduction
Your introduction text...
= Methods
...
= Results
...
= Conclusion
...
#pagebreak()
// Bibliography
#bibliography("refs.bib", title: "References", style: "ieee")
#import "@preview/charged-ieee:0.1.4": *
#show: ieee.with(
title: "Your Paper Title",
authors: (
(name: "Author One", email: "author1@example.com"),
(name: "Author Two", email: "author2@example.com"),
),
abstract: [
Your abstract text here...
],
index-terms: ("keyword1", "keyword2", "keyword3"),
bibliography: bibliography("refs.bib"), // the ieee template takes care of bibliography itself. That's not always the case
)
// Content starts immediately
= Introduction
Your introduction text...
= Methods
...
= Results
...
= Conclusion
...
If you see "unknown font family" warnings, remove the font specification to use system defaults
Note : Font warnings don't prevent compilation; the document will use fallback fonts
If import fails with "package not found":
@preview/package:version syntaxCommon fixes:
#{ } or use proper syntax# prefix in markup context() for both, dictionaries need key: value, singleton arrays are (elem,)For large documents:
#include "file.typ" to split into multiple filestypst compile doc.typ output.pdf --pages 1-5typst compile --timings doc.typWeekly Installs
70
Repository
GitHub Stars
24
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode61
codex58
gemini-cli57
github-copilot54
kimi-cli53
amp53
minimax-docx:基于 OpenXML SDK 的 DOCX 文档自动化创建与编辑工具
1,300 周安装
Terraform Provider验收测试模式指南:使用plugin-testing与插件框架
267 周安装
Crypto.com App 交易技能 - 自动化加密货币交易代理集成指南
193 周安装
GitHub API 集成与自动化操作指南 - 使用 Membrane 管理仓库、议题和拉取请求
162 周安装
swain-init项目初始化工具:自动化迁移CLAUDE.md至AGENTS.md并验证依赖
63 周安装
OSS 替换自动化工具 - 开源模块替换执行器,优化代码库依赖管理
109 周安装
依赖项优化协调器:自动化升级npm、NuGet、Python依赖,提升项目安全与性能
108 周安装
lilaq: data visualization and plotstablem: write tables in markdown-like table format - easy control over strokes, merged cells...cmarker: render Markdown (inlined or from separate file) as part as a Typst docpolylux: presentations, slidessuiji: random number generation in Typst codezebraw: code listings with line numbers, highlighted lines, inlined Typst comments/explanations etc.lovelace: algorithms/pseudo-codeconchord: lyrics with overlayed chord changes, guitar shapes and tabseqalc: math equations to actual, callable Typst functionsjlyfish: Typst as a Julia notebook: embed Julia code inside Typst to generate content, visualizations etc.pyrunner: embed and call non-I/O Python code inside Typst