常见问题
本页收集了 Touying 使用中的常见问题与解决方案。
主题与配置
如何选择和切换主题?
Touying 提供多个内置主题,通过导入并应用主题函数即可切换:
#import "@preview/touying:0.7.1": *
#import themes.simple: *
#show: simple-theme
= Section
== Slide
Using the simple theme.
其他内置主题包括 themes.default、themes.metropolis、themes.aqua、themes.dewdrop、themes.stargazer、themes.university 等。
如何自定义主题颜色?
使用 config-colors(primary: ...) 自定义主题的主色调:
#import "@preview/touying:0.7.1": *
#import themes.metropolis: *
#show: metropolis-theme.with(
aspect-ratio: "16-9",
config-colors(primary: rgb("#d94f00")),
config-info(title: [Custom Color], author: [Author]),
)
= Section
== Slide
The header now uses the custom primary color.
config-common 配置参考
config-common 有哪些常用配置项?
config-common 是 Touying 的核心配置函数,以下是常用配置项及其默认值和说明:
| 配置项 | 默认值 | 说明 |
|---|---|---|
handout | false | 讲义模式,禁用动画 |
slide-level | 2 | 控制哪个标题级别创建新幻灯片 |
frozen-counters | () | 冻结计数器列表 |
show-strong-with-alert | true | 粗体文本使用 alert 样式 |
show-notes-on-second-screen | none | 第二屏幕演讲者备注(none/right/left) |
horizontal-line-to-pagebreak | true | 将 --- 水平线转换为分页符 |
nontight-list-enum-and-terms | false | 列表项间距控制 |
show-hide-set-list-marker-none | true | #pause 后隐藏列表标记 |
show-bibliography-as-footnote | none | 参考文献显示为脚注 |
scale-list-items | none | 缩放列表项大小 |
new-section-slide-fn | none | 章节幻灯片函数 |
freeze-slide-counter | false | 冻结幻灯片计数器 |
enable-pdfpc | true | 启用 pdfpc 支持 |
breakable | true | 是否允许幻灯片内容溢出到下一页 |
clip | false | 是否裁剪溢出内容(仅在 breakable: false 时生效) |
detect-overflow | true | 是否检测溢出并报错(仅在 breakable: false 时生效) |
如何防止幻灯片内容溢出到下一页?
使用 config-common(breakable: false) 可以防止幻灯片内容自动溢出到下一页。默认情况下(breakable: true),超出幻灯片高度的内容会自动创建新页面;设置为 false 后,内容将被限制在单页内,这对于需要保证源码与输出页面一一对应的场景(如 AI 智能体工作流)非常有用。
配合使用的参数:
clip(默认false):设为true时,超出幻灯片高度的内容会被视觉截断。detect-overflow(默认true):设为true时,会通过布局测量检测溢出,一旦内容高度超出幻灯片高度则直接panic()报错,便于及早发现问题;设为false可避免额外的布局开销。
// Prevent overflow, panic on overflow (default behavior when breakable: false)
#show: simple-theme.with(
config-common(breakable: false),
)
// Prevent overflow and visually clip overflowing content
#show: simple-theme.with(
config-common(breakable: false, clip: true),
)
// Prevent overflow, disable overflow detection (performance-first)
#show: simple-theme.with(
config-common(breakable: false, detect-overflow: false),
)
也可以在演示文稿中途通过 touying-set-config 切换:
== This slide's overflow will be clipped
// Enable clipping for a specific slide
#show: touying-set-config.with(config-common(clip: true))
#lorem(500)
如何使用半透明遮罩替代完全隐藏?
使用 config-methods(cover: utils.semi-transparent-cover) 配置,使被隐藏的内容以半透明形式显示:
#import "@preview/touying:0.7.1": *
#import themes.simple: *
#show: simple-theme.with(
aspect-ratio: "16-9",
config-methods(cover: utils.semi-transparent-cover),
)
= Section
== Slide
#pause
This content is shown with a semi-transparent cover.