|
| 1 | +--- |
| 2 | +title: Typst Books, Article Layout, and `typst-gather` |
| 3 | +--- |
| 4 | + |
| 5 | +Typst is a modern and lightning-fast typesetting system that aims to replace LaTeX. |
| 6 | + |
| 7 | +The Typst ecosystem is exploding, and Quarto 1.9 provides first-class support for Typst packages: |
| 8 | + |
| 9 | +* Typst Books |
| 10 | +* Article layout in Typst |
| 11 | +* Bundling of Typst packages for offline rendering |
| 12 | + |
| 13 | +## Typst Books |
| 14 | + |
| 15 | +In Quarto 1.9, a project with type `book` and format `typst` is now rendered as a single document with multiple chapters and other book content. |
| 16 | + |
| 17 | +``` {.yaml filename="_quarto.yml"} |
| 18 | +project: |
| 19 | + type: book |
| 20 | +
|
| 21 | +book: |
| 22 | + title: "My Book" |
| 23 | + author: "Jane Doe" |
| 24 | + chapters: |
| 25 | + - index.qmd |
| 26 | + - intro.qmd |
| 27 | + - summary.qmd |
| 28 | +
|
| 29 | +format: typst |
| 30 | +``` |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +All book features previously available in the LaTeX format are now available in Typst: |
| 35 | + |
| 36 | +* Parts and Chapters |
| 37 | +* Appendices |
| 38 | +* Cross-references and chapter-based numbering |
| 39 | +* Table of Contents |
| 40 | + |
| 41 | +List-of-Figures and List-of-Tables support is [coming soon](https://github.com/quarto-dev/quarto-cli/issues/14081). |
| 42 | + |
| 43 | +Typst Books are implemented as Quarto [Format Extensions](https://quarto.org/docs/extensions/formats.html). Typst partials define the overall book structure, while Lua filters handle the necessary AST transformations. |
| 44 | + |
| 45 | +Quarto bundles the [quarto-orange-book](https://github.com/quarto-ext/orange-book) extension, which [bundles](#typst-gather) the Typst [orange-book](https://typst.app/universe/package/orange-book) package. Orange-book provides a textbook-style layout with colored chapter headers and sidebars. |
| 46 | + |
| 47 | +## Article Layout in Typst |
| 48 | + |
| 49 | +Also in Quarto 1.9, all [Article Layout](https://quarto.org/docs/authoring/article-layout.html) features now work in Typst, via the Typst [Marginalia](https://typst.app/universe/package/marginalia/) package. |
| 50 | + |
| 51 | +Specifically: |
| 52 | + |
| 53 | + |
| 54 | +* Figures, tables, code listings, and equations can be placed in the margin using the `.column-margin` class. |
| 55 | +* Figure, table, and code listing captions can be placed in the margin with `cap-location: margin` |
| 56 | +* Footnotes and citations can be displayed in the margin with `reference-location: margin` and `citation-location: margin`. When margin citations are enabled, the bibliography is suppressed. |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +Naturally, book and article layout can be combined: |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +## `typst-gather` |
| 65 | + |
| 66 | +Quarto 1.9 automatically stages Typst packages — from your extensions, from Quarto's bundled extensions, and from Quarto itself — into the `.quarto/` cache directory before calling `typst compile`. This means Typst documents render offline without needing network access. |
| 67 | + |
| 68 | +To make this work, extension authors use the new [`typst-gather`](/docs/advanced/typst/typst-gather.qmd) tool, which scans their `.typ` files for `@preview` imports and downloads the packages into the extension directory. Authors run `quarto call typst-gather` and commit the results — users of the extension don't need to do anything. This means [Custom Typst Formats](/docs/output-formats/typst-custom.qmd#custom-formats) can depend on Typst packages without copying and pasting Typst code, making them simpler and easier to maintain. |
0 commit comments