-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.typ
249 lines (221 loc) · 6.51 KB
/
lib.typ
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
#let script-size = 15pt
#let normal-size = 20pt
#let large-size = 30pt
#let very-large-size = 38pt
#let huge-size = 58pt
#let logo-light-image = state("logo-light-image", none)
#let section-page = state("section-page", false)
#let main-color-state = state("main-color-state", none)
#let set-main-color(main-color) = {
main-color-state.update(x =>
main-color
)
}
#let columns-content(..args) = {
let slide-info = args.named()
let bodies = args.pos()
let colwidths = none
let thisgutter = 1cm
if "colwidths" in slide-info{
colwidths = slide-info.colwidths
if colwidths.len() != bodies.len(){
panic("Provided colwidths must be of same length as bodies")
}
}
else{
colwidths = (1fr,) * bodies.len()
}
if "gutter" in slide-info{
thisgutter = slide-info.gutter
}
grid(
columns: colwidths,
gutter: thisgutter,
..bodies
)
}
#let project(
title: [Title],
sub-title: [sub-title],
author: none,
date: none,
aspect-ratio: "16-9",
main-color: rgb("#E30512"),
text-color-light: white,
text-color-dark: black,
cover: none,
logo: none,
logo-light: none,
index-title: none,
body
) = {
set document(title: title, author: author)
main-color-state.update(x =>
main-color
)
set text(fill: text-color-dark, size: normal-size, lang: "it")
set underline(offset: 3pt)
set page(
paper: "presentation-" + aspect-ratio,
margin: 0pt,
)
set list(tight:true, indent: 0.27cm ,body-indent: 0.7cm, marker: (context{place(center, dy: -0.25em, text(size: 1.5em, fill: main-color-state.at(here()), "▶"))}, context{place(center, dy: -0.2em, text(size: 1.3em, fill: main-color-state.at(here()), "■"))}))
set enum(numbering: (..args) => context{text(fill:main-color-state.at(here()), numbering("1.", ..args))})
set figure(gap: 20pt)
show figure.caption: set text(script-size)
show raw: set text(size: script-size)
let page-number-int() = {
let lastpage-number = context{counter(page).final(here()).at(0)}
set align(right)
text(size: script-size)[
#counter(page).display("1 / 1", both: true)
]
}
let page-number() = {
place(bottom + right)[
#pad(bottom: 0.5cm, right: 0.5cm)[
#let lastpage-number = context{counter(page).final(here()).at(0)}
#set align(right)
#text(size: script-size)[
#counter(page).display("1 / 1", both: true)
]
]
]
}
let slide-polygon() = {
place(top+left, context{polygon(
fill: main-color-state.at(here()),
(0cm, 0cm),
(0cm, 3cm),
(0.4cm, 3cm),
(0.4cm, 0cm),
)})
}
let slide-logo(theLogo) = {
if theLogo!= none {
place(top + right, dx: -0.5cm, dy: 0.5cm)[
#set image(width: 2.5cm)
#theLogo
]
}
}
// Display the title page.
page(margin: 0pt)[
#set text(fill: text-color-light)
#if (cover != none){
place()[
#set image(width: 100%, height: 100%)
#cover
]
}
#logo-light-image.update(x =>
logo-light
)
#place(block(fill: rgb("000000C2"), width: 100%, height: 100% + 1pt))
#place(
polygon(
fill: main-color,
(100%, 0%),
(55%, 0%),
(80%, 100%),
(100%, 100%),
))
#slide-logo(logo-light)
#pad(left: 1.5cm, right: 10cm, y: 1.5cm)[
#v(1fr)
#block(width: 15cm)[ #par(leading: 1cm)[
#text(size: 62pt, weight: "regular", upper(title))
]]
#v(0.5cm)
#text(size: 30pt, weight: "regular", sub-title)
#v(1fr)
#if author != none {
text(size: normal-size)[#author]
} --
#if date != none {
text(size: normal-size)[#date]
}
]
]
set page(
background: context{
if section-page.at(here()) {
rect(width: 100%, height: 100%, fill: main-color-state.at(here()))
place(top,
polygon(
fill: white,
(90%, 20%),
(90% - 1.2cm, 20%),
(90% - 1.2cm, 90%),
(90% - 1.2cm, 20%),
(90% - 1.2cm, 90% - 1.2cm),
(90% - 9cm, 90% - 1.2cm),
(90% - 9cm, 90%),
(90%, 90%),
(90%, 20%)
))
context{
let logo-light = logo-light-image.at(here())
place(top + right, dx: -0.5cm, dy: 0.5cm)[
#set image(width: 2.5cm)
#logo-light
]
}
place(bottom + right)[
#pad(bottom: 0.5cm, right: 0.5cm)[
#let lastpage-number = context{counter(page).final(here()).at(0)}
#set align(right)
#text(fill: white, size: script-size)[
#counter(page).display("1 / 1", both: true)
]
]
]
}
else{
[
#slide-logo(logo)
#slide-polygon()
#page-number()
]
}
},
margin: (top:4cm, bottom: 1cm, left: 1.5cm, right: 1.5cm)
)
set align(horizon)
// Display the summary page.
place(top + left, dy: -4cm, block(height: 3cm, width: if logo!= none {100% - 2.5cm} else {100%}, align(horizon, text(size: very-large-size, weight: "regular", index-title))))
context{
let elems = query(selector(heading.where(level: 1)).after(here()))
enum(tight: false, ..elems.map(elem => {link((page: elem.location().page() + 1, x: 0pt, y: 0pt),elem.body)}))
}
show link: it => [
#set text(fill: main-color)
#underline(it)
]
show heading.where(level: 1): it => [
#section-page.update(x =>
true
)
#pagebreak(weak: true)
#set text(huge-size, fill: white, weight: "bold")
#move(dy: -1.5cm, place(horizon, pad(right:5cm, upper(it.body))))
]
show heading.where(level: 2): it => {
section-page.update(x =>
false
)
pagebreak()
set text(very-large-size, weight: "regular")
place(top + left, dy: -4cm, block(height: 3cm, width: if logo!= none {100% - 2.5cm} else {100%}, align(horizon, it.body)))
}
show heading.where(level: 3): it => {
pagebreak()
context{
let elems = query(selector(heading.where(level: 2)).before(here()))
let heading2 = elems.last().body
place(top + left, dy: -4cm, block(height: 3cm, width: if logo!= none {100% - 2.5cm} else {100%}, align(horizon, [#block(below: 0em, above: 0em, text(heading2, size: very-large-size, weight: "regular")) #block(below: 0em, above: 0.65em, text(it.body, size: normal-size, weight: "regular"))])))
}
}
// Add the body.
body
}