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
|
#import "@preview/tablex:0.0.7": tablex, cellx
#import "/template.typ": *
#apply(page-numbering: "(i)" , [
#align(center, [== Contents])
#let heading-format(content) = cellx(align: center + horizon, content)
#let column-alignments = (right, auto, center + horizon, center + horizon, auto)
#let preprocess-alist(assignment-list, last-page-number) = {
let index = 0
let last-index = assignment-list.len() - 1
let page-number-list = ()
while index < last-index {
let item = assignment-list.at(index)
let next-item = assignment-list.at(index + 1)
let starting-page-number = item.page-number
let finishing-page-number = next-item.page-number - 1
page-number-list.push((starting-page-number, finishing-page-number))
index = index + 1
}
page-number-list.push((assignment-list.at(last-index).page-number, last-page-number))
let new-assignment-list = ()
index = 0
for (start, end) in page-number-list {
let page-number = if start == end [#start] else [#start - #end]
let assignment = assignment-list.at(index)
let item = ([#{assignment.number}. ], assignment.description, page-number, assignment.date, [])
new-assignment-list.push(item)
index = index + 1
}
new-assignment-list
}
#list-of-assignments((assignment-list, last-page-number) =>
tablex(
columns: (3em, 1fr, 4em, 6em, 11em),
stroke: 1pt + gray,
map-cols: (i, cells) => (cells.first(), ..cells.slice(1).map(cell => (..cell, align: column-alignments.at(i)))),
heading-format[*Sl.* \ *No.*], heading-format[*Description*], heading-format[*Page No.*], heading-format[*Date*], heading-format[*Teacher’s* \ *Signature*],
..preprocess-alist(assignment-list, last-page-number).flatten(),
))
])
#colbreak()
#counter(page).update(0)
|