/
template.typ
123 lines (113 loc) · 2.89 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
// The project function defines how your document looks.
// It takes your content and some metadata and formats it.
// Go ahead and customize it to your liking!
#let theme(title: "", authors: (), version: none, intro: [], toc: true, newpage: true, body) = {
// Set the document's basic properties.
set document(author: authors, title: title)
set page(numbering: none, number-align: center)
set text(font: "Avenir Next", lang: "en", size: 12pt, hyphenate: false)
set heading(numbering: "1.1")
// Title row.
align(center)[
#block(text(weight: 700, 1.75em, title))
#v(1em, weak: true)
#version
]
// Author information.
pad(
top: 0.5em,
bottom: 0.5em,
x: 2em,
grid(
columns: (1fr,) * calc.min(3, authors.len()),
gutter: 1em,
..authors.map(author => align(center, strong(author))),
),
)
if toc {
text(weight: "bold", size: 18pt, baseline: 12pt)[Contents]
outline(target: heading.where(numbering: "1.1"), depth: 1, title: none)
text(weight: "bold", size: 18pt, baseline: 12pt)[Appendices]
outline(target: heading.where(numbering: "A.1"), title: none, depth: 1)
}
if intro != [] {
heading(outlined: false, numbering: none, "Preface")
intro
}
// Main body.
set page(
header: locate(loc => {
if calc.rem(loc.page(), 2) == 0 {
align(left)[#emph(title)]
} else {
align(right)[#emph(title)]
}
}),
numbering: "1", number-align: center
)
let kwds_mapping = (
"set": "setz",
"and": "und",
"or": "oder",
"not": "nicht",
"if": "wenn",
"else": "sonst",
"match": "paaren",
"default": "default",
"iterate": "wieder",
"import": "importiere",
"while": "solange",
"def": "def",
"return": "rück",
"continue": "fortsetze",
"break": "brechen",
"as": "als",
"in": "in"
)
let kwds2_mapping = (
"pub": "öffentlich",
"alias": "alias",
"class": "klass",
"properties": "eigentum",
"enum": "gezählt",
"variants": "varianten",
"derived": "abgeleitet",
"extension": "extension",
"extend": "strecken",
"with": "mit",
)
let types_mapping = (
"int": "ganze",
"float": "gleit",
"bool": "bool",
"str": "str",
"list": "liste",
"map": "map",
"true": "wahr",
"false": "falsch"
)
let self_mapping = ("self": "selbst", "Self": "Selbst")
let mapping = (:..kwds_mapping, ..kwds2_mapping, ..types_mapping, ..self_mapping)
show raw.where(block: false): it => if it.lang == none { text(it) } else {
box(
fill: rgb("#1d2433"),
inset: (x: 3pt, y: 0pt),
outset: (y: 3pt),
radius: 2pt,
text(fill: rgb("#a2aabc"), it)
)
}
set raw(syntaxes: "fck-syntax.sublime-syntax", theme: "code-theme.tmTheme")
show raw.where(block: true): it => if it.lang == none { align(center, it) } else {
block(
fill: rgb("#1d2433"),
inset: 8pt,
radius: 5pt,
width: 100%,
align(left, text(fill: rgb("#a2aabc"), it))
)
}
// align(left) is a hack to make sure it's aligned left in figures
body
}
#import "prelude.typ": *