Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix to the theme and docs #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ SEU-styled slide themes and templates based on [Touying](https://touying-typ.git

So far, only a theme inspired by <https://github.com/TouchFishPioneer/SEU-Beamer-Slide> is provided. The example can be found in `examples/beamer-sms.typ`.

> [!NOTE]
> This theme requires the installation of [Helvetica](./themes/assets/Helvetica.ttf) and [SimHei](./themes/assets/SimHei.ttf) fonts, both of which can be found in the [`themes/assets`](./themes/assets) directory.

Welcome to contribute more templates!

## License
Expand Down
3 changes: 3 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

目前只提供了一个 Beamer 风格的主题 `themes/seu-beamer.typ`,仿自 <https://github.com/TouchFishPioneer/SEU-Beamer-Slide>,在 `examples/beamer-sms.typ` 中提供迁移示例。

> [!NOTE]
> 本主题需要安装 [Helvetica](./themes/assets/Helvetica.ttf) 和 [SimHei](./themes/assets/SimHei.ttf) 字体,这两个字体均可在 [`themes/assets`](./themes/assets) 目录下找到。

欢迎投稿更多模板!

## License
Expand Down
Binary file modified examples/beamer-sms.pdf
Binary file not shown.
Binary file added themes/assets/Helvetica.ttf
Binary file not shown.
Binary file added themes/assets/SimHei.ttf
Binary file not shown.
144 changes: 112 additions & 32 deletions themes/seu-beamer.typ
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,68 @@

#let seu-nav-bar(self: none) = states.touying-progress-with-sections(dict => {
let (current-sections, final-sections) = dict
current-sections = current-sections.filter(section => section.loc != none).map(section => (
section,
section.children,
)).flatten().filter(item => item.kind == "section")
final-sections = final-sections.filter(section => section.loc != none).map(section => (
section,
section.children,
)).flatten().filter(item => item.kind == "section")

current-sections = current-sections
.filter(section => section.loc != none)
.map(section => (section, section.children,))
.flatten()
.filter(item => item.kind == "section")

final-sections = final-sections
.filter(section => section.loc != none)
.map(section => (section, section.children,))
.flatten()
.filter(item => item.kind == "section")

let current-index = current-sections.len() - 1

set text(size: 0.5em)

for (i, section) in final-sections.enumerate() {
set text(fill: if i != current-index {
gray
} else {
white
})
box(inset: 0.5em)[#link(section.loc, utils.section-short-title(section))<touying-link>]
box(inset: 0.5em)[
#link(section.loc, utils.section-short-title(section))<touying-link>
]
}
})

#let seu-outline(self: none) = states.touying-progress-with-sections(dict => {
let (current-sections, final-sections) = dict
current-sections = current-sections.filter(section => section.loc != none).map(section => (
section,
section.children,
)).flatten().filter(item => item.kind == "section")
final-sections = final-sections.filter(section => section.loc != none).map(section => (
section,
section.children,
)).flatten().filter(item => item.kind == "section")

current-sections = current-sections
.filter(section => section.loc != none)
.map(section => (section, section.children,))
.flatten()
.filter(item => item.kind == "section")

final-sections = final-sections
.filter(section => section.loc != none)
.map(section => (section, section.children,))
.flatten()
.filter(item => item.kind == "section")

let current-index = current-sections.len() - 1

// set text(size: 0.5em)
for (i, section) in final-sections.enumerate() {
if i == 0 {
continue
}

set text(fill: if current-index == 0 or i == current-index {
self.colors.primary
} else {
self.colors.primary.lighten(80%)
})

block(
spacing: 1.5em,
[#link(section.loc, utils.section-short-title(section))<touying-link>],
[
#link(section.loc, section.title)<touying-link>
],
)
}
})
Expand Down Expand Up @@ -80,13 +96,13 @@
if display-current-section != auto {
self.seu-display-current-section = display-current-section
}

(self.methods.touying-slide)(
..args.named(),
self: self,
title: title,
setting: body => {
show: args.named().at("setting", default: body => body)
// align(center + horizon, block(body))
align(horizon, body)
},
..args.pos(),
Expand All @@ -95,6 +111,7 @@

#let title-slide(self: none, ..args) = {
let info = self.info + args.named()

info.authors = {
let authors = if "authors" in info {
info.authors
Expand All @@ -107,66 +124,102 @@
(authors,)
}
}

let content = {
if info.logo != none {
align(right, info.logo)
}

show: align.with(center + horizon)
block(
fill: self.colors.primary,
inset: 1.5em,
radius: 0.5em,
breakable: false,
{
text(size: 1.2em, fill: self.colors.neutral-lightest, weight: "bold", info.title)
text(
size: 1.2em,
fill: self.colors.neutral-lightest,
weight: "bold",
info.title
)

if info.subtitle != none {
parbreak()
text(size: 1.0em, fill: self.colors.neutral-lightest, weight: "bold", info.subtitle)
text(
size: 1.0em,
fill: self.colors.neutral-lightest,
weight: "bold",
info.subtitle
)
}
},
)

// authors
grid(
columns: (1fr,) * calc.min(info.authors.len(), 3),
column-gutter: 1em,
row-gutter: 1em,
..info.authors.map(author => text(fill: black, author)),
)

v(0.5em)

// institution
if info.institution != none {
parbreak()
text(size: 0.7em, info.institution)
}

// date
if info.date != none {
parbreak()
text(size: 1.0em, utils.info-date(self))
}
}
(self.methods.touying-slide)(self: self, repeat: none, content)

(self.methods.touying-slide)(
self: self,
repeat: none,
content
)
}

#let outline-slide(self: none) = {
self.seu-title = [目录]

let content = {
set align(horizon)
set text(weight: "bold")
hide([-])
seu-outline(self: self)
}
(self.methods.touying-slide)(self: self, repeat: none, section: (title: [目录]), content)

(self.methods.touying-slide)(
self: self,
repeat: none,
section: (title: [目录]),
content
)
}

#let new-section-slide(self: none, short-title: auto, title) = {
self.seu-title = [目录]

let content = {
set align(horizon)
set text(weight: "bold")
hide([-]) // 如果没这个会导致显示出问题
hide([-])
seu-outline(self: self)
}
(self.methods.touying-slide)(self: self, repeat: none, section: (title: title, short-title: short-title), content)

(self.methods.touying-slide)(
self: self,
repeat: none,
section: (title: title, short-title: short-title),
content
)
}

#let ending-slide(self: none, title: none, body) = {
Expand All @@ -177,19 +230,33 @@
fill: self.colors.tertiary,
inset: (x: 3em, y: 0.7em),
radius: 0.5em,
text(size: 1.5em, fill: self.colors.neutral-lightest, title),
text(
size: 1.5em,
fill: self.colors.neutral-lightest,
title
),
)
}
body
}
(self.methods.touying-slide)(self: self, repeat: none, content)

(self.methods.touying-slide)(
self: self,
repeat: none,
content
)
}

#let slides(self: none, title-slide: true, slide-level: 1, ..args) = {
if title-slide {
(self.methods.title-slide)(self: self)
}
(self.methods.touying-slides)(self: self, slide-level: slide-level, ..args)

(self.methods.touying-slides)(
self: self,
slide-level: slide-level,
..args
)
}

#let register(
Expand Down Expand Up @@ -220,6 +287,7 @@
neutral-lightest: rgb("#ffffff"),
neutral-darkest: rgb("#000000"),
)

// marker
self.seu-knob-marker = box(
width: 0.5em,
Expand All @@ -246,6 +314,7 @@
components.cell(fill: self.colors.tertiary),
)
})

self.seu-navigation = self => {
grid(
align: center + horizon,
Expand All @@ -256,6 +325,7 @@
block(fill: self.colors.primary, inset: 0.1em, image("assets/seu-logo-min.svg", height: 100%)),
)
}

self.seu-display-current-section = display-current-section
self.seu-title = none
self.seu-subtitle = none
Expand All @@ -278,6 +348,7 @@
cell(fill: self.colors.primary, utils.call-or-display(self, footer-d)),
)
}

self.seu-header = self => {
if self.seu-title != none {
block(
Expand All @@ -292,6 +363,7 @@
)
}
}

// set page
let header(self) = {
set align(top)
Expand All @@ -316,6 +388,7 @@
margin: (top: 4em, bottom: 0.7em, x: 2.5em),
background: place(center + horizon, dx: 50%, dy: 5%, image("assets/seu-background-min.svg", width: 75%)),
)

// register methods
self.methods.slide = slide
self.methods.title-slide = title-slide
Expand All @@ -328,7 +401,6 @@
states.touying-outline(self: self, enum-args: (tight: false) + enum-args, ..args)
}
self.methods.alert = (self: none, it) => text(fill: self.colors.primary, it)

self.methods.tblock = (self: none, title: none, it) => {
grid(
columns: 1,
Expand All @@ -338,10 +410,18 @@
width: 100%,
radius: (top: 0.4em),
inset: (top: 0.4em, bottom: 0.3em, x: 0.5em),
text(fill: self.colors.neutral-lightest, weight: "bold", title),
text(
fill: self.colors.neutral-lightest,
weight: "bold",
title
),
),
rect(
fill: gradient.linear(self.colors.primary-dark, self.colors.primary.lighten(90%), angle: 90deg),
fill: gradient.linear(
self.colors.primary-dark,
self.colors.primary.lighten(90%),
angle: 90deg
),
width: 100%,
height: 4pt,
),
Expand Down