This repository has been archived on 2026-11-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2026-07-26 11:55:16 +02:00

106 lines
2.5 KiB
Markdown

---
sidebar_position: 7
---
# Multi-File Architecture
Touying features a syntax as concise as native Typst documents, along with numerous customizable configuration options, yet it still maintains real-time incremental compilation performance, making it suitable for writing large-scale slides.
If you need to write a large set of slides, such as a course manual spanning tens or hundreds of pages, you can also try Touying's multi-file architecture.
## Configuration and Content Separation
A simple Touying multi-file architecture consists of three files: a global configuration file `globals.typ`, a main entry file `main.typ`, and a content file `content.typ` for storing the actual content.
These three files are separated to allow both `main.typ` and `content.typ` to import `globals.typ` without causing circular references.
`globals.typ` can be used to store some global custom functions and initialize Touying themes:
```typst
// globals.typ
#import "@preview/touying:0.6.1": *
#import themes.university: *
// as well as some utility functions
```
`main.typ`, as the main entry point of the project, applies show rules by importing `globals.typ` and includes `content.typ` using `#include`:
```typst
// main.typ
#import "/globals.typ": *
#show: university-theme.with(
aspect-ratio: "16-9",
config-info(
title: [Title],
subtitle: [Subtitle],
author: [Authors],
date: datetime.today(),
institution: [Institution],
logo: emoji.school,
),
)
#include "content.typ"
```
`content.typ` is where you write the actual content:
```typst
// content.typ
#import "/globals.typ": *
= The Section
== Slide Title
Hello, Touying!
#focus-slide[
Focus on me.
]
```
## Multiple Sections
Implementing multiple sections is also straightforward. You only need to create a `sections` directory and move the `content.typ` file to the `sections.typ` directory, for example:
```typst
// main.typ
#import "/globals.typ": *
#show: university-theme.with(
aspect-ratio: "16-9",
config-info(
title: [Title],
subtitle: [Subtitle],
author: [Authors],
date: datetime.today(),
institution: [Institution],
logo: emoji.school,
),
)
#include "sections/content.typ"
// #include "sections/another-section.typ"
```
And
```typst
// sections/content.typ
#import "/globals.typ": *
= The Section
== Slide Title
Hello, Touying!
#focus-slide[
Focus on me.
]
```
Now, you have learned how to use Touying to achieve a multi-file architecture for large-scale slides.