phd-typst/template.typ

79 lines
1.5 KiB
Plaintext
Raw Normal View History

2023-05-02 17:57:14 +02:00
#let phd(doc) = {
set page(paper: "a4")
set par(first-line-indent: 1em, justify: true, leading: 1em)
// Code formatting
show raw.where(block: true): it => {
set par(justify: false)
let split = it.text.split("\n")
let len = split.len()
grid(
columns: (100%, 100%),
column-gutter: -100%,
block(width: 100%, inset: 1em, for (i, line) in split.enumerate() {
if i != len - 1 {
box(width: 0pt, align(right, str(i + 1) + h(2em)))
hide(line)
linebreak()
}
}),
block(radius: 1em, fill: luma(246), width: 100%, inset: 1em, it),
)
}
show heading: content => {
content
v(1em)
}
show figure: content => {
content
v(1em)
}
show link: content => {
set text(fill: blue)
content
}
show cite: content => {
set text(fill: blue)
content
}
show ref: content => {
set text(fill: blue)
content
}
set heading(supplement: (..nums) =>
if (nums.pos().len() == 1) {
[Chapter]
} else {
[Section]
}
)
set heading(numbering: "1.1")
show heading.where(level: 1): it => {
align(right, {
v(100pt)
if it.numbering != none {
text(size: 50pt)[Chapter ]
text(counter(heading).display(), size: 150pt, fill: rgb(173, 216, 230))
}
v(50pt)
text(it.body, size: 40pt)
if it.numbering != none {
pagebreak()
} else {
v(40pt)
}
})
}
doc
}