-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlib.typ
More file actions
592 lines (504 loc) · 15.5 KB
/
lib.typ
File metadata and controls
592 lines (504 loc) · 15.5 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
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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
// Workaround for the lack of an `std` scope.
#let std-bibliography = bibliography
// Minimal bullseye-compatible target switching (avoids external dependency)
#let get-target() = {
if "target" in dictionary(std) { std.target() }
else { "paged" }
}
#let match-target(..targets) = {
let targets = targets.named()
let current = get-target()
if current in targets { targets.at(current) }
else if "default" in targets { targets.default }
else { none }
}
#let show-target(..targets) = body => context {
match-target(default: it => it, ..targets)(body)
}
#let on-target(..targets) = context {
match-target(default: none, ..targets)
}
#let serif-font = ("Times New Roman", "Liberation Serif")
#let sans-serif-font = ("Helvetica", "Liberation Sans")
#let mono-font = ("Liberation Mono") // LaTeX uses txtt
#let narrow-font = ("PT Sans")
// This function gets your whole document as its `body` and formats
// it as a VGTC conference paper.
#let conference(
// The paper's title.
title: [Paper Title],
// An array of authors. For each author you can specify a name,
// department, organization, location, and email.
// Everything but the name is optional.
authors: (),
// The paper's abstract.
abstract: none,
// Teaser image path and caption
teaser: (),
// A list of index terms to display after the abstract.
index-terms: (),
// The article's paper size. Also affects the margins.
paper-size: "us-letter",
// The result of a call to the `bibliography` function or `none`.
bibliography: none,
// Whether DOIs in the bibliography should be displayed in narrow font
narrow-doi: false,
// Review mode - hides authors and shows submission info
review: false,
// Submission ID (for review mode)
submission-id: 0,
// Category (for review mode)
category: none,
// Custom manuscript note (appears in footer of first page)
manuscript-note: none,
// The paper's content.
body
) = {
// Set document metadata.
if review {
set document(title: title, author: "Anonymous")
} else {
set document(title: title, author: authors.map(author => author.name))
}
set text(font: serif-font, size: 9pt)
// Custom small caps with dual sizing (hack for fonts without small caps)
// TODO: Remove when Typst implements synthetic small caps: https://github.com/typst/typst/issues/7009
let render-smallcaps(body) = {
let render-letter(letter) = {
if letter == upper(letter) {
text(size: 9pt, letter)
} else {
text(size: 7pt, upper(letter))
}
h(0.45pt) // hack to increase tracking
}
if body.has("text") {
for letter in body.text {
render-letter(letter)
}
} else if body.has("children") {
for part in body.children {
if part.has("text") {
for letter in part.text {
render-letter(letter)
}
} else [ ]
}
} else {
show smallcaps: set text(tracking: 0.45pt)
smallcaps(body)
}
}
// Configure links to use NavyBlue color and monospace font (matching LaTeX hyperref/url settings)
show link: it => {
set text(fill: rgb("#000080")) // NavyBlue (SVG color)
if type(it.dest) == str {
if narrow-doi and regex("https:\\/\\/doi\\.org\\/") in it.dest {
// DOI links should use narrow font if narrow-doi option is enabled
set text(font: narrow-font, stretch: 50%, size: 8pt)
it
} else {
// Other URLs should use monospace font like LaTeX \url{}
set text(font: mono-font, size: 8pt)
it
}
} else {
it
}
}
// Configure page
set page(
paper: paper-size,
margin: (
top: 51pt,
bottom: 54pt,
left: 54pt,
right: 54pt
),
header: if review {
context {
if calc.odd(counter(page).get().first()) {
align(center, emph([Online Submission ID: #submission-id]))
}
}
}
)
// Configure equations
set math.equation(numbering: "(1)")
show math.equation: set block(spacing: 0.65em)
// Configure references
show ref: it => {
set text(fill: rgb("#000080"))
if it.element != none and it.element.func() == math.equation {
link(it.element.location(), numbering(
it.element.numbering,
..counter(math.equation).at(it.element.location())
))
} else {
it
}
}
// Configure lists
set enum(indent: 10pt, body-indent: 9pt)
set list(indent: 10pt, body-indent: 9pt)
// Configure figures
set figure(gap: 10pt)
show figure.caption: it => {
set text(font: sans-serif-font, size: 8pt)
it
}
// Configure headings
set heading(numbering: (..n) => numbering("1.1.1", ..n) + h(4pt))
show heading: set text(font: sans-serif-font, size: 9pt, weight: "bold")
show heading.where(level: 1): it => {
let is-ack = it.body in ([Acknowledgments], [Acknowledgements])
set par(first-line-indent: 0pt)
block(above: 12pt, below: 7.2pt)[
#if it.numbering != none and not is-ack {
numbering("1", ..counter(heading).get())
h(7pt, weak: true)
}
#render-smallcaps(it.body)
]
}
show heading.where(level: 2): it => {
set par(first-line-indent: 0pt)
block(above: 12pt, below: 7.2pt, it)
}
show heading.where(level: 3): it => {
set par(first-line-indent: 0pt)
text(weight: "regular")[
#numbering("1.1.1", ..counter(heading).get())
#it.body
]
}
// Conference-specific: center captions and add spacing below figures
show figure.caption: set align(center)
show figure: it => {
it
v(8pt)
}
// Title
v(42pt, weak: true)
align(center, text(14pt, weight: "bold", title, font: sans-serif-font))
v(18pt, weak: true)
// Authors
if review {
align(center, text(10pt, font: sans-serif-font, [
Category: #category
]))
} else {
set par(leading: 0.4em)
align(center)[
#grid(
columns: authors.len(),
gutter: 1.5em,
..authors.map(author => [
#text(10pt, font: sans-serif-font)[
#author.name
#if "orcid" in author and author.orcid != "" {
link("https://orcid.org/" + author.orcid)[#box(height: 1.1em, baseline: 13.5%)[#pdf.artifact[#image("assets/orcid.svg")]]]
}
#if "email" in author {
footnote[#author.email]
}
]\
#text(8pt, font: sans-serif-font)[#author.organization]
])
)
]
}
v(18pt, weak: true)
// Teaser
if teaser != () {
[#figure(
teaser.image,
caption: teaser.caption,
) <teaser>]
v(10pt, weak: true)
}
// Two-column layout
show: show-target(paged: it => columns(2, gutter: 12.24pt)[#it])
set par(justify: true, first-line-indent: 1em, leading: 0.45em, spacing: 0.45em)
set text(font: serif-font, size: 9pt)
// Abstract
if abstract != none {
heading(level: 1, numbering: none)[Abstract]
set par(justify: true)
abstract
if index-terms != () {
parbreak()
set par(first-line-indent: 0pt)
text(weight: "bold")[Index Terms: ]
index-terms.join(", ")
}
v(10pt)
}
body
// Bibliography
if bibliography != none {
show std-bibliography: set text(8pt)
set std-bibliography(
title: text(font: sans-serif-font, size: 9pt, weight: "bold")[#render-smallcaps([References])],
style: "ieee-vgtc.csl"
)
bibliography
}
}
// This function gets your whole document as its `body` and formats
// it as a TVCG journal article.
#let journal(
// The paper's title.
title: [Paper Title],
// An array of authors. For each author you can specify a name,
// department, organization, location, and email.
// Everything but the name is optional.
authors: (),
// The paper's abstract.
abstract: none,
// Teaser image path and caption
teaser: (),
// A list of index terms to display after the abstract.
index-terms: (),
// The article's paper size. Also affects the margins.
paper-size: "us-letter",
// The result of a call to the `bibliography` function or `none`.
bibliography: none,
// Whether DOIs in the bibliography should be displayed in narrow font
narrow-doi: false,
// Review mode - hides authors and shows submission info
review: false,
// Submission ID (for review mode)
submission-id: 0,
// Category (for review mode)
category: none,
// Custom manuscript note (appears in footer of first page)
manuscript-note: none,
// The paper's content.
body
) = {
// Set document metadata.
if review {
set document(title: title, author: "Anonymous")
} else {
set document(title: title, author: authors.map(author => author.name))
}
// Set the body font.
set text(font: serif-font, size: 9pt)
// Custom small caps with dual sizing (hack for fonts without small caps)
// TODO: Remove when Typst implements synthetic small caps: https://github.com/typst/typst/issues/7009
let render-smallcaps(body) = {
let render-letter(letter) = {
if letter == upper(letter) {
text(size: 9pt, letter)
} else {
text(size: 7pt, upper(letter))
}
h(0.45pt) // hack to increase tracking
}
if body.has("text") {
for letter in body.text {
render-letter(letter)
}
} else if body.has("children") {
for part in body.children {
if part.has("text") {
for letter in part.text {
render-letter(letter)
}
} else [ ]
}
} else {
show smallcaps: set text(tracking: 0.45pt)
smallcaps(body)
}
}
// Configure links to use NavyBlue color and monospace font (matching LaTeX hyperref/url settings)
show link: it => {
set text(fill: rgb("#000080")) // NavyBlue (SVG color)
if type(it.dest) == str {
if narrow-doi and regex("https:\\/\\/doi\\.org\\/") in it.dest {
// DOI links should use narrow font if narrow-doi option is enabled
set text(font: narrow-font, stretch: 50%, size: 8pt)
it
} else {
// Other URLs should use monospace font like LaTeX \url{}
set text(font: mono-font, size: 8pt)
it
}
} else {
it
}
}
// Configure the page.
set page(
paper: paper-size,
margin: (
top: 54pt, // 0.75in
bottom: 45pt, // 0.625in
inside: 54pt, // 0.75in
outside: 45pt // 0.625in
),
header: if review {
context {
if calc.odd(counter(page).get().first()) {
align(center, emph([Online Submission ID: #submission-id]))
}
}
}
)
// Configure equations
set math.equation(numbering: "(1)")
show math.equation: set block(spacing: 0.65em)
// Configure references
show ref: it => {
set text(fill: rgb("#000080"))
if it.element != none and it.element.func() == math.equation {
link(it.element.location(), numbering(
it.element.numbering,
..counter(math.equation).at(it.element.location())
))
} else {
it
}
}
// Configure lists
set enum(indent: 10pt, body-indent: 9pt)
set list(indent: 10pt, body-indent: 9pt)
// Configure figures
set figure(gap: 10pt, supplement: "Fig.")
show figure.caption: it => {
set align(left)
set text(font: sans-serif-font, size: 8pt)
it
v(12pt)
}
// Configure headings
set heading(numbering: (..n) => numbering("1.1.1", ..n) + h(4pt))
show heading: set text(font: sans-serif-font, size: 9pt, weight: "bold")
show heading.where(level: 1): show-target(paged: it => {
let is-ack = it.body in ([Acknowledgments], [Acknowledgements])
set par(first-line-indent: 0pt)
if (counter(heading).get() == (1,)) {
// first heading is full width
place(
top + left,
float: true,
scope: "parent",
{
numbering("1", ..counter(heading).get())
h(9pt, weak: true)
render-smallcaps(it.body)
v(-6pt)
},
)
} else {
block(above: 14pt, below: 7.6pt, {
if it.numbering != none and not is-ack {
numbering("1", ..counter(heading).get())
h(9pt, weak: true)
}
render-smallcaps(it.body)
})
}
})
show heading.where(level: 2): it => {
set par(first-line-indent: 0pt)
block(above: 12pt, below: 7.2pt, it)
}
show heading.where(level: 3): it => {
set par(first-line-indent: 0pt)
show block: set text(weight: "regular")
block(above: 12pt, below: 7.2pt, it)
}
// Display the paper's title.
v(3pt, weak: true)
on-target(paged: align(center, text(18pt, title, font: sans-serif-font)), html: heading(numbering: none)[#title])
v(23pt, weak: true)
// Display the authors list or submission info (if review mode).
if review {
align(center, text(10pt, font: sans-serif-font, [
Category: #category
]))
} else {
let and-comma = if authors.len() == 2 {" and "} else {", and "}
align(center,
text(10pt, font: sans-serif-font, authors.map(author => {
author.name
if "orcid" in author and author.orcid != "" {
link("https://orcid.org/" + author.orcid)[#box(height: 1.1em, baseline: 13.5%)[#pdf.artifact[#image("assets/orcid.svg")]]]
}
} ).join(", ", last: and-comma)
)
)
}
v(6pt, weak: true)
block(inset: (left: 24pt, right: 24pt), [
// Insert teaser image
#figure(
teaser.image,
caption: teaser.caption,
) <teaser>
#v(10pt, weak: true)
// Display abstract and index terms.
// LaTeX uses \scriptsize (8pt with 9.5pt leading)
#(if abstract != none [
#set par(justify: true, leading: 0.45em,
justification-limits: (
tracking: (min: -0.01em, max: 0.02em),
)
)
#set text(font: sans-serif-font, size: 8pt)
#[*Abstract*---#abstract]
#if index-terms != () [
*Index terms*---#index-terms.join(", ")
]
]
)
]
)
v(10pt, weak: true)
align(center, pdf.artifact[#image("assets/diamondrule.svg", width: 40%)])
v(15pt, weak: true)
// Start two column mode and configure paragraph properties.
show: show-target(paged: it => columns(2, gutter: 12.24pt)[#it])
// LaTeX uses 9pt font with 10pt baseline skip
set par(justify: true, first-line-indent: 1em, leading: 0.45em, spacing: 0.45em,
justification-limits: (
tracking: (min: -0.01em, max: 0.02em),
)
)
// Footer with author info
if not review {
place(left+bottom, float: true, block(
width: 100%,[
#align(center, line(length: 50%, stroke: 0.4pt))
#set text(style: "italic", size: 7.5pt, font: serif-font)
#set list(indent: 0pt, body-indent: 5pt, spacing: 0.5em)
#for author in authors [
- #author.name is with #author.organization. #box(if "email" in author [E-mail: #author.email.])
]
#v(4pt)
#if manuscript-note != none [
#manuscript-note
] else [
Manuscript received DD MMM. YYYY; accepted DD MMM. YYYY.
Date of Publication DD MMM. YYYY; date of current version DD MMM. YYYY.
For information on obtaining reprints of this article, please send e-mail to: reprints`@`ieee.org.
Digital Object Identifier: xx.xxxx/TVCG.YYYY.xxxxxxx
]
]
)
)
}
set text(font: serif-font, size: 9pt)
body
if bibliography != none {
show std-bibliography: set text(8pt)
set std-bibliography(
title: text(font: sans-serif-font, size: 9pt, weight: "bold")[#render-smallcaps([References])],
style: "ieee-vgtc.csl"
)
bibliography
}
}