-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathutils.typ
More file actions
219 lines (194 loc) · 5.71 KB
/
Copy pathutils.typ
File metadata and controls
219 lines (194 loc) · 5.71 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
// Built-in theme color palette
// Maps theme names to their corresponding RGB color values
#let _theme-colors = (
bluey: rgb("3059AB"),
reddy: rgb("BF3D3D"),
greeny: rgb("28842F"),
yelly: rgb("C4853D"),
purply: rgb("862A70"),
dusky: rgb("1F4289"),
darky: black,
)
//************************************************************************\\
// Automatically resizes text to fit within available space
// Used primarily in focus slides to ensure content fits properly
//
// Arguments:
// body: The content to be resized
//
// Returns: A block with dynamically adjusted font size
#let _resize-text(body) = layout(size => {
let font-size = text.size
let (height,) = measure(
block(width: size.width, text(size: font-size)[#body]),
)
let max_height = size.height
while height > max_height {
font-size -= 0.2pt
height = measure(
block(width: size.width, text(size: font-size)[#body]),
).height
}
block(
height: height,
width: 100%,
text(size: font-size)[#body],
)
})
//************************************************************************\\
// Simple horizontal divider line without progress indication
// Used in the front slide to maintain a clean appearance
//
// Arguments:
// color: The color of the divider line
//
// Returns: A horizontal line element
#let _divider(color: none) = {
line(
length: 100%,
stroke: 2.5pt + color,
)
}
//************************************************************************\\
// Progress-aware horizontal divider
// Displays a two-tone bar showing presentation progress
// Left portion (solid color) represents completed slides
// Right portion (lightened color) represents remaining slides
//
// Arguments:
// color: The base color for the progress divider
//
// Returns: A horizontal stack with progress indication
#let _progress-divider(color: none) = context {
let current = counter(page).get().first()
let total = counter(page).final().first()
let progress-width = if total == 0 { 0% } else { (current / total) * 100% }
stack(
dir: ltr,
rect(
width: progress-width,
height: 2.5pt,
fill: color,
radius: 0pt,
),
rect(
width: 100% - progress-width,
height: 2.5pt,
fill: color.lighten(60%),
radius: 0pt,
),
)
}
//************************************************************************\\
// Bottom progress bar overlay for slides
// Creates a Beamer-style progress indicator at the bottom of slides
// Uses a subtle background with a solid foreground showing progress
//
// Arguments:
// color: Color for the progress indicator (default: black)
// height: Height of the progress bar (default: 3pt)
//
// Returns: Two overlaid rectangles positioned at the bottom of the slide
#let _progress-bar(color: black, height: 3pt) = context {
let current = counter(page).get().first()
let total = counter(page).final().first()
let progress-width = if total == 0 { 0% } else { (current / total) * 100% }
// Background bar
place(bottom + left, rect(
width: 100%,
height: height,
fill: rgb(200, 200, 200, 25%),
))
// Progress indicator
place(bottom + left, rect(
width: progress-width,
height: height,
fill: color,
))
}
//************************************************************************\\
// Creates a colored header box for slides
// Dynamically adjusts height based on whether a title is present
// Supports outline mode to mark subsections in the table of contents
//
// Arguments:
// title: The slide title text (optional)
// outlined: Whether this slide should appear in the outline (default: false)
// color: Background color for the header
// page-num: Page number to display in the header (optional)
//
// Returns: A colored rectangle containing the formatted title and page number
#let _slide-header(title, outlined, color, page-num: none) = {
let header-height = if title != none { 1.6cm } else { .95cm }
rect(
fill: color,
width: 100%,
height: header-height,
inset: .6cm,
if outlined {
grid(
columns: (1fr, auto),
align: (left, right),
text(white, weight: "semibold", size: 24pt)[
#h(.1cm) #title #metadata(title) <subsection>
],
if page-num != none {
text(white, weight: "semibold", size: 12pt)[#page-num]
},
)
} else if title != none {
grid(
columns: (1fr, auto),
align: (left, right),
text(white, weight: "semibold", size: 24pt)[
#h(.1cm) #title
],
if page-num != none {
text(white, weight: "semibold", size: 12pt)[#page-num]
},
)
},
)
}
//************************************************************************\\
// Generates the front page layout for presentations
// Displays title, subtitle, author information, and a divider
// Uses a simple divider (without progress) to maintain clean aesthetics
//
// Arguments:
// title: Main presentation title
// subtitle: Optional subtitle text
// authors: Author name(s)
// info: Additional information (e.g., links, dates)
// theme-color: Color for styling text and divider
//
// Returns: A formatted front page with all provided information
#let _make-frontpage(
title,
subtitle,
authors,
info,
theme-color,
margin,
) = {
set align(left + horizon)
set page(footer: none, margin: margin)
text(40pt, weight: "bold")[#smallcaps(title)]
v(-.95cm)
if subtitle != none {
set text(24pt)
v(.1cm)
subtitle
}
let subtext = ()
if authors != none {
subtext.push(text(22pt, weight: "regular")[#authors])
}
if info != none {
subtext.push(text(20pt, fill: theme-color, weight: "regular")[
#v(-.15cm) #info
])
}
_divider(color: theme-color)
subtext.join()
}