Skip to content

About

A skill for organizing Typst documents into clean, modular structures using include and import. Never write monolithic typ files again.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Typst Modular Architecture

A skill for organizing Typst documents into clean, modular structures using #include and #import. Never write monolithic .typ files again.

Purpose

This skill guides you to:

  • Split large Typst documents into modular, maintainable files
  • Use #include for content injection and #import for 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

Quick Start

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.

Core Concepts

#include vs #import

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-title

Rule of thumb: Section files use #include. Utility/lib files use #import.

Flat Include Rule

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 File Rules

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 Structure

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 Responsibilities

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 —

Project Templates

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

Syntax Reference

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

Installation

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

About

A skill for organizing Typst documents into clean, modular structures using include and import. Never write monolithic typ files again.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors