phd-typst/template.typ

92 lines
1.9 KiB
Plaintext
Raw Normal View History

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