A skill for organizing Typst documents into clean, modular structures using #include and #import. Never write monolithic .typ files again.
This skill guides you to:
- Split large Typst documents into modular, maintainable files
- Use
#includefor content injection and#importfor definitions - Maintain a single entry point (
main.typ) that orchestrates all content - Follow best practices for project structure across document types
Triggers: typst, .typ, include, import, modular document, sections, chapters, split document, multi-file typst, typst project structure
Given a monolithic file, extract sections into separate files:
project/
├── main.typ # Entry point
├── sections/
│ ├── introduction.typ # Content only
│ ├── methodology.typ
│ └── results.typ
├── figures/ # Images
└── bibliography.bib # References
main.typ
#set page(paper: "a4", margin: 2cm)
#set text(font: "Inter", size: 11pt)
#set heading(numbering: "1.")
= Introduction
#include "sections/introduction.typ"
= Methodology
#include "sections/methodology.typ"
= Results
#include "sections/results.typ"
= Conclusion
#include "sections/conclusion.typ"sections/introduction.typ
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
== Background
Ut enim ad minim veniam, quis nostrud exercitation ullamco.| Directive | Purpose | Example Use |
|---|---|---|
#include |
Inject content (text, headings, figures) | Section files |
#import |
Bring definitions (functions, variables) | Utility/lib files |
// Content injection
#include "sections/abstract.typ"
// Definition import
#import "lib/styles.typ": accent-color, make-title
#show: make-titleRule of thumb: Section files use #include. Utility/lib files use #import.
Typst does not support nested includes. Keep the tree flat:
// main.typ — flat includes
#include "sections/ch01.typ"
#include "sections/ch02.typ"
#include "sections/ch03.typ"Section files should:
- Contain only content (text, headings, figures, tables)
- Never include
#set page(...)or#set text(...)at document level - Use relative paths for images:
image("../figures/diagram.png")
project/
├── main.typ # Entry point, document config, includes
├── sections/ # Content files (one per section/chapter)
│ ├── introduction.typ
│ ├── methodology.typ
│ ├── results.typ
│ └── conclusion.typ
├── lib/ # Reusable functions and styles
│ ├── styles.typ
│ └── helpers.typ
├── figures/ # Images and diagrams
│ ├── diagram-01.png
│ └── chart-results.svg
└── bibliography.bib # References
| Directory | Contains | Never Contains |
|---|---|---|
sections/ |
Content only (text, headings, figures) | #set page, #set text at doc level |
lib/ |
Functions, variables, show rules | Content (no headings, no paragraphs) |
figures/ |
Images referenced by section files | — |
Adapt the structure to your document type. See references/project-structure.md for complete templates:
- Academic Paper — abstract, introduction, methodology, results, discussion, conclusion
- Book / Thesis — frontmatter, chapters, appendices, shared styles in
lib/ - Technical Report — executive summary, analysis, recommendations, confidential headers
For detailed #include and #import syntax, see references/modular-include.md:
- Import variants: all, specific items, aliases, namespaces
- Sharing variables between files
- Show rules across files
- Path conventions
Add the typst-architect folder to your agent's skill directory. The skill will activate when working with Typst documents that need modular organization.
Supported platforms (via apm.yml): claude, codex, copilot, cursor, gemini, opencode, windsurf