-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathheading.typ
144 lines (113 loc) · 2.56 KB
/
heading.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/***********************/
/* TEMPLATE DEFINITION */
/***********************/
#let apply(doc) = {
// Numbering parameters
set heading(numbering: "1.1 - ")
// H1 styling
show heading.where(level:1): he => {
set align(center)
box(width: 85%)[#{
set par(justify: false)
set text(
size: 20pt,
weight: "black",
fill: rgb("CE0037"),
font: "New Computer Modern Sans",
hyphenate: false
)
if type(he.numbering) == str {
counter(heading).display(he.numbering.slice(0, -3))
linebreak()
} else if he.numbering != none {
upper((he.numbering)(he.level).slice(0, -2))
linebreak()
}
upper(he.body)
image("assets/filet-long.svg", width: 30%)
v(0.5em)
}]
}
// H2 styling
show heading.where(level:2): he => {
box()[#{
set text(
size:20pt,
weight: "medium",
fill: rgb("00677F"),
)
smallcaps(he)
v(-0.5em)
image("assets/filet-court.svg")
}]
}
// H3 styling
show heading.where(level: 3): he => {
set text(
size: 16pt,
weight: "regular",
fill: rgb("01426A")
)
if type(he.numbering) == str {
counter(heading).display(he.numbering.slice(0, -3))
[ • ]
}
smallcaps(he.body)
}
// H4 styling
show heading.where(level: 4): he => {
counter(heading).display(he.numbering)
he.body
}
// Quick fix for paragraph indentation...
// Any superior entity who might be reading, please forgive me
show heading: he => {
set par(first-line-indent: 0pt)
he
}
// Don't forget to return doc cause
// we're in a template
doc
}
#let appendix(body, title: "Appendix") = {
counter(heading).update(0)
// From https://github.com/typst/typst/discussions/3630
set heading(
numbering: (..nums) => {
let vals = nums.pos()
let s = ""
if vals.len() == 1 {
s += title + " "
}
s += numbering("A.1 -", ..vals)
s
},
)
body
}
/********************/
/* TESTING TEMPLATE */
/********************/
#show: apply
#outline()
= My first section
== A sub-section
#heading(level: 2, numbering: none)[Sub-section without numbering]
#lorem(60)
=== No more ideas
==== Sometimes dummy text is
===== Really important
really ?
==== Back again
#heading(level: 3, numbering: none)[Sub-sub-section without numbering]
=== Guess who's back ?
#lorem(40)
= My second section
#lorem(30)
== Another one
#lorem(20)
#show: appendix.with(title: "Appendix")
= Some proofs
#lorem(50)
== Some theorem
#lorem(20)