-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy pathtypst-template.typ
More file actions
144 lines (132 loc) · 3.5 KB
/
typst-template.typ
File metadata and controls
144 lines (132 loc) · 3.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
#let article(
title: none,
subtitle: none,
authors: none,
keywords: (),
date: none,
abstract-title: none,
abstract: none,
thanks: none,
cols: 1,
lang: "en",
region: "US",
font: none,
fontsize: 11pt,
title-size: 1.5em,
subtitle-size: 1.25em,
heading-family: none,
heading-weight: "bold",
heading-style: "normal",
heading-color: black,
heading-line-height: 0.65em,
mathfont: none,
codefont: none,
linestretch: 1,
sectionnumbering: none,
linkcolor: none,
citecolor: none,
filecolor: none,
toc: false,
toc_title: none,
toc_depth: none,
toc_indent: 1.5em,
doc,
) = {
// Set document metadata for PDF accessibility
set document(title: title, keywords: keywords)
set document(
author: authors.map(author => content-to-string(author.name)).join(", ", last: " & "),
) if authors != none and authors != ()
set par(
justify: true,
leading: linestretch * 0.65em
)
set text(lang: lang,
region: region,
size: fontsize)
set text(font: font) if font != none
show math.equation: set text(font: mathfont) if mathfont != none
show raw: set text(font: codefont) if codefont != none
set heading(numbering: sectionnumbering)
show link: set text(fill: rgb(content-to-string(linkcolor))) if linkcolor != none
show ref: set text(fill: rgb(content-to-string(citecolor))) if citecolor != none
show link: this => {
if filecolor != none and type(this.dest) == label {
text(this, fill: rgb(content-to-string(filecolor)))
} else {
text(this)
}
}
let has-title-block = title != none or (authors != none and authors != ()) or date != none or abstract != none
if has-title-block {
place(
top,
float: true,
scope: "parent",
clearance: 4mm,
block(below: 1em, width: 100%)[
#if title != none {
align(center, block(inset: 2em)[
#set par(leading: heading-line-height) if heading-line-height != none
#set text(font: heading-family) if heading-family != none
#set text(weight: heading-weight)
#set text(style: heading-style) if heading-style != "normal"
#set text(fill: heading-color) if heading-color != black
#text(size: title-size)[#title #if thanks != none {
footnote(thanks, numbering: "*")
counter(footnote).update(n => n - 1)
}]
#(if subtitle != none {
parbreak()
text(size: subtitle-size)[#subtitle]
})
])
}
#if authors != none and authors != () {
let count = authors.len()
let ncols = calc.min(count, 3)
grid(
columns: (1fr,) * ncols,
row-gutter: 1.5em,
..authors.map(author =>
align(center)[
#author.name \
#author.affiliation \
#author.email
]
)
)
}
#if date != none {
align(center)[#block(inset: 1em)[
#date
]]
}
#if abstract != none {
block(inset: 2em)[
#text(weight: "semibold")[#abstract-title] #h(1em) #abstract
]
}
]
)
}
if toc {
let title = if toc_title == none {
auto
} else {
toc_title
}
block(above: 0em, below: 2em)[
#outline(
title: toc_title,
depth: toc_depth,
indent: toc_indent
);
]
}
doc
}
#set table(
inset: 6pt,
stroke: none
)