touying-author
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTouying Author
Touying 创作指南
Guide Typst presentation authoring with Touying, emphasizing clean structure, repeatable configuration, and slide-safe patterns.
指导使用Touying进行Typst演示文稿创作,强调清晰的结构、可复用的配置以及幻灯片安全的编写模式。
Quick start
快速入门
- Import Touying and a theme, then apply the theme with .
#show: <theme>.with(...) - Keep configuration centralized; include slide content from separate files.
- Use headings to create slides; use for custom layouts or animations.
#slide - Start from for a minimal deck, or
examples/simple.typfor the bare theme.examples/default.typ
Snippet from :
examples/simple.typtypst
#import "@preview/touying:0.6.1": *
#import themes.simple: *
#show: simple-theme.with(
aspect-ratio: "16-9",
footer: [Simple slides],
)- 导入Touying和一个主题,然后使用应用该主题。
#show: <theme>.with(...) - 集中管理配置;从单独的文件中引入幻灯片内容。
- 使用标题创建幻灯片;使用实现自定义布局或动画。
#slide - 可以从开始搭建极简演示文稿,或从
examples/simple.typ开始使用基础主题。examples/default.typ
来自的代码片段:
examples/simple.typtypst
#import "@preview/touying:0.6.1": *
#import themes.simple: *
#show: simple-theme.with(
aspect-ratio: "16-9",
footer: [Simple slides],
)Best practices and code structure
最佳实践与代码结构
- Use a single entry file (e.g., ) that applies
main.typand all#showcalls.config-* - For multi-file decks, follow the +
globals.typ+main.typpattern; usecontent.typfor content and#includefor globals to avoid circular refs.#import - Docs use both (see
config.typ) anddocs/start.md(seeglobals.typ) for the shared config file; pick one name and use it consistently in your project.docs/multi-file.md - For large decks, move into
content.typand includesections/(and optionalsections/content.typ) fromsections/another-section.typ.main.typ - Prefer ,
config-page,config-common,config-info,config-colors, andconfig-methodsover directconfig-storeor ad-hoc globalset page.show - Use headings for most slides; use to choose which heading levels create slides.
config-common(slide-level: n) - Use only for custom layout or animation; always wrap slide functions with
#slide.touying-slide-wrapper - For callback-style animation (), set
#slide(repeat: n, self => [...])explicitly and userepeatto accessutils.methods(self),uncover, andonly.alternatives
- 使用单个入口文件(例如)来应用
main.typ和所有#show调用。config-* - 对于多文件演示文稿,遵循+
globals.typ+main.typ的模式;使用content.typ引入内容,使用#include引入全局文件以避免循环引用。#import - 文档中同时使用(参见
config.typ)和docs/start.md(参见globals.typ)作为共享配置文件;在项目中选择一个名称并保持一致。docs/multi-file.md - 对于大型演示文稿,将移入
content.typ目录,并从sections/中引入main.typ(以及可选的sections/content.typ)。sections/another-section.typ - 优先使用、
config-page、config-common、config-info、config-colors和config-methods,而非直接使用config-store或临时的全局set page设置。show - 大多数幻灯片使用标题创建;使用来指定哪些标题级别可创建幻灯片。
config-common(slide-level: n) - 仅在需要自定义布局或动画时使用;始终用
#slide包裹幻灯片函数。touying-slide-wrapper - 对于回调式动画(),显式设置
#slide(repeat: n, self => [...])参数,并使用repeat来访问utils.methods(self)、uncover和only。alternatives
Single-file structure
单文件结构
.
├── globals.typ
├── main.typ
└── content.typ.
├── globals.typ
├── main.typ
└── content.typMulti-file structure
多文件结构
.
├── globals.typ
├── main.typ
└── sections/
├── content.typ
└── another-section.typ.
├── globals.typ
├── main.typ
└── sections/
├── content.typ
└── another-section.typCore API map (exports)
核心API映射(导出项)
- Slides: ,
touying-slides,slide,touying-slide,touying-slide-wrapperempty-slide - Dynamics: ,
pause,meanwhile,uncover,only,effect,alternatives,alternatives-match,alternatives-fnalternatives-cases - Config: ,
config-common,config-page,config-info,config-colors,config-methods,config-store,default-config,touying-set-configappendix - Utilities: (fit-to-height, fit-to-width, cover helpers, progress, heading helpers)
utils.* - Components: ,
components.side-by-side,components.adaptive-columns,components.progressive-outlinecomponents.custom-progressive-outline - Integrations: ,
touying-reducer,touying-equation,touying-mitex,speaker-notepdfpc.* - Recall: ,
touying-recalltouying-fn-wrapper
- 幻灯片:、
touying-slides、slide、touying-slide、touying-slide-wrapperempty-slide - 动态效果:、
pause、meanwhile、uncover、only、effect、alternatives、alternatives-match、alternatives-fnalternatives-cases - 配置:、
config-common、config-page、config-info、config-colors、config-methods、config-store、default-config、touying-set-configappendix - 工具函数:(高度适配、宽度适配、封面辅助函数、进度、标题辅助函数)
utils.* - 组件:、
components.side-by-side、components.adaptive-columns、components.progressive-outlinecomponents.custom-progressive-outline - 集成:、
touying-reducer、touying-equation、touying-mitex、speaker-notepdfpc.* - 回调:、
touying-recalltouying-fn-wrapper
Slide structure and headings
幻灯片结构与标题
- Use heading labels to control numbering/outline/bookmarks: use (see
<touying:hidden>), and seedocs/code-styles.mdfordocs/changelog.md,<touying:unnumbered>,<touying:unoutlined>, and<touying:unbookmarked>.<touying:skip> - Use for a table of contents slide; use
components.adaptive-columns(outline(...))for progress-aware outlines.components.progressive-outline - Use to insert a blank title slide and clear the previous heading context.
== <touying:hidden> - Use or
#pagebreak()to split slides without changing headings.--- - Use for slides without header/footer.
#empty-slide[...] - Use to keep only the last subslide per slide in handout output.
config-common(handout: true) - Use to freeze last-slide counts after the main deck.
#show: appendix
Snippet from :
examples/default.typtypst
= Outline <touying:hidden>
#components.adaptive-columns(outline(title: none, indent: 1em))- 使用标题标签控制编号/大纲/书签:使用(参见
<touying:hidden>),并查看docs/code-styles.md了解docs/changelog.md、<touying:unnumbered>、<touying:unoutlined>和<touying:unbookmarked>的用法。<touying:skip> - 使用创建目录幻灯片;使用
components.adaptive-columns(outline(...))创建支持进度显示的大纲。components.progressive-outline - 使用插入空白标题幻灯片并清除之前的标题上下文。
== <touying:hidden> - 使用或
#pagebreak()在不改变标题的情况下拆分幻灯片。--- - 使用创建没有页眉/页脚的幻灯片。
#empty-slide[...] - 使用在讲义输出中仅保留每个幻灯片的最后一个子幻灯片。
config-common(handout: true) - 使用在主演示文稿结束后冻结最后幻灯片的计数。
#show: appendix
来自的代码片段:
examples/default.typtypst
= Outline <touying:hidden>
#components.adaptive-columns(outline(title: none, indent: 1em))Animations and dynamic content
动画与动态内容
- Use and
#pausefor simple reveals; avoid using them inside#meanwhilewhere marks are not supported.context - Use to reserve layout space; use
#uncoverto remove layout space when hidden.#only - When marks cause warnings, use callback-style slides with and
repeat.utils.methods(self) - For math animations, use /
pauseinsidemeanwhile; use$ ... $when you need the helper for inline equation text (you can also usetouying-equationor#pause).#pause; - See for simple/complex/callback animations and equation animations.
examples/example.typ
Snippet from :
examples/simple.typtypst
== Dynamic slide
Did you know that...
#pause
...you can see the current section at the top of the slide?Snippet from :
examples/example.typtypst
#slide(
repeat: 3,
self => [
#let (uncover, only, alternatives) = utils.methods(self)
At subslide #self.subslide, we can
use #uncover("2-")[`#uncover` function] for reserving space,
use #only("2-")[`#only` function] for not reserving space,
#alternatives[call `#only` multiple times \u{2717}][use `#alternatives` function #sym.checkmark] for choosing one of the alternatives.
],
)- 使用和
#pause实现简单的内容展示;避免在不支持标记的#meanwhile内部使用它们。context - 使用预留布局空间;使用
#uncover在内容隐藏时移除布局空间。#only - 当标记导致警告时,使用带参数的回调式幻灯片和
repeat。utils.methods(self) - 对于数学公式动画,在内部使用
$ ... $/pause;当需要内联公式文本的辅助函数时,使用meanwhile(也可以使用touying-equation或#pause)。#pause; - 查看了解简单/复杂/回调式动画以及公式动画的示例。
examples/example.typ
来自的代码片段:
examples/simple.typtypst
== Dynamic slide
Did you know that...
#pause
...you can see the current section at the top of the slide?来自的代码片段:
examples/example.typtypst
#slide(
repeat: 3,
self => [
#let (uncover, only, alternatives) = utils.methods(self)
At subslide #self.subslide, we can
use #uncover("2-")[`#uncover` function] for reserving space,
use #only("2-")[`#only` function] for not reserving space,
#alternatives[call `#only` multiple times \u{2717}][use `#alternatives` function #sym.checkmark] for choosing one of the alternatives.
],
)Layout and theming
布局与主题
- Use in
composerfor columns; pass#slideor a custom(1fr, 2fr)function.grid - Use for margin, header, footer, and background; do not use
config-pagedirectly.set page - Use only when layout changes are acceptable.
config-methods(cover: utils.semi-transparent-cover.with(alpha: 85%)) - Use to stash theme-specific values for headers/footers or navigation elements.
config-store - Use to disable automatic section slides, or provide a custom function to replace them.
config-common(new-section-slide-fn: none) - Apply global styles either around or via
#show: <theme>.with(...)in a theme.config-methods(init: ...) - Use for title/author/date and
config-info(...)to control date formatting.config-common(datetime-format: ...)
Snippet from :
examples/default.typtypst
#import "@preview/touying:0.6.1": *
#import themes.default: *
#import "@preview/numbly:0.1.0": numbly
#show: default-theme.with(
aspect-ratio: "16-9",
config-common(
slide-level: 3,
zero-margin-header: false,
),
config-colors(primary: blue),
config-methods(alert: utils.alert-with-primary-color),
config-page(
header: text(gray, utils.display-current-short-heading(level: 2)),
),
)- 在中使用
#slide创建分栏;传入composer或自定义的(1fr, 2fr)函数。grid - 使用设置边距、页眉、页脚和背景;不要直接使用
config-page。set page - 仅在可接受布局变化时,使用。
config-methods(cover: utils.semi-transparent-cover.with(alpha: 85%)) - 使用存储主题特定的值,用于页眉/页脚或导航元素。
config-store - 使用禁用自动生成的章节幻灯片,或提供自定义函数替换它们。
config-common(new-section-slide-fn: none) - 全局样式可以在周围设置,或通过主题中的
#show: <theme>.with(...)应用。config-methods(init: ...) - 使用设置标题/作者/日期,并使用
config-info(...)控制日期格式。config-common(datetime-format: ...)
来自的代码片段:
examples/default.typtypst
#import "@preview/touying:0.6.1": *
#import themes.default: *
#import "@preview/numbly:0.1.0": numbly
#show: default-theme.with(
aspect-ratio: "16-9",
config-common(
slide-level: 3,
zero-margin-header: false,
),
config-colors(primary: blue),
config-methods(alert: utils.alert-with-primary-color),
config-page(
header: text(gray, utils.display-current-short-heading(level: 2)),
),
)Speaker notes and presenter tools
演讲者备注与演示工具
- Add notes with .
#speaker-note[...] - Show notes on second screen with or
config-common(show-notes-on-second-screen: right).bottom - Export pdfpc metadata with and
enable-pdfpc: true.typst query --field value --one "<pdfpc-file>"
- 使用添加备注。
#speaker-note[...] - 使用或
config-common(show-notes-on-second-screen: right)在第二个屏幕上显示备注。bottom - 启用并使用
enable-pdfpc: true导出pdfpc元数据。typst query --field value --one "<pdfpc-file>"
Use bundled docs and examples
使用内置文档与示例
- Read only the specific docs needed for the task; avoid loading the full docs tree.
- Read and
docs/start.mdfor basics and import patterns.docs/intro.md - Read for multi-file layout and include patterns.
docs/multi-file.md - Read and
docs/layout.mdfor slide-level and heading behavior.docs/sections.md - Read for simple vs block style and pagination tricks.
docs/code-styles.md - Read for global styles and
docs/global-settings.mdusage.config-info - Read for
docs/dynamic/*.md,pause, cover behavior, and equation animation.meanwhile - Read for theme-specific APIs and defaults.
docs/themes/*.md - Read for pdfpc and Pympress usage.
docs/external/*.md - Read for CeTZ/Fletcher/Theorion/MiTeX integrations.
docs/integration/*.md - Use as working templates for each theme.
examples/*.typ
- 仅阅读完成任务所需的特定文档;避免加载完整的文档树。
- 阅读和
docs/start.md了解基础用法和导入模式。docs/intro.md - 阅读了解多文件布局和引入模式。
docs/multi-file.md - 阅读和
docs/layout.md了解幻灯片级别和标题行为。docs/sections.md - 阅读了解简洁式与块式写法以及分页技巧。
docs/code-styles.md - 阅读了解全局样式和
docs/global-settings.md的用法。config-info - 阅读了解
docs/dynamic/*.md、pause、封面行为和公式动画。meanwhile - 阅读了解主题特定的API和默认设置。
docs/themes/*.md - 阅读了解pdfpc和Pympress的用法。
docs/external/*.md - 阅读了解CeTZ/Fletcher/Theorion/MiTeX的集成。
docs/integration/*.md - 使用作为每个主题的可用模板。
examples/*.typ
File tree (docs and examples)
文件树(文档与示例)
docs/
├── build-your-own-theme.md
├── changelog.md
├── code-styles.md
├── dynamic
│ ├── complex.md
│ ├── cover.md
│ ├── equation.md
│ ├── handout.md
│ ├── other.md
│ └── simple.md
├── external
│ ├── pdfpc.md
│ ├── pympress.md
│ └── typst-preview.md
├── global-settings.md
├── integration
│ ├── cetz.md
│ ├── codly.md
│ ├── fletcher.md
│ ├── mitex.md
│ ├── pinit.md
│ └── theorion.md
├── intro.md
├── layout.md
├── multi-file.md
├── progress
│ ├── counters.md
│ └── sections.md
├── sections.md
├── start.md
├── themes
│ ├── aqua.md
│ ├── custom.md
│ ├── dewdrop.md
│ ├── metropolis.md
│ ├── simple.md
│ ├── stargazer.md
│ └── university.md
└── utilities
└── fit-to.md
examples/
├── aqua-zh.typ
├── aqua.typ
├── default.typ
├── dewdrop.typ
├── example.typ
├── metropolis.typ
├── simple.typ
├── stargazer.typ
└── university.typdocs/
├── build-your-own-theme.md
├── changelog.md
├── code-styles.md
├── dynamic
│ ├── complex.md
│ ├── cover.md
│ ├── equation.md
│ ├── handout.md
│ ├── other.md
│ └── simple.md
├── external
│ ├── pdfpc.md
│ ├── pympress.md
│ └── typst-preview.md
├── global-settings.md
├── integration
│ ├── cetz.md
│ ├── codly.md
│ ├── fletcher.md
│ ├── mitex.md
│ ├── pinit.md
│ └── theorion.md
├── intro.md
├── layout.md
├── multi-file.md
├── progress
│ ├── counters.md
│ └── sections.md
├── sections.md
├── start.md
├── themes
│ ├── aqua.md
│ ├── custom.md
│ ├── dewdrop.md
│ ├── metropolis.md
│ ├── simple.md
│ ├── stargazer.md
│ └── university.md
└── utilities
└── fit-to.md
examples/
├── aqua-zh.typ
├── aqua.typ
├── default.typ
├── dewdrop.typ
├── example.typ
├── metropolis.typ
├── simple.typ
├── stargazer.typ
└── university.typ