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:
// globals.typ
#import "@preview/touying:0.5.5": *
#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
:
// 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:
// 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:
// 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
// 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.