File size: 4,114 Bytes
9286790
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#let ink = rgb("#26323a")
#let teal = rgb("#0f766e")
#let orange = rgb("#c2410c")
#let blue = rgb("#1d4ed8")
#let quiet = rgb("#66757f")
#let sans = ("Segoe UI", "Helvetica Neue", "Arial", "Libertinus Serif")
#let today = datetime.today().display("[day padding:none] [month repr:long] [year]")

#let question-number = counter("classroom-question")
#let points-total = state("classroom-points", 0)

#let base(body) = {
  set text(font: sans, size: 11pt, fill: ink, lang: "en")
  set par(leading: 0.7em, spacing: 1.2em)
  show heading: set text(fill: teal)
  show heading: set block(above: 1.5em, below: 0.8em)
  body
}

#let sheet(course, title, body) = {
  show: base
  set page(
    paper: "a4",
    margin: (x: 2.3cm, top: 2.8cm, bottom: 2.3cm),
    header: text(size: 9pt, fill: quiet)[#course #h(1fr) #title],
    footer: context align(center, text(size: 9pt, fill: quiet, counter(page).display())),
  )
  body
}

#let callout(colour, label, title, body) = block(
  width: 100%,
  inset: (left: 12pt, rest: 8pt),
  stroke: (left: 3pt + colour),
  fill: colour.lighten(92%),
  [#text(weight: "bold", fill: colour)[#label#if title != none [: #title]] \ #body],
)

#let definition(title: none, body) = callout(teal, "Definition", title, body)
#let example(title: none, body) = callout(blue, "Example", title, body)
#let remark(title: none, body) = callout(orange, "Note", title, body)

#let question(points: none, body) = {
  question-number.step()
  if points != none { points-total.update(total => total + points) }
  block(width: 100%, above: 1.6em, below: 0.8em)[
    #text(weight: "bold", fill: teal, context question-number.display("1."))
    #body
    #if points != none { h(1fr); text(size: 9pt, fill: quiet)[(#points #if points == 1 [point] else [points])] }
  ]
}

#let answer-lines(count) = for _ in range(count) {
  v(1.9em)
  line(length: 100%, stroke: 0.4pt + quiet)
}

#let notes(title: "Title", course: none, lecturer: none, date: today, body) = {
  show: sheet.with(course, title)
  set par(justify: true)
  set heading(numbering: "1.1")
  block(below: 2em)[
    #text(size: 22pt, weight: "bold", fill: teal, title) \
    #text(size: 10pt, fill: quiet, (course, lecturer, date).filter(part => part != none).join[ · ])
  ]
  body
}

#let worksheet(title: "Title", course: none, body) = {
  show: sheet.with(course, title)
  text(size: 20pt, weight: "bold", fill: teal, title)
  block(above: 1.2em, below: 1.8em, grid(
    columns: (auto, 2fr, auto, 1fr),
    gutter: 0.6em,
    align: bottom,
    [Name:], line(length: 100%, stroke: 0.4pt + quiet), [Date:], line(length: 100%, stroke: 0.4pt + quiet),
  ))
  body
}

#let exam(title: "Title", course: none, duration: none, date: today, body) = {
  show: sheet.with(course, title)
  align(center)[
    #text(size: 22pt, weight: "bold", fill: teal, title) \
    #text(fill: quiet, (course, date).filter(part => part != none).join[ · ])
  ]
  block(width: 100%, above: 1.5em, below: 2em, inset: 10pt, stroke: 0.6pt + teal, grid(
    columns: (auto, 1fr, auto, auto),
    gutter: 0.7em,
    align: bottom,
    [Name:], line(length: 100%, stroke: 0.4pt + quiet),
    [#if duration != none [Time: #duration]],
    context [Points: #box(width: 2.5em, line(length: 100%, stroke: 0.4pt + quiet)) / #points-total.final()],
  ))
  body
}

#let slides(title: "Title", course: none, lecturer: none, date: today, body) = {
  show: base
  set text(size: 20pt)
  set page(
    paper: "presentation-16-9",
    margin: (x: 2cm, top: 2cm, bottom: 1.8cm),
    footer: context text(size: 11pt, fill: quiet)[#course #h(1fr) #counter(page).display()],
  )
  show heading.where(level: 1): it => {
    pagebreak(weak: true)
    block(below: 1em, stroke: (bottom: 2pt + orange), inset: (bottom: 8pt), text(size: 30pt, weight: "bold", fill: teal, it.body))
  }
  show heading.where(level: 2): set text(size: 22pt)
  page(footer: none, align(horizon)[
    #rect(width: 4cm, height: 6pt, fill: orange)
    #text(size: 40pt, weight: "bold", fill: teal, title)

    #text(size: 16pt, fill: quiet, (course, lecturer, date).filter(part => part != none).join[ · ])
  ])
  body
}