-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.typ
223 lines (205 loc) · 5.5 KB
/
template.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
#import "@preview/chic-hdr:0.4.0": *
#import "@preview/physica:0.9.3": *
#let buildMainHeader(mainHeadingContent) = {
[
#align(center, smallcaps(mainHeadingContent))
#line(length: 100%)
]
}
#let buildSecondaryHeader(mainHeadingContent, secondaryHeadingContent) = {
[
#smallcaps(mainHeadingContent) #h(1fr) #emph(secondaryHeadingContent)
#line(length: 100%)
]
}
#let isAfter(secondaryHeading, mainHeading) = {
let secHeadPos = secondaryHeading.location().position()
let mainHeadPos = mainHeading.location().position()
if (secHeadPos.at("page") > mainHeadPos.at("page")) {
return true
}
if (secHeadPos.at("page") == mainHeadPos.at("page")) {
return secHeadPos.at("y") > mainHeadPos.at("y")
}
return false
}
#let getHeader() = {
locate(loc => {
// Find if there is a level 1 heading on the current page
let nextMainHeading = query(selector(heading).after(loc), loc).find(headIt => {
headIt.location().page() == loc.page() and headIt.level == 1
})
if (nextMainHeading != none) {
return buildMainHeader(nextMainHeading.body)
}
// Find the last previous level 1 heading -- at this point surely there's one :-)
let lastMainHeading = query(selector(heading).before(loc), loc).filter(headIt => {
headIt.level == 1
}).last()
// Find if the last level > 1 heading in previous pages
let previousSecondaryHeadingArray = query(selector(heading).before(loc), loc).filter(headIt => {
headIt.level > 1
})
let lastSecondaryHeading = if (previousSecondaryHeadingArray.len() != 0) {previousSecondaryHeadingArray.last()} else {none}
// Find if the last secondary heading exists and if it's after the last main heading
if (lastSecondaryHeading != none and isAfter(lastSecondaryHeading, lastMainHeading)) {
return buildSecondaryHeader(lastMainHeading.body, lastSecondaryHeading.body)
}
return buildMainHeader(lastMainHeading.body)
})
}
// Project part
#let project(
title: "",
authors: (),
subtitle: "",
objective: "",
department: "" ,
institute: "",
year: "",
logo: none,
abstract: none,
subject: "",
degree: "Master of Science",
stream: "Cybersecurity",
guide: (),
body
) = {
// Set the document's basic properties.
set document(
author: authors.map(a => a.name),
title: title)
set page(
paper: "a4",
margin: (
top: 1in,
bottom: 1in,
left: 1in,
right: 1in
)
)
set text(font: "Times New Roman", lang: "en")
set par(justify: true)
// Title row.
v(.10fr)
align(center)[
#text(12pt, strong(smallcaps(subject)))
\ \ #text(30pt, weight: 900, smallcaps(title))
\ #text(14pt, weight: 200, subtitle)
]
// Degree Part
align(center)[
#text(12pt, strong(degree))
\ #text(12pt, strong("in"))
\ #text(12pt, strong(stream))
#v(1cm)
#text(12pt, strong("Submitted By,"))
]
pad(
top: 2em,
for i in range(calc.ceil(authors.len() / 3)) {
let end = calc.min((i + 1) * 3, authors.len())
let is-last = authors.len() == end
let slice = authors.slice(i * 3, end)
grid(
columns: slice.len() * (1fr,),
gutter: 12pt,
..slice.map(author => align(center, {
text(12pt, strong(author.name))
if "rollno" in author [
\ #author.rollno
]
if "regno" in author [
\ #author.regno
]
if "department" in author [
\ #author.department
]
if "email" in author [
\ #link("mailto:" + author.email)
]
}))
)
if not is-last {
v(16pt, weak: true)
}
}
)
v(1cm)
align(center)[
#text(12pt, "Under the guidance of,")
\ #text(14pt, smallcaps(strong(guide.name)))
\ #text(12pt, smallcaps(guide.designation+","))
\ #text(12pt, smallcaps(guide.department))
]
v(0.75fr)
if logo != none {
align(center)[
#image(logo, width: 26%)
\ #text(12pt, strong(smallcaps(department)))
\ #text(14pt, institute)
\ #text("Accademic Year: " + year)
]
} else {
align(center)[
#text(12pt, strong(smallcaps(department)))
\ #text(14pt, institute)
\ #text("Accademic Year: " + year)
]
}
set page(margin: (
top: 1in,
bottom: 1in,
left: 1.5in,
right: 1in
))
if abstract != none {
pagebreak()
align(right)[
#text(34pt, underline(smallcaps(strong("Abstract"))))
]
set par(justify: true)
abstract
}
pagebreak()
outline(depth: 3, indent: true)
// Formatting the headings
// General First and then specific headings
show heading: it => [
#set align(left)
#set text(14pt)
#block(smallcaps(it.body))
]
show heading.where(level: 1): it => [
#pagebreak(weak: true)
#set align(center)
#set text(30pt)
#underline(extent: 2pt)[
#block(smallcaps(it.body))
#v(0em)
]
]
show heading.where(level:2): it => [
#set text(24pt)
#block(counter(heading).display() + " " + smallcaps(it.body))
]
show heading.where(level:3): it => [
#set text(20pt)
#block(counter(heading).display() + " " + smallcaps(it.body))
]
show heading.where(level:4): it => [
#set text(16pt)
#block(smallcaps(it.body))
]
show heading.where(level:5): it => [
#set text(14pt)
#block(smallcaps(it.body))
]
// Main body.
set par(justify: true)
set heading(numbering: "1.1")
counter(page).update(1)
set page(header: getHeader())
set page(numbering: "1", number-align: center)
body
}