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:

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.