Back to marketplace

/typst-author

v1.0.0documentation

Generate idiomatic Typst (.typ) code, edit existing Typst files

typsttypesettingdocspdf
/plugin install typst-author@max-skills

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 1This 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 [blocked]), then create the .typ file(s).
  • Editing existing content: Locate the target text and apply changes; confirm syntax against the reference when needed (docs/reference/ [blocked]).
  • Formatting & Styling: Consult the styling guide (docs/reference/styling.md [blocked]) for set rule, show rule, and custom themes.
  • Using Typst packages: Before using any external package, search Typst Universe first (https://typst.app/universe/search/?q=...) to select the best candidate. Then open the selected package page on Typst Universe and read its documentation before writing imports or code based on that package.
  • Tables (preferred style): For publication-style tables, prefer the booktabs package (@preview/booktabs) and avoid heavy vertical borders unless the user explicitly asks for boxed grid tables.

Documentation

  • Guides: docs/guides/*.md
  • Tutorials: docs/tutorial/*.md
  • Full reference tree: docs/reference/**/*.md

Detailed instructions

  1. 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 docs/ folder before generating code.
  2. Read the relevant documentation (use Read/Grep/Glob on the paths above).
  3. If package usage is needed, select the package via Typst Universe search first (https://typst.app/universe/search/?q=...). Compare candidates and choose one that best matches the task.
  4. Open the chosen package page on Typst Universe and read its documentation before writing imports or using any of its APIs.
  5. If the task includes tables, default to booktabs for clean table styling unless the user asks for a different table style or package.
  6. Generate or modify the .typ source according to the user's request.
  7. Validate the generated Typst by running typst compile (if tool access is allowed).
  8. Provide the final .typ content and optionally a rendered preview (PDF/HTML).

Quick syntax reference

Critical distinctions

  • Arrays: (item1, item2) (parentheses). See docs/reference/foundations/array.md [blocked].
  • Dictionaries: (key: value, key2: value2) (parentheses with colons). See docs/reference/foundations/dictionary.md [blocked].
  • Content blocks: [markup content] (square brackets). See docs/reference/foundations/content.md [blocked].
  • 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: #figure(image("file.png")) (no # before image).
  • Reference: docs/reference/scripting.md [blocked], docs/tutorial/writing-in-typst.md [blocked]
typst
// Incorrect (missing # inside content block)text(...)[(numbering(...))]// Correcttext(...)[(#numbering(...))]

Styling rules: set vs show

  • set: Set rule to configure optional parameters on element functions (style defaults scoped to the current block or file).
  • show: Show rule to target selected elements and apply a set rule or transform/replace the element output.
  • Use set for common styling; use show for selective or structural changes (e.g., heading.where(level: 1), labels, text, regex).
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)]

Tables (booktabs default)

  • For professional-looking tables, prefer @preview/booktabs when the user does not request a specific table package.
  • Keep table rules minimal (top/mid/bottom emphasis) and avoid dense full-grid lines by default.
  • If the user asks for spreadsheet-like or fully boxed tables, follow the request instead of forcing booktabs style.
typst
#import "@preview/booktabs:0.2.0": *#booktabs-table(  columns: 3,  [Item], [Qty], [Price],  [Engine], [2], [$1.2M],  [Tank], [1], [$0.8M],)

Common mistakes to avoid

  • Calling things "tuples" (Typst only has arrays).
  • Using [] for arrays (use () instead).
  • Accessing array elements with arr[0] (use arr.at(0)).
  • Omitting # in markup/content blocks (e.g., text(...)[numbering(...)] should be text(...)[#numbering(...)]).
  • Using # inside code contexts (e.g., figure(#image("x.png")) in an argument list).
  • Mixing up content blocks [] with code blocks {}.
  • Forgetting to include the namespace when accessing imported variables/functions (e.g., use color.hsl instead of just hsl).
  • Using LaTeX syntax (do NOT use \begin{...}, \section, or other LaTeX commands).
  • Hallucinating environments (e.g., tabular does not exist; use table).

Advanced features

  • Custom themes: See docs/reference/styling.md [blocked] for theme creation.
  • Scripting: Use Typst's scripting capabilities (docs/reference/scripting.md [blocked]) for automatic generation.
  • Math and visualisation: Reference docs/reference/math/ [blocked] and docs/reference/visualize/ [blocked] for formulas and diagrams.

For large projects

When working on large projects, consider organizing the project across multiple files.

  • Use #include "file.typ" to split into multiple files
  • Relevant documentation: docs/reference/foundations/module.md [blocked]

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 @preview/package:version syntax.
  • 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 key: value, singleton arrays are (elem,).

by Max Wiseman · MIT