Files
liteauthdocs/PageTemplate.typ

188 lines
4.2 KiB
Typst

#let thai-numbering(n) = {
let chars = ("ก", "ข", "ค", "ง", "จ", "ฉ", "ช")
if n <= chars.len() {
chars.at(n - 1)
} else {
str(n - chars.len()) // fallback to numbers if exceeds available characters
}
}
#let chapter-page(doc) = {
set page(
paper: "a4",
margin: (
top: 2in,
left: 1.5in,
right: 1in,
bottom: 1in,
),
header: none,
)
doc
}
/// Sane indentation
#let i = h(3em)
/// Insane shit forced upon by my teacher
/// For indenting in 3rd level subheadings
// #let iii = h(3em)
#let iii = h(5.5em)
/// For indenting in 4th level subheadings
// #let iiii = h(6em)
#let iiii = h(9.25em)
#let iiiii = h(13em)
#let iiiiii = h(16.85em)
#let page-theme(doc) = {
set page(
paper: "a4",
margin: (
top: 1.5in,
left: 1.5in,
right: 1in,
bottom: 1in,
),
header: context [
#h(1fr)
#counter(page).display(thai-numbering)
],
)
set text(
lang: "th",
font: "Laksaman",
size: 10.5pt,
)
set par(
justify: true,
justification-limits: (
tracking: (min: -1pt, max: 3pt),
),
leading: 1em,
)
set list(indent: 1em)
show raw.where(block: false): set text(font: "Laksaman", size: 10.5pt)
show raw.where(block: true): set block(
fill: rgb("#282A36"),
stroke: black + 2pt,
inset: 1.5em,
)
show raw.where(block: true): set raw(theme: "Dracula.tmTheme")
show raw.where(block: true): set text(
fill: rgb("#F8F8F2"),
font: "Cascadia Code",
size: 10pt,
)
show heading: set text(size: 10.5pt, weight: "regular")
show heading: set block(below: 1em)
show heading.where(level: 1): set text(size: 12pt, weight: "bold")
show heading.where(level: 1): set align(center)
show heading.where(level: 1): set block(below: 2em)
show heading.where(level: 2): set block(above: 2em)
show heading.where(level: 2): set text(weight: "bold")
show heading: it => {
if it.level > 2 {
block(
it,
inset: (left: 3em * (it.level - 2)),
)
} else {
it
}
}
show math.equation: set text(font: "Laksaman")
show table.cell.where(y: 0): strong
show image: it => {
block(stroke: black + 2pt, it)
}
show figure.where(kind: "i-figured-table"): set align(start)
show figure.where(kind: table): set figure.caption(position: top)
show figure.caption: it => {
text(weight: "bold")[
#it.supplement
#it.counter.display(it.numbering)
]
it.body
}
show figure.caption.where(position: bottom): it => place(center, it, dy: 2em)
set figure.caption(separator: "")
// show figure.where(kind: image): set figure(gap: 2em)
show figure.where(kind: image): set block(below: 2.5em)
set enum(number-align: start + top)
set ref(supplement: "หัวข้อ")
doc
}
#let fake-h1(body) = {
align(center, text(body, weight: "bold", size: 12pt))
}
#let sane-theme(doc) = {
set page(
paper: "a4",
margin: (
top: 1.5in,
left: 1.5in,
right: 1in,
bottom: 1in,
),
header: context [
#h(1fr)
#counter(page).display(thai-numbering)
],
)
set text(
lang: "th",
font: "Laksaman",
size: 10.5pt,
)
set par(
justify: true,
justification-limits: (
tracking: (min: -1pt, max: 3pt),
),
leading: 1em,
)
set list(indent: 1em)
show raw: set text(font: "Cascadia Code")
show heading: set text(size: 10.5pt)
show heading: set block(below: 1em)
show heading.where(level: 1): set text(size: 12pt, weight: "bold")
show heading.where(level: 1): set align(center)
show heading.where(level: 2): set text(weight: "bold")
show math.equation: set text(font: "Laksaman")
show table.cell.where(y: 0): strong
show figure.caption: it => {
text(weight: "bold")[
#it.supplement
#it.counter.display(it.numbering)
#it.separator
]
it.body
}
set figure.caption(separator: "")
set enum(number-align: start + top)
set ref(supplement: "หัวข้อ")
doc
}
// Figure with attribution information
#let afigure(
body,
attr: none,
..args,
) = [
#figure(body, ..args)
#box(
hide(attr),
width: 0pt,
height: 0pt,
) <afig>
]
#let jb = linebreak(justify: true)