This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib.typ
123 lines (92 loc) · 2.88 KB
/
lib.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
#import "@preview/fontawesome:0.2.0": *
#import "@preview/codly:0.2.0": *
#import "@preview/drafting:0.2.0": *
#let link-icon = super[#fa-arrow-up-right-from-square()]
// Workaround for the lack of an `std` scope.
#let std-bibliography = bibliography
// This function gets your whole document as its `body` and formats
// it as an article in the style of the IEEE.
// Taken from https://github.com/typst/templates/tree/main/charged-ieee
#let template(
// 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
// but the name is optional.
authors: (),
// The paper's abstract. Can be omitted if you don't have one.
abstract: none,
preface: [Preface goes here],
// A list of index terms to display after the abstract.
index-terms: (),
// The result of a call to the `bibliography` function or `none`.
bibliography: none,
// The paper's content.
body
) = {
// Set document metadata.
set document(title: title, author: authors.map(author => author.name))
set text(font: "Noto Sans", lang: "en")
set heading(numbering: "1.1")
set figure(placement: auto)
show link: set text(style: "italic")
pagebreak()
// Configure the page.
set page(paper: "a4", margin: 2.5cm)
set align(center + horizon)
preface
set align(top + left)
pagebreak()
// Display abstract and index terms.
if abstract != none [
#set text(weight: 700)
#h(1em) _Abstract_---#h(weak: true, 0pt)#abstract
#if index-terms != () [
#h(1em)_Index terms_---#h(weak: true, 0pt)#index-terms.join(", ")
]
#v(2pt)
]
pagebreak()
// Table of contents.
outline(depth: 3, indent: true)
set par(leading: 10pt, justify: true)
show par: set block(above: 1em, below: 2em)
show figure: set block(breakable: true, below: 2em)
show figure.caption: emph
let icon(codepoint) = {
box(
height: 0.8em,
baseline: 0.05em,
image(codepoint)
)
h(0.1em)
}
show table.cell.where(y: 0): set text(weight: "bold")
let frame(stroke) = (x, y) => (
left: if x > 0 { 0pt } else { stroke },
right: stroke,
top: if y < 2 { stroke } else { 0pt },
bottom: stroke,
)
set table(
fill: (_, y) => if calc.odd(y) { rgb("EAF2F5") },
stroke: frame(rgb("21222C")),
)
show: codly-init.with()
codly(languages: (
tsv: (name: "TSV", icon: icon("images/tsv.png"), color: gray),
csv: (name: "CSV", icon: icon("images/csv.png"), color: gray),
))
set-page-properties()
show heading.where(level: 1): it => pagebreak(weak: true) + it
set page(numbering: "1")
counter(page).update(1)
// Display the paper's contents.
body
// Display bibliography.
if bibliography != none {
show std-bibliography: set text(8pt)
set std-bibliography(title: text(10pt)[References], style: "ieee")
bibliography
}
}