phd-typst/template.typ

108 lines
2.3 KiB
Plaintext
Raw Normal View History

2023-05-02 16:57:14 +01:00
#let phd(doc) = {
2023-05-02 22:55:48 +01:00
set page(paper: "a4", numbering: "1")
2023-05-02 16:57:14 +01:00
2023-05-02 22:55:48 +01:00
set par(first-line-indent: 1em, justify: true, leading: 1em)
2023-05-02 16:57:14 +01:00
// 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 => {
2023-05-02 22:55:48 +01:00
v(0.5em)
2023-05-02 16:57:14 +01:00
content
2023-05-02 22:55:48 +01:00
v(0.38em)
2023-05-02 16:57:14 +01:00
}
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]
}
)
2023-05-02 22:55:48 +01:00
set heading(numbering: (..nums) => {
if nums.pos().len() >= 4 {
none
} else {
2023-05-11 10:59:37 +01:00
nums.pos().map(str).join(".")
2023-05-02 22:55:48 +01:00
}
})
2023-05-02 16:57:14 +01:00
show heading.where(level: 1): it => {
2024-07-09 10:45:16 +01:00
if it.numbering != none {
set page(header: [], footer: [])
align(right, {
v(100pt)
if it.numbering != none {
text(size: 50pt, weight: "bold")[Chapter ]
set heading(numbering: (..nums) => str(nums.pos().at(0)))
text(counter(heading).display(), size: 150pt, fill: rgb(173, 216, 230))
}
v(50pt)
text(it.body, size: 40pt, weight: "bold")
v(40pt)
})
} else {
align(right, {
v(100pt)
if it.numbering != none {
text(size: 50pt, weight: "bold")[Chapter ]
set heading(numbering: (..nums) => str(nums.pos().at(0)))
text(counter(heading).display(), size: 150pt, fill: rgb(173, 216, 230))
}
v(50pt)
text(it.body, size: 40pt, weight: "bold")
v(40pt)
})
}
2023-05-02 16:57:14 +01:00
}
2023-05-02 22:55:48 +01:00
show heading.where(level: 2): set text(size: 15pt)
show heading.where(level: 3): set text(size: 13pt)
2023-05-02 16:57:14 +01:00
doc
}
2023-05-11 10:59:37 +01:00
#let beforeChapter = () => {
2024-07-09 10:45:16 +01:00
pagebreak(to: "odd")
2023-05-11 10:59:37 +01:00
}
#let afterNumberedChapter = () => {
}