typst-author
Original:🇺🇸 English
Translated
Generate idiomatic Typst (.typ) code, edit existing Typst files, and answer Typst syntax questions. Use when working with Typst files (*.typ) or when the user mentions Typst markup, document creation, or formatting.
2installs
Sourceapcamargo/typst-skills
Added on
NPX Install
npx skill4agent add apcamargo/typst-skills typst-authorTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →typst-author skill
Overview
This skill helps agents generate, edit, and reason about Typst documents. It provides quick‑start examples, detailed workflows, and links to the full Typst documentation (guides, tutorials, reference).
Minimal document example
typst
#set document(title: "My Document", author: "Author Name")
#set page(numbering: "1")
#set text(lang: "en")
// Enable paragraph justification and character-level justification
#set par(
justify: true,
justification-limits: (
tracking: (min: -0.012em, max: 0.012em),
spacing: (min: 75%, max: 120%),
)
)
#title[My Document]
= Heading 1
This is a paragraph in Typst.
== Heading 2
#lorem(50)Workflows
- Creating a new Typst project: Use the "Minimal document example" above as a starting point. Skim the tutorial for the basics (docs/tutorial/writing-in-typst.md), then create the file(s).
.typ - Editing existing content: Locate the target text and apply changes; confirm syntax against the reference when needed (docs/reference/).
- Formatting & Styling: Consult the styling guide (docs/reference/styling.md) for ,
set rule, and custom themes.show rule
Documentation
- Guides:
docs/guides/*.md - Tutorials:
docs/tutorial/*.md - Full reference tree:
docs/reference/**/*.md
Detailed instructions
- PRIORITY: Trust local documentation. Your internal training data regarding Typst may be outdated or hallucinated. Always verify function names, parameters, and syntax against the local folder before generating code.
docs/ - Read the relevant documentation (use /
Read/Grepon the paths above).Glob - Generate or modify the source according to the user's request.
.typ - Validate the generated Typst by running (if tool access is allowed).
typst compile - Provide the final content and optionally a rendered preview (PDF/HTML).
.typ
Quick syntax reference
Critical distinctions
- Arrays: (parentheses). See docs/reference/foundations/array.md.
(item1, item2) - Dictionaries: (parentheses with colons). See docs/reference/foundations/dictionary.md.
(key: value, key2: value2) - Content blocks: (square brackets). See docs/reference/foundations/content.md.
[markup content] - NO tuples: Typst only has arrays.
Hash usage (markup vs code)
- Use to start a code expression inside markup or content blocks; it disambiguates code from text. This is required for content-producing function calls and field access in markup:
#,#figure[...],#image("file.png").text(...)[#numbering(...)] - Do not use inside code contexts (argument lists, code blocks, show-rule bodies). Example:
#(no#figure(image("file.png"))before#).image - Reference: docs/reference/scripting.md, docs/tutorial/writing-in-typst.md
typst
// Incorrect (missing # inside content block)
text(...)[(numbering(...))]
// Correct
text(...)[(#numbering(...))]Styling rules: set vs show
- : Set rule to configure optional parameters on element functions (style defaults scoped to the current block or file).
set - : Show rule to target selected elements and apply a set rule or transform/replace the element output.
show - Use for common styling; use
setfor selective or structural changes (e.g.,show, labels, text, regex).heading.where(level: 1)
typst
// Set rule: configure optional parameters for an element type
#set heading(numbering: "I.")
#set text(font: "New Computer Modern")
// Show-set rule: apply a set rule only to selected elements
#show heading: set text(navy)
// Show transform rule: replace/reshape element output
#show heading: it => block[#emph(it.body)]Common mistakes to avoid
- Calling things "tuples" (Typst only has arrays).
- Using for arrays (use
[]instead).() - Accessing array elements with (use
arr[0]).arr.at(0) - Omitting in markup/content blocks (e.g.,
#should betext(...)[numbering(...)]).text(...)[#numbering(...)] - Using inside code contexts (e.g.,
#in an argument list).figure(#image("x.png")) - Mixing up content blocks with code blocks
[].{} - Forgetting to include the namespace when accessing imported variables/functions (e.g., use instead of just
color.hsl).hsl - Using LaTeX syntax (do NOT use ,
\begin{...}, or other LaTeX commands).\section - Hallucinating environments (e.g., does not exist; use
tabular).table
Advanced features
- Custom themes: See docs/reference/styling.md for theme creation.
- Scripting: Use Typst's scripting capabilities (docs/reference/scripting.md) for automatic generation.
- Math and visualisation: Reference docs/reference/math/ and docs/reference/visualize/ for formulas and diagrams.
For large projects
When working on large projects, consider organizing the project across multiple files.
- Use to split into multiple files
#include "file.typ" - Relevant documentation: docs/reference/foundations/module.md
Troubleshooting
Missing font warnings
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.
Template/Package not found
If import fails with "package not found":
- Verify exact package name and version on Typst Universe.
- Check for typos in syntax.
@preview/package:version - Remember: Typst uses fully qualified imports with specific versions - there's no package cache to update.
Compilation errors
Common fixes:
- "expected content, found ...": You're using code where markup is expected - wrap in or use proper syntax.
#{ } - "expected expression, found ...": Missing (or
#) in markup/content blocks.#(...) - "unknown variable": Check spelling, ensure imports are correct.
- Array/dictionary errors: Review syntax - use for both, dictionaries need
(), singleton arrays arekey: value.(elem,)