forked from mintyfrankie/brilliant-CV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cv.typ
521 lines (495 loc) · 13.1 KB
/
cv.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
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
/*
* Functions for the CV template
*/
#import "@preview/fontawesome:0.2.1": *
#import "./utils/injection.typ": inject
#import "./utils/styles.typ": latinFontList, latinHeaderFont, awesomeColors, regularColors, setAccentColor, hBar
#import "./utils/lang.typ": isNonLatin
/// Insert the header section of the CV.
///
/// - metadata (array): the metadata read from the TOML file.
/// - headerFont (array): the font of the header.
/// - regularColors (array): the regular colors of the CV.
/// - awesomeColors (array): the awesome colors of the CV.
/// -> content
#let _cvHeader(
metadata,
profilePhoto,
headerFont,
regularColors,
awesomeColors,
) = {
// Parameters
let hasPhoto = metadata.layout.header.display_profile_photo
let align = eval(metadata.layout.header.header_align)
let if_inject_ai_prompt = metadata.inject.inject_ai_prompt
let if_inject_keywords = metadata.inject.inject_keywords
let keywords_list = metadata.inject.injected_keywords_list
let personalInfo = metadata.personal.info
let firstName = metadata.personal.first_name
let lastName = metadata.personal.last_name
let headerQuote = metadata.lang.at(metadata.language).header_quote
let displayProfilePhoto = metadata.layout.header.display_profile_photo
// let profilePhoto = metadata.layout.header.profile_photo_path
let accentColor = setAccentColor(awesomeColors, metadata)
let nonLatinName = ""
let nonLatin = isNonLatin(metadata.language)
if nonLatin {
nonLatinName = metadata.lang.non_latin.name
}
// Injection
inject(
if_inject_ai_prompt: if_inject_ai_prompt,
if_inject_keywords: if_inject_keywords,
keywords_list: keywords_list,
)
// Styles
let headerFirstNameStyle(str) = {
text(
font: headerFont,
size: 32pt,
weight: "light",
fill: regularColors.darkgray,
str,
)
}
let headerLastNameStyle(str) = {
text(font: headerFont, size: 32pt, weight: "bold", str)
}
let headerInfoStyle(str) = {
text(size: 10pt, fill: accentColor, str)
}
let headerQuoteStyle(str) = {
text(size: 10pt, weight: "medium", style: "italic", fill: accentColor, str)
}
// Components
let makeHeaderInfo() = {
let personalInfoIcons = (
phone: fa-phone(),
email: fa-envelope(),
linkedin: fa-linkedin(),
homepage: fa-pager(),
github: fa-square-github(),
gitlab: fa-gitlab(),
orcid: fa-orcid(),
researchgate: fa-researchgate(),
location: fa-location-dot(),
extraInfo: "",
)
let n = 1
for (k, v) in personalInfo {
// A dirty trick to add linebreaks with "linebreak" as key in personalInfo
if k == "linebreak" {
n = 0
linebreak()
continue
}
if k.contains("custom") {
let img = v.at("image", default: "")
let awesomeIcon = v.at("awesomeIcon", default: "")
let text = v.at("text", default: "")
let link_value = v.at("link", default: "")
let icon = ""
if img != "" {
icon = img.with(width: 10pt)
} else {
icon = fa-icon(awesomeIcon)
}
box({
icon
h(5pt)
link(link_value)[#text]
})
} else if v != "" {
box({
// Adds icons
personalInfoIcons.at(k)
h(5pt)
// Adds hyperlinks
if k == "email" {
link("mailto:" + v)[#v]
} else if k == "linkedin" {
link("https://www.linkedin.com/in/" + v)[#v]
} else if k == "github" {
link("https://github.com/" + v)[#v]
} else if k == "gitlab" {
link("https://gitlab.com/" + v)[#v]
} else if k == "homepage" {
link("https://" + v)[#v]
} else if k == "orcid" {
link("https://orcid.org/" + v)[#v]
} else if k == "researchgate" {
link("https://www.researchgate.net/profile/" + v)[#v]
} else {
v
}
})
}
// Adds hBar
if n != personalInfo.len() {
hBar()
}
n = n + 1
}
}
let makeHeaderNameSection() = table(
columns: 1fr,
inset: 0pt,
stroke: none,
row-gutter: 6mm,
if nonLatin {
headerFirstNameStyle(nonLatinName)
} else [#headerFirstNameStyle(firstName) #h(5pt) #headerLastNameStyle(lastName)],
[#headerInfoStyle(makeHeaderInfo())],
[#headerQuoteStyle(headerQuote)],
)
let makeHeaderPhotoSection() = {
set image(height: 3.6cm)
if displayProfilePhoto {
box(profilePhoto, radius: 50%, clip: true)
} else {
v(3.6cm)
}
}
let makeHeader(leftComp, rightComp, columns, align) = table(
columns: columns,
inset: 0pt,
stroke: none,
column-gutter: 15pt,
align: align + horizon,
{
leftComp
},
{
rightComp
},
)
if hasPhoto {
makeHeader(
makeHeaderNameSection(),
makeHeaderPhotoSection(),
(auto, 20%),
align,
)
} else {
makeHeader(
makeHeaderNameSection(),
makeHeaderPhotoSection(),
(auto, 0%),
align,
)
}
}
/// Insert the footer section of the CV.
///
/// - metadata (array): the metadata read from the TOML file.
/// -> content
#let _cvFooter(metadata) = {
// Parameters
let firstName = metadata.personal.first_name
let lastName = metadata.personal.last_name
let footerText = metadata.lang.at(metadata.language).cv_footer
// Styles
let footerStyle(str) = {
text(size: 8pt, fill: rgb("#999999"), smallcaps(str))
}
return table(
columns: (1fr, auto),
inset: -5pt,
stroke: none,
footerStyle([#firstName #lastName]), footerStyle(footerText),
)
}
/// Add the title of a section.
///
/// NOTE: If the language is non-Latin, the title highlight will not be sliced.
///
/// - title (str): The title of the section.
/// - highlighted (bool): Whether the first n letters will be highlighted in accent color.
/// - letters (int): The number of first letters of the title to highlight.
/// - metadata (array): (optional) the metadata read from the TOML file.
/// - awesomeColors (array): (optional) the awesome colors of the CV.
/// -> content
#let cvSection(
title,
highlighted: true,
letters: 3,
metadata: metadata,
awesomeColors: awesomeColors,
) = {
let lang = metadata.language
let nonLatin = isNonLatin(lang)
let beforeSectionSkip = eval(
metadata.layout.at("before_section_skip", default: 1pt),
)
let accentColor = setAccentColor(awesomeColors, metadata)
let highlightText = title.slice(0, letters)
let normalText = title.slice(letters)
let sectionTitleStyle(str, color: black) = {
text(size: 16pt, weight: "bold", fill: color, str)
}
v(beforeSectionSkip)
if nonLatin {
sectionTitleStyle(title, color: accentColor)
} else {
if highlighted {
sectionTitleStyle(highlightText, color: accentColor)
sectionTitleStyle(normalText, color: black)
} else {
sectionTitleStyle(title, color: black)
}
}
h(2pt)
box(width: 1fr, line(stroke: 0.9pt, length: 100%))
}
/// Add an entry to the CV.
///
/// - title (str): The title of the entry.
/// - society (str): The society of the entr (company, university, etc.).
/// - date (str): The date of the entry.
/// - location (str): The location of the entry.
/// - description (array): The description of the entry. It can be a string or an array of strings.
/// - logo (image): The logo of the society. If empty, no logo will be displayed.
/// - tags (array): The tags of the entry.
/// - metadata (array): (optional) the metadata read from the TOML file.
/// - awesomeColors (array): (optional) the awesome colors of the CV.
/// -> content
#let cvEntry(
title: "Title",
society: "Society",
date: "Date",
location: "Location",
description: "Description",
logo: "",
tags: (),
metadata: metadata,
awesomeColors: awesomeColors,
) = {
let accentColor = setAccentColor(awesomeColors, metadata)
let beforeEntrySkip = eval(
metadata.layout.at("before_entry_skip", default: 1pt),
)
let beforeEntryDescriptionSkip = eval(
metadata.layout.at("before_entry_description_skip", default: 1pt),
)
let entryA1Style(str) = {
text(size: 10pt, weight: "bold", str)
}
let entryA2Style(str) = {
align(
right,
text(weight: "medium", fill: accentColor, style: "oblique", str),
)
}
let entryB1Style(str) = {
text(size: 8pt, fill: accentColor, weight: "medium", smallcaps(str))
}
let entryB2Style(str) = {
align(
right,
text(size: 8pt, weight: "medium", fill: gray, style: "oblique", str),
)
}
let entryDescriptionStyle(str) = {
text(
fill: regularColors.lightgray,
{
v(beforeEntryDescriptionSkip)
str
},
)
}
let entryTagStyle(str) = {
align(center, text(size: 8pt, weight: "regular", str))
}
let entryTagListStyle(tags) = {
for tag in tags {
box(
inset: (x: 0.25em),
outset: (y: 0.25em),
fill: regularColors.subtlegray,
radius: 3pt,
entryTagStyle(tag),
)
h(5pt)
}
}
let ifSocietyFirst(condition, field1, field2) = {
return if condition {
field1
} else {
field2
}
}
let ifLogo(path, ifTrue, ifFalse) = {
return if metadata.layout.entry.display_logo {
if path == "" {
ifFalse
} else {
ifTrue
}
} else {
ifFalse
}
}
let setLogoLength(path) = {
return if path == "" {
0%
} else {
4%
}
}
let setLogoContent(path) = {
return if logo == "" [] else {
set image(width: 100%)
logo
}
}
v(beforeEntrySkip)
table(
columns: (ifLogo(logo, 4%, 0%), 1fr),
inset: 0pt,
stroke: none,
align: horizon,
column-gutter: ifLogo(logo, 4pt, 0pt),
setLogoContent(logo),
table(
columns: (1fr, auto),
inset: 0pt,
stroke: none,
row-gutter: 6pt,
align: auto,
{
entryA1Style(
ifSocietyFirst(
metadata.layout.entry.display_entry_society_first,
society,
title,
),
)
},
{
entryA2Style(
ifSocietyFirst(
metadata.layout.entry.display_entry_society_first,
location,
date,
),
)
},
{
entryB1Style(
ifSocietyFirst(
metadata.layout.entry.display_entry_society_first,
title,
society,
),
)
},
{
entryB2Style(
ifSocietyFirst(
metadata.layout.entry.display_entry_society_first,
date,
location,
),
)
},
),
)
entryDescriptionStyle(description)
entryTagListStyle(tags)
}
/// Add a skill to the CV.
///
/// - type (str): The type of the skill. It is displayed on the left side.
/// - info (str | content): The information about the skill. It is displayed on the right side. Items can be seperated by `#hbar()`.
/// -> content
#let cvSkill(type: "Type", info: "Info") = {
let skillTypeStyle(str) = {
align(right, text(size: 10pt, weight: "bold", str))
}
let skillInfoStyle(str) = {
text(str)
}
table(
columns: (16%, 1fr),
inset: 0pt,
column-gutter: 10pt,
stroke: none,
skillTypeStyle(type), skillInfoStyle(info),
)
v(-6pt)
}
/// Add a Honor to the CV.
///
/// - date (str): The date of the honor.
/// - title (str): The title of the honor.
/// - issuer (str): The issuer of the honor.
/// - url (str): The URL of the honor.
/// - location (str): The location of the honor.
/// - awesomeColors (array): (optional) The awesome colors of the CV.
/// - metadata (array): (optional) The metadata read from the TOML file.
/// -> content
#let cvHonor(
date: "1990",
title: "Title",
issuer: "",
url: "",
location: "",
awesomeColors: awesomeColors,
metadata: metadata,
) = {
let accentColor = setAccentColor(awesomeColors, metadata)
let honorDateStyle(str) = {
align(right, text(str))
}
let honorTitleStyle(str) = {
text(weight: "bold", str)
}
let honorIssuerStyle(str) = {
text(str)
}
let honorLocationStyle(str) = {
align(
right,
text(weight: "medium", fill: accentColor, style: "oblique", str),
)
}
table(
columns: (16%, 1fr, 15%),
inset: 0pt,
column-gutter: 10pt,
align: horizon,
stroke: none,
honorDateStyle(date),
if issuer == "" {
honorTitleStyle(title)
} else if url != "" {
[
#honorTitleStyle(link(url)[#title]), #honorIssuerStyle(issuer)
]
} else {
[
#honorTitleStyle(title), #honorIssuerStyle(issuer)
]
},
honorLocationStyle(location),
)
v(-6pt)
}
/// Add the publications to the CV by reading a bib file.
///
/// - bib (bibliography): The `bibliography` object with the path to the bib file.
/// - keyList (list): The list of keys to include in the publication list.
/// - refStyle (str): The reference style of the publication list.
/// - refFull (bool): Whether to show the full reference or not.
/// -> content
#let cvPublication(bib: "", keyList: list(), refStyle: "apa", refFull: true) = {
let publicationStyle(str) = {
text(str)
}
show bibliography: it => publicationStyle(it)
set bibliography(title: none, style: refStyle, full: refFull)
bib
}