From ebfcb0fb7c3db8ba22541ccbf0ff7c379126c20f Mon Sep 17 00:00:00 2001 From: OrangeX4 <318483724@qq.com> Date: Fri, 15 Mar 2024 15:52:32 +0800 Subject: [PATCH] theme: update aqua theme and simplify codes --- examples/aqua-zh.typ | 46 +++++++++++++++++-------------------------- examples/aqua.typ | 38 +++++++++++++++++------------------ examples/slides.typ | 2 ++ themes/aqua.typ | 14 +++++++++++-- themes/dewdrop.typ | 2 +- themes/metropolis.typ | 2 +- themes/simple.typ | 3 +-- themes/university.typ | 2 +- 8 files changed, 55 insertions(+), 54 deletions(-) diff --git a/examples/aqua-zh.typ b/examples/aqua-zh.typ index 56f12c82a..9df192c9c 100644 --- a/examples/aqua-zh.typ +++ b/examples/aqua-zh.typ @@ -1,45 +1,35 @@ #import "../lib.typ": * #let s = themes.aqua.register(aspect-ratio: "16-9", lang: "zh") - #let s = (s.methods.info)( - self: s, - title: [An Instruction to Typst-Beamer], - author: [Author], + self: s, + title: [标题], + subtitle: [副标题], + author: [作者], date: datetime.today(), + institution: [机构], ) -#let (init, slides) = utils.methods(s) +#let (init, slides, touying-outline, alert) = utils.methods(s) #show: init -#set text(font: "Microsoft YaHei") // "Microsoft YaHei" is recommended. -#let (slide, title-slide, outline-slide, new-section-slide) = utils.slides(s) -#show: slides +#show strong: alert -= 制作一个标题页 +#let (slide, title-slide, outline-slide, focus-slide) = utils.slides(s) +#show: slides -#slide[ - = Typst Beamer 如何做? - 欢迎阅读 Typst 的中文文档!Typst 是为科学写作而诞生的基于标记的排版系统。 它被设计之初就是作为一种替代品,用于替代像 LaTeX 这样的高级工具,又或者是像 Word 和 Google Docs 这样的简单工具。 我们对 Typst 的目标是构建一个功能强大的排版工具,并且让用户可以愉快地使用它。 += 第一节 - 本文档分为两部分:一个适合初学者的教程,其通过实际用例介绍 Typst;以及一个全面的参考,以解释 Typst 的所有概念和功能。 +== 小标题 - 我们还邀请您加入我们为 Typst 建立的社区。Typst 仍是一个非常年轻的项目,因此我们非常希望能够得到您的反馈。 +#slide[ + #lorem(40) ] -= 制作一个目录页 - -== 标题2 - -#grid( - columns: (1fr,1fr), - column-gutter: 50pt, - row-gutter: 20pt, - [属性 1], [属性 2], - [#lorem(20)], [#lorem(20)], -) - +#slide[ + #lorem(40) +] -== Summary +== 总结 #align(center + horizon)[ #set text(size: 3em, weight: "bold", s.colors.primary) @@ -47,4 +37,4 @@ THANKS FOR ALL 敬请指正! -] +] \ No newline at end of file diff --git a/examples/aqua.typ b/examples/aqua.typ index 78a06bdcc..b8acd20af 100644 --- a/examples/aqua.typ +++ b/examples/aqua.typ @@ -1,37 +1,37 @@ #import "../lib.typ": * #let s = themes.aqua.register(aspect-ratio: "16-9") - #let s = (s.methods.info)( - self: s, - title: [An Instruction to Typst-Beamer], - author: [Author], + self: s, + title: [Title], + subtitle: [Subtitle], + author: [Authors], date: datetime.today(), + institution: [Institution], ) -#let (init, slides) = utils.methods(s) +#let (init, slides, touying-outline, alert) = utils.methods(s) #show: init -#let (slide, title-slide, outline-slide, new-section-slide) = utils.slides(s) +#show strong: alert + +#let (slide, title-slide, outline-slide, focus-slide) = utils.slides(s) #show: slides -= Title Slide += The Section + +== Slide Title #slide[ - = How to make Typst-Beamer? - #lorem(80) + #lorem(40) ] -= Content Slide - -== Test for grid +#slide[ + #lorem(40) +] -#grid( - columns: (1fr, 1fr), - column-gutter: 50pt, - row-gutter: 20pt, - [Feature 1], [Feature 2], - [#lorem(20)], [#lorem(20)], -) +#focus-slide[ + Another variant with primary color in background... +] == Summary diff --git a/examples/slides.typ b/examples/slides.typ index 3b3068e10..49e260da2 100644 --- a/examples/slides.typ +++ b/examples/slides.typ @@ -4,6 +4,8 @@ // #let s = themes.simple.register(aspect-ratio: "16-9", footer: [Simple slides]) // #let s = themes.metropolis.register(aspect-ratio: "16-9", footer: [Custom footer]) // #let s = themes.dewdrop.register(aspect-ratio: "16-9", footer: [Dewdrop]) +// #let s = themes.university.register(aspect-ratio: "16-9") +// #let s = themes.aqua.register(aspect-ratio: "16-9") #let s = (s.methods.info)( self: s, title: [Title], diff --git a/themes/aqua.typ b/themes/aqua.typ index 0acf8543c..b631b22c2 100644 --- a/themes/aqua.typ +++ b/themes/aqua.typ @@ -26,7 +26,7 @@ fill: self.colors.primary-light, size: 20pt, weight: "regular", - if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date }, + utils.info-date(self), ) } ) @@ -110,6 +110,13 @@ (self.methods.touying-slide)(self: self, repeat: none, section: section, body) } +#let focus-slide(self: none, body) = { + self = utils.empty-page(self) + self.page-args += (fill: self.colors.primary, margin: 2em) + set text(fill: white, size: 2em, weight: "bold") + (self.methods.touying-slide)(self: self, repeat: none, align(horizon + center, body)) +} + #let slide(self: none, title: auto, ..args) = { if title != auto { self.aqua-title = title @@ -137,6 +144,7 @@ #let register( self: s, aspect-ratio: "16-9", + footer: states.slide-counter.display(), lang: "en", ) = { assert(lang in ("zh", "en"), message: "lang must be 'zh' or 'en'") @@ -153,6 +161,7 @@ [ ] states.current-section-title } + self.aqua-footer = footer self.aqua-lang = lang self.aqua-background = (self) => { place(left + top, dx: -15pt, dy: -26pt, @@ -193,7 +202,7 @@ } let footer(self) = { set text(size: 0.8em) - place(right, dx: -5%, states.slide-counter.display()) + place(right, dx: -5%, utils.call-or-display(self, self.aqua-footer)) } self.page-args += ( paper: "presentation-" + aspect-ratio, @@ -208,6 +217,7 @@ } self.methods.title-slide = title-slide self.methods.outline-slide = outline-slide + self.methods.focus-slide = focus-slide self.methods.new-section-slide = new-section-slide self.methods.touying-new-section-slide = new-section-slide self.methods.slide = slide diff --git a/themes/dewdrop.typ b/themes/dewdrop.typ index 63a05ccf3..655db1882 100644 --- a/themes/dewdrop.typ +++ b/themes/dewdrop.typ @@ -67,7 +67,7 @@ } v(1em) if info.date != none { - block(spacing: 1em, if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date }) + block(spacing: 1em, utils.info-date(self)) } set text(size: .8em) if info.institution != none { diff --git a/themes/metropolis.typ b/themes/metropolis.typ index 377d49b42..ed9c712f2 100644 --- a/themes/metropolis.typ +++ b/themes/metropolis.typ @@ -65,7 +65,7 @@ block(spacing: 1em, info.author) } if info.date != none { - block(spacing: 1em, if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date }) + block(spacing: 1em, utils.info-date(self)) } set text(size: .8em) if info.institution != none { diff --git a/themes/simple.typ b/themes/simple.typ index 0ef440b8a..abe3dc0b1 100644 --- a/themes/simple.typ +++ b/themes/simple.typ @@ -33,8 +33,7 @@ } #let focus-slide(self: none, background: auto, foreground: white, body) = { - self.page-args.header = none - self.page-args.footer = none + self = utils.empty-page(self) self.page-args.fill = if background == auto { self.colors.primary } else { background } set text(fill: foreground, size: 1.5em) centered-slide(self: self, align(center + horizon, body)) diff --git a/themes/university.typ b/themes/university.typ index 1c3995b05..901cfd2af 100644 --- a/themes/university.typ +++ b/themes/university.typ @@ -88,7 +88,7 @@ } if info.date != none { parbreak() - text(size: .8em, if type(info.date) == datetime { info.date.display(self.datetime-format) } else { info.date }) + text(size: .8em, utils.info-date(self)) } }) }