-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy paththeme2.typ
More file actions
378 lines (342 loc) · 8.51 KB
/
theme2.typ
File metadata and controls
378 lines (342 loc) · 8.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#import "common.typ": *
#let title-slide(content) = {
set page(header: none, footer: none)
set align(horizon)
content
pagebreak(weak: true)
}
#let current-heading(level: 1) = context {
let h = query(selector(heading.where(level: level)).before(here()))
if h.len() > 0 {
h.last().body
} else {
none
}
}
// Usage:
// #focus-slide(
// title: [Section Title],
// epigraph: [Your inspirational quote here],
// epigraph-author: [Author Name],
// scholars: ("Name 1", "Name 2", "Name 3", ...)
// )
//
// Note: `title` can be:
// - none (default): use current heading (level 1)
// - function: a function that receives the current heading
// - str: use the provided string as the title
#let focus-slide(
title: none,
epigraph: none,
epigraph-author: none,
scholars: (),
dark: false,
) = {
let title = if title == none {
current-heading()
} else if type(title) == function {
title(current-heading())
} else {
title
}
// Configuration variables
let page-margin = 1cm
let hex-stroke-width = 1pt
let hex-height = 1in
let title-font-size = 2.2em
let title-width = 90%
let title-inset = 1.2em
let title-stroke-width = 2pt
let epigraph-font-size = 1.1em
let epigraph-width = 80%
let epigraph-inset = 1em
let epigraph-author-font-size = 0.9em
let initials-font-size = 1.2em
let name-font-size = 0.8em
// Colors
let title-color = blue.darken(40%)
let accent-color = blue.darken(20%)
let text-color = accent-color
if dark {
title-color = title-color.lighten(40%)
accent-color = accent-color.lighten(40%)
text-color = accent-color
}
// heading(title)
// Set up the page for the title slide
set page(
header: none,
footer: none,
margin: page-margin,
)
set text(fill: text-color)
set align(center)
let scholar-portrait(scholar) = {
let portrait-content = if type(scholar) == str {
// Scholar is a string name - create placeholder with initials
let initials = scholar.split(" ").map(word => word.first()).join("")
align(horizon)[
#box(
height: hex-height,
inset: 1em,
radius: 20%,
fill: gradient.radial(
accent-color.lighten(70%),
accent-color.lighten(40%),
),
stroke: hex-stroke-width + accent-color,
)[
#text(
initials,
initials-font-size,
weight: "bold",
fill: text-color.darken(30%),
)
]
]
} else {
// Scholar is a dict (name, image)
let img = scholar.at("image")
box(height: hex-height, box(
img,
radius: 20%,
clip: true,
stroke: hex-stroke-width + accent-color,
))
}
let scholar-name = if type(scholar) == str {
scholar
} else {
scholar.at("name")
}
(portrait-content, scholar-name)
}
grid(
columns: 1fr,
// Note: one row for title+epigraph, one for portraits.
// - First row fills all available space.
// - Second row (optional) is auto-sized to content.
rows: (1fr, auto),
align(horizon, stack(
// Title
block(
width: title-width,
// stroke: .1pt, // debug
)[
#block(
stroke: (bottom: 1pt + title-color),
inset: 1em,
)[
#set text(
title-font-size,
weight: "bold",
font: "Libertinus Sans",
fill: title-color,
)
#title
]
],
// Epigraph
if epigraph != none {
if type(epigraph) == function {
epigraph = epigraph()
} else {
epigraph = ["#epigraph"]
}
block(
width: epigraph-width,
inset: (top: epigraph-inset),
// stroke: .1pt, // debug
)[
#set text(
epigraph-font-size,
style: "italic",
)
#epigraph
#if epigraph-author != none [
#align(right)[
#set text(
epigraph-author-font-size,
weight: "bold",
)
--- #epigraph-author
]
]
]
},
)),
// Portraits
if scholars.len() > 0 {
grid(
columns: scholars.len(),
align: (x, y) => if y == 0 { bottom } else { top },
column-gutter: .5em,
row-gutter: .5em,
// stroke: 1pt + silver,
..array
.zip(..scholars.map(scholar => {
let (hex, name) = scholar-portrait(scholar)
(
box(width: 2cm, hex),
box(width: 2cm, text(name, name-font-size)),
)
}))
.flatten()
)
}
)
pagebreak(weak: true)
}
#let slides(
content,
title: none,
subtitle: none,
date: none,
authors: (),
dark: false,
) = {
// Page dimensions
let height = 10.5cm
let width = height * 16 / 9
let space = 1.6cm
// Colors
let title-color = blue.darken(40%)
let emph-color = blue.darken(20%)
// Fonts
let title-font = "Libertinus Sans"
// 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(title: title, author: authors) if (title != none)
set page(
width: width,
height: height,
margin: (x: 0.5 * space, top: space, bottom: 0.5 * space),
header: context {
// show: body => block(width: 100%, height: 100%, stroke: 1pt + red, body)
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",
font: title-font,
fill: title-color,
)
let body = {
heading.body
if not heading.location().page() == page {
numbering(" [1]", page - heading.location().page() + 1)
}
}
block(
outset: (bottom: 0.4em, x: 0.1em),
stroke: (bottom: 0.6pt + title-color),
)[
// Note: reduce leading to fit 2-line headings better
// Note: default leading is 0.65em
#set par(leading: 0.4em)
#body
]
}
},
footer: context {
// show: body => block(width: 100%, height: 100%, stroke: 1pt + red, body)
set text(0.8em, fill: luma(50%))
set align(right)
counter(page).display("1 / 1", both: true)
},
)
set outline(target: heading.where(level: 1), title: none)
set bibliography(title: none)
// Rules
show heading.where(level: 1): it => {
// Create a simple focus page for regular level 1 headings
set page(header: none, footer: none, margin: 1cm)
// Main layout: simple centered title
align(center + horizon, block(
width: 90%,
// stroke: .1pt, // debug
)[
#block(
inset: 1em,
stroke: (bottom: 1pt + title-color),
)[
#set text(
1.6em,
weight: "bold",
font: title-font,
fill: title-color,
)
#it.body
]
])
pagebreak(weak: true)
}
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({
// Title:
{
set text(
2em,
weight: "bold",
font: title-font,
fill: title-color,
)
title
}
v(1.4em, weak: true)
// Subtitle:
if subtitle != none or date != none {
set text(1.4em, weight: "bold")
if subtitle != none {
subtitle
}
if date != none {
if subtitle != none {
[, ]
}
date
}
}
v(1em, weak: true)
// Authors:
{
authors.join(", ", last: " and ")
}
})
}
// Content
content
}