-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.typ
More file actions
347 lines (301 loc) · 8.39 KB
/
lib.typ
File metadata and controls
347 lines (301 loc) · 8.39 KB
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
/// This function gets your whole document as its `body` and format it as an
/// article in the style of the IEEE with the first page needed by a ENSIMAG
/// internship report
///
/// -> content
#let ensimag(
/// Logos shown in the header of the first page
/// -> dict
logos: (
/// The logo of the company
/// -> content | none
company: none,
/// The logo of the ENSIMAG
///
/// Due to copyright restrictions, the logo cannot be included within the
/// package.
///
/// -> content | none
ensimag: none,
),
/// The document title
/// -> content | none
title: none,
/// The author's informations
/// -> dict
author: (
/// The author's name
/// -> str | array
name: "",
/// The author's school year
/// -> content | none
year: none,
/// The author's option
/// -> content | none
option: none,
),
/// The period of the internship
/// -> dict
period: (
/// The begin date
/// -> datetime
begin: none,
/// The end date
/// -> datetime
end: none,
),
/// Date format string
///
/// Please see the #link(https://typst.app/docs/reference/foundations/datetime/#format)[format syntax].
///
/// -> auto | str
date_fmt: auto,
/// The informations about the company
/// -> dict
company: (
/// The name of the company
/// -> content | none
name: none,
/// The address of the company
/// -> content | none
address: none,
),
/// The internship tutor
/// -> content | none
internship_tutor: none,
/// The school tutor
/// -> content | none
school_tutor: none,
/// The paper's abstract
///
/// It can be omitted if you don't have one.
///
/// -> content | none
abstract: none,
/// A list of index terms to display after the abstract
/// -> array
index-terms: (),
/// The article's paper size
///
/// It also affects the margins.
///
/// -> str
paper-size: "a4",
/// The result of a call to the `bibliography` function or `none`
/// -> content | none
bibliography: none,
/// How figures are referred to from within the text
///
/// Use "Figure" instead of "Fig." for computer-related publications.
///
/// -> content | none
figure-supplement: [Fig.],
/// The paper's content
/// -> content | none
body,
) = {
// Set document metadata.
set document(title: title, author: author.name)
// Set the body font.
// As of 2024-08, the IEEE LaTeX template uses wider interword spacing
// - See e.g. the definition \def\@IEEEinterspaceratioM{0.35} in IEEEtran.cls
set text(font: "TeX Gyre Termes", size: 10pt, spacing: .35em)
// Enums numbering
set enum(numbering: "1)a)i)")
// Tables & figures
show figure: set block(spacing: 15.5pt)
show figure: set place(clearance: 15.5pt)
show figure.where(kind: table): set figure.caption(position: top, separator: [\ ])
show figure.where(kind: table): set text(size: 8pt)
show figure.where(kind: table): set figure(numbering: "I")
show figure.where(kind: image): set figure(supplement: figure-supplement, numbering: "1")
show figure.caption: set text(size: 8pt)
show figure.caption: set align(start)
show figure.caption.where(kind: table): set align(center)
// Adapt supplement in caption independently from supplement used for
// references.
set figure.caption(separator: [. ])
show figure: fig => {
let prefix = (
if fig.kind == table [TABLE]
else if fig.kind == image [Fig.]
else [#fig.supplement]
)
let numbers = numbering(fig.numbering, ..fig.counter.at(fig.location()))
// Wrap figure captions in block to prevent the creation of paragraphs. In
// particular, this means `par.first-line-indent` does not apply.
// See https://github.com/typst/templates/pull/73#discussion_r2112947947.
show figure.caption: it => block[#prefix~#numbers#it.separator#it.body]
show figure.caption.where(kind: table): smallcaps
fig
}
// Code blocks
show raw: set text(
font: "TeX Gyre Cursor",
ligatures: false,
size: 1em / 0.8,
spacing: 100%,
)
// Configure the page and multi-column properties.
set columns(gutter: 12pt)
set page(
columns: 2,
paper: paper-size,
// The margins depend on the paper size.
margin: if paper-size == "a4" {
(x: 41.5pt, top: 80.51pt, bottom: 89.51pt)
} else {
(
x: (50pt / 216mm) * 100%,
top: (55pt / 279mm) * 100%,
bottom: (64pt / 279mm) * 100%,
)
}
)
// Configure equation numbering and spacing.
set math.equation(numbering: "(1)")
show math.equation: set block(spacing: 0.65em)
// Configure appearance of equation references
show ref: it => {
if it.element != none and it.element.func() == math.equation {
// Override equation references.
link(it.element.location(), numbering(
it.element.numbering,
..counter(math.equation).at(it.element.location())
))
} else {
// Other references as usual.
it
}
}
// Configure lists.
set enum(indent: 10pt, body-indent: 9pt)
set list(indent: 10pt, body-indent: 9pt)
// Configure headings.
set heading(numbering: "I.A.a)")
show heading: it => {
// Find out the final number of the heading counter.
let levels = counter(heading).get()
let deepest = if levels != () {
levels.last()
} else {
1
}
set text(10pt, weight: 400)
if it.level == 1 {
// First-level headings are centered smallcaps. We don't want to number
// the acknowledgment section.
let is-ack = it.body == [Remerciements]
set align(center)
set text(if is-ack { 10pt } else { 11pt })
show: block.with(above: 15pt, below: 13.75pt, sticky: true)
show: smallcaps
if it.numbering != none and not is-ack {
numbering("I.", deepest)
h(7pt, weak: true)
}
it.body
} else if it.level == 2 {
// Second-level headings are run-ins.
set text(style: "italic")
show: block.with(spacing: 10pt, sticky: true)
if it.numbering != none {
numbering("A.", deepest)
h(7pt, weak: true)
}
it.body
} else [
// Third level headings are run-ins too, but different.
#if it.level == 3 {
numbering("a)", deepest)
[ ]
}
_#(it.body):_
]
}
// Style bibliography.
show std.bibliography: set text(8pt)
show std.bibliography: set block(spacing: 0.5em)
set std.bibliography(title: text(10pt)[Réferences], style: "ieee")
// Display the paper's first page, spanning all columns (hence floating at
// the scope of the columns' parent, which is the page).
let first = grid(
columns: (50%, 50%),
rows: (5%, 90%, 5%),
align: (left, right),
logos.company,
logos.ensimag,
grid.cell(
align: center,
colspan: 2,
{
let top_title = text(14pt)[
Grenoble INP --- ENSIMAG \
École Nationale Supérieure d'Informatique et de Mathématiques Appliquées
]
let main_title = text(22pt)[Rapport de Stage Assistant Ingénieur]
let subtitle = text(14pt)[Effectué chez #company.name]
let big_title = rect(
inset: 8pt,
stroke: 2pt,
width: 100%,
text(20pt, title),
)
let extra = text(12pt)[
#author.name \
#author.year --- #author.option
]
let date = text(12pt)[
#period.begin.display(date_fmt)
---
#period.end.display(date_fmt)
]
top_title
v(3fr)
main_title
v(1fr)
subtitle
v(2fr)
big_title
v(2fr)
extra
v(10pt)
date
v(2fr)
}
),
[
#strong(company.name) \
#company.address
],
[
*Responsable de stage* \
#internship_tutor
*Tuteur de l'école* \
#school_tutor
],
)
place(
top,
float: true,
scope: "parent",
clearance: 30pt,
first
)
set par(justify: true, first-line-indent: (amount: 1em, all: true), spacing: 0.5em, leading: 0.5em)
// Display abstract and index terms.
if abstract != none {
set par(spacing: 0.45em, leading: 0.45em)
set text(9pt, weight: 700, spacing: 150%)
[_Résumé_ --- #abstract]
if index-terms != () {
parbreak()
[_Mots-clefs_ --- #index-terms.join[, ]]
}
v(2pt)
}
// Display the paper's contents.
body
// Display bibliography.
bibliography
}