File organization
When writing a long document, such as a book or a thesis manuscript, it is preferable to adopt a multi-file organization to avoid having one very long main file. This is especially important during proofreading and correction, as well as when several people write together.
Project structure
A typical structure for a Bookly project is:
tmain.typ
- appendices/
- tapp1.typ
- bibliography/
- biblio.bib
- chapters/
- tchapter1.typ
- images/
- logo.png
- preamble/
- tsummary.typ
Main file
Based on this structure, the main.typ file could look like this:
// main.typ
#import "@preview/bookly:5.3.0": *
#show: bookly.with(...)
#show: front-matter
#include "preamble/summary.typ"
#show: main-matter
#tableofcontents
#listoffigures
#listoftables
#part[User guide]
#include "chapters/chapter1.typ"
#bibliography("bibliography/biblio.bib")
#show: appendix
#part[Appendices]
#include "appendices/app1.typ"
#back-cover(...)The main file presents the general structure of the document. It contains:
- the front matter (
#front-matter), main matter (#main-matter) and appendix (#appendix) environments (see Environments); - a table of contents (
#tableofcontents), a list of figures (#listoffigures) and a list of tables (#listoftables) (see Tables of contents); - parts (
#part) (see Parts and chapters); - chapters and appendices imported from other files using Typst’s
#includecommand; - a bibliography inserted with Typst’s
#bibliographycommand; - a back cover (
#back-cover) containing the summary and abstract of the document.
Tip
Each included chapter file starts with its own heading or with
#show: chapter.with(...), so that it can be moved or reordered in main.typ without any change to its content.