$npx -y skills add apcamargo/typst-skills --skill touying-authorAuthor, refactor, and troubleshoot Typst slide decks built with Touying
| 1 | # Touying Author |
| 2 | |
| 3 | Guide Typst presentation authoring with Touying, emphasizing clean structure, repeatable configuration, and slide-safe patterns. |
| 4 | |
| 5 | ## Quick start |
| 6 | - Import Touying and a theme, then apply the theme with `#show: <theme>.with(...)`. |
| 7 | - Keep configuration centralized; include slide content from separate files. |
| 8 | - Use headings to create slides; use `#slide` for custom layouts or animations. |
| 9 | - Start from `examples/simple.typ` for a minimal deck, or `examples/default.typ` for the bare theme. |
| 10 | |
| 11 | Snippet from `examples/simple.typ`: |
| 12 | |
| 13 | ```typst |
| 14 | #import "@preview/touying:0.6.1": * |
| 15 | #import themes.simple: * |
| 16 | |
| 17 | #show: simple-theme.with( |
| 18 | aspect-ratio: "16-9", |
| 19 | footer: [Simple slides], |
| 20 | ) |
| 21 | ``` |
| 22 | |
| 23 | ## Best practices and code structure |
| 24 | |
| 25 | - Use a single entry file (e.g., `main.typ`) that applies `#show` and all `config-*` calls. |
| 26 | - For multi-file decks, follow the `globals.typ` + `main.typ` + `content.typ` pattern; use `#include` for content and `#import` for globals to avoid circular refs. |
| 27 | - Docs use both `config.typ` (see `docs/start.md`) and `globals.typ` (see `docs/multi-file.md`) for the shared config file; pick one name and use it consistently in your project. |
| 28 | - For large decks, move `content.typ` into `sections/` and include `sections/content.typ` (and optional `sections/another-section.typ`) from `main.typ`. |
| 29 | - Prefer `config-page`, `config-common`, `config-info`, `config-colors`, `config-methods`, and `config-store` over direct `set page` or ad-hoc global `show`. |
| 30 | - Use headings for most slides; use `config-common(slide-level: n)` to choose which heading levels create slides. |
| 31 | - Use `#slide` only for custom layout or animation; always wrap slide functions with `touying-slide-wrapper`. |
| 32 | - For callback-style animation (`#slide(repeat: n, self => [...])`), set `repeat` explicitly and use `utils.methods(self)` to access `uncover`, `only`, and `alternatives`. |
| 33 | |
| 34 | ### Single-file structure |
| 35 | |
| 36 | ``` |
| 37 | . |
| 38 | ├── globals.typ |
| 39 | ├── main.typ |
| 40 | └── content.typ |
| 41 | ``` |
| 42 | |
| 43 | ### Multi-file structure |
| 44 | |
| 45 | ``` |
| 46 | . |
| 47 | ├── globals.typ |
| 48 | ├── main.typ |
| 49 | └── sections/ |
| 50 | ├── content.typ |
| 51 | └── another-section.typ |
| 52 | ``` |
| 53 | |
| 54 | ## Core API map (exports) |
| 55 | |
| 56 | - Slides: `touying-slides`, `slide`, `touying-slide`, `touying-slide-wrapper`, `empty-slide` |
| 57 | - Dynamics: `pause`, `meanwhile`, `uncover`, `only`, `effect`, `alternatives`, `alternatives-match`, `alternatives-fn`, `alternatives-cases` |
| 58 | - Config: `config-common`, `config-page`, `config-info`, `config-colors`, `config-methods`, `config-store`, `default-config`, `touying-set-config`, `appendix` |
| 59 | - Utilities: `utils.*` (fit-to-height, fit-to-width, cover helpers, progress, heading helpers) |
| 60 | - Components: `components.side-by-side`, `components.adaptive-columns`, `components.progressive-outline`, `components.custom-progressive-outline` |
| 61 | - Integrations: `touying-reducer`, `touying-equation`, `touying-mitex`, `speaker-note`, `pdfpc.*` |
| 62 | - Recall: `touying-recall`, `touying-fn-wrapper` |
| 63 | |
| 64 | ## Slide structure and headings |
| 65 | |
| 66 | - Use heading labels to control numbering/outline/bookmarks: use `<touying:hidden>` (see `docs/code-styles.md`), and see `docs/changelog.md` for `<touying:unnumbered>`, `<touying:unoutlined>`, `<touying:unbookmarked>`, and `<touying:skip>`. |
| 67 | - Use `components.adaptive-columns(outline(...))` for a table of contents slide; use `components.progressive-outline` for progress-aware outlines. |
| 68 | - Use `== <touying:hidden>` to insert a blank title slide and clear the previous heading context. |
| 69 | - Use `#pagebreak()` or `---` to split slides without changing headings. |
| 70 | - Use `#empty-slide[...]` for slides without header/footer. |
| 71 | - Use `config-common(handout: true)` to keep only the last subslide per slide in handout output. |
| 72 | - Use `#show: appendix` to freeze last-slide counts after the main deck. |
| 73 | |
| 74 | Snippet from `examples/default.typ`: |
| 75 | |
| 76 | ```typst |
| 77 | = Outline <touying:hidden> |
| 78 | |
| 79 | #components.adaptive-columns(outline(title: none, indent: 1em)) |
| 80 | ``` |
| 81 | |
| 82 | ## Animations and dynamic content |
| 83 | |
| 84 | - Use `#pause` and `#meanwhile` for simple reveals; avoid using them inside `context` where marks are not supported. |
| 85 | - Use `#uncover` to reserve layout space; use `#only` to remove layout space when hidden. |
| 86 | - When marks cause warnings, use callback-style slides with `repeat` and `utils.methods(self)`. |
| 87 | - For math animations, use `pause`/`meanwhile` inside `$ ... $`; use `touying-equation` when you need the helper for inline equation text (you can also use `#pause` or `#pause;`). |
| 88 | - See `examples/example.typ` for simple/complex/callback animations and equation animations. |
| 89 | |
| 90 | Snippet from `examples/simple.typ`: |
| 91 | |
| 92 | ```typst |
| 93 | == Dynamic slide |
| 94 | |
| 95 | Did you know that... |
| 96 | |
| 97 | #pause |
| 98 | |
| 99 | ...you can see the current section at the top of the slide? |
| 100 | ``` |
| 101 | |
| 102 | Snippet from `examples/example.typ`: |
| 103 | ```typst |
| 104 | #slide( |
| 105 | repeat: 3, |
| 106 | self => [ |
| 107 | #let (uncover, only, alternatives) = utils.methods(self) |
| 108 | |
| 109 | At subslide #self.subslide, we can |
| 110 | |
| 111 | use #uncover("2-")[`#uncover` function] for reserving space, |