-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paththeme.typ
More file actions
203 lines (187 loc) · 4.51 KB
/
Copy paththeme.typ
File metadata and controls
203 lines (187 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#import "common.typ": *
#import ctheorems: *
#let layouts = (
"small": ("height": 9cm, "space": 1.4cm),
"medium": ("height": 10.5cm, "space": 1.6cm),
"large": ("height": 12cm, "space": 1.8cm),
)
#let title-slide(content) = {
set page(header: none, footer: none)
set align(horizon)
content
pagebreak(weak: true)
}
#let slides(
content,
title: none,
subtitle: none,
date: none,
authors: (),
layout: "medium",
ratio: 4 / 3,
dark: false,
) = {
// Parsing
if layout not in layouts {
panic("Unknown layout " + layout)
}
let (height, space) = layouts.at(layout)
let width = ratio * height
// Colors
let title-color = blue.darken(40%)
let emph-color = blue.darken(20%)
// Dark mode
if dark {
title-color = title-color.lighten(40%)
emph-color = emph-color.lighten(40%)
}
// Common template
show: template.with(dark: dark)
// Setup
set document(author: authors)
set document(title: title) if title != none
set page(
width: width,
height: height,
margin: (x: 0.5 * space, top: space, bottom: 0.5 * space),
header: context {
let page = here().page()
let headings = query(selector(heading.where(level: 2)))
let heading = headings.rev().find(x => x.location().page() <= page)
if heading != none {
set align(bottom)
set text(1.4em, weight: "bold", fill: title-color, font: "Libertinus Sans")
let body = {
heading.body
if not heading.location().page() == page {
numbering(" [1]", page - heading.location().page() + 1)
}
}
context {
body
place(bottom, dy: 0.4em)[
#line(length: measure(body).width, stroke: 0.6pt + title-color)
]
}
}
},
header-ascent: 1.2em,
footer: context {
set text(0.8em)
set align(right)
counter(page).display("1 / 1", both: true)
},
footer-descent: 0.5em,
)
set outline(target: heading.where(level: 1), title: none)
set bibliography(title: none)
// Rules
show heading.where(level: 1): x => {
set page(header: none, footer: none, margin: 0pt)
set align(horizon)
set text(1.2em, weight: "bold", fill: title-color)
grid(
columns: (1fr, 3fr),
inset: 1em,
align: (right, left),
fill: (title-color, none),
[#block(height: 100%)], [#text(size: 1.2em, weight: "bold", fill: title-color, font: "Libertinus Sans")[#x]],
)
}
show heading.where(level: 2): pagebreak(weak: true)
show heading: set text(1.1em, fill: title-color)
// Style headings
set heading(
numbering: numbly.numbly(
sym.section + "{1} ",
none,
sym.square + "",
default: (.., last) => str(last) + ".",
),
)
// Style lists
set list(
marker: (
text(fill: title-color)[•],
text(fill: title-color)[‣],
text(fill: title-color)[-],
),
)
set enum(numbering: nums => text(fill: title-color)[*#nums.*])
// Colored emph
show emph: set text(fill: emph-color) if emph-color != none
// Make links underlined
show link: underline
// Title page
if title != none {
if (type(authors) != array) {
authors = (authors,)
}
title-slide[
#text(2em, weight: "bold", fill: title-color, font: "Libertinus Sans", title)
#v(1.4em, weak: true)
#if subtitle != none {
text(1.1em, weight: "bold", subtitle)
}
#if subtitle != none and date != none {
text(1.1em)[ --- ]
}
#if date != none {
text(1.1em, date)
}
#v(1em, weak: true)
#authors.join(", ", last: " and ")
]
}
// Content
content
}
#let definition = thmbox(
"definition",
"Definition",
fill: rgb("#e8f8e8"),
inset: 0.8em,
padding: (),
base_level: 0,
)
#let theorem = thmbox(
"theorem",
"Theorem",
fill: rgb("e8e8f8"),
inset: 0.8em,
padding: (),
base_level: 0,
)
#let corollary = thmbox(
"corollary",
"Corollary",
base: "theorem",
fill: rgb("f8e8e8"),
inset: 0.8em,
padding: (),
)
#let proof = thmproof(
"proof",
"Proof",
inset: (x: 0em, y: 0em),
titlefmt: it => strong(it),
)
#let example = thmplain(
"example",
"Example",
inset: (x: 0em, y: 0em),
titlefmt: it => strong(it),
).with(numbering: none)
#let examples = example.with(title: "Examples")
#let note = thmplain(
"note",
"Note",
inset: (x: 0em, y: 0em),
titlefmt: it => strong(it),
).with(numbering: none)
#let exercise = thmplain(
"exercise",
"Exercise",
inset: (x: 0em, y: 0em),
titlefmt: it => strong(it),
).with(numbering: none)